@stack0/sdk 0.2.9 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -381,6 +381,144 @@ var CDN = class {
381
381
  }
382
382
  return folder;
383
383
  }
384
+ // ============================================================================
385
+ // Video Transcoding Methods
386
+ // ============================================================================
387
+ /**
388
+ * Start a video transcoding job
389
+ *
390
+ * @example
391
+ * ```typescript
392
+ * const job = await cdn.transcode({
393
+ * projectSlug: 'my-project',
394
+ * assetId: 'video-asset-id',
395
+ * outputFormat: 'hls',
396
+ * variants: [
397
+ * { quality: '720p', codec: 'h264' },
398
+ * { quality: '1080p', codec: 'h264' },
399
+ * ],
400
+ * webhookUrl: 'https://your-app.com/webhook',
401
+ * });
402
+ * console.log(`Job started: ${job.id}`);
403
+ * ```
404
+ */
405
+ async transcode(request) {
406
+ const response = await this.http.post("/cdn/video/transcode", request);
407
+ return this.convertJobDates(response);
408
+ }
409
+ /**
410
+ * Get a transcoding job by ID
411
+ *
412
+ * @example
413
+ * ```typescript
414
+ * const job = await cdn.getJob('job-id');
415
+ * console.log(`Status: ${job.status}, Progress: ${job.progress}%`);
416
+ * ```
417
+ */
418
+ async getJob(jobId) {
419
+ const response = await this.http.get(`/cdn/video/jobs/${jobId}`);
420
+ return this.convertJobDates(response);
421
+ }
422
+ /**
423
+ * List transcoding jobs with filters
424
+ *
425
+ * @example
426
+ * ```typescript
427
+ * const { jobs, total } = await cdn.listJobs({
428
+ * projectSlug: 'my-project',
429
+ * status: 'processing',
430
+ * limit: 20,
431
+ * });
432
+ * ```
433
+ */
434
+ async listJobs(request) {
435
+ const params = new URLSearchParams();
436
+ params.set("projectSlug", request.projectSlug);
437
+ if (request.assetId) params.set("assetId", request.assetId);
438
+ if (request.status) params.set("status", request.status);
439
+ if (request.limit) params.set("limit", request.limit.toString());
440
+ if (request.offset) params.set("offset", request.offset.toString());
441
+ const response = await this.http.get(`/cdn/video/jobs?${params.toString()}`);
442
+ return {
443
+ ...response,
444
+ jobs: response.jobs.map((job) => this.convertJobDates(job))
445
+ };
446
+ }
447
+ /**
448
+ * Cancel a pending or processing transcoding job
449
+ *
450
+ * @example
451
+ * ```typescript
452
+ * await cdn.cancelJob('job-id');
453
+ * ```
454
+ */
455
+ async cancelJob(jobId) {
456
+ return this.http.post(`/cdn/video/jobs/${jobId}/cancel`, {});
457
+ }
458
+ /**
459
+ * Get streaming URLs for a transcoded video
460
+ *
461
+ * @example
462
+ * ```typescript
463
+ * const urls = await cdn.getStreamingUrls('asset-id');
464
+ * console.log(`HLS URL: ${urls.hlsUrl}`);
465
+ * console.log(`MP4 720p: ${urls.mp4Urls.find(u => u.quality === '720p')?.url}`);
466
+ * ```
467
+ */
468
+ async getStreamingUrls(assetId) {
469
+ return this.http.get(`/cdn/video/stream/${assetId}`);
470
+ }
471
+ /**
472
+ * Generate a thumbnail from a video at a specific timestamp
473
+ *
474
+ * @example
475
+ * ```typescript
476
+ * const thumbnail = await cdn.getThumbnail({
477
+ * assetId: 'video-asset-id',
478
+ * timestamp: 10.5, // 10.5 seconds into the video
479
+ * width: 320,
480
+ * format: 'webp',
481
+ * });
482
+ * console.log(`Thumbnail URL: ${thumbnail.url}`);
483
+ * ```
484
+ */
485
+ async getThumbnail(request) {
486
+ const params = new URLSearchParams();
487
+ params.set("timestamp", request.timestamp.toString());
488
+ if (request.width) params.set("width", request.width.toString());
489
+ if (request.format) params.set("format", request.format);
490
+ return this.http.get(
491
+ `/cdn/video/thumbnail/${request.assetId}?${params.toString()}`
492
+ );
493
+ }
494
+ /**
495
+ * Extract audio from a video file
496
+ *
497
+ * @example
498
+ * ```typescript
499
+ * const { jobId } = await cdn.extractAudio({
500
+ * projectSlug: 'my-project',
501
+ * assetId: 'video-asset-id',
502
+ * format: 'mp3',
503
+ * bitrate: 192,
504
+ * });
505
+ * ```
506
+ */
507
+ async extractAudio(request) {
508
+ return this.http.post("/cdn/video/extract-audio", request);
509
+ }
510
+ convertJobDates(job) {
511
+ if (typeof job.createdAt === "string") {
512
+ job.createdAt = new Date(job.createdAt);
513
+ }
514
+ if (job.startedAt && typeof job.startedAt === "string") {
515
+ job.startedAt = new Date(job.startedAt);
516
+ }
517
+ if (job.completedAt && typeof job.completedAt === "string") {
518
+ job.completedAt = new Date(job.completedAt);
519
+ }
520
+ return job;
521
+ }
384
522
  };
385
523
 
386
524
  // src/screenshots/client.ts
@@ -1713,12 +1851,321 @@ var Webdata = class {
1713
1851
  }
1714
1852
  };
1715
1853
 
1854
+ // src/integrations/client.ts
1855
+ var CRM = class {
1856
+ http;
1857
+ constructor(http) {
1858
+ this.http = http;
1859
+ }
1860
+ // Contacts
1861
+ async listContacts(connectionId, options) {
1862
+ const params = new URLSearchParams({ connectionId });
1863
+ if (options?.cursor) params.set("cursor", options.cursor);
1864
+ if (options?.limit) params.set("limit", String(options.limit));
1865
+ if (options?.sortBy) params.set("sortBy", options.sortBy);
1866
+ if (options?.sortOrder) params.set("sortOrder", options.sortOrder);
1867
+ return this.http.get(`/integrations/crm/contacts?${params}`);
1868
+ }
1869
+ async getContact(connectionId, id) {
1870
+ return this.http.get(`/integrations/crm/contacts/${id}?connectionId=${connectionId}`);
1871
+ }
1872
+ async createContact(connectionId, data) {
1873
+ return this.http.post("/integrations/crm/contacts", { connectionId, data });
1874
+ }
1875
+ async updateContact(connectionId, id, data) {
1876
+ return this.http.patch(`/integrations/crm/contacts/${id}`, { connectionId, data });
1877
+ }
1878
+ async deleteContact(connectionId, id) {
1879
+ return this.http.delete(`/integrations/crm/contacts/${id}?connectionId=${connectionId}`);
1880
+ }
1881
+ // Companies
1882
+ async listCompanies(connectionId, options) {
1883
+ const params = new URLSearchParams({ connectionId });
1884
+ if (options?.cursor) params.set("cursor", options.cursor);
1885
+ if (options?.limit) params.set("limit", String(options.limit));
1886
+ if (options?.sortBy) params.set("sortBy", options.sortBy);
1887
+ if (options?.sortOrder) params.set("sortOrder", options.sortOrder);
1888
+ return this.http.get(`/integrations/crm/companies?${params}`);
1889
+ }
1890
+ async getCompany(connectionId, id) {
1891
+ return this.http.get(`/integrations/crm/companies/${id}?connectionId=${connectionId}`);
1892
+ }
1893
+ async createCompany(connectionId, data) {
1894
+ return this.http.post("/integrations/crm/companies", { connectionId, data });
1895
+ }
1896
+ async updateCompany(connectionId, id, data) {
1897
+ return this.http.patch(`/integrations/crm/companies/${id}`, { connectionId, data });
1898
+ }
1899
+ async deleteCompany(connectionId, id) {
1900
+ return this.http.delete(`/integrations/crm/companies/${id}?connectionId=${connectionId}`);
1901
+ }
1902
+ // Deals
1903
+ async listDeals(connectionId, options) {
1904
+ const params = new URLSearchParams({ connectionId });
1905
+ if (options?.cursor) params.set("cursor", options.cursor);
1906
+ if (options?.limit) params.set("limit", String(options.limit));
1907
+ if (options?.sortBy) params.set("sortBy", options.sortBy);
1908
+ if (options?.sortOrder) params.set("sortOrder", options.sortOrder);
1909
+ return this.http.get(`/integrations/crm/deals?${params}`);
1910
+ }
1911
+ async getDeal(connectionId, id) {
1912
+ return this.http.get(`/integrations/crm/deals/${id}?connectionId=${connectionId}`);
1913
+ }
1914
+ async createDeal(connectionId, data) {
1915
+ return this.http.post("/integrations/crm/deals", { connectionId, data });
1916
+ }
1917
+ async updateDeal(connectionId, id, data) {
1918
+ return this.http.patch(`/integrations/crm/deals/${id}`, { connectionId, data });
1919
+ }
1920
+ async deleteDeal(connectionId, id) {
1921
+ return this.http.delete(`/integrations/crm/deals/${id}?connectionId=${connectionId}`);
1922
+ }
1923
+ };
1924
+ var Storage = class {
1925
+ http;
1926
+ constructor(http) {
1927
+ this.http = http;
1928
+ }
1929
+ // Files
1930
+ async listFiles(connectionId, folderId, options) {
1931
+ const params = new URLSearchParams({ connectionId });
1932
+ if (folderId) params.set("folderId", folderId);
1933
+ if (options?.cursor) params.set("cursor", options.cursor);
1934
+ if (options?.limit) params.set("limit", String(options.limit));
1935
+ return this.http.get(`/integrations/storage/files?${params}`);
1936
+ }
1937
+ async getFile(connectionId, id) {
1938
+ return this.http.get(`/integrations/storage/files/${id}?connectionId=${connectionId}`);
1939
+ }
1940
+ async uploadFile(connectionId, input) {
1941
+ const base64Data = input.data instanceof ArrayBuffer ? btoa(String.fromCharCode(...new Uint8Array(input.data))) : btoa(String.fromCharCode(...input.data));
1942
+ return this.http.post("/integrations/storage/files", {
1943
+ connectionId,
1944
+ name: input.name,
1945
+ mimeType: input.mimeType,
1946
+ data: base64Data,
1947
+ folderId: input.folderId
1948
+ });
1949
+ }
1950
+ async deleteFile(connectionId, id) {
1951
+ return this.http.delete(`/integrations/storage/files/${id}?connectionId=${connectionId}`);
1952
+ }
1953
+ async downloadFile(connectionId, id) {
1954
+ const response = await this.http.get(
1955
+ `/integrations/storage/files/${id}/download?connectionId=${connectionId}`
1956
+ );
1957
+ const binaryString = atob(response.data);
1958
+ const bytes = new Uint8Array(binaryString.length);
1959
+ for (let i = 0; i < binaryString.length; i++) {
1960
+ bytes[i] = binaryString.charCodeAt(i);
1961
+ }
1962
+ return {
1963
+ data: bytes.buffer,
1964
+ mimeType: response.mimeType,
1965
+ filename: response.filename
1966
+ };
1967
+ }
1968
+ // Folders
1969
+ async listFolders(connectionId, parentId, options) {
1970
+ const params = new URLSearchParams({ connectionId });
1971
+ if (parentId) params.set("parentId", parentId);
1972
+ if (options?.cursor) params.set("cursor", options.cursor);
1973
+ if (options?.limit) params.set("limit", String(options.limit));
1974
+ return this.http.get(`/integrations/storage/folders?${params}`);
1975
+ }
1976
+ async getFolder(connectionId, id) {
1977
+ return this.http.get(`/integrations/storage/folders/${id}?connectionId=${connectionId}`);
1978
+ }
1979
+ async createFolder(connectionId, data) {
1980
+ return this.http.post("/integrations/storage/folders", { connectionId, ...data });
1981
+ }
1982
+ async deleteFolder(connectionId, id) {
1983
+ return this.http.delete(`/integrations/storage/folders/${id}?connectionId=${connectionId}`);
1984
+ }
1985
+ };
1986
+ var Communication = class {
1987
+ http;
1988
+ constructor(http) {
1989
+ this.http = http;
1990
+ }
1991
+ // Channels
1992
+ async listChannels(connectionId, options) {
1993
+ const params = new URLSearchParams({ connectionId });
1994
+ if (options?.cursor) params.set("cursor", options.cursor);
1995
+ if (options?.limit) params.set("limit", String(options.limit));
1996
+ return this.http.get(`/integrations/communication/channels?${params}`);
1997
+ }
1998
+ async getChannel(connectionId, id) {
1999
+ return this.http.get(`/integrations/communication/channels/${id}?connectionId=${connectionId}`);
2000
+ }
2001
+ // Messages
2002
+ async listMessages(connectionId, channelId, options) {
2003
+ const params = new URLSearchParams({ connectionId, channelId });
2004
+ if (options?.cursor) params.set("cursor", options.cursor);
2005
+ if (options?.limit) params.set("limit", String(options.limit));
2006
+ return this.http.get(`/integrations/communication/messages?${params}`);
2007
+ }
2008
+ async sendMessage(connectionId, input) {
2009
+ return this.http.post("/integrations/communication/messages", { connectionId, ...input });
2010
+ }
2011
+ // Users
2012
+ async listUsers(connectionId, options) {
2013
+ const params = new URLSearchParams({ connectionId });
2014
+ if (options?.cursor) params.set("cursor", options.cursor);
2015
+ if (options?.limit) params.set("limit", String(options.limit));
2016
+ return this.http.get(`/integrations/communication/users?${params}`);
2017
+ }
2018
+ };
2019
+ var Productivity = class {
2020
+ http;
2021
+ constructor(http) {
2022
+ this.http = http;
2023
+ }
2024
+ // Documents
2025
+ async listDocuments(connectionId, parentId, options) {
2026
+ const params = new URLSearchParams({ connectionId });
2027
+ if (parentId) params.set("parentId", parentId);
2028
+ if (options?.cursor) params.set("cursor", options.cursor);
2029
+ if (options?.limit) params.set("limit", String(options.limit));
2030
+ return this.http.get(`/integrations/productivity/documents?${params}`);
2031
+ }
2032
+ async getDocument(connectionId, id) {
2033
+ return this.http.get(`/integrations/productivity/documents/${id}?connectionId=${connectionId}`);
2034
+ }
2035
+ async createDocument(connectionId, data) {
2036
+ return this.http.post("/integrations/productivity/documents", { connectionId, ...data });
2037
+ }
2038
+ async updateDocument(connectionId, id, data) {
2039
+ return this.http.patch(`/integrations/productivity/documents/${id}`, { connectionId, ...data });
2040
+ }
2041
+ // Tables
2042
+ async listTables(connectionId, options) {
2043
+ const params = new URLSearchParams({ connectionId });
2044
+ if (options?.cursor) params.set("cursor", options.cursor);
2045
+ if (options?.limit) params.set("limit", String(options.limit));
2046
+ return this.http.get(`/integrations/productivity/tables?${params}`);
2047
+ }
2048
+ async getTable(connectionId, id) {
2049
+ return this.http.get(`/integrations/productivity/tables/${id}?connectionId=${connectionId}`);
2050
+ }
2051
+ // Table Rows
2052
+ async listTableRows(connectionId, tableId, options) {
2053
+ const params = new URLSearchParams({ connectionId });
2054
+ if (options?.cursor) params.set("cursor", options.cursor);
2055
+ if (options?.limit) params.set("limit", String(options.limit));
2056
+ return this.http.get(`/integrations/productivity/tables/${tableId}/rows?${params}`);
2057
+ }
2058
+ async getTableRow(connectionId, tableId, rowId) {
2059
+ return this.http.get(
2060
+ `/integrations/productivity/tables/${tableId}/rows/${rowId}?connectionId=${connectionId}`
2061
+ );
2062
+ }
2063
+ async createTableRow(connectionId, tableId, data) {
2064
+ return this.http.post(`/integrations/productivity/tables/${tableId}/rows`, {
2065
+ connectionId,
2066
+ ...data
2067
+ });
2068
+ }
2069
+ async updateTableRow(connectionId, tableId, rowId, data) {
2070
+ return this.http.patch(`/integrations/productivity/tables/${tableId}/rows/${rowId}`, {
2071
+ connectionId,
2072
+ ...data
2073
+ });
2074
+ }
2075
+ async deleteTableRow(connectionId, tableId, rowId) {
2076
+ return this.http.delete(
2077
+ `/integrations/productivity/tables/${tableId}/rows/${rowId}?connectionId=${connectionId}`
2078
+ );
2079
+ }
2080
+ };
2081
+ var Integrations = class {
2082
+ http;
2083
+ crm;
2084
+ storage;
2085
+ communication;
2086
+ productivity;
2087
+ constructor(config) {
2088
+ this.http = new HttpClient(config);
2089
+ this.crm = new CRM(this.http);
2090
+ this.storage = new Storage(this.http);
2091
+ this.communication = new Communication(this.http);
2092
+ this.productivity = new Productivity(this.http);
2093
+ }
2094
+ // ============================================================================
2095
+ // CONNECTORS
2096
+ // ============================================================================
2097
+ /**
2098
+ * List all available connectors
2099
+ */
2100
+ async listConnectors(category) {
2101
+ const params = category ? `?category=${category}` : "";
2102
+ return this.http.get(`/integrations/connectors${params}`);
2103
+ }
2104
+ /**
2105
+ * Get a specific connector
2106
+ */
2107
+ async getConnector(slug) {
2108
+ return this.http.get(`/integrations/connectors/${slug}`);
2109
+ }
2110
+ // ============================================================================
2111
+ // CONNECTIONS
2112
+ // ============================================================================
2113
+ /**
2114
+ * List all connections
2115
+ */
2116
+ async listConnections(options) {
2117
+ const params = new URLSearchParams();
2118
+ if (options?.connectorId) params.set("connectorId", options.connectorId);
2119
+ if (options?.status) params.set("status", options.status);
2120
+ const queryString = params.toString();
2121
+ return this.http.get(`/integrations/connections${queryString ? `?${queryString}` : ""}`);
2122
+ }
2123
+ /**
2124
+ * Get a specific connection
2125
+ */
2126
+ async getConnection(id) {
2127
+ return this.http.get(`/integrations/connections/${id}`);
2128
+ }
2129
+ /**
2130
+ * Create a new connection (initiates OAuth flow)
2131
+ * Returns the OAuth authorization URL to redirect the user to
2132
+ */
2133
+ async createConnection(connectorSlug, options) {
2134
+ return this.http.post("/integrations/connections", {
2135
+ connectorSlug,
2136
+ ...options
2137
+ });
2138
+ }
2139
+ /**
2140
+ * Delete a connection
2141
+ */
2142
+ async deleteConnection(id) {
2143
+ return this.http.delete(`/integrations/connections/${id}`);
2144
+ }
2145
+ /**
2146
+ * Test a connection's credentials
2147
+ */
2148
+ async testConnection(id) {
2149
+ return this.http.post(`/integrations/connections/${id}/test`, {});
2150
+ }
2151
+ // ============================================================================
2152
+ // PASSTHROUGH
2153
+ // ============================================================================
2154
+ /**
2155
+ * Make a raw passthrough request to the provider API
2156
+ */
2157
+ async passthrough(request) {
2158
+ return this.http.post("/integrations/passthrough", request);
2159
+ }
2160
+ };
2161
+
1716
2162
  // src/index.ts
1717
2163
  var Stack0 = class {
1718
2164
  mail;
1719
2165
  cdn;
1720
2166
  screenshots;
1721
2167
  extraction;
2168
+ integrations;
1722
2169
  /**
1723
2170
  * @deprecated Use `screenshots` and `extraction` instead. Will be removed in a future version.
1724
2171
  */
@@ -1732,11 +2179,12 @@ var Stack0 = class {
1732
2179
  this.cdn = new CDN(clientConfig);
1733
2180
  this.screenshots = new Screenshots(clientConfig);
1734
2181
  this.extraction = new Extraction(clientConfig);
2182
+ this.integrations = new Integrations(clientConfig);
1735
2183
  this.webdata = new Webdata(clientConfig);
1736
2184
  }
1737
2185
  };
1738
2186
  var src_default = Stack0;
1739
2187
 
1740
- export { CDN, Extraction, Mail, Screenshots, Stack0, Webdata, src_default as default };
2188
+ export { CDN, Extraction, Integrations, Mail, Screenshots, Stack0, Webdata, src_default as default };
1741
2189
  //# sourceMappingURL=index.mjs.map
1742
2190
  //# sourceMappingURL=index.mjs.map