@stackbit/cms-core 0.8.4-develop.1 → 0.8.4-develop.3
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/.tsbuildinfo +1 -1
- package/dist/content-store-utils.d.ts.map +1 -1
- package/dist/content-store-utils.js +44 -48
- package/dist/content-store-utils.js.map +1 -1
- package/dist/content-store.d.ts +1 -1
- package/dist/content-store.d.ts.map +1 -1
- package/dist/content-store.js +14 -7
- package/dist/content-store.js.map +1 -1
- package/dist/types/custom-actions.d.ts +12 -8
- package/dist/types/custom-actions.d.ts.map +1 -1
- package/dist/utils/csi-to-store-docs-converter.d.ts +14 -11
- package/dist/utils/csi-to-store-docs-converter.d.ts.map +1 -1
- package/dist/utils/csi-to-store-docs-converter.js +21 -92
- package/dist/utils/csi-to-store-docs-converter.js.map +1 -1
- package/dist/utils/custom-actions.d.ts +39 -24
- package/dist/utils/custom-actions.d.ts.map +1 -1
- package/dist/utils/custom-actions.js +417 -231
- package/dist/utils/custom-actions.js.map +1 -1
- package/dist/utils/store-to-api-docs-converter.d.ts.map +1 -1
- package/dist/utils/store-to-api-docs-converter.js +40 -3
- package/dist/utils/store-to-api-docs-converter.js.map +1 -1
- package/package.json +4 -4
- package/src/content-store-utils.ts +79 -51
- package/src/content-store.ts +15 -8
- package/src/types/custom-actions.ts +22 -16
- package/src/utils/csi-to-store-docs-converter.ts +89 -227
- package/src/utils/custom-actions.ts +514 -263
- package/src/utils/store-to-api-docs-converter.ts +40 -3
|
@@ -34,6 +34,7 @@ function documentToLocalizedApiObject({
|
|
|
34
34
|
}): ContentStoreTypes.APIDocumentObject {
|
|
35
35
|
const { type, fields, getPreview, getDocumentActions, ...rest } = document;
|
|
36
36
|
return omitByUndefined({
|
|
37
|
+
// for historical reasons, stackbit app works with { type: 'object' } not { type: 'document' }
|
|
37
38
|
type: 'object',
|
|
38
39
|
...rest,
|
|
39
40
|
srcObjectLabel: getPreview({ delegate, locale }).previewTitle,
|
|
@@ -62,6 +63,42 @@ function toLocalizedAPIFields({
|
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
/**
|
|
67
|
+
* For historical reasons, Stackit app works with fields that can have only one
|
|
68
|
+
* locale. When Stackbit app fetches documents, it passes the current locale.
|
|
69
|
+
* This function converts the internal document field (DocumentField), possibly
|
|
70
|
+
* with nested locales, into an API field (DocumentFieldAPI) with single locale.
|
|
71
|
+
*
|
|
72
|
+
* DocumentField:
|
|
73
|
+
* {
|
|
74
|
+
* type: "string",
|
|
75
|
+
* localized: true,
|
|
76
|
+
* locales: {
|
|
77
|
+
* 'en-US': {
|
|
78
|
+
* locale: 'en-US',
|
|
79
|
+
* value: 'hello
|
|
80
|
+
* },
|
|
81
|
+
* 'fr-FR': {
|
|
82
|
+
* locale: 'fr-FR',
|
|
83
|
+
* valie: 'bonjour'
|
|
84
|
+
* }
|
|
85
|
+
* }
|
|
86
|
+
* }
|
|
87
|
+
*
|
|
88
|
+
* DocumentFieldAPI:
|
|
89
|
+
* {
|
|
90
|
+
* type: "string",
|
|
91
|
+
* localized: true,
|
|
92
|
+
* locale: 'fr-FR',
|
|
93
|
+
* value: 'bonjour'
|
|
94
|
+
* }
|
|
95
|
+
*
|
|
96
|
+
* It also does some conversions between field types:
|
|
97
|
+
* type: 'model' => 'object',
|
|
98
|
+
* type: 'reference' => 'unresolved_reference',
|
|
99
|
+
* refType: 'asset' => 'image'
|
|
100
|
+
* refType: 'document' => 'object'
|
|
101
|
+
*/
|
|
65
102
|
function toLocalizedAPIField({
|
|
66
103
|
docField,
|
|
67
104
|
delegate,
|
|
@@ -542,12 +579,12 @@ function concatObjectAndFieldActions(
|
|
|
542
579
|
fieldActions?: APICustomActionField[]
|
|
543
580
|
): (APICustomActionObject | APICustomActionField)[] | undefined {
|
|
544
581
|
let result: (APICustomActionObject | APICustomActionField)[] = [];
|
|
545
|
-
if (objectActions) {
|
|
546
|
-
result = result.concat(objectActions);
|
|
547
|
-
}
|
|
548
582
|
if (fieldActions) {
|
|
549
583
|
result = result.concat(fieldActions);
|
|
550
584
|
}
|
|
585
|
+
if (objectActions) {
|
|
586
|
+
result = result.concat(objectActions);
|
|
587
|
+
}
|
|
551
588
|
if (result.length) {
|
|
552
589
|
return result;
|
|
553
590
|
}
|