@relyio/sdk 0.5.0 → 0.6.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/CHANGELOG.md +170 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-5AZUUV5B.js → chunk-7ABNXVWL.js} +398 -184
- package/dist/{chunk-HAQELDZN.cjs → chunk-DY2XT7OF.cjs} +2 -2
- package/dist/{chunk-CIRT6TVT.cjs → chunk-GCMQUM6N.cjs} +400 -183
- package/dist/{chunk-XY5KFEFY.js → chunk-XJVY2CLY.js} +2 -2
- package/dist/client/index.cjs +3 -3
- package/dist/client/index.d.cts +4 -4
- package/dist/client/index.d.ts +4 -4
- package/dist/client/index.js +1 -1
- package/dist/define-content-type-CDB3kyeA.d.cts +1173 -0
- package/dist/define-content-type-CDB3kyeA.d.ts +1173 -0
- package/dist/{define-schema-DzYXk4HL.d.ts → define-schema-1kr2HIzN.d.cts} +25 -347
- package/dist/{define-schema-2xbHgtK-.d.cts → define-schema-ChvAzY8H.d.ts} +25 -347
- package/dist/{index-BozPz4n1.d.cts → index-Df1VsfJR.d.cts} +233 -74
- package/dist/{index-Dzo-upNS.d.ts → index-XqoGUaAY.d.ts} +233 -74
- package/dist/{index-C5mRBb6t.d.cts → index-d1Kz1e19.d.cts} +62 -29
- package/dist/{index-mXUx2H99.d.ts → index-yPbhZc6q.d.ts} +62 -29
- package/dist/index.cjs +161 -68
- package/dist/index.d.cts +283 -8
- package/dist/index.d.ts +283 -8
- package/dist/index.js +90 -3
- package/dist/schema/index.cjs +35 -35
- package/dist/schema/index.d.cts +11 -7
- package/dist/schema/index.d.ts +11 -7
- package/dist/schema/index.js +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/define-content-type-CBfnTWSS.d.cts +0 -716
- package/dist/define-content-type-CBfnTWSS.d.ts +0 -716
|
@@ -1,98 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Singleton content type definition matching @relyio/schema
|
|
5
|
-
*
|
|
6
|
-
* In RelyIO, singletons are just content types with a special flag.
|
|
7
|
-
* They share the same structure as regular content types.
|
|
8
|
-
*
|
|
9
|
-
* Uses advanced TypeScript generics to preserve literal field IDs through
|
|
10
|
-
* the type system, enabling full autocomplete in SDK methods.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Type alias for a fieldset with any fields.
|
|
15
|
-
*/
|
|
16
|
-
type AnyFieldset$1 = Fieldset<any>;
|
|
17
|
-
/**
|
|
18
|
-
* Singleton content type definition - preserves field types for inference
|
|
19
|
-
*/
|
|
20
|
-
interface SingletonContentTypeDefinition<TFields extends readonly AnyFieldDefinition[] = readonly AnyFieldDefinition[], TFieldsets extends readonly AnyFieldset$1[] = readonly AnyFieldset$1[]> {
|
|
21
|
-
readonly _tag: 'singletonContentType';
|
|
22
|
-
readonly name: string;
|
|
23
|
-
readonly displayName: string;
|
|
24
|
-
readonly displayNamePlural?: string;
|
|
25
|
-
readonly description?: string;
|
|
26
|
-
/** AI configuration: generation guidance + entry intelligence */
|
|
27
|
-
readonly ai?: AIConfig;
|
|
28
|
-
/** Field ID to use as entry display title */
|
|
29
|
-
readonly displayField?: string;
|
|
30
|
-
readonly hierarchical: false;
|
|
31
|
-
readonly accessTags?: string[];
|
|
32
|
-
readonly fields?: TFields;
|
|
33
|
-
readonly fieldsets?: TFieldsets;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Define a singleton content type
|
|
37
|
-
*
|
|
38
|
-
* Singletons are single-instance content types like homepage, site settings, etc.
|
|
39
|
-
* They use the same field structure as regular content types.
|
|
40
|
-
*
|
|
41
|
-
* The generic type parameters preserve the literal field IDs through the type
|
|
42
|
-
* system, enabling autocomplete in SDK methods.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* const homepage = defineSingletonContentType('homepage', {
|
|
46
|
-
* displayName: 'Homepage',
|
|
47
|
-
* fields: [
|
|
48
|
-
* fields.shortText('heroTitle', { config: { required: true } }),
|
|
49
|
-
* fields.image('heroImage'),
|
|
50
|
-
* ]
|
|
51
|
-
* })
|
|
52
|
-
*/
|
|
53
|
-
declare function defineSingletonContentType<TFields extends readonly AnyFieldDefinition[], _TFieldsets extends readonly Fieldset<AnyFieldDefinition[]>[]>(name: string, config: ContentTypeConfigWithFields<TFields>): SingletonContentTypeDefinition<TFields, readonly []>;
|
|
54
|
-
declare function defineSingletonContentType<_TFields extends readonly AnyFieldDefinition[], TFieldsets extends readonly Fieldset<AnyFieldDefinition[]>[]>(name: string, config: ContentTypeConfigWithFieldsets<TFieldsets>): SingletonContentTypeDefinition<readonly [], TFieldsets>;
|
|
55
|
-
declare const defineSingleton: typeof defineSingletonContentType;
|
|
56
|
-
/**
|
|
57
|
-
* Singleton metadata.
|
|
58
|
-
*
|
|
59
|
-
* The per-locale publication half is inherited from `LocalePublicationFields` rather than absent.
|
|
60
|
-
* `apps/services/api` reports `localeStatus` / `localeHasDraft` / `draftLocales` on singleton reads
|
|
61
|
-
* exactly as it does on entry reads (`INV-LM-PUBLICATION-IS-REPORTED-PER-LOCALE`); this type simply
|
|
62
|
-
* never said so, which told a customer that a singleton has no publication state to read.
|
|
63
|
-
*/
|
|
64
|
-
interface SingletonMetadata extends LocalePublicationFields {
|
|
65
|
-
/** Singleton key identifier */
|
|
66
|
-
key: string;
|
|
67
|
-
/** Singleton type identifier */
|
|
68
|
-
singletonType: string;
|
|
69
|
-
/** Content version */
|
|
70
|
-
version: number;
|
|
71
|
-
/** Content locale */
|
|
72
|
-
locale: string;
|
|
73
|
-
/** Creation timestamp */
|
|
74
|
-
createdAt: Date;
|
|
75
|
-
/** Last update timestamp */
|
|
76
|
-
updatedAt: Date;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Type alias for any singleton content type definition.
|
|
80
|
-
*/
|
|
81
|
-
type AnySingletonContentTypeDefinition = SingletonContentTypeDefinition<any, any>;
|
|
82
|
-
/**
|
|
83
|
-
* Extract field IDs from a singleton content type definition
|
|
84
|
-
*/
|
|
85
|
-
type ExtractSingletonFieldIds<T extends AnySingletonContentTypeDefinition> = NonNullable<T['fields']> extends (infer F)[] ? F extends AnyFieldDefinition ? F['id'] : ExtractFromSingletonFieldsets<T> : ExtractFromSingletonFieldsets<T>;
|
|
86
|
-
type ExtractFromSingletonFieldsets<T extends AnySingletonContentTypeDefinition> = NonNullable<T['fieldsets']> extends (infer FS)[] ? FS extends Fieldset<infer Fields> ? Fields extends AnyFieldDefinition[] ? Fields[number]['id'] : never : never : never;
|
|
87
|
-
/**
|
|
88
|
-
* Infer the TypeScript type from a singleton definition
|
|
89
|
-
*/
|
|
90
|
-
type InferSingletonContentType<T extends AnySingletonContentTypeDefinition> = {
|
|
91
|
-
[K in ExtractSingletonFieldIds<T> & string]?: unknown;
|
|
92
|
-
} & {
|
|
93
|
-
_metadata: SingletonMetadata;
|
|
94
|
-
};
|
|
95
|
-
type InferSingleton<T extends AnySingletonContentTypeDefinition> = InferSingletonContentType<T>;
|
|
1
|
+
import { A as AnyFieldDefinition, c as FieldDefinition, k as AIConfig, u as FieldSchemaContext, w as FieldValues, x as DeclaredFields, O as ContentTypeDefinition, Z as SingletonContentTypeDefinition, aD as WorkflowDefinition, a5 as AssetTypeDefinition, Q as InferContentType } from './define-content-type-CDB3kyeA.cjs';
|
|
96
2
|
|
|
97
3
|
/**
|
|
98
4
|
* Component definition matching @relyio/schema ComponentSchema
|
|
@@ -121,9 +27,10 @@ interface ComponentMetadata {
|
|
|
121
27
|
validation?: ComponentValidationMetadata;
|
|
122
28
|
}
|
|
123
29
|
/**
|
|
124
|
-
* Component configuration
|
|
30
|
+
* Component configuration. Generic over its fields, as a content type's is, so a component field
|
|
31
|
+
* reads as an object typed by them (`INV-SS-TYPES-INFERRED`).
|
|
125
32
|
*/
|
|
126
|
-
interface ComponentConfig {
|
|
33
|
+
interface ComponentConfig<TFields extends readonly AnyFieldDefinition[] = FieldDefinition[]> {
|
|
127
34
|
/** Display name shown in the UI */
|
|
128
35
|
displayName?: string;
|
|
129
36
|
/** Description of the component */
|
|
@@ -133,14 +40,14 @@ interface ComponentConfig {
|
|
|
133
40
|
/** Whether this component is deprecated */
|
|
134
41
|
deprecated?: boolean;
|
|
135
42
|
/** Component fields */
|
|
136
|
-
fields:
|
|
43
|
+
fields: TFields;
|
|
137
44
|
/** Component metadata for validation and reusability */
|
|
138
45
|
metadata?: ComponentMetadata;
|
|
139
46
|
}
|
|
140
47
|
/**
|
|
141
|
-
* Component definition
|
|
48
|
+
* Component definition - preserves field types for inference
|
|
142
49
|
*/
|
|
143
|
-
interface ComponentDefinition {
|
|
50
|
+
interface ComponentDefinition<TFields extends readonly AnyFieldDefinition[] = FieldDefinition[]> {
|
|
144
51
|
readonly _tag: 'component';
|
|
145
52
|
readonly name: string;
|
|
146
53
|
readonly displayName?: string;
|
|
@@ -148,7 +55,7 @@ interface ComponentDefinition {
|
|
|
148
55
|
/** AI configuration for content generation and review */
|
|
149
56
|
readonly ai?: AIConfig;
|
|
150
57
|
readonly deprecated: boolean;
|
|
151
|
-
readonly fields:
|
|
58
|
+
readonly fields: TFields;
|
|
152
59
|
readonly metadata?: ComponentMetadata;
|
|
153
60
|
}
|
|
154
61
|
/**
|
|
@@ -182,7 +89,7 @@ interface ComponentDefinition {
|
|
|
182
89
|
* ]
|
|
183
90
|
* })
|
|
184
91
|
*/
|
|
185
|
-
declare function defineComponent(name: string, config: ComponentConfig): ComponentDefinition
|
|
92
|
+
declare function defineComponent<TFields extends readonly AnyFieldDefinition[]>(name: string, config: ComponentConfig<TFields>): ComponentDefinition<TFields>;
|
|
186
93
|
|
|
187
94
|
/**
|
|
188
95
|
* Settings group definition matching @relyio/schema SettingsGroupSchema
|
|
@@ -252,10 +159,6 @@ declare function defineSettingsGroup<TFields extends readonly AnyFieldDefinition
|
|
|
252
159
|
* Type alias for any settings group definition.
|
|
253
160
|
*/
|
|
254
161
|
type AnySettingsGroupDefinition = SettingsGroupDefinition<any>;
|
|
255
|
-
/**
|
|
256
|
-
* Extract field IDs from a settings group definition
|
|
257
|
-
*/
|
|
258
|
-
type ExtractSettingsFieldIds<T extends AnySettingsGroupDefinition> = T['fields'] extends readonly AnyFieldDefinition[] ? T['fields'][number]['id'] : never;
|
|
259
162
|
/**
|
|
260
163
|
* Settings group metadata
|
|
261
164
|
*/
|
|
@@ -272,250 +175,13 @@ interface SettingsGroupMetadata {
|
|
|
272
175
|
updatedAt: Date;
|
|
273
176
|
}
|
|
274
177
|
/**
|
|
275
|
-
* Infer the TypeScript type from a settings group definition
|
|
178
|
+
* Infer the TypeScript type from a settings group definition: every field typed as a read returns it
|
|
179
|
+
* (`schema/infer-fields.ts`), plus `_metadata`. `S` is the schema, as for `InferContentType`.
|
|
276
180
|
*/
|
|
277
|
-
type InferSettingsGroup<T extends AnySettingsGroupDefinition> = {
|
|
278
|
-
[K in ExtractSettingsFieldIds<T> & string]?: unknown;
|
|
279
|
-
} & {
|
|
181
|
+
type InferSettingsGroup<T extends AnySettingsGroupDefinition, S extends FieldSchemaContext | undefined = undefined> = FieldValues<DeclaredFields<T>, S> & {
|
|
280
182
|
_metadata: SettingsGroupMetadata;
|
|
281
183
|
};
|
|
282
184
|
|
|
283
|
-
/**
|
|
284
|
-
* Asset type definition matching @relyio/schema AssetTypeSchema
|
|
285
|
-
*
|
|
286
|
-
* Asset types are first-class entries (entryType: 'asset') that pair a binary
|
|
287
|
-
* pipeline family (declared via exactly one kind key: `image`, `video`, or
|
|
288
|
-
* `file`) with user-defined metadata fields that reuse the standard field
|
|
289
|
-
* system — including fieldsets, workflow, access tags, and AI config.
|
|
290
|
-
*
|
|
291
|
-
* The kind config blocks are strongly typed below (mirroring the zod-inferred
|
|
292
|
-
* `@relyio/schema` types), so authoring asset types in TypeScript gets full
|
|
293
|
-
* autocomplete. The authoritative validation still lives in @relyio/schema's
|
|
294
|
-
* `AssetTypesValidator` and runs on deploy.
|
|
295
|
-
*/
|
|
296
|
-
|
|
297
|
-
/** Resize fit modes supported by the Cloudflare Images binding. */
|
|
298
|
-
type ImageFitMode = 'cover' | 'contain' | 'fill' | 'inside' | 'outside';
|
|
299
|
-
/** Output formats the Cloudflare Images binding can produce (`heic` is input-only). */
|
|
300
|
-
type ImageOutputFormat = 'avif' | 'webp' | 'jpeg' | 'png';
|
|
301
|
-
/** Shared image transform props (CF Images vocabulary). */
|
|
302
|
-
interface ImageTransform {
|
|
303
|
-
width?: number;
|
|
304
|
-
height?: number;
|
|
305
|
-
fit?: ImageFitMode;
|
|
306
|
-
format?: ImageOutputFormat;
|
|
307
|
-
quality?: number;
|
|
308
|
-
}
|
|
309
|
-
/** Upload gate for the `image` kind (rejects bad files at the door). */
|
|
310
|
-
interface ImageUploadConfig {
|
|
311
|
-
allowedMimeTypes?: string[];
|
|
312
|
-
maxFileSize?: number;
|
|
313
|
-
minWidth?: number;
|
|
314
|
-
maxWidth?: number;
|
|
315
|
-
minHeight?: number;
|
|
316
|
-
maxHeight?: number;
|
|
317
|
-
/** `width:height`, e.g. `16:9`. */
|
|
318
|
-
aspectRatio?: string;
|
|
319
|
-
}
|
|
320
|
-
/** Upload gate for the `video` kind. */
|
|
321
|
-
interface VideoUploadConfig {
|
|
322
|
-
allowedMimeTypes?: string[];
|
|
323
|
-
maxFileSize?: number;
|
|
324
|
-
maxDuration?: number;
|
|
325
|
-
minWidth?: number;
|
|
326
|
-
maxWidth?: number;
|
|
327
|
-
minHeight?: number;
|
|
328
|
-
maxHeight?: number;
|
|
329
|
-
}
|
|
330
|
-
/** Upload gate for the `file` kind (MIME + size only in v1). */
|
|
331
|
-
interface FileUploadConfig {
|
|
332
|
-
allowedMimeTypes?: string[];
|
|
333
|
-
maxFileSize?: number;
|
|
334
|
-
}
|
|
335
|
-
/** Delivery rendition preset (max 20 per asset type), applied on the fly by the gateway. */
|
|
336
|
-
interface VariantDefinition extends ImageTransform {
|
|
337
|
-
/** Variant id; must start with a letter (codegen emits the `*Variant` union from these). */
|
|
338
|
-
id: string;
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Ingest normalization of the canonical stored original (image v1 only).
|
|
342
|
-
* `true` expands to the platform default on deploy.
|
|
343
|
-
*/
|
|
344
|
-
type ImageSourceConfig = boolean | (ImageTransform & {
|
|
345
|
-
stripMetadata?: boolean;
|
|
346
|
-
});
|
|
347
|
-
/** EXIF retention policy for the `image` kind (plan 15). */
|
|
348
|
-
interface ImageExifConfig {
|
|
349
|
-
/** Retain GPS in `extracted.exif` (default strips it for privacy). */
|
|
350
|
-
keepGps?: boolean;
|
|
351
|
-
}
|
|
352
|
-
/** Image kind config (`upload`, `source`, `variants`, `localization`, `exif`). */
|
|
353
|
-
interface ImageKindConfig {
|
|
354
|
-
upload?: ImageUploadConfig;
|
|
355
|
-
source?: ImageSourceConfig;
|
|
356
|
-
/** Max 20 variants per asset type. */
|
|
357
|
-
variants?: VariantDefinition[];
|
|
358
|
-
localization?: LocalizationConfig;
|
|
359
|
-
exif?: ImageExifConfig;
|
|
360
|
-
}
|
|
361
|
-
/** Poster/thumbnail strategy for the `video` kind. */
|
|
362
|
-
interface VideoPosterConfig {
|
|
363
|
-
/** 0.0–1.0 → Stream thumbnailTimestampPct. */
|
|
364
|
-
defaultTimestampPct?: number;
|
|
365
|
-
/** Enable an animated preview (gif/webp). */
|
|
366
|
-
animated?: boolean;
|
|
367
|
-
}
|
|
368
|
-
/** Subtitle track strategy for the `video` kind. */
|
|
369
|
-
interface VideoCaptionsConfig {
|
|
370
|
-
enabled?: boolean;
|
|
371
|
-
requiredLocales?: string[];
|
|
372
|
-
/** Stream AI transcription when no track is uploaded. */
|
|
373
|
-
autoGenerate?: boolean;
|
|
374
|
-
}
|
|
375
|
-
/** Downloadable-MP4 toggle for the `video` kind. */
|
|
376
|
-
interface VideoDownloadConfig {
|
|
377
|
-
enabled?: boolean;
|
|
378
|
-
}
|
|
379
|
-
/** Stream watermark profile for the `video` kind. */
|
|
380
|
-
interface VideoWatermarkConfig {
|
|
381
|
-
enabled?: boolean;
|
|
382
|
-
/** Account-level Stream watermark profile uid. */
|
|
383
|
-
profileId?: string;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Video kind config (`upload`, `poster`, `captions`, `download`, `watermark`,
|
|
387
|
-
* `localization`). Stream auto-generates the ABR ladder — there is intentionally
|
|
388
|
-
* NO `variants` and NO `encoding` block.
|
|
389
|
-
*/
|
|
390
|
-
interface VideoKindConfig {
|
|
391
|
-
upload?: VideoUploadConfig;
|
|
392
|
-
poster?: VideoPosterConfig;
|
|
393
|
-
captions?: VideoCaptionsConfig;
|
|
394
|
-
download?: VideoDownloadConfig;
|
|
395
|
-
watermark?: VideoWatermarkConfig;
|
|
396
|
-
localization?: LocalizationConfig;
|
|
397
|
-
}
|
|
398
|
-
/** Malware scan config for the `file` kind (plan 19). */
|
|
399
|
-
interface FileScanConfig {
|
|
400
|
-
enabled?: boolean;
|
|
401
|
-
blockUntilClean?: boolean;
|
|
402
|
-
}
|
|
403
|
-
/** File kind config (`upload`, `localization`, `scan`, `extractText`). */
|
|
404
|
-
interface FileKindConfig {
|
|
405
|
-
upload?: FileUploadConfig;
|
|
406
|
-
localization?: LocalizationConfig;
|
|
407
|
-
/** Malware scan (plan 19). */
|
|
408
|
-
scan?: FileScanConfig;
|
|
409
|
-
/** Extract searchable text + metadata for PDFs (plan 15). */
|
|
410
|
-
extractText?: boolean;
|
|
411
|
-
}
|
|
412
|
-
interface AssetTypeBaseConfig {
|
|
413
|
-
/** Display name shown in the UI */
|
|
414
|
-
displayName: string;
|
|
415
|
-
/** Plural display name (e.g., "Product Photos" for "Product Photo") */
|
|
416
|
-
displayNamePlural?: string;
|
|
417
|
-
/** Description of the asset type */
|
|
418
|
-
description?: string;
|
|
419
|
-
/**
|
|
420
|
-
* AI configuration. `ai.instructions` is an optional global brief; per-field
|
|
421
|
-
* `ai.instructions` describe individual fields. `ai.autoGenerate` (image
|
|
422
|
-
* kind, v1) is the master switch: when true, the derived analysis agent runs
|
|
423
|
-
* after upload and fills every field that declares `ai.instructions`, applied
|
|
424
|
-
* as a review proposal.
|
|
425
|
-
*/
|
|
426
|
-
ai?: AssetAIConfig;
|
|
427
|
-
/** Field ID to use as the asset display title */
|
|
428
|
-
displayField?: string;
|
|
429
|
-
/** Access tags for role-based access control */
|
|
430
|
-
accessTags?: string[];
|
|
431
|
-
/** Workflow configuration for this asset type */
|
|
432
|
-
workflow?: ContentTypeWorkflowConfig;
|
|
433
|
-
/** Image pipeline config — mutually exclusive with `video`/`file` */
|
|
434
|
-
image?: ImageKindConfig;
|
|
435
|
-
/** Video pipeline config — mutually exclusive with `image`/`file` */
|
|
436
|
-
video?: VideoKindConfig;
|
|
437
|
-
/** File pipeline config — mutually exclusive with `image`/`video` */
|
|
438
|
-
file?: FileKindConfig;
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Type alias for a fieldset with any fields.
|
|
442
|
-
*/
|
|
443
|
-
type AnyFieldset = Fieldset<any>;
|
|
444
|
-
/** Asset type configuration using direct fields. */
|
|
445
|
-
interface AssetTypeConfigWithFields<TFields extends readonly AnyFieldDefinition[] = readonly AnyFieldDefinition[]> extends AssetTypeBaseConfig {
|
|
446
|
-
/** Direct field definitions - preserves literal types */
|
|
447
|
-
fields: TFields;
|
|
448
|
-
/** Cannot have fieldsets when using fields */
|
|
449
|
-
fieldsets?: never;
|
|
450
|
-
}
|
|
451
|
-
/** Asset type configuration using fieldsets. */
|
|
452
|
-
interface AssetTypeConfigWithFieldsets<TFieldsets extends readonly AnyFieldset[] = readonly AnyFieldset[]> extends AssetTypeBaseConfig {
|
|
453
|
-
/** Field organization via fieldsets - preserves literal types */
|
|
454
|
-
fieldsets: TFieldsets;
|
|
455
|
-
/** Cannot have direct fields when using fieldsets */
|
|
456
|
-
fields?: never;
|
|
457
|
-
}
|
|
458
|
-
/** Asset type configuration (either fields OR fieldsets). */
|
|
459
|
-
type AssetTypeConfig<TFields extends readonly AnyFieldDefinition[] = readonly AnyFieldDefinition[], TFieldsets extends readonly AnyFieldset[] = readonly AnyFieldset[]> = AssetTypeConfigWithFields<TFields> | AssetTypeConfigWithFieldsets<TFieldsets>;
|
|
460
|
-
/** Asset type definition - preserves field types for inference. */
|
|
461
|
-
interface AssetTypeDefinition<TFields extends readonly AnyFieldDefinition[] = readonly AnyFieldDefinition[], TFieldsets extends readonly AnyFieldset[] = readonly AnyFieldset[]> {
|
|
462
|
-
readonly _tag: 'assetType';
|
|
463
|
-
readonly name: string;
|
|
464
|
-
readonly displayName: string;
|
|
465
|
-
readonly displayNamePlural?: string;
|
|
466
|
-
readonly description?: string;
|
|
467
|
-
readonly ai?: AssetAIConfig;
|
|
468
|
-
readonly displayField?: string;
|
|
469
|
-
readonly accessTags?: string[];
|
|
470
|
-
readonly workflow?: ContentTypeWorkflowConfig;
|
|
471
|
-
readonly image?: ImageKindConfig;
|
|
472
|
-
readonly video?: VideoKindConfig;
|
|
473
|
-
readonly file?: FileKindConfig;
|
|
474
|
-
readonly fields?: TFields;
|
|
475
|
-
readonly fieldsets?: TFieldsets;
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Define an asset type.
|
|
479
|
-
*
|
|
480
|
-
* Exactly one kind key (`image`, `video`, or `file`) must be supplied. The
|
|
481
|
-
* generic type parameters preserve literal field IDs for inference, mirroring
|
|
482
|
-
* `defineContentType`.
|
|
483
|
-
*
|
|
484
|
-
* @example
|
|
485
|
-
* const productPhoto = defineAssetType('productPhoto', {
|
|
486
|
-
* displayName: 'Product Photo',
|
|
487
|
-
* image: {
|
|
488
|
-
* upload: { allowedMimeTypes: ['image/jpeg', 'image/png', 'image/webp'], maxFileSize: 10485760 },
|
|
489
|
-
* variants: [{ id: 'thumb', width: 200, height: 200, fit: 'cover', format: 'webp' }],
|
|
490
|
-
* },
|
|
491
|
-
* fields: [
|
|
492
|
-
* fields.shortText('altText', { ui: { displayName: 'Alt Text' } }),
|
|
493
|
-
* ],
|
|
494
|
-
* })
|
|
495
|
-
*/
|
|
496
|
-
declare function defineAssetType<TFields extends readonly AnyFieldDefinition[], _TFieldsets extends readonly Fieldset<AnyFieldDefinition[]>[]>(name: string, config: AssetTypeConfigWithFields<TFields>): AssetTypeDefinition<TFields, readonly []>;
|
|
497
|
-
declare function defineAssetType<_TFields extends readonly AnyFieldDefinition[], TFieldsets extends readonly Fieldset<AnyFieldDefinition[]>[]>(name: string, config: AssetTypeConfigWithFieldsets<TFieldsets>): AssetTypeDefinition<readonly [], TFieldsets>;
|
|
498
|
-
/**
|
|
499
|
-
* Type alias for any asset type definition.
|
|
500
|
-
*/
|
|
501
|
-
type AnyAssetTypeDefinition = AssetTypeDefinition<any, any>;
|
|
502
|
-
type ExtractAssetFieldIds<T extends AnyAssetTypeDefinition> = NonNullable<T['fields']> extends (infer F)[] ? F extends AnyFieldDefinition ? F['id'] : ExtractFromAssetFieldsets<T> : ExtractFromAssetFieldsets<T>;
|
|
503
|
-
type ExtractFromAssetFieldsets<T extends AnyAssetTypeDefinition> = NonNullable<T['fieldsets']> extends (infer FS)[] ? FS extends Fieldset<infer Fields> ? Fields extends AnyFieldDefinition[] ? Fields[number]['id'] : never : never : never;
|
|
504
|
-
/**
|
|
505
|
-
* Infer the TypeScript type from an asset type definition.
|
|
506
|
-
*
|
|
507
|
-
* Mirrors {@link InferContentType}: produces the (optional) metadata field shape
|
|
508
|
-
* plus `_metadata`, so it is assignable to `BaseContent` and can parametrize
|
|
509
|
-
* `AssetClient<T>`. The runtime `file`/`urls` blocks are layered on by the
|
|
510
|
-
* client's `AssetEntryResponse<T>` return type, not here, to keep the schema
|
|
511
|
-
* layer free of any dependency on the client layer.
|
|
512
|
-
*/
|
|
513
|
-
type InferAssetType<T extends AnyAssetTypeDefinition> = {
|
|
514
|
-
[K in ExtractAssetFieldIds<T> & string]?: unknown;
|
|
515
|
-
} & {
|
|
516
|
-
_metadata: EntryMetadata;
|
|
517
|
-
};
|
|
518
|
-
|
|
519
185
|
/**
|
|
520
186
|
* Query definition matching @relyio/schema QueryDefinitionSchema
|
|
521
187
|
*
|
|
@@ -1410,6 +1076,18 @@ type AnySchemaDefinition = SchemaDefinition<any, any, any, any, any, any, any, a
|
|
|
1410
1076
|
* Get content type names from a schema
|
|
1411
1077
|
*/
|
|
1412
1078
|
type SchemaContentTypeNames<T extends AnySchemaDefinition> = keyof T['contentTypes'] & string;
|
|
1079
|
+
/**
|
|
1080
|
+
* An entry of content type `K`, typed by schema `T` as a read returns it — what `content(K)` reads,
|
|
1081
|
+
* with references and components resolved against `T` (`INV-SS-TYPES-INFERRED`).
|
|
1082
|
+
*/
|
|
1083
|
+
type SchemaEntry<T extends AnySchemaDefinition, K extends SchemaContentTypeNames<T>> = InferContentType<T['contentTypes'][K], T>;
|
|
1084
|
+
/**
|
|
1085
|
+
* An entry of any one of the content types `K` names — every content type by default — as a search
|
|
1086
|
+
* across them returns it: a union, so `_metadata.type` tells a caller which it holds.
|
|
1087
|
+
*/
|
|
1088
|
+
type SchemaEntryOf<T extends AnySchemaDefinition, K extends SchemaContentTypeNames<T> = SchemaContentTypeNames<T>> = {
|
|
1089
|
+
[N in K]: SchemaEntry<T, N>;
|
|
1090
|
+
}[K];
|
|
1413
1091
|
/**
|
|
1414
1092
|
* Get singleton names from a schema
|
|
1415
1093
|
*/
|
|
@@ -1435,4 +1113,4 @@ type SchemaAssetTypeNames<T extends AnySchemaDefinition> = NonNullable<T['assetT
|
|
|
1435
1113
|
*/
|
|
1436
1114
|
type SchemaLocaleCodes<T extends AnySchemaDefinition> = NonNullable<T['locales']> extends readonly LocaleDefinition[] ? NonNullable<T['locales']>[number]['code'] : never;
|
|
1437
1115
|
|
|
1438
|
-
export { type
|
|
1116
|
+
export { type ViewFilter as $, defineRole as A, isRoleDefinition as B, type ComponentConfig as C, isBuiltInRole as D, getBuiltInRoleActions as E, BUILT_IN_ROLES as F, BUILT_IN_ROLE_ACTIONS as G, type BuiltInRole as H, type InferSettingsGroup as I, type RoleAction as J, type ResourcePermission as K, type LocaleOptions as L, type FieldVisibility as M, type RoleConfig as N, type RoleDefinition as O, defineView as P, type ContentTypeScopeConfig as Q, ROLE_ACTIONS as R, type SchemaConfig as S, type TextDirection as T, type ContentTypesScopeConfig as U, type ViewScopeConfig as V, type EntryTypeScopeConfig as W, type AllScopeConfig as X, type ViewFilterOperator as Y, type ViewFilterCondition as Z, type ViewFilterGroup as _, type SchemaDefinition as a, type ViewConfig as a0, type ViewDefinition as a1, defineQuery as a2, type QueryConfig as a3, type QueryDefinition as a4, type FetchBlock as a5, type AggregateBlock as a6, type SearchBlock as a7, type SimilarBlock as a8, type WhereCondition as a9, type WhereValue as aa, type WhereOperator as ab, type SortCondition as ac, type SortDirection as ad, type IncludeDefinition as ae, type SelectMapping as af, type FilterDefinition as ag, type CachePolicy as ah, type CachePolicyObject as ai, type IncludeSubQuery as aj, type IncludeSubQueries as ak, type Parameterizable as al, type QueryParameter as am, type QueryParameterType as an, type QueryCardinality as ao, type InferQueryResponse as ap, type InferQueryParams as aq, type SchemaContentTypeNames as b, type SchemaSingletonNames as c, defineSchema as d, type SchemaQueryNames as e, type SchemaLocaleCodes as f, type SchemaSettingsGroupNames as g, type SchemaAssetTypeNames as h, type SchemaEntry as i, type SchemaEntryOf as j, defineLocale as k, isLocaleDefinition as l, getLocaleCodes as m, findDefaultLocale as n, getActiveLocales as o, buildFallbackChain as p, type LocaleDefinition as q, defineComponent as r, type ComponentDefinition as s, type ComponentMetadata as t, type ComponentReusabilityMetadata as u, type ComponentValidationMetadata as v, defineSettingsGroup as w, type SettingsGroupConfig as x, type SettingsGroupDefinition as y, type SettingsGroupMetadata as z };
|