@datocms/cma-client 5.1.0 → 5.1.1
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/cjs/fieldTypes/rich_text.js +3 -3
- package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
- package/dist/cjs/fieldTypes/single_block.js +3 -3
- package/dist/cjs/fieldTypes/single_block.js.map +1 -1
- package/dist/cjs/fieldTypes/structured_text.js +3 -3
- package/dist/cjs/fieldTypes/structured_text.js.map +1 -1
- package/dist/cjs/generated/Client.js +1 -1
- package/dist/cjs/utilities/fieldValueLocalization.js +90 -55
- package/dist/cjs/utilities/fieldValueLocalization.js.map +1 -1
- package/dist/cjs/utilities/structuredText.js +11 -11
- package/dist/cjs/utilities/structuredText.js.map +1 -1
- package/dist/esm/fieldTypes/rich_text.d.ts +2 -2
- package/dist/esm/fieldTypes/rich_text.js +1 -1
- package/dist/esm/fieldTypes/rich_text.js.map +1 -1
- package/dist/esm/fieldTypes/single_block.d.ts +2 -2
- package/dist/esm/fieldTypes/single_block.js +1 -1
- package/dist/esm/fieldTypes/single_block.js.map +1 -1
- package/dist/esm/fieldTypes/structured_text.d.ts +8 -8
- package/dist/esm/fieldTypes/structured_text.js +1 -1
- package/dist/esm/fieldTypes/structured_text.js.map +1 -1
- package/dist/esm/generated/Client.js +1 -1
- package/dist/esm/generated/SchemaTypes.d.ts +11 -6
- package/dist/esm/generated/SimpleSchemaTypes.d.ts +11 -6
- package/dist/esm/utilities/fieldValueLocalization.d.ts +51 -9
- package/dist/esm/utilities/fieldValueLocalization.js +87 -54
- package/dist/esm/utilities/fieldValueLocalization.js.map +1 -1
- package/dist/esm/utilities/structuredText.d.ts +2 -2
- package/dist/esm/utilities/structuredText.js +8 -8
- package/dist/esm/utilities/structuredText.js.map +1 -1
- package/dist/types/fieldTypes/rich_text.d.ts +2 -2
- package/dist/types/fieldTypes/single_block.d.ts +2 -2
- package/dist/types/fieldTypes/structured_text.d.ts +8 -8
- package/dist/types/generated/SchemaTypes.d.ts +11 -6
- package/dist/types/generated/SimpleSchemaTypes.d.ts +11 -6
- package/dist/types/utilities/fieldValueLocalization.d.ts +51 -9
- package/dist/types/utilities/structuredText.d.ts +2 -2
- package/package.json +4 -4
- package/src/fieldTypes/rich_text.ts +3 -3
- package/src/fieldTypes/single_block.ts +3 -3
- package/src/fieldTypes/structured_text.ts +13 -13
- package/src/generated/Client.ts +1 -1
- package/src/generated/SchemaTypes.ts +42 -7
- package/src/generated/SimpleSchemaTypes.ts +42 -7
- package/src/utilities/blocks.ts +6 -6
- package/src/utilities/fieldValueLocalization.ts +122 -93
- package/src/utilities/structuredText.ts +8 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isRichTextFieldValueWithNestedBlocks = exports.isRichTextFieldValueAsRequest = exports.isRichTextFieldValue = void 0;
|
|
4
4
|
const single_block_1 = require("./single_block");
|
|
5
5
|
/**
|
|
6
6
|
* =============================================================================
|
|
@@ -39,7 +39,7 @@ exports.isRichTextFieldValueAsRequest = isRichTextFieldValueAsRequest;
|
|
|
39
39
|
* Type guard for Modular Content field values with nested blocks (?nested=true format).
|
|
40
40
|
* Ensures all blocks are full SchemaTypes.Item objects with complete data.
|
|
41
41
|
*/
|
|
42
|
-
function
|
|
42
|
+
function isRichTextFieldValueWithNestedBlocks(value) {
|
|
43
43
|
if (value === null)
|
|
44
44
|
return true;
|
|
45
45
|
if (!Array.isArray(value))
|
|
@@ -49,5 +49,5 @@ function isRichTextFieldValueWithResolvedBlocks(value) {
|
|
|
49
49
|
return (0, single_block_1.isBlockObjectWithId)(block);
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
exports.
|
|
52
|
+
exports.isRichTextFieldValueWithNestedBlocks = isRichTextFieldValueWithNestedBlocks;
|
|
53
53
|
//# sourceMappingURL=rich_text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich_text.js","sourceRoot":"","sources":["../../../src/fieldTypes/rich_text.ts"],"names":[],"mappings":";;;AACA,iDAKwB;AAqExB;;;;GAIG;AAEH;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAC1E,CAAC;AACJ,CAAC;AARD,oDAQC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CAC3C,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,yCAAyC;QACzC,IAAI,IAAA,8BAAe,EAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAExC,0DAA0D;QAC1D,OAAO,IAAA,4BAAa,EAAC,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAdD,sEAcC;AAED;;;GAGG;AACH,SAAgB,
|
|
1
|
+
{"version":3,"file":"rich_text.js","sourceRoot":"","sources":["../../../src/fieldTypes/rich_text.ts"],"names":[],"mappings":";;;AACA,iDAKwB;AAqExB;;;;GAIG;AAEH;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAC1E,CAAC;AACJ,CAAC;AARD,oDAQC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CAC3C,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,yCAAyC;QACzC,IAAI,IAAA,8BAAe,EAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAExC,0DAA0D;QAC1D,OAAO,IAAA,4BAAa,EAAC,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAdD,sEAcC;AAED;;;GAGG;AACH,SAAgB,oCAAoC,CAClD,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,uFAAuF;QACvF,OAAO,IAAA,kCAAmB,EAAC,KAAK,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AAXD,oFAWC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isSingleBlockFieldValueWithNestedBlocks = exports.isSingleBlockFieldValueAsRequest = exports.isSingleBlockFieldValue = exports.isBlockObjectWithId = exports.isBlockObject = exports.isBlockStringId = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* =============================================================================
|
|
6
6
|
* SHARED UTILITY FUNCTIONS
|
|
@@ -62,11 +62,11 @@ exports.isSingleBlockFieldValueAsRequest = isSingleBlockFieldValueAsRequest;
|
|
|
62
62
|
* Type guard for Single Block field values with nested blocks (?nested=true format).
|
|
63
63
|
* Ensures block is a full SchemaTypes.Item object with complete data.
|
|
64
64
|
*/
|
|
65
|
-
function
|
|
65
|
+
function isSingleBlockFieldValueWithNestedBlocks(value) {
|
|
66
66
|
if (value === null)
|
|
67
67
|
return true;
|
|
68
68
|
// Must be a full object with ID (nested format always includes complete block objects)
|
|
69
69
|
return isBlockObjectWithId(value);
|
|
70
70
|
}
|
|
71
|
-
exports.
|
|
71
|
+
exports.isSingleBlockFieldValueWithNestedBlocks = isSingleBlockFieldValueWithNestedBlocks;
|
|
72
72
|
//# sourceMappingURL=single_block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single_block.js","sourceRoot":"","sources":["../../../src/fieldTypes/single_block.ts"],"names":[],"mappings":";;;AAiFA;;;;;GAKG;AAEH;;GAEG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,0CAEC;AAOD;;GAEG;AACH,SAAgB,aAAa,CAC3B,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,YAAY,IAAI,KAAK,CACtB,CAAC;AACJ,CAAC;AATD,sCASC;AAID;;GAEG;AACH,SAAgB,mBAAmB,CACjC,KAAc;IAEd,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,CAAC;AAC/E,CAAC;AAJD,kDAIC;AAED;;;;GAIG;AAEH;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAJD,0DAIC;AAED;;;GAGG;AACH,SAAgB,gCAAgC,CAC9C,KAAc;IAEd,IAAI,KAA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ED;;;GAGG;AACH,SAAgB,uCAAuC,CACrD,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,uFAAuF;IACvF,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAPD,0FAOC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isStructuredTextFieldValueWithNestedBlocks = exports.isStructuredTextFieldValueAsRequest = exports.isStructuredTextFieldValue = void 0;
|
|
4
4
|
const datocms_structured_text_utils_1 = require("datocms-structured-text-utils");
|
|
5
5
|
const structuredText_1 = require("../utilities/structuredText");
|
|
6
6
|
const single_block_1 = require("./single_block");
|
|
@@ -70,7 +70,7 @@ exports.isStructuredTextFieldValueAsRequest = isStructuredTextFieldValueAsReques
|
|
|
70
70
|
* Type guard for structured text field values with nested blocks (?nested=true format).
|
|
71
71
|
* Ensures all block/inlineBlock nodes have full SchemaTypes.Item objects.
|
|
72
72
|
*/
|
|
73
|
-
function
|
|
73
|
+
function isStructuredTextFieldValueWithNestedBlocks(value) {
|
|
74
74
|
if (value === null)
|
|
75
75
|
return true;
|
|
76
76
|
if (!isValidDocumentStructure(value)) {
|
|
@@ -83,5 +83,5 @@ function isStructuredTextFieldValueWithResolvedBlocks(value) {
|
|
|
83
83
|
return (0, single_block_1.isBlockObjectWithId)(item);
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
exports.
|
|
86
|
+
exports.isStructuredTextFieldValueWithNestedBlocks = isStructuredTextFieldValueWithNestedBlocks;
|
|
87
87
|
//# sourceMappingURL=structured_text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured_text.js","sourceRoot":"","sources":["../../../src/fieldTypes/structured_text.ts"],"names":[],"mappings":";;;AAAA,iFAQuC;AAEvC,gEAAwD;AACxD,iDAKwB;AA8HxB;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EAAE,EAAE;QACpD,OAAO,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAbD,gEAaC;AAED;;;GAGG;AACH,SAAgB,mCAAmC,CACjD,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE;QACpC,OAAO,KAAK,CAAC;KACd;IAED,yEAAyE;IACzE,OAAO,qBAAqB,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;QACpD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,YAAY;QACZ,IAAI,IAAA,8BAAe,EAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAEvC,qCAAqC;QACrC,OAAO,IAAA,4BAAa,EAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC;AAnBD,kFAmBC;AAED;;;GAGG;AACH,SAAgB,0CAA0C,CACxD,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE;QACpC,OAAO,KAAK,CAAC;KACd;IAED,gEAAgE;IAChE,OAAO,qBAAqB,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;QACpD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,2EAA2E;QAC3E,OAAO,IAAA,kCAAmB,EAAC,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC;AAhBD,gGAgBC"}
|
|
@@ -88,7 +88,7 @@ class Client {
|
|
|
88
88
|
return this.config.baseUrl || Client.defaultBaseUrl;
|
|
89
89
|
}
|
|
90
90
|
request(options) {
|
|
91
|
-
return (0, rest_client_utils_1.request)(Object.assign(Object.assign(Object.assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v5.1.
|
|
91
|
+
return (0, rest_client_utils_1.request)(Object.assign(Object.assign(Object.assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v5.1.1', baseUrl: this.baseUrl, preCallStack: new Error().stack, extraHeaders: Object.assign(Object.assign(Object.assign({}, (this.config.extraHeaders || {})), (this.config.environment
|
|
92
92
|
? { 'X-Environment': this.config.environment }
|
|
93
93
|
: {})), { 'X-API-Version': '3' }), fetchJobResult: (jobId) => {
|
|
94
94
|
return this.jobResultsFetcher
|
|
@@ -9,11 +9,57 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.visitLocalizedFieldValuesAsync = exports.visitLocalizedFieldValues = exports.everyLocalizedFieldValuesAsync = exports.everyLocalizedFieldValues = exports.someLocalizedFieldValuesAsync = exports.someLocalizedFieldValues = exports.filterLocalizedFieldValuesAsync = exports.filterLocalizedFieldValues = exports.mapLocalizedFieldValuesAsync = exports.mapLocalizedFieldValues = exports.isLocalized = void 0;
|
|
12
|
+
exports.visitLocalizedFieldValuesAsync = exports.visitLocalizedFieldValues = exports.everyLocalizedFieldValuesAsync = exports.everyLocalizedFieldValues = exports.someLocalizedFieldValuesAsync = exports.someLocalizedFieldValues = exports.filterLocalizedFieldValuesAsync = exports.filterLocalizedFieldValues = exports.mapLocalizedFieldValuesAsync = exports.mapLocalizedFieldValues = exports.possiblyLocalizedEntriesToFieldValue = exports.fieldValueToPossiblyLocalizedEntries = exports.isLocalized = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Determines whether a DatoCMS field is localized or not.
|
|
15
|
+
*
|
|
16
|
+
* This function handles both full Schema field objects and simplified Schema field objects
|
|
17
|
+
* by checking the appropriate property based on the object structure.
|
|
18
|
+
*
|
|
19
|
+
* @param field - The DatoCMS field definition (either full or simple schema)
|
|
20
|
+
* @returns true if the field is localized, false otherwise
|
|
21
|
+
*/
|
|
13
22
|
function isLocalized(field) {
|
|
14
23
|
return 'attributes' in field ? field.attributes.localized : field.localized;
|
|
15
24
|
}
|
|
16
25
|
exports.isLocalized = isLocalized;
|
|
26
|
+
/**
|
|
27
|
+
* Converts a field value (localized or non-localized) into a uniform array of entries.
|
|
28
|
+
*
|
|
29
|
+
* This function normalizes the handling of field values by converting them into a consistent
|
|
30
|
+
* array format, regardless of whether the field is localized or not.
|
|
31
|
+
*
|
|
32
|
+
* @param field - The DatoCMS field definition that determines localization behavior
|
|
33
|
+
* @param value - The field value to convert (either a localized object or direct value)
|
|
34
|
+
* @returns Array of entries where each entry contains a locale (string for localized, undefined for non-localized) and the corresponding value
|
|
35
|
+
*/
|
|
36
|
+
function fieldValueToPossiblyLocalizedEntries(field, value) {
|
|
37
|
+
if (isLocalized(field)) {
|
|
38
|
+
const localizedValue = value;
|
|
39
|
+
return Object.entries(localizedValue).map(([locale, value]) => ({ locale, value }));
|
|
40
|
+
}
|
|
41
|
+
return [{ locale: undefined, value }];
|
|
42
|
+
}
|
|
43
|
+
exports.fieldValueToPossiblyLocalizedEntries = fieldValueToPossiblyLocalizedEntries;
|
|
44
|
+
/**
|
|
45
|
+
* Converts an array of possibly localized entries back into the appropriate field value format.
|
|
46
|
+
*
|
|
47
|
+
* This function is the inverse of `fieldValueToPossiblyLocalizedEntries`. It takes a uniform
|
|
48
|
+
* array of entries and converts them back to either a localized object or a direct value,
|
|
49
|
+
* depending on the field's localization setting.
|
|
50
|
+
*
|
|
51
|
+
* @param field - The DatoCMS field definition that determines the output format
|
|
52
|
+
* @param possiblyLocalizedEntries - Array of entries to convert back to field value format
|
|
53
|
+
* @returns Either a localized object (for localized fields) or the direct value (for non-localized fields)
|
|
54
|
+
*/
|
|
55
|
+
function possiblyLocalizedEntriesToFieldValue(field, possiblyLocalizedEntries) {
|
|
56
|
+
var _a;
|
|
57
|
+
if (isLocalized(field)) {
|
|
58
|
+
return Object.fromEntries(possiblyLocalizedEntries.map(({ locale, value }) => [locale, value]));
|
|
59
|
+
}
|
|
60
|
+
return (_a = possiblyLocalizedEntries[0]) === null || _a === void 0 ? void 0 : _a.value;
|
|
61
|
+
}
|
|
62
|
+
exports.possiblyLocalizedEntriesToFieldValue = possiblyLocalizedEntriesToFieldValue;
|
|
17
63
|
/**
|
|
18
64
|
* Maps localized field values using a provided mapping function.
|
|
19
65
|
* For localized fields, applies the mapping function to each locale value.
|
|
@@ -26,14 +72,12 @@ exports.isLocalized = isLocalized;
|
|
|
26
72
|
* @returns The mapped value with the same structure as the input
|
|
27
73
|
*/
|
|
28
74
|
function mapLocalizedFieldValues(field, value, mapFn) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
return mapFn(undefined, value);
|
|
75
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
76
|
+
const mappedEntries = entries.map(({ locale, value }) => ({
|
|
77
|
+
locale,
|
|
78
|
+
value: mapFn(locale, value),
|
|
79
|
+
}));
|
|
80
|
+
return possiblyLocalizedEntriesToFieldValue(field, mappedEntries);
|
|
37
81
|
}
|
|
38
82
|
exports.mapLocalizedFieldValues = mapLocalizedFieldValues;
|
|
39
83
|
/**
|
|
@@ -49,11 +93,14 @@ exports.mapLocalizedFieldValues = mapLocalizedFieldValues;
|
|
|
49
93
|
*/
|
|
50
94
|
function mapLocalizedFieldValuesAsync(field, value, mapFn) {
|
|
51
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
96
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
97
|
+
const mappedEntries = yield Promise.all(entries.map(({ locale, value }) => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
return ({
|
|
99
|
+
locale,
|
|
100
|
+
value: yield mapFn(locale, value),
|
|
101
|
+
});
|
|
102
|
+
})));
|
|
103
|
+
return possiblyLocalizedEntriesToFieldValue(field, mappedEntries);
|
|
57
104
|
});
|
|
58
105
|
}
|
|
59
106
|
exports.mapLocalizedFieldValuesAsync = mapLocalizedFieldValuesAsync;
|
|
@@ -68,11 +115,13 @@ exports.mapLocalizedFieldValuesAsync = mapLocalizedFieldValuesAsync;
|
|
|
68
115
|
* @returns The filtered value with the same structure as the input
|
|
69
116
|
*/
|
|
70
117
|
function filterLocalizedFieldValues(field, value, filterFn) {
|
|
118
|
+
var _a;
|
|
119
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
120
|
+
const filteredEntries = entries.filter(({ locale, value }) => filterFn(locale, value));
|
|
71
121
|
if (isLocalized(field)) {
|
|
72
|
-
|
|
73
|
-
return Object.fromEntries(Object.entries(localizedValue).filter(([locale, value]) => filterFn(locale, value)));
|
|
122
|
+
return possiblyLocalizedEntriesToFieldValue(field, filteredEntries);
|
|
74
123
|
}
|
|
75
|
-
return
|
|
124
|
+
return filteredEntries.length > 0 ? (_a = filteredEntries[0]) === null || _a === void 0 ? void 0 : _a.value : undefined;
|
|
76
125
|
}
|
|
77
126
|
exports.filterLocalizedFieldValues = filterLocalizedFieldValues;
|
|
78
127
|
/**
|
|
@@ -86,21 +135,23 @@ exports.filterLocalizedFieldValues = filterLocalizedFieldValues;
|
|
|
86
135
|
* @returns The filtered value with the same structure as the input
|
|
87
136
|
*/
|
|
88
137
|
function filterLocalizedFieldValuesAsync(field, value, filterFn) {
|
|
138
|
+
var _a;
|
|
89
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
141
|
+
const results = yield Promise.all(entries.map(({ locale, value }) => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
return ({
|
|
143
|
+
locale,
|
|
144
|
+
value,
|
|
145
|
+
passed: yield filterFn(locale, value),
|
|
146
|
+
});
|
|
147
|
+
})));
|
|
148
|
+
const filteredEntries = results
|
|
149
|
+
.filter(({ passed }) => passed)
|
|
150
|
+
.map(({ locale, value }) => ({ locale, value }));
|
|
90
151
|
if (isLocalized(field)) {
|
|
91
|
-
|
|
92
|
-
const results = yield Promise.all(Object.entries(localizedValue).map(([locale, value]) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return [
|
|
94
|
-
locale,
|
|
95
|
-
value,
|
|
96
|
-
yield filterFn(locale, value),
|
|
97
|
-
];
|
|
98
|
-
})));
|
|
99
|
-
return Object.fromEntries(results
|
|
100
|
-
.filter(([, , passed]) => passed)
|
|
101
|
-
.map(([locale, value]) => [locale, value]));
|
|
152
|
+
return possiblyLocalizedEntriesToFieldValue(field, filteredEntries);
|
|
102
153
|
}
|
|
103
|
-
return
|
|
154
|
+
return filteredEntries.length > 0 ? (_a = filteredEntries[0]) === null || _a === void 0 ? void 0 : _a.value : undefined;
|
|
104
155
|
});
|
|
105
156
|
}
|
|
106
157
|
exports.filterLocalizedFieldValuesAsync = filterLocalizedFieldValuesAsync;
|
|
@@ -115,11 +166,8 @@ exports.filterLocalizedFieldValuesAsync = filterLocalizedFieldValuesAsync;
|
|
|
115
166
|
* @returns true if at least one value passes the test, false otherwise
|
|
116
167
|
*/
|
|
117
168
|
function someLocalizedFieldValues(field, value, testFn) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return Object.entries(localizedValue).some(([locale, value]) => testFn(locale, value));
|
|
121
|
-
}
|
|
122
|
-
return testFn(undefined, value);
|
|
169
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
170
|
+
return entries.some(({ locale, value }) => testFn(locale, value));
|
|
123
171
|
}
|
|
124
172
|
exports.someLocalizedFieldValues = someLocalizedFieldValues;
|
|
125
173
|
/**
|
|
@@ -134,12 +182,9 @@ exports.someLocalizedFieldValues = someLocalizedFieldValues;
|
|
|
134
182
|
*/
|
|
135
183
|
function someLocalizedFieldValuesAsync(field, value, testFn) {
|
|
136
184
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return results.some((result) => result);
|
|
141
|
-
}
|
|
142
|
-
return yield testFn(undefined, value);
|
|
185
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
186
|
+
const results = yield Promise.all(entries.map(({ locale, value }) => testFn(locale, value)));
|
|
187
|
+
return results.some((result) => result);
|
|
143
188
|
});
|
|
144
189
|
}
|
|
145
190
|
exports.someLocalizedFieldValuesAsync = someLocalizedFieldValuesAsync;
|
|
@@ -183,14 +228,9 @@ exports.everyLocalizedFieldValuesAsync = everyLocalizedFieldValuesAsync;
|
|
|
183
228
|
* @param visitFn - The function to call for each locale value or the direct value
|
|
184
229
|
*/
|
|
185
230
|
function visitLocalizedFieldValues(field, value, visitFn) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
visitFn(locale, value);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
visitFn(undefined, value);
|
|
231
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
232
|
+
for (const { locale, value } of entries) {
|
|
233
|
+
visitFn(locale, value);
|
|
194
234
|
}
|
|
195
235
|
}
|
|
196
236
|
exports.visitLocalizedFieldValues = visitLocalizedFieldValues;
|
|
@@ -205,13 +245,8 @@ exports.visitLocalizedFieldValues = visitLocalizedFieldValues;
|
|
|
205
245
|
*/
|
|
206
246
|
function visitLocalizedFieldValuesAsync(field, value, visitFn) {
|
|
207
247
|
return __awaiter(this, void 0, void 0, function* () {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
yield Promise.all(Object.entries(localizedValue).map(([locale, value]) => __awaiter(this, void 0, void 0, function* () { return yield visitFn(locale, value); })));
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
yield visitFn(undefined, value);
|
|
214
|
-
}
|
|
248
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
249
|
+
yield Promise.all(entries.map(({ locale, value }) => visitFn(locale, value)));
|
|
215
250
|
});
|
|
216
251
|
}
|
|
217
252
|
exports.visitLocalizedFieldValuesAsync = visitLocalizedFieldValuesAsync;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldValueLocalization.js","sourceRoot":"","sources":["../../../src/utilities/fieldValueLocalization.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"fieldValueLocalization.js","sourceRoot":"","sources":["../../../src/utilities/fieldValueLocalization.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgDA;;;;;;;;GAQG;AACH,SAAgB,WAAW,CACzB,KAAkD;IAElD,OAAO,YAAY,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;AAC9E,CAAC;AAJD,kCAIC;AAeD;;;;;;;;;GASG;AACH,SAAgB,oCAAoC,CAClD,KAAkD,EAClD,KAAc;IAEd,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE;QACtB,MAAM,cAAc,GAAG,KAA4B,CAAC;QAEpD,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,CACvC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CACzC,CAAC;KACH;IAED,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AACxC,CAAC;AAbD,oFAaC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,oCAAoC,CAClD,KAAkD,EAClD,wBAAkD;;IAElD,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE;QACtB,OAAO,MAAM,CAAC,WAAW,CACvB,wBAAwB,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,E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CAC1C,KAAK,EACL,KAAK,EACL,CAAO,MAAM,EAAE,WAAW,EAAE,EAAE,gDAAC,OAAA,CAAC,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA,GAAA,CACpE,CAAC,CAAC;IACL,CAAC;CAAA;AAbD,wEAaC;AAED;;;;;;;;GAQG;AACH,SAAgB,yBAAyB,CACvC,KAAkD,EAClD,KAAc,EACd,OAAmE;IAEnE,MAAM,OAAO,GAAG,oCAAoC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACnE,KAAK,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE;QACvC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;KACxB;AACH,CAAC;AATD,8DASC;AAED;;;;;;;;GAQG;AACH,SAAsB,8BAA8B,CAClD,KAAkD,EAClD,KAAc,EACd,OAA4E;;QAE5E,MAAM,OAAO,GAAG,oCAAoC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACnE,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAChF,CAAC;CAAA;AAPD,wEAOC"}
|
|
@@ -15,7 +15,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.everyNodeAsync = exports.everyNode = exports.someNodeAsync = exports.someNode = exports.reduceNodesAsync = exports.reduceNodes = exports.filterNodesAsync = exports.filterNodes = exports.findAllNodesAsync = exports.findAllNodes = exports.mapNodesAsync = exports.mapNodes = exports.
|
|
18
|
+
exports.everyNodeAsync = exports.everyNode = exports.someNodeAsync = exports.someNode = exports.reduceNodesAsync = exports.reduceNodes = exports.filterNodesAsync = exports.filterNodes = exports.findAllNodesAsync = exports.findAllNodes = exports.mapNodesAsync = exports.mapNodes = exports.forEachNodeAsync = exports.forEachNode = void 0;
|
|
19
19
|
/**
|
|
20
20
|
* Check if a value has children property that is an array
|
|
21
21
|
*/
|
|
@@ -33,14 +33,14 @@ function hasChildren(node) {
|
|
|
33
33
|
* @param node - The root node to start visiting from
|
|
34
34
|
* @param visitor - Synchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
|
|
35
35
|
*/
|
|
36
|
-
function
|
|
36
|
+
function forEachNode(node, visitor, parent = null, path = []) {
|
|
37
37
|
// Visit current node
|
|
38
38
|
visitor(node, parent, path);
|
|
39
39
|
// Recursively visit children
|
|
40
40
|
if (hasChildren(node)) {
|
|
41
41
|
for (let index = 0; index < node.children.length; index++) {
|
|
42
42
|
const child = node.children[index];
|
|
43
|
-
|
|
43
|
+
forEachNode(child, visitor, node, [
|
|
44
44
|
...path,
|
|
45
45
|
'children',
|
|
46
46
|
index,
|
|
@@ -48,7 +48,7 @@ function visitNodes(node, visitor, parent = null, path = []) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
exports.
|
|
51
|
+
exports.forEachNode = forEachNode;
|
|
52
52
|
/**
|
|
53
53
|
* Visit every node in the Structured Text tree, calling the visitor function for each.
|
|
54
54
|
* Uses pre-order traversal (parent is visited before its children).
|
|
@@ -58,7 +58,7 @@ exports.visitNodes = visitNodes;
|
|
|
58
58
|
* @param visitor - Asynchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
|
|
59
59
|
* @returns Promise that resolves when all nodes have been visited
|
|
60
60
|
*/
|
|
61
|
-
function
|
|
61
|
+
function forEachNodeAsync(node, visitor, parent = null, path = []) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
63
|
// Visit current node
|
|
64
64
|
yield visitor(node, parent, path);
|
|
@@ -66,7 +66,7 @@ function visitNodesAsync(node, visitor, parent = null, path = []) {
|
|
|
66
66
|
if (hasChildren(node)) {
|
|
67
67
|
for (let index = 0; index < node.children.length; index++) {
|
|
68
68
|
const child = node.children[index];
|
|
69
|
-
yield
|
|
69
|
+
yield forEachNodeAsync(child, visitor, node, [
|
|
70
70
|
...path,
|
|
71
71
|
'children',
|
|
72
72
|
index,
|
|
@@ -75,7 +75,7 @@ function visitNodesAsync(node, visitor, parent = null, path = []) {
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
exports.
|
|
78
|
+
exports.forEachNodeAsync = forEachNodeAsync;
|
|
79
79
|
/**
|
|
80
80
|
* Transform nodes in the Structured Text tree by applying a mapping function.
|
|
81
81
|
* Creates a new tree structure with transformed nodes while preserving the Structured Text tree hierarchy.
|
|
@@ -143,7 +143,7 @@ exports.mapNodesAsync = mapNodesAsync;
|
|
|
143
143
|
*/
|
|
144
144
|
function findAllNodes(node, predicate, parent = null, path = []) {
|
|
145
145
|
const results = [];
|
|
146
|
-
|
|
146
|
+
forEachNode(node, (currentNode, currentParent, currentPath) => {
|
|
147
147
|
if (predicate(currentNode, currentParent, currentPath)) {
|
|
148
148
|
results.push({ node: currentNode, path: currentPath });
|
|
149
149
|
}
|
|
@@ -163,7 +163,7 @@ exports.findAllNodes = findAllNodes;
|
|
|
163
163
|
function findAllNodesAsync(node, predicate, parent = null, path = []) {
|
|
164
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
165
|
const results = [];
|
|
166
|
-
yield
|
|
166
|
+
yield forEachNodeAsync(node, (currentNode, currentParent, currentPath) => __awaiter(this, void 0, void 0, function* () {
|
|
167
167
|
if (yield predicate(currentNode, currentParent, currentPath)) {
|
|
168
168
|
results.push({ node: currentNode, path: currentPath });
|
|
169
169
|
}
|
|
@@ -246,7 +246,7 @@ exports.filterNodesAsync = filterNodesAsync;
|
|
|
246
246
|
*/
|
|
247
247
|
function reduceNodes(node, reducer, initialValue, parent = null, path = []) {
|
|
248
248
|
let accumulator = initialValue;
|
|
249
|
-
|
|
249
|
+
forEachNode(node, (currentNode, currentParent, currentPath) => {
|
|
250
250
|
accumulator = reducer(accumulator, currentNode, currentParent, currentPath);
|
|
251
251
|
}, parent, path);
|
|
252
252
|
return accumulator;
|
|
@@ -267,7 +267,7 @@ exports.reduceNodes = reduceNodes;
|
|
|
267
267
|
function reduceNodesAsync(node, reducer, initialValue, parent = null, path = []) {
|
|
268
268
|
return __awaiter(this, void 0, void 0, function* () {
|
|
269
269
|
let accumulator = initialValue;
|
|
270
|
-
yield
|
|
270
|
+
yield forEachNodeAsync(node, (currentNode, currentParent, currentPath) => __awaiter(this, void 0, void 0, function* () {
|
|
271
271
|
accumulator = yield reducer(accumulator, currentNode, currentParent, currentPath);
|
|
272
272
|
}), parent, path);
|
|
273
273
|
return accumulator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structuredText.js","sourceRoot":"","sources":["../../../src/utilities/structuredText.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;AAqDH;;GAEG;AACH,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,UAAU,IAAI,IAAI;QAClB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAC7B,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,
|
|
1
|
+
{"version":3,"file":"structuredText.js","sourceRoot":"","sources":["../../../src/utilities/structuredText.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;AAqDH;;GAEG;AACH,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,UAAU,IAAI,IAAI;QAClB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAC7B,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,WAAW,CAC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S,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IAC7D,CAAC,EACD,MAAM,EACN,IAAI,CACL,CAAC;AACJ,CAAC;AAlBD,8BAkBC;AAED;;;;;;;;GAQG;AACH,SAAsB,cAAc,CAClC,IAAO,EACP,SAA6C,EAC7C,SAAmC,IAAI,EACvC,OAAiB,EAAE;;QAEnB,OAAO,CAAC,CAAC,MAAM,aAAa,CAC1B,IAAI,EACJ,CACE,WAA8B,EAC9B,aAAuC,EACvC,WAAqB,EACrB,EAAE;YACF,OAAO,CAAC,CAAC,MAAM,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;QACrE,CAAC,CAAA,EACD,MAAM,EACN,IAAI,CACL,CAAC,CAAC;IACL,CAAC;CAAA;AAlBD,wCAkBC"}
|
|
@@ -59,7 +59,7 @@ export type RichTextFieldValueAsRequest = BlockItemInARequest[] | null;
|
|
|
59
59
|
/**
|
|
60
60
|
* Modular Content field value with nested blocks - array of fully populated block objects
|
|
61
61
|
*/
|
|
62
|
-
export type
|
|
62
|
+
export type RichTextFieldValueWithNestedBlocks = SchemaTypes.Item[] | null;
|
|
63
63
|
/**
|
|
64
64
|
* =============================================================================
|
|
65
65
|
* TYPE GUARDS - Runtime validation functions
|
|
@@ -79,7 +79,7 @@ export declare function isRichTextFieldValueAsRequest(value: unknown): value is
|
|
|
79
79
|
* Type guard for Modular Content field values with nested blocks (?nested=true format).
|
|
80
80
|
* Ensures all blocks are full SchemaTypes.Item objects with complete data.
|
|
81
81
|
*/
|
|
82
|
-
export declare function
|
|
82
|
+
export declare function isRichTextFieldValueWithNestedBlocks(value: unknown): value is RichTextFieldValueWithNestedBlocks;
|
|
83
83
|
import type { RichTextEditorConfiguration } from './appearance/rich_text';
|
|
84
84
|
import type { RichTextBlocksValidator } from './validators/rich_text_blocks';
|
|
85
85
|
import type { SizeValidator } from './validators/size';
|
|
@@ -34,7 +34,7 @@ export function isRichTextFieldValueAsRequest(value) {
|
|
|
34
34
|
* Type guard for Modular Content field values with nested blocks (?nested=true format).
|
|
35
35
|
* Ensures all blocks are full SchemaTypes.Item objects with complete data.
|
|
36
36
|
*/
|
|
37
|
-
export function
|
|
37
|
+
export function isRichTextFieldValueWithNestedBlocks(value) {
|
|
38
38
|
if (value === null)
|
|
39
39
|
return true;
|
|
40
40
|
if (!Array.isArray(value))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich_text.js","sourceRoot":"","sources":["../../../src/fieldTypes/rich_text.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,aAAa,EACb,mBAAmB,EACnB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAqExB;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAC1E,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAC3C,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,yCAAyC;QACzC,IAAI,eAAe,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAExC,0DAA0D;QAC1D,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"rich_text.js","sourceRoot":"","sources":["../../../src/fieldTypes/rich_text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68
|
* Single Block field value with nested block - fully populated block object
|
|
69
69
|
*/
|
|
70
|
-
export type
|
|
70
|
+
export type SingleBlockFieldValueWithNestedBlocks = SchemaTypes.Item | null;
|
|
71
71
|
/**
|
|
72
72
|
* =============================================================================
|
|
73
73
|
* SHARED UTILITY FUNCTIONS
|
|
@@ -107,7 +107,7 @@ export declare function isSingleBlockFieldValueAsRequest(value: unknown): value
|
|
|
107
107
|
* Type guard for Single Block field values with nested blocks (?nested=true format).
|
|
108
108
|
* Ensures block is a full SchemaTypes.Item object with complete data.
|
|
109
109
|
*/
|
|
110
|
-
export declare function
|
|
110
|
+
export declare function isSingleBlockFieldValueWithNestedBlocks(value: unknown): value is SingleBlockFieldValueWithNestedBlocks;
|
|
111
111
|
import type { FramedSingleBlockEditorConfiguration } from './appearance/framed_single_block';
|
|
112
112
|
import type { FramelessSingleBlockEditorConfiguration } from './appearance/frameless_single_block';
|
|
113
113
|
import type { RequiredValidator } from './validators/required';
|
|
@@ -54,7 +54,7 @@ export function isSingleBlockFieldValueAsRequest(value) {
|
|
|
54
54
|
* Type guard for Single Block field values with nested blocks (?nested=true format).
|
|
55
55
|
* Ensures block is a full SchemaTypes.Item object with complete data.
|
|
56
56
|
*/
|
|
57
|
-
export function
|
|
57
|
+
export function isSingleBlockFieldValueWithNestedBlocks(value) {
|
|
58
58
|
if (value === null)
|
|
59
59
|
return true;
|
|
60
60
|
// Must be a full object with ID (nested format always includes complete block objects)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single_block.js","sourceRoot":"","sources":["../../../src/fieldTypes/single_block.ts"],"names":[],"mappings":"AAiFA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAOD;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK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C/E,CAAC;AAED;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAC9C,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,yCAAyC;IACzC,IAAI,eAAe,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAExC,0DAA0D;IAC1D,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uCAAuC,CACrD,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,uFAAuF;IACvF,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -67,27 +67,27 @@ export type DocumentAsRequest = {
|
|
|
67
67
|
/**
|
|
68
68
|
* Variant of 'block' structured text node for ?nested=true API responses
|
|
69
69
|
*/
|
|
70
|
-
export type
|
|
70
|
+
export type BlockWithNestedBlocks = Omit<Block, 'item'> & {
|
|
71
71
|
item: SchemaTypes.Item;
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
74
74
|
* Variant of 'inlineBlock' structured text node for ?nested=true API responses
|
|
75
75
|
*/
|
|
76
|
-
export type
|
|
76
|
+
export type InlineBlockWithNestedBlocks = Omit<InlineBlock, 'item'> & {
|
|
77
77
|
item: SchemaTypes.Item;
|
|
78
78
|
};
|
|
79
79
|
/**
|
|
80
80
|
* Generic type to transform a node that might be containing a 'block' or 'inlineBlock' as a (deeply nested) children to it's variant for ?nested=true API responses
|
|
81
81
|
*/
|
|
82
|
-
export type
|
|
82
|
+
export type NodeWithNestedBlocks<T> = WithMappedChildren<T, DeepMapVariants<T extends {
|
|
83
83
|
children: infer C;
|
|
84
|
-
} ? C : never,
|
|
84
|
+
} ? C : never, BlockWithNestedBlocks, InlineBlockWithNestedBlocks>>;
|
|
85
85
|
/**
|
|
86
86
|
* Variant of Structured Text document for ?nested=true API responses
|
|
87
87
|
*/
|
|
88
|
-
export type
|
|
88
|
+
export type DocumentWithNestedBlocks = {
|
|
89
89
|
schema: 'dast';
|
|
90
|
-
document:
|
|
90
|
+
document: NodeWithNestedBlocks<Root>;
|
|
91
91
|
};
|
|
92
92
|
/**
|
|
93
93
|
* =============================================================================
|
|
@@ -100,7 +100,7 @@ export type DocumentWithResolvedBlocks = {
|
|
|
100
100
|
*/
|
|
101
101
|
export type StructuredTextFieldValue = Document | null;
|
|
102
102
|
export type StructuredTextFieldValueAsRequest = DocumentAsRequest | null;
|
|
103
|
-
export type
|
|
103
|
+
export type StructuredTextFieldValueWithNestedBlocks = DocumentWithNestedBlocks | null;
|
|
104
104
|
/**
|
|
105
105
|
* Type guard for basic structured text field values (blocks as string IDs only).
|
|
106
106
|
* Checks for the expected structure and ensures all block/inlineBlock nodes have string IDs.
|
|
@@ -115,7 +115,7 @@ export declare function isStructuredTextFieldValueAsRequest(value: unknown): val
|
|
|
115
115
|
* Type guard for structured text field values with nested blocks (?nested=true format).
|
|
116
116
|
* Ensures all block/inlineBlock nodes have full SchemaTypes.Item objects.
|
|
117
117
|
*/
|
|
118
|
-
export declare function
|
|
118
|
+
export declare function isStructuredTextFieldValueWithNestedBlocks(value: unknown): value is StructuredTextFieldValueWithNestedBlocks;
|
|
119
119
|
/**
|
|
120
120
|
* =============================================================================
|
|
121
121
|
* SHARED TRANSFORMATION UTILITIES
|