@shotstack/schemas 1.21.1 → 1.23.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.
@@ -7,6 +7,7 @@ export const assetsidRootSchema = z.unknown();
7
7
  export const assetsrenderidRootSchema = z.unknown();
8
8
  export const generateRootSchema = z.unknown();
9
9
  export const generateidRootSchema = z.unknown();
10
+ export const generatequoteRootSchema = z.unknown();
10
11
  export const modelsRootSchema = z.unknown();
11
12
  export const modelsidRootSchema = z.unknown();
12
13
  export const probeRootSchema = z.unknown();
@@ -432,7 +433,7 @@ export const fontFontSchema = z.object({
432
433
  }).strict();
433
434
  export const fontSchema = fontFontSchema;
434
435
  /**
435
- * An image, video or audio asset to generate from a text prompt.
436
+ * An asset to generate, from a text `prompt` or, for models that take one, a source `src`.
436
437
  */
437
438
  export const generationassetGenerationAssetSchema = z.object({
438
439
  type: z.enum([
@@ -440,72 +441,24 @@ export const generationassetGenerationAssetSchema = z.object({
440
441
  'video',
441
442
  'audio'
442
443
  ]),
443
- prompt: z.string().min(1).max(4000).regex(/\S/),
444
+ prompt: z.optional(z.string().min(1).max(4000).regex(/\S/)),
445
+ src: z.optional(z.url()),
444
446
  model: z.optional(z.string()),
445
447
  options: z.optional(z.record(z.string(), z.unknown()))
446
- }).strict();
448
+ }).strict().superRefine((data, ctx) => {
449
+ var hasSrc = typeof data.src === "string" && data.src.trim().length > 0;
450
+ var hasPrompt = typeof data.prompt === "string" && data.prompt.trim().length > 0;
451
+ if (!hasSrc && !hasPrompt) {
452
+ ctx.addIssue({
453
+ code: z.ZodIssueCode.custom,
454
+ message: "A media asset requires either \"src\" (a source URL) or \"prompt\" (to generate the asset). Provide one.",
455
+ path: ["src"],
456
+ });
457
+ }
458
+ });
447
459
  export const generationAssetSchema = generationassetGenerationAssetSchema;
448
460
  /**
449
- * What one generation costs, in credits: the rate multiplied by the units consumed. `quantity` says how to count the units, and is absent when one generation is one unit. Where a model charges differently per option value, `credits` is an object keyed by that value and `tieredBy` names the option that selects it.
450
- */
451
- export const generationmodelpricingGenerationModelPricingSchema = z.object({
452
- credits: z.union([
453
- z.union([z.preprocess(((v) => { if (v === '' || v === null || v === undefined)
454
- return undefined; if (Array.isArray(v))
455
- return v; if (typeof v === 'string') {
456
- if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v))
457
- return v;
458
- return Number(v);
459
- } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]),
460
- z.record(z.string(), z.union([z.preprocess(((v) => { if (v === '' || v === null || v === undefined)
461
- return undefined; if (Array.isArray(v))
462
- return v; if (typeof v === 'string') {
463
- if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v))
464
- return v;
465
- return Number(v);
466
- } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]))
467
- ]),
468
- tieredBy: z.optional(z.object({
469
- option: z.string(),
470
- default: z.string()
471
- })),
472
- quantity: z.optional(z.object({
473
- measure: z.enum(['clipSeconds', 'promptCharacters']),
474
- per: z.union([z.preprocess(((v) => { if (v === '' || v === null || v === undefined)
475
- return undefined; if (Array.isArray(v))
476
- return v; if (typeof v === 'string') {
477
- if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v))
478
- return v;
479
- return Number(v);
480
- } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]),
481
- min: z.optional(z.union([z.preprocess(((v) => { if (v === '' || v === null || v === undefined)
482
- return undefined; if (Array.isArray(v))
483
- return v; if (typeof v === 'string') {
484
- if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v))
485
- return v;
486
- return Number(v);
487
- } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)])),
488
- max: z.optional(z.union([z.preprocess(((v) => { if (v === '' || v === null || v === undefined)
489
- return undefined; if (Array.isArray(v))
490
- return v; if (typeof v === 'string') {
491
- if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v))
492
- return v;
493
- return Number(v);
494
- } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)])),
495
- default: z.optional(z.union([z.preprocess(((v) => { if (v === '' || v === null || v === undefined)
496
- return undefined; if (Array.isArray(v))
497
- return v; if (typeof v === 'string') {
498
- if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v))
499
- return v;
500
- return Number(v);
501
- } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)])),
502
- round: z.optional(z.enum(['up']))
503
- })),
504
- effectiveFrom: z.string()
505
- }).strict();
506
- export const generationModelPricingSchema = generationmodelpricingGenerationModelPricingSchema;
507
- /**
508
- * A generation model available to `prompt`-bearing image, video and audio assets, with the options it accepts and what it costs. Render a model picker and its option fields from this rather than hard coding a model list, so a newly launched model is available without a client release.
461
+ * A generation model available to image, video and audio assets generated from a prompt or, for some models, a source file, with the options it accepts. Use `POST /generate/quote` for a credit estimate. Render a model picker and its option fields from this rather than hard coding a model list, so a newly launched model is available without a client release.
509
462
  */
510
463
  export const generationmodelGenerationModelSchema = z.object({
511
464
  model: z.string(),
@@ -516,7 +469,6 @@ export const generationmodelGenerationModelSchema = z.object({
516
469
  ]),
517
470
  name: z.optional(z.string()),
518
471
  description: z.optional(z.string()),
519
- pricing: z.optional(generationmodelpricingGenerationModelPricingSchema),
520
472
  options: z.optional(z.record(z.string(), z.unknown())),
521
473
  available: z.optional(z.boolean()),
522
474
  unavailableReason: z.optional(z.enum([
@@ -526,6 +478,17 @@ export const generationmodelGenerationModelSchema = z.object({
526
478
  ]))
527
479
  }).strict();
528
480
  export const generationModelSchema = generationmodelGenerationModelSchema;
481
+ export const generationrequestGenerationRequestSchema = z.object({
482
+ asset: generationassetGenerationAssetSchema,
483
+ length: z.optional(z.union([z.preprocess(((v) => { if (v === '' || v === null || v === undefined)
484
+ return undefined; if (Array.isArray(v))
485
+ return v; if (typeof v === 'string') {
486
+ if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v))
487
+ return v;
488
+ return Number(v);
489
+ } return v; }), z.number().gt(0)), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]))
490
+ }).strict();
491
+ export const generationRequestSchema = generationrequestGenerationRequestSchema;
529
492
  /**
530
493
  * The Html5Asset renders full HTML5/CSS3/JS.
531
494
  *
@@ -897,6 +860,20 @@ export const generationmodellistresponseGenerationModelListResponseSchema = z.ob
897
860
  models: z.array(generationmodelGenerationModelSchema)
898
861
  }).strict();
899
862
  export const generationModelListResponseSchema = generationmodellistresponseGenerationModelListResponseSchema;
863
+ /**
864
+ * Current credit estimate for a generation, calculated with the same rules as submission. Does not reserve credits or lock a price. A cached result costs nothing; final duration-based charges can be lower. Submit the same asset and length to generate it.
865
+ */
866
+ export const generationquoteGenerationQuoteSchema = z.object({
867
+ credits: z.union([z.preprocess(((v) => { if (v === '' || v === null || v === undefined)
868
+ return undefined; if (Array.isArray(v))
869
+ return v; if (typeof v === 'string') {
870
+ if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v))
871
+ return v;
872
+ return Number(v);
873
+ } return v; }), z.number().gte(0)), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]),
874
+ ceiling: z.boolean()
875
+ }).strict();
876
+ export const generationQuoteSchema = generationquoteGenerationQuoteSchema;
900
877
  /**
901
878
  * The status of an on-demand asset generation job. Completed jobs include the public URL of the generated asset.
902
879
  */
@@ -3012,16 +2989,7 @@ export const probeRequest = z.object({
3012
2989
  */
3013
2990
  export const probeResponse = proberesponseProbeResponseSchema;
3014
2991
  export const postGenerateRequest = z.object({
3015
- body: z.object({
3016
- asset: generationassetGenerationAssetSchema,
3017
- length: z.optional(z.union([z.preprocess(((v) => { if (v === '' || v === null || v === undefined)
3018
- return undefined; if (Array.isArray(v))
3019
- return v; if (typeof v === 'string') {
3020
- if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v))
3021
- return v;
3022
- return Number(v);
3023
- } return v; }), z.number().gt(0)), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]))
3024
- }),
2992
+ body: generationrequestGenerationRequestSchema,
3025
2993
  path: z.optional(z.never()),
3026
2994
  query: z.optional(z.never()),
3027
2995
  headers: z.optional(z.object({
@@ -3032,6 +3000,15 @@ export const postGenerateRequest = z.object({
3032
3000
  * The asset was generated before: `done` with its URL, or `failed` with the error that ended it.
3033
3001
  */
3034
3002
  export const postGenerateResponse = generationresponseGenerationResponseSchema;
3003
+ export const postGenerateQuoteRequest = z.object({
3004
+ body: generationrequestGenerationRequestSchema,
3005
+ path: z.optional(z.never()),
3006
+ query: z.optional(z.never())
3007
+ }).strict();
3008
+ /**
3009
+ * The generation credit estimate.
3010
+ */
3011
+ export const postGenerateQuoteResponse = generationquoteGenerationQuoteSchema;
3035
3012
  export const getGenerateRequest = z.object({
3036
3013
  body: z.optional(z.never()),
3037
3014
  path: z.object({
@@ -16,6 +16,8 @@ export const generateRootSchema = z.unknown();
16
16
 
17
17
  export const generateidRootSchema = z.unknown();
18
18
 
19
+ export const generatequoteRootSchema = z.unknown();
20
+
19
21
  export const modelsRootSchema = z.unknown();
20
22
 
21
23
  export const modelsidRootSchema = z.unknown();
@@ -392,7 +394,7 @@ export const fontFontSchema = z.object({
392
394
  export const fontSchema = fontFontSchema;
393
395
 
394
396
  /**
395
- * An image, video or audio asset to generate from a text prompt.
397
+ * An asset to generate, from a text `prompt` or, for models that take one, a source `src`.
396
398
  */
397
399
  export const generationassetGenerationAssetSchema = z.object({
398
400
  type: z.enum([
@@ -400,40 +402,26 @@ export const generationassetGenerationAssetSchema = z.object({
400
402
  'video',
401
403
  'audio'
402
404
  ]),
403
- prompt: z.string().min(1).max(4000).regex(/\S/),
405
+ prompt: z.optional(z.string().min(1).max(4000).regex(/\S/)),
406
+ src: z.optional(z.url()),
404
407
  model: z.optional(z.string()),
405
408
  options: z.optional(z.record(z.string(), z.unknown()))
406
- }).strict();
409
+ }).strict().superRefine((data, ctx) => {
410
+ var hasSrc = typeof data.src === "string" && data.src.trim().length > 0;
411
+ var hasPrompt = typeof data.prompt === "string" && data.prompt.trim().length > 0;
412
+ if (!hasSrc && !hasPrompt) {
413
+ ctx.addIssue({
414
+ code: z.ZodIssueCode.custom,
415
+ message: "A media asset requires either \"src\" (a source URL) or \"prompt\" (to generate the asset). Provide one.",
416
+ path: ["src"],
417
+ });
418
+ }
419
+ });
407
420
 
408
421
  export const generationAssetSchema = generationassetGenerationAssetSchema;
409
422
 
410
423
  /**
411
- * What one generation costs, in credits: the rate multiplied by the units consumed. `quantity` says how to count the units, and is absent when one generation is one unit. Where a model charges differently per option value, `credits` is an object keyed by that value and `tieredBy` names the option that selects it.
412
- */
413
- export const generationmodelpricingGenerationModelPricingSchema = z.object({
414
- credits: z.union([
415
- z.union([z.preprocess(((v: unknown) => { if (v === '' || v === null || v === undefined) return undefined; if (Array.isArray(v)) return v; if (typeof v === 'string') { if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v)) return v; return Number(v); } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]),
416
- z.record(z.string(), z.union([z.preprocess(((v: unknown) => { if (v === '' || v === null || v === undefined) return undefined; if (Array.isArray(v)) return v; if (typeof v === 'string') { if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v)) return v; return Number(v); } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]))
417
- ]),
418
- tieredBy: z.optional(z.object({
419
- option: z.string(),
420
- default: z.string()
421
- })),
422
- quantity: z.optional(z.object({
423
- measure: z.enum(['clipSeconds', 'promptCharacters']),
424
- per: z.union([z.preprocess(((v: unknown) => { if (v === '' || v === null || v === undefined) return undefined; if (Array.isArray(v)) return v; if (typeof v === 'string') { if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v)) return v; return Number(v); } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]),
425
- min: z.optional(z.union([z.preprocess(((v: unknown) => { if (v === '' || v === null || v === undefined) return undefined; if (Array.isArray(v)) return v; if (typeof v === 'string') { if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v)) return v; return Number(v); } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)])),
426
- max: z.optional(z.union([z.preprocess(((v: unknown) => { if (v === '' || v === null || v === undefined) return undefined; if (Array.isArray(v)) return v; if (typeof v === 'string') { if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v)) return v; return Number(v); } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)])),
427
- default: z.optional(z.union([z.preprocess(((v: unknown) => { if (v === '' || v === null || v === undefined) return undefined; if (Array.isArray(v)) return v; if (typeof v === 'string') { if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v)) return v; return Number(v); } return v; }), z.number()), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)])),
428
- round: z.optional(z.enum(['up']))
429
- })),
430
- effectiveFrom: z.string()
431
- }).strict();
432
-
433
- export const generationModelPricingSchema = generationmodelpricingGenerationModelPricingSchema;
434
-
435
- /**
436
- * A generation model available to `prompt`-bearing image, video and audio assets, with the options it accepts and what it costs. Render a model picker and its option fields from this rather than hard coding a model list, so a newly launched model is available without a client release.
424
+ * A generation model available to image, video and audio assets generated from a prompt or, for some models, a source file, with the options it accepts. Use `POST /generate/quote` for a credit estimate. Render a model picker and its option fields from this rather than hard coding a model list, so a newly launched model is available without a client release.
437
425
  */
438
426
  export const generationmodelGenerationModelSchema = z.object({
439
427
  model: z.string(),
@@ -444,7 +432,6 @@ export const generationmodelGenerationModelSchema = z.object({
444
432
  ]),
445
433
  name: z.optional(z.string()),
446
434
  description: z.optional(z.string()),
447
- pricing: z.optional(generationmodelpricingGenerationModelPricingSchema),
448
435
  options: z.optional(z.record(z.string(), z.unknown())),
449
436
  available: z.optional(z.boolean()),
450
437
  unavailableReason: z.optional(z.enum([
@@ -456,6 +443,13 @@ export const generationmodelGenerationModelSchema = z.object({
456
443
 
457
444
  export const generationModelSchema = generationmodelGenerationModelSchema;
458
445
 
446
+ export const generationrequestGenerationRequestSchema = z.object({
447
+ asset: generationassetGenerationAssetSchema,
448
+ length: z.optional(z.union([z.preprocess(((v: unknown) => { if (v === '' || v === null || v === undefined) return undefined; if (Array.isArray(v)) return v; if (typeof v === 'string') { if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v)) return v; return Number(v); } return v; }), z.number().gt(0)), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]))
449
+ }).strict();
450
+
451
+ export const generationRequestSchema = generationrequestGenerationRequestSchema;
452
+
459
453
  /**
460
454
  * The Html5Asset renders full HTML5/CSS3/JS.
461
455
  *
@@ -829,6 +823,16 @@ export const generationmodellistresponseGenerationModelListResponseSchema = z.ob
829
823
 
830
824
  export const generationModelListResponseSchema = generationmodellistresponseGenerationModelListResponseSchema;
831
825
 
826
+ /**
827
+ * Current credit estimate for a generation, calculated with the same rules as submission. Does not reserve credits or lock a price. A cached result costs nothing; final duration-based charges can be lower. Submit the same asset and length to generate it.
828
+ */
829
+ export const generationquoteGenerationQuoteSchema = z.object({
830
+ credits: z.union([z.preprocess(((v: unknown) => { if (v === '' || v === null || v === undefined) return undefined; if (Array.isArray(v)) return v; if (typeof v === 'string') { if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v)) return v; return Number(v); } return v; }), z.number().gte(0)), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]),
831
+ ceiling: z.boolean()
832
+ }).strict();
833
+
834
+ export const generationQuoteSchema = generationquoteGenerationQuoteSchema;
835
+
832
836
  /**
833
837
  * The status of an on-demand asset generation job. Completed jobs include the public URL of the generated asset.
834
838
  */
@@ -2529,10 +2533,7 @@ export const probeRequest = z.object({
2529
2533
  export const probeResponse = proberesponseProbeResponseSchema;
2530
2534
 
2531
2535
  export const postGenerateRequest = z.object({
2532
- body: z.object({
2533
- asset: generationassetGenerationAssetSchema,
2534
- length: z.optional(z.union([z.preprocess(((v: unknown) => { if (v === '' || v === null || v === undefined) return undefined; if (Array.isArray(v)) return v; if (typeof v === 'string') { if (/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(v)) return v; return Number(v); } return v; }), z.number().gt(0)), z.string().regex(/^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/)]))
2535
- }),
2536
+ body: generationrequestGenerationRequestSchema,
2536
2537
  path: z.optional(z.never()),
2537
2538
  query: z.optional(z.never()),
2538
2539
  headers: z.optional(z.object({
@@ -2545,6 +2546,17 @@ export const postGenerateRequest = z.object({
2545
2546
  */
2546
2547
  export const postGenerateResponse = generationresponseGenerationResponseSchema;
2547
2548
 
2549
+ export const postGenerateQuoteRequest = z.object({
2550
+ body: generationrequestGenerationRequestSchema,
2551
+ path: z.optional(z.never()),
2552
+ query: z.optional(z.never())
2553
+ }).strict();
2554
+
2555
+ /**
2556
+ * The generation credit estimate.
2557
+ */
2558
+ export const postGenerateQuoteResponse = generationquoteGenerationQuoteSchema;
2559
+
2548
2560
  export const getGenerateRequest = z.object({
2549
2561
  body: z.optional(z.never()),
2550
2562
  path: z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shotstack/schemas",
3
- "version": "1.21.1",
3
+ "version": "1.23.0",
4
4
  "description": "Centralized OpenAPI schemas and TypeScript types for Shotstack API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",