@stackbit/sdk 0.3.3-alpha.1 → 0.3.3-alpha.2
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/dist/analyzer/analyze-schema-types.d.ts +10 -13
- package/dist/analyzer/analyze-schema-types.d.ts.map +1 -1
- package/dist/analyzer/analyze-schema-types.js.map +1 -1
- package/dist/analyzer/schema-generator.d.ts.map +1 -1
- package/dist/analyzer/schema-generator.js +6 -2
- package/dist/analyzer/schema-generator.js.map +1 -1
- package/dist/analyzer/site-analyzer.d.ts.map +1 -1
- package/dist/analyzer/site-analyzer.js.map +1 -1
- package/dist/config/config-consts.d.ts +1 -25
- package/dist/config/config-consts.d.ts.map +1 -1
- package/dist/config/config-consts.js +6 -79
- package/dist/config/config-consts.js.map +1 -1
- package/dist/config/config-loader-static.d.ts +3 -1
- package/dist/config/config-loader-static.d.ts.map +1 -1
- package/dist/config/config-loader-static.js +5 -1
- package/dist/config/config-loader-static.js.map +1 -1
- package/dist/config/config-loader-utils.d.ts +2 -1
- package/dist/config/config-loader-utils.d.ts.map +1 -1
- package/dist/config/config-loader-utils.js +4 -1
- package/dist/config/config-loader-utils.js.map +1 -1
- package/dist/config/config-loader.d.ts +2 -1
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/config/config-loader.js.map +1 -1
- package/dist/config/config-schema.d.ts +2 -2
- package/dist/config/config-schema.d.ts.map +1 -1
- package/dist/config/config-schema.js.map +1 -1
- package/dist/config/config-types.d.ts +44 -287
- package/dist/config/config-types.d.ts.map +1 -1
- package/dist/config/config-validator.d.ts +3 -2
- package/dist/config/config-validator.d.ts.map +1 -1
- package/dist/config/config-validator.js.map +1 -1
- package/dist/config/presets-loader.js +3 -0
- package/dist/config/presets-loader.js.map +1 -1
- package/dist/content/content-schema.js +1 -1
- package/dist/content/content-schema.js.map +1 -1
- package/dist/utils/model-extender.d.ts +3 -3
- package/dist/utils/model-extender.d.ts.map +1 -1
- package/dist/utils/model-extender.js +3 -3
- package/dist/utils/model-extender.js.map +1 -1
- package/dist/utils/model-iterators.d.ts +3 -67
- package/dist/utils/model-iterators.d.ts.map +1 -1
- package/dist/utils/model-iterators.js.map +1 -1
- package/dist/utils/model-matcher.js +1 -1
- package/dist/utils/model-matcher.js.map +1 -1
- package/dist/utils/model-utils.d.ts +8 -52
- package/dist/utils/model-utils.d.ts.map +1 -1
- package/dist/utils/model-utils.js +5 -1
- package/dist/utils/model-utils.js.map +1 -1
- package/package.json +3 -2
- package/src/analyzer/analyze-schema-types.ts +12 -16
- package/src/analyzer/schema-generator.ts +14 -4
- package/src/analyzer/site-analyzer.ts +2 -1
- package/src/config/config-consts.ts +1 -83
- package/src/config/config-loader-static.ts +11 -3
- package/src/config/config-loader-utils.ts +7 -3
- package/src/config/config-loader.ts +12 -11
- package/src/config/config-schema/style-field-schema.ts +1 -1
- package/src/config/config-schema.ts +20 -25
- package/src/config/config-types.ts +103 -334
- package/src/config/config-validator.ts +3 -2
- package/src/config/presets-loader.ts +3 -0
- package/src/content/content-schema.ts +1 -1
- package/src/utils/model-extender.ts +8 -8
- package/src/utils/model-iterators.ts +2 -2
- package/src/utils/model-matcher.ts +1 -1
- package/src/utils/model-utils.ts +25 -11
package/src/utils/model-utils.ts
CHANGED
|
@@ -7,6 +7,12 @@ import {
|
|
|
7
7
|
DataModel,
|
|
8
8
|
PageModel,
|
|
9
9
|
ConfigModel,
|
|
10
|
+
ImageModel,
|
|
11
|
+
YamlModel,
|
|
12
|
+
YamlObjectModel,
|
|
13
|
+
YamlPageModel,
|
|
14
|
+
YamlDataModel,
|
|
15
|
+
YamlDataModelList,
|
|
10
16
|
Field,
|
|
11
17
|
FieldEnum,
|
|
12
18
|
FieldList,
|
|
@@ -19,7 +25,8 @@ import {
|
|
|
19
25
|
FieldObject,
|
|
20
26
|
FieldObjectProps,
|
|
21
27
|
FieldReference,
|
|
22
|
-
FieldReferenceProps
|
|
28
|
+
FieldReferenceProps,
|
|
29
|
+
DataModelList
|
|
23
30
|
} from '../config/config-types';
|
|
24
31
|
|
|
25
32
|
export function getModelByName(models: Model[], modelName: string): Model | undefined {
|
|
@@ -30,23 +37,27 @@ export function isConfigModel(model: Model): model is ConfigModel {
|
|
|
30
37
|
return model.type === 'config';
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
export function isDataModel(model: Model): model is DataModel {
|
|
40
|
+
export function isDataModel(model: Model | YamlModel): model is DataModel | YamlDataModel {
|
|
34
41
|
return model.type === 'data';
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
export function isListDataModel(model: Model): model is
|
|
44
|
+
export function isListDataModel(model: Model | YamlModel): model is DataModelList | YamlDataModelList {
|
|
38
45
|
return isDataModel(model) && Boolean(model.isList);
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
export function isPageModel(model: Model): model is PageModel {
|
|
48
|
+
export function isPageModel(model: Model | YamlModel): model is PageModel | YamlPageModel {
|
|
42
49
|
return model.type === 'page';
|
|
43
50
|
}
|
|
44
51
|
|
|
45
|
-
export function isObjectModel(model: Model): model is ObjectModel {
|
|
52
|
+
export function isObjectModel(model: Model | YamlModel): model is ObjectModel | YamlObjectModel {
|
|
46
53
|
return model.type === 'object';
|
|
47
54
|
}
|
|
48
55
|
|
|
49
|
-
export function
|
|
56
|
+
export function isImageModel(model: Model): model is ImageModel {
|
|
57
|
+
return model.type === 'image';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function isSingleInstanceModel(model: Model | YamlModel): boolean {
|
|
50
61
|
if (model.type === 'config') {
|
|
51
62
|
return true;
|
|
52
63
|
} else if (model.type === 'data') {
|
|
@@ -198,8 +209,8 @@ export function resolveLabelFieldForModel(modelOrField: Model | FieldObjectProps
|
|
|
198
209
|
return labelField || null;
|
|
199
210
|
}
|
|
200
211
|
|
|
201
|
-
export function getModelFieldForModelKeyPath(model: Model, modelKeyPath: string[]) {
|
|
202
|
-
function _getField(field: Field, modelKeyPath: string[]): Model | Field | FieldListItems | FieldObjectProps | null {
|
|
212
|
+
export function getModelFieldForModelKeyPath(model: Model | YamlModel, modelKeyPath: string[]) {
|
|
213
|
+
function _getField(field: Field, modelKeyPath: string[]): Model | YamlModel | Field | FieldListItems | FieldObjectProps | null {
|
|
203
214
|
if (modelKeyPath.length === 0) {
|
|
204
215
|
return field;
|
|
205
216
|
} else if (isObjectField(field)) {
|
|
@@ -211,7 +222,10 @@ export function getModelFieldForModelKeyPath(model: Model, modelKeyPath: string[
|
|
|
211
222
|
}
|
|
212
223
|
}
|
|
213
224
|
|
|
214
|
-
function _getObjectFields<T extends FieldObjectProps | Model
|
|
225
|
+
function _getObjectFields<T extends FieldObjectProps | Model | YamlModel>(
|
|
226
|
+
field: T,
|
|
227
|
+
modelKeyPath: string[]
|
|
228
|
+
): Model | YamlModel | Field | FieldListItems | FieldObjectProps | null {
|
|
215
229
|
if (modelKeyPath.length === 0) {
|
|
216
230
|
return field;
|
|
217
231
|
}
|
|
@@ -230,10 +244,10 @@ export function getModelFieldForModelKeyPath(model: Model, modelKeyPath: string[
|
|
|
230
244
|
return _getField(childField, modelKeyPath);
|
|
231
245
|
}
|
|
232
246
|
|
|
233
|
-
function _getListItems<T extends FieldList |
|
|
247
|
+
function _getListItems<T extends FieldList | DataModelList | YamlDataModelList>(
|
|
234
248
|
field: T,
|
|
235
249
|
modelKeyPath: string[]
|
|
236
|
-
): Model | Field | FieldListItems | FieldObjectProps | null {
|
|
250
|
+
): Model | YamlModel | Field | FieldListItems | FieldObjectProps | null {
|
|
237
251
|
if (modelKeyPath.length === 0) {
|
|
238
252
|
return field;
|
|
239
253
|
}
|