@stackshift-cloud/sdk 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -1
- package/dist/ai-credits.d.ts +78 -0
- package/dist/ai-credits.js +15 -0
- package/dist/assets-dam-types.d.ts +259 -0
- package/dist/assets-dam-types.js +1 -0
- package/dist/assets-dam.d.ts +106 -0
- package/dist/assets-dam.js +52 -0
- package/dist/assets-video-types.d.ts +116 -0
- package/dist/assets-video-types.js +1 -0
- package/dist/assets-video.d.ts +25 -0
- package/dist/assets-video.js +19 -0
- package/dist/assets.d.ts +5 -1
- package/dist/assets.js +11 -2
- package/dist/client.d.ts +6 -0
- package/dist/client.js +14 -0
- package/dist/generated/assets-contract.d.ts +531 -1
- package/dist/generated/assets-contract.js +106 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +9 -0
- package/dist/mail-advanced-types.d.ts +9 -0
- package/dist/mail-billing.d.ts +34 -0
- package/dist/mail-billing.js +7 -0
- package/dist/mail-brands.d.ts +35 -0
- package/dist/mail-brands.js +17 -0
- package/dist/mail-campaigns.d.ts +72 -10
- package/dist/mail-campaigns.js +25 -2
- package/dist/mail-marketing.d.ts +84 -0
- package/dist/mail-marketing.js +24 -0
- package/dist/mail-migration.d.ts +16 -0
- package/dist/mail-migration.js +10 -0
- package/dist/mail-otp-types.d.ts +4 -0
- package/dist/mail-simulation.d.ts +4 -0
- package/dist/mail-simulation.js +1 -0
- package/dist/mail-subscribers.d.ts +39 -0
- package/dist/mail-subscribers.js +1 -0
- package/dist/mail-template-types.d.ts +8 -0
- package/dist/mail-tracking.d.ts +59 -0
- package/dist/mail-tracking.js +14 -0
- package/dist/mail-webhook-types.d.ts +4 -1
- package/dist/mail.d.ts +12 -0
- package/dist/mail.js +19 -0
- package/dist/types.d.ts +13 -0
- package/dist/workload-security.d.ts +172 -0
- package/dist/workload-security.js +50 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
Official JavaScript and TypeScript SDK for StackShift.
|
|
4
4
|
|
|
5
|
+
## Governed media and galleries
|
|
6
|
+
|
|
7
|
+
Use a separate server-side client for each Assets space; the namespace is fixed on that client. Project membership does not grant Assets access.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const studio = new StackShift({
|
|
11
|
+
apiKey: process.env.STACKSHIFT_API_KEY,
|
|
12
|
+
assetSpaceId: 'your-asset-space-uuid',
|
|
13
|
+
})
|
|
14
|
+
const page = await studio.assets.dam.publications({ status: 'published' })
|
|
15
|
+
if (page.next_cursor) {
|
|
16
|
+
const next = await studio.assets.dam.publications({ status: 'published', cursor: page.next_cursor })
|
|
17
|
+
}
|
|
18
|
+
const gallery = await studio.assets.dam.resolveGallery('published-gallery-uuid')
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`assets.dam` also exposes collaborators, typed metadata schemas, bucket governance, publication transitions, model processing, gallery drafts and picker capabilities. Updates use explicit revisions. Submission needs `assets:write`, review needs `assets:admin`, and publication/withdrawal needs `assets:publish`, in addition to the corresponding Assets grant.
|
|
22
|
+
|
|
23
|
+
Keep account credentials on your server. Give `@stackshift-cloud/assets-picker` a short-lived, origin-restricted capability; give `@stackshift-cloud/assets-gallery` a server resolver for approved media. Store publication/gallery IDs and versions, never delivery URLs. Model processing is an explicitly enabled pilot and requires the qualified isolated worker described in `packages/assets-model-processor/README.md`.
|
|
24
|
+
|
|
5
25
|
## Install
|
|
6
26
|
|
|
7
27
|
```bash
|
|
@@ -14,6 +34,27 @@ Set your API key:
|
|
|
14
34
|
STACKSHIFT_API_KEY=sk_live_xxx
|
|
15
35
|
```
|
|
16
36
|
|
|
37
|
+
## AI credits
|
|
38
|
+
|
|
39
|
+
AI credits are account-scoped. Inspect the balance and usage, create a top-up checkout, or choose managed billing versus your own provider key:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { StackShift } from '@stackshift-cloud/sdk'
|
|
43
|
+
|
|
44
|
+
const stackshift = new StackShift()
|
|
45
|
+
const balance = await stackshift.aiCredits.balance()
|
|
46
|
+
const usage = await stackshift.aiCredits.usage({ product: 'assets', limit: 25 })
|
|
47
|
+
const quote = await stackshift.aiCredits.quote(1_000, 'USD')
|
|
48
|
+
const checkout = await stackshift.aiCredits.checkout({
|
|
49
|
+
quote_id: quote.id,
|
|
50
|
+
idempotency_key: crypto.randomUUID(),
|
|
51
|
+
provider: 'paystack',
|
|
52
|
+
})
|
|
53
|
+
await stackshift.aiCredits.setFunding('assets', 'managed')
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Keep account API keys and checkout creation on your server. An Assets space ID does not change which billing account these methods use.
|
|
57
|
+
|
|
17
58
|
## Send email
|
|
18
59
|
|
|
19
60
|
```ts
|
|
@@ -276,7 +317,7 @@ const capability = await stackshift.assets.uploadCapabilities.create({
|
|
|
276
317
|
})
|
|
277
318
|
```
|
|
278
319
|
|
|
279
|
-
Create capabilities only in trusted backend code. Send `capability.token` to `@stackshift/assets-widget`; never put the Stackshift API key in a browser bundle.
|
|
320
|
+
Create capabilities only in trusted backend code. Send `capability.token` to `@stackshift-cloud/assets-widget`; never put the Stackshift API key in a browser bundle.
|
|
280
321
|
|
|
281
322
|
For larger uploads, create a signed upload URL on your NestJS server and let the browser upload directly.
|
|
282
323
|
|
|
@@ -307,3 +348,40 @@ await fetch(upload.url, {
|
|
|
307
348
|
This is the recommended pattern for React, Next.js, TanStack Start, and any browser app. The browser never receives your StackShift API key.
|
|
308
349
|
|
|
309
350
|
StackShift chooses storage nodes, writes to StackShift-owned disks, replicates internally, and returns CDN-ready asset URLs. SDK users never choose storage nodes and never receive disk paths.
|
|
351
|
+
|
|
352
|
+
### Campaign drafts and engagement
|
|
353
|
+
|
|
354
|
+
Create campaigns with `content: { subject, html, text, editorMode: 'code' }`, or keep using a template/version. `mail.campaigns.update(id, { ...draft, revision })` saves a full draft; `preview`, `test`, `send(id, revision)`, and `schedule(id, sendAt, revision)` support review and dispatch. A stale revision returns 409.
|
|
355
|
+
|
|
356
|
+
Mail send inputs accept `tracking: { opens: false, clicks: true }`. Each omitted setting inherits the workspace default. Use `mail.tracking.settings()` / `updateSettings()`, `message(id)` / `campaign(id)` for reports, and `domains()` / `createDomain()` / `verifyDomain()` / `updateDomain()` for branded hosts. Features must be enabled on the deployment. Opens are approximate; suspected automation is reported separately. Detailed activity expires after 90 days. Tests and OTPs never track.
|
|
357
|
+
|
|
358
|
+
### Isolated testing, brands, migration, and spending
|
|
359
|
+
|
|
360
|
+
Use a `sspat_test_` credential with `simulation: { scenario: 'delayed' }` for a 60-second simulated delay. Other outcomes are delivered, bounced, and complained. Test resources are isolated; no real email is delivered.
|
|
361
|
+
|
|
362
|
+
```ts
|
|
363
|
+
const brand = await client.mail.brands.create({ name: 'Product', editableFields: ['company'] })
|
|
364
|
+
const audience = await client.mail.audiences.create({ brandId: brand.id, name: 'Product news' })
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
Every audience requires an explicit brand. Contact names/attributes are shared within that brand while consent stays per audience. `mail.automations`, `mail.forms`, and `mail.segments` expose audience-owned resources.
|
|
368
|
+
|
|
369
|
+
`mail.migration` supports public DNS audits/plans and authenticated checklists. `mail.billing.summary()` and `mail.campaigns.estimate(id)` expose allowance, credit, and blocking reasons. Pass approved maximum kobo as the third argument to `send(id, revision, approvedMaxKobo)` or the fourth to `schedule(id, sendAt, revision, approvedMaxKobo)`. Zero is a valid hard maximum. Billing is inactive until a rate card is explicitly published and activated; funding and prepaid opt-in are separate owner-only dashboard actions.
|
|
370
|
+
|
|
371
|
+
## Native video, governed DAM and product rendering
|
|
372
|
+
|
|
373
|
+
Use the space-scoped DAM and video clients for collaborators, metadata schemas, bucket governance, reviewed publications, picker capabilities, model preparation, product rendering, galleries, version-pinned encoding, captions and playback sessions.
|
|
374
|
+
|
|
375
|
+
```ts
|
|
376
|
+
const dam = sdk.assets.dam
|
|
377
|
+
const video = sdk.assets.video
|
|
378
|
+
const schema = await dam.createMetadataSchema({ name: 'Products', fields: [{
|
|
379
|
+
key: 'product_name', label: 'Product name', type: 'text', required: true,
|
|
380
|
+
}] })
|
|
381
|
+
const published = await dam.publishMetadataSchema(schema.id, schema.revision)
|
|
382
|
+
const workspace = await video.workspace(assetId)
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
Mutations carry the supplied revision in `If-Match`. Model preparation and rendering carry an idempotency key; render submission also carries the accepted maximum units. Playback renewal and events authenticate with the session credential, not the account key. Keep these clients on your backend and return grants with `Cache-Control: private, no-store`.
|
|
386
|
+
|
|
387
|
+
See the [Assets SDK guide](https://docs.stackshift.cloud/assets/sdk-media-workflows) and its linked feature guides for complete language examples, inputs, permissions, review transitions and browser callbacks.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { StackShift } from './client.js';
|
|
2
|
+
export interface AICreditGrant {
|
|
3
|
+
id: string;
|
|
4
|
+
kind: string;
|
|
5
|
+
source: string;
|
|
6
|
+
policy_revision: number;
|
|
7
|
+
amount_microcredits: number;
|
|
8
|
+
remaining_microcredits: number;
|
|
9
|
+
available_at: string;
|
|
10
|
+
expires_at: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface AICreditBalance {
|
|
13
|
+
available_microcredits: number;
|
|
14
|
+
monthly_microcredits: number;
|
|
15
|
+
purchased_microcredits: number;
|
|
16
|
+
reserved_microcredits: number;
|
|
17
|
+
shortfall_microcredits: number;
|
|
18
|
+
next_reset: string;
|
|
19
|
+
grants: AICreditGrant[];
|
|
20
|
+
}
|
|
21
|
+
export interface AICreditUsage {
|
|
22
|
+
id: string;
|
|
23
|
+
operation_key: string;
|
|
24
|
+
product: string;
|
|
25
|
+
feature: string;
|
|
26
|
+
user_id: string;
|
|
27
|
+
project_id?: string;
|
|
28
|
+
space_id?: string;
|
|
29
|
+
parent_task_id?: string;
|
|
30
|
+
funding_mode: string;
|
|
31
|
+
state: string;
|
|
32
|
+
created_at: string;
|
|
33
|
+
reserved_microcredits: number;
|
|
34
|
+
used_microcredits: number;
|
|
35
|
+
returned_microcredits: number;
|
|
36
|
+
}
|
|
37
|
+
export interface AICreditUsagePage {
|
|
38
|
+
items: AICreditUsage[];
|
|
39
|
+
totals_microcredits: Record<string, number>;
|
|
40
|
+
}
|
|
41
|
+
export interface AICreditQuote {
|
|
42
|
+
id: string;
|
|
43
|
+
catalog_revision: number;
|
|
44
|
+
credit_microcredits: number;
|
|
45
|
+
amount_minor: number;
|
|
46
|
+
currency: string;
|
|
47
|
+
expires_at: string;
|
|
48
|
+
}
|
|
49
|
+
export interface AICreditCheckout {
|
|
50
|
+
reference: string;
|
|
51
|
+
status: string;
|
|
52
|
+
authorization_url?: string;
|
|
53
|
+
}
|
|
54
|
+
export type AIFundingPreferences = Record<'assets' | 'agents' | 'workflows', 'managed' | 'byok'>;
|
|
55
|
+
export declare class AICreditsClient {
|
|
56
|
+
private readonly client;
|
|
57
|
+
constructor(client: StackShift);
|
|
58
|
+
balance(): Promise<AICreditBalance>;
|
|
59
|
+
usage(filters?: {
|
|
60
|
+
product?: string;
|
|
61
|
+
user?: string;
|
|
62
|
+
project?: string;
|
|
63
|
+
space?: string;
|
|
64
|
+
from?: string;
|
|
65
|
+
until?: string;
|
|
66
|
+
before_time?: string;
|
|
67
|
+
before_id?: string;
|
|
68
|
+
limit?: number;
|
|
69
|
+
}): Promise<AICreditUsagePage>;
|
|
70
|
+
quote(credits: number, currency: 'USD' | 'NGN'): Promise<AICreditQuote>;
|
|
71
|
+
checkout(input: {
|
|
72
|
+
quote_id: string;
|
|
73
|
+
idempotency_key: string;
|
|
74
|
+
provider: string;
|
|
75
|
+
}): Promise<AICreditCheckout>;
|
|
76
|
+
funding(): Promise<AIFundingPreferences>;
|
|
77
|
+
setFunding(product: 'assets' | 'agents' | 'workflows', mode: 'managed' | 'byok'): Promise<AIFundingPreferences>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class AICreditsClient {
|
|
2
|
+
client;
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
balance() { return this.client.request('/billing/ai-credits', { method: 'GET' }); }
|
|
7
|
+
usage(filters = {}) {
|
|
8
|
+
const query = new URLSearchParams(Object.entries(filters).filter(([, v]) => v !== undefined).map(([k, v]) => [k, String(v)]));
|
|
9
|
+
return this.client.request(`/billing/ai-credits/usage?${query}`, { method: 'GET' });
|
|
10
|
+
}
|
|
11
|
+
quote(credits, currency) { return this.client.request('/billing/ai-credits/top-ups/quote', { method: 'POST', body: { credits, currency } }); }
|
|
12
|
+
checkout(input) { return this.client.request('/billing/ai-credits/top-ups/checkout', { method: 'POST', body: input }); }
|
|
13
|
+
funding() { return this.client.request('/billing/ai-credits/funding', { method: 'GET' }); }
|
|
14
|
+
setFunding(product, mode) { return this.client.request('/billing/ai-credits/funding', { method: 'PUT', body: { product, mode } }); }
|
|
15
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
export type AssetAction = 'read' | 'upload' | 'edit_metadata' | 'process' | 'review' | 'publish' | 'download_original' | 'curate' | 'manage_policy' | 'manage_access';
|
|
2
|
+
export interface AssetSpaceAccess {
|
|
3
|
+
id: string;
|
|
4
|
+
owner_id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
actions: AssetAction[];
|
|
7
|
+
collection_ids: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface AssetCollaborator {
|
|
10
|
+
id: string;
|
|
11
|
+
asset_space_id: string;
|
|
12
|
+
email: string;
|
|
13
|
+
user_id?: string;
|
|
14
|
+
collection_id?: string;
|
|
15
|
+
actions: AssetAction[];
|
|
16
|
+
status: string;
|
|
17
|
+
revision: number;
|
|
18
|
+
expires_at: string;
|
|
19
|
+
}
|
|
20
|
+
export interface AssetMetadataField {
|
|
21
|
+
key: string;
|
|
22
|
+
label: string;
|
|
23
|
+
type: 'text' | 'integer' | 'decimal' | 'boolean' | 'date' | 'single_choice' | 'multiple_choice';
|
|
24
|
+
required?: boolean;
|
|
25
|
+
searchable?: boolean;
|
|
26
|
+
options?: string[];
|
|
27
|
+
minimum?: number;
|
|
28
|
+
maximum?: number;
|
|
29
|
+
max_length?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface AssetMetadataSchema {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
revision: number;
|
|
35
|
+
published_revision?: number;
|
|
36
|
+
fields: AssetMetadataField[];
|
|
37
|
+
}
|
|
38
|
+
export interface AssetBucketGovernance {
|
|
39
|
+
bucket_id: string;
|
|
40
|
+
revision: number;
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
migrating: boolean;
|
|
43
|
+
schema_id?: string;
|
|
44
|
+
schema_revision?: number;
|
|
45
|
+
require_other_reviewer: boolean;
|
|
46
|
+
allow_ar: boolean;
|
|
47
|
+
channels: string[];
|
|
48
|
+
}
|
|
49
|
+
export interface AssetMediaReference {
|
|
50
|
+
render_set_id?: string;
|
|
51
|
+
render_role?: string;
|
|
52
|
+
spin_frame?: number;
|
|
53
|
+
language?: string;
|
|
54
|
+
label?: string;
|
|
55
|
+
caption_kind?: 'captions' | 'subtitles';
|
|
56
|
+
is_default?: boolean;
|
|
57
|
+
asset_id: string;
|
|
58
|
+
version_id: string;
|
|
59
|
+
rendition_id: string;
|
|
60
|
+
kind: 'image' | 'video' | 'model' | 'usdz' | 'caption';
|
|
61
|
+
role: 'media' | 'poster' | 'fallback' | 'caption' | 'usdz' | 'spin_frame';
|
|
62
|
+
output_checksum_sha256?: string;
|
|
63
|
+
policy_revision?: number;
|
|
64
|
+
}
|
|
65
|
+
export interface AssetPublicationRights {
|
|
66
|
+
owner: string;
|
|
67
|
+
attribution: string;
|
|
68
|
+
starts_at?: string;
|
|
69
|
+
expires_at?: string;
|
|
70
|
+
}
|
|
71
|
+
export type AssetPublicationStatus = 'draft' | 'in_review' | 'approved' | 'published' | 'withdrawn';
|
|
72
|
+
export interface AssetPublicationInput {
|
|
73
|
+
asset_id: string;
|
|
74
|
+
asset_revision: number;
|
|
75
|
+
channel: string;
|
|
76
|
+
renditions: AssetMediaReference[];
|
|
77
|
+
rights: AssetPublicationRights;
|
|
78
|
+
}
|
|
79
|
+
export interface AssetPublication {
|
|
80
|
+
id: string;
|
|
81
|
+
asset_id: string;
|
|
82
|
+
version_id: string;
|
|
83
|
+
channel: string;
|
|
84
|
+
status: AssetPublicationStatus;
|
|
85
|
+
revision: number;
|
|
86
|
+
metadata_revision: number;
|
|
87
|
+
metadata: Record<string, unknown>;
|
|
88
|
+
renditions: AssetMediaReference[];
|
|
89
|
+
rights: AssetPublicationRights;
|
|
90
|
+
reviewed_by?: string;
|
|
91
|
+
review_note?: string;
|
|
92
|
+
}
|
|
93
|
+
export interface AssetPublicationDelivery {
|
|
94
|
+
publication_id: string;
|
|
95
|
+
expires_at: string;
|
|
96
|
+
attribution: string;
|
|
97
|
+
ar_allowed: boolean;
|
|
98
|
+
renditions: Array<{
|
|
99
|
+
reference: AssetMediaReference;
|
|
100
|
+
url: string;
|
|
101
|
+
mp4_url?: string;
|
|
102
|
+
poster_url?: string;
|
|
103
|
+
}>;
|
|
104
|
+
}
|
|
105
|
+
export interface AssetPickerCapabilityInput {
|
|
106
|
+
buckets?: string[];
|
|
107
|
+
collections?: string[];
|
|
108
|
+
origins: string[];
|
|
109
|
+
channel: string;
|
|
110
|
+
result_limit?: number;
|
|
111
|
+
expires_in_seconds?: number;
|
|
112
|
+
actions?: ('search' | 'select')[];
|
|
113
|
+
}
|
|
114
|
+
export interface AssetPickerCapability {
|
|
115
|
+
id: string;
|
|
116
|
+
expires_at: string;
|
|
117
|
+
origins: string[];
|
|
118
|
+
channel: string;
|
|
119
|
+
result_limit: number;
|
|
120
|
+
}
|
|
121
|
+
export interface AssetModelPackage {
|
|
122
|
+
id: string;
|
|
123
|
+
asset_id: string;
|
|
124
|
+
version_id: string;
|
|
125
|
+
kind: 'glb' | 'usdz';
|
|
126
|
+
status: 'queued' | 'processing' | 'ready' | 'failed';
|
|
127
|
+
rendition_id?: string;
|
|
128
|
+
failure_reason?: string;
|
|
129
|
+
report: Record<string, unknown>;
|
|
130
|
+
updated_at: string;
|
|
131
|
+
}
|
|
132
|
+
export interface AssetModelTextureOverride {
|
|
133
|
+
texture_index: number;
|
|
134
|
+
asset_id: string;
|
|
135
|
+
version_id: string;
|
|
136
|
+
checksum_sha256: string;
|
|
137
|
+
}
|
|
138
|
+
export interface AssetModelVariant {
|
|
139
|
+
id: string;
|
|
140
|
+
asset_id: string;
|
|
141
|
+
source_version_id: string;
|
|
142
|
+
source_checksum_sha256: string;
|
|
143
|
+
name: string;
|
|
144
|
+
swatch: {
|
|
145
|
+
label: string;
|
|
146
|
+
color: string;
|
|
147
|
+
};
|
|
148
|
+
texture_overrides: AssetModelTextureOverride[];
|
|
149
|
+
revision: number;
|
|
150
|
+
}
|
|
151
|
+
export interface AssetModelVariantInput {
|
|
152
|
+
name: string;
|
|
153
|
+
source_version_id: string;
|
|
154
|
+
source_checksum_sha256: string;
|
|
155
|
+
swatch: {
|
|
156
|
+
label: string;
|
|
157
|
+
color: string;
|
|
158
|
+
};
|
|
159
|
+
texture_overrides: AssetModelTextureOverride[];
|
|
160
|
+
expected_revision?: number;
|
|
161
|
+
}
|
|
162
|
+
export interface AssetGalleryEntryInput {
|
|
163
|
+
publication_id: string;
|
|
164
|
+
fallback_publication_id?: string;
|
|
165
|
+
role: 'hero' | 'detail' | 'media';
|
|
166
|
+
locale: string;
|
|
167
|
+
alt: string;
|
|
168
|
+
}
|
|
169
|
+
export interface AssetGalleryEntry extends AssetGalleryEntryInput {
|
|
170
|
+
asset_id: string;
|
|
171
|
+
version_id: string;
|
|
172
|
+
publication_revision: number;
|
|
173
|
+
fallback_revision?: number;
|
|
174
|
+
}
|
|
175
|
+
export interface AssetGallery {
|
|
176
|
+
id: string;
|
|
177
|
+
name: string;
|
|
178
|
+
revision: number;
|
|
179
|
+
published_revision?: number;
|
|
180
|
+
entries: AssetGalleryEntry[];
|
|
181
|
+
}
|
|
182
|
+
export interface AssetGalleryDelivery {
|
|
183
|
+
gallery_id: string;
|
|
184
|
+
name: string;
|
|
185
|
+
revision: number;
|
|
186
|
+
entries: Array<{
|
|
187
|
+
reference: AssetGalleryEntry;
|
|
188
|
+
delivery?: AssetPublicationDelivery;
|
|
189
|
+
fallback_delivery?: AssetPublicationDelivery;
|
|
190
|
+
unavailable?: boolean;
|
|
191
|
+
}>;
|
|
192
|
+
}
|
|
193
|
+
export interface AssetRenderRecipe {
|
|
194
|
+
environment: 'neutral' | 'pillars';
|
|
195
|
+
orbit: number;
|
|
196
|
+
elevation: number;
|
|
197
|
+
zoom: number;
|
|
198
|
+
exposure: number;
|
|
199
|
+
shadow: number;
|
|
200
|
+
background: string;
|
|
201
|
+
size: 512 | 1024;
|
|
202
|
+
}
|
|
203
|
+
export type AssetRenderOutput = 'proof' | 'poster' | 'spin' | 'turntable' | 'model' | 'usdz';
|
|
204
|
+
export interface AssetRenderInput {
|
|
205
|
+
version_id: string;
|
|
206
|
+
source_checksum: string;
|
|
207
|
+
recipe: AssetRenderRecipe;
|
|
208
|
+
outputs: AssetRenderOutput[];
|
|
209
|
+
variant_id?: string;
|
|
210
|
+
variant_revision?: number;
|
|
211
|
+
}
|
|
212
|
+
export interface AssetRenderEstimate {
|
|
213
|
+
units: number;
|
|
214
|
+
remaining: number;
|
|
215
|
+
reused: boolean;
|
|
216
|
+
set_id?: string;
|
|
217
|
+
}
|
|
218
|
+
export interface AssetRenderSubmission {
|
|
219
|
+
set_id: string;
|
|
220
|
+
status: string;
|
|
221
|
+
job_id?: string;
|
|
222
|
+
units?: number;
|
|
223
|
+
reused?: boolean;
|
|
224
|
+
}
|
|
225
|
+
export interface AssetRenderSet {
|
|
226
|
+
id: string;
|
|
227
|
+
asset_id: string;
|
|
228
|
+
version_id: string;
|
|
229
|
+
source_checksum: string;
|
|
230
|
+
recipe: AssetRenderRecipe;
|
|
231
|
+
requested: AssetRenderOutput[];
|
|
232
|
+
variant_id?: string;
|
|
233
|
+
variant_revision?: number;
|
|
234
|
+
status: 'queued' | 'processing' | 'ready' | 'failed';
|
|
235
|
+
can_retry: boolean;
|
|
236
|
+
units: number;
|
|
237
|
+
outputs: Array<{
|
|
238
|
+
role: AssetRenderOutput;
|
|
239
|
+
frame: number;
|
|
240
|
+
reference: AssetMediaReference;
|
|
241
|
+
}>;
|
|
242
|
+
created_at: string;
|
|
243
|
+
updated_at: string;
|
|
244
|
+
failure_reason?: string;
|
|
245
|
+
}
|
|
246
|
+
export interface AssetRenderingInfo {
|
|
247
|
+
enabled: boolean;
|
|
248
|
+
reason: string;
|
|
249
|
+
remaining: number;
|
|
250
|
+
qualified_outputs: AssetRenderOutput[];
|
|
251
|
+
source?: {
|
|
252
|
+
assetId: string;
|
|
253
|
+
versionId: string;
|
|
254
|
+
checksum: string;
|
|
255
|
+
};
|
|
256
|
+
delivery?: AssetPublicationDelivery;
|
|
257
|
+
sets: AssetRenderSet[];
|
|
258
|
+
deliveries: Record<string, AssetPublicationDelivery>;
|
|
259
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { StackShift } from './client.js';
|
|
2
|
+
import type { AssetJobSubmission } from './types.js';
|
|
3
|
+
import type { AssetRenderInput, AssetRenderEstimate, AssetRenderSubmission, AssetRenderingInfo } from './assets-dam-types.js';
|
|
4
|
+
import type { AssetAction, AssetSpaceAccess, AssetCollaborator, AssetMetadataSchema, AssetMetadataField, AssetBucketGovernance, AssetPublication, AssetPublicationInput, AssetPublicationStatus, AssetPublicationDelivery, AssetMediaReference, AssetPickerCapability, AssetPickerCapabilityInput, AssetModelPackage, AssetModelVariant, AssetModelVariantInput, AssetGallery, AssetGalleryEntryInput, AssetGalleryDelivery } from './assets-dam-types.js';
|
|
5
|
+
export declare class AssetDAMClient {
|
|
6
|
+
private readonly client;
|
|
7
|
+
constructor(client: StackShift);
|
|
8
|
+
spaces(): Promise<{
|
|
9
|
+
spaces: AssetSpaceAccess[];
|
|
10
|
+
}>;
|
|
11
|
+
collaborators(): Promise<{
|
|
12
|
+
collaborators: AssetCollaborator[];
|
|
13
|
+
}>;
|
|
14
|
+
invite(input: {
|
|
15
|
+
email: string;
|
|
16
|
+
actions: AssetAction[];
|
|
17
|
+
collection_id?: string;
|
|
18
|
+
expires_at: string;
|
|
19
|
+
}): Promise<AssetCollaborator>;
|
|
20
|
+
acceptInvitation(id: string): Promise<AssetCollaborator>;
|
|
21
|
+
updateCollaborator(id: string, revision: number, actions: AssetAction[]): Promise<{
|
|
22
|
+
saved: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
revokeCollaborator(id: string, revision: number): Promise<{
|
|
25
|
+
saved: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
metadataSchemas(): Promise<{
|
|
28
|
+
schemas: AssetMetadataSchema[];
|
|
29
|
+
}>;
|
|
30
|
+
metadataEditor(assetId: string): Promise<{
|
|
31
|
+
fields: AssetMetadataField[];
|
|
32
|
+
metadata: Record<string, unknown>;
|
|
33
|
+
revision: number;
|
|
34
|
+
metadata_revision: number;
|
|
35
|
+
can_edit: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
createMetadataSchema(input: {
|
|
38
|
+
name: string;
|
|
39
|
+
fields: AssetMetadataField[];
|
|
40
|
+
}): Promise<AssetMetadataSchema>;
|
|
41
|
+
updateMetadataSchema(id: string, revision: number, input: {
|
|
42
|
+
name: string;
|
|
43
|
+
fields: AssetMetadataField[];
|
|
44
|
+
}): Promise<AssetMetadataSchema>;
|
|
45
|
+
publishMetadataSchema(id: string, revision: number): Promise<AssetMetadataSchema>;
|
|
46
|
+
bucketGovernance(id: string): Promise<AssetBucketGovernance>;
|
|
47
|
+
saveBucketGovernance(id: string, input: Omit<AssetBucketGovernance, 'bucket_id' | 'migrating'>): Promise<AssetBucketGovernance>;
|
|
48
|
+
migrateBucketGovernance(id: string, revision: number): Promise<AssetBucketGovernance>;
|
|
49
|
+
publications(options?: {
|
|
50
|
+
asset_id?: string;
|
|
51
|
+
status?: AssetPublicationStatus;
|
|
52
|
+
cursor?: string;
|
|
53
|
+
}): Promise<{
|
|
54
|
+
publications: AssetPublication[];
|
|
55
|
+
next_cursor: string;
|
|
56
|
+
}>;
|
|
57
|
+
publicationRenditions(assetId: string): Promise<{
|
|
58
|
+
renditions: AssetMediaReference[];
|
|
59
|
+
}>;
|
|
60
|
+
createPublication(input: AssetPublicationInput): Promise<AssetPublication>;
|
|
61
|
+
updatePublication(id: string, revision: number, input: AssetPublicationInput): Promise<AssetPublication>;
|
|
62
|
+
transitionPublication(id: string, revision: number, action: 'submit' | 'approve' | 'request-changes' | 'publish' | 'withdraw', note?: string): Promise<AssetPublication>;
|
|
63
|
+
resolvePublication(id: string, preview?: boolean): Promise<AssetPublicationDelivery>;
|
|
64
|
+
resolvePublicationAR(id: string): Promise<AssetPublicationDelivery>;
|
|
65
|
+
createPublicationARHandoff(id: string): Promise<{
|
|
66
|
+
handoff_url: string;
|
|
67
|
+
expires_at: string;
|
|
68
|
+
}>;
|
|
69
|
+
createPickerCapability(input: AssetPickerCapabilityInput): Promise<{
|
|
70
|
+
token: string;
|
|
71
|
+
capability: AssetPickerCapability;
|
|
72
|
+
}>;
|
|
73
|
+
revokePickerCapability(id: string): Promise<{
|
|
74
|
+
revoked: boolean;
|
|
75
|
+
}>;
|
|
76
|
+
models(assetId: string): Promise<{
|
|
77
|
+
packages: AssetModelPackage[];
|
|
78
|
+
pilot_enabled: boolean;
|
|
79
|
+
daily_jobs: number;
|
|
80
|
+
rendering: AssetRenderingInfo;
|
|
81
|
+
}>;
|
|
82
|
+
estimateRender(assetId: string, revision: number, input: AssetRenderInput): Promise<AssetRenderEstimate>;
|
|
83
|
+
renderProduct(assetId: string, revision: number, idempotencyKey: string, input: AssetRenderInput, maximumUnits: number): Promise<AssetRenderSubmission>;
|
|
84
|
+
processModel(assetId: string, revision: number, idempotencyKey: string): Promise<AssetJobSubmission>;
|
|
85
|
+
modelVariants(assetId: string): Promise<AssetModelVariant[]>;
|
|
86
|
+
createModelVariant(assetId: string, revision: number, input: AssetModelVariantInput): Promise<AssetModelVariant>;
|
|
87
|
+
updateModelVariant(assetId: string, variantId: string, revision: number, input: AssetModelVariantInput): Promise<AssetModelVariant>;
|
|
88
|
+
deleteModelVariant(assetId: string, variantId: string, assetRevision: number, variantRevision: number): Promise<{
|
|
89
|
+
deleted: boolean;
|
|
90
|
+
}>;
|
|
91
|
+
galleries(cursor?: string): Promise<{
|
|
92
|
+
galleries: AssetGallery[];
|
|
93
|
+
next_cursor: string;
|
|
94
|
+
}>;
|
|
95
|
+
createGallery(input: {
|
|
96
|
+
name: string;
|
|
97
|
+
entries: AssetGalleryEntryInput[];
|
|
98
|
+
}): Promise<AssetGallery>;
|
|
99
|
+
updateGallery(id: string, revision: number, input: {
|
|
100
|
+
name: string;
|
|
101
|
+
entries: AssetGalleryEntryInput[];
|
|
102
|
+
}): Promise<AssetGallery>;
|
|
103
|
+
transitionGallery(id: string, revision: number, action: 'publish' | 'withdraw'): Promise<AssetGallery>;
|
|
104
|
+
resolveGallery(id: string, preview?: boolean): Promise<AssetGalleryDelivery>;
|
|
105
|
+
resolveGalleryAR(id: string, publicationId: string): Promise<AssetPublicationDelivery>;
|
|
106
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const path = (group, id) => `/assets/${group}/${encodeURIComponent(id)}`;
|
|
2
|
+
const revisionHeaders = (revision) => ({ 'If-Match': `"${revision}"` });
|
|
3
|
+
export class AssetDAMClient {
|
|
4
|
+
client;
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
spaces() { return this.client.request('/assets/spaces'); }
|
|
9
|
+
collaborators() { return this.client.request('/assets/collaborators'); }
|
|
10
|
+
invite(input) { return this.client.request('/assets/collaborators', { method: 'POST', body: input }); }
|
|
11
|
+
acceptInvitation(id) { return this.client.request(`${path('invitations', id)}/accept`, { method: 'POST' }); }
|
|
12
|
+
updateCollaborator(id, revision, actions) { return this.client.request(path('collaborators', id), { method: 'PUT', headers: revisionHeaders(revision), body: { actions } }); }
|
|
13
|
+
revokeCollaborator(id, revision) { return this.client.request(path('collaborators', id), { method: 'DELETE', headers: revisionHeaders(revision) }); }
|
|
14
|
+
metadataSchemas() { return this.client.request('/assets/metadata-schemas'); }
|
|
15
|
+
metadataEditor(assetId) { return this.client.request(`/assets/${encodeURIComponent(assetId)}/metadata-editor`); }
|
|
16
|
+
createMetadataSchema(input) { return this.client.request('/assets/metadata-schemas', { method: 'POST', body: input }); }
|
|
17
|
+
updateMetadataSchema(id, revision, input) { return this.client.request(path('metadata-schemas', id), { method: 'PUT', headers: revisionHeaders(revision), body: input }); }
|
|
18
|
+
publishMetadataSchema(id, revision) { return this.client.request(`${path('metadata-schemas', id)}/publish`, { method: 'POST', headers: revisionHeaders(revision) }); }
|
|
19
|
+
bucketGovernance(id) { return this.client.request(`${path('buckets', id)}/governance`); }
|
|
20
|
+
saveBucketGovernance(id, input) { return this.client.request(`${path('buckets', id)}/governance`, { method: 'PUT', body: input }); }
|
|
21
|
+
migrateBucketGovernance(id, revision) { return this.client.request(`${path('buckets', id)}/governance/migrate`, { method: 'POST', headers: revisionHeaders(revision) }); }
|
|
22
|
+
publications(options = {}) {
|
|
23
|
+
const query = new URLSearchParams();
|
|
24
|
+
for (const [key, value] of Object.entries(options))
|
|
25
|
+
if (value)
|
|
26
|
+
query.set(key, value);
|
|
27
|
+
return this.client.request(`/assets/publications?${query}`);
|
|
28
|
+
}
|
|
29
|
+
publicationRenditions(assetId) { return this.client.request(`/assets/${encodeURIComponent(assetId)}/publication-renditions`); }
|
|
30
|
+
createPublication(input) { return this.client.request('/assets/publications', { method: 'POST', body: input }); }
|
|
31
|
+
updatePublication(id, revision, input) { return this.client.request(path('publications', id), { method: 'PUT', headers: revisionHeaders(revision), body: input }); }
|
|
32
|
+
transitionPublication(id, revision, action, note = '') { return this.client.request(`${path('publications', id)}/${action}`, { method: 'POST', headers: revisionHeaders(revision), body: { note } }); }
|
|
33
|
+
resolvePublication(id, preview = false) { return this.client.request(`${path('publications', id)}/${preview ? 'preview' : 'resolve'}`); }
|
|
34
|
+
resolvePublicationAR(id) { return this.client.request(`${path('publications', id)}/ar`, { method: 'POST' }); }
|
|
35
|
+
createPublicationARHandoff(id) { return this.client.request(`${path('publications', id)}/ar-handoff`, { method: 'POST' }); }
|
|
36
|
+
createPickerCapability(input) { return this.client.request('/assets/picker-capabilities', { method: 'POST', body: input }); }
|
|
37
|
+
revokePickerCapability(id) { return this.client.request(path('picker-capabilities', id), { method: 'DELETE' }); }
|
|
38
|
+
models(assetId) { return this.client.request(`/assets/${encodeURIComponent(assetId)}/models`); }
|
|
39
|
+
estimateRender(assetId, revision, input) { return this.client.request(`/assets/${encodeURIComponent(assetId)}/models`, { method: 'POST', headers: revisionHeaders(revision), body: { ...input, operation: 'estimate' } }); }
|
|
40
|
+
renderProduct(assetId, revision, idempotencyKey, input, maximumUnits) { return this.client.request(`/assets/${encodeURIComponent(assetId)}/models`, { method: 'POST', headers: { ...revisionHeaders(revision), 'Idempotency-Key': idempotencyKey }, body: { ...input, operation: 'render', maximum_units: maximumUnits } }); }
|
|
41
|
+
processModel(assetId, revision, idempotencyKey) { return this.client.request(`/assets/${encodeURIComponent(assetId)}/models`, { method: 'POST', headers: { ...revisionHeaders(revision), 'Idempotency-Key': idempotencyKey } }); }
|
|
42
|
+
modelVariants(assetId) { return this.client.request(`/assets/${encodeURIComponent(assetId)}/model-variants`); }
|
|
43
|
+
createModelVariant(assetId, revision, input) { return this.client.request(`/assets/${encodeURIComponent(assetId)}/model-variants`, { method: 'POST', headers: revisionHeaders(revision), body: input }); }
|
|
44
|
+
updateModelVariant(assetId, variantId, revision, input) { return this.client.request(`/assets/${encodeURIComponent(assetId)}/model-variants/${encodeURIComponent(variantId)}`, { method: 'PUT', headers: revisionHeaders(revision), body: input }); }
|
|
45
|
+
deleteModelVariant(assetId, variantId, assetRevision, variantRevision) { return this.client.request(`/assets/${encodeURIComponent(assetId)}/model-variants/${encodeURIComponent(variantId)}?revision=${variantRevision}`, { method: 'DELETE', headers: revisionHeaders(assetRevision) }); }
|
|
46
|
+
galleries(cursor) { return this.client.request(`/assets/galleries${cursor ? '?cursor=' + encodeURIComponent(cursor) : ''}`); }
|
|
47
|
+
createGallery(input) { return this.client.request('/assets/galleries', { method: 'POST', body: input }); }
|
|
48
|
+
updateGallery(id, revision, input) { return this.client.request(path('galleries', id), { method: 'PUT', headers: revisionHeaders(revision), body: input }); }
|
|
49
|
+
transitionGallery(id, revision, action) { return this.client.request(`${path('galleries', id)}/${action}`, { method: 'POST', headers: revisionHeaders(revision) }); }
|
|
50
|
+
resolveGallery(id, preview = false) { return this.client.request(`${path('galleries', id)}/resolve${preview ? '?preview=true' : ''}`); }
|
|
51
|
+
resolveGalleryAR(id, publicationId) { return this.client.request(`${path('galleries', id)}/ar`, { method: 'POST', body: { publication_id: publicationId } }); }
|
|
52
|
+
}
|