@webiny/website-builder-sdk 6.5.0-beta.1 → 6.5.0-beta.10

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.
@@ -12,6 +12,10 @@ class ComponentInputTraverser {
12
12
  if (node.list) {
13
13
  value = value ?? [];
14
14
  if (0 === value.length) visitor(node, currentPath, value);
15
+ if (0 === node.children.length && "slot" !== node.type) {
16
+ if (value.length > 0) visitor(node, currentPath, value);
17
+ return;
18
+ }
15
19
  value.forEach((item, index)=>{
16
20
  if (node.children.length > 0) {
17
21
  const itemPath = `${currentPath}/${index}`;
@@ -1 +1 @@
1
- {"version":3,"file":"ComponentInputTraverser.js","sources":["../src/ComponentInputTraverser.ts"],"sourcesContent":["import type { InputAstNode } from \"./ComponentManifestToAstConverter.js\";\n\n// Visitor signature: called for every resolved leaf\nexport type InputVisitor = (node: InputAstNode, path: string, value: any) => void;\n\n/**\n * ComponentInputTraverser\n *\n * Walks an input AST and a matching data object,\n * invoking `visitor` for each leaf value found.\n */\nexport class ComponentInputTraverser {\n private readonly ast: InputAstNode[];\n\n constructor(ast: InputAstNode[]) {\n this.ast = ast;\n }\n\n /**\n * Traverse the given `data` object according to the AST,\n * calling `visitor(node, path, value)` for each leaf.\n */\n public traverse(data: Record<string, any>, visitor: InputVisitor): void {\n for (const node of this.ast) {\n const rootValue = data[node.name];\n this.traverseNode(node, rootValue, node.name, visitor);\n }\n }\n\n private traverseNode(\n node: InputAstNode,\n value: any,\n currentPath: string,\n visitor: InputVisitor\n ): void {\n if (node.list) {\n value = value ?? [];\n\n if (value.length === 0) {\n visitor(node, currentPath, value);\n }\n\n value.forEach((item: any, index: number) => {\n if (node.children.length > 0) {\n const itemPath = `${currentPath}/${index}`;\n for (const child of node.children) {\n const childValue = item?.[child.name];\n const childPath = `${itemPath}/${child.name}`;\n this.traverseNode(child, childValue, childPath, visitor);\n }\n } else {\n visitor(node, currentPath, item);\n }\n });\n } else {\n if (node.children.length > 0) {\n for (const child of node.children) {\n const childValue = value?.[child.name];\n const childPath = `${currentPath}/${child.name}`;\n this.traverseNode(child, childValue, childPath, visitor);\n }\n } else {\n visitor(node, currentPath, value);\n }\n }\n }\n}\n"],"names":["ComponentInputTraverser","ast","data","visitor","node","rootValue","value","currentPath","item","index","itemPath","child","childValue","childPath"],"mappings":"AAWO,MAAMA;IAGT,YAAYC,GAAmB,CAAE;QAC7B,IAAI,CAAC,GAAG,GAAGA;IACf;IAMO,SAASC,IAAyB,EAAEC,OAAqB,EAAQ;QACpE,KAAK,MAAMC,QAAQ,IAAI,CAAC,GAAG,CAAE;YACzB,MAAMC,YAAYH,IAAI,CAACE,KAAK,IAAI,CAAC;YACjC,IAAI,CAAC,YAAY,CAACA,MAAMC,WAAWD,KAAK,IAAI,EAAED;QAClD;IACJ;IAEQ,aACJC,IAAkB,EAClBE,KAAU,EACVC,WAAmB,EACnBJ,OAAqB,EACjB;QACJ,IAAIC,KAAK,IAAI,EAAE;YACXE,QAAQA,SAAS,EAAE;YAEnB,IAAIA,AAAiB,MAAjBA,MAAM,MAAM,EACZH,QAAQC,MAAMG,aAAaD;YAG/BA,MAAM,OAAO,CAAC,CAACE,MAAWC;gBACtB,IAAIL,KAAK,QAAQ,CAAC,MAAM,GAAG,GAAG;oBAC1B,MAAMM,WAAW,GAAGH,YAAY,CAAC,EAAEE,OAAO;oBAC1C,KAAK,MAAME,SAASP,KAAK,QAAQ,CAAE;wBAC/B,MAAMQ,aAAaJ,MAAM,CAACG,MAAM,IAAI,CAAC;wBACrC,MAAME,YAAY,GAAGH,SAAS,CAAC,EAAEC,MAAM,IAAI,EAAE;wBAC7C,IAAI,CAAC,YAAY,CAACA,OAAOC,YAAYC,WAAWV;oBACpD;gBACJ,OACIA,QAAQC,MAAMG,aAAaC;YAEnC;QACJ,OACI,IAAIJ,KAAK,QAAQ,CAAC,MAAM,GAAG,GACvB,KAAK,MAAMO,SAASP,KAAK,QAAQ,CAAE;YAC/B,MAAMQ,aAAaN,OAAO,CAACK,MAAM,IAAI,CAAC;YACtC,MAAME,YAAY,GAAGN,YAAY,CAAC,EAAEI,MAAM,IAAI,EAAE;YAChD,IAAI,CAAC,YAAY,CAACA,OAAOC,YAAYC,WAAWV;QACpD;aAEAA,QAAQC,MAAMG,aAAaD;IAGvC;AACJ"}
1
+ {"version":3,"file":"ComponentInputTraverser.js","sources":["../src/ComponentInputTraverser.ts"],"sourcesContent":["import type { InputAstNode } from \"./ComponentManifestToAstConverter.js\";\n\n// Visitor signature: called for every resolved leaf\nexport type InputVisitor = (node: InputAstNode, path: string, value: any) => void;\n\n/**\n * ComponentInputTraverser\n *\n * Walks an input AST and a matching data object,\n * invoking `visitor` for each leaf value found.\n */\nexport class ComponentInputTraverser {\n private readonly ast: InputAstNode[];\n\n constructor(ast: InputAstNode[]) {\n this.ast = ast;\n }\n\n /**\n * Traverse the given `data` object according to the AST,\n * calling `visitor(node, path, value)` for each leaf.\n */\n public traverse(data: Record<string, any>, visitor: InputVisitor): void {\n for (const node of this.ast) {\n const rootValue = data[node.name];\n this.traverseNode(node, rootValue, node.name, visitor);\n }\n }\n\n private traverseNode(\n node: InputAstNode,\n value: any,\n currentPath: string,\n visitor: InputVisitor\n ): void {\n if (node.list) {\n value = value ?? [];\n\n if (value.length === 0) {\n visitor(node, currentPath, value);\n }\n\n // A list of primitives (e.g. tags) is a single leaf: its value is the whole array.\n // Visiting each item would write every item to the same path, leaving only the last.\n // Slot lists are still visited per item, as each item creates its own element.\n if (node.children.length === 0 && node.type !== \"slot\") {\n if (value.length > 0) {\n visitor(node, currentPath, value);\n }\n return;\n }\n\n value.forEach((item: any, index: number) => {\n if (node.children.length > 0) {\n const itemPath = `${currentPath}/${index}`;\n for (const child of node.children) {\n const childValue = item?.[child.name];\n const childPath = `${itemPath}/${child.name}`;\n this.traverseNode(child, childValue, childPath, visitor);\n }\n } else {\n visitor(node, currentPath, item);\n }\n });\n } else {\n if (node.children.length > 0) {\n for (const child of node.children) {\n const childValue = value?.[child.name];\n const childPath = `${currentPath}/${child.name}`;\n this.traverseNode(child, childValue, childPath, visitor);\n }\n } else {\n visitor(node, currentPath, value);\n }\n }\n }\n}\n"],"names":["ComponentInputTraverser","ast","data","visitor","node","rootValue","value","currentPath","item","index","itemPath","child","childValue","childPath"],"mappings":"AAWO,MAAMA;IAGT,YAAYC,GAAmB,CAAE;QAC7B,IAAI,CAAC,GAAG,GAAGA;IACf;IAMO,SAASC,IAAyB,EAAEC,OAAqB,EAAQ;QACpE,KAAK,MAAMC,QAAQ,IAAI,CAAC,GAAG,CAAE;YACzB,MAAMC,YAAYH,IAAI,CAACE,KAAK,IAAI,CAAC;YACjC,IAAI,CAAC,YAAY,CAACA,MAAMC,WAAWD,KAAK,IAAI,EAAED;QAClD;IACJ;IAEQ,aACJC,IAAkB,EAClBE,KAAU,EACVC,WAAmB,EACnBJ,OAAqB,EACjB;QACJ,IAAIC,KAAK,IAAI,EAAE;YACXE,QAAQA,SAAS,EAAE;YAEnB,IAAIA,AAAiB,MAAjBA,MAAM,MAAM,EACZH,QAAQC,MAAMG,aAAaD;YAM/B,IAAIF,AAAyB,MAAzBA,KAAK,QAAQ,CAAC,MAAM,IAAUA,AAAc,WAAdA,KAAK,IAAI,EAAa;gBACpD,IAAIE,MAAM,MAAM,GAAG,GACfH,QAAQC,MAAMG,aAAaD;gBAE/B;YACJ;YAEAA,MAAM,OAAO,CAAC,CAACE,MAAWC;gBACtB,IAAIL,KAAK,QAAQ,CAAC,MAAM,GAAG,GAAG;oBAC1B,MAAMM,WAAW,GAAGH,YAAY,CAAC,EAAEE,OAAO;oBAC1C,KAAK,MAAME,SAASP,KAAK,QAAQ,CAAE;wBAC/B,MAAMQ,aAAaJ,MAAM,CAACG,MAAM,IAAI,CAAC;wBACrC,MAAME,YAAY,GAAGH,SAAS,CAAC,EAAEC,MAAM,IAAI,EAAE;wBAC7C,IAAI,CAAC,YAAY,CAACA,OAAOC,YAAYC,WAAWV;oBACpD;gBACJ,OACIA,QAAQC,MAAMG,aAAaC;YAEnC;QACJ,OACI,IAAIJ,KAAK,QAAQ,CAAC,MAAM,GAAG,GACvB,KAAK,MAAMO,SAASP,KAAK,QAAQ,CAAE;YAC/B,MAAMQ,aAAaN,OAAO,CAACK,MAAM,IAAI,CAAC;YACtC,MAAME,YAAY,GAAGN,YAAY,CAAC,EAAEI,MAAM,IAAI,EAAE;YAChD,IAAI,CAAC,YAAY,CAACA,OAAOC,YAAYC,WAAWV;QACpD;aAEAA,QAAQC,MAAMG,aAAaD;IAGvC;AACJ"}
@@ -246,6 +246,108 @@ describe("ElementFactory", ()=>{
246
246
  step2.id
247
247
  ]);
248
248
  });
249
+ it("should keep every item of a primitive list (tags) from the component defaults", ()=>{
250
+ const pricing = {
251
+ name: "Custom/PricingPlans",
252
+ label: "Pricing Plans",
253
+ tags: [],
254
+ inputs: [
255
+ {
256
+ type: "text",
257
+ list: true,
258
+ renderer: "Webiny/Tags",
259
+ name: "highlights",
260
+ defaultValue: [
261
+ "Default"
262
+ ]
263
+ },
264
+ {
265
+ type: "object",
266
+ list: true,
267
+ renderer: "Webiny/Object",
268
+ name: "plans",
269
+ fields: [
270
+ {
271
+ type: "text",
272
+ renderer: "Webiny/Input",
273
+ name: "name"
274
+ },
275
+ {
276
+ type: "text",
277
+ list: true,
278
+ renderer: "Webiny/Tags",
279
+ name: "features",
280
+ defaultValue: [
281
+ "Feature one",
282
+ "Feature two"
283
+ ]
284
+ }
285
+ ]
286
+ }
287
+ ],
288
+ defaults: {
289
+ inputs: {
290
+ highlights: [
291
+ "Fast",
292
+ "Cheap"
293
+ ],
294
+ plans: [
295
+ {
296
+ name: "Hobby",
297
+ features: [
298
+ "Autocomplete",
299
+ "Limited AI integration"
300
+ ]
301
+ },
302
+ {
303
+ name: "Enterprise",
304
+ features: [
305
+ "Everything in Hobby",
306
+ "24/7 Support"
307
+ ]
308
+ }
309
+ ]
310
+ }
311
+ }
312
+ };
313
+ const factory = new ElementFactory({
314
+ ...components,
315
+ [pricing.name]: pricing
316
+ });
317
+ const result = factory.createElementFromComponent({
318
+ componentName: pricing.name,
319
+ parentId: "root",
320
+ slot: "children"
321
+ });
322
+ const document = {
323
+ state: {},
324
+ elements: {
325
+ root: {
326
+ type: "Webiny/Element",
327
+ id: "root",
328
+ component: {
329
+ name: "Webiny/Root"
330
+ }
331
+ }
332
+ },
333
+ bindings: {}
334
+ };
335
+ for (const op of result.operations)op.apply(document);
336
+ const inputs = document.bindings[result.element.id].inputs;
337
+ expect(inputs["highlights"]?.static).toEqual([
338
+ "Fast",
339
+ "Cheap"
340
+ ]);
341
+ expect(inputs["plans/0/name"]?.static).toBe("Hobby");
342
+ expect(inputs["plans/0/features"]?.static).toEqual([
343
+ "Autocomplete",
344
+ "Limited AI integration"
345
+ ]);
346
+ expect(inputs["plans/1/features"]?.static).toEqual([
347
+ "Everything in Hobby",
348
+ "24/7 Support"
349
+ ]);
350
+ });
249
351
  });
250
352
 
251
353
  //# sourceMappingURL=ElementFactory.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElementFactory.test.js","sources":["../src/ElementFactory.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { ElementFactory } from \"./ElementFactory.js\";\nimport { DocumentOperations } from \"./documentOperations/index.js\";\nimport type { ComponentManifest, Document } from \"~/types.js\";\n\nconst components: Record<string, ComponentManifest> = {\n \"Webiny/Root\": {\n name: \"Webiny/Root\",\n label: \"Main Content\",\n tags: [],\n inputs: [\n {\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n defaultValue: [],\n name: \"children\"\n }\n ]\n },\n \"FunnelBuilder/Funnel\": {\n name: \"FunnelBuilder/Funnel\",\n label: \"Funnel\",\n tags: [],\n inputs: [\n {\n type: \"object\",\n renderer: \"Webiny/Object\",\n name: \"fields\",\n list: true,\n fields: [],\n defaultValue: []\n },\n {\n type: \"number\",\n renderer: \"Webiny/Number\",\n name: \"activeStep\",\n label: \"Active Step\",\n defaultValue: 0\n },\n {\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n defaultValue: [],\n name: \"steps\"\n },\n {\n type: \"object\",\n renderer: \"FunnelBuilder/ConditionRulesRenderer\",\n name: \"conditionRules\",\n list: true,\n fields: []\n }\n ]\n },\n \"FunnelBuilder/Step\": {\n name: \"FunnelBuilder/Step\",\n label: \"Funnel Step\",\n tags: [],\n inputs: [\n {\n type: \"text\",\n renderer: \"Webiny/Input\",\n name: \"label\",\n label: \"Label\"\n },\n {\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n defaultValue: [],\n name: \"children\"\n }\n ]\n }\n};\n\n/**\n * Extract private fields from operation instances for assertion.\n */\nfunction serializeOp(op: any) {\n if (op instanceof DocumentOperations.AddElement) {\n return { type: \"AddElement\", element: op[\"element\"] };\n }\n if (op instanceof DocumentOperations.AddToParent) {\n return { type: \"AddToParent\", element: op[\"element\"], index: op[\"index\"] };\n }\n if (op instanceof DocumentOperations.SetGlobalInputBinding) {\n return {\n type: \"SetGlobalInputBinding\",\n elementId: op[\"elementId\"],\n bindingPath: op[\"bindingPath\"],\n binding: op[\"binding\"]\n };\n }\n if (op instanceof DocumentOperations.SetGlobalStyleBinding) {\n return {\n type: \"SetGlobalStyleBinding\",\n elementId: op[\"elementId\"],\n bindingPath: op[\"bindingPath\"],\n binding: op[\"binding\"]\n };\n }\n return op;\n}\n\ndescribe(\"ElementFactory\", () => {\n it(\"should produce correct operation sequence for a Funnel with two Steps\", () => {\n const factory = new ElementFactory(components);\n const result = factory.createElementFromComponent({\n componentName: \"FunnelBuilder/Funnel\",\n parentId: \"root\",\n slot: \"children\",\n index: 0,\n bindings: {\n inputs: {\n fields: [],\n activeStep: 0,\n steps: [\n {\n action: \"CreateElement\",\n params: {\n component: \"FunnelBuilder/Step\",\n inputs: { label: \"Step 1\", children: [] }\n }\n },\n {\n action: \"CreateElement\",\n params: {\n component: \"FunnelBuilder/Step\",\n inputs: { label: \"Final Step\", children: [] }\n }\n }\n ]\n }\n }\n });\n\n const ops = result.operations.map(serializeOp);\n const funnelId = result.element.id;\n\n // 0: AddElement — Funnel\n expect(ops[0].type).toBe(\"AddElement\");\n expect(ops[0].element.component.name).toBe(\"FunnelBuilder/Funnel\");\n\n // 1: AddToParent — Funnel → root/children at index 0\n expect(ops[1].type).toBe(\"AddToParent\");\n expect(ops[1].element.id).toBe(funnelId);\n expect(ops[1].index).toBe(0);\n\n // 2: SetGlobalInputBinding — activeStep = 0\n expect(ops[2].type).toBe(\"SetGlobalInputBinding\");\n expect(ops[2].elementId).toBe(funnelId);\n expect(ops[2].bindingPath).toBe(\"activeStep\");\n expect(ops[2].binding.static).toBe(0);\n\n // 3: AddElement — Step 1\n const step1Id = ops[3].element.id;\n expect(ops[3].type).toBe(\"AddElement\");\n expect(ops[3].element.component.name).toBe(\"FunnelBuilder/Step\");\n expect(ops[3].element.parent).toEqual({ id: funnelId, slot: \"steps\" });\n\n // 4: AddToParent — Step 1 (undefined = append)\n expect(ops[4].type).toBe(\"AddToParent\");\n expect(ops[4].element.id).toBe(step1Id);\n expect(ops[4].index).toBeUndefined();\n\n // 5: Step 1 label binding\n expect(ops[5].bindingPath).toBe(\"label\");\n expect(ops[5].binding.static).toBe(\"Step 1\");\n\n // 6: Step 1 children binding\n expect(ops[6].bindingPath).toBe(\"children\");\n expect(ops[6].binding.static).toEqual([]);\n\n // 7-8: Step 1 style bindings\n expect(ops[7].bindingPath).toBe(\"display\");\n expect(ops[8].bindingPath).toBe(\"flexDirection\");\n\n // 9: SetGlobalInputBinding — steps slot metadata (no static, AddToParent handles it)\n expect(ops[9].type).toBe(\"SetGlobalInputBinding\");\n expect(ops[9].elementId).toBe(funnelId);\n expect(ops[9].bindingPath).toBe(\"steps\");\n expect(ops[9].binding.static).toBeUndefined();\n expect(ops[9].binding.type).toBe(\"slot\");\n expect(ops[9].binding.list).toBe(true);\n\n // 10: AddElement — Step 2\n expect(ops[10].element.component.name).toBe(\"FunnelBuilder/Step\");\n\n // 11: AddToParent — Step 2 (undefined = append)\n expect(ops[11].index).toBeUndefined();\n\n // 12-15: Step 2 bindings + styles\n expect(ops[12].binding.static).toBe(\"Final Step\");\n expect(ops[13].binding.static).toEqual([]);\n\n // 16: SetGlobalInputBinding — steps slot metadata (no static)\n expect(ops[16].type).toBe(\"SetGlobalInputBinding\");\n expect(ops[16].elementId).toBe(funnelId);\n expect(ops[16].bindingPath).toBe(\"steps\");\n expect(ops[16].binding.static).toBeUndefined();\n\n // 17-18: Funnel style bindings\n expect(ops[17].bindingPath).toBe(\"display\");\n expect(ops[18].bindingPath).toBe(\"flexDirection\");\n\n expect(ops).toHaveLength(19);\n });\n\n it(\"should produce correct document after applying all operations\", () => {\n const factory = new ElementFactory(components);\n const result = factory.createElementFromComponent({\n componentName: \"FunnelBuilder/Funnel\",\n parentId: \"root\",\n slot: \"children\",\n index: 0,\n bindings: {\n inputs: {\n fields: [],\n activeStep: 0,\n steps: [\n {\n action: \"CreateElement\",\n params: {\n component: \"FunnelBuilder/Step\",\n inputs: { label: \"Step 1\", children: [] }\n }\n },\n {\n action: \"CreateElement\",\n params: {\n component: \"FunnelBuilder/Step\",\n inputs: { label: \"Final Step\", children: [] }\n }\n }\n ]\n }\n }\n });\n\n const document = {\n state: {},\n elements: {\n root: {\n type: \"Webiny/Element\",\n id: \"root\",\n component: { name: \"Webiny/Root\" }\n }\n },\n bindings: {}\n } as unknown as Document;\n\n for (const op of result.operations) {\n op.apply(document);\n }\n\n const funnelId = result.element.id;\n\n // Both step elements exist in the document.\n const stepElements = Object.values(document.elements).filter(\n el => el.component.name === \"FunnelBuilder/Step\"\n );\n expect(stepElements).toHaveLength(2);\n\n // Both steps have their correct labels.\n const labels = stepElements.map(el => document.bindings[el.id]?.inputs?.label?.static);\n expect(labels).toContain(\"Step 1\");\n expect(labels).toContain(\"Final Step\");\n\n // The steps binding contains both step IDs in order.\n const stepsBinding = document.bindings[funnelId]?.inputs?.steps;\n expect(stepsBinding?.list).toBe(true);\n expect(stepsBinding?.type).toBe(\"slot\");\n expect(stepsBinding?.static).toHaveLength(2);\n\n const step1 = stepElements.find(\n el => document.bindings[el.id]?.inputs?.label?.static === \"Step 1\"\n )!;\n const step2 = stepElements.find(\n el => document.bindings[el.id]?.inputs?.label?.static === \"Final Step\"\n )!;\n expect(stepsBinding?.static).toEqual([step1.id, step2.id]);\n });\n});\n"],"names":["components","serializeOp","op","DocumentOperations","describe","it","factory","ElementFactory","result","ops","funnelId","expect","step1Id","document","stepElements","Object","el","labels","stepsBinding","step1","step2"],"mappings":";;;AAKA,MAAMA,aAAgD;IAClD,eAAe;QACX,MAAM;QACN,OAAO;QACP,MAAM,EAAE;QACR,QAAQ;YACJ;gBACI,MAAM;gBACN,MAAM;gBACN,UAAU;gBACV,cAAc,EAAE;gBAChB,MAAM;YACV;SACH;IACL;IACA,wBAAwB;QACpB,MAAM;QACN,OAAO;QACP,MAAM,EAAE;QACR,QAAQ;YACJ;gBACI,MAAM;gBACN,UAAU;gBACV,MAAM;gBACN,MAAM;gBACN,QAAQ,EAAE;gBACV,cAAc,EAAE;YACpB;YACA;gBACI,MAAM;gBACN,UAAU;gBACV,MAAM;gBACN,OAAO;gBACP,cAAc;YAClB;YACA;gBACI,MAAM;gBACN,MAAM;gBACN,UAAU;gBACV,cAAc,EAAE;gBAChB,MAAM;YACV;YACA;gBACI,MAAM;gBACN,UAAU;gBACV,MAAM;gBACN,MAAM;gBACN,QAAQ,EAAE;YACd;SACH;IACL;IACA,sBAAsB;QAClB,MAAM;QACN,OAAO;QACP,MAAM,EAAE;QACR,QAAQ;YACJ;gBACI,MAAM;gBACN,UAAU;gBACV,MAAM;gBACN,OAAO;YACX;YACA;gBACI,MAAM;gBACN,MAAM;gBACN,UAAU;gBACV,cAAc,EAAE;gBAChB,MAAM;YACV;SACH;IACL;AACJ;AAKA,SAASC,YAAYC,EAAO;IACxB,IAAIA,cAAcC,mBAAmB,UAAU,EAC3C,OAAO;QAAE,MAAM;QAAc,SAASD,EAAE,CAAC,UAAU;IAAC;IAExD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,CAAC;QAChCP,OAAOO,cAAc,QAAQ,YAAY,CAAC;QAE1C,MAAMC,QAAQL,aAAa,IAAI,CAC3BE,CAAAA,KAAMH,SAAS,QAAQ,CAACG,GAAG,EAAE,CAAC,EAAE,QAAQ,OAAO,WAAW;QAE9D,MAAMI,QAAQN,aAAa,IAAI,CAC3BE,CAAAA,KAAMH,SAAS,QAAQ,CAACG,GAAG,EAAE,CAAC,EAAE,QAAQ,OAAO,WAAW;QAE9DL,OAAOO,cAAc,QAAQ,OAAO,CAAC;YAACC,MAAM,EAAE;YAAEC,MAAM,EAAE;SAAC;IAC7D;AACJ"}
1
+ {"version":3,"file":"ElementFactory.test.js","sources":["../src/ElementFactory.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { ElementFactory } from \"./ElementFactory.js\";\nimport { DocumentOperations } from \"./documentOperations/index.js\";\nimport type { ComponentManifest, Document } from \"~/types.js\";\n\nconst components: Record<string, ComponentManifest> = {\n \"Webiny/Root\": {\n name: \"Webiny/Root\",\n label: \"Main Content\",\n tags: [],\n inputs: [\n {\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n defaultValue: [],\n name: \"children\"\n }\n ]\n },\n \"FunnelBuilder/Funnel\": {\n name: \"FunnelBuilder/Funnel\",\n label: \"Funnel\",\n tags: [],\n inputs: [\n {\n type: \"object\",\n renderer: \"Webiny/Object\",\n name: \"fields\",\n list: true,\n fields: [],\n defaultValue: []\n },\n {\n type: \"number\",\n renderer: \"Webiny/Number\",\n name: \"activeStep\",\n label: \"Active Step\",\n defaultValue: 0\n },\n {\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n defaultValue: [],\n name: \"steps\"\n },\n {\n type: \"object\",\n renderer: \"FunnelBuilder/ConditionRulesRenderer\",\n name: \"conditionRules\",\n list: true,\n fields: []\n }\n ]\n },\n \"FunnelBuilder/Step\": {\n name: \"FunnelBuilder/Step\",\n label: \"Funnel Step\",\n tags: [],\n inputs: [\n {\n type: \"text\",\n renderer: \"Webiny/Input\",\n name: \"label\",\n label: \"Label\"\n },\n {\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n defaultValue: [],\n name: \"children\"\n }\n ]\n }\n};\n\n/**\n * Extract private fields from operation instances for assertion.\n */\nfunction serializeOp(op: any) {\n if (op instanceof DocumentOperations.AddElement) {\n return { type: \"AddElement\", element: op[\"element\"] };\n }\n if (op instanceof DocumentOperations.AddToParent) {\n return { type: \"AddToParent\", element: op[\"element\"], index: op[\"index\"] };\n }\n if (op instanceof DocumentOperations.SetGlobalInputBinding) {\n return {\n type: \"SetGlobalInputBinding\",\n elementId: op[\"elementId\"],\n bindingPath: op[\"bindingPath\"],\n binding: op[\"binding\"]\n };\n }\n if (op instanceof DocumentOperations.SetGlobalStyleBinding) {\n return {\n type: \"SetGlobalStyleBinding\",\n elementId: op[\"elementId\"],\n bindingPath: op[\"bindingPath\"],\n binding: op[\"binding\"]\n };\n }\n return op;\n}\n\ndescribe(\"ElementFactory\", () => {\n it(\"should produce correct operation sequence for a Funnel with two Steps\", () => {\n const factory = new ElementFactory(components);\n const result = factory.createElementFromComponent({\n componentName: \"FunnelBuilder/Funnel\",\n parentId: \"root\",\n slot: \"children\",\n index: 0,\n bindings: {\n inputs: {\n fields: [],\n activeStep: 0,\n steps: [\n {\n action: \"CreateElement\",\n params: {\n component: \"FunnelBuilder/Step\",\n inputs: { label: \"Step 1\", children: [] }\n }\n },\n {\n action: \"CreateElement\",\n params: {\n component: \"FunnelBuilder/Step\",\n inputs: { label: \"Final Step\", children: [] }\n }\n }\n ]\n }\n }\n });\n\n const ops = result.operations.map(serializeOp);\n const funnelId = result.element.id;\n\n // 0: AddElement — Funnel\n expect(ops[0].type).toBe(\"AddElement\");\n expect(ops[0].element.component.name).toBe(\"FunnelBuilder/Funnel\");\n\n // 1: AddToParent — Funnel → root/children at index 0\n expect(ops[1].type).toBe(\"AddToParent\");\n expect(ops[1].element.id).toBe(funnelId);\n expect(ops[1].index).toBe(0);\n\n // 2: SetGlobalInputBinding — activeStep = 0\n expect(ops[2].type).toBe(\"SetGlobalInputBinding\");\n expect(ops[2].elementId).toBe(funnelId);\n expect(ops[2].bindingPath).toBe(\"activeStep\");\n expect(ops[2].binding.static).toBe(0);\n\n // 3: AddElement — Step 1\n const step1Id = ops[3].element.id;\n expect(ops[3].type).toBe(\"AddElement\");\n expect(ops[3].element.component.name).toBe(\"FunnelBuilder/Step\");\n expect(ops[3].element.parent).toEqual({ id: funnelId, slot: \"steps\" });\n\n // 4: AddToParent — Step 1 (undefined = append)\n expect(ops[4].type).toBe(\"AddToParent\");\n expect(ops[4].element.id).toBe(step1Id);\n expect(ops[4].index).toBeUndefined();\n\n // 5: Step 1 label binding\n expect(ops[5].bindingPath).toBe(\"label\");\n expect(ops[5].binding.static).toBe(\"Step 1\");\n\n // 6: Step 1 children binding\n expect(ops[6].bindingPath).toBe(\"children\");\n expect(ops[6].binding.static).toEqual([]);\n\n // 7-8: Step 1 style bindings\n expect(ops[7].bindingPath).toBe(\"display\");\n expect(ops[8].bindingPath).toBe(\"flexDirection\");\n\n // 9: SetGlobalInputBinding — steps slot metadata (no static, AddToParent handles it)\n expect(ops[9].type).toBe(\"SetGlobalInputBinding\");\n expect(ops[9].elementId).toBe(funnelId);\n expect(ops[9].bindingPath).toBe(\"steps\");\n expect(ops[9].binding.static).toBeUndefined();\n expect(ops[9].binding.type).toBe(\"slot\");\n expect(ops[9].binding.list).toBe(true);\n\n // 10: AddElement — Step 2\n expect(ops[10].element.component.name).toBe(\"FunnelBuilder/Step\");\n\n // 11: AddToParent — Step 2 (undefined = append)\n expect(ops[11].index).toBeUndefined();\n\n // 12-15: Step 2 bindings + styles\n expect(ops[12].binding.static).toBe(\"Final Step\");\n expect(ops[13].binding.static).toEqual([]);\n\n // 16: SetGlobalInputBinding — steps slot metadata (no static)\n expect(ops[16].type).toBe(\"SetGlobalInputBinding\");\n expect(ops[16].elementId).toBe(funnelId);\n expect(ops[16].bindingPath).toBe(\"steps\");\n expect(ops[16].binding.static).toBeUndefined();\n\n // 17-18: Funnel style bindings\n expect(ops[17].bindingPath).toBe(\"display\");\n expect(ops[18].bindingPath).toBe(\"flexDirection\");\n\n expect(ops).toHaveLength(19);\n });\n\n it(\"should produce correct document after applying all operations\", () => {\n const factory = new ElementFactory(components);\n const result = factory.createElementFromComponent({\n componentName: \"FunnelBuilder/Funnel\",\n parentId: \"root\",\n slot: \"children\",\n index: 0,\n bindings: {\n inputs: {\n fields: [],\n activeStep: 0,\n steps: [\n {\n action: \"CreateElement\",\n params: {\n component: \"FunnelBuilder/Step\",\n inputs: { label: \"Step 1\", children: [] }\n }\n },\n {\n action: \"CreateElement\",\n params: {\n component: \"FunnelBuilder/Step\",\n inputs: { label: \"Final Step\", children: [] }\n }\n }\n ]\n }\n }\n });\n\n const document = {\n state: {},\n elements: {\n root: {\n type: \"Webiny/Element\",\n id: \"root\",\n component: { name: \"Webiny/Root\" }\n }\n },\n bindings: {}\n } as unknown as Document;\n\n for (const op of result.operations) {\n op.apply(document);\n }\n\n const funnelId = result.element.id;\n\n // Both step elements exist in the document.\n const stepElements = Object.values(document.elements).filter(\n el => el.component.name === \"FunnelBuilder/Step\"\n );\n expect(stepElements).toHaveLength(2);\n\n // Both steps have their correct labels.\n const labels = stepElements.map(el => document.bindings[el.id]?.inputs?.label?.static);\n expect(labels).toContain(\"Step 1\");\n expect(labels).toContain(\"Final Step\");\n\n // The steps binding contains both step IDs in order.\n const stepsBinding = document.bindings[funnelId]?.inputs?.steps;\n expect(stepsBinding?.list).toBe(true);\n expect(stepsBinding?.type).toBe(\"slot\");\n expect(stepsBinding?.static).toHaveLength(2);\n\n const step1 = stepElements.find(\n el => document.bindings[el.id]?.inputs?.label?.static === \"Step 1\"\n )!;\n const step2 = stepElements.find(\n el => document.bindings[el.id]?.inputs?.label?.static === \"Final Step\"\n )!;\n expect(stepsBinding?.static).toEqual([step1.id, step2.id]);\n });\n it(\"should keep every item of a primitive list (tags) from the component defaults\", () => {\n const pricing: ComponentManifest = {\n name: \"Custom/PricingPlans\",\n label: \"Pricing Plans\",\n tags: [],\n inputs: [\n {\n type: \"text\",\n list: true,\n renderer: \"Webiny/Tags\",\n name: \"highlights\",\n defaultValue: [\"Default\"]\n },\n {\n type: \"object\",\n list: true,\n renderer: \"Webiny/Object\",\n name: \"plans\",\n fields: [\n { type: \"text\", renderer: \"Webiny/Input\", name: \"name\" },\n {\n type: \"text\",\n list: true,\n renderer: \"Webiny/Tags\",\n name: \"features\",\n defaultValue: [\"Feature one\", \"Feature two\"]\n }\n ]\n }\n ],\n defaults: {\n inputs: {\n highlights: [\"Fast\", \"Cheap\"],\n plans: [\n { name: \"Hobby\", features: [\"Autocomplete\", \"Limited AI integration\"] },\n { name: \"Enterprise\", features: [\"Everything in Hobby\", \"24/7 Support\"] }\n ]\n }\n }\n };\n\n const factory = new ElementFactory({ ...components, [pricing.name]: pricing });\n const result = factory.createElementFromComponent({\n componentName: pricing.name,\n parentId: \"root\",\n slot: \"children\"\n });\n\n const document = {\n state: {},\n elements: {\n root: {\n type: \"Webiny/Element\",\n id: \"root\",\n component: { name: \"Webiny/Root\" }\n }\n },\n bindings: {}\n } as unknown as Document;\n\n for (const op of result.operations) {\n op.apply(document);\n }\n\n const inputs = document.bindings[result.element.id]!.inputs!;\n expect(inputs[\"highlights\"]?.static).toEqual([\"Fast\", \"Cheap\"]);\n expect(inputs[\"plans/0/name\"]?.static).toBe(\"Hobby\");\n expect(inputs[\"plans/0/features\"]?.static).toEqual([\n \"Autocomplete\",\n \"Limited AI integration\"\n ]);\n expect(inputs[\"plans/1/features\"]?.static).toEqual([\"Everything in Hobby\", \"24/7 Support\"]);\n });\n});\n"],"names":["components","serializeOp","op","DocumentOperations","describe","it","factory","ElementFactory","result","ops","funnelId","expect","step1Id","document","stepElements","Object","el","labels","stepsBinding","step1","step2","pricing","inputs"],"mappings":";;;AAKA,MAAMA,aAAgD;IAClD,eAAe;QACX,MAAM;QACN,OAAO;QACP,MAAM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MAAM,CAAC,eAAe,EAAE,QAAQ,IAAI,CAAC;QAC5CX,OAAOW,MAAM,CAAC,mBAAmB,EAAE,QAAQ,OAAO,CAAC;YAC/C;YACA;SACH;QACDX,OAAOW,MAAM,CAAC,mBAAmB,EAAE,QAAQ,OAAO,CAAC;YAAC;YAAuB;SAAe;IAC9F;AACJ"}
@@ -1 +1 @@
1
- export declare const GET_PAGE_BY_ID = "\n query GetPageById($id: ID!) {\n websiteBuilder {\n getPageById(id: $id) {\n data {\n id\n properties\n elements\n bindings\n extensions\n languagePaths\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n";
1
+ export declare const GET_PAGE_BY_ID = "\n query GetPageById($id: ID!) {\n websiteBuilder {\n getPageById(id: $id) {\n data {\n id\n version\n properties\n metadata\n elements\n bindings\n extensions\n languagePaths\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n";
@@ -4,7 +4,9 @@ const GET_PAGE_BY_ID = `
4
4
  getPageById(id: $id) {
5
5
  data {
6
6
  id
7
+ version
7
8
  properties
9
+ metadata
8
10
  elements
9
11
  bindings
10
12
  extensions
@@ -1 +1 @@
1
- {"version":3,"file":"dataProviders/GET_PAGE_BY_ID.js","sources":["../../src/dataProviders/GET_PAGE_BY_ID.ts"],"sourcesContent":["export const GET_PAGE_BY_ID = /* GraphQL*/ `\n query GetPageById($id: ID!) {\n websiteBuilder {\n getPageById(id: $id) {\n data {\n id\n properties\n elements\n bindings\n extensions\n languagePaths\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n"],"names":["GET_PAGE_BY_ID"],"mappings":"AAAO,MAAMA,iBAA8B,CAAC;;;;;;;;;;;;;;;;;;;;AAoB5C,CAAC"}
1
+ {"version":3,"file":"dataProviders/GET_PAGE_BY_ID.js","sources":["../../src/dataProviders/GET_PAGE_BY_ID.ts"],"sourcesContent":["export const GET_PAGE_BY_ID = /* GraphQL*/ `\n query GetPageById($id: ID!) {\n websiteBuilder {\n getPageById(id: $id) {\n data {\n id\n version\n properties\n metadata\n elements\n bindings\n extensions\n languagePaths\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n"],"names":["GET_PAGE_BY_ID"],"mappings":"AAAO,MAAMA,iBAA8B,CAAC;;;;;;;;;;;;;;;;;;;;;;AAsB5C,CAAC"}
@@ -1 +1 @@
1
- export declare const GET_PAGE_BY_PATH = "\n query GetPageByPath($path: String!) {\n websiteBuilder {\n getPageByPath(path: $path) {\n data {\n id\n properties\n elements\n bindings\n extensions\n languagePaths\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n";
1
+ export declare const GET_PAGE_BY_PATH = "\n query GetPageByPath($path: String!) {\n websiteBuilder {\n getPageByPath(path: $path) {\n data {\n id\n version\n properties\n metadata\n elements\n bindings\n extensions\n languagePaths\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n";
@@ -4,7 +4,9 @@ const GET_PAGE_BY_PATH = `
4
4
  getPageByPath(path: $path) {
5
5
  data {
6
6
  id
7
+ version
7
8
  properties
9
+ metadata
8
10
  elements
9
11
  bindings
10
12
  extensions
@@ -1 +1 @@
1
- {"version":3,"file":"dataProviders/GET_PAGE_BY_PATH.js","sources":["../../src/dataProviders/GET_PAGE_BY_PATH.ts"],"sourcesContent":["export const GET_PAGE_BY_PATH = /* GraphQL*/ `\n query GetPageByPath($path: String!) {\n websiteBuilder {\n getPageByPath(path: $path) {\n data {\n id\n properties\n elements\n bindings\n extensions\n languagePaths\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n"],"names":["GET_PAGE_BY_PATH"],"mappings":"AAAO,MAAMA,mBAAgC,CAAC;;;;;;;;;;;;;;;;;;;;AAoB9C,CAAC"}
1
+ {"version":3,"file":"dataProviders/GET_PAGE_BY_PATH.js","sources":["../../src/dataProviders/GET_PAGE_BY_PATH.ts"],"sourcesContent":["export const GET_PAGE_BY_PATH = /* GraphQL*/ `\n query GetPageByPath($path: String!) {\n websiteBuilder {\n getPageByPath(path: $path) {\n data {\n id\n version\n properties\n metadata\n elements\n bindings\n extensions\n languagePaths\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n"],"names":["GET_PAGE_BY_PATH"],"mappings":"AAAO,MAAMA,mBAAgC,CAAC;;;;;;;;;;;;;;;;;;;;;;AAsB9C,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
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
@@ -0,0 +1 @@
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/website-builder-sdk",
3
- "version": "6.5.0-beta.1",
3
+ "version": "6.5.0-beta.10",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,7 @@
12
12
  "author": "Pavel Denisjuk",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@webiny/sdk": "6.5.0-beta.1",
15
+ "@webiny/sdk": "6.5.0-beta.10",
16
16
  "csstype": "3.2.3",
17
17
  "deep-equal": "2.2.3",
18
18
  "deepmerge": "4.3.1",
@@ -20,19 +20,19 @@
20
20
  "fast-json-stable-stringify": "2.1.0",
21
21
  "is-hotkey": "0.2.0",
22
22
  "lodash": "4.18.1",
23
- "matcher": "6.0.0",
24
- "mobx": "6.16.1",
25
- "nanoid": "6.0.0",
23
+ "matcher": "7.0.0",
24
+ "mobx": "7.0.6",
25
+ "nanoid": "6.0.1",
26
26
  "nanoid-dictionary": "5.0.0",
27
- "pino": "10.3.1",
27
+ "pino": "10.4.0",
28
28
  "pino-pretty": "13.1.3"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/deep-equal": "1.0.4",
32
32
  "@types/is-hotkey": "0.1.10",
33
- "@webiny/build-tools": "6.5.0-beta.1",
33
+ "@webiny/build-tools": "6.5.0-beta.10",
34
34
  "typescript": "7.0.2",
35
- "vitest": "4.1.10"
35
+ "vitest": "5.0.3"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"