@relyio/sdk 0.10.0 → 0.12.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 +135 -0
- package/dist/chunk-3DRDHXLY.js +680 -0
- package/dist/{chunk-2HP566NI.cjs → chunk-3MSFWXQL.cjs} +37 -65
- package/dist/{chunk-DC4QLAI3.cjs → chunk-DXCVO6M5.cjs} +46 -59
- package/dist/chunk-FI5VIF4M.cjs +686 -0
- package/dist/{chunk-2L5JUW7O.js → chunk-FRJEUAAF.js} +46 -59
- package/dist/{chunk-IGHYC2WM.js → chunk-POEEDYFM.js} +38 -65
- package/dist/client/index.cjs +3 -3
- package/dist/client/index.d.cts +5 -4
- package/dist/client/index.d.ts +5 -4
- package/dist/client/index.js +1 -1
- package/dist/{define-schema-rbTrXxNN.d.ts → define-schema-DgctHlI2.d.cts} +50 -229
- package/dist/{define-schema-W-0u1Jg1.d.cts → define-schema-mrEZbY1h.d.ts} +50 -229
- package/dist/{define-content-type-DfnTu26S.d.cts → include-paths-CL4gHv6I.d.cts} +1691 -739
- package/dist/{define-content-type-DfnTu26S.d.ts → include-paths-CrJNTsMl.d.ts} +1691 -739
- package/dist/{index-B9hDmCho.d.ts → index-B9RfZVF1.d.ts} +3 -2
- package/dist/{index-KuYgc7eG.d.cts → index-BrvEg6-A.d.cts} +110 -49
- package/dist/{index-rLEBSFvK.d.ts → index-Pw0onkJe.d.ts} +110 -49
- package/dist/{index-NnLCwSqF.d.cts → index-b-AkfTUv.d.cts} +3 -2
- package/dist/index.cjs +102 -85
- package/dist/index.d.cts +14 -10
- package/dist/index.d.ts +14 -10
- package/dist/index.js +4 -3
- package/dist/rich-text/index.cjs +29 -0
- package/dist/rich-text/index.d.cts +148 -0
- package/dist/rich-text/index.d.ts +148 -0
- package/dist/rich-text/index.js +4 -0
- package/dist/rich-text.d-rKmpgdGd.d.cts +200 -0
- package/dist/rich-text.d-rKmpgdGd.d.ts +200 -0
- package/dist/schema/index.cjs +34 -38
- package/dist/schema/index.d.cts +86 -38
- package/dist/schema/index.d.ts +86 -38
- package/dist/schema/index.js +1 -1
- package/dist/types/index.d.cts +3 -2
- package/dist/types/index.d.ts +3 -2
- package/package.json +8 -2
- package/dist/.tsbuildinfo +0 -1
|
@@ -1,183 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Component definition matching @relyio/schema ComponentSchema
|
|
5
|
-
*
|
|
6
|
-
* Components are reusable field groups that can be embedded in content types.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
interface ComponentReusabilityMetadata {
|
|
10
|
-
/** Minimum number of usages to be considered reusable */
|
|
11
|
-
minUsageCount?: number;
|
|
12
|
-
/** Maximum complexity score */
|
|
13
|
-
maxComplexity?: number;
|
|
14
|
-
/** Recommended usage contexts */
|
|
15
|
-
recommendedUsage?: string[];
|
|
16
|
-
}
|
|
17
|
-
interface ComponentValidationMetadata {
|
|
18
|
-
/** Whether nesting of components is allowed */
|
|
19
|
-
allowNesting?: boolean;
|
|
20
|
-
/** Maximum nesting depth */
|
|
21
|
-
maxNestingDepth?: number;
|
|
22
|
-
/** How to resolve field ID conflicts */
|
|
23
|
-
conflictResolution?: 'error' | 'component-wins' | 'field-wins' | 'prefix';
|
|
24
|
-
}
|
|
25
|
-
interface ComponentMetadata {
|
|
26
|
-
reusability?: ComponentReusabilityMetadata;
|
|
27
|
-
validation?: ComponentValidationMetadata;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
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`).
|
|
32
|
-
*/
|
|
33
|
-
interface ComponentConfig<TFields extends readonly AnyFieldDefinition[] = FieldDefinition[]> {
|
|
34
|
-
/** Display name shown in the UI */
|
|
35
|
-
displayName?: string;
|
|
36
|
-
/** Description of the component */
|
|
37
|
-
description?: string;
|
|
38
|
-
/** AI configuration for content generation and review */
|
|
39
|
-
ai?: AIConfig;
|
|
40
|
-
/** Whether this component is deprecated */
|
|
41
|
-
deprecated?: boolean;
|
|
42
|
-
/** Component fields */
|
|
43
|
-
fields: TFields;
|
|
44
|
-
/** Component metadata for validation and reusability */
|
|
45
|
-
metadata?: ComponentMetadata;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Component definition - preserves field types for inference
|
|
49
|
-
*/
|
|
50
|
-
interface ComponentDefinition<TFields extends readonly AnyFieldDefinition[] = FieldDefinition[]> {
|
|
51
|
-
readonly _tag: 'component';
|
|
52
|
-
readonly name: string;
|
|
53
|
-
readonly displayName?: string;
|
|
54
|
-
readonly description?: string;
|
|
55
|
-
/** AI configuration for content generation and review */
|
|
56
|
-
readonly ai?: AIConfig;
|
|
57
|
-
readonly deprecated?: boolean;
|
|
58
|
-
readonly fields: TFields;
|
|
59
|
-
readonly metadata?: ComponentMetadata;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Define a reusable component (field group)
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* const seoComponent = defineComponent('seoMetadata', {
|
|
66
|
-
* displayName: 'SEO Metadata',
|
|
67
|
-
* description: 'Common SEO fields for all content types',
|
|
68
|
-
* fields: [
|
|
69
|
-
* fields.shortText('metaTitle', {
|
|
70
|
-
* config: { maxLength: 60 },
|
|
71
|
-
* ui: { displayName: 'Meta Title' }
|
|
72
|
-
* }),
|
|
73
|
-
* fields.longText('metaDescription', {
|
|
74
|
-
* config: { maxLength: 160 },
|
|
75
|
-
* ui: { displayName: 'Meta Description' }
|
|
76
|
-
* }),
|
|
77
|
-
* // An image is an entry of an asset type, which a reference points at
|
|
78
|
-
* fields.reference('ogImage', {
|
|
79
|
-
* config: { to: 'productPhoto' },
|
|
80
|
-
* ui: { displayName: 'Open Graph Image' }
|
|
81
|
-
* }),
|
|
82
|
-
* ]
|
|
83
|
-
* })
|
|
84
|
-
*
|
|
85
|
-
* // Use in a content type:
|
|
86
|
-
* const product = defineContentType('product', {
|
|
87
|
-
* displayName: 'Product',
|
|
88
|
-
* fields: [
|
|
89
|
-
* fields.shortText('title', { config: { required: true } }),
|
|
90
|
-
* fields.component('seo', 'seoMetadata'), // Reference the component
|
|
91
|
-
* ]
|
|
92
|
-
* })
|
|
93
|
-
*/
|
|
94
|
-
declare function defineComponent<TFields extends readonly AnyFieldDefinition[]>(name: string, config: ComponentConfig<TFields>): ComponentDefinition<TFields>;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Settings group definition matching @relyio/schema SettingsGroupSchema
|
|
98
|
-
*
|
|
99
|
-
* Settings groups are for project-level configuration that doesn't fit
|
|
100
|
-
* into content types (e.g., API keys, feature flags, integrations).
|
|
101
|
-
*
|
|
102
|
-
* Uses advanced TypeScript generics to preserve literal field IDs through
|
|
103
|
-
* the type system, enabling full autocomplete in SDK methods.
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Settings group configuration - generic to preserve field types
|
|
108
|
-
*/
|
|
109
|
-
interface SettingsGroupConfig<TFields extends readonly AnyFieldDefinition[] = readonly AnyFieldDefinition[]> {
|
|
110
|
-
/** Display name shown in the UI */
|
|
111
|
-
displayName: string;
|
|
112
|
-
/** Description of the settings group */
|
|
113
|
-
description?: string;
|
|
114
|
-
/** AI configuration for content generation and review */
|
|
115
|
-
ai?: AIConfig;
|
|
116
|
-
/** Access tags for role-based access control */
|
|
117
|
-
accessTags?: string[];
|
|
118
|
-
/** Settings fields - preserves literal types */
|
|
119
|
-
fields: TFields;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Settings group definition - preserves field types for inference
|
|
123
|
-
*/
|
|
124
|
-
interface SettingsGroupDefinition<TFields extends readonly AnyFieldDefinition[] = readonly AnyFieldDefinition[]> {
|
|
125
|
-
readonly _tag: 'settingsGroup';
|
|
126
|
-
readonly name: string;
|
|
127
|
-
readonly displayName: string;
|
|
128
|
-
readonly description?: string;
|
|
129
|
-
/** AI configuration for content generation and review */
|
|
130
|
-
readonly ai?: AIConfig;
|
|
131
|
-
readonly accessTags?: string[];
|
|
132
|
-
readonly fields: TFields;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Define a settings group
|
|
136
|
-
*
|
|
137
|
-
* The generic type parameter preserves the literal field IDs through the type
|
|
138
|
-
* system, enabling autocomplete in SDK methods.
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* const integrations = defineSettingsGroup('integrations', {
|
|
142
|
-
* displayName: 'Integrations',
|
|
143
|
-
* description: 'Third-party service integrations',
|
|
144
|
-
* fields: [
|
|
145
|
-
* fields.shortText('stripeApiKey', {
|
|
146
|
-
* config: { required: true },
|
|
147
|
-
* ui: { displayName: 'Stripe API Key' }
|
|
148
|
-
* }),
|
|
149
|
-
* fields.shortText('sendgridApiKey', {
|
|
150
|
-
* ui: { displayName: 'SendGrid API Key' }
|
|
151
|
-
* }),
|
|
152
|
-
* fields.boolean('enableAnalytics', {
|
|
153
|
-
* config: { defaultValue: true },
|
|
154
|
-
* ui: { displayName: 'Enable Analytics' }
|
|
155
|
-
* }),
|
|
156
|
-
* ]
|
|
157
|
-
* })
|
|
158
|
-
*/
|
|
159
|
-
declare function defineSettingsGroup<TFields extends readonly AnyFieldDefinition[]>(name: string, config: SettingsGroupConfig<TFields>): SettingsGroupDefinition<TFields>;
|
|
160
|
-
/**
|
|
161
|
-
* Type alias for any settings group definition.
|
|
162
|
-
*/
|
|
163
|
-
type AnySettingsGroupDefinition = SettingsGroupDefinition<any>;
|
|
164
|
-
/**
|
|
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.
|
|
167
|
-
*
|
|
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.
|
|
172
|
-
*/
|
|
173
|
-
type SettingsGroupMetadata = components['schemas']['SettingsGroupMetadata'];
|
|
174
|
-
/**
|
|
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`.
|
|
177
|
-
*/
|
|
178
|
-
type InferSettingsGroup<T extends AnySettingsGroupDefinition, S extends FieldSchemaContext | undefined = undefined> = FieldValues<DeclaredFields<T>, S> & {
|
|
179
|
-
_metadata: SettingsGroupMetadata;
|
|
180
|
-
};
|
|
1
|
+
import { a4 as ContentTypeDefinition, ab as SingletonContentTypeDefinition, ah as SettingsGroupDefinition, aU as WorkflowDefinition, am as AssetTypeDefinition, a6 as InferContentType } from './include-paths-CL4gHv6I.cjs';
|
|
181
2
|
|
|
182
3
|
/**
|
|
183
4
|
* Query definition matching @relyio/schema QueryDefinitionSchema
|
|
@@ -255,7 +76,12 @@ type WhereValue = string | number | boolean | (string | number | boolean)[] | Wh
|
|
|
255
76
|
type WhereCondition = Record<string, WhereValue>;
|
|
256
77
|
type SortDirection = 'asc' | 'desc';
|
|
257
78
|
type SortCondition = Record<string, SortDirection> | Record<string, SortDirection>[];
|
|
258
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* A relationship joined by name — a reference the fetched type declares, or a reverse one another
|
|
81
|
+
* type declares to it (`reviews`) — optionally filtered, counted and aliased:
|
|
82
|
+
* `{ relationship: 'products', where: { status: 'active' }, aggregate: 'count', alias: 'productCount' }`.
|
|
83
|
+
* `relationship` is a name, with no parentheses. A `select` reads what it joins.
|
|
84
|
+
*/
|
|
259
85
|
type IncludeRelationship = {
|
|
260
86
|
relationship: string;
|
|
261
87
|
where?: WhereCondition;
|
|
@@ -269,23 +95,14 @@ type IncludeRelationship = {
|
|
|
269
95
|
alias?: string;
|
|
270
96
|
};
|
|
271
97
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
fields?: string[];
|
|
281
|
-
include?: (string | {
|
|
282
|
-
path: string;
|
|
283
|
-
fields?: string[];
|
|
284
|
-
where?: WhereCondition;
|
|
285
|
-
})[];
|
|
286
|
-
where?: WhereCondition;
|
|
287
|
-
};
|
|
288
|
-
type IncludeDefinition = string | string[] | (string | IncludeRelationship | IncludeSelection)[];
|
|
98
|
+
* What a fetch includes (REL-2035). A string is an **include path**, the grammar `?include=` and the
|
|
99
|
+
* SDK's `include()` read: field ids joined by `.`, crossing lists, page builders, objects and
|
|
100
|
+
* references, each hop written out, with the fields to return in parentheses —
|
|
101
|
+
* `'sections.customers.logo'`, `'sections.features(name,slug)'`. The query returns what
|
|
102
|
+
* `GET …?include=` returns for the same paths. A path's entries are expanded after the read, so a
|
|
103
|
+
* `select` cannot read them: join a relationship for that ({@link IncludeRelationship}).
|
|
104
|
+
*/
|
|
105
|
+
type IncludeDefinition = string | (string | IncludeRelationship)[];
|
|
289
106
|
type SelectMapping = Record<string, string>;
|
|
290
107
|
/** `filters` are `where` conditions bound at call time: the same operators, written the same way. */
|
|
291
108
|
type FilterOperator = WhereOperator;
|
|
@@ -928,7 +745,11 @@ type ViewFilterValue = string | number | boolean | null | (string | number)[] |
|
|
|
928
745
|
*/
|
|
929
746
|
interface ViewFilterCondition {
|
|
930
747
|
/**
|
|
931
|
-
*
|
|
748
|
+
* The Property to filter on, as the Studio's entry list names it: `fields.<id>` for a field your
|
|
749
|
+
* schema declares (`fields.seo.title` for a field of an object's value), `_metadata.<id>` for a system
|
|
750
|
+
* field — `_metadata.status`, `_metadata.createdAt`, `_metadata.updatedAt`. So a field called
|
|
751
|
+
* `status` (`fields.status`) and the entry's own lifecycle (`_metadata.status`) are both
|
|
752
|
+
* filterable.
|
|
932
753
|
*/
|
|
933
754
|
field: string;
|
|
934
755
|
/**
|
|
@@ -994,7 +815,9 @@ interface ViewConfig {
|
|
|
994
815
|
*/
|
|
995
816
|
metadataFields?: string[];
|
|
996
817
|
/**
|
|
997
|
-
* Default sort
|
|
818
|
+
* Default sort (optional). `field` names the Property to sort by, as a filter names one —
|
|
819
|
+
* `fields.<id>` or `_metadata.<id>` — and deploy refuses one the view's entries cannot be sorted
|
|
820
|
+
* by. `columns` and `metadataFields` are display settings and name field IDs as written.
|
|
998
821
|
*/
|
|
999
822
|
sort?: {
|
|
1000
823
|
field: string;
|
|
@@ -1025,25 +848,25 @@ interface ViewDefinition extends ViewConfig {
|
|
|
1025
848
|
* columns, and metadata settings.
|
|
1026
849
|
*
|
|
1027
850
|
* @example
|
|
1028
|
-
* const
|
|
1029
|
-
* name: '
|
|
1030
|
-
* description: '
|
|
851
|
+
* const featuredPosts = defineView('featuredPosts', {
|
|
852
|
+
* name: 'Featured Posts',
|
|
853
|
+
* description: 'Blog posts marked as featured',
|
|
1031
854
|
* icon: '📝',
|
|
1032
855
|
* scope: { type: 'contentType', contentType: 'post' },
|
|
1033
856
|
* filters: [
|
|
1034
|
-
* { field: '
|
|
857
|
+
* { field: 'fields.featured', operator: 'is', value: true }
|
|
1035
858
|
* ],
|
|
1036
859
|
* columns: ['title', 'author', 'publishedAt'],
|
|
1037
860
|
* metadataFields: ['category', 'views'],
|
|
1038
|
-
* sort: { field: 'publishedAt', direction: 'desc' }
|
|
861
|
+
* sort: { field: '_metadata.publishedAt', direction: 'desc' }
|
|
1039
862
|
* })
|
|
1040
863
|
*
|
|
1041
864
|
* @example
|
|
1042
|
-
* const
|
|
1043
|
-
* name: '
|
|
865
|
+
* const archivedContent = defineView('archivedContent', {
|
|
866
|
+
* name: 'Archived',
|
|
1044
867
|
* scope: { type: 'all' },
|
|
1045
868
|
* filters: [
|
|
1046
|
-
* { field: 'status', operator: 'is', value: '
|
|
869
|
+
* { field: '_metadata.status', operator: 'is', value: 'archived' }
|
|
1047
870
|
* ]
|
|
1048
871
|
* })
|
|
1049
872
|
*
|
|
@@ -1065,7 +888,6 @@ declare function defineView(id: string, config: ViewConfig): ViewDefinition;
|
|
|
1065
888
|
* Matches the SchemaDefinitionSchema from @relyio/schema:
|
|
1066
889
|
* - locales: Optional array of locale definitions for multi-language support
|
|
1067
890
|
* - contentTypes: Required record of content type definitions
|
|
1068
|
-
* - components: Required record of component definitions (can be empty {})
|
|
1069
891
|
* - singletonContentTypes: Required record of singleton definitions (can be empty {})
|
|
1070
892
|
* - queries: Required record of query definitions (can be empty {})
|
|
1071
893
|
* - settingsGroups: Optional record of settings groups
|
|
@@ -1079,8 +901,6 @@ interface SchemaConfig {
|
|
|
1079
901
|
locales?: LocaleDefinition[];
|
|
1080
902
|
/** Content type definitions (required) */
|
|
1081
903
|
contentTypes: Record<string, ContentTypeDefinition>;
|
|
1082
|
-
/** Reusable component definitions (required, can be empty) */
|
|
1083
|
-
components?: Record<string, ComponentDefinition>;
|
|
1084
904
|
/** Singleton content type definitions (required, can be empty) */
|
|
1085
905
|
singletonContentTypes?: Record<string, SingletonContentTypeDefinition>;
|
|
1086
906
|
/** Predefined query definitions (required, can be empty) */
|
|
@@ -1099,11 +919,10 @@ interface SchemaConfig {
|
|
|
1099
919
|
/**
|
|
1100
920
|
* Complete schema definition - Generic version for type inference
|
|
1101
921
|
*/
|
|
1102
|
-
interface SchemaDefinition<TContentTypes extends Record<string, ContentTypeDefinition> = Record<string, ContentTypeDefinition>,
|
|
922
|
+
interface SchemaDefinition<TContentTypes extends Record<string, ContentTypeDefinition> = Record<string, ContentTypeDefinition>, TSingletons extends Record<string, SingletonContentTypeDefinition> = Record<string, SingletonContentTypeDefinition>, TQueries extends Record<string, QueryDefinition> = Record<string, QueryDefinition>, TSettings extends Record<string, SettingsGroupDefinition> = Record<string, SettingsGroupDefinition>, TLocales extends readonly LocaleDefinition[] = readonly LocaleDefinition[], TRoles extends readonly RoleDefinition[] = readonly RoleDefinition[], TWorkflow extends WorkflowDefinition | undefined = WorkflowDefinition | undefined, TViews extends readonly ViewDefinition[] = readonly ViewDefinition[], TAssets extends Record<string, AssetTypeDefinition> = Record<string, AssetTypeDefinition>> {
|
|
1103
923
|
readonly _tag: 'schema';
|
|
1104
924
|
readonly locales?: TLocales;
|
|
1105
925
|
readonly contentTypes: TContentTypes;
|
|
1106
|
-
readonly components: TComponents;
|
|
1107
926
|
readonly singletonContentTypes: TSingletons;
|
|
1108
927
|
readonly queries: TQueries;
|
|
1109
928
|
readonly settingsGroups?: TSettings;
|
|
@@ -1115,10 +934,9 @@ interface SchemaDefinition<TContentTypes extends Record<string, ContentTypeDefin
|
|
|
1115
934
|
/**
|
|
1116
935
|
* Typed schema config for type inference
|
|
1117
936
|
*/
|
|
1118
|
-
interface TypedSchemaConfig<TContentTypes extends Record<string, ContentTypeDefinition>,
|
|
937
|
+
interface TypedSchemaConfig<TContentTypes extends Record<string, ContentTypeDefinition>, TSingletons extends Record<string, SingletonContentTypeDefinition>, TQueries extends Record<string, QueryDefinition>, TSettings extends Record<string, SettingsGroupDefinition>, TLocales extends readonly LocaleDefinition[] = readonly LocaleDefinition[], TRoles extends readonly RoleDefinition[] = readonly RoleDefinition[], TWorkflow extends WorkflowDefinition | undefined = WorkflowDefinition | undefined, TViews extends readonly ViewDefinition[] = readonly ViewDefinition[], TAssets extends Record<string, AssetTypeDefinition> = Record<string, AssetTypeDefinition>> {
|
|
1119
938
|
locales?: TLocales;
|
|
1120
939
|
contentTypes: TContentTypes;
|
|
1121
|
-
components?: TComponents;
|
|
1122
940
|
singletonContentTypes?: TSingletons;
|
|
1123
941
|
queries?: TQueries;
|
|
1124
942
|
settingsGroups?: TSettings;
|
|
@@ -1135,35 +953,38 @@ interface TypedSchemaConfig<TContentTypes extends Record<string, ContentTypeDefi
|
|
|
1135
953
|
* 2. Used for type inference in the SDK client
|
|
1136
954
|
*
|
|
1137
955
|
* @example
|
|
1138
|
-
* import { defineSchema, defineContentType,
|
|
956
|
+
* import { defineSchema, defineContentType, defineLocale, fields } from '@relyio/sdk/schema'
|
|
1139
957
|
*
|
|
1140
958
|
* const enUS = defineLocale('en-US', { displayName: 'English (US)', default: true })
|
|
1141
959
|
* const esES = defineLocale('es-ES', { displayName: 'Spanish', fallback: ['en-US'] })
|
|
1142
960
|
*
|
|
1143
|
-
* const seoComponent = defineComponent('seo', {
|
|
1144
|
-
* displayName: 'SEO Metadata',
|
|
1145
|
-
* fields: [
|
|
1146
|
-
* fields.shortText('metaTitle', { config: { maxLength: 60 } }),
|
|
1147
|
-
* fields.longText('metaDescription', { config: { maxLength: 160 } }),
|
|
1148
|
-
* ]
|
|
1149
|
-
* })
|
|
1150
|
-
*
|
|
1151
961
|
* const product = defineContentType('product', {
|
|
1152
962
|
* displayName: 'Product',
|
|
1153
963
|
* fields: [
|
|
1154
964
|
* fields.shortText('title', { config: { required: true }, localization: true }),
|
|
1155
965
|
* fields.decimal('price', { config: { min: 0, decimalPlaces: 2 } }),
|
|
1156
|
-
*
|
|
966
|
+
* // One value of a fieldset: `{ _type: 'seo', _key, metaTitle?, metaDescription? }`
|
|
967
|
+
* fields.object('seo', {
|
|
968
|
+
* config: {
|
|
969
|
+
* of: {
|
|
970
|
+
* id: 'seo',
|
|
971
|
+
* displayName: 'SEO Metadata',
|
|
972
|
+
* fields: [
|
|
973
|
+
* fields.shortText('metaTitle', { config: { maxLength: 60 } }),
|
|
974
|
+
* fields.longText('metaDescription', { config: { maxLength: 160 } }),
|
|
975
|
+
* ],
|
|
976
|
+
* },
|
|
977
|
+
* },
|
|
978
|
+
* }),
|
|
1157
979
|
* ]
|
|
1158
980
|
* })
|
|
1159
981
|
*
|
|
1160
982
|
* export const schema = defineSchema({
|
|
1161
983
|
* locales: [enUS, esES],
|
|
1162
984
|
* contentTypes: { product },
|
|
1163
|
-
* components: { seo: seoComponent },
|
|
1164
985
|
* })
|
|
1165
986
|
*/
|
|
1166
|
-
declare function defineSchema<TContentTypes extends Record<string, ContentTypeDefinition>,
|
|
987
|
+
declare function defineSchema<TContentTypes extends Record<string, ContentTypeDefinition>, TSingletons extends Record<string, SingletonContentTypeDefinition> = Record<string, never>, TQueries extends Record<string, QueryDefinition> = Record<string, never>, TSettings extends Record<string, SettingsGroupDefinition> = Record<string, never>, TLocales extends readonly LocaleDefinition[] = readonly LocaleDefinition[], TRoles extends readonly RoleDefinition[] = readonly RoleDefinition[], TWorkflow extends WorkflowDefinition | undefined = WorkflowDefinition | undefined, TViews extends readonly ViewDefinition[] = readonly ViewDefinition[], TAssets extends Record<string, AssetTypeDefinition> = Record<string, never>>(config: TypedSchemaConfig<TContentTypes, TSingletons, TQueries, TSettings, TLocales, TRoles, TWorkflow, TViews, TAssets>): SchemaDefinition<TContentTypes, TSingletons, TQueries, TSettings, TLocales, TRoles, TWorkflow, TViews, TAssets>;
|
|
1167
988
|
/**
|
|
1168
989
|
* Type alias for any schema definition.
|
|
1169
990
|
* Uses `any` intentionally for type inference utilities that need to accept any schema.
|
|
@@ -1175,7 +996,7 @@ type AnySchemaDefinition = SchemaDefinition<any, any, any, any, any, any, any, a
|
|
|
1175
996
|
type SchemaContentTypeNames<T extends AnySchemaDefinition> = keyof T['contentTypes'] & string;
|
|
1176
997
|
/**
|
|
1177
998
|
* An entry of content type `K`, typed by schema `T` as a read returns it — what `content(K)` reads,
|
|
1178
|
-
* with references
|
|
999
|
+
* with references resolved against `T` (`INV-SS-TYPES-INFERRED`).
|
|
1179
1000
|
*/
|
|
1180
1001
|
type SchemaEntry<T extends AnySchemaDefinition, K extends SchemaContentTypeNames<T>> = InferContentType<T['contentTypes'][K], T>;
|
|
1181
1002
|
/**
|
|
@@ -1210,4 +1031,4 @@ type SchemaAssetTypeNames<T extends AnySchemaDefinition> = NonNullable<T['assetT
|
|
|
1210
1031
|
*/
|
|
1211
1032
|
type SchemaLocaleCodes<T extends AnySchemaDefinition> = NonNullable<T['locales']> extends readonly LocaleDefinition[] ? NonNullable<T['locales']>[number]['code'] : never;
|
|
1212
1033
|
|
|
1213
|
-
export { type
|
|
1034
|
+
export { type SearchBlock as $, type RoleDefinition as A, BUILT_IN_ROLES as B, defineView as C, type ContentTypeScopeConfig as D, type ContentTypesScopeConfig as E, type FieldVisibility as F, type EntryTypeScopeConfig as G, type AllScopeConfig as H, type ViewFilterOperator as I, type ViewFilterValue as J, type ViewFilterRelativeDate as K, type LocaleOptions as L, type ViewFilterCondition as M, type ViewFilter as N, type ViewConfig as O, type ViewDefinition as P, defineQuery as Q, ROLE_ACTIONS as R, type SchemaConfig as S, type TextDirection as T, type QueryConfig as U, type ViewScopeConfig as V, type QueryDefinition as W, type QueryType as X, type FullTextSearch as Y, type FetchBlock as Z, type AggregateBlock as _, type SchemaDefinition as a, type WhereCondition as a0, type WhereValue as a1, type WhereOperator as a2, type HavingOperator as a3, type QueryScalar as a4, type SortCondition as a5, type SortDirection as a6, type IncludeDefinition as a7, type IncludeRelationship as a8, type SelectMapping as a9, type FilterDefinition as aa, type CachePolicy as ab, type CachePolicyObject as ac, type IncludeSubQuery as ad, type IncludeSubQueries as ae, type Parameterizable as af, type QueryParameter as ag, type QueryParameterType as ah, type QueryCardinality as ai, type InferQueryResponse as aj, type InferQueryParams as ak, type FilterOperator as al, 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, defineRole as r, isRoleDefinition as s, isBuiltInRole as t, getBuiltInRoleActions as u, BUILT_IN_ROLE_ACTIONS as v, type BuiltInRole as w, type RoleAction as x, type ResourcePermission as y, type RoleConfig as z };
|