@relyio/sdk 0.5.0 → 0.7.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 +540 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-HAQELDZN.cjs → chunk-72UK5U7T.cjs} +70 -60
- package/dist/{chunk-5AZUUV5B.js → chunk-GYHAVYND.js} +1086 -494
- package/dist/{chunk-I3ESNANB.js → chunk-H6IBQSMM.js} +2 -2
- package/dist/{chunk-HT6NFRM2.cjs → chunk-TZL374LS.cjs} +2 -2
- package/dist/{chunk-CIRT6TVT.cjs → chunk-VH2DE7HZ.cjs} +1088 -497
- package/dist/{chunk-XY5KFEFY.js → chunk-YEJUMW4X.js} +70 -60
- package/dist/client/index.cjs +4 -3
- package/dist/client/index.d.cts +4 -4
- package/dist/client/index.d.ts +4 -4
- package/dist/client/index.js +2 -1
- package/dist/{index-C5mRBb6t.d.cts → define-content-type-DiVpbwNs.d.cts} +1629 -665
- package/dist/{index-mXUx2H99.d.ts → define-content-type-DiVpbwNs.d.ts} +1629 -665
- package/dist/{define-schema-DzYXk4HL.d.ts → define-schema-C-5an28C.d.ts} +211 -429
- package/dist/{define-schema-2xbHgtK-.d.cts → define-schema-D7MButVt.d.cts} +211 -429
- package/dist/{index-Dzo-upNS.d.ts → index-1G97sNA8.d.ts} +677 -296
- package/dist/index-BOQIHnsh.d.ts +818 -0
- package/dist/index-DbsTUw3Q.d.cts +818 -0
- package/dist/{index-BozPz4n1.d.cts → index-M0X45k7J.d.cts} +677 -296
- package/dist/index.cjs +180 -103
- package/dist/index.d.cts +307 -32
- package/dist/index.d.ts +307 -32
- package/dist/index.js +95 -8
- package/dist/schema/index.cjs +35 -35
- package/dist/schema/index.d.cts +21 -15
- package/dist/schema/index.d.ts +21 -15
- package/dist/schema/index.js +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/index.cjs +19 -19
- package/dist/utils/index.d.cts +10 -1
- package/dist/utils/index.d.ts +10 -1
- package/dist/utils/index.js +1 -1
- package/package.json +4 -3
- 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, v as FieldSchemaContext, x as FieldValues, y as DeclaredFields, aK as components, P as ContentTypeDefinition, a0 as SingletonContentTypeDefinition, aH as WorkflowDefinition, a9 as AssetTypeDefinition, W as InferContentType } from './define-content-type-DiVpbwNs.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,22 +40,22 @@ 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;
|
|
147
54
|
readonly description?: string;
|
|
148
55
|
/** AI configuration for content generation and review */
|
|
149
56
|
readonly ai?: AIConfig;
|
|
150
|
-
readonly deprecated
|
|
151
|
-
readonly fields:
|
|
57
|
+
readonly deprecated?: boolean;
|
|
58
|
+
readonly fields: TFields;
|
|
152
59
|
readonly metadata?: ComponentMetadata;
|
|
153
60
|
}
|
|
154
61
|
/**
|
|
@@ -167,7 +74,9 @@ interface ComponentDefinition {
|
|
|
167
74
|
* config: { maxLength: 160 },
|
|
168
75
|
* ui: { displayName: 'Meta Description' }
|
|
169
76
|
* }),
|
|
170
|
-
*
|
|
77
|
+
* // An image is an entry of an asset type, which a reference points at
|
|
78
|
+
* fields.reference('ogImage', {
|
|
79
|
+
* config: { to: 'productPhoto' },
|
|
171
80
|
* ui: { displayName: 'Open Graph Image' }
|
|
172
81
|
* }),
|
|
173
82
|
* ]
|
|
@@ -182,7 +91,7 @@ interface ComponentDefinition {
|
|
|
182
91
|
* ]
|
|
183
92
|
* })
|
|
184
93
|
*/
|
|
185
|
-
declare function defineComponent(name: string, config: ComponentConfig): ComponentDefinition
|
|
94
|
+
declare function defineComponent<TFields extends readonly AnyFieldDefinition[]>(name: string, config: ComponentConfig<TFields>): ComponentDefinition<TFields>;
|
|
186
95
|
|
|
187
96
|
/**
|
|
188
97
|
* Settings group definition matching @relyio/schema SettingsGroupSchema
|
|
@@ -253,267 +162,21 @@ declare function defineSettingsGroup<TFields extends readonly AnyFieldDefinition
|
|
|
253
162
|
*/
|
|
254
163
|
type AnySettingsGroupDefinition = SettingsGroupDefinition<any>;
|
|
255
164
|
/**
|
|
256
|
-
*
|
|
257
|
-
|
|
258
|
-
type ExtractSettingsFieldIds<T extends AnySettingsGroupDefinition> = T['fields'] extends readonly AnyFieldDefinition[] ? T['fields'][number]['id'] : never;
|
|
259
|
-
/**
|
|
260
|
-
* Settings group metadata
|
|
261
|
-
*/
|
|
262
|
-
interface SettingsGroupMetadata {
|
|
263
|
-
/** Settings group key identifier */
|
|
264
|
-
key: string;
|
|
265
|
-
/** Settings group type identifier */
|
|
266
|
-
groupType: string;
|
|
267
|
-
/** Content version */
|
|
268
|
-
version: number;
|
|
269
|
-
/** Creation timestamp */
|
|
270
|
-
createdAt: Date;
|
|
271
|
-
/** Last update timestamp */
|
|
272
|
-
updatedAt: Date;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Infer the TypeScript type from a settings group definition
|
|
276
|
-
*/
|
|
277
|
-
type InferSettingsGroup<T extends AnySettingsGroupDefinition> = {
|
|
278
|
-
[K in ExtractSettingsFieldIds<T> & string]?: unknown;
|
|
279
|
-
} & {
|
|
280
|
-
_metadata: SettingsGroupMetadata;
|
|
281
|
-
};
|
|
282
|
-
|
|
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.
|
|
165
|
+
* What a read reports about a settings group beside its fields: the committed document's
|
|
166
|
+
* `SettingsGroupMetadata`, read through `http/api-schema.ts` rather than declared again here.
|
|
290
167
|
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
* `
|
|
168
|
+
* It names the group by `id` and `groupId`, carries the per-locale facts and the version history
|
|
169
|
+
* of `locale`, and says when the group was last written — there is no `createdAt`. The hand-written
|
|
170
|
+
* type this replaces declared a `key`, a `groupType` and a `createdAt` the wire does not carry, and
|
|
171
|
+
* `Date` timestamps where it sends ISO 8601 strings.
|
|
295
172
|
*/
|
|
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
|
-
}
|
|
173
|
+
type SettingsGroupMetadata = components['schemas']['SettingsGroupMetadata'];
|
|
340
174
|
/**
|
|
341
|
-
*
|
|
342
|
-
* `
|
|
175
|
+
* Infer the TypeScript type from a settings group definition: every field typed as a read returns it
|
|
176
|
+
* (`schema/infer-fields.ts`), plus `_metadata`. `S` is the schema, as for `InferContentType`.
|
|
343
177
|
*/
|
|
344
|
-
type
|
|
345
|
-
|
|
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;
|
|
178
|
+
type InferSettingsGroup<T extends AnySettingsGroupDefinition, S extends FieldSchemaContext | undefined = undefined> = FieldValues<DeclaredFields<T>, S> & {
|
|
179
|
+
_metadata: SettingsGroupMetadata;
|
|
517
180
|
};
|
|
518
181
|
|
|
519
182
|
/**
|
|
@@ -523,19 +186,68 @@ type InferAssetType<T extends AnyAssetTypeDefinition> = {
|
|
|
523
186
|
*
|
|
524
187
|
* This is a hand-written mirror: `@relyio/sdk` is published standalone and does not depend on
|
|
525
188
|
* `@relyio/schema`, so a field added there has to be added here too. When the two drifted, `limit`
|
|
526
|
-
* was the casualty — the documentation writes `limit: '${limit?20}'` and this file said `number
|
|
189
|
+
* was the casualty — the documentation writes `limit: '${limit?20}'` and this file said `number` —
|
|
190
|
+
* and so were `fullText` and `type`, which a query pulled by `relyio generate-types` carried and
|
|
191
|
+
* this refused. `@relyio/codegen-typescript`'s `src/__tests__/sdk-definition-config.types.ts` now
|
|
192
|
+
* fails to compile when a key, whether it is required, or the values it accepts differs from the
|
|
193
|
+
* schema's, block by block (REL-1457).
|
|
194
|
+
*/
|
|
195
|
+
/** One value a query clause compares with. */
|
|
196
|
+
type QueryScalar = string | number | boolean;
|
|
197
|
+
/**
|
|
198
|
+
* The operators `where` and `filters` compare a field with — `{ price: { gte: 10 } }`.
|
|
199
|
+
*
|
|
200
|
+
* The service's one vocabulary for `where`, `filters` and `having`, which deploy refuses any other
|
|
201
|
+
* key against (REL-1479). There were four copies, and this one's `where` had no `eq` while `filters`
|
|
202
|
+
* took six operators, each a `${…}` string. A value may be a parameter expression: a list operator
|
|
203
|
+
* takes a list or a parameter that supplies one, a flag a boolean or a parameter.
|
|
204
|
+
* `@relyio/codegen-typescript`'s `sdk-definition-config.types.ts` fails to compile when an operator,
|
|
205
|
+
* or what it takes, differs from the schema's.
|
|
527
206
|
*/
|
|
528
207
|
type WhereOperator = {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
208
|
+
/** Equal to */
|
|
209
|
+
eq?: QueryScalar;
|
|
210
|
+
/** Not equal to */
|
|
211
|
+
ne?: QueryScalar;
|
|
212
|
+
/** Greater than */
|
|
213
|
+
gt?: QueryScalar;
|
|
214
|
+
/** Greater than or equal to */
|
|
215
|
+
gte?: QueryScalar;
|
|
216
|
+
/** Less than */
|
|
217
|
+
lt?: QueryScalar;
|
|
218
|
+
/** Less than or equal to */
|
|
219
|
+
lte?: QueryScalar;
|
|
220
|
+
/** One of the values given */
|
|
221
|
+
in?: QueryScalar[] | string;
|
|
222
|
+
/** None of the values given */
|
|
223
|
+
nin?: QueryScalar[] | string;
|
|
224
|
+
/** Contains the text, ignoring case */
|
|
225
|
+
contains?: QueryScalar;
|
|
226
|
+
/** Starts with the text, ignoring case */
|
|
227
|
+
startsWith?: QueryScalar;
|
|
228
|
+
/** Ends with the text, ignoring case */
|
|
229
|
+
endsWith?: QueryScalar;
|
|
230
|
+
/** The field holds a value (true) or does not (false) */
|
|
231
|
+
exists?: boolean | string;
|
|
232
|
+
/** The field holds no value (true) or does (false) */
|
|
233
|
+
notExists?: boolean | string;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* The operators `having` compares a metric with: the same as `where`'s, each with a literal, since
|
|
237
|
+
* `having` reads the values the aggregate computed and substitutes no parameter.
|
|
238
|
+
*/
|
|
239
|
+
type HavingOperator = {
|
|
240
|
+
eq?: QueryScalar;
|
|
241
|
+
ne?: QueryScalar;
|
|
242
|
+
gt?: QueryScalar;
|
|
243
|
+
gte?: QueryScalar;
|
|
244
|
+
lt?: QueryScalar;
|
|
245
|
+
lte?: QueryScalar;
|
|
246
|
+
in?: QueryScalar[];
|
|
247
|
+
nin?: QueryScalar[];
|
|
248
|
+
contains?: QueryScalar;
|
|
249
|
+
startsWith?: QueryScalar;
|
|
250
|
+
endsWith?: QueryScalar;
|
|
539
251
|
exists?: boolean;
|
|
540
252
|
notExists?: boolean;
|
|
541
253
|
};
|
|
@@ -543,28 +255,40 @@ type WhereValue = string | number | boolean | (string | number | boolean)[] | Wh
|
|
|
543
255
|
type WhereCondition = Record<string, WhereValue>;
|
|
544
256
|
type SortDirection = 'asc' | 'desc';
|
|
545
257
|
type SortCondition = Record<string, SortDirection> | Record<string, SortDirection>[];
|
|
258
|
+
/** `products(status=active).count as productCount`: a relationship, filtered and counted. */
|
|
546
259
|
type IncludeRelationship = {
|
|
547
260
|
relationship: string;
|
|
548
261
|
where?: WhereCondition;
|
|
549
|
-
|
|
262
|
+
/**
|
|
263
|
+
* What the include answers instead of the entries it joins. `count` is the one modifier: `sum`,
|
|
264
|
+
* `avg`, `min` and `max` name no field to reduce — select one, like `products.price.sum` — and
|
|
265
|
+
* the service refuses them (REL-1479).
|
|
266
|
+
*/
|
|
267
|
+
aggregate?: 'count';
|
|
268
|
+
/** The name the include answers under; the relationship's name when absent */
|
|
550
269
|
alias?: string;
|
|
551
270
|
};
|
|
552
|
-
|
|
271
|
+
/**
|
|
272
|
+
* A path, the fields to return from it, the references to expand beneath it and which entries to
|
|
273
|
+
* join — `{ path: 'items.product', fields: ['title'], include: ['brand'] }`. The one object form of a
|
|
274
|
+
* path: `IncludePath`, `{ path, include: string[], where }`, described a subset of this one and is
|
|
275
|
+
* gone. One level beneath, as the schema declares it: a deeper `include` inside a nested path is
|
|
276
|
+
* refused at deploy.
|
|
277
|
+
*/
|
|
278
|
+
type IncludeSelection = {
|
|
553
279
|
path: string;
|
|
554
280
|
fields?: string[];
|
|
555
|
-
include?: (string |
|
|
281
|
+
include?: (string | {
|
|
282
|
+
path: string;
|
|
283
|
+
fields?: string[];
|
|
284
|
+
where?: WhereCondition;
|
|
285
|
+
})[];
|
|
556
286
|
where?: WhereCondition;
|
|
557
287
|
};
|
|
558
|
-
type IncludeDefinition = string | string[] | (string | IncludeRelationship |
|
|
288
|
+
type IncludeDefinition = string | string[] | (string | IncludeRelationship | IncludeSelection)[];
|
|
559
289
|
type SelectMapping = Record<string, string>;
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
lte?: string;
|
|
563
|
-
gt?: string;
|
|
564
|
-
lt?: string;
|
|
565
|
-
in?: string;
|
|
566
|
-
nin?: string;
|
|
567
|
-
};
|
|
290
|
+
/** `filters` are `where` conditions bound at call time: the same operators, written the same way. */
|
|
291
|
+
type FilterOperator = WhereOperator;
|
|
568
292
|
type FilterDefinition = Record<string, string | FilterOperator>;
|
|
569
293
|
/** A value that is either a literal or a `${param}` / `${param?default}` expression. */
|
|
570
294
|
type Parameterizable<T> = T | string;
|
|
@@ -596,12 +320,22 @@ interface QueryParameter {
|
|
|
596
320
|
/** Whether the query answers with one record or a list. Independent of how many rows match. */
|
|
597
321
|
type QueryCardinality = 'one' | 'many';
|
|
598
322
|
type CachePolicyObject = {
|
|
599
|
-
|
|
323
|
+
/** Defaults to `public` */
|
|
324
|
+
policy?: 'public' | 'private' | 'no-cache';
|
|
600
325
|
ttl?: number;
|
|
601
326
|
staleWhileRevalidate?: number;
|
|
602
327
|
tags?: string[];
|
|
603
328
|
};
|
|
604
329
|
type CachePolicy = string | CachePolicyObject;
|
|
330
|
+
/** A text search over `fields` the query runs beside its operation block. */
|
|
331
|
+
type FullTextSearch = {
|
|
332
|
+
/** The fields searched; at least one */
|
|
333
|
+
fields: string[];
|
|
334
|
+
/** The search text, usually a parameter expression such as `${q}` */
|
|
335
|
+
query: string;
|
|
336
|
+
highlight?: boolean;
|
|
337
|
+
ranking?: 'simple' | 'complex';
|
|
338
|
+
};
|
|
605
339
|
/**
|
|
606
340
|
* Fetch block - retrieve content entries
|
|
607
341
|
*/
|
|
@@ -634,12 +368,15 @@ interface AggregateBlock {
|
|
|
634
368
|
expression: string;
|
|
635
369
|
as?: string;
|
|
636
370
|
})[];
|
|
637
|
-
/**
|
|
638
|
-
|
|
639
|
-
|
|
371
|
+
/**
|
|
372
|
+
* What to compute per group, keyed by the name each answers under: `<field>.<fn>`, where `fn` is
|
|
373
|
+
* `count`, `sum`, `avg`, `min`, `max`, `first` or `last` — `{ total: 'amount.sum' }`. Deploy
|
|
374
|
+
* requires it. The one spelling: `aggregations`, which this type called the main one, was a
|
|
375
|
+
* second name deploy refused (REL-1470).
|
|
376
|
+
*/
|
|
640
377
|
metrics?: Record<string, string>;
|
|
641
378
|
/** Having clause for filtering aggregations */
|
|
642
|
-
having?: Record<string,
|
|
379
|
+
having?: Record<string, QueryScalar | HavingOperator>;
|
|
643
380
|
/** Sort order */
|
|
644
381
|
sort?: SortCondition;
|
|
645
382
|
/** Maximum results */
|
|
@@ -681,23 +418,6 @@ interface SearchBlock {
|
|
|
681
418
|
/** Results offset */
|
|
682
419
|
offset?: Parameterizable<number>;
|
|
683
420
|
}
|
|
684
|
-
/**
|
|
685
|
-
* Similar block - find similar content via vector search
|
|
686
|
-
*/
|
|
687
|
-
interface SimilarBlock {
|
|
688
|
-
/** Single content type */
|
|
689
|
-
contentType?: string;
|
|
690
|
-
/** Multiple content types or "*" for all */
|
|
691
|
-
contentTypes?: string | string[] | '*';
|
|
692
|
-
/** Source entry UID to find similar content for */
|
|
693
|
-
source: string;
|
|
694
|
-
/** Filter conditions */
|
|
695
|
-
where?: WhereCondition;
|
|
696
|
-
/** Field mapping for results */
|
|
697
|
-
fields?: SelectMapping;
|
|
698
|
-
/** Maximum results */
|
|
699
|
-
limit?: Parameterizable<number>;
|
|
700
|
-
}
|
|
701
421
|
/**
|
|
702
422
|
* Include sub-queries for additional data
|
|
703
423
|
*/
|
|
@@ -709,10 +429,19 @@ interface IncludeSubQuery {
|
|
|
709
429
|
select?: SelectMapping;
|
|
710
430
|
}
|
|
711
431
|
type IncludeSubQueries = Record<string, IncludeSubQuery>;
|
|
432
|
+
/**
|
|
433
|
+
* Which operation block a query runs. Inferred from the block it declares when absent.
|
|
434
|
+
*
|
|
435
|
+
* `similar` is not one: deploy refused a query built on it alone and nothing ran it. Similar
|
|
436
|
+
* content is `relyio.similar(uid)` (REL-1470).
|
|
437
|
+
*/
|
|
438
|
+
type QueryType = 'fetch' | 'aggregate' | 'search';
|
|
712
439
|
/**
|
|
713
440
|
* Query definition configuration
|
|
714
441
|
*/
|
|
715
442
|
interface QueryConfig {
|
|
443
|
+
/** Which operation block the query runs; inferred when absent */
|
|
444
|
+
type?: QueryType;
|
|
716
445
|
/** API endpoint path (required, e.g., /api/featured-products) */
|
|
717
446
|
endpoint: string;
|
|
718
447
|
/** Query description */
|
|
@@ -723,12 +452,12 @@ interface QueryConfig {
|
|
|
723
452
|
aggregate?: AggregateBlock;
|
|
724
453
|
/** Search block for full-text/semantic search */
|
|
725
454
|
search?: SearchBlock;
|
|
726
|
-
/** Similar block for vector similarity search */
|
|
727
|
-
similar?: SimilarBlock;
|
|
728
455
|
/** Include sub-queries */
|
|
729
456
|
include?: IncludeSubQueries;
|
|
730
457
|
/** Dynamic filter definitions */
|
|
731
458
|
filters?: FilterDefinition;
|
|
459
|
+
/** Full-text search over the fields it names */
|
|
460
|
+
fullText?: FullTextSearch;
|
|
732
461
|
/** Field selection/mapping */
|
|
733
462
|
select?: SelectMapping;
|
|
734
463
|
/** Cache policy */
|
|
@@ -744,14 +473,15 @@ interface QueryConfig {
|
|
|
744
473
|
interface QueryDefinition {
|
|
745
474
|
readonly _tag: 'query';
|
|
746
475
|
readonly name: string;
|
|
476
|
+
readonly type?: QueryType;
|
|
747
477
|
readonly endpoint: string;
|
|
748
478
|
readonly description?: string;
|
|
749
479
|
readonly fetch?: FetchBlock;
|
|
750
480
|
readonly aggregate?: AggregateBlock;
|
|
751
481
|
readonly search?: SearchBlock;
|
|
752
|
-
readonly similar?: SimilarBlock;
|
|
753
482
|
readonly include?: IncludeSubQueries;
|
|
754
483
|
readonly filters?: FilterDefinition;
|
|
484
|
+
readonly fullText?: FullTextSearch;
|
|
755
485
|
readonly select?: SelectMapping;
|
|
756
486
|
readonly cache?: CachePolicy;
|
|
757
487
|
readonly parameters?: QueryParameter[];
|
|
@@ -807,7 +537,7 @@ interface QueryDefinition {
|
|
|
807
537
|
* source: 'product',
|
|
808
538
|
* where: { status: 'active' },
|
|
809
539
|
* by: ['category'],
|
|
810
|
-
*
|
|
540
|
+
* metrics: {
|
|
811
541
|
* totalProducts: 'id.count',
|
|
812
542
|
* avgPrice: 'price.base.avg',
|
|
813
543
|
* minPrice: 'price.base.min',
|
|
@@ -1171,16 +901,28 @@ interface AllScopeConfig {
|
|
|
1171
901
|
*/
|
|
1172
902
|
type ViewScopeConfig = ContentTypeScopeConfig | ContentTypesScopeConfig | EntryTypeScopeConfig | AllScopeConfig;
|
|
1173
903
|
/**
|
|
1174
|
-
*
|
|
904
|
+
* The operators a view filter may name: the schema's `FILTER_OPERATORS`, which deploy parses a view
|
|
905
|
+
* with and the read core compiles every one of.
|
|
1175
906
|
*
|
|
1176
|
-
*
|
|
1177
|
-
* `
|
|
1178
|
-
*
|
|
1179
|
-
*
|
|
1180
|
-
*
|
|
1181
|
-
*
|
|
1182
|
-
|
|
1183
|
-
|
|
907
|
+
* This list used to be its own: ten of its names — `doesNotContain`, `isNotEmpty`, `isOnOrBefore`,
|
|
908
|
+
* `isOnOrAfter`, `tomorrow`, `lastWeek`, `lastMonth`, `includesAll`, `includesAny`, `excludes` —
|
|
909
|
+
* are none the schema declares, so a view naming one was refused at deploy, and six the schema does
|
|
910
|
+
* declare — `notContains`, `notIncludes`, `isOn`, `isBetween`, `thisYear`, `hasValue` — could not be
|
|
911
|
+
* written here, so a view pulled by `relyio generate-types` that named one did not compile.
|
|
912
|
+
* `@relyio/codegen-typescript`'s `src/__tests__/sdk-definition-config.types.ts` holds the two to each
|
|
913
|
+
* other (REL-1457).
|
|
914
|
+
*/
|
|
915
|
+
type ViewFilterOperator = 'is' | 'isNot' | 'contains' | 'notContains' | 'startsWith' | 'endsWith' | 'isAnyOf' | 'isNoneOf' | 'includes' | 'notIncludes' | 'isTrue' | 'isFalse' | 'equals' | 'notEquals' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'between' | 'isOn' | 'isBefore' | 'isAfter' | 'isBetween' | 'inTheLast' | 'inTheNext' | 'today' | 'yesterday' | 'thisWeek' | 'thisMonth' | 'thisYear' | 'isEmpty' | 'hasValue';
|
|
916
|
+
/** A span of time back or forward from now, for `inTheLast` and `inTheNext`. */
|
|
917
|
+
interface ViewFilterRelativeDate {
|
|
918
|
+
amount: number;
|
|
919
|
+
unit: 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'years';
|
|
920
|
+
}
|
|
921
|
+
/** What a filter compares against: the schema's `FilterValueSchema`. */
|
|
922
|
+
type ViewFilterValue = string | number | boolean | null | (string | number)[] | {
|
|
923
|
+
from: string | number | Date;
|
|
924
|
+
to: string | number | Date;
|
|
925
|
+
} | ViewFilterRelativeDate | Date;
|
|
1184
926
|
/**
|
|
1185
927
|
* Simple filter condition
|
|
1186
928
|
*/
|
|
@@ -1196,7 +938,7 @@ interface ViewFilterCondition {
|
|
|
1196
938
|
/**
|
|
1197
939
|
* Filter value (optional for some operators like isEmpty)
|
|
1198
940
|
*/
|
|
1199
|
-
value?:
|
|
941
|
+
value?: ViewFilterValue;
|
|
1200
942
|
}
|
|
1201
943
|
/**
|
|
1202
944
|
* Grouped filter conditions with AND/OR logic
|
|
@@ -1224,8 +966,8 @@ interface ViewConfig {
|
|
|
1224
966
|
*/
|
|
1225
967
|
name: string;
|
|
1226
968
|
/**
|
|
1227
|
-
* URL-friendly slug for the view
|
|
1228
|
-
*
|
|
969
|
+
* URL-friendly slug for the view, used in Studio URLs like /studio/views/:slug. Absent, the
|
|
970
|
+
* platform derives one from the id when it reads the schema.
|
|
1229
971
|
*/
|
|
1230
972
|
slug?: string;
|
|
1231
973
|
/**
|
|
@@ -1282,12 +1024,40 @@ interface ViewDefinition extends ViewConfig {
|
|
|
1282
1024
|
* Unique view ID (must start with a letter)
|
|
1283
1025
|
*/
|
|
1284
1026
|
readonly id: string;
|
|
1285
|
-
/**
|
|
1286
|
-
* URL-friendly slug for the view
|
|
1287
|
-
* Auto-generated from id if not provided in config
|
|
1288
|
-
*/
|
|
1289
|
-
readonly slug: string;
|
|
1290
1027
|
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Define a schema view
|
|
1030
|
+
*
|
|
1031
|
+
* Views are pre-configured entry list displays with filters,
|
|
1032
|
+
* columns, and metadata settings.
|
|
1033
|
+
*
|
|
1034
|
+
* @example
|
|
1035
|
+
* const publishedPosts = defineView('publishedPosts', {
|
|
1036
|
+
* name: 'Published Posts',
|
|
1037
|
+
* description: 'All published blog posts',
|
|
1038
|
+
* icon: '📝',
|
|
1039
|
+
* scope: { type: 'contentType', contentType: 'post' },
|
|
1040
|
+
* filters: [
|
|
1041
|
+
* { field: 'status', operator: 'is', value: 'published' }
|
|
1042
|
+
* ],
|
|
1043
|
+
* columns: ['title', 'author', 'publishedAt'],
|
|
1044
|
+
* metadataFields: ['category', 'views'],
|
|
1045
|
+
* sort: { field: 'publishedAt', direction: 'desc' }
|
|
1046
|
+
* })
|
|
1047
|
+
*
|
|
1048
|
+
* @example
|
|
1049
|
+
* const draftContent = defineView('draftContent', {
|
|
1050
|
+
* name: 'Drafts',
|
|
1051
|
+
* scope: { type: 'all' },
|
|
1052
|
+
* filters: [
|
|
1053
|
+
* { field: 'status', operator: 'is', value: 'draft' }
|
|
1054
|
+
* ]
|
|
1055
|
+
* })
|
|
1056
|
+
*
|
|
1057
|
+
* @param id - Unique view ID (must start with a letter)
|
|
1058
|
+
* @param config - View configuration
|
|
1059
|
+
* @returns View definition object
|
|
1060
|
+
*/
|
|
1291
1061
|
declare function defineView(id: string, config: ViewConfig): ViewDefinition;
|
|
1292
1062
|
|
|
1293
1063
|
/**
|
|
@@ -1389,7 +1159,7 @@ interface TypedSchemaConfig<TContentTypes extends Record<string, ContentTypeDefi
|
|
|
1389
1159
|
* displayName: 'Product',
|
|
1390
1160
|
* fields: [
|
|
1391
1161
|
* fields.shortText('title', { config: { required: true }, localization: true }),
|
|
1392
|
-
* fields.
|
|
1162
|
+
* fields.decimal('price', { config: { min: 0, decimalPlaces: 2 } }),
|
|
1393
1163
|
* fields.component('seo', 'seo'),
|
|
1394
1164
|
* ]
|
|
1395
1165
|
* })
|
|
@@ -1410,6 +1180,18 @@ type AnySchemaDefinition = SchemaDefinition<any, any, any, any, any, any, any, a
|
|
|
1410
1180
|
* Get content type names from a schema
|
|
1411
1181
|
*/
|
|
1412
1182
|
type SchemaContentTypeNames<T extends AnySchemaDefinition> = keyof T['contentTypes'] & string;
|
|
1183
|
+
/**
|
|
1184
|
+
* An entry of content type `K`, typed by schema `T` as a read returns it — what `content(K)` reads,
|
|
1185
|
+
* with references and components resolved against `T` (`INV-SS-TYPES-INFERRED`).
|
|
1186
|
+
*/
|
|
1187
|
+
type SchemaEntry<T extends AnySchemaDefinition, K extends SchemaContentTypeNames<T>> = InferContentType<T['contentTypes'][K], T>;
|
|
1188
|
+
/**
|
|
1189
|
+
* An entry of any one of the content types `K` names — every content type by default — as a search
|
|
1190
|
+
* across them returns it: a union, so `_metadata.type` tells a caller which it holds.
|
|
1191
|
+
*/
|
|
1192
|
+
type SchemaEntryOf<T extends AnySchemaDefinition, K extends SchemaContentTypeNames<T> = SchemaContentTypeNames<T>> = {
|
|
1193
|
+
[N in K]: SchemaEntry<T, N>;
|
|
1194
|
+
}[K];
|
|
1413
1195
|
/**
|
|
1414
1196
|
* Get singleton names from a schema
|
|
1415
1197
|
*/
|
|
@@ -1435,4 +1217,4 @@ type SchemaAssetTypeNames<T extends AnySchemaDefinition> = NonNullable<T['assetT
|
|
|
1435
1217
|
*/
|
|
1436
1218
|
type SchemaLocaleCodes<T extends AnySchemaDefinition> = NonNullable<T['locales']> extends readonly LocaleDefinition[] ? NonNullable<T['locales']>[number]['code'] : never;
|
|
1437
1219
|
|
|
1438
|
-
export { type
|
|
1220
|
+
export { type ViewFilterCondition 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 ViewFilterValue as Z, type ViewFilterRelativeDate as _, type SchemaDefinition as a, type ViewFilterGroup as a0, type ViewFilter as a1, type ViewConfig as a2, type ViewDefinition as a3, defineQuery as a4, type QueryConfig as a5, type QueryDefinition as a6, type QueryType as a7, type FullTextSearch as a8, type FetchBlock as a9, type AggregateBlock as aa, type SearchBlock as ab, type WhereCondition as ac, type WhereValue as ad, type WhereOperator as ae, type HavingOperator as af, type QueryScalar as ag, type SortCondition as ah, type SortDirection as ai, type IncludeDefinition as aj, type IncludeRelationship as ak, type IncludeSelection as al, type SelectMapping as am, type FilterDefinition as an, type CachePolicy as ao, type CachePolicyObject as ap, type IncludeSubQuery as aq, type IncludeSubQueries as ar, type Parameterizable as as, type QueryParameter as at, type QueryParameterType as au, type QueryCardinality as av, type InferQueryResponse as aw, type InferQueryParams as ax, type FilterOperator as ay, 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 };
|