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