@stackbit/cms-core 0.0.18-alpha.0 → 0.0.19

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.
Files changed (59) hide show
  1. package/dist/annotator/html.d.ts +0 -1
  2. package/dist/annotator/index.d.ts +2 -3
  3. package/dist/annotator/react.d.ts +0 -1
  4. package/dist/common/common-schema.d.ts +10 -3
  5. package/dist/common/common-schema.js +4 -3
  6. package/dist/common/common-schema.js.map +1 -1
  7. package/dist/consts.d.ts +0 -1
  8. package/dist/encoder.d.ts +7 -36
  9. package/dist/encoder.js +40 -63
  10. package/dist/encoder.js.map +1 -1
  11. package/dist/index.d.ts +6 -11
  12. package/dist/index.js +11 -37
  13. package/dist/index.js.map +1 -1
  14. package/dist/stackbit/index.d.ts +3 -7
  15. package/dist/stackbit/index.js +10 -13
  16. package/dist/stackbit/index.js.map +1 -1
  17. package/dist/utils/index.d.ts +7 -8
  18. package/dist/utils/lazy-poller.d.ts +21 -0
  19. package/dist/utils/lazy-poller.js +56 -0
  20. package/dist/utils/lazy-poller.js.map +1 -0
  21. package/dist/utils/schema-utils.d.ts +2 -3
  22. package/package.json +4 -8
  23. package/src/common/common-schema.js +14 -0
  24. package/src/{encoder.ts → encoder.js} +17 -55
  25. package/src/index.js +13 -0
  26. package/src/stackbit/{index.ts → index.js} +9 -5
  27. package/src/utils/lazy-poller.ts +74 -0
  28. package/dist/annotator/html.d.ts.map +0 -1
  29. package/dist/annotator/index.d.ts.map +0 -1
  30. package/dist/annotator/react.d.ts.map +0 -1
  31. package/dist/common/common-schema.d.ts.map +0 -1
  32. package/dist/consts.d.ts.map +0 -1
  33. package/dist/content-source-interface.d.ts +0 -292
  34. package/dist/content-source-interface.d.ts.map +0 -1
  35. package/dist/content-source-interface.js +0 -28
  36. package/dist/content-source-interface.js.map +0 -1
  37. package/dist/content-store-types.d.ts +0 -324
  38. package/dist/content-store-types.d.ts.map +0 -1
  39. package/dist/content-store-types.js +0 -3
  40. package/dist/content-store-types.js.map +0 -1
  41. package/dist/content-store.d.ts +0 -207
  42. package/dist/content-store.d.ts.map +0 -1
  43. package/dist/content-store.js +0 -1643
  44. package/dist/content-store.js.map +0 -1
  45. package/dist/encoder.d.ts.map +0 -1
  46. package/dist/index.d.ts.map +0 -1
  47. package/dist/stackbit/index.d.ts.map +0 -1
  48. package/dist/utils/index.d.ts.map +0 -1
  49. package/dist/utils/schema-utils.d.ts.map +0 -1
  50. package/dist/utils/timer.d.ts +0 -18
  51. package/dist/utils/timer.d.ts.map +0 -1
  52. package/dist/utils/timer.js +0 -36
  53. package/dist/utils/timer.js.map +0 -1
  54. package/src/common/common-schema.ts +0 -12
  55. package/src/content-source-interface.ts +0 -417
  56. package/src/content-store-types.ts +0 -406
  57. package/src/content-store.ts +0 -2112
  58. package/src/index.ts +0 -10
  59. package/src/utils/timer.ts +0 -42
@@ -1,406 +0,0 @@
1
- import { DocumentStatus, FieldType } from './content-source-interface';
2
-
3
- export { FieldType, Logger, LeveledLogMethod, DocumentStatus } from './content-source-interface';
4
-
5
- export interface Document {
6
- type: 'document';
7
- srcType: string;
8
- srcProjectId: string;
9
- srcProjectUrl: string;
10
- srcEnvironment: string;
11
- srcObjectId: string;
12
- srcObjectUrl: string;
13
- srcObjectLabel: string;
14
- srcModelName: string;
15
- srcModelLabel: string;
16
- isChanged: boolean;
17
- status: DocumentStatus;
18
- createdAt: string;
19
- createdBy?: string;
20
- updatedAt: string;
21
- updatedBy?: string[];
22
- fields: Record<string, DocumentField>;
23
- }
24
-
25
- export interface Asset {
26
- type: 'asset';
27
- srcType: string;
28
- srcProjectId: string;
29
- srcProjectUrl: string;
30
- srcEnvironment: string;
31
- srcObjectId: string;
32
- srcObjectUrl: string;
33
- srcObjectLabel: string;
34
- srcModelName: string;
35
- srcModelLabel: string;
36
- isChanged: boolean;
37
- status: DocumentStatus;
38
- createdAt: string;
39
- createdBy?: string;
40
- updatedAt: string;
41
- updatedBy?: string[];
42
- fields: AssetFields;
43
- }
44
-
45
- export type AssetFields = {
46
- title: DocumentValueFieldForType<'string'>;
47
- file: AssetFileField;
48
- };
49
-
50
- export interface UploadAssetData {
51
- url: string;
52
- data?: string;
53
- metadata: {
54
- name: string;
55
- type: string;
56
- };
57
- }
58
-
59
- export interface ContentChangeResultItem {
60
- srcType: string;
61
- srcProjectId: string;
62
- srcObjectId: string;
63
- }
64
-
65
- export interface ContentChangeResult {
66
- updatedDocuments: ContentChangeResultItem[];
67
- updatedAssets: ContentChangeResultItem[];
68
- deletedDocuments: ContentChangeResultItem[];
69
- deletedAssets: ContentChangeResultItem[];
70
- }
71
-
72
- export type APIObject = APIDocumentObject | APIImageObject;
73
-
74
- export interface APIDocumentObject extends Omit<Document, 'fields' | 'type'> {
75
- type: 'object';
76
- fields: Record<string, DocumentFieldAPI>;
77
- }
78
-
79
- export interface APIImageObject extends Omit<Asset, 'fields' | 'type'> {
80
- type: 'image';
81
- fields: AssetFieldsAPI;
82
- }
83
-
84
- export type AssetFieldsAPI = {
85
- title: DocumentFieldAPIForType<'string'>;
86
- url: DocumentFieldAPIForType<'string'>;
87
- };
88
-
89
- export interface APIAsset {
90
- objectId: string;
91
- createdAt: string;
92
- url: string;
93
- title?: string;
94
- fileName?: string;
95
- contentType?: string;
96
- size?: number;
97
- width?: number;
98
- height?: number;
99
- }
100
-
101
- export type DocumentField =
102
- | DocumentValueField
103
- | DocumentObjectField
104
- | DocumentModelField
105
- | DocumentReferenceField
106
- | DocumentListField
107
- | DocumentMarkdownField
108
- | DocumentRichTextField;
109
-
110
- export type DocumentFieldLocalized =
111
- | DocumentValueFieldLocalized
112
- | DocumentObjectFieldLocalized
113
- | DocumentModelFieldLocalized
114
- | DocumentReferenceFieldLocalized
115
- | DocumentMarkdownFieldLocalized
116
- | DocumentRichTextFieldLocalized
117
- | DocumentListFieldLocalized;
118
-
119
- export type DocumentFieldNonLocalized =
120
- | DocumentValueFieldNonLocalized
121
- | DocumentObjectFieldNonLocalized
122
- | DocumentModelFieldNonLocalized
123
- | DocumentReferenceFieldNonLocalized
124
- | DocumentMarkdownFieldNonLocalized
125
- | DocumentRichTextFieldNonLocalized
126
- | DocumentListFieldNonLocalized;
127
-
128
- export type DocumentFieldAPI =
129
- | DocumentValueFieldAPI
130
- | DocumentObjectFieldAPI
131
- | DocumentModelFieldAPI
132
- | DocumentReferenceFieldAPI
133
- | DocumentMarkdownFieldAPI
134
- | DocumentRichTextFieldAPI
135
- | DocumentListFieldAPI;
136
-
137
- export type DocumentFieldBaseProps =
138
- | DocumentValueFieldBaseProps
139
- | DocumentObjectFieldBase
140
- | DocumentModelFieldBase
141
- | DocumentReferenceFieldBase
142
- | DocumentListFieldBase
143
- | DocumentRichTextFieldBase;
144
-
145
- export type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
146
-
147
- export type Simplify<T> = {
148
- [K in keyof T]: T[K];
149
- };
150
-
151
- export type FindByType<Union extends { type: FieldType | 'unresolved_reference' }, Type> = Union extends { type: Type } ? Union : never;
152
- export type DocumentFieldForType<Type extends FieldType> = FindByType<DocumentField, Type>;
153
- export type DocumentFieldLocalizedForType<Type extends FieldType> = FindByType<DocumentFieldLocalized, Type>;
154
- export type DocumentFieldNonLocalizedForType<Type extends FieldType> = FindByType<DocumentFieldNonLocalized, Type>;
155
- export type DocumentFieldAPIForType<Type extends FieldType | 'unresolved_reference'> = FindByType<DocumentFieldAPI, Type>;
156
- export type DocumentFieldBasePropsForType<Type extends FieldType> = FindByType<DocumentFieldBaseProps, Type>;
157
- export type DocumentFieldSpecificPropsForType<Type extends FieldType> = Simplify<
158
- DistributiveOmit<DocumentFieldNonLocalizedForType<Type>, keyof DocumentFieldBasePropsForType<Type> | 'label' | 'locale' | 'localized'>
159
- >;
160
-
161
- // helpers
162
- export type DocumentFieldTypeLocalized<BaseFieldProps, LocalizedFieldProps> = Simplify<
163
- BaseFieldProps & {
164
- label?: string;
165
- localized: true;
166
- locales: Record<string, { locale: string } & Omit<LocalizedFieldProps, 'isUnset'>>;
167
- }
168
- >;
169
-
170
- export type DocumentFieldTypeNonLocalized<BaseFieldProps, LocalizedFieldProps> = Simplify<
171
- BaseFieldProps &
172
- LocalizedFieldProps & {
173
- label?: string;
174
- localized?: false;
175
- locale?: string;
176
- }
177
- >;
178
-
179
- export type DocumentFieldTypeAPI<BaseFieldProps, LocalizedFieldProps> = BaseFieldProps &
180
- LocalizedFieldProps & {
181
- label?: string;
182
- description?: string;
183
- locale?: string;
184
- localized?: boolean;
185
- };
186
-
187
- // any field that is not 'object' | 'model' | 'reference' | 'richText' | 'markdown' | 'list'
188
- export type DocumentValueFieldType = Exclude<FieldType, 'object' | 'model' | 'reference' | 'markdown' | 'richText' | 'list'>;
189
-
190
- export type DocumentValueFieldForType<Type> = Type extends DocumentValueFieldType
191
- ? DocumentValueFieldLocalizedForType<Type> | DocumentValueFieldNonLocalizedForType<Type>
192
- : never;
193
- export type DocumentValueField = DocumentValueFieldForType<DocumentValueFieldType>;
194
-
195
- export type DocumentValueFieldLocalizedForType<Type> = Type extends DocumentValueFieldType
196
- ? DocumentFieldTypeLocalized<DocumentValueFieldBase<Type>, DocumentValueFieldProps>
197
- : never;
198
- export type DocumentValueFieldLocalized = DocumentValueFieldLocalizedForType<DocumentValueFieldType>;
199
-
200
- export type DocumentValueFieldNonLocalizedForType<Type> = Type extends DocumentValueFieldType
201
- ? DocumentFieldTypeNonLocalized<DocumentValueFieldBase<Type>, DocumentValueFieldProps>
202
- : never;
203
- export type DocumentValueFieldNonLocalized = DocumentValueFieldNonLocalizedForType<DocumentValueFieldType>;
204
-
205
- export type DocumentValueFieldAPIForType<Type> = Type extends DocumentValueFieldType
206
- ? DocumentFieldTypeAPI<DocumentValueFieldBase<Type>, DocumentValueFieldProps>
207
- : never;
208
- export type DocumentValueFieldAPI = DocumentValueFieldAPIForType<DocumentValueFieldType>;
209
-
210
- export type DocumentValueFieldBasePropsForType<Type> = Type extends DocumentValueFieldType ? DocumentValueFieldBase<Type> : never;
211
- export type DocumentValueFieldBaseProps = DocumentValueFieldBasePropsForType<DocumentValueFieldType>;
212
- export type DocumentValueFieldBase<Type extends DocumentValueFieldType> = {
213
- type: Type;
214
- };
215
- export type DocumentValueFieldProps = {
216
- value: any;
217
- };
218
-
219
- // object
220
- export type DocumentObjectField = DocumentObjectFieldLocalized | DocumentObjectFieldNonLocalized;
221
- export type DocumentObjectFieldLocalized = DocumentFieldTypeLocalized<DocumentObjectFieldBase, DocumentObjectFieldProps>;
222
- export type DocumentObjectFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentObjectFieldBase, DocumentObjectFieldProps>;
223
- export type DocumentObjectFieldAPI = DocumentFieldTypeAPI<DocumentObjectFieldBase, DocumentObjectFieldPropsAPI>;
224
- export type DocumentObjectFieldBase = { type: 'object' };
225
- export type DocumentObjectFieldPropsCommon = {
226
- srcObjectLabel: string;
227
- };
228
- export type DocumentObjectFieldProps = { isUnset: true } | ({ isUnset?: false; fields: Record<string, DocumentField> } & DocumentObjectFieldPropsCommon);
229
- export type DocumentObjectFieldPropsAPI = { isUnset: true } | ({ isUnset?: false; fields: Record<string, DocumentFieldAPI> } & DocumentObjectFieldPropsCommon);
230
-
231
- // model
232
- export type DocumentModelField = DocumentModelFieldLocalized | DocumentModelFieldNonLocalized;
233
- export type DocumentModelFieldLocalized = DocumentFieldTypeLocalized<DocumentModelFieldBase, DocumentModelFieldProps>;
234
- export type DocumentModelFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentModelFieldBase, DocumentModelFieldProps>;
235
- export type DocumentModelFieldAPI = DocumentFieldTypeAPI<DocumentModelFieldBase, DocumentModelFieldPropsAPI>;
236
- export type DocumentModelFieldBase = { type: 'model' };
237
- export type DocumentModelFieldPropsCommon = {
238
- srcObjectLabel: string;
239
- srcModelName: string;
240
- srcModelLabel: string;
241
- };
242
- export type DocumentModelFieldProps = { isUnset: true } | ({ isUnset?: false; fields: Record<string, DocumentField> } & DocumentModelFieldPropsCommon);
243
- export type DocumentModelFieldPropsAPI = { isUnset: true } | ({ isUnset?: false; fields: Record<string, DocumentFieldAPI> } & DocumentModelFieldPropsCommon);
244
-
245
- // reference
246
- export type DocumentReferenceField = DocumentReferenceFieldLocalized | DocumentReferenceFieldNonLocalized;
247
- export type DocumentReferenceFieldLocalized = DocumentFieldTypeLocalized<DocumentReferenceFieldBase, DocumentReferenceFieldProps>;
248
- export type DocumentReferenceFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentReferenceFieldBase, DocumentReferenceFieldProps>;
249
- export type DocumentReferenceFieldAPI = DocumentFieldTypeAPI<DocumentReferenceFieldBaseAPI, DocumentReferenceFieldProps>;
250
- export type DocumentReferenceFieldBase = {
251
- type: 'reference';
252
- refType: 'document' | 'asset';
253
- };
254
- export type DocumentReferenceFieldProps = { isUnset: true } | { isUnset?: false; refId: string };
255
- export type DocumentReferenceFieldBaseAPI = {
256
- type: 'unresolved_reference';
257
- refType: 'object' | 'image';
258
- };
259
-
260
- // markdown
261
- export type DocumentMarkdownField = DocumentMarkdownFieldLocalized | DocumentMarkdownFieldNonLocalized;
262
- export type DocumentMarkdownFieldLocalized = DocumentFieldTypeLocalized<DocumentMarkdownFieldBase, DocumentMarkdownFieldProps>;
263
- export type DocumentMarkdownFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentMarkdownFieldBase, DocumentMarkdownFieldProps>;
264
- export type DocumentMarkdownFieldAPI = DocumentFieldTypeAPI<DocumentMarkdownFieldBase, DocumentMarkdownFieldProps>;
265
- export type DocumentMarkdownFieldBase = {
266
- type: 'markdown';
267
- };
268
- export type DocumentMarkdownFieldProps = {
269
- isUnset?: boolean;
270
- multiElement?: boolean;
271
- value: any;
272
- };
273
-
274
- // richText
275
- export type DocumentRichTextField = DocumentRichTextFieldLocalized | DocumentRichTextFieldNonLocalized;
276
- export type DocumentRichTextFieldLocalized = DocumentFieldTypeLocalized<DocumentRichTextFieldBase, DocumentRichTextFieldProps>;
277
- export type DocumentRichTextFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentRichTextFieldBase, DocumentRichTextFieldProps>;
278
- export type DocumentRichTextFieldAPI = DocumentFieldTypeAPI<DocumentRichTextFieldBase, DocumentRichTextFieldProps>;
279
- export type DocumentRichTextFieldBase = {
280
- type: 'richText';
281
- };
282
- export type DocumentRichTextFieldProps = {
283
- isUnset?: boolean;
284
- hint?: string;
285
- multiElement?: boolean;
286
- value: any;
287
- };
288
-
289
- // list
290
- export type DocumentListField = DocumentListFieldLocalized | DocumentListFieldNonLocalized;
291
- export type DocumentListFieldLocalized = DocumentFieldTypeLocalized<DocumentListFieldBase, DocumentListFieldProps>;
292
- export type DocumentListFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentListFieldBase, DocumentListFieldProps>;
293
- export type DocumentListFieldAPI = DocumentFieldTypeAPI<DocumentListFieldBase, DocumentListFieldPropsAPI>;
294
- export type DocumentListFieldBase = {
295
- type: 'list';
296
- };
297
- export type DocumentListFieldProps = {
298
- items: DocumentField[];
299
- };
300
- export type DocumentListFieldPropsAPI = {
301
- items: DocumentFieldAPI[];
302
- };
303
-
304
- // assetFile
305
- export type AssetFileField = AssetFileFieldLocalized | AssetFileFieldNonLocalized;
306
- export type AssetFileFieldLocalized = DocumentFieldTypeLocalized<AssetFileFieldBase, AssetFileFieldProps>;
307
- export type AssetFileFieldNonLocalized = DocumentFieldTypeNonLocalized<AssetFileFieldBase, AssetFileFieldProps>;
308
- export type AssetFileFieldBase = {
309
- type: 'assetFile';
310
- };
311
- export type AssetFileFieldProps = {
312
- url: string;
313
- fileName?: string;
314
- contentType?: string;
315
- size?: number;
316
- dimensions?: {
317
- width?: number;
318
- height?: number;
319
- };
320
- };
321
- export type UpdateOperation = UpdateOperationSet | UpdateOperationUnset | UpdateOperationInsert | UpdateOperationRemove | UpdateOperationReorder;
322
-
323
- export type UpdateOperationBase = {
324
- opType: string;
325
- fieldPath: (string | number)[];
326
- locale?: string;
327
- };
328
-
329
- export type UpdateOperationSet = Simplify<
330
- UpdateOperationBase & {
331
- opType: 'set';
332
- field: UpdateOperationField;
333
- }
334
- >;
335
-
336
- export type UpdateOperationUnset = Simplify<
337
- UpdateOperationBase & {
338
- opType: 'unset';
339
- }
340
- >;
341
-
342
- export type UpdateOperationInsert = Simplify<
343
- UpdateOperationBase & {
344
- opType: 'insert';
345
- index?: number;
346
- item: UpdateOperationField;
347
- }
348
- >;
349
-
350
- export type UpdateOperationRemove = Simplify<
351
- UpdateOperationBase & {
352
- opType: 'remove';
353
- index: number;
354
- }
355
- >;
356
-
357
- export type UpdateOperationReorder = Simplify<
358
- UpdateOperationBase & {
359
- opType: 'reorder';
360
- order: number[];
361
- }
362
- >;
363
-
364
- export type UpdateOperationField = UpdateOperationValueField | UpdateOperationObjectField | UpdateOperationModelField | UpdateOperationReferenceField;
365
-
366
- export type UpdateOperationValueFieldType = Exclude<FieldType, 'object' | 'model' | 'reference'>;
367
- export type UpdateOperationValueField = {
368
- type: UpdateOperationValueFieldType;
369
- value: any;
370
- };
371
-
372
- export type UpdateOperationObjectField = {
373
- type: 'object';
374
- object: Record<string, any>;
375
- };
376
-
377
- export type UpdateOperationModelField = {
378
- type: 'model';
379
- modelName: string;
380
- object: Record<string, any>;
381
- };
382
-
383
- export type UpdateOperationReferenceField = {
384
- type: 'reference';
385
- refType: 'document' | 'asset';
386
- refId: string;
387
- };
388
-
389
- export type User = {
390
- name: string;
391
- email: string;
392
- connections: {
393
- type: string;
394
- [key: string]: any;
395
- }[];
396
- };
397
-
398
- export type ValidationError = {
399
- message: string;
400
- srcType: string;
401
- srcProjectId: string;
402
- srcObjectType: string;
403
- srcObjectId: string;
404
- fieldPath: (string | number)[];
405
- isUniqueValidation?: boolean;
406
- };