@stackbit/cms-sanity 0.2.45-develop.1 → 0.2.45-develop.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/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/sanity-content-source.d.ts +21 -10
- package/dist/sanity-content-source.d.ts.map +1 -1
- package/dist/sanity-content-source.js +74 -242
- package/dist/sanity-content-source.js.map +1 -1
- package/dist/sanity-document-converter.d.ts +11 -9
- package/dist/sanity-document-converter.d.ts.map +1 -1
- package/dist/sanity-document-converter.js +262 -205
- package/dist/sanity-document-converter.js.map +1 -1
- package/dist/sanity-operation-converter.d.ts +60 -0
- package/dist/sanity-operation-converter.d.ts.map +1 -0
- package/dist/sanity-operation-converter.js +664 -0
- package/dist/sanity-operation-converter.js.map +1 -0
- package/dist/sanity-schema-converter.d.ts +35 -3
- package/dist/sanity-schema-converter.d.ts.map +1 -1
- package/dist/sanity-schema-converter.js +290 -43
- package/dist/sanity-schema-converter.js.map +1 -1
- package/dist/sanity-schema-fetcher.d.ts +3 -3
- package/dist/sanity-schema-fetcher.d.ts.map +1 -1
- package/dist/utils.d.ts +53 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +93 -1
- package/dist/utils.js.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +1 -1
- package/src/sanity-content-source.ts +109 -317
- package/src/sanity-document-converter.ts +332 -231
- package/src/sanity-operation-converter.ts +785 -0
- package/src/sanity-schema-converter.ts +424 -70
- package/src/sanity-schema-fetcher.ts +3 -3
- package/src/utils.ts +98 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { PatchOperations, SanityDocument } from '@sanity/client';
|
|
2
|
+
import type * as StackbitTypes from '@stackbit/types';
|
|
3
|
+
import type { ModelContext, ModelWithContext } from './sanity-schema-converter';
|
|
4
|
+
import type { GetModelByName } from './sanity-document-converter';
|
|
5
|
+
export declare function convertUpdateOperation({ operation, ...rest }: {
|
|
6
|
+
operation: StackbitTypes.UpdateOperation;
|
|
7
|
+
sanityDocument: SanityDocument;
|
|
8
|
+
getModelByName: GetModelByName;
|
|
9
|
+
model: ModelWithContext;
|
|
10
|
+
}): PatchOperations;
|
|
11
|
+
export declare const Operations: {
|
|
12
|
+
[Type in StackbitTypes.UpdateOperation as Type['opType']]: ({ sanityDocument, operation, getModelByName }: {
|
|
13
|
+
sanityDocument: SanityDocument;
|
|
14
|
+
operation: Type;
|
|
15
|
+
getModelByName: GetModelByName;
|
|
16
|
+
model: StackbitTypes.Model<ModelContext>;
|
|
17
|
+
}) => PatchOperations;
|
|
18
|
+
};
|
|
19
|
+
export declare function mapUpdateOperationFieldToSanityValue({ updateOperationField, getModelByName, modelField, rootModel, modelFieldPath, locale, isInList }: {
|
|
20
|
+
updateOperationField: StackbitTypes.UpdateOperationField;
|
|
21
|
+
getModelByName: GetModelByName;
|
|
22
|
+
modelField: StackbitTypes.FieldSpecificProps;
|
|
23
|
+
rootModel: StackbitTypes.Model<ModelContext>;
|
|
24
|
+
modelFieldPath: string[];
|
|
25
|
+
locale: string | undefined;
|
|
26
|
+
isInList?: boolean;
|
|
27
|
+
}): any;
|
|
28
|
+
/**
|
|
29
|
+
* In Sanity, a localized field is represented by an array of objects containing the localized field values.
|
|
30
|
+
* Each object has three properties:
|
|
31
|
+
* - `_key` holds the field's locale
|
|
32
|
+
* - `_type` holds the type of the localized value
|
|
33
|
+
* - `value` holds the localized value.
|
|
34
|
+
*
|
|
35
|
+
* Note: the `_type` is not the regular type such as `string` or `object`,
|
|
36
|
+
* but a special localized type generated by the Sanity Internationalized Array plugin.
|
|
37
|
+
* The map between the localized fields and these types is stored in the model's context.
|
|
38
|
+
* title: [
|
|
39
|
+
* {
|
|
40
|
+
* _key: 'us',
|
|
41
|
+
* _type: 'internationalizedArrayStringValue',
|
|
42
|
+
* value: 'hello',
|
|
43
|
+
* }, {
|
|
44
|
+
* _key: 'es',
|
|
45
|
+
* _type: 'internationalizedArrayStringValue',
|
|
46
|
+
* value: 'hola',
|
|
47
|
+
* }
|
|
48
|
+
* ]
|
|
49
|
+
*/
|
|
50
|
+
export declare function localizedValue({ value, model, modelFieldPath, locale }: {
|
|
51
|
+
value: any;
|
|
52
|
+
model: ModelWithContext;
|
|
53
|
+
modelFieldPath: string[];
|
|
54
|
+
locale?: string;
|
|
55
|
+
}): {
|
|
56
|
+
_key: string;
|
|
57
|
+
_type: string;
|
|
58
|
+
value: any;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=sanity-operation-converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanity-operation-converter.d.ts","sourceRoot":"","sources":["../src/sanity-operation-converter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,KAAK,aAAa,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,wBAAgB,sBAAsB,CAAC,EACnC,SAAS,EACT,GAAG,IAAI,EACV,EAAE;IACC,SAAS,EAAE,aAAa,CAAC,eAAe,CAAC;IACzC,cAAc,EAAE,cAAc,CAAC;IAC/B,cAAc,EAAE,cAAc,CAAC;IAC/B,KAAK,EAAE,gBAAgB,CAAC;CAC3B,GAAG,eAAe,CAalB;AAED,eAAO,MAAM,UAAU,EAAE;KACpB,IAAI,IAAI,aAAa,CAAC,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EACxD,cAAc,EACd,SAAS,EACT,cAAc,EACjB,EAAE;QACC,cAAc,EAAE,cAAc,CAAC;QAC/B,SAAS,EAAE,IAAI,CAAC;QAChB,cAAc,EAAE,cAAc,CAAC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