@webiny/website-builder-sdk 6.4.12-beta.4 → 6.5.0-beta.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/BindingsResolver.d.ts +4 -1
- package/BindingsResolver.js.map +1 -1
- package/ComponentResolver.d.ts +3 -2
- package/ComponentResolver.js +6 -3
- package/ComponentResolver.js.map +1 -1
- package/ContentSdk.d.ts +2 -0
- package/ContentSdk.js +5 -0
- package/ContentSdk.js.map +1 -1
- package/asset/deliveryUrl.d.ts +41 -0
- package/asset/deliveryUrl.js +34 -0
- package/asset/deliveryUrl.js.map +1 -0
- package/asset/deliveryUrl.test.js +127 -0
- package/asset/deliveryUrl.test.js.map +1 -0
- package/asset/geometry.d.ts +7 -0
- package/asset/geometry.js +10 -0
- package/asset/geometry.js.map +1 -0
- package/asset/imageSrcSet.d.ts +63 -0
- package/asset/imageSrcSet.js +98 -0
- package/asset/imageSrcSet.js.map +1 -0
- package/asset/imageSrcSet.test.d.ts +1 -0
- package/asset/imageSrcSet.test.js +103 -0
- package/asset/imageSrcSet.test.js.map +1 -0
- package/asset/index.d.ts +5 -0
- package/asset/index.js +5 -0
- package/asset/normalize.d.ts +24 -0
- package/asset/normalize.js +102 -0
- package/asset/normalize.js.map +1 -0
- package/asset/normalize.test.d.ts +1 -0
- package/asset/normalize.test.js +256 -0
- package/asset/normalize.test.js.map +1 -0
- package/asset/types.d.ts +2 -0
- package/asset/types.js +0 -0
- package/contentEntry/ContentEntryBindingsResolver.d.ts +30 -0
- package/contentEntry/ContentEntryBindingsResolver.js +45 -0
- package/contentEntry/ContentEntryBindingsResolver.js.map +1 -0
- package/contentEntry/ContentEntryCache.d.ts +46 -0
- package/contentEntry/ContentEntryCache.js +50 -0
- package/contentEntry/ContentEntryCache.js.map +1 -0
- package/contentEntry/resolveContentEntry.d.ts +74 -0
- package/contentEntry/resolveContentEntry.js +53 -0
- package/contentEntry/resolveContentEntry.js.map +1 -0
- package/contentEntry/resolveContentEntry.test.d.ts +1 -0
- package/contentEntry/resolveContentEntry.test.js +213 -0
- package/contentEntry/resolveContentEntry.test.js.map +1 -0
- package/createComponent.d.ts +5 -0
- package/createComponent.js +32 -0
- package/createComponent.js.map +1 -0
- package/createInput.d.ts +10 -2
- package/createInput.js +8 -1
- package/createInput.js.map +1 -1
- package/dataProviders/ApiClient.d.ts +3 -1
- package/dataProviders/ApiClient.js +4 -2
- package/dataProviders/ApiClient.js.map +1 -1
- package/dataProviders/GET_PAGE_BY_ID.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_ID.js +0 -2
- package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.js +0 -2
- package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
- package/image/geometry.d.ts +54 -0
- package/image/geometry.js +112 -0
- package/image/geometry.js.map +1 -0
- package/image/geometry.test.d.ts +1 -0
- package/image/geometry.test.js +190 -0
- package/image/geometry.test.js.map +1 -0
- package/image/index.d.ts +3 -0
- package/image/index.js +3 -0
- package/image/presets.d.ts +6 -0
- package/image/presets.js +20 -0
- package/image/presets.js.map +1 -0
- package/image/types.d.ts +10 -0
- package/image/types.js +0 -0
- package/index.d.ts +6 -0
- package/index.js +6 -0
- package/package.json +7 -6
- package/types.d.ts +69 -1
- package/dataProviders/queries.test.js +0 -45
- package/dataProviders/queries.test.js.map +0 -1
- /package/{dataProviders/queries.test.d.ts → asset/deliveryUrl.test.d.ts} +0 -0
package/index.js
CHANGED
|
@@ -8,6 +8,12 @@ export * from "./DocumentStore.js";
|
|
|
8
8
|
export * from "./Logger.js";
|
|
9
9
|
export * from "./FunctionConverter.js";
|
|
10
10
|
export * from "./createInput.js";
|
|
11
|
+
export * from "./contentEntry/resolveContentEntry.js";
|
|
12
|
+
export * from "./contentEntry/ContentEntryCache.js";
|
|
13
|
+
export * from "./contentEntry/ContentEntryBindingsResolver.js";
|
|
14
|
+
export * from "./createComponent.js";
|
|
15
|
+
export * from "./image/index.js";
|
|
16
|
+
export * from "./asset/index.js";
|
|
11
17
|
export * from "./MouseTracker.js";
|
|
12
18
|
export * from "./ViewportManager.js";
|
|
13
19
|
export * from "./messenger/Messenger.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/website-builder-sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"author": "Pavel Denisjuk",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"@webiny/sdk": "6.5.0-beta.0",
|
|
15
16
|
"csstype": "3.2.3",
|
|
16
17
|
"deep-equal": "2.2.3",
|
|
17
18
|
"deepmerge": "4.3.1",
|
|
@@ -20,8 +21,8 @@
|
|
|
20
21
|
"is-hotkey": "0.2.0",
|
|
21
22
|
"lodash": "4.18.1",
|
|
22
23
|
"matcher": "6.0.0",
|
|
23
|
-
"mobx": "
|
|
24
|
-
"nanoid": "6.0.
|
|
24
|
+
"mobx": "6.16.1",
|
|
25
|
+
"nanoid": "6.0.0",
|
|
25
26
|
"nanoid-dictionary": "5.0.0",
|
|
26
27
|
"pino": "10.3.1",
|
|
27
28
|
"pino-pretty": "13.1.3"
|
|
@@ -29,9 +30,9 @@
|
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@types/deep-equal": "1.0.4",
|
|
31
32
|
"@types/is-hotkey": "0.1.10",
|
|
32
|
-
"@webiny/build-tools": "6.
|
|
33
|
-
"typescript": "
|
|
34
|
-
"vitest": "
|
|
33
|
+
"@webiny/build-tools": "6.5.0-beta.0",
|
|
34
|
+
"typescript": "7.0.2",
|
|
35
|
+
"vitest": "4.1.10"
|
|
35
36
|
},
|
|
36
37
|
"publishConfig": {
|
|
37
38
|
"access": "public"
|
package/types.d.ts
CHANGED
|
@@ -231,6 +231,7 @@ export type DocumentElement = {
|
|
|
231
231
|
export type SerializableCSSStyleDeclaration = {
|
|
232
232
|
[K in keyof CssProperties]?: CssProperties[K];
|
|
233
233
|
};
|
|
234
|
+
export type DocumentCache = Record<string, unknown>;
|
|
234
235
|
export type Document = {
|
|
235
236
|
id: string;
|
|
236
237
|
state: DocumentState;
|
|
@@ -240,6 +241,7 @@ export type Document = {
|
|
|
240
241
|
metadata: DocumentMetadata;
|
|
241
242
|
bindings: DocumentBindings;
|
|
242
243
|
elements: ElementMap;
|
|
244
|
+
__cache?: DocumentCache;
|
|
243
245
|
};
|
|
244
246
|
export type PublicPage = Pick<Page, "id" | "version" | "properties" | "bindings" | "elements" | "extensions" | "metadata" | "state"> & {
|
|
245
247
|
languagePaths: Record<string, string>;
|
|
@@ -448,6 +450,72 @@ export type RadioInput = BaseInput<string> & {
|
|
|
448
450
|
value: string;
|
|
449
451
|
}[];
|
|
450
452
|
};
|
|
453
|
+
export interface ContentEntryReference {
|
|
454
|
+
id: string;
|
|
455
|
+
modelId: string;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Query-mode configuration, declared by the component author. The editor then
|
|
459
|
+
* builds a query within these bounds (see `ContentEntryQueryValue`).
|
|
460
|
+
*/
|
|
461
|
+
/**
|
|
462
|
+
* A field the editor may sort by: a bare read-API sort key, or a key paired with
|
|
463
|
+
* a display label shown in the editor.
|
|
464
|
+
*/
|
|
465
|
+
export type ContentEntrySortField = string | {
|
|
466
|
+
field: string;
|
|
467
|
+
label?: string;
|
|
468
|
+
};
|
|
469
|
+
export interface ContentEntryQueryConfig {
|
|
470
|
+
/**
|
|
471
|
+
* Fields the editor may sort by (one at a time). Each `field` is a CMS read-API
|
|
472
|
+
* sort key — value fields as `values_<fieldId>` (e.g. `values_title`), meta
|
|
473
|
+
* fields bare (e.g. `createdOn`). Provide a `label` for a friendlier UI; a bare
|
|
474
|
+
* string uses the key as its label.
|
|
475
|
+
*/
|
|
476
|
+
sort?: {
|
|
477
|
+
fields: ContentEntrySortField[];
|
|
478
|
+
};
|
|
479
|
+
/** Editor-configurable result limit, with an optional default and hard cap. */
|
|
480
|
+
limit?: {
|
|
481
|
+
default?: number;
|
|
482
|
+
max?: number;
|
|
483
|
+
};
|
|
484
|
+
/** Show a free-text search box (matches fullTextSearch-enabled fields). */
|
|
485
|
+
search?: boolean;
|
|
486
|
+
/** Enable "load more" pagination in the rendered component. */
|
|
487
|
+
pagination?: boolean;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* The value stored for a query-mode input: the editor's chosen query.
|
|
491
|
+
* `modelId` identifies the CMS model so the frontend SDK can resolve the
|
|
492
|
+
* query without component manifests.
|
|
493
|
+
*/
|
|
494
|
+
export interface ContentEntryQueryValue {
|
|
495
|
+
modelId: string;
|
|
496
|
+
sort?: {
|
|
497
|
+
field: string;
|
|
498
|
+
order: "asc" | "desc";
|
|
499
|
+
};
|
|
500
|
+
limit?: number;
|
|
501
|
+
search?: string;
|
|
502
|
+
}
|
|
503
|
+
export type ContentEntryInput = BaseInput<ContentEntryReference | ContentEntryReference[] | ContentEntryQueryValue> & {
|
|
504
|
+
type: "contentEntry";
|
|
505
|
+
/**
|
|
506
|
+
* The content model(s) the editor may pick entries from. Author-fixed.
|
|
507
|
+
*/
|
|
508
|
+
models: string[];
|
|
509
|
+
/**
|
|
510
|
+
* "manual" (default): the editor hand-picks entries (stored as references).
|
|
511
|
+
* "query": the editor configures a dynamic query on the fixed model.
|
|
512
|
+
*/
|
|
513
|
+
mode?: "manual" | "query";
|
|
514
|
+
/**
|
|
515
|
+
* Query-mode configuration. Only used when `mode` is "query".
|
|
516
|
+
*/
|
|
517
|
+
query?: ContentEntryQueryConfig;
|
|
518
|
+
};
|
|
451
519
|
export type ObjectInput = BaseInput<Record<string, any>> & {
|
|
452
520
|
type: "object";
|
|
453
521
|
fields: ComponentInput[];
|
|
@@ -456,7 +524,7 @@ export type CustomInput = BaseInput<any> & {
|
|
|
456
524
|
type: string;
|
|
457
525
|
fields: ComponentInput[];
|
|
458
526
|
};
|
|
459
|
-
export type ComponentInput = TextInput | LongTextInput | NumberInput | BooleanInput | ColorInput | FileInput | DateTimeInput | LexicalInput | SelectInput | RadioInput | TagsInput | ObjectInput | SlotInput | CustomInput;
|
|
527
|
+
export type ComponentInput = TextInput | LongTextInput | NumberInput | BooleanInput | ColorInput | FileInput | DateTimeInput | LexicalInput | SelectInput | RadioInput | TagsInput | ObjectInput | SlotInput | ContentEntryInput | CustomInput;
|
|
460
528
|
export type ManifestInputsArray<TInputs, TAllowChildren extends boolean> = TAllowChildren extends true ? {
|
|
461
529
|
[K in Exclude<keyof TInputs, "children">]: InputFactory<K & string>;
|
|
462
530
|
}[Exclude<keyof TInputs, "children">][] : {
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { GET_PAGE_BY_PATH } from "./GET_PAGE_BY_PATH.js";
|
|
3
|
-
import { GET_PAGE_BY_ID } from "./GET_PAGE_BY_ID.js";
|
|
4
|
-
const getDataSelection = (query)=>{
|
|
5
|
-
const match = query.match(/data\s*\{([^}]*)\}/);
|
|
6
|
-
if (!match) throw new Error("Query has no `data` selection set.");
|
|
7
|
-
return match[1].split("\n").map((line)=>line.trim()).filter(Boolean);
|
|
8
|
-
};
|
|
9
|
-
describe("single-page queries", ()=>{
|
|
10
|
-
it.each([
|
|
11
|
-
[
|
|
12
|
-
"GET_PAGE_BY_PATH",
|
|
13
|
-
GET_PAGE_BY_PATH
|
|
14
|
-
],
|
|
15
|
-
[
|
|
16
|
-
"GET_PAGE_BY_ID",
|
|
17
|
-
GET_PAGE_BY_ID
|
|
18
|
-
]
|
|
19
|
-
])("%s selects metadata", (_name, query)=>{
|
|
20
|
-
expect(getDataSelection(query)).toContain("metadata");
|
|
21
|
-
});
|
|
22
|
-
it.each([
|
|
23
|
-
[
|
|
24
|
-
"GET_PAGE_BY_PATH",
|
|
25
|
-
GET_PAGE_BY_PATH
|
|
26
|
-
],
|
|
27
|
-
[
|
|
28
|
-
"GET_PAGE_BY_ID",
|
|
29
|
-
GET_PAGE_BY_ID
|
|
30
|
-
]
|
|
31
|
-
])("%s selects exactly the expected fields", (_name, query)=>{
|
|
32
|
-
expect(getDataSelection(query)).toEqual([
|
|
33
|
-
"id",
|
|
34
|
-
"version",
|
|
35
|
-
"properties",
|
|
36
|
-
"metadata",
|
|
37
|
-
"elements",
|
|
38
|
-
"bindings",
|
|
39
|
-
"extensions",
|
|
40
|
-
"languagePaths"
|
|
41
|
-
]);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=queries.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataProviders/queries.test.js","sources":["../../src/dataProviders/queries.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { GET_PAGE_BY_PATH } from \"./GET_PAGE_BY_PATH.js\";\nimport { GET_PAGE_BY_ID } from \"./GET_PAGE_BY_ID.js\";\n\n/**\n * Extracts the fields selected inside the `data { ... }` block of a single-page query.\n * The block is flat (all scalars), so matching up to the first closing brace is enough.\n */\nconst getDataSelection = (query: string): string[] => {\n const match = query.match(/data\\s*\\{([^}]*)\\}/);\n if (!match) {\n throw new Error(\"Query has no `data` selection set.\");\n }\n\n return match[1]\n .split(\"\\n\")\n .map(line => line.trim())\n .filter(Boolean);\n};\n\ndescribe(\"single-page queries\", () => {\n // These assertions exist because a missing `metadata` field previously forced consumers\n // to maintain a Yarn patch against the built SDK. Keep both queries selecting it.\n it.each([\n [\"GET_PAGE_BY_PATH\", GET_PAGE_BY_PATH],\n [\"GET_PAGE_BY_ID\", GET_PAGE_BY_ID]\n ])(\"%s selects metadata\", (_name, query) => {\n expect(getDataSelection(query)).toContain(\"metadata\");\n });\n\n // `PublicPage` also declares `state`, which is not sourced from the API and so is\n // deliberately absent from both queries.\n it.each([\n [\"GET_PAGE_BY_PATH\", GET_PAGE_BY_PATH],\n [\"GET_PAGE_BY_ID\", GET_PAGE_BY_ID]\n ])(\"%s selects exactly the expected fields\", (_name, query) => {\n expect(getDataSelection(query)).toEqual([\n \"id\",\n \"version\",\n \"properties\",\n \"metadata\",\n \"elements\",\n \"bindings\",\n \"extensions\",\n \"languagePaths\"\n ]);\n });\n});\n"],"names":["getDataSelection","query","match","Error","line","Boolean","describe","it","GET_PAGE_BY_PATH","GET_PAGE_BY_ID","_name","expect"],"mappings":";;;AAQA,MAAMA,mBAAmB,CAACC;IACtB,MAAMC,QAAQD,MAAM,KAAK,CAAC;IAC1B,IAAI,CAACC,OACD,MAAM,IAAIC,MAAM;IAGpB,OAAOD,KAAK,CAAC,EAAE,CACV,KAAK,CAAC,MACN,GAAG,CAACE,CAAAA,OAAQA,KAAK,IAAI,IACrB,MAAM,CAACC;AAChB;AAEAC,SAAS,uBAAuB;IAG5BC,GAAG,IAAI,CAAC;QACJ;YAAC;YAAoBC;SAAiB;QACtC;YAAC;YAAkBC;SAAe;KACrC,EAAE,uBAAuB,CAACC,OAAOT;QAC9BU,OAAOX,iBAAiBC,QAAQ,SAAS,CAAC;IAC9C;IAIAM,GAAG,IAAI,CAAC;QACJ;YAAC;YAAoBC;SAAiB;QACtC;YAAC;YAAkBC;SAAe;KACrC,EAAE,0CAA0C,CAACC,OAAOT;QACjDU,OAAOX,iBAAiBC,QAAQ,OAAO,CAAC;YACpC;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACH;IACL;AACJ"}
|
|
File without changes
|