@stack0/sdk 0.5.3 → 0.5.5
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 +201 -1
- package/dist/cdn/index.d.ts +201 -1
- package/dist/cdn/index.js +107 -0
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/index.mjs +107 -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 +722 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +722 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1816,6 +1816,113 @@ var CDN = class {
|
|
|
1816
1816
|
async movePrivateFiles(request) {
|
|
1817
1817
|
return this.http.post("/cdn/private/move", request);
|
|
1818
1818
|
}
|
|
1819
|
+
// ============================================================================
|
|
1820
|
+
// Video Merge Methods
|
|
1821
|
+
// ============================================================================
|
|
1822
|
+
/**
|
|
1823
|
+
* Create a merge job to combine multiple videos/images with optional audio overlay
|
|
1824
|
+
*
|
|
1825
|
+
* Merge jobs combine multiple assets (videos, images) in sequence and can
|
|
1826
|
+
* optionally overlay an audio track. Images require a duration to be specified.
|
|
1827
|
+
*
|
|
1828
|
+
* @example
|
|
1829
|
+
* ```typescript
|
|
1830
|
+
* const job = await cdn.createMergeJob({
|
|
1831
|
+
* projectSlug: 'my-project',
|
|
1832
|
+
* inputs: [
|
|
1833
|
+
* { assetId: 'intro-video-id' },
|
|
1834
|
+
* { assetId: 'image-id', duration: 5 }, // Show image for 5 seconds
|
|
1835
|
+
* { assetId: 'main-video-id', startTime: 10, endTime: 60 }, // Trim to 50 seconds
|
|
1836
|
+
* ],
|
|
1837
|
+
* audioTrack: {
|
|
1838
|
+
* assetId: 'background-music-id',
|
|
1839
|
+
* loop: true,
|
|
1840
|
+
* fadeIn: 2,
|
|
1841
|
+
* fadeOut: 3,
|
|
1842
|
+
* },
|
|
1843
|
+
* output: {
|
|
1844
|
+
* format: 'mp4',
|
|
1845
|
+
* quality: '1080p',
|
|
1846
|
+
* filename: 'final-video.mp4',
|
|
1847
|
+
* },
|
|
1848
|
+
* webhookUrl: 'https://your-app.com/webhook',
|
|
1849
|
+
* });
|
|
1850
|
+
* console.log(`Merge job started: ${job.id}`);
|
|
1851
|
+
* ```
|
|
1852
|
+
*/
|
|
1853
|
+
async createMergeJob(request) {
|
|
1854
|
+
const response = await this.http.post("/cdn/video/merge", request);
|
|
1855
|
+
return this.convertMergeJobDates(response);
|
|
1856
|
+
}
|
|
1857
|
+
/**
|
|
1858
|
+
* Get a merge job by ID with output asset details
|
|
1859
|
+
*
|
|
1860
|
+
* @example
|
|
1861
|
+
* ```typescript
|
|
1862
|
+
* const job = await cdn.getMergeJob('job-id');
|
|
1863
|
+
* if (job.status === 'completed' && job.outputAsset) {
|
|
1864
|
+
* console.log(`Output video: ${job.outputAsset.cdnUrl}`);
|
|
1865
|
+
* }
|
|
1866
|
+
* ```
|
|
1867
|
+
*/
|
|
1868
|
+
async getMergeJob(jobId) {
|
|
1869
|
+
const response = await this.http.get(`/cdn/video/merge/${jobId}`);
|
|
1870
|
+
return this.convertMergeJobWithOutputDates(response);
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* List merge jobs with optional filters
|
|
1874
|
+
*
|
|
1875
|
+
* @example
|
|
1876
|
+
* ```typescript
|
|
1877
|
+
* const { jobs, total, hasMore } = await cdn.listMergeJobs({
|
|
1878
|
+
* projectSlug: 'my-project',
|
|
1879
|
+
* status: 'completed',
|
|
1880
|
+
* limit: 20,
|
|
1881
|
+
* });
|
|
1882
|
+
* ```
|
|
1883
|
+
*/
|
|
1884
|
+
async listMergeJobs(request) {
|
|
1885
|
+
const params = new URLSearchParams();
|
|
1886
|
+
params.set("projectSlug", request.projectSlug);
|
|
1887
|
+
if (request.status) params.set("status", request.status);
|
|
1888
|
+
if (request.limit) params.set("limit", request.limit.toString());
|
|
1889
|
+
if (request.offset) params.set("offset", request.offset.toString());
|
|
1890
|
+
const response = await this.http.get(`/cdn/video/merge?${params.toString()}`);
|
|
1891
|
+
return {
|
|
1892
|
+
...response,
|
|
1893
|
+
jobs: response.jobs.map((job) => this.convertMergeJobDates(job))
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Cancel a pending or processing merge job
|
|
1898
|
+
*
|
|
1899
|
+
* @example
|
|
1900
|
+
* ```typescript
|
|
1901
|
+
* await cdn.cancelMergeJob('job-id');
|
|
1902
|
+
* console.log('Merge job cancelled');
|
|
1903
|
+
* ```
|
|
1904
|
+
*/
|
|
1905
|
+
async cancelMergeJob(jobId) {
|
|
1906
|
+
return this.http.post(`/cdn/video/merge/${jobId}/cancel`, {});
|
|
1907
|
+
}
|
|
1908
|
+
convertMergeJobDates(job) {
|
|
1909
|
+
if (typeof job.createdAt === "string") {
|
|
1910
|
+
job.createdAt = new Date(job.createdAt);
|
|
1911
|
+
}
|
|
1912
|
+
if (job.updatedAt && typeof job.updatedAt === "string") {
|
|
1913
|
+
job.updatedAt = new Date(job.updatedAt);
|
|
1914
|
+
}
|
|
1915
|
+
if (job.startedAt && typeof job.startedAt === "string") {
|
|
1916
|
+
job.startedAt = new Date(job.startedAt);
|
|
1917
|
+
}
|
|
1918
|
+
if (job.completedAt && typeof job.completedAt === "string") {
|
|
1919
|
+
job.completedAt = new Date(job.completedAt);
|
|
1920
|
+
}
|
|
1921
|
+
return job;
|
|
1922
|
+
}
|
|
1923
|
+
convertMergeJobWithOutputDates(job) {
|
|
1924
|
+
return this.convertMergeJobDates(job);
|
|
1925
|
+
}
|
|
1819
1926
|
};
|
|
1820
1927
|
|
|
1821
1928
|
// src/screenshots/client.ts
|
|
@@ -2492,6 +2599,28 @@ var Extraction = class {
|
|
|
2492
2599
|
const response = await this.http.get(`/webdata/usage${query ? `?${query}` : ""}`);
|
|
2493
2600
|
return this.convertUsageDates(response);
|
|
2494
2601
|
}
|
|
2602
|
+
/**
|
|
2603
|
+
* Get daily usage breakdown
|
|
2604
|
+
*
|
|
2605
|
+
* @example
|
|
2606
|
+
* ```typescript
|
|
2607
|
+
* const { days } = await extraction.getUsageDaily({
|
|
2608
|
+
* periodStart: '2024-01-01T00:00:00Z',
|
|
2609
|
+
* periodEnd: '2024-01-31T23:59:59Z',
|
|
2610
|
+
* });
|
|
2611
|
+
* days.forEach(day => {
|
|
2612
|
+
* console.log(`${day.date}: ${day.screenshots} screenshots, ${day.extractions} extractions`);
|
|
2613
|
+
* });
|
|
2614
|
+
* ```
|
|
2615
|
+
*/
|
|
2616
|
+
async getUsageDaily(request = {}) {
|
|
2617
|
+
const params = new URLSearchParams();
|
|
2618
|
+
if (request.environment) params.set("environment", request.environment);
|
|
2619
|
+
if (request.periodStart) params.set("periodStart", request.periodStart);
|
|
2620
|
+
if (request.periodEnd) params.set("periodEnd", request.periodEnd);
|
|
2621
|
+
const query = params.toString();
|
|
2622
|
+
return this.http.get(`/webdata/usage/daily${query ? `?${query}` : ""}`);
|
|
2623
|
+
}
|
|
2495
2624
|
// ==========================================================================
|
|
2496
2625
|
// HELPERS
|
|
2497
2626
|
// ==========================================================================
|
|
@@ -3424,41 +3553,150 @@ var Integrations = class {
|
|
|
3424
3553
|
// ============================================================================
|
|
3425
3554
|
/**
|
|
3426
3555
|
* List all connections
|
|
3556
|
+
*
|
|
3557
|
+
* @example
|
|
3558
|
+
* ```typescript
|
|
3559
|
+
* const { connections } = await integrations.listConnections({
|
|
3560
|
+
* environment: 'production',
|
|
3561
|
+
* status: 'connected',
|
|
3562
|
+
* });
|
|
3563
|
+
* ```
|
|
3427
3564
|
*/
|
|
3428
|
-
async listConnections(
|
|
3565
|
+
async listConnections(request) {
|
|
3429
3566
|
const params = new URLSearchParams();
|
|
3430
|
-
if (
|
|
3431
|
-
if (
|
|
3567
|
+
if (request?.projectId) params.set("projectId", request.projectId);
|
|
3568
|
+
if (request?.environment) params.set("environment", request.environment);
|
|
3569
|
+
if (request?.connectorSlug) params.set("connectorSlug", request.connectorSlug);
|
|
3570
|
+
if (request?.status) params.set("status", request.status);
|
|
3571
|
+
if (request?.limit) params.set("limit", request.limit.toString());
|
|
3432
3572
|
const queryString = params.toString();
|
|
3433
|
-
|
|
3573
|
+
const response = await this.http.get(
|
|
3574
|
+
`/integrations/connections${queryString ? `?${queryString}` : ""}`
|
|
3575
|
+
);
|
|
3576
|
+
return {
|
|
3577
|
+
...response,
|
|
3578
|
+
connections: response.connections.map((c) => this.convertConnectionDates(c))
|
|
3579
|
+
};
|
|
3434
3580
|
}
|
|
3435
3581
|
/**
|
|
3436
3582
|
* Get a specific connection
|
|
3437
3583
|
*/
|
|
3438
|
-
async getConnection(
|
|
3439
|
-
|
|
3584
|
+
async getConnection(connectionId) {
|
|
3585
|
+
const response = await this.http.get(`/integrations/connections/${connectionId}`);
|
|
3586
|
+
return this.convertConnectionDetailsDates(response);
|
|
3587
|
+
}
|
|
3588
|
+
/**
|
|
3589
|
+
* Initiate OAuth flow for a connector
|
|
3590
|
+
*
|
|
3591
|
+
* @example
|
|
3592
|
+
* ```typescript
|
|
3593
|
+
* const { authUrl, connectionId, state } = await integrations.initiateOAuth({
|
|
3594
|
+
* connectorSlug: 'hubspot',
|
|
3595
|
+
* redirectUrl: 'https://yourapp.com/oauth/callback',
|
|
3596
|
+
* name: 'My HubSpot Connection',
|
|
3597
|
+
* });
|
|
3598
|
+
* // Redirect user to authUrl
|
|
3599
|
+
* ```
|
|
3600
|
+
*/
|
|
3601
|
+
async initiateOAuth(request) {
|
|
3602
|
+
return this.http.post("/integrations/connections/oauth/initiate", request);
|
|
3440
3603
|
}
|
|
3441
3604
|
/**
|
|
3442
|
-
*
|
|
3443
|
-
*
|
|
3605
|
+
* Complete OAuth flow with callback data
|
|
3606
|
+
*
|
|
3607
|
+
* @example
|
|
3608
|
+
* ```typescript
|
|
3609
|
+
* const result = await integrations.completeOAuth({
|
|
3610
|
+
* code: 'auth_code_from_callback',
|
|
3611
|
+
* state: 'state_from_initiate',
|
|
3612
|
+
* redirectUrl: 'https://yourapp.com/oauth/callback',
|
|
3613
|
+
* });
|
|
3614
|
+
* console.log(`Connected to: ${result.externalAccountName}`);
|
|
3615
|
+
* ```
|
|
3444
3616
|
*/
|
|
3445
|
-
async
|
|
3446
|
-
return this.http.post("/integrations/connections",
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3617
|
+
async completeOAuth(request) {
|
|
3618
|
+
return this.http.post("/integrations/connections/oauth/callback", request);
|
|
3619
|
+
}
|
|
3620
|
+
/**
|
|
3621
|
+
* Update a connection
|
|
3622
|
+
*/
|
|
3623
|
+
async updateConnection(request) {
|
|
3624
|
+
const { connectionId, ...data } = request;
|
|
3625
|
+
return this.http.patch(`/integrations/connections/${connectionId}`, data);
|
|
3450
3626
|
}
|
|
3451
3627
|
/**
|
|
3452
3628
|
* Delete a connection
|
|
3453
3629
|
*/
|
|
3454
|
-
async deleteConnection(
|
|
3455
|
-
return this.http.delete(`/integrations/connections/${
|
|
3630
|
+
async deleteConnection(connectionId) {
|
|
3631
|
+
return this.http.delete(`/integrations/connections/${connectionId}`);
|
|
3632
|
+
}
|
|
3633
|
+
/**
|
|
3634
|
+
* Reconnect an expired or errored connection
|
|
3635
|
+
*
|
|
3636
|
+
* @example
|
|
3637
|
+
* ```typescript
|
|
3638
|
+
* const { authUrl, state } = await integrations.reconnectConnection({
|
|
3639
|
+
* connectionId: 'conn_123',
|
|
3640
|
+
* redirectUrl: 'https://yourapp.com/oauth/callback',
|
|
3641
|
+
* });
|
|
3642
|
+
* // Redirect user to authUrl
|
|
3643
|
+
* ```
|
|
3644
|
+
*/
|
|
3645
|
+
async reconnectConnection(request) {
|
|
3646
|
+
return this.http.post(
|
|
3647
|
+
`/integrations/connections/${request.connectionId}/reconnect`,
|
|
3648
|
+
{ redirectUrl: request.redirectUrl }
|
|
3649
|
+
);
|
|
3650
|
+
}
|
|
3651
|
+
/**
|
|
3652
|
+
* Get integration statistics
|
|
3653
|
+
*
|
|
3654
|
+
* @example
|
|
3655
|
+
* ```typescript
|
|
3656
|
+
* const stats = await integrations.getStats({ environment: 'production' });
|
|
3657
|
+
* console.log(`Active connections: ${stats.activeConnections}`);
|
|
3658
|
+
* console.log(`API calls last 30 days: ${stats.apiCallsLast30Days}`);
|
|
3659
|
+
* ```
|
|
3660
|
+
*/
|
|
3661
|
+
async getStats(request) {
|
|
3662
|
+
const params = new URLSearchParams();
|
|
3663
|
+
if (request?.environment) params.set("environment", request.environment);
|
|
3664
|
+
const queryString = params.toString();
|
|
3665
|
+
return this.http.get(
|
|
3666
|
+
`/integrations/connections/stats${queryString ? `?${queryString}` : ""}`
|
|
3667
|
+
);
|
|
3456
3668
|
}
|
|
3669
|
+
// ============================================================================
|
|
3670
|
+
// LOGS
|
|
3671
|
+
// ============================================================================
|
|
3457
3672
|
/**
|
|
3458
|
-
*
|
|
3673
|
+
* List API logs
|
|
3674
|
+
*
|
|
3675
|
+
* @example
|
|
3676
|
+
* ```typescript
|
|
3677
|
+
* const { logs } = await integrations.listLogs({
|
|
3678
|
+
* connectionId: 'conn_123',
|
|
3679
|
+
* limit: 50,
|
|
3680
|
+
* });
|
|
3681
|
+
* ```
|
|
3459
3682
|
*/
|
|
3460
|
-
async
|
|
3461
|
-
|
|
3683
|
+
async listLogs(request) {
|
|
3684
|
+
const params = new URLSearchParams();
|
|
3685
|
+
if (request?.connectionId) params.set("connectionId", request.connectionId);
|
|
3686
|
+
if (request?.connectorSlug) params.set("connectorSlug", request.connectorSlug);
|
|
3687
|
+
if (request?.statusCode) params.set("statusCode", request.statusCode.toString());
|
|
3688
|
+
if (request?.method) params.set("method", request.method);
|
|
3689
|
+
if (request?.search) params.set("search", request.search);
|
|
3690
|
+
if (request?.limit) params.set("limit", request.limit.toString());
|
|
3691
|
+
if (request?.cursor) params.set("cursor", request.cursor);
|
|
3692
|
+
const queryString = params.toString();
|
|
3693
|
+
const response = await this.http.get(
|
|
3694
|
+
`/integrations/logs${queryString ? `?${queryString}` : ""}`
|
|
3695
|
+
);
|
|
3696
|
+
return {
|
|
3697
|
+
...response,
|
|
3698
|
+
logs: response.logs.map((log) => this.convertLogDates(log))
|
|
3699
|
+
};
|
|
3462
3700
|
}
|
|
3463
3701
|
// ============================================================================
|
|
3464
3702
|
// PASSTHROUGH
|
|
@@ -3469,6 +3707,45 @@ var Integrations = class {
|
|
|
3469
3707
|
async passthrough(request) {
|
|
3470
3708
|
return this.http.post("/integrations/passthrough", request);
|
|
3471
3709
|
}
|
|
3710
|
+
// ============================================================================
|
|
3711
|
+
// Date Conversion Helpers
|
|
3712
|
+
// ============================================================================
|
|
3713
|
+
convertConnectionDates(connection) {
|
|
3714
|
+
if (connection.connectedAt && typeof connection.connectedAt === "string") {
|
|
3715
|
+
connection.connectedAt = new Date(connection.connectedAt);
|
|
3716
|
+
}
|
|
3717
|
+
if (connection.lastUsedAt && typeof connection.lastUsedAt === "string") {
|
|
3718
|
+
connection.lastUsedAt = new Date(connection.lastUsedAt);
|
|
3719
|
+
}
|
|
3720
|
+
if (connection.createdAt && typeof connection.createdAt === "string") {
|
|
3721
|
+
connection.createdAt = new Date(connection.createdAt);
|
|
3722
|
+
}
|
|
3723
|
+
return connection;
|
|
3724
|
+
}
|
|
3725
|
+
convertConnectionDetailsDates(connection) {
|
|
3726
|
+
if (connection.connectedAt && typeof connection.connectedAt === "string") {
|
|
3727
|
+
connection.connectedAt = new Date(connection.connectedAt);
|
|
3728
|
+
}
|
|
3729
|
+
if (connection.lastUsedAt && typeof connection.lastUsedAt === "string") {
|
|
3730
|
+
connection.lastUsedAt = new Date(connection.lastUsedAt);
|
|
3731
|
+
}
|
|
3732
|
+
if (connection.lastErrorAt && typeof connection.lastErrorAt === "string") {
|
|
3733
|
+
connection.lastErrorAt = new Date(connection.lastErrorAt);
|
|
3734
|
+
}
|
|
3735
|
+
if (connection.createdAt && typeof connection.createdAt === "string") {
|
|
3736
|
+
connection.createdAt = new Date(connection.createdAt);
|
|
3737
|
+
}
|
|
3738
|
+
if (connection.updatedAt && typeof connection.updatedAt === "string") {
|
|
3739
|
+
connection.updatedAt = new Date(connection.updatedAt);
|
|
3740
|
+
}
|
|
3741
|
+
return connection;
|
|
3742
|
+
}
|
|
3743
|
+
convertLogDates(log) {
|
|
3744
|
+
if (typeof log.createdAt === "string") {
|
|
3745
|
+
log.createdAt = new Date(log.createdAt);
|
|
3746
|
+
}
|
|
3747
|
+
return log;
|
|
3748
|
+
}
|
|
3472
3749
|
};
|
|
3473
3750
|
|
|
3474
3751
|
// src/marketing/client.ts
|
|
@@ -3524,6 +3801,22 @@ var Marketing = class {
|
|
|
3524
3801
|
const response = await this.http.get(`/marketing/trends/${trendId}`);
|
|
3525
3802
|
return this.convertTrendDates(response);
|
|
3526
3803
|
}
|
|
3804
|
+
/**
|
|
3805
|
+
* Update trend status
|
|
3806
|
+
*
|
|
3807
|
+
* @example
|
|
3808
|
+
* ```typescript
|
|
3809
|
+
* await marketing.updateTrendStatus({
|
|
3810
|
+
* trendId: 'trend-id',
|
|
3811
|
+
* status: 'active',
|
|
3812
|
+
* });
|
|
3813
|
+
* ```
|
|
3814
|
+
*/
|
|
3815
|
+
async updateTrendStatus(request) {
|
|
3816
|
+
return this.http.patch(`/marketing/trends/${request.trendId}/status`, {
|
|
3817
|
+
status: request.status
|
|
3818
|
+
});
|
|
3819
|
+
}
|
|
3527
3820
|
// ============================================================================
|
|
3528
3821
|
// Opportunities
|
|
3529
3822
|
// ============================================================================
|
|
@@ -3732,6 +4025,54 @@ var Marketing = class {
|
|
|
3732
4025
|
const response = await this.http.get(`/marketing/scripts/${scriptId}`);
|
|
3733
4026
|
return this.convertScriptDates(response);
|
|
3734
4027
|
}
|
|
4028
|
+
/**
|
|
4029
|
+
* Update a script
|
|
4030
|
+
*
|
|
4031
|
+
* @example
|
|
4032
|
+
* ```typescript
|
|
4033
|
+
* const updated = await marketing.updateScript({
|
|
4034
|
+
* scriptId: 'script-id',
|
|
4035
|
+
* hook: 'Updated hook line',
|
|
4036
|
+
* cta: 'New call to action!',
|
|
4037
|
+
* });
|
|
4038
|
+
* ```
|
|
4039
|
+
*/
|
|
4040
|
+
async updateScript(request) {
|
|
4041
|
+
const { scriptId, ...data } = request;
|
|
4042
|
+
const response = await this.http.patch(`/marketing/scripts/${scriptId}`, data);
|
|
4043
|
+
return this.convertScriptDates(response);
|
|
4044
|
+
}
|
|
4045
|
+
/**
|
|
4046
|
+
* Create a new version of a script
|
|
4047
|
+
*
|
|
4048
|
+
* @example
|
|
4049
|
+
* ```typescript
|
|
4050
|
+
* const newVersion = await marketing.createScriptVersion({
|
|
4051
|
+
* scriptId: 'script-id',
|
|
4052
|
+
* hook: 'Updated hook for v2',
|
|
4053
|
+
* slides: [...],
|
|
4054
|
+
* cta: 'Updated CTA',
|
|
4055
|
+
* });
|
|
4056
|
+
* ```
|
|
4057
|
+
*/
|
|
4058
|
+
async createScriptVersion(request) {
|
|
4059
|
+
const { scriptId, ...data } = request;
|
|
4060
|
+
const response = await this.http.post(`/marketing/scripts/${scriptId}/versions`, data);
|
|
4061
|
+
return this.convertScriptDates(response);
|
|
4062
|
+
}
|
|
4063
|
+
/**
|
|
4064
|
+
* Get all versions of a script
|
|
4065
|
+
*/
|
|
4066
|
+
async getScriptVersions(scriptId) {
|
|
4067
|
+
const response = await this.http.get(`/marketing/scripts/${scriptId}/versions`);
|
|
4068
|
+
return response.map((s) => this.convertScriptDates(s));
|
|
4069
|
+
}
|
|
4070
|
+
/**
|
|
4071
|
+
* Delete a script
|
|
4072
|
+
*/
|
|
4073
|
+
async deleteScript(scriptId) {
|
|
4074
|
+
return this.http.delete(`/marketing/scripts/${scriptId}`);
|
|
4075
|
+
}
|
|
3735
4076
|
// ============================================================================
|
|
3736
4077
|
// Analytics
|
|
3737
4078
|
// ============================================================================
|
|
@@ -3779,6 +4120,318 @@ var Marketing = class {
|
|
|
3779
4120
|
});
|
|
3780
4121
|
return this.http.get(`/marketing/analytics/performance?${params.toString()}`);
|
|
3781
4122
|
}
|
|
4123
|
+
/**
|
|
4124
|
+
* Get trend discovery analytics
|
|
4125
|
+
*
|
|
4126
|
+
* @example
|
|
4127
|
+
* ```typescript
|
|
4128
|
+
* const trendStats = await marketing.getTrendAnalytics({
|
|
4129
|
+
* projectSlug: 'my-project',
|
|
4130
|
+
* environment: 'production',
|
|
4131
|
+
* });
|
|
4132
|
+
* console.log(`Total trends: ${trendStats.totalTrends}`);
|
|
4133
|
+
* ```
|
|
4134
|
+
*/
|
|
4135
|
+
async getTrendAnalytics(request) {
|
|
4136
|
+
const params = new URLSearchParams({
|
|
4137
|
+
projectSlug: request.projectSlug,
|
|
4138
|
+
...request.environment && { environment: request.environment },
|
|
4139
|
+
...request.startDate && { startDate: request.startDate.toISOString() },
|
|
4140
|
+
...request.endDate && { endDate: request.endDate.toISOString() }
|
|
4141
|
+
});
|
|
4142
|
+
return this.http.get(`/marketing/analytics/trends?${params.toString()}`);
|
|
4143
|
+
}
|
|
4144
|
+
/**
|
|
4145
|
+
* Get opportunity conversion analytics
|
|
4146
|
+
*
|
|
4147
|
+
* @example
|
|
4148
|
+
* ```typescript
|
|
4149
|
+
* const conversion = await marketing.getOpportunityConversion({
|
|
4150
|
+
* projectSlug: 'my-project',
|
|
4151
|
+
* environment: 'production',
|
|
4152
|
+
* });
|
|
4153
|
+
* console.log(`Conversion rate: ${conversion.conversionRate}%`);
|
|
4154
|
+
* ```
|
|
4155
|
+
*/
|
|
4156
|
+
async getOpportunityConversion(request) {
|
|
4157
|
+
const params = new URLSearchParams({
|
|
4158
|
+
projectSlug: request.projectSlug,
|
|
4159
|
+
...request.environment && { environment: request.environment },
|
|
4160
|
+
...request.startDate && { startDate: request.startDate.toISOString() },
|
|
4161
|
+
...request.endDate && { endDate: request.endDate.toISOString() }
|
|
4162
|
+
});
|
|
4163
|
+
return this.http.get(`/marketing/analytics/conversion?${params.toString()}`);
|
|
4164
|
+
}
|
|
4165
|
+
// ============================================================================
|
|
4166
|
+
// Calendar
|
|
4167
|
+
// ============================================================================
|
|
4168
|
+
/**
|
|
4169
|
+
* Schedule content for publishing
|
|
4170
|
+
*
|
|
4171
|
+
* @example
|
|
4172
|
+
* ```typescript
|
|
4173
|
+
* const entry = await marketing.scheduleContent({
|
|
4174
|
+
* projectSlug: 'my-project',
|
|
4175
|
+
* contentId: 'content-id',
|
|
4176
|
+
* scheduledFor: new Date('2024-12-25T10:00:00Z'),
|
|
4177
|
+
* autoPublish: true,
|
|
4178
|
+
* });
|
|
4179
|
+
* ```
|
|
4180
|
+
*/
|
|
4181
|
+
async scheduleContent(request) {
|
|
4182
|
+
const response = await this.http.post("/marketing/calendar/schedule", {
|
|
4183
|
+
...request,
|
|
4184
|
+
scheduledFor: request.scheduledFor.toISOString()
|
|
4185
|
+
});
|
|
4186
|
+
return this.convertCalendarEntryDates(response);
|
|
4187
|
+
}
|
|
4188
|
+
/**
|
|
4189
|
+
* List scheduled content
|
|
4190
|
+
*
|
|
4191
|
+
* @example
|
|
4192
|
+
* ```typescript
|
|
4193
|
+
* const entries = await marketing.listCalendarEntries({
|
|
4194
|
+
* projectSlug: 'my-project',
|
|
4195
|
+
* startDate: new Date('2024-12-01'),
|
|
4196
|
+
* endDate: new Date('2024-12-31'),
|
|
4197
|
+
* });
|
|
4198
|
+
* ```
|
|
4199
|
+
*/
|
|
4200
|
+
async listCalendarEntries(request) {
|
|
4201
|
+
const params = new URLSearchParams({
|
|
4202
|
+
projectSlug: request.projectSlug,
|
|
4203
|
+
...request.environment && { environment: request.environment },
|
|
4204
|
+
...request.startDate && { startDate: request.startDate.toISOString() },
|
|
4205
|
+
...request.endDate && { endDate: request.endDate.toISOString() },
|
|
4206
|
+
...request.limit && { limit: request.limit.toString() },
|
|
4207
|
+
...request.offset && { offset: request.offset.toString() }
|
|
4208
|
+
});
|
|
4209
|
+
const response = await this.http.get(`/marketing/calendar?${params.toString()}`);
|
|
4210
|
+
return response.map((e) => this.convertCalendarEntryDates(e));
|
|
4211
|
+
}
|
|
4212
|
+
/**
|
|
4213
|
+
* Get a single calendar entry by ID
|
|
4214
|
+
*/
|
|
4215
|
+
async getCalendarEntry(entryId) {
|
|
4216
|
+
const response = await this.http.get(`/marketing/calendar/${entryId}`);
|
|
4217
|
+
return this.convertCalendarEntryDates(response);
|
|
4218
|
+
}
|
|
4219
|
+
/**
|
|
4220
|
+
* Update a calendar entry
|
|
4221
|
+
*
|
|
4222
|
+
* @example
|
|
4223
|
+
* ```typescript
|
|
4224
|
+
* const updated = await marketing.updateCalendarEntry({
|
|
4225
|
+
* entryId: 'entry-id',
|
|
4226
|
+
* scheduledFor: new Date('2024-12-26T10:00:00Z'),
|
|
4227
|
+
* });
|
|
4228
|
+
* ```
|
|
4229
|
+
*/
|
|
4230
|
+
async updateCalendarEntry(request) {
|
|
4231
|
+
const { entryId, ...data } = request;
|
|
4232
|
+
const response = await this.http.patch(`/marketing/calendar/${entryId}`, {
|
|
4233
|
+
...data,
|
|
4234
|
+
...data.scheduledFor && { scheduledFor: data.scheduledFor.toISOString() }
|
|
4235
|
+
});
|
|
4236
|
+
return this.convertCalendarEntryDates(response);
|
|
4237
|
+
}
|
|
4238
|
+
/**
|
|
4239
|
+
* Cancel a scheduled calendar entry
|
|
4240
|
+
*/
|
|
4241
|
+
async cancelCalendarEntry(entryId) {
|
|
4242
|
+
return this.http.post(`/marketing/calendar/${entryId}/cancel`, {});
|
|
4243
|
+
}
|
|
4244
|
+
/**
|
|
4245
|
+
* Mark content as published
|
|
4246
|
+
*/
|
|
4247
|
+
async markContentPublished(request) {
|
|
4248
|
+
const response = await this.http.post(`/marketing/calendar/${request.entryId}/published`, {
|
|
4249
|
+
...request.publishedAt && { publishedAt: request.publishedAt.toISOString() }
|
|
4250
|
+
});
|
|
4251
|
+
return this.convertCalendarEntryDates(response);
|
|
4252
|
+
}
|
|
4253
|
+
// ============================================================================
|
|
4254
|
+
// Assets (Asset Jobs)
|
|
4255
|
+
// ============================================================================
|
|
4256
|
+
/**
|
|
4257
|
+
* Create an asset generation job
|
|
4258
|
+
*
|
|
4259
|
+
* @example
|
|
4260
|
+
* ```typescript
|
|
4261
|
+
* const job = await marketing.createAssetJob({
|
|
4262
|
+
* projectSlug: 'my-project',
|
|
4263
|
+
* contentId: 'content-id',
|
|
4264
|
+
* jobType: 'slide_generation',
|
|
4265
|
+
* input: { style: 'modern' },
|
|
4266
|
+
* });
|
|
4267
|
+
* ```
|
|
4268
|
+
*/
|
|
4269
|
+
async createAssetJob(request) {
|
|
4270
|
+
const response = await this.http.post("/marketing/assets/jobs", request);
|
|
4271
|
+
return this.convertAssetJobDates(response);
|
|
4272
|
+
}
|
|
4273
|
+
/**
|
|
4274
|
+
* List asset jobs
|
|
4275
|
+
*
|
|
4276
|
+
* @example
|
|
4277
|
+
* ```typescript
|
|
4278
|
+
* const jobs = await marketing.listAssetJobs({
|
|
4279
|
+
* projectSlug: 'my-project',
|
|
4280
|
+
* status: 'processing',
|
|
4281
|
+
* });
|
|
4282
|
+
* ```
|
|
4283
|
+
*/
|
|
4284
|
+
async listAssetJobs(request) {
|
|
4285
|
+
const params = new URLSearchParams({
|
|
4286
|
+
projectSlug: request.projectSlug,
|
|
4287
|
+
...request.contentId && { contentId: request.contentId },
|
|
4288
|
+
...request.status && { status: request.status },
|
|
4289
|
+
...request.jobType && { jobType: request.jobType },
|
|
4290
|
+
...request.limit && { limit: request.limit.toString() },
|
|
4291
|
+
...request.offset && { offset: request.offset.toString() }
|
|
4292
|
+
});
|
|
4293
|
+
const response = await this.http.get(`/marketing/assets/jobs?${params.toString()}`);
|
|
4294
|
+
return response.map((j) => this.convertAssetJobDates(j));
|
|
4295
|
+
}
|
|
4296
|
+
/**
|
|
4297
|
+
* Get an asset job by ID
|
|
4298
|
+
*/
|
|
4299
|
+
async getAssetJob(jobId) {
|
|
4300
|
+
const response = await this.http.get(`/marketing/assets/jobs/${jobId}`);
|
|
4301
|
+
return this.convertAssetJobDates(response);
|
|
4302
|
+
}
|
|
4303
|
+
/**
|
|
4304
|
+
* Update asset job status
|
|
4305
|
+
*/
|
|
4306
|
+
async updateAssetJobStatus(request) {
|
|
4307
|
+
const { jobId, ...data } = request;
|
|
4308
|
+
const response = await this.http.patch(`/marketing/assets/jobs/${jobId}/status`, data);
|
|
4309
|
+
return this.convertAssetJobDates(response);
|
|
4310
|
+
}
|
|
4311
|
+
/**
|
|
4312
|
+
* Retry a failed asset job
|
|
4313
|
+
*/
|
|
4314
|
+
async retryAssetJob(jobId) {
|
|
4315
|
+
const response = await this.http.post(`/marketing/assets/jobs/${jobId}/retry`, {});
|
|
4316
|
+
return this.convertAssetJobDates(response);
|
|
4317
|
+
}
|
|
4318
|
+
/**
|
|
4319
|
+
* Cancel an asset job
|
|
4320
|
+
*/
|
|
4321
|
+
async cancelAssetJob(jobId) {
|
|
4322
|
+
const response = await this.http.post(`/marketing/assets/jobs/${jobId}/cancel`, {});
|
|
4323
|
+
return this.convertAssetJobDates(response);
|
|
4324
|
+
}
|
|
4325
|
+
// ============================================================================
|
|
4326
|
+
// Settings
|
|
4327
|
+
// ============================================================================
|
|
4328
|
+
/**
|
|
4329
|
+
* Get marketing settings for a project
|
|
4330
|
+
*
|
|
4331
|
+
* @example
|
|
4332
|
+
* ```typescript
|
|
4333
|
+
* const settings = await marketing.getSettings({
|
|
4334
|
+
* projectSlug: 'my-project',
|
|
4335
|
+
* environment: 'production',
|
|
4336
|
+
* });
|
|
4337
|
+
* console.log(`Brand voice: ${settings.brandVoice}`);
|
|
4338
|
+
* ```
|
|
4339
|
+
*/
|
|
4340
|
+
async getSettings(request) {
|
|
4341
|
+
const params = new URLSearchParams({
|
|
4342
|
+
projectSlug: request.projectSlug,
|
|
4343
|
+
...request.environment && { environment: request.environment }
|
|
4344
|
+
});
|
|
4345
|
+
return this.http.get(`/marketing/settings?${params.toString()}`);
|
|
4346
|
+
}
|
|
4347
|
+
/**
|
|
4348
|
+
* Update marketing settings
|
|
4349
|
+
*
|
|
4350
|
+
* @example
|
|
4351
|
+
* ```typescript
|
|
4352
|
+
* await marketing.updateSettings({
|
|
4353
|
+
* projectSlug: 'my-project',
|
|
4354
|
+
* brandVoice: 'Professional yet approachable',
|
|
4355
|
+
* monitoredKeywords: ['AI', 'startup', 'tech'],
|
|
4356
|
+
* });
|
|
4357
|
+
* ```
|
|
4358
|
+
*/
|
|
4359
|
+
async updateSettings(request) {
|
|
4360
|
+
return this.http.post("/marketing/settings", request);
|
|
4361
|
+
}
|
|
4362
|
+
// ============================================================================
|
|
4363
|
+
// Usage
|
|
4364
|
+
// ============================================================================
|
|
4365
|
+
/**
|
|
4366
|
+
* Get current period usage
|
|
4367
|
+
*
|
|
4368
|
+
* @example
|
|
4369
|
+
* ```typescript
|
|
4370
|
+
* const usage = await marketing.getCurrentUsage({
|
|
4371
|
+
* projectSlug: 'my-project',
|
|
4372
|
+
* environment: 'production',
|
|
4373
|
+
* });
|
|
4374
|
+
* console.log(`AI tokens used: ${usage.aiTokensUsed}`);
|
|
4375
|
+
* ```
|
|
4376
|
+
*/
|
|
4377
|
+
async getCurrentUsage(request) {
|
|
4378
|
+
const params = new URLSearchParams({
|
|
4379
|
+
projectSlug: request.projectSlug,
|
|
4380
|
+
...request.environment && { environment: request.environment }
|
|
4381
|
+
});
|
|
4382
|
+
const response = await this.http.get(`/marketing/usage/current?${params.toString()}`);
|
|
4383
|
+
return this.convertUsageDates(response);
|
|
4384
|
+
}
|
|
4385
|
+
/**
|
|
4386
|
+
* Get usage history
|
|
4387
|
+
*
|
|
4388
|
+
* @example
|
|
4389
|
+
* ```typescript
|
|
4390
|
+
* const history = await marketing.getUsageHistory({
|
|
4391
|
+
* projectSlug: 'my-project',
|
|
4392
|
+
* limit: 6, // Last 6 months
|
|
4393
|
+
* });
|
|
4394
|
+
* ```
|
|
4395
|
+
*/
|
|
4396
|
+
async getUsageHistory(request) {
|
|
4397
|
+
const params = new URLSearchParams({
|
|
4398
|
+
projectSlug: request.projectSlug,
|
|
4399
|
+
...request.environment && { environment: request.environment },
|
|
4400
|
+
...request.startDate && { startDate: request.startDate.toISOString() },
|
|
4401
|
+
...request.endDate && { endDate: request.endDate.toISOString() },
|
|
4402
|
+
...request.limit && { limit: request.limit.toString() }
|
|
4403
|
+
});
|
|
4404
|
+
const response = await this.http.get(`/marketing/usage/history?${params.toString()}`);
|
|
4405
|
+
return response.map((u) => this.convertMarketingUsageDates(u));
|
|
4406
|
+
}
|
|
4407
|
+
/**
|
|
4408
|
+
* Get total usage across all periods
|
|
4409
|
+
*
|
|
4410
|
+
* @example
|
|
4411
|
+
* ```typescript
|
|
4412
|
+
* const totals = await marketing.getTotalUsage({
|
|
4413
|
+
* projectSlug: 'my-project',
|
|
4414
|
+
* startDate: new Date('2024-01-01'),
|
|
4415
|
+
* });
|
|
4416
|
+
* console.log(`Total content generated: ${totals.contentGenerated}`);
|
|
4417
|
+
* ```
|
|
4418
|
+
*/
|
|
4419
|
+
async getTotalUsage(request) {
|
|
4420
|
+
const params = new URLSearchParams({
|
|
4421
|
+
projectSlug: request.projectSlug,
|
|
4422
|
+
...request.environment && { environment: request.environment },
|
|
4423
|
+
...request.startDate && { startDate: request.startDate.toISOString() },
|
|
4424
|
+
...request.endDate && { endDate: request.endDate.toISOString() }
|
|
4425
|
+
});
|
|
4426
|
+
return this.http.get(`/marketing/usage/total?${params.toString()}`);
|
|
4427
|
+
}
|
|
4428
|
+
/**
|
|
4429
|
+
* Record usage (typically called internally)
|
|
4430
|
+
*/
|
|
4431
|
+
async recordUsage(request) {
|
|
4432
|
+
const response = await this.http.post("/marketing/usage/record", request);
|
|
4433
|
+
return this.convertMarketingUsageDates(response);
|
|
4434
|
+
}
|
|
3782
4435
|
// ============================================================================
|
|
3783
4436
|
// Date Conversion Helpers
|
|
3784
4437
|
// ============================================================================
|
|
@@ -3830,6 +4483,57 @@ var Marketing = class {
|
|
|
3830
4483
|
}
|
|
3831
4484
|
return script;
|
|
3832
4485
|
}
|
|
4486
|
+
convertCalendarEntryDates(entry) {
|
|
4487
|
+
if (typeof entry.scheduledFor === "string") {
|
|
4488
|
+
entry.scheduledFor = new Date(entry.scheduledFor);
|
|
4489
|
+
}
|
|
4490
|
+
if (typeof entry.createdAt === "string") {
|
|
4491
|
+
entry.createdAt = new Date(entry.createdAt);
|
|
4492
|
+
}
|
|
4493
|
+
if (entry.updatedAt && typeof entry.updatedAt === "string") {
|
|
4494
|
+
entry.updatedAt = new Date(entry.updatedAt);
|
|
4495
|
+
}
|
|
4496
|
+
if (entry.publishedAt && typeof entry.publishedAt === "string") {
|
|
4497
|
+
entry.publishedAt = new Date(entry.publishedAt);
|
|
4498
|
+
}
|
|
4499
|
+
return entry;
|
|
4500
|
+
}
|
|
4501
|
+
convertAssetJobDates(job) {
|
|
4502
|
+
if (typeof job.createdAt === "string") {
|
|
4503
|
+
job.createdAt = new Date(job.createdAt);
|
|
4504
|
+
}
|
|
4505
|
+
if (job.startedAt && typeof job.startedAt === "string") {
|
|
4506
|
+
job.startedAt = new Date(job.startedAt);
|
|
4507
|
+
}
|
|
4508
|
+
if (job.completedAt && typeof job.completedAt === "string") {
|
|
4509
|
+
job.completedAt = new Date(job.completedAt);
|
|
4510
|
+
}
|
|
4511
|
+
return job;
|
|
4512
|
+
}
|
|
4513
|
+
convertUsageDates(usage) {
|
|
4514
|
+
if (typeof usage.periodStart === "string") {
|
|
4515
|
+
usage.periodStart = new Date(usage.periodStart);
|
|
4516
|
+
}
|
|
4517
|
+
if (typeof usage.periodEnd === "string") {
|
|
4518
|
+
usage.periodEnd = new Date(usage.periodEnd);
|
|
4519
|
+
}
|
|
4520
|
+
return usage;
|
|
4521
|
+
}
|
|
4522
|
+
convertMarketingUsageDates(usage) {
|
|
4523
|
+
if (typeof usage.periodStart === "string") {
|
|
4524
|
+
usage.periodStart = new Date(usage.periodStart);
|
|
4525
|
+
}
|
|
4526
|
+
if (typeof usage.periodEnd === "string") {
|
|
4527
|
+
usage.periodEnd = new Date(usage.periodEnd);
|
|
4528
|
+
}
|
|
4529
|
+
if (typeof usage.createdAt === "string") {
|
|
4530
|
+
usage.createdAt = new Date(usage.createdAt);
|
|
4531
|
+
}
|
|
4532
|
+
if (usage.updatedAt && typeof usage.updatedAt === "string") {
|
|
4533
|
+
usage.updatedAt = new Date(usage.updatedAt);
|
|
4534
|
+
}
|
|
4535
|
+
return usage;
|
|
4536
|
+
}
|
|
3833
4537
|
};
|
|
3834
4538
|
|
|
3835
4539
|
// src/index.ts
|