@stack0/sdk 0.5.2 → 0.5.4
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/cdn/index.d.mts +244 -1
- package/dist/cdn/index.d.ts +244 -1
- package/dist/cdn/index.js +218 -0
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/index.mjs +218 -0
- package/dist/cdn/index.mjs.map +1 -1
- package/dist/extraction/index.d.mts +25 -1
- package/dist/extraction/index.d.ts +25 -1
- package/dist/extraction/index.js +22 -0
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/index.mjs +22 -0
- package/dist/extraction/index.mjs.map +1 -1
- package/dist/index.d.mts +697 -23
- package/dist/index.d.ts +697 -23
- package/dist/index.js +833 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +833 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1598,6 +1598,224 @@ var CDN = class {
|
|
|
1598
1598
|
}
|
|
1599
1599
|
return bundle;
|
|
1600
1600
|
}
|
|
1601
|
+
// ============================================================================
|
|
1602
|
+
// Usage Methods
|
|
1603
|
+
// ============================================================================
|
|
1604
|
+
/**
|
|
1605
|
+
* Get current usage stats for the billing period
|
|
1606
|
+
*
|
|
1607
|
+
* @example
|
|
1608
|
+
* ```typescript
|
|
1609
|
+
* const usage = await cdn.getUsage({
|
|
1610
|
+
* projectSlug: 'my-project',
|
|
1611
|
+
* });
|
|
1612
|
+
* console.log(`Bandwidth: ${usage.bandwidthFormatted}`);
|
|
1613
|
+
* console.log(`Estimated cost: ${usage.estimatedCostFormatted}`);
|
|
1614
|
+
* ```
|
|
1615
|
+
*/
|
|
1616
|
+
async getUsage(request = {}) {
|
|
1617
|
+
const params = new URLSearchParams();
|
|
1618
|
+
if (request.projectSlug) params.set("projectSlug", request.projectSlug);
|
|
1619
|
+
if (request.environment) params.set("environment", request.environment);
|
|
1620
|
+
if (request.periodStart) {
|
|
1621
|
+
const date = request.periodStart instanceof Date ? request.periodStart.toISOString() : request.periodStart;
|
|
1622
|
+
params.set("periodStart", date);
|
|
1623
|
+
}
|
|
1624
|
+
if (request.periodEnd) {
|
|
1625
|
+
const date = request.periodEnd instanceof Date ? request.periodEnd.toISOString() : request.periodEnd;
|
|
1626
|
+
params.set("periodEnd", date);
|
|
1627
|
+
}
|
|
1628
|
+
const query = params.toString();
|
|
1629
|
+
const response = await this.http.get(`/cdn/usage${query ? `?${query}` : ""}`);
|
|
1630
|
+
return this.convertUsageDates(response);
|
|
1631
|
+
}
|
|
1632
|
+
/**
|
|
1633
|
+
* Get usage history (time series data for charts)
|
|
1634
|
+
*
|
|
1635
|
+
* @example
|
|
1636
|
+
* ```typescript
|
|
1637
|
+
* const history = await cdn.getUsageHistory({
|
|
1638
|
+
* projectSlug: 'my-project',
|
|
1639
|
+
* days: 30,
|
|
1640
|
+
* });
|
|
1641
|
+
* console.log(`Total requests: ${history.totals.requests}`);
|
|
1642
|
+
* ```
|
|
1643
|
+
*/
|
|
1644
|
+
async getUsageHistory(request = {}) {
|
|
1645
|
+
const params = new URLSearchParams();
|
|
1646
|
+
if (request.projectSlug) params.set("projectSlug", request.projectSlug);
|
|
1647
|
+
if (request.environment) params.set("environment", request.environment);
|
|
1648
|
+
if (request.days) params.set("days", request.days.toString());
|
|
1649
|
+
if (request.granularity) params.set("granularity", request.granularity);
|
|
1650
|
+
const query = params.toString();
|
|
1651
|
+
const response = await this.http.get(`/cdn/usage/history${query ? `?${query}` : ""}`);
|
|
1652
|
+
return {
|
|
1653
|
+
...response,
|
|
1654
|
+
data: response.data.map((point) => this.convertUsageDataPointDates(point))
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Get storage breakdown by type or folder
|
|
1659
|
+
*
|
|
1660
|
+
* @example
|
|
1661
|
+
* ```typescript
|
|
1662
|
+
* const breakdown = await cdn.getStorageBreakdown({
|
|
1663
|
+
* projectSlug: 'my-project',
|
|
1664
|
+
* groupBy: 'type',
|
|
1665
|
+
* });
|
|
1666
|
+
* breakdown.items.forEach(item => {
|
|
1667
|
+
* console.log(`${item.key}: ${item.sizeFormatted} (${item.percentage}%)`);
|
|
1668
|
+
* });
|
|
1669
|
+
* ```
|
|
1670
|
+
*/
|
|
1671
|
+
async getStorageBreakdown(request = {}) {
|
|
1672
|
+
const params = new URLSearchParams();
|
|
1673
|
+
if (request.projectSlug) params.set("projectSlug", request.projectSlug);
|
|
1674
|
+
if (request.environment) params.set("environment", request.environment);
|
|
1675
|
+
if (request.groupBy) params.set("groupBy", request.groupBy);
|
|
1676
|
+
const query = params.toString();
|
|
1677
|
+
return this.http.get(`/cdn/usage/storage-breakdown${query ? `?${query}` : ""}`);
|
|
1678
|
+
}
|
|
1679
|
+
convertUsageDates(usage) {
|
|
1680
|
+
if (typeof usage.periodStart === "string") {
|
|
1681
|
+
usage.periodStart = new Date(usage.periodStart);
|
|
1682
|
+
}
|
|
1683
|
+
if (typeof usage.periodEnd === "string") {
|
|
1684
|
+
usage.periodEnd = new Date(usage.periodEnd);
|
|
1685
|
+
}
|
|
1686
|
+
return usage;
|
|
1687
|
+
}
|
|
1688
|
+
convertUsageDataPointDates(point) {
|
|
1689
|
+
if (typeof point.timestamp === "string") {
|
|
1690
|
+
point.timestamp = new Date(point.timestamp);
|
|
1691
|
+
}
|
|
1692
|
+
return point;
|
|
1693
|
+
}
|
|
1694
|
+
// ============================================================================
|
|
1695
|
+
// Additional Folder Methods
|
|
1696
|
+
// ============================================================================
|
|
1697
|
+
/**
|
|
1698
|
+
* Get a folder by ID
|
|
1699
|
+
*
|
|
1700
|
+
* @example
|
|
1701
|
+
* ```typescript
|
|
1702
|
+
* const folder = await cdn.getFolder('folder-id');
|
|
1703
|
+
* console.log(`Folder: ${folder.name}, Assets: ${folder.assetCount}`);
|
|
1704
|
+
* ```
|
|
1705
|
+
*/
|
|
1706
|
+
async getFolder(id) {
|
|
1707
|
+
const response = await this.http.get(`/cdn/folders/${id}`);
|
|
1708
|
+
return this.convertFolderDates(response);
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Get a folder by its path
|
|
1712
|
+
*
|
|
1713
|
+
* @example
|
|
1714
|
+
* ```typescript
|
|
1715
|
+
* const folder = await cdn.getFolderByPath('/images/avatars');
|
|
1716
|
+
* ```
|
|
1717
|
+
*/
|
|
1718
|
+
async getFolderByPath(path) {
|
|
1719
|
+
const encodedPath = encodeURIComponent(path);
|
|
1720
|
+
const response = await this.http.get(`/cdn/folders/path/${encodedPath}`);
|
|
1721
|
+
return this.convertFolderDates(response);
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* Update a folder's name
|
|
1725
|
+
*
|
|
1726
|
+
* @example
|
|
1727
|
+
* ```typescript
|
|
1728
|
+
* const folder = await cdn.updateFolder({
|
|
1729
|
+
* id: 'folder-id',
|
|
1730
|
+
* name: 'New Folder Name',
|
|
1731
|
+
* });
|
|
1732
|
+
* ```
|
|
1733
|
+
*/
|
|
1734
|
+
async updateFolder(request) {
|
|
1735
|
+
const { id, ...data } = request;
|
|
1736
|
+
const response = await this.http.patch(`/cdn/folders/${id}`, data);
|
|
1737
|
+
return this.convertFolderDates(response);
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* List folders with optional filters
|
|
1741
|
+
*
|
|
1742
|
+
* @example
|
|
1743
|
+
* ```typescript
|
|
1744
|
+
* const { folders, total } = await cdn.listFolders({
|
|
1745
|
+
* parentId: null, // root level
|
|
1746
|
+
* limit: 50,
|
|
1747
|
+
* });
|
|
1748
|
+
* ```
|
|
1749
|
+
*/
|
|
1750
|
+
async listFolders(request = {}) {
|
|
1751
|
+
const params = new URLSearchParams();
|
|
1752
|
+
if (request.parentId !== void 0) params.set("parentId", request.parentId ?? "");
|
|
1753
|
+
if (request.limit) params.set("limit", request.limit.toString());
|
|
1754
|
+
if (request.offset) params.set("offset", request.offset.toString());
|
|
1755
|
+
if (request.search) params.set("search", request.search);
|
|
1756
|
+
const query = params.toString();
|
|
1757
|
+
const response = await this.http.get(`/cdn/folders${query ? `?${query}` : ""}`);
|
|
1758
|
+
return {
|
|
1759
|
+
...response,
|
|
1760
|
+
folders: response.folders.map((folder) => this.convertFolderListItemDates(folder))
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Move a folder to a new parent
|
|
1765
|
+
*
|
|
1766
|
+
* @example
|
|
1767
|
+
* ```typescript
|
|
1768
|
+
* await cdn.moveFolder({
|
|
1769
|
+
* id: 'folder-id',
|
|
1770
|
+
* newParentId: 'new-parent-id', // or null for root
|
|
1771
|
+
* });
|
|
1772
|
+
* ```
|
|
1773
|
+
*/
|
|
1774
|
+
async moveFolder(request) {
|
|
1775
|
+
return this.http.post("/cdn/folders/move", request);
|
|
1776
|
+
}
|
|
1777
|
+
convertFolderListItemDates(folder) {
|
|
1778
|
+
if (typeof folder.createdAt === "string") {
|
|
1779
|
+
folder.createdAt = new Date(folder.createdAt);
|
|
1780
|
+
}
|
|
1781
|
+
return folder;
|
|
1782
|
+
}
|
|
1783
|
+
// ============================================================================
|
|
1784
|
+
// Additional Video Methods
|
|
1785
|
+
// ============================================================================
|
|
1786
|
+
/**
|
|
1787
|
+
* List all thumbnails for a video asset
|
|
1788
|
+
*
|
|
1789
|
+
* @example
|
|
1790
|
+
* ```typescript
|
|
1791
|
+
* const { thumbnails } = await cdn.listThumbnails('video-asset-id');
|
|
1792
|
+
* thumbnails.forEach(thumb => {
|
|
1793
|
+
* console.log(`${thumb.timestamp}s: ${thumb.url}`);
|
|
1794
|
+
* });
|
|
1795
|
+
* ```
|
|
1796
|
+
*/
|
|
1797
|
+
async listThumbnails(assetId) {
|
|
1798
|
+
const response = await this.http.get(`/cdn/video/${assetId}/thumbnails`);
|
|
1799
|
+
return response;
|
|
1800
|
+
}
|
|
1801
|
+
// ============================================================================
|
|
1802
|
+
// Additional Private Files Methods
|
|
1803
|
+
// ============================================================================
|
|
1804
|
+
/**
|
|
1805
|
+
* Move private files to a different folder
|
|
1806
|
+
*
|
|
1807
|
+
* @example
|
|
1808
|
+
* ```typescript
|
|
1809
|
+
* const result = await cdn.movePrivateFiles({
|
|
1810
|
+
* fileIds: ['file-1', 'file-2'],
|
|
1811
|
+
* folder: '/confidential/archive',
|
|
1812
|
+
* });
|
|
1813
|
+
* console.log(`Moved ${result.movedCount} files`);
|
|
1814
|
+
* ```
|
|
1815
|
+
*/
|
|
1816
|
+
async movePrivateFiles(request) {
|
|
1817
|
+
return this.http.post("/cdn/private/move", request);
|
|
1818
|
+
}
|
|
1601
1819
|
};
|
|
1602
1820
|
|
|
1603
1821
|
// src/screenshots/client.ts
|
|
@@ -2274,6 +2492,28 @@ var Extraction = class {
|
|
|
2274
2492
|
const response = await this.http.get(`/webdata/usage${query ? `?${query}` : ""}`);
|
|
2275
2493
|
return this.convertUsageDates(response);
|
|
2276
2494
|
}
|
|
2495
|
+
/**
|
|
2496
|
+
* Get daily usage breakdown
|
|
2497
|
+
*
|
|
2498
|
+
* @example
|
|
2499
|
+
* ```typescript
|
|
2500
|
+
* const { days } = await extraction.getUsageDaily({
|
|
2501
|
+
* periodStart: '2024-01-01T00:00:00Z',
|
|
2502
|
+
* periodEnd: '2024-01-31T23:59:59Z',
|
|
2503
|
+
* });
|
|
2504
|
+
* days.forEach(day => {
|
|
2505
|
+
* console.log(`${day.date}: ${day.screenshots} screenshots, ${day.extractions} extractions`);
|
|
2506
|
+
* });
|
|
2507
|
+
* ```
|
|
2508
|
+
*/
|
|
2509
|
+
async getUsageDaily(request = {}) {
|
|
2510
|
+
const params = new URLSearchParams();
|
|
2511
|
+
if (request.environment) params.set("environment", request.environment);
|
|
2512
|
+
if (request.periodStart) params.set("periodStart", request.periodStart);
|
|
2513
|
+
if (request.periodEnd) params.set("periodEnd", request.periodEnd);
|
|
2514
|
+
const query = params.toString();
|
|
2515
|
+
return this.http.get(`/webdata/usage/daily${query ? `?${query}` : ""}`);
|
|
2516
|
+
}
|
|
2277
2517
|
// ==========================================================================
|
|
2278
2518
|
// HELPERS
|
|
2279
2519
|
// ==========================================================================
|
|
@@ -3206,41 +3446,150 @@ var Integrations = class {
|
|
|
3206
3446
|
// ============================================================================
|
|
3207
3447
|
/**
|
|
3208
3448
|
* List all connections
|
|
3449
|
+
*
|
|
3450
|
+
* @example
|
|
3451
|
+
* ```typescript
|
|
3452
|
+
* const { connections } = await integrations.listConnections({
|
|
3453
|
+
* environment: 'production',
|
|
3454
|
+
* status: 'connected',
|
|
3455
|
+
* });
|
|
3456
|
+
* ```
|
|
3209
3457
|
*/
|
|
3210
|
-
async listConnections(
|
|
3458
|
+
async listConnections(request) {
|
|
3211
3459
|
const params = new URLSearchParams();
|
|
3212
|
-
if (
|
|
3213
|
-
if (
|
|
3460
|
+
if (request?.projectId) params.set("projectId", request.projectId);
|
|
3461
|
+
if (request?.environment) params.set("environment", request.environment);
|
|
3462
|
+
if (request?.connectorSlug) params.set("connectorSlug", request.connectorSlug);
|
|
3463
|
+
if (request?.status) params.set("status", request.status);
|
|
3464
|
+
if (request?.limit) params.set("limit", request.limit.toString());
|
|
3214
3465
|
const queryString = params.toString();
|
|
3215
|
-
|
|
3466
|
+
const response = await this.http.get(
|
|
3467
|
+
`/integrations/connections${queryString ? `?${queryString}` : ""}`
|
|
3468
|
+
);
|
|
3469
|
+
return {
|
|
3470
|
+
...response,
|
|
3471
|
+
connections: response.connections.map((c) => this.convertConnectionDates(c))
|
|
3472
|
+
};
|
|
3216
3473
|
}
|
|
3217
3474
|
/**
|
|
3218
3475
|
* Get a specific connection
|
|
3219
3476
|
*/
|
|
3220
|
-
async getConnection(
|
|
3221
|
-
|
|
3477
|
+
async getConnection(connectionId) {
|
|
3478
|
+
const response = await this.http.get(`/integrations/connections/${connectionId}`);
|
|
3479
|
+
return this.convertConnectionDetailsDates(response);
|
|
3222
3480
|
}
|
|
3223
3481
|
/**
|
|
3224
|
-
*
|
|
3225
|
-
*
|
|
3482
|
+
* Initiate OAuth flow for a connector
|
|
3483
|
+
*
|
|
3484
|
+
* @example
|
|
3485
|
+
* ```typescript
|
|
3486
|
+
* const { authUrl, connectionId, state } = await integrations.initiateOAuth({
|
|
3487
|
+
* connectorSlug: 'hubspot',
|
|
3488
|
+
* redirectUrl: 'https://yourapp.com/oauth/callback',
|
|
3489
|
+
* name: 'My HubSpot Connection',
|
|
3490
|
+
* });
|
|
3491
|
+
* // Redirect user to authUrl
|
|
3492
|
+
* ```
|
|
3226
3493
|
*/
|
|
3227
|
-
async
|
|
3228
|
-
return this.http.post("/integrations/connections",
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3494
|
+
async initiateOAuth(request) {
|
|
3495
|
+
return this.http.post("/integrations/connections/oauth/initiate", request);
|
|
3496
|
+
}
|
|
3497
|
+
/**
|
|
3498
|
+
* Complete OAuth flow with callback data
|
|
3499
|
+
*
|
|
3500
|
+
* @example
|
|
3501
|
+
* ```typescript
|
|
3502
|
+
* const result = await integrations.completeOAuth({
|
|
3503
|
+
* code: 'auth_code_from_callback',
|
|
3504
|
+
* state: 'state_from_initiate',
|
|
3505
|
+
* redirectUrl: 'https://yourapp.com/oauth/callback',
|
|
3506
|
+
* });
|
|
3507
|
+
* console.log(`Connected to: ${result.externalAccountName}`);
|
|
3508
|
+
* ```
|
|
3509
|
+
*/
|
|
3510
|
+
async completeOAuth(request) {
|
|
3511
|
+
return this.http.post("/integrations/connections/oauth/callback", request);
|
|
3512
|
+
}
|
|
3513
|
+
/**
|
|
3514
|
+
* Update a connection
|
|
3515
|
+
*/
|
|
3516
|
+
async updateConnection(request) {
|
|
3517
|
+
const { connectionId, ...data } = request;
|
|
3518
|
+
return this.http.patch(`/integrations/connections/${connectionId}`, data);
|
|
3232
3519
|
}
|
|
3233
3520
|
/**
|
|
3234
3521
|
* Delete a connection
|
|
3235
3522
|
*/
|
|
3236
|
-
async deleteConnection(
|
|
3237
|
-
return this.http.delete(`/integrations/connections/${
|
|
3523
|
+
async deleteConnection(connectionId) {
|
|
3524
|
+
return this.http.delete(`/integrations/connections/${connectionId}`);
|
|
3238
3525
|
}
|
|
3239
3526
|
/**
|
|
3240
|
-
*
|
|
3527
|
+
* Reconnect an expired or errored connection
|
|
3528
|
+
*
|
|
3529
|
+
* @example
|
|
3530
|
+
* ```typescript
|
|
3531
|
+
* const { authUrl, state } = await integrations.reconnectConnection({
|
|
3532
|
+
* connectionId: 'conn_123',
|
|
3533
|
+
* redirectUrl: 'https://yourapp.com/oauth/callback',
|
|
3534
|
+
* });
|
|
3535
|
+
* // Redirect user to authUrl
|
|
3536
|
+
* ```
|
|
3537
|
+
*/
|
|
3538
|
+
async reconnectConnection(request) {
|
|
3539
|
+
return this.http.post(
|
|
3540
|
+
`/integrations/connections/${request.connectionId}/reconnect`,
|
|
3541
|
+
{ redirectUrl: request.redirectUrl }
|
|
3542
|
+
);
|
|
3543
|
+
}
|
|
3544
|
+
/**
|
|
3545
|
+
* Get integration statistics
|
|
3546
|
+
*
|
|
3547
|
+
* @example
|
|
3548
|
+
* ```typescript
|
|
3549
|
+
* const stats = await integrations.getStats({ environment: 'production' });
|
|
3550
|
+
* console.log(`Active connections: ${stats.activeConnections}`);
|
|
3551
|
+
* console.log(`API calls last 30 days: ${stats.apiCallsLast30Days}`);
|
|
3552
|
+
* ```
|
|
3241
3553
|
*/
|
|
3242
|
-
async
|
|
3243
|
-
|
|
3554
|
+
async getStats(request) {
|
|
3555
|
+
const params = new URLSearchParams();
|
|
3556
|
+
if (request?.environment) params.set("environment", request.environment);
|
|
3557
|
+
const queryString = params.toString();
|
|
3558
|
+
return this.http.get(
|
|
3559
|
+
`/integrations/connections/stats${queryString ? `?${queryString}` : ""}`
|
|
3560
|
+
);
|
|
3561
|
+
}
|
|
3562
|
+
// ============================================================================
|
|
3563
|
+
// LOGS
|
|
3564
|
+
// ============================================================================
|
|
3565
|
+
/**
|
|
3566
|
+
* List API logs
|
|
3567
|
+
*
|
|
3568
|
+
* @example
|
|
3569
|
+
* ```typescript
|
|
3570
|
+
* const { logs } = await integrations.listLogs({
|
|
3571
|
+
* connectionId: 'conn_123',
|
|
3572
|
+
* limit: 50,
|
|
3573
|
+
* });
|
|
3574
|
+
* ```
|
|
3575
|
+
*/
|
|
3576
|
+
async listLogs(request) {
|
|
3577
|
+
const params = new URLSearchParams();
|
|
3578
|
+
if (request?.connectionId) params.set("connectionId", request.connectionId);
|
|
3579
|
+
if (request?.connectorSlug) params.set("connectorSlug", request.connectorSlug);
|
|
3580
|
+
if (request?.statusCode) params.set("statusCode", request.statusCode.toString());
|
|
3581
|
+
if (request?.method) params.set("method", request.method);
|
|
3582
|
+
if (request?.search) params.set("search", request.search);
|
|
3583
|
+
if (request?.limit) params.set("limit", request.limit.toString());
|
|
3584
|
+
if (request?.cursor) params.set("cursor", request.cursor);
|
|
3585
|
+
const queryString = params.toString();
|
|
3586
|
+
const response = await this.http.get(
|
|
3587
|
+
`/integrations/logs${queryString ? `?${queryString}` : ""}`
|
|
3588
|
+
);
|
|
3589
|
+
return {
|
|
3590
|
+
...response,
|
|
3591
|
+
logs: response.logs.map((log) => this.convertLogDates(log))
|
|
3592
|
+
};
|
|
3244
3593
|
}
|
|
3245
3594
|
// ============================================================================
|
|
3246
3595
|
// PASSTHROUGH
|
|
@@ -3251,6 +3600,45 @@ var Integrations = class {
|
|
|
3251
3600
|
async passthrough(request) {
|
|
3252
3601
|
return this.http.post("/integrations/passthrough", request);
|
|
3253
3602
|
}
|
|
3603
|
+
// ============================================================================
|
|
3604
|
+
// Date Conversion Helpers
|
|
3605
|
+
// ============================================================================
|
|
3606
|
+
convertConnectionDates(connection) {
|
|
3607
|
+
if (connection.connectedAt && typeof connection.connectedAt === "string") {
|
|
3608
|
+
connection.connectedAt = new Date(connection.connectedAt);
|
|
3609
|
+
}
|
|
3610
|
+
if (connection.lastUsedAt && typeof connection.lastUsedAt === "string") {
|
|
3611
|
+
connection.lastUsedAt = new Date(connection.lastUsedAt);
|
|
3612
|
+
}
|
|
3613
|
+
if (connection.createdAt && typeof connection.createdAt === "string") {
|
|
3614
|
+
connection.createdAt = new Date(connection.createdAt);
|
|
3615
|
+
}
|
|
3616
|
+
return connection;
|
|
3617
|
+
}
|
|
3618
|
+
convertConnectionDetailsDates(connection) {
|
|
3619
|
+
if (connection.connectedAt && typeof connection.connectedAt === "string") {
|
|
3620
|
+
connection.connectedAt = new Date(connection.connectedAt);
|
|
3621
|
+
}
|
|
3622
|
+
if (connection.lastUsedAt && typeof connection.lastUsedAt === "string") {
|
|
3623
|
+
connection.lastUsedAt = new Date(connection.lastUsedAt);
|
|
3624
|
+
}
|
|
3625
|
+
if (connection.lastErrorAt && typeof connection.lastErrorAt === "string") {
|
|
3626
|
+
connection.lastErrorAt = new Date(connection.lastErrorAt);
|
|
3627
|
+
}
|
|
3628
|
+
if (connection.createdAt && typeof connection.createdAt === "string") {
|
|
3629
|
+
connection.createdAt = new Date(connection.createdAt);
|
|
3630
|
+
}
|
|
3631
|
+
if (connection.updatedAt && typeof connection.updatedAt === "string") {
|
|
3632
|
+
connection.updatedAt = new Date(connection.updatedAt);
|
|
3633
|
+
}
|
|
3634
|
+
return connection;
|
|
3635
|
+
}
|
|
3636
|
+
convertLogDates(log) {
|
|
3637
|
+
if (typeof log.createdAt === "string") {
|
|
3638
|
+
log.createdAt = new Date(log.createdAt);
|
|
3639
|
+
}
|
|
3640
|
+
return log;
|
|
3641
|
+
}
|
|
3254
3642
|
};
|
|
3255
3643
|
|
|
3256
3644
|
// src/marketing/client.ts
|
|
@@ -3306,6 +3694,22 @@ var Marketing = class {
|
|
|
3306
3694
|
const response = await this.http.get(`/marketing/trends/${trendId}`);
|
|
3307
3695
|
return this.convertTrendDates(response);
|
|
3308
3696
|
}
|
|
3697
|
+
/**
|
|
3698
|
+
* Update trend status
|
|
3699
|
+
*
|
|
3700
|
+
* @example
|
|
3701
|
+
* ```typescript
|
|
3702
|
+
* await marketing.updateTrendStatus({
|
|
3703
|
+
* trendId: 'trend-id',
|
|
3704
|
+
* status: 'active',
|
|
3705
|
+
* });
|
|
3706
|
+
* ```
|
|
3707
|
+
*/
|
|
3708
|
+
async updateTrendStatus(request) {
|
|
3709
|
+
return this.http.patch(`/marketing/trends/${request.trendId}/status`, {
|
|
3710
|
+
status: request.status
|
|
3711
|
+
});
|
|
3712
|
+
}
|
|
3309
3713
|
// ============================================================================
|
|
3310
3714
|
// Opportunities
|
|
3311
3715
|
// ============================================================================
|
|
@@ -3514,6 +3918,54 @@ var Marketing = class {
|
|
|
3514
3918
|
const response = await this.http.get(`/marketing/scripts/${scriptId}`);
|
|
3515
3919
|
return this.convertScriptDates(response);
|
|
3516
3920
|
}
|
|
3921
|
+
/**
|
|
3922
|
+
* Update a script
|
|
3923
|
+
*
|
|
3924
|
+
* @example
|
|
3925
|
+
* ```typescript
|
|
3926
|
+
* const updated = await marketing.updateScript({
|
|
3927
|
+
* scriptId: 'script-id',
|
|
3928
|
+
* hook: 'Updated hook line',
|
|
3929
|
+
* cta: 'New call to action!',
|
|
3930
|
+
* });
|
|
3931
|
+
* ```
|
|
3932
|
+
*/
|
|
3933
|
+
async updateScript(request) {
|
|
3934
|
+
const { scriptId, ...data } = request;
|
|
3935
|
+
const response = await this.http.patch(`/marketing/scripts/${scriptId}`, data);
|
|
3936
|
+
return this.convertScriptDates(response);
|
|
3937
|
+
}
|
|
3938
|
+
/**
|
|
3939
|
+
* Create a new version of a script
|
|
3940
|
+
*
|
|
3941
|
+
* @example
|
|
3942
|
+
* ```typescript
|
|
3943
|
+
* const newVersion = await marketing.createScriptVersion({
|
|
3944
|
+
* scriptId: 'script-id',
|
|
3945
|
+
* hook: 'Updated hook for v2',
|
|
3946
|
+
* slides: [...],
|
|
3947
|
+
* cta: 'Updated CTA',
|
|
3948
|
+
* });
|
|
3949
|
+
* ```
|
|
3950
|
+
*/
|
|
3951
|
+
async createScriptVersion(request) {
|
|
3952
|
+
const { scriptId, ...data } = request;
|
|
3953
|
+
const response = await this.http.post(`/marketing/scripts/${scriptId}/versions`, data);
|
|
3954
|
+
return this.convertScriptDates(response);
|
|
3955
|
+
}
|
|
3956
|
+
/**
|
|
3957
|
+
* Get all versions of a script
|
|
3958
|
+
*/
|
|
3959
|
+
async getScriptVersions(scriptId) {
|
|
3960
|
+
const response = await this.http.get(`/marketing/scripts/${scriptId}/versions`);
|
|
3961
|
+
return response.map((s) => this.convertScriptDates(s));
|
|
3962
|
+
}
|
|
3963
|
+
/**
|
|
3964
|
+
* Delete a script
|
|
3965
|
+
*/
|
|
3966
|
+
async deleteScript(scriptId) {
|
|
3967
|
+
return this.http.delete(`/marketing/scripts/${scriptId}`);
|
|
3968
|
+
}
|
|
3517
3969
|
// ============================================================================
|
|
3518
3970
|
// Analytics
|
|
3519
3971
|
// ============================================================================
|
|
@@ -3561,6 +4013,318 @@ var Marketing = class {
|
|
|
3561
4013
|
});
|
|
3562
4014
|
return this.http.get(`/marketing/analytics/performance?${params.toString()}`);
|
|
3563
4015
|
}
|
|
4016
|
+
/**
|
|
4017
|
+
* Get trend discovery analytics
|
|
4018
|
+
*
|
|
4019
|
+
* @example
|
|
4020
|
+
* ```typescript
|
|
4021
|
+
* const trendStats = await marketing.getTrendAnalytics({
|
|
4022
|
+
* projectSlug: 'my-project',
|
|
4023
|
+
* environment: 'production',
|
|
4024
|
+
* });
|
|
4025
|
+
* console.log(`Total trends: ${trendStats.totalTrends}`);
|
|
4026
|
+
* ```
|
|
4027
|
+
*/
|
|
4028
|
+
async getTrendAnalytics(request) {
|
|
4029
|
+
const params = new URLSearchParams({
|
|
4030
|
+
projectSlug: request.projectSlug,
|
|
4031
|
+
...request.environment && { environment: request.environment },
|
|
4032
|
+
...request.startDate && { startDate: request.startDate.toISOString() },
|
|
4033
|
+
...request.endDate && { endDate: request.endDate.toISOString() }
|
|
4034
|
+
});
|
|
4035
|
+
return this.http.get(`/marketing/analytics/trends?${params.toString()}`);
|
|
4036
|
+
}
|
|
4037
|
+
/**
|
|
4038
|
+
* Get opportunity conversion analytics
|
|
4039
|
+
*
|
|
4040
|
+
* @example
|
|
4041
|
+
* ```typescript
|
|
4042
|
+
* const conversion = await marketing.getOpportunityConversion({
|
|
4043
|
+
* projectSlug: 'my-project',
|
|
4044
|
+
* environment: 'production',
|
|
4045
|
+
* });
|
|
4046
|
+
* console.log(`Conversion rate: ${conversion.conversionRate}%`);
|
|
4047
|
+
* ```
|
|
4048
|
+
*/
|
|
4049
|
+
async getOpportunityConversion(request) {
|
|
4050
|
+
const params = new URLSearchParams({
|
|
4051
|
+
projectSlug: request.projectSlug,
|
|
4052
|
+
...request.environment && { environment: request.environment },
|
|
4053
|
+
...request.startDate && { startDate: request.startDate.toISOString() },
|
|
4054
|
+
...request.endDate && { endDate: request.endDate.toISOString() }
|
|
4055
|
+
});
|
|
4056
|
+
return this.http.get(`/marketing/analytics/conversion?${params.toString()}`);
|
|
4057
|
+
}
|
|
4058
|
+
// ============================================================================
|
|
4059
|
+
// Calendar
|
|
4060
|
+
// ============================================================================
|
|
4061
|
+
/**
|
|
4062
|
+
* Schedule content for publishing
|
|
4063
|
+
*
|
|
4064
|
+
* @example
|
|
4065
|
+
* ```typescript
|
|
4066
|
+
* const entry = await marketing.scheduleContent({
|
|
4067
|
+
* projectSlug: 'my-project',
|
|
4068
|
+
* contentId: 'content-id',
|
|
4069
|
+
* scheduledFor: new Date('2024-12-25T10:00:00Z'),
|
|
4070
|
+
* autoPublish: true,
|
|
4071
|
+
* });
|
|
4072
|
+
* ```
|
|
4073
|
+
*/
|
|
4074
|
+
async scheduleContent(request) {
|
|
4075
|
+
const response = await this.http.post("/marketing/calendar/schedule", {
|
|
4076
|
+
...request,
|
|
4077
|
+
scheduledFor: request.scheduledFor.toISOString()
|
|
4078
|
+
});
|
|
4079
|
+
return this.convertCalendarEntryDates(response);
|
|
4080
|
+
}
|
|
4081
|
+
/**
|
|
4082
|
+
* List scheduled content
|
|
4083
|
+
*
|
|
4084
|
+
* @example
|
|
4085
|
+
* ```typescript
|
|
4086
|
+
* const entries = await marketing.listCalendarEntries({
|
|
4087
|
+
* projectSlug: 'my-project',
|
|
4088
|
+
* startDate: new Date('2024-12-01'),
|
|
4089
|
+
* endDate: new Date('2024-12-31'),
|
|
4090
|
+
* });
|
|
4091
|
+
* ```
|
|
4092
|
+
*/
|
|
4093
|
+
async listCalendarEntries(request) {
|
|
4094
|
+
const params = new URLSearchParams({
|
|
4095
|
+
projectSlug: request.projectSlug,
|
|
4096
|
+
...request.environment && { environment: request.environment },
|
|
4097
|
+
...request.startDate && { startDate: request.startDate.toISOString() },
|
|
4098
|
+
...request.endDate && { endDate: request.endDate.toISOString() },
|
|
4099
|
+
...request.limit && { limit: request.limit.toString() },
|
|
4100
|
+
...request.offset && { offset: request.offset.toString() }
|
|
4101
|
+
});
|
|
4102
|
+
const response = await this.http.get(`/marketing/calendar?${params.toString()}`);
|
|
4103
|
+
return response.map((e) => this.convertCalendarEntryDates(e));
|
|
4104
|
+
}
|
|
4105
|
+
/**
|
|
4106
|
+
* Get a single calendar entry by ID
|
|
4107
|
+
*/
|
|
4108
|
+
async getCalendarEntry(entryId) {
|
|
4109
|
+
const response = await this.http.get(`/marketing/calendar/${entryId}`);
|
|
4110
|
+
return this.convertCalendarEntryDates(response);
|
|
4111
|
+
}
|
|
4112
|
+
/**
|
|
4113
|
+
* Update a calendar entry
|
|
4114
|
+
*
|
|
4115
|
+
* @example
|
|
4116
|
+
* ```typescript
|
|
4117
|
+
* const updated = await marketing.updateCalendarEntry({
|
|
4118
|
+
* entryId: 'entry-id',
|
|
4119
|
+
* scheduledFor: new Date('2024-12-26T10:00:00Z'),
|
|
4120
|
+
* });
|
|
4121
|
+
* ```
|
|
4122
|
+
*/
|
|
4123
|
+
async updateCalendarEntry(request) {
|
|
4124
|
+
const { entryId, ...data } = request;
|
|
4125
|
+
const response = await this.http.patch(`/marketing/calendar/${entryId}`, {
|
|
4126
|
+
...data,
|
|
4127
|
+
...data.scheduledFor && { scheduledFor: data.scheduledFor.toISOString() }
|
|
4128
|
+
});
|
|
4129
|
+
return this.convertCalendarEntryDates(response);
|
|
4130
|
+
}
|
|
4131
|
+
/**
|
|
4132
|
+
* Cancel a scheduled calendar entry
|
|
4133
|
+
*/
|
|
4134
|
+
async cancelCalendarEntry(entryId) {
|
|
4135
|
+
return this.http.post(`/marketing/calendar/${entryId}/cancel`, {});
|
|
4136
|
+
}
|
|
4137
|
+
/**
|
|
4138
|
+
* Mark content as published
|
|
4139
|
+
*/
|
|
4140
|
+
async markContentPublished(request) {
|
|
4141
|
+
const response = await this.http.post(`/marketing/calendar/${request.entryId}/published`, {
|
|
4142
|
+
...request.publishedAt && { publishedAt: request.publishedAt.toISOString() }
|
|
4143
|
+
});
|
|
4144
|
+
return this.convertCalendarEntryDates(response);
|
|
4145
|
+
}
|
|
4146
|
+
// ============================================================================
|
|
4147
|
+
// Assets (Asset Jobs)
|
|
4148
|
+
// ============================================================================
|
|
4149
|
+
/**
|
|
4150
|
+
* Create an asset generation job
|
|
4151
|
+
*
|
|
4152
|
+
* @example
|
|
4153
|
+
* ```typescript
|
|
4154
|
+
* const job = await marketing.createAssetJob({
|
|
4155
|
+
* projectSlug: 'my-project',
|
|
4156
|
+
* contentId: 'content-id',
|
|
4157
|
+
* jobType: 'slide_generation',
|
|
4158
|
+
* input: { style: 'modern' },
|
|
4159
|
+
* });
|
|
4160
|
+
* ```
|
|
4161
|
+
*/
|
|
4162
|
+
async createAssetJob(request) {
|
|
4163
|
+
const response = await this.http.post("/marketing/assets/jobs", request);
|
|
4164
|
+
return this.convertAssetJobDates(response);
|
|
4165
|
+
}
|
|
4166
|
+
/**
|
|
4167
|
+
* List asset jobs
|
|
4168
|
+
*
|
|
4169
|
+
* @example
|
|
4170
|
+
* ```typescript
|
|
4171
|
+
* const jobs = await marketing.listAssetJobs({
|
|
4172
|
+
* projectSlug: 'my-project',
|
|
4173
|
+
* status: 'processing',
|
|
4174
|
+
* });
|
|
4175
|
+
* ```
|
|
4176
|
+
*/
|
|
4177
|
+
async listAssetJobs(request) {
|
|
4178
|
+
const params = new URLSearchParams({
|
|
4179
|
+
projectSlug: request.projectSlug,
|
|
4180
|
+
...request.contentId && { contentId: request.contentId },
|
|
4181
|
+
...request.status && { status: request.status },
|
|
4182
|
+
...request.jobType && { jobType: request.jobType },
|
|
4183
|
+
...request.limit && { limit: request.limit.toString() },
|
|
4184
|
+
...request.offset && { offset: request.offset.toString() }
|
|
4185
|
+
});
|
|
4186
|
+
const response = await this.http.get(`/marketing/assets/jobs?${params.toString()}`);
|
|
4187
|
+
return response.map((j) => this.convertAssetJobDates(j));
|
|
4188
|
+
}
|
|
4189
|
+
/**
|
|
4190
|
+
* Get an asset job by ID
|
|
4191
|
+
*/
|
|
4192
|
+
async getAssetJob(jobId) {
|
|
4193
|
+
const response = await this.http.get(`/marketing/assets/jobs/${jobId}`);
|
|
4194
|
+
return this.convertAssetJobDates(response);
|
|
4195
|
+
}
|
|
4196
|
+
/**
|
|
4197
|
+
* Update asset job status
|
|
4198
|
+
*/
|
|
4199
|
+
async updateAssetJobStatus(request) {
|
|
4200
|
+
const { jobId, ...data } = request;
|
|
4201
|
+
const response = await this.http.patch(`/marketing/assets/jobs/${jobId}/status`, data);
|
|
4202
|
+
return this.convertAssetJobDates(response);
|
|
4203
|
+
}
|
|
4204
|
+
/**
|
|
4205
|
+
* Retry a failed asset job
|
|
4206
|
+
*/
|
|
4207
|
+
async retryAssetJob(jobId) {
|
|
4208
|
+
const response = await this.http.post(`/marketing/assets/jobs/${jobId}/retry`, {});
|
|
4209
|
+
return this.convertAssetJobDates(response);
|
|
4210
|
+
}
|
|
4211
|
+
/**
|
|
4212
|
+
* Cancel an asset job
|
|
4213
|
+
*/
|
|
4214
|
+
async cancelAssetJob(jobId) {
|
|
4215
|
+
const response = await this.http.post(`/marketing/assets/jobs/${jobId}/cancel`, {});
|
|
4216
|
+
return this.convertAssetJobDates(response);
|
|
4217
|
+
}
|
|
4218
|
+
// ============================================================================
|
|
4219
|
+
// Settings
|
|
4220
|
+
// ============================================================================
|
|
4221
|
+
/**
|
|
4222
|
+
* Get marketing settings for a project
|
|
4223
|
+
*
|
|
4224
|
+
* @example
|
|
4225
|
+
* ```typescript
|
|
4226
|
+
* const settings = await marketing.getSettings({
|
|
4227
|
+
* projectSlug: 'my-project',
|
|
4228
|
+
* environment: 'production',
|
|
4229
|
+
* });
|
|
4230
|
+
* console.log(`Brand voice: ${settings.brandVoice}`);
|
|
4231
|
+
* ```
|
|
4232
|
+
*/
|
|
4233
|
+
async getSettings(request) {
|
|
4234
|
+
const params = new URLSearchParams({
|
|
4235
|
+
projectSlug: request.projectSlug,
|
|
4236
|
+
...request.environment && { environment: request.environment }
|
|
4237
|
+
});
|
|
4238
|
+
return this.http.get(`/marketing/settings?${params.toString()}`);
|
|
4239
|
+
}
|
|
4240
|
+
/**
|
|
4241
|
+
* Update marketing settings
|
|
4242
|
+
*
|
|
4243
|
+
* @example
|
|
4244
|
+
* ```typescript
|
|
4245
|
+
* await marketing.updateSettings({
|
|
4246
|
+
* projectSlug: 'my-project',
|
|
4247
|
+
* brandVoice: 'Professional yet approachable',
|
|
4248
|
+
* monitoredKeywords: ['AI', 'startup', 'tech'],
|
|
4249
|
+
* });
|
|
4250
|
+
* ```
|
|
4251
|
+
*/
|
|
4252
|
+
async updateSettings(request) {
|
|
4253
|
+
return this.http.post("/marketing/settings", request);
|
|
4254
|
+
}
|
|
4255
|
+
// ============================================================================
|
|
4256
|
+
// Usage
|
|
4257
|
+
// ============================================================================
|
|
4258
|
+
/**
|
|
4259
|
+
* Get current period usage
|
|
4260
|
+
*
|
|
4261
|
+
* @example
|
|
4262
|
+
* ```typescript
|
|
4263
|
+
* const usage = await marketing.getCurrentUsage({
|
|
4264
|
+
* projectSlug: 'my-project',
|
|
4265
|
+
* environment: 'production',
|
|
4266
|
+
* });
|
|
4267
|
+
* console.log(`AI tokens used: ${usage.aiTokensUsed}`);
|
|
4268
|
+
* ```
|
|
4269
|
+
*/
|
|
4270
|
+
async getCurrentUsage(request) {
|
|
4271
|
+
const params = new URLSearchParams({
|
|
4272
|
+
projectSlug: request.projectSlug,
|
|
4273
|
+
...request.environment && { environment: request.environment }
|
|
4274
|
+
});
|
|
4275
|
+
const response = await this.http.get(`/marketing/usage/current?${params.toString()}`);
|
|
4276
|
+
return this.convertUsageDates(response);
|
|
4277
|
+
}
|
|
4278
|
+
/**
|
|
4279
|
+
* Get usage history
|
|
4280
|
+
*
|
|
4281
|
+
* @example
|
|
4282
|
+
* ```typescript
|
|
4283
|
+
* const history = await marketing.getUsageHistory({
|
|
4284
|
+
* projectSlug: 'my-project',
|
|
4285
|
+
* limit: 6, // Last 6 months
|
|
4286
|
+
* });
|
|
4287
|
+
* ```
|
|
4288
|
+
*/
|
|
4289
|
+
async getUsageHistory(request) {
|
|
4290
|
+
const params = new URLSearchParams({
|
|
4291
|
+
projectSlug: request.projectSlug,
|
|
4292
|
+
...request.environment && { environment: request.environment },
|
|
4293
|
+
...request.startDate && { startDate: request.startDate.toISOString() },
|
|
4294
|
+
...request.endDate && { endDate: request.endDate.toISOString() },
|
|
4295
|
+
...request.limit && { limit: request.limit.toString() }
|
|
4296
|
+
});
|
|
4297
|
+
const response = await this.http.get(`/marketing/usage/history?${params.toString()}`);
|
|
4298
|
+
return response.map((u) => this.convertMarketingUsageDates(u));
|
|
4299
|
+
}
|
|
4300
|
+
/**
|
|
4301
|
+
* Get total usage across all periods
|
|
4302
|
+
*
|
|
4303
|
+
* @example
|
|
4304
|
+
* ```typescript
|
|
4305
|
+
* const totals = await marketing.getTotalUsage({
|
|
4306
|
+
* projectSlug: 'my-project',
|
|
4307
|
+
* startDate: new Date('2024-01-01'),
|
|
4308
|
+
* });
|
|
4309
|
+
* console.log(`Total content generated: ${totals.contentGenerated}`);
|
|
4310
|
+
* ```
|
|
4311
|
+
*/
|
|
4312
|
+
async getTotalUsage(request) {
|
|
4313
|
+
const params = new URLSearchParams({
|
|
4314
|
+
projectSlug: request.projectSlug,
|
|
4315
|
+
...request.environment && { environment: request.environment },
|
|
4316
|
+
...request.startDate && { startDate: request.startDate.toISOString() },
|
|
4317
|
+
...request.endDate && { endDate: request.endDate.toISOString() }
|
|
4318
|
+
});
|
|
4319
|
+
return this.http.get(`/marketing/usage/total?${params.toString()}`);
|
|
4320
|
+
}
|
|
4321
|
+
/**
|
|
4322
|
+
* Record usage (typically called internally)
|
|
4323
|
+
*/
|
|
4324
|
+
async recordUsage(request) {
|
|
4325
|
+
const response = await this.http.post("/marketing/usage/record", request);
|
|
4326
|
+
return this.convertMarketingUsageDates(response);
|
|
4327
|
+
}
|
|
3564
4328
|
// ============================================================================
|
|
3565
4329
|
// Date Conversion Helpers
|
|
3566
4330
|
// ============================================================================
|
|
@@ -3612,6 +4376,57 @@ var Marketing = class {
|
|
|
3612
4376
|
}
|
|
3613
4377
|
return script;
|
|
3614
4378
|
}
|
|
4379
|
+
convertCalendarEntryDates(entry) {
|
|
4380
|
+
if (typeof entry.scheduledFor === "string") {
|
|
4381
|
+
entry.scheduledFor = new Date(entry.scheduledFor);
|
|
4382
|
+
}
|
|
4383
|
+
if (typeof entry.createdAt === "string") {
|
|
4384
|
+
entry.createdAt = new Date(entry.createdAt);
|
|
4385
|
+
}
|
|
4386
|
+
if (entry.updatedAt && typeof entry.updatedAt === "string") {
|
|
4387
|
+
entry.updatedAt = new Date(entry.updatedAt);
|
|
4388
|
+
}
|
|
4389
|
+
if (entry.publishedAt && typeof entry.publishedAt === "string") {
|
|
4390
|
+
entry.publishedAt = new Date(entry.publishedAt);
|
|
4391
|
+
}
|
|
4392
|
+
return entry;
|
|
4393
|
+
}
|
|
4394
|
+
convertAssetJobDates(job) {
|
|
4395
|
+
if (typeof job.createdAt === "string") {
|
|
4396
|
+
job.createdAt = new Date(job.createdAt);
|
|
4397
|
+
}
|
|
4398
|
+
if (job.startedAt && typeof job.startedAt === "string") {
|
|
4399
|
+
job.startedAt = new Date(job.startedAt);
|
|
4400
|
+
}
|
|
4401
|
+
if (job.completedAt && typeof job.completedAt === "string") {
|
|
4402
|
+
job.completedAt = new Date(job.completedAt);
|
|
4403
|
+
}
|
|
4404
|
+
return job;
|
|
4405
|
+
}
|
|
4406
|
+
convertUsageDates(usage) {
|
|
4407
|
+
if (typeof usage.periodStart === "string") {
|
|
4408
|
+
usage.periodStart = new Date(usage.periodStart);
|
|
4409
|
+
}
|
|
4410
|
+
if (typeof usage.periodEnd === "string") {
|
|
4411
|
+
usage.periodEnd = new Date(usage.periodEnd);
|
|
4412
|
+
}
|
|
4413
|
+
return usage;
|
|
4414
|
+
}
|
|
4415
|
+
convertMarketingUsageDates(usage) {
|
|
4416
|
+
if (typeof usage.periodStart === "string") {
|
|
4417
|
+
usage.periodStart = new Date(usage.periodStart);
|
|
4418
|
+
}
|
|
4419
|
+
if (typeof usage.periodEnd === "string") {
|
|
4420
|
+
usage.periodEnd = new Date(usage.periodEnd);
|
|
4421
|
+
}
|
|
4422
|
+
if (typeof usage.createdAt === "string") {
|
|
4423
|
+
usage.createdAt = new Date(usage.createdAt);
|
|
4424
|
+
}
|
|
4425
|
+
if (usage.updatedAt && typeof usage.updatedAt === "string") {
|
|
4426
|
+
usage.updatedAt = new Date(usage.updatedAt);
|
|
4427
|
+
}
|
|
4428
|
+
return usage;
|
|
4429
|
+
}
|
|
3615
4430
|
};
|
|
3616
4431
|
|
|
3617
4432
|
// src/index.ts
|