@cmssy/core 7.0.1 → 8.0.0
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/index.cjs +13 -11
- package/dist/index.d.cts +36 -23
- package/dist/index.d.ts +36 -23
- package/dist/index.js +13 -11
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -778,12 +778,14 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
|
|
|
778
778
|
}
|
|
779
779
|
|
|
780
780
|
// src/fields.ts
|
|
781
|
+
function build(type, opts) {
|
|
782
|
+
return { type, label: opts.label ?? "", ...opts };
|
|
783
|
+
}
|
|
781
784
|
function control(type) {
|
|
782
|
-
return (opts = {}) => (
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
});
|
|
785
|
+
return (opts = {}) => build(type, opts);
|
|
786
|
+
}
|
|
787
|
+
function choice(type) {
|
|
788
|
+
return (opts) => build(type, opts);
|
|
787
789
|
}
|
|
788
790
|
var fields = {
|
|
789
791
|
text: control("text"),
|
|
@@ -795,18 +797,18 @@ var fields = {
|
|
|
795
797
|
datetime: control("datetime"),
|
|
796
798
|
boolean: control("boolean"),
|
|
797
799
|
color: control("color"),
|
|
798
|
-
media: control("media"),
|
|
799
800
|
link: control("link"),
|
|
800
801
|
url: control("url"),
|
|
801
802
|
email: control("email"),
|
|
802
|
-
select: control("select"),
|
|
803
|
-
multiselect: control("multiselect"),
|
|
804
|
-
radio: control("radio"),
|
|
805
|
-
repeater: control("repeater"),
|
|
806
803
|
table: control("table"),
|
|
807
804
|
json: control("json"),
|
|
808
805
|
form: control("form"),
|
|
809
|
-
pageSelector: control("pageSelector")
|
|
806
|
+
pageSelector: control("pageSelector"),
|
|
807
|
+
select: choice("select"),
|
|
808
|
+
radio: choice("radio"),
|
|
809
|
+
multiselect: (opts) => build("multiselect", opts),
|
|
810
|
+
media: (opts = {}) => build("media", opts),
|
|
811
|
+
repeater: (opts) => build("repeater", opts)
|
|
810
812
|
};
|
|
811
813
|
|
|
812
814
|
// src/bridge/protocol.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as _cmssy_types from '@cmssy/types';
|
|
2
|
+
import { CmssyAuthConfig, CmssyClientConfig, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssySiteConfig, RawBlock, CmssyFormDefinition, CmssySiteLocales, BuildBlockContextExtra, CmssyBlockContext, CmssyLocaleContext, FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, BlockRect, BlockSchema, BlockMeta, CmssySessionPayload, SessionCookieOptions, CmssySessionUser, CmssyAddress, CmssyCart, CmssyOrder, CmssyProduct, MyOrdersResult, FetchProductOptions, FetchProductsOptions, CmssyProductPage, FetchOrderByTokenOptions, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
3
|
+
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyAddress, CmssyAuthConfig, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyCart, CmssyCartDiscount, CmssyCartItem, CmssyCartItemSnapshot, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyOrder, CmssyOrderDiscount, CmssyOrderItem, CmssyOrderTaxSummaryLine, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyPriceTier, CmssyProduct, CmssyProductPage, CmssyProductVariant, CmssyRecordList, CmssySessionPayload, CmssySessionUser, CmssyShippingMethod, CmssySiteConfig, CmssySiteLocales, CmssyStockState, CmssyTaxSummaryLine, CmssyWebhookEvent, CmssyWebhookOrder, FetchOrderByTokenOptions, FetchProductOptions, FetchProductsOptions, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, MyOrdersResult, RawBlock, RawLayoutBlock, SessionCookieOptions, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
3
4
|
|
|
4
5
|
declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
|
|
5
6
|
declare function isDevelopment(): boolean;
|
|
@@ -216,28 +217,40 @@ declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | un
|
|
|
216
217
|
*/
|
|
217
218
|
declare function localeForPath(config: CmssyClientConfig, path: string | string[]): Promise<string>;
|
|
218
219
|
|
|
220
|
+
type Declared<O> = O extends {
|
|
221
|
+
required: true;
|
|
222
|
+
} ? true : false;
|
|
223
|
+
type OptionValue<O> = O extends {
|
|
224
|
+
options: readonly (infer Option extends string)[];
|
|
225
|
+
} ? Option : string;
|
|
226
|
+
type MediaValue<O> = O extends {
|
|
227
|
+
multiple: true;
|
|
228
|
+
} ? string[] : string;
|
|
229
|
+
type RepeaterValue<O> = O extends {
|
|
230
|
+
itemSchema: infer Schema extends BlockPropsSchema;
|
|
231
|
+
} ? InferBlockContent<Schema>[] : Record<string, unknown>[];
|
|
219
232
|
declare const fields: {
|
|
220
|
-
text: (opts?:
|
|
221
|
-
textarea: (opts?:
|
|
222
|
-
richText: (opts?:
|
|
223
|
-
markdown: (opts?:
|
|
224
|
-
number: (opts?:
|
|
225
|
-
date: (opts?:
|
|
226
|
-
datetime: (opts?:
|
|
227
|
-
boolean: (opts?:
|
|
228
|
-
color: (opts?:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
233
|
+
text: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
234
|
+
textarea: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
235
|
+
richText: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
236
|
+
markdown: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
237
|
+
number: <const O extends FieldOptions>(opts?: O) => TypedField<number, Declared<O>>;
|
|
238
|
+
date: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
239
|
+
datetime: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
240
|
+
boolean: <const O extends FieldOptions>(opts?: O) => TypedField<boolean, Declared<O>>;
|
|
241
|
+
color: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
242
|
+
link: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
243
|
+
url: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
244
|
+
email: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
245
|
+
table: <const O extends FieldOptions>(opts?: O) => TypedField<_cmssy_types.TableValue, Declared<O>>;
|
|
246
|
+
json: <const O extends FieldOptions>(opts?: O) => TypedField<_cmssy_types.JsonValue, Declared<O>>;
|
|
247
|
+
form: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
248
|
+
pageSelector: <const O extends FieldOptions>(opts?: O) => TypedField<_cmssy_types.PageRef[], Declared<O>>;
|
|
249
|
+
select: <const O extends FieldOptions>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
|
|
250
|
+
radio: <const O extends FieldOptions>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
|
|
251
|
+
multiselect: <const O extends FieldOptions>(opts: O) => TypedField<OptionValue<O>[], Declared<O>>;
|
|
252
|
+
media: <const O extends FieldOptions>(opts?: O) => TypedField<MediaValue<O>, Declared<O>>;
|
|
253
|
+
repeater: <const O extends FieldOptions>(opts: O) => TypedField<RepeaterValue<O>, Declared<O>>;
|
|
241
254
|
};
|
|
242
255
|
|
|
243
256
|
declare const PROTOCOL_VERSION = 2;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as _cmssy_types from '@cmssy/types';
|
|
2
|
+
import { CmssyAuthConfig, CmssyClientConfig, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssySiteConfig, RawBlock, CmssyFormDefinition, CmssySiteLocales, BuildBlockContextExtra, CmssyBlockContext, CmssyLocaleContext, FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, BlockRect, BlockSchema, BlockMeta, CmssySessionPayload, SessionCookieOptions, CmssySessionUser, CmssyAddress, CmssyCart, CmssyOrder, CmssyProduct, MyOrdersResult, FetchProductOptions, FetchProductsOptions, CmssyProductPage, FetchOrderByTokenOptions, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
3
|
+
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyAddress, CmssyAuthConfig, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyCart, CmssyCartDiscount, CmssyCartItem, CmssyCartItemSnapshot, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyOrder, CmssyOrderDiscount, CmssyOrderItem, CmssyOrderTaxSummaryLine, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyPriceTier, CmssyProduct, CmssyProductPage, CmssyProductVariant, CmssyRecordList, CmssySessionPayload, CmssySessionUser, CmssyShippingMethod, CmssySiteConfig, CmssySiteLocales, CmssyStockState, CmssyTaxSummaryLine, CmssyWebhookEvent, CmssyWebhookOrder, FetchOrderByTokenOptions, FetchProductOptions, FetchProductsOptions, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, MyOrdersResult, RawBlock, RawLayoutBlock, SessionCookieOptions, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
3
4
|
|
|
4
5
|
declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
|
|
5
6
|
declare function isDevelopment(): boolean;
|
|
@@ -216,28 +217,40 @@ declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | un
|
|
|
216
217
|
*/
|
|
217
218
|
declare function localeForPath(config: CmssyClientConfig, path: string | string[]): Promise<string>;
|
|
218
219
|
|
|
220
|
+
type Declared<O> = O extends {
|
|
221
|
+
required: true;
|
|
222
|
+
} ? true : false;
|
|
223
|
+
type OptionValue<O> = O extends {
|
|
224
|
+
options: readonly (infer Option extends string)[];
|
|
225
|
+
} ? Option : string;
|
|
226
|
+
type MediaValue<O> = O extends {
|
|
227
|
+
multiple: true;
|
|
228
|
+
} ? string[] : string;
|
|
229
|
+
type RepeaterValue<O> = O extends {
|
|
230
|
+
itemSchema: infer Schema extends BlockPropsSchema;
|
|
231
|
+
} ? InferBlockContent<Schema>[] : Record<string, unknown>[];
|
|
219
232
|
declare const fields: {
|
|
220
|
-
text: (opts?:
|
|
221
|
-
textarea: (opts?:
|
|
222
|
-
richText: (opts?:
|
|
223
|
-
markdown: (opts?:
|
|
224
|
-
number: (opts?:
|
|
225
|
-
date: (opts?:
|
|
226
|
-
datetime: (opts?:
|
|
227
|
-
boolean: (opts?:
|
|
228
|
-
color: (opts?:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
233
|
+
text: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
234
|
+
textarea: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
235
|
+
richText: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
236
|
+
markdown: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
237
|
+
number: <const O extends FieldOptions>(opts?: O) => TypedField<number, Declared<O>>;
|
|
238
|
+
date: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
239
|
+
datetime: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
240
|
+
boolean: <const O extends FieldOptions>(opts?: O) => TypedField<boolean, Declared<O>>;
|
|
241
|
+
color: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
242
|
+
link: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
243
|
+
url: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
244
|
+
email: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
245
|
+
table: <const O extends FieldOptions>(opts?: O) => TypedField<_cmssy_types.TableValue, Declared<O>>;
|
|
246
|
+
json: <const O extends FieldOptions>(opts?: O) => TypedField<_cmssy_types.JsonValue, Declared<O>>;
|
|
247
|
+
form: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
248
|
+
pageSelector: <const O extends FieldOptions>(opts?: O) => TypedField<_cmssy_types.PageRef[], Declared<O>>;
|
|
249
|
+
select: <const O extends FieldOptions>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
|
|
250
|
+
radio: <const O extends FieldOptions>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
|
|
251
|
+
multiselect: <const O extends FieldOptions>(opts: O) => TypedField<OptionValue<O>[], Declared<O>>;
|
|
252
|
+
media: <const O extends FieldOptions>(opts?: O) => TypedField<MediaValue<O>, Declared<O>>;
|
|
253
|
+
repeater: <const O extends FieldOptions>(opts: O) => TypedField<RepeaterValue<O>, Declared<O>>;
|
|
241
254
|
};
|
|
242
255
|
|
|
243
256
|
declare const PROTOCOL_VERSION = 2;
|
package/dist/index.js
CHANGED
|
@@ -776,12 +776,14 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
|
|
|
776
776
|
}
|
|
777
777
|
|
|
778
778
|
// src/fields.ts
|
|
779
|
+
function build(type, opts) {
|
|
780
|
+
return { type, label: opts.label ?? "", ...opts };
|
|
781
|
+
}
|
|
779
782
|
function control(type) {
|
|
780
|
-
return (opts = {}) => (
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
});
|
|
783
|
+
return (opts = {}) => build(type, opts);
|
|
784
|
+
}
|
|
785
|
+
function choice(type) {
|
|
786
|
+
return (opts) => build(type, opts);
|
|
785
787
|
}
|
|
786
788
|
var fields = {
|
|
787
789
|
text: control("text"),
|
|
@@ -793,18 +795,18 @@ var fields = {
|
|
|
793
795
|
datetime: control("datetime"),
|
|
794
796
|
boolean: control("boolean"),
|
|
795
797
|
color: control("color"),
|
|
796
|
-
media: control("media"),
|
|
797
798
|
link: control("link"),
|
|
798
799
|
url: control("url"),
|
|
799
800
|
email: control("email"),
|
|
800
|
-
select: control("select"),
|
|
801
|
-
multiselect: control("multiselect"),
|
|
802
|
-
radio: control("radio"),
|
|
803
|
-
repeater: control("repeater"),
|
|
804
801
|
table: control("table"),
|
|
805
802
|
json: control("json"),
|
|
806
803
|
form: control("form"),
|
|
807
|
-
pageSelector: control("pageSelector")
|
|
804
|
+
pageSelector: control("pageSelector"),
|
|
805
|
+
select: choice("select"),
|
|
806
|
+
radio: choice("radio"),
|
|
807
|
+
multiselect: (opts) => build("multiselect", opts),
|
|
808
|
+
media: (opts = {}) => build("media", opts),
|
|
809
|
+
repeater: (opts) => build("repeater", opts)
|
|
808
810
|
};
|
|
809
811
|
|
|
810
812
|
// src/bridge/protocol.ts
|
package/dist/testing.d.cts
CHANGED
|
@@ -28,11 +28,11 @@ interface EditSmokeResult {
|
|
|
28
28
|
* because the site compiles and serves fine while being uneditable.
|
|
29
29
|
*
|
|
30
30
|
* It asserts three independent things:
|
|
31
|
-
* 1. the public page renders WITHOUT the editor,
|
|
31
|
+
* 1. the public page renders WITHOUT the editor, header and footer server-rendered;
|
|
32
32
|
* 2. a bare `?cmssyEdit=1` does NOT enter edit mode (an unverified pair must
|
|
33
33
|
* not open the door - CMS-948);
|
|
34
34
|
* 3. a verified `cmssyEdit=1` + `cmssySecret` renders the editor AND moves the
|
|
35
|
-
*
|
|
35
|
+
* header and footer onto the edit bridge.
|
|
36
36
|
*
|
|
37
37
|
* Run it against a started production build:
|
|
38
38
|
*
|
package/dist/testing.d.ts
CHANGED
|
@@ -28,11 +28,11 @@ interface EditSmokeResult {
|
|
|
28
28
|
* because the site compiles and serves fine while being uneditable.
|
|
29
29
|
*
|
|
30
30
|
* It asserts three independent things:
|
|
31
|
-
* 1. the public page renders WITHOUT the editor,
|
|
31
|
+
* 1. the public page renders WITHOUT the editor, header and footer server-rendered;
|
|
32
32
|
* 2. a bare `?cmssyEdit=1` does NOT enter edit mode (an unverified pair must
|
|
33
33
|
* not open the door - CMS-948);
|
|
34
34
|
* 3. a verified `cmssyEdit=1` + `cmssySecret` renders the editor AND moves the
|
|
35
|
-
*
|
|
35
|
+
* header and footer onto the edit bridge.
|
|
36
36
|
*
|
|
37
37
|
* Run it against a started production build:
|
|
38
38
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Framework-agnostic cmssy client: content, commerce, config, editor protocol. No React, no Next.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"vitest": "^2.1.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@cmssy/types": "0.
|
|
50
|
+
"@cmssy/types": "0.28.0",
|
|
51
51
|
"jose": "^6.2.3"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|