@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
|
@@ -65,7 +65,7 @@ export function isStructuredTextFieldValueAsRequest(value) {
|
|
|
65
65
|
* Type guard for structured text field values with nested blocks (?nested=true format).
|
|
66
66
|
* Ensures all block/inlineBlock nodes have full SchemaTypes.Item objects.
|
|
67
67
|
*/
|
|
68
|
-
export function
|
|
68
|
+
export function isStructuredTextFieldValueWithNestedBlocks(value) {
|
|
69
69
|
if (value === null)
|
|
70
70
|
return true;
|
|
71
71
|
if (!isValidDocumentStructure(value)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured_text.js","sourceRoot":"","sources":["../../../src/fieldTypes/structured_text.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,OAAO,EACP,aAAa,EACb,MAAM,GACP,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAEL,aAAa,EACb,mBAAmB,EACnB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AA8HxB;;;GAGG;AACH,SAAS,wBAAwB,CAC/B,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,QAAQ,IAAI,KAAK;QACjB,UAAU,IAAI,KAAK,CACpB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,S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
|
|
1
|
+
{"version":3,"file":"structured_text.js","sourceRoot":"","sources":["../../../src/fieldTypes/structured_text.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,OAAO,EACP,aAAa,EACb,MAAM,GACP,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAEL,aAAa,EACb,mBAAmB,EACnB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AA8HxB;;;GAGG;AACH,SAAS,wBAAwB,CAC/B,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,QAAQ,IAAI,KAAK;QACjB,UAAU,IAAI,KAAK,CACpB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,qBAAqB,CAC5B,IAAa,EACb,QAQY;IAEZ,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE;QACrC,wEAAwE;QACxE,IACE,MAAM,CAAC,WAAW,CAAC;YACnB,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC,EACpD;YACA,OAAO,QAAQ,CAAC,WAAW,CAAC,CAAC;SAC9B;QACD,qDAAqD;QACrD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE;QACpC,OAAO,KAAK,CAAC;KACd;IAED,8DAA8D;IAC9D,OAAO,qBAAqB,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;QACpD,OAAO,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,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,eAAe,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAEvC,qCAAqC;QACrC,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,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,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -62,7 +62,7 @@ export class Client {
|
|
|
62
62
|
return this.config.baseUrl || Client.defaultBaseUrl;
|
|
63
63
|
}
|
|
64
64
|
request(options) {
|
|
65
|
-
return request(Object.assign(Object.assign(Object.assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v5.1.
|
|
65
|
+
return 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
|
|
66
66
|
? { 'X-Environment': this.config.environment }
|
|
67
67
|
: {})), { 'X-API-Version': '3' }), fetchJobResult: (jobId) => {
|
|
68
68
|
return this.jobResultsFetcher
|
|
@@ -30,16 +30,21 @@ type FieldAttributesForFieldType<SourceType, FieldType extends RawFieldAttribute
|
|
|
30
30
|
type GenericFieldAttributes<SourceType> = FieldAttributesForFieldType<SourceType, 'boolean', BooleanFieldValue, BooleanFieldValidators, BooleanFieldAppearance> | FieldAttributesForFieldType<SourceType, 'color', ColorFieldValue, ColorFieldValidators, ColorFieldAppearance> | FieldAttributesForFieldType<SourceType, 'date', DateFieldValue, DateFieldValidators, DateFieldAppearance> | FieldAttributesForFieldType<SourceType, 'date_time', DateTimeFieldValue, DateTimeFieldValidators, DateTimeFieldAppearance> | FieldAttributesForFieldType<SourceType, 'file', null, FileFieldValidators, FileFieldAppearance> | FieldAttributesForFieldType<SourceType, 'float', FloatFieldValue, FloatFieldValidators, FloatFieldAppearance> | FieldAttributesForFieldType<SourceType, 'gallery', null, GalleryFieldValidators, GalleryFieldAppearance> | FieldAttributesForFieldType<SourceType, 'integer', IntegerFieldValue, IntegerFieldValidators, IntegerFieldAppearance> | FieldAttributesForFieldType<SourceType, 'json', JsonFieldValue, JsonFieldValidators, JsonFieldAppearance> | FieldAttributesForFieldType<SourceType, 'lat_lon', LocationFieldValue, LocationFieldValidators, LocationFieldAppearance> | FieldAttributesForFieldType<SourceType, 'link', null, LinkFieldValidators, LinkFieldAppearance> | FieldAttributesForFieldType<SourceType, 'links', null, LinksFieldValidators, LinksFieldAppearance> | FieldAttributesForFieldType<SourceType, 'rich_text', null, RichTextFieldValidators, RichTextFieldAppearance> | FieldAttributesForFieldType<SourceType, 'seo', null, SeoFieldValidators, SeoFieldAppearance> | FieldAttributesForFieldType<SourceType, 'single_block', null, SingleBlockFieldValidators, SingleBlockFieldAppearance> | FieldAttributesForFieldType<SourceType, 'slug', null, SlugFieldValidators, SlugFieldAppearance> | FieldAttributesForFieldType<SourceType, 'string', StringFieldValue, StringFieldValidators, StringFieldAppearance> | FieldAttributesForFieldType<SourceType, 'structured_text', null, StructuredTextFieldValidators, StructuredTextFieldAppearance> | FieldAttributesForFieldType<SourceType, 'text', TextFieldValue, TextFieldValidators, TextFieldAppearance> | FieldAttributesForFieldType<SourceType, 'video', null, VideoFieldValidators, VideoFieldAppearance>;
|
|
31
31
|
export type FieldAttributes = GenericFieldAttributes<RawFieldAttributes>;
|
|
32
32
|
export type Field = RawField;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
type LocalizedFieldCreateConfigForFieldType<SourceType, FieldType extends RawFieldAttributes['field_type'], FieldValue, FieldValidators, FieldAppearance> = Omit<SourceType, 'field_type' | 'default_value' | 'validators' | 'appearance' | 'localized'> & {
|
|
34
|
+
field_type: FieldType;
|
|
35
|
+
localized: true;
|
|
36
|
+
default_value?: Record<string, FieldValue>;
|
|
37
|
+
validators?: FieldValidators;
|
|
38
|
+
appearance?: FieldAppearanceConfig<FieldAppearance>;
|
|
39
|
+
};
|
|
40
|
+
type NonLocalizedFieldCreateConfigForFieldType<SourceType, FieldType extends RawFieldAttributes['field_type'], FieldValue, FieldValidators, FieldAppearance> = Omit<SourceType, 'field_type' | 'default_value' | 'validators' | 'appearance' | 'localized'> & {
|
|
38
41
|
field_type: FieldType;
|
|
39
|
-
|
|
42
|
+
localized?: false;
|
|
43
|
+
default_value?: FieldValue;
|
|
40
44
|
validators?: FieldValidators;
|
|
41
45
|
appearance?: FieldAppearanceConfig<FieldAppearance>;
|
|
42
46
|
};
|
|
47
|
+
type FieldCreateConfigForFieldType<SourceType, FieldType extends RawFieldAttributes['field_type'], FieldValue, FieldValidators, FieldAppearance> = LocalizedFieldCreateConfigForFieldType<SourceType, FieldType, FieldValue, FieldValidators, FieldAppearance> | NonLocalizedFieldCreateConfigForFieldType<SourceType, FieldType, FieldValue, FieldValidators, FieldAppearance>;
|
|
43
48
|
type FieldCreateConfig<SourceType> = FieldCreateConfigForFieldType<SourceType, 'boolean', BooleanFieldValue, BooleanFieldValidators, BooleanFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'color', ColorFieldValue, ColorFieldValidators, ColorFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'date', DateFieldValue, DateFieldValidators, DateFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'date_time', DateTimeFieldValue, DateTimeFieldValidators, DateTimeFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'file', null, FileFieldValidators, FileFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'float', FloatFieldValue, FloatFieldValidators, FloatFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'gallery', null, GalleryFieldValidators, GalleryFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'integer', IntegerFieldValue, IntegerFieldValidators, IntegerFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'json', JsonFieldValue, JsonFieldValidators, JsonFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'lat_lon', LocationFieldValue, LocationFieldValidators, LocationFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'link', null, LinkFieldValidators, LinkFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'links', null, LinksFieldValidators, LinksFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'rich_text', null, RichTextFieldValidators, RichTextFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'seo', null, SeoFieldValidators, SeoFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'single_block', null, SingleBlockFieldValidators, SingleBlockFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'slug', null, SlugFieldValidators, SlugFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'string', StringFieldValue, StringFieldValidators, StringFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'structured_text', null, StructuredTextFieldValidators, StructuredTextFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'text', TextFieldValue, TextFieldValidators, TextFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'video', null, VideoFieldValidators, VideoFieldAppearance>;
|
|
44
49
|
export type FieldCreateSchema = Omit<RawFieldCreateSchema, 'data'> & {
|
|
45
50
|
data: Omit<RawFieldCreateSchema['data'], 'attributes'> & {
|
|
@@ -30,16 +30,21 @@ type FieldAttributesForFieldType<SourceType, FieldType extends RawFieldAttribute
|
|
|
30
30
|
type GenericFieldAttributes<SourceType> = FieldAttributesForFieldType<SourceType, 'boolean', BooleanFieldValue, BooleanFieldValidators, BooleanFieldAppearance> | FieldAttributesForFieldType<SourceType, 'color', ColorFieldValue, ColorFieldValidators, ColorFieldAppearance> | FieldAttributesForFieldType<SourceType, 'date', DateFieldValue, DateFieldValidators, DateFieldAppearance> | FieldAttributesForFieldType<SourceType, 'date_time', DateTimeFieldValue, DateTimeFieldValidators, DateTimeFieldAppearance> | FieldAttributesForFieldType<SourceType, 'file', null, FileFieldValidators, FileFieldAppearance> | FieldAttributesForFieldType<SourceType, 'float', FloatFieldValue, FloatFieldValidators, FloatFieldAppearance> | FieldAttributesForFieldType<SourceType, 'gallery', null, GalleryFieldValidators, GalleryFieldAppearance> | FieldAttributesForFieldType<SourceType, 'integer', IntegerFieldValue, IntegerFieldValidators, IntegerFieldAppearance> | FieldAttributesForFieldType<SourceType, 'json', JsonFieldValue, JsonFieldValidators, JsonFieldAppearance> | FieldAttributesForFieldType<SourceType, 'lat_lon', LocationFieldValue, LocationFieldValidators, LocationFieldAppearance> | FieldAttributesForFieldType<SourceType, 'link', null, LinkFieldValidators, LinkFieldAppearance> | FieldAttributesForFieldType<SourceType, 'links', null, LinksFieldValidators, LinksFieldAppearance> | FieldAttributesForFieldType<SourceType, 'rich_text', null, RichTextFieldValidators, RichTextFieldAppearance> | FieldAttributesForFieldType<SourceType, 'seo', null, SeoFieldValidators, SeoFieldAppearance> | FieldAttributesForFieldType<SourceType, 'single_block', null, SingleBlockFieldValidators, SingleBlockFieldAppearance> | FieldAttributesForFieldType<SourceType, 'slug', null, SlugFieldValidators, SlugFieldAppearance> | FieldAttributesForFieldType<SourceType, 'string', StringFieldValue, StringFieldValidators, StringFieldAppearance> | FieldAttributesForFieldType<SourceType, 'structured_text', null, StructuredTextFieldValidators, StructuredTextFieldAppearance> | FieldAttributesForFieldType<SourceType, 'text', TextFieldValue, TextFieldValidators, TextFieldAppearance> | FieldAttributesForFieldType<SourceType, 'video', null, VideoFieldValidators, VideoFieldAppearance>;
|
|
31
31
|
export type FieldAttributes = GenericFieldAttributes<RawFieldAttributes>;
|
|
32
32
|
export type Field = GenericFieldAttributes<RawField>;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
type LocalizedFieldCreateConfigForFieldType<SourceType, FieldType extends RawFieldAttributes['field_type'], FieldValue, FieldValidators, FieldAppearance> = Omit<SourceType, 'field_type' | 'default_value' | 'validators' | 'appearance' | 'localized'> & {
|
|
34
|
+
field_type: FieldType;
|
|
35
|
+
localized: true;
|
|
36
|
+
default_value?: Record<string, FieldValue>;
|
|
37
|
+
validators?: FieldValidators;
|
|
38
|
+
appearance?: FieldAppearanceConfig<FieldAppearance>;
|
|
39
|
+
};
|
|
40
|
+
type NonLocalizedFieldCreateConfigForFieldType<SourceType, FieldType extends RawFieldAttributes['field_type'], FieldValue, FieldValidators, FieldAppearance> = Omit<SourceType, 'field_type' | 'default_value' | 'validators' | 'appearance' | 'localized'> & {
|
|
38
41
|
field_type: FieldType;
|
|
39
|
-
|
|
42
|
+
localized?: false;
|
|
43
|
+
default_value?: FieldValue;
|
|
40
44
|
validators?: FieldValidators;
|
|
41
45
|
appearance?: FieldAppearanceConfig<FieldAppearance>;
|
|
42
46
|
};
|
|
47
|
+
type FieldCreateConfigForFieldType<SourceType, FieldType extends RawFieldAttributes['field_type'], FieldValue, FieldValidators, FieldAppearance> = LocalizedFieldCreateConfigForFieldType<SourceType, FieldType, FieldValue, FieldValidators, FieldAppearance> | NonLocalizedFieldCreateConfigForFieldType<SourceType, FieldType, FieldValue, FieldValidators, FieldAppearance>;
|
|
43
48
|
type FieldCreateConfig<SourceType> = FieldCreateConfigForFieldType<SourceType, 'boolean', BooleanFieldValue, BooleanFieldValidators, BooleanFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'color', ColorFieldValue, ColorFieldValidators, ColorFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'date', DateFieldValue, DateFieldValidators, DateFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'date_time', DateTimeFieldValue, DateTimeFieldValidators, DateTimeFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'file', null, FileFieldValidators, FileFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'float', FloatFieldValue, FloatFieldValidators, FloatFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'gallery', null, GalleryFieldValidators, GalleryFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'integer', IntegerFieldValue, IntegerFieldValidators, IntegerFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'json', JsonFieldValue, JsonFieldValidators, JsonFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'lat_lon', LocationFieldValue, LocationFieldValidators, LocationFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'link', null, LinkFieldValidators, LinkFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'links', null, LinksFieldValidators, LinksFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'rich_text', null, RichTextFieldValidators, RichTextFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'seo', null, SeoFieldValidators, SeoFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'single_block', null, SingleBlockFieldValidators, SingleBlockFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'slug', null, SlugFieldValidators, SlugFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'string', StringFieldValue, StringFieldValidators, StringFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'structured_text', null, StructuredTextFieldValidators, StructuredTextFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'text', TextFieldValue, TextFieldValidators, TextFieldAppearance> | FieldCreateConfigForFieldType<SourceType, 'video', null, VideoFieldValidators, VideoFieldAppearance>;
|
|
44
49
|
export type FieldCreateSchema = FieldCreateConfig<RawFieldCreateSchema>;
|
|
45
50
|
/**
|
|
@@ -1,12 +1,58 @@
|
|
|
1
1
|
import type * as SchemaTypes from '../generated/SchemaTypes';
|
|
2
2
|
import type * as SimpleSchemaTypes from '../generated/SimpleSchemaTypes';
|
|
3
3
|
/**
|
|
4
|
+
* Represents a localized field value in DatoCMS.
|
|
5
|
+
*
|
|
4
6
|
* In DatoCMS, fields can be localized. In this scenario, their value contains values
|
|
5
7
|
* for various locales structured as an object, such as
|
|
6
|
-
`{ "en": "Hello", "it": "Ciao" }`
|
|
8
|
+
* `{ "en": "Hello", "it": "Ciao" }`
|
|
7
9
|
*/
|
|
8
10
|
export type LocalizedFieldValue = Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Determines whether a DatoCMS field is localized or not.
|
|
13
|
+
*
|
|
14
|
+
* This function handles both full Schema field objects and simplified Schema field objects
|
|
15
|
+
* by checking the appropriate property based on the object structure.
|
|
16
|
+
*
|
|
17
|
+
* @param field - The DatoCMS field definition (either full or simple schema)
|
|
18
|
+
* @returns true if the field is localized, false otherwise
|
|
19
|
+
*/
|
|
9
20
|
export declare function isLocalized(field: SchemaTypes.Field | SimpleSchemaTypes.Field): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* A normalized entry that represents a single value from either a localized or non-localized field.
|
|
23
|
+
*
|
|
24
|
+
* For localized fields, each locale produces one entry with `locale` set to the locale code (e.g., "en", "it").
|
|
25
|
+
* For non-localized fields, there's one entry with `locale` set to `undefined`.
|
|
26
|
+
*
|
|
27
|
+
* This uniform structure allows the same processing logic to work with both field types.
|
|
28
|
+
*/
|
|
29
|
+
export type PossiblyLocalizedEntry = {
|
|
30
|
+
locale: string | undefined;
|
|
31
|
+
value: unknown;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Converts a field value (localized or non-localized) into a uniform array of entries.
|
|
35
|
+
*
|
|
36
|
+
* This function normalizes the handling of field values by converting them into a consistent
|
|
37
|
+
* array format, regardless of whether the field is localized or not.
|
|
38
|
+
*
|
|
39
|
+
* @param field - The DatoCMS field definition that determines localization behavior
|
|
40
|
+
* @param value - The field value to convert (either a localized object or direct value)
|
|
41
|
+
* @returns Array of entries where each entry contains a locale (string for localized, undefined for non-localized) and the corresponding value
|
|
42
|
+
*/
|
|
43
|
+
export declare function fieldValueToPossiblyLocalizedEntries(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown): PossiblyLocalizedEntry[];
|
|
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
|
+
export declare function possiblyLocalizedEntriesToFieldValue(field: SchemaTypes.Field | SimpleSchemaTypes.Field, possiblyLocalizedEntries: PossiblyLocalizedEntry[]): any;
|
|
10
56
|
/**
|
|
11
57
|
* Maps localized field values using a provided mapping function.
|
|
12
58
|
* For localized fields, applies the mapping function to each locale value.
|
|
@@ -18,9 +64,7 @@ export declare function isLocalized(field: SchemaTypes.Field | SimpleSchemaTypes
|
|
|
18
64
|
* @param mapFn - The function to apply to each locale value or the direct value
|
|
19
65
|
* @returns The mapped value with the same structure as the input
|
|
20
66
|
*/
|
|
21
|
-
export declare function mapLocalizedFieldValues<T>(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, mapFn: (locale: string | undefined, localeValue: unknown) => T):
|
|
22
|
-
[k: string]: T;
|
|
23
|
-
};
|
|
67
|
+
export declare function mapLocalizedFieldValues<T>(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, mapFn: (locale: string | undefined, localeValue: unknown) => T): any;
|
|
24
68
|
/**
|
|
25
69
|
* Maps localized field values using a provided mapping function (async version).
|
|
26
70
|
* For localized fields, applies the mapping function to each locale value.
|
|
@@ -32,9 +76,7 @@ export declare function mapLocalizedFieldValues<T>(field: SchemaTypes.Field | Si
|
|
|
32
76
|
* @param mapFn - The function to apply to each locale value or the direct value
|
|
33
77
|
* @returns The mapped value with the same structure as the input
|
|
34
78
|
*/
|
|
35
|
-
export declare function mapLocalizedFieldValuesAsync<T>(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, mapFn: (locale: string | undefined, localeValue: unknown) => Promise<T>): Promise<
|
|
36
|
-
[k: string]: unknown;
|
|
37
|
-
}>;
|
|
79
|
+
export declare function mapLocalizedFieldValuesAsync<T>(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, mapFn: (locale: string | undefined, localeValue: unknown) => Promise<T>): Promise<any>;
|
|
38
80
|
/**
|
|
39
81
|
* Filters localized field values using a provided filter function.
|
|
40
82
|
* For localized fields, filters each locale value.
|
|
@@ -45,7 +87,7 @@ export declare function mapLocalizedFieldValuesAsync<T>(field: SchemaTypes.Field
|
|
|
45
87
|
* @param filterFn - The function to test each locale value or the direct value
|
|
46
88
|
* @returns The filtered value with the same structure as the input
|
|
47
89
|
*/
|
|
48
|
-
export declare function filterLocalizedFieldValues(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, filterFn: (locale: string | undefined, localeValue: unknown) => boolean):
|
|
90
|
+
export declare function filterLocalizedFieldValues(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, filterFn: (locale: string | undefined, localeValue: unknown) => boolean): any;
|
|
49
91
|
/**
|
|
50
92
|
* Filters localized field values using a provided filter function (async version).
|
|
51
93
|
* For localized fields, filters each locale value.
|
|
@@ -56,7 +98,7 @@ export declare function filterLocalizedFieldValues(field: SchemaTypes.Field | Si
|
|
|
56
98
|
* @param filterFn - The function to test each locale value or the direct value
|
|
57
99
|
* @returns The filtered value with the same structure as the input
|
|
58
100
|
*/
|
|
59
|
-
export declare function filterLocalizedFieldValuesAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, filterFn: (locale: string | undefined, localeValue: unknown) => Promise<boolean>): Promise<
|
|
101
|
+
export declare function filterLocalizedFieldValuesAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, filterFn: (locale: string | undefined, localeValue: unknown) => Promise<boolean>): Promise<any>;
|
|
60
102
|
/**
|
|
61
103
|
* Tests whether at least one localized field value passes the test implemented by the provided function.
|
|
62
104
|
* For localized fields, tests each locale value.
|
|
@@ -7,9 +7,53 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Determines whether a DatoCMS field is localized or not.
|
|
12
|
+
*
|
|
13
|
+
* This function handles both full Schema field objects and simplified Schema field objects
|
|
14
|
+
* by checking the appropriate property based on the object structure.
|
|
15
|
+
*
|
|
16
|
+
* @param field - The DatoCMS field definition (either full or simple schema)
|
|
17
|
+
* @returns true if the field is localized, false otherwise
|
|
18
|
+
*/
|
|
10
19
|
export function isLocalized(field) {
|
|
11
20
|
return 'attributes' in field ? field.attributes.localized : field.localized;
|
|
12
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Converts a field value (localized or non-localized) into a uniform array of entries.
|
|
24
|
+
*
|
|
25
|
+
* This function normalizes the handling of field values by converting them into a consistent
|
|
26
|
+
* array format, regardless of whether the field is localized or not.
|
|
27
|
+
*
|
|
28
|
+
* @param field - The DatoCMS field definition that determines localization behavior
|
|
29
|
+
* @param value - The field value to convert (either a localized object or direct value)
|
|
30
|
+
* @returns Array of entries where each entry contains a locale (string for localized, undefined for non-localized) and the corresponding value
|
|
31
|
+
*/
|
|
32
|
+
export function fieldValueToPossiblyLocalizedEntries(field, value) {
|
|
33
|
+
if (isLocalized(field)) {
|
|
34
|
+
const localizedValue = value;
|
|
35
|
+
return Object.entries(localizedValue).map(([locale, value]) => ({ locale, value }));
|
|
36
|
+
}
|
|
37
|
+
return [{ locale: undefined, value }];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Converts an array of possibly localized entries back into the appropriate field value format.
|
|
41
|
+
*
|
|
42
|
+
* This function is the inverse of `fieldValueToPossiblyLocalizedEntries`. It takes a uniform
|
|
43
|
+
* array of entries and converts them back to either a localized object or a direct value,
|
|
44
|
+
* depending on the field's localization setting.
|
|
45
|
+
*
|
|
46
|
+
* @param field - The DatoCMS field definition that determines the output format
|
|
47
|
+
* @param possiblyLocalizedEntries - Array of entries to convert back to field value format
|
|
48
|
+
* @returns Either a localized object (for localized fields) or the direct value (for non-localized fields)
|
|
49
|
+
*/
|
|
50
|
+
export function possiblyLocalizedEntriesToFieldValue(field, possiblyLocalizedEntries) {
|
|
51
|
+
var _a;
|
|
52
|
+
if (isLocalized(field)) {
|
|
53
|
+
return Object.fromEntries(possiblyLocalizedEntries.map(({ locale, value }) => [locale, value]));
|
|
54
|
+
}
|
|
55
|
+
return (_a = possiblyLocalizedEntries[0]) === null || _a === void 0 ? void 0 : _a.value;
|
|
56
|
+
}
|
|
13
57
|
/**
|
|
14
58
|
* Maps localized field values using a provided mapping function.
|
|
15
59
|
* For localized fields, applies the mapping function to each locale value.
|
|
@@ -22,14 +66,12 @@ export function isLocalized(field) {
|
|
|
22
66
|
* @returns The mapped value with the same structure as the input
|
|
23
67
|
*/
|
|
24
68
|
export function mapLocalizedFieldValues(field, value, mapFn) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
return mapFn(undefined, value);
|
|
69
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
70
|
+
const mappedEntries = entries.map(({ locale, value }) => ({
|
|
71
|
+
locale,
|
|
72
|
+
value: mapFn(locale, value),
|
|
73
|
+
}));
|
|
74
|
+
return possiblyLocalizedEntriesToFieldValue(field, mappedEntries);
|
|
33
75
|
}
|
|
34
76
|
/**
|
|
35
77
|
* Maps localized field values using a provided mapping function (async version).
|
|
@@ -44,11 +86,14 @@ export function mapLocalizedFieldValues(field, value, mapFn) {
|
|
|
44
86
|
*/
|
|
45
87
|
export function mapLocalizedFieldValuesAsync(field, value, mapFn) {
|
|
46
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
89
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
90
|
+
const mappedEntries = yield Promise.all(entries.map(({ locale, value }) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
return ({
|
|
92
|
+
locale,
|
|
93
|
+
value: yield mapFn(locale, value),
|
|
94
|
+
});
|
|
95
|
+
})));
|
|
96
|
+
return possiblyLocalizedEntriesToFieldValue(field, mappedEntries);
|
|
52
97
|
});
|
|
53
98
|
}
|
|
54
99
|
/**
|
|
@@ -62,11 +107,13 @@ export function mapLocalizedFieldValuesAsync(field, value, mapFn) {
|
|
|
62
107
|
* @returns The filtered value with the same structure as the input
|
|
63
108
|
*/
|
|
64
109
|
export function filterLocalizedFieldValues(field, value, filterFn) {
|
|
110
|
+
var _a;
|
|
111
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
112
|
+
const filteredEntries = entries.filter(({ locale, value }) => filterFn(locale, value));
|
|
65
113
|
if (isLocalized(field)) {
|
|
66
|
-
|
|
67
|
-
return Object.fromEntries(Object.entries(localizedValue).filter(([locale, value]) => filterFn(locale, value)));
|
|
114
|
+
return possiblyLocalizedEntriesToFieldValue(field, filteredEntries);
|
|
68
115
|
}
|
|
69
|
-
return
|
|
116
|
+
return filteredEntries.length > 0 ? (_a = filteredEntries[0]) === null || _a === void 0 ? void 0 : _a.value : undefined;
|
|
70
117
|
}
|
|
71
118
|
/**
|
|
72
119
|
* Filters localized field values using a provided filter function (async version).
|
|
@@ -79,21 +126,23 @@ export function filterLocalizedFieldValues(field, value, filterFn) {
|
|
|
79
126
|
* @returns The filtered value with the same structure as the input
|
|
80
127
|
*/
|
|
81
128
|
export function filterLocalizedFieldValuesAsync(field, value, filterFn) {
|
|
129
|
+
var _a;
|
|
82
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
132
|
+
const results = yield Promise.all(entries.map(({ locale, value }) => __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
return ({
|
|
134
|
+
locale,
|
|
135
|
+
value,
|
|
136
|
+
passed: yield filterFn(locale, value),
|
|
137
|
+
});
|
|
138
|
+
})));
|
|
139
|
+
const filteredEntries = results
|
|
140
|
+
.filter(({ passed }) => passed)
|
|
141
|
+
.map(({ locale, value }) => ({ locale, value }));
|
|
83
142
|
if (isLocalized(field)) {
|
|
84
|
-
|
|
85
|
-
const results = yield Promise.all(Object.entries(localizedValue).map(([locale, value]) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
return [
|
|
87
|
-
locale,
|
|
88
|
-
value,
|
|
89
|
-
yield filterFn(locale, value),
|
|
90
|
-
];
|
|
91
|
-
})));
|
|
92
|
-
return Object.fromEntries(results
|
|
93
|
-
.filter(([, , passed]) => passed)
|
|
94
|
-
.map(([locale, value]) => [locale, value]));
|
|
143
|
+
return possiblyLocalizedEntriesToFieldValue(field, filteredEntries);
|
|
95
144
|
}
|
|
96
|
-
return
|
|
145
|
+
return filteredEntries.length > 0 ? (_a = filteredEntries[0]) === null || _a === void 0 ? void 0 : _a.value : undefined;
|
|
97
146
|
});
|
|
98
147
|
}
|
|
99
148
|
/**
|
|
@@ -107,11 +156,8 @@ export function filterLocalizedFieldValuesAsync(field, value, filterFn) {
|
|
|
107
156
|
* @returns true if at least one value passes the test, false otherwise
|
|
108
157
|
*/
|
|
109
158
|
export function someLocalizedFieldValues(field, value, testFn) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return Object.entries(localizedValue).some(([locale, value]) => testFn(locale, value));
|
|
113
|
-
}
|
|
114
|
-
return testFn(undefined, value);
|
|
159
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
160
|
+
return entries.some(({ locale, value }) => testFn(locale, value));
|
|
115
161
|
}
|
|
116
162
|
/**
|
|
117
163
|
* Tests whether at least one localized field value passes the test implemented by the provided function (async version).
|
|
@@ -125,12 +171,9 @@ export function someLocalizedFieldValues(field, value, testFn) {
|
|
|
125
171
|
*/
|
|
126
172
|
export function someLocalizedFieldValuesAsync(field, value, testFn) {
|
|
127
173
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return results.some((result) => result);
|
|
132
|
-
}
|
|
133
|
-
return yield testFn(undefined, value);
|
|
174
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
175
|
+
const results = yield Promise.all(entries.map(({ locale, value }) => testFn(locale, value)));
|
|
176
|
+
return results.some((result) => result);
|
|
134
177
|
});
|
|
135
178
|
}
|
|
136
179
|
/**
|
|
@@ -171,14 +214,9 @@ export function everyLocalizedFieldValuesAsync(field, value, testFn) {
|
|
|
171
214
|
* @param visitFn - The function to call for each locale value or the direct value
|
|
172
215
|
*/
|
|
173
216
|
export function visitLocalizedFieldValues(field, value, visitFn) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
visitFn(locale, value);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
visitFn(undefined, value);
|
|
217
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
218
|
+
for (const { locale, value } of entries) {
|
|
219
|
+
visitFn(locale, value);
|
|
182
220
|
}
|
|
183
221
|
}
|
|
184
222
|
/**
|
|
@@ -192,13 +230,8 @@ export function visitLocalizedFieldValues(field, value, visitFn) {
|
|
|
192
230
|
*/
|
|
193
231
|
export function visitLocalizedFieldValuesAsync(field, value, visitFn) {
|
|
194
232
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
yield Promise.all(Object.entries(localizedValue).map(([locale, value]) => __awaiter(this, void 0, void 0, function* () { return yield visitFn(locale, value); })));
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
yield visitFn(undefined, value);
|
|
201
|
-
}
|
|
233
|
+
const entries = fieldValueToPossiblyLocalizedEntries(field, value);
|
|
234
|
+
yield Promise.all(entries.map(({ locale, value }) => visitFn(locale, value)));
|
|
202
235
|
});
|
|
203
236
|
}
|
|
204
237
|
//# sourceMappingURL=fieldValueLocalization.js.map
|
|
@@ -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,MAAM,UAAU,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;AAeD;;;;;;;;;GASG;AACH,MAAM,UAAU,oCAAoC,CAClD,KAAkD,EAClD,KAAc;IAEd,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE;QACtB,MAAM,cAAc,G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AAC;CAAA"}
|
|
@@ -27,7 +27,7 @@ export type NodePredicate<T, R> = (node: AllNodesInTree<T>, parent: AllNodesInTr
|
|
|
27
27
|
* @param node - The root node to start visiting from
|
|
28
28
|
* @param visitor - Synchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
|
|
29
29
|
*/
|
|
30
|
-
export declare function
|
|
30
|
+
export declare function forEachNode<T>(node: T, visitor: NodePredicate<T, void>, parent?: AllNodesInTree<T> | null, path?: TreePath): void;
|
|
31
31
|
/**
|
|
32
32
|
* Visit every node in the Structured Text tree, calling the visitor function for each.
|
|
33
33
|
* Uses pre-order traversal (parent is visited before its children).
|
|
@@ -37,7 +37,7 @@ export declare function visitNodes<T>(node: T, visitor: NodePredicate<T, void>,
|
|
|
37
37
|
* @param visitor - Asynchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
|
|
38
38
|
* @returns Promise that resolves when all nodes have been visited
|
|
39
39
|
*/
|
|
40
|
-
export declare function
|
|
40
|
+
export declare function forEachNodeAsync<T>(node: T, visitor: NodePredicate<T, Promise<void>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<void>;
|
|
41
41
|
/**
|
|
42
42
|
* Transform nodes in the Structured Text tree by applying a mapping function.
|
|
43
43
|
* Creates a new tree structure with transformed nodes while preserving the Structured Text tree hierarchy.
|
|
@@ -30,14 +30,14 @@ function hasChildren(node) {
|
|
|
30
30
|
* @param node - The root node to start visiting from
|
|
31
31
|
* @param visitor - Synchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
|
|
32
32
|
*/
|
|
33
|
-
export function
|
|
33
|
+
export function forEachNode(node, visitor, parent = null, path = []) {
|
|
34
34
|
// Visit current node
|
|
35
35
|
visitor(node, parent, path);
|
|
36
36
|
// Recursively visit children
|
|
37
37
|
if (hasChildren(node)) {
|
|
38
38
|
for (let index = 0; index < node.children.length; index++) {
|
|
39
39
|
const child = node.children[index];
|
|
40
|
-
|
|
40
|
+
forEachNode(child, visitor, node, [
|
|
41
41
|
...path,
|
|
42
42
|
'children',
|
|
43
43
|
index,
|
|
@@ -54,7 +54,7 @@ export function visitNodes(node, visitor, parent = null, path = []) {
|
|
|
54
54
|
* @param visitor - Asynchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
|
|
55
55
|
* @returns Promise that resolves when all nodes have been visited
|
|
56
56
|
*/
|
|
57
|
-
export function
|
|
57
|
+
export function forEachNodeAsync(node, visitor, parent = null, path = []) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
59
|
// Visit current node
|
|
60
60
|
yield visitor(node, parent, path);
|
|
@@ -62,7 +62,7 @@ export function visitNodesAsync(node, visitor, parent = null, path = []) {
|
|
|
62
62
|
if (hasChildren(node)) {
|
|
63
63
|
for (let index = 0; index < node.children.length; index++) {
|
|
64
64
|
const child = node.children[index];
|
|
65
|
-
yield
|
|
65
|
+
yield forEachNodeAsync(child, visitor, node, [
|
|
66
66
|
...path,
|
|
67
67
|
'children',
|
|
68
68
|
index,
|
|
@@ -136,7 +136,7 @@ export function mapNodesAsync(node, mapper, parent = null, path = []) {
|
|
|
136
136
|
*/
|
|
137
137
|
export function findAllNodes(node, predicate, parent = null, path = []) {
|
|
138
138
|
const results = [];
|
|
139
|
-
|
|
139
|
+
forEachNode(node, (currentNode, currentParent, currentPath) => {
|
|
140
140
|
if (predicate(currentNode, currentParent, currentPath)) {
|
|
141
141
|
results.push({ node: currentNode, path: currentPath });
|
|
142
142
|
}
|
|
@@ -155,7 +155,7 @@ export function findAllNodes(node, predicate, parent = null, path = []) {
|
|
|
155
155
|
export function findAllNodesAsync(node, predicate, parent = null, path = []) {
|
|
156
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
157
|
const results = [];
|
|
158
|
-
yield
|
|
158
|
+
yield forEachNodeAsync(node, (currentNode, currentParent, currentPath) => __awaiter(this, void 0, void 0, function* () {
|
|
159
159
|
if (yield predicate(currentNode, currentParent, currentPath)) {
|
|
160
160
|
results.push({ node: currentNode, path: currentPath });
|
|
161
161
|
}
|
|
@@ -235,7 +235,7 @@ export function filterNodesAsync(node, predicate, parent = null, path = []) {
|
|
|
235
235
|
*/
|
|
236
236
|
export function reduceNodes(node, reducer, initialValue, parent = null, path = []) {
|
|
237
237
|
let accumulator = initialValue;
|
|
238
|
-
|
|
238
|
+
forEachNode(node, (currentNode, currentParent, currentPath) => {
|
|
239
239
|
accumulator = reducer(accumulator, currentNode, currentParent, currentPath);
|
|
240
240
|
}, parent, path);
|
|
241
241
|
return accumulator;
|
|
@@ -255,7 +255,7 @@ export function reduceNodes(node, reducer, initialValue, parent = null, path = [
|
|
|
255
255
|
export function reduceNodesAsync(node, reducer, initialValue, parent = null, path = []) {
|
|
256
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
257
257
|
let accumulator = initialValue;
|
|
258
|
-
yield
|
|
258
|
+
yield forEachNodeAsync(node, (currentNode, currentParent, currentPath) => __awaiter(this, void 0, void 0, function* () {
|
|
259
259
|
accumulator = yield reducer(accumulator, currentNode, currentParent, currentPath);
|
|
260
260
|
}), parent, path);
|
|
261
261
|
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,MAAM,UAAU,
|
|
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,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CACE,WAA8B,EAC9B,aAAuC,EACvC,WAAqB,EACrB,EAAE;QACF,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IAC7D,CAAC,EACD,MAAM,EACN,IAAI,CACL,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAgB,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"}
|
|
@@ -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';
|
|
@@ -67,7 +67,7 @@ export type SingleBlockFieldValueAsRequest = BlockItemInARequest | null;
|
|
|
67
67
|
/**
|
|
68
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';
|