@webiny/website-builder-sdk 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.eb81deee7e

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.
Files changed (272) hide show
  1. package/BindingsApi.js +29 -36
  2. package/BindingsApi.js.map +1 -1
  3. package/BindingsProcessor.js +34 -43
  4. package/BindingsProcessor.js.map +1 -1
  5. package/BindingsProcessor.test.js +82 -78
  6. package/BindingsProcessor.test.js.map +1 -1
  7. package/BindingsResolver.d.ts +4 -1
  8. package/BindingsResolver.js +99 -119
  9. package/BindingsResolver.js.map +1 -1
  10. package/BindingsResolver.test.js +399 -363
  11. package/BindingsResolver.test.js.map +1 -1
  12. package/ComponentInputTraverser.js +32 -49
  13. package/ComponentInputTraverser.js.map +1 -1
  14. package/ComponentManifestToAstConverter.js +20 -21
  15. package/ComponentManifestToAstConverter.js.map +1 -1
  16. package/ComponentRegistry.d.ts +9 -0
  17. package/ComponentRegistry.js +30 -44
  18. package/ComponentRegistry.js.map +1 -1
  19. package/ComponentResolver.d.ts +3 -2
  20. package/ComponentResolver.js +39 -29
  21. package/ComponentResolver.js.map +1 -1
  22. package/ComponentResolver.test.d.ts +1 -0
  23. package/ComponentResolver.test.js +81 -0
  24. package/ComponentResolver.test.js.map +1 -0
  25. package/ConstraintEvaluator.js +246 -353
  26. package/ConstraintEvaluator.js.map +1 -1
  27. package/ConstraintEvaluator.test.js +1616 -1438
  28. package/ConstraintEvaluator.test.js.map +1 -1
  29. package/ContentSdk.d.ts +14 -0
  30. package/ContentSdk.js +113 -90
  31. package/ContentSdk.js.map +1 -1
  32. package/DocumentStore.js +47 -59
  33. package/DocumentStore.js.map +1 -1
  34. package/DocumentStoreManager.js +17 -16
  35. package/DocumentStoreManager.js.map +1 -1
  36. package/EditingSdk.js +92 -121
  37. package/EditingSdk.js.map +1 -1
  38. package/ElementFactory.js +164 -172
  39. package/ElementFactory.js.map +1 -1
  40. package/ElementFactory.objectListDefaults.test.d.ts +1 -0
  41. package/ElementFactory.objectListDefaults.test.js +423 -0
  42. package/ElementFactory.objectListDefaults.test.js.map +1 -0
  43. package/ElementFactory.test.js +335 -262
  44. package/ElementFactory.test.js.map +1 -1
  45. package/Environment.js +18 -19
  46. package/Environment.js.map +1 -1
  47. package/FunctionConverter.js +8 -7
  48. package/FunctionConverter.js.map +1 -1
  49. package/HashObject.js +11 -26
  50. package/HashObject.js.map +1 -1
  51. package/HotkeyManager.js +40 -47
  52. package/HotkeyManager.js.map +1 -1
  53. package/IBindingsUpdater.js +0 -3
  54. package/IRedirects.js +0 -3
  55. package/InheritanceProcessor.js +99 -139
  56. package/InheritanceProcessor.js.map +1 -1
  57. package/InheritanceProcessor.test.js +178 -179
  58. package/InheritanceProcessor.test.js.map +1 -1
  59. package/InheritedValueResolver.d.ts +18 -1
  60. package/InheritedValueResolver.js +18 -20
  61. package/InheritedValueResolver.js.map +1 -1
  62. package/InputBindingsProcessor.d.ts +23 -2
  63. package/InputBindingsProcessor.js +200 -307
  64. package/InputBindingsProcessor.js.map +1 -1
  65. package/InputBindingsProcessorTokens.test.d.ts +1 -0
  66. package/InputBindingsProcessorTokens.test.js +400 -0
  67. package/InputBindingsProcessorTokens.test.js.map +1 -0
  68. package/InputsBindingsProcessor.test.js +334 -315
  69. package/InputsBindingsProcessor.test.js.map +1 -1
  70. package/InputsUpdater.js +23 -26
  71. package/InputsUpdater.js.map +1 -1
  72. package/LiveSdk.js +12 -13
  73. package/LiveSdk.js.map +1 -1
  74. package/Logger.js +9 -8
  75. package/Logger.js.map +1 -1
  76. package/MouseTracker.js +77 -83
  77. package/MouseTracker.js.map +1 -1
  78. package/NullSdk.js +22 -21
  79. package/NullSdk.js.map +1 -1
  80. package/PreviewDocument.d.ts +1 -0
  81. package/PreviewDocument.js +30 -30
  82. package/PreviewDocument.js.map +1 -1
  83. package/PreviewSdk.d.ts +2 -1
  84. package/PreviewSdk.js +19 -17
  85. package/PreviewSdk.js.map +1 -1
  86. package/PreviewViewport.js +51 -63
  87. package/PreviewViewport.js.map +1 -1
  88. package/ResizeObserver.js +24 -31
  89. package/ResizeObserver.js.map +1 -1
  90. package/StylesBindingsProcessor.d.ts +12 -2
  91. package/StylesBindingsProcessor.js +62 -79
  92. package/StylesBindingsProcessor.js.map +1 -1
  93. package/StylesUpdater.js +20 -25
  94. package/StylesUpdater.js.map +1 -1
  95. package/Theme.js +30 -25
  96. package/Theme.js.map +1 -1
  97. package/ViewportManager.js +89 -101
  98. package/ViewportManager.js.map +1 -1
  99. package/assertBindingShapes.d.ts +31 -0
  100. package/assertBindingShapes.js +64 -0
  101. package/assertBindingShapes.js.map +1 -0
  102. package/assertBindingShapes.test.d.ts +1 -0
  103. package/assertBindingShapes.test.js +131 -0
  104. package/assertBindingShapes.test.js.map +1 -0
  105. package/asset/deliveryUrl.d.ts +41 -0
  106. package/asset/deliveryUrl.js +34 -0
  107. package/asset/deliveryUrl.js.map +1 -0
  108. package/asset/deliveryUrl.test.d.ts +1 -0
  109. package/asset/deliveryUrl.test.js +127 -0
  110. package/asset/deliveryUrl.test.js.map +1 -0
  111. package/asset/geometry.d.ts +7 -0
  112. package/asset/geometry.js +10 -0
  113. package/asset/geometry.js.map +1 -0
  114. package/asset/imageSrcSet.d.ts +63 -0
  115. package/asset/imageSrcSet.js +98 -0
  116. package/asset/imageSrcSet.js.map +1 -0
  117. package/asset/imageSrcSet.test.d.ts +1 -0
  118. package/asset/imageSrcSet.test.js +103 -0
  119. package/asset/imageSrcSet.test.js.map +1 -0
  120. package/asset/index.d.ts +5 -0
  121. package/asset/index.js +5 -0
  122. package/asset/normalize.d.ts +24 -0
  123. package/asset/normalize.js +106 -0
  124. package/asset/normalize.js.map +1 -0
  125. package/asset/normalize.test.d.ts +1 -0
  126. package/asset/normalize.test.js +263 -0
  127. package/asset/normalize.test.js.map +1 -0
  128. package/asset/types.d.ts +2 -0
  129. package/asset/types.js +0 -0
  130. package/constants.js +7 -6
  131. package/constants.js.map +1 -1
  132. package/contentEntry/ContentEntryBindingsResolver.d.ts +30 -0
  133. package/contentEntry/ContentEntryBindingsResolver.js +45 -0
  134. package/contentEntry/ContentEntryBindingsResolver.js.map +1 -0
  135. package/contentEntry/ContentEntryCache.d.ts +46 -0
  136. package/contentEntry/ContentEntryCache.js +50 -0
  137. package/contentEntry/ContentEntryCache.js.map +1 -0
  138. package/contentEntry/resolveContentEntry.d.ts +74 -0
  139. package/contentEntry/resolveContentEntry.js +53 -0
  140. package/contentEntry/resolveContentEntry.js.map +1 -0
  141. package/contentEntry/resolveContentEntry.test.d.ts +1 -0
  142. package/contentEntry/resolveContentEntry.test.js +213 -0
  143. package/contentEntry/resolveContentEntry.test.js.map +1 -0
  144. package/createComponent.d.ts +5 -0
  145. package/createComponent.js +32 -0
  146. package/createComponent.js.map +1 -0
  147. package/createElement.js +5 -6
  148. package/createElement.js.map +1 -1
  149. package/createInput.d.ts +10 -2
  150. package/createInput.js +92 -143
  151. package/createInput.js.map +1 -1
  152. package/createTheme.js +2 -3
  153. package/createTheme.js.map +1 -1
  154. package/dataProviders/ApiClient.d.ts +10 -5
  155. package/dataProviders/ApiClient.js +40 -49
  156. package/dataProviders/ApiClient.js.map +1 -1
  157. package/dataProviders/DefaultDataProvider.d.ts +4 -0
  158. package/dataProviders/DefaultDataProvider.js +91 -58
  159. package/dataProviders/DefaultDataProvider.js.map +1 -1
  160. package/dataProviders/GET_EXPERIMENT_PAUSED.d.ts +1 -0
  161. package/dataProviders/GET_EXPERIMENT_PAUSED.js +17 -0
  162. package/dataProviders/GET_EXPERIMENT_PAUSED.js.map +1 -0
  163. package/dataProviders/GET_PAGE_BY_ID.js +2 -1
  164. package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
  165. package/dataProviders/GET_PAGE_BY_PATH.js +2 -1
  166. package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
  167. package/dataProviders/GET_PAGE_EXPERIMENT.d.ts +1 -0
  168. package/dataProviders/GET_PAGE_EXPERIMENT.js +32 -0
  169. package/dataProviders/GET_PAGE_EXPERIMENT.js.map +1 -0
  170. package/dataProviders/GET_VARIANT_CONTENT.d.ts +1 -0
  171. package/dataProviders/GET_VARIANT_CONTENT.js +24 -0
  172. package/dataProviders/GET_VARIANT_CONTENT.js.map +1 -0
  173. package/dataProviders/LIST_PUBLISHED_PAGES.js +2 -1
  174. package/dataProviders/LIST_PUBLISHED_PAGES.js.map +1 -1
  175. package/dataProviders/NullDataProvider.d.ts +4 -0
  176. package/dataProviders/NullDataProvider.js +30 -20
  177. package/dataProviders/NullDataProvider.js.map +1 -1
  178. package/dataProviders/RedirectsProvider.js +24 -27
  179. package/dataProviders/RedirectsProvider.js.map +1 -1
  180. package/defaultBreakpoints.js +43 -22
  181. package/defaultBreakpoints.js.map +1 -1
  182. package/documentOperations/$addElementReferenceToParent.js +29 -32
  183. package/documentOperations/$addElementReferenceToParent.js.map +1 -1
  184. package/documentOperations/AddElement.js +8 -7
  185. package/documentOperations/AddElement.js.map +1 -1
  186. package/documentOperations/AddToParent.js +14 -13
  187. package/documentOperations/AddToParent.js.map +1 -1
  188. package/documentOperations/IDocumentOperation.js +0 -3
  189. package/documentOperations/RemoveElement.js +9 -15
  190. package/documentOperations/RemoveElement.js.map +1 -1
  191. package/documentOperations/SetGlobalInputBinding.js +23 -22
  192. package/documentOperations/SetGlobalInputBinding.js.map +1 -1
  193. package/documentOperations/SetGlobalStyleBinding.js +23 -23
  194. package/documentOperations/SetGlobalStyleBinding.js.map +1 -1
  195. package/documentOperations/SetInputBindingOverride.js +30 -29
  196. package/documentOperations/SetInputBindingOverride.js.map +1 -1
  197. package/documentOperations/SetStyleBindingOverride.js +30 -31
  198. package/documentOperations/SetStyleBindingOverride.js.map +1 -1
  199. package/documentOperations/index.js +9 -8
  200. package/documentOperations/index.js.map +1 -1
  201. package/experiments/PostHogAnalyticsProvider.d.ts +31 -0
  202. package/experiments/PostHogAnalyticsProvider.js +28 -0
  203. package/experiments/PostHogAnalyticsProvider.js.map +1 -0
  204. package/experiments/analyticsProvider.d.ts +4 -0
  205. package/experiments/analyticsProvider.js +11 -0
  206. package/experiments/analyticsProvider.js.map +1 -0
  207. package/experiments/bucketing.d.ts +27 -0
  208. package/experiments/bucketing.js +91 -0
  209. package/experiments/bucketing.js.map +1 -0
  210. package/experiments/bucketing.test.d.ts +1 -0
  211. package/experiments/bucketing.test.js +183 -0
  212. package/experiments/bucketing.test.js.map +1 -0
  213. package/experiments/index.d.ts +5 -0
  214. package/experiments/index.js +5 -0
  215. package/experiments/render.d.ts +79 -0
  216. package/experiments/render.js +149 -0
  217. package/experiments/render.js.map +1 -0
  218. package/experiments/types.d.ts +108 -0
  219. package/experiments/types.js +4 -0
  220. package/experiments/types.js.map +1 -0
  221. package/findMatchingAstNode.js +11 -13
  222. package/findMatchingAstNode.js.map +1 -1
  223. package/generateElementId.js +2 -1
  224. package/generateElementId.js.map +1 -1
  225. package/headersProvider.js +4 -3
  226. package/headersProvider.js.map +1 -1
  227. package/image/geometry.d.ts +54 -0
  228. package/image/geometry.js +112 -0
  229. package/image/geometry.js.map +1 -0
  230. package/image/geometry.test.d.ts +1 -0
  231. package/image/geometry.test.js +190 -0
  232. package/image/geometry.test.js.map +1 -0
  233. package/image/index.d.ts +3 -0
  234. package/image/index.js +3 -0
  235. package/image/presets.d.ts +6 -0
  236. package/image/presets.js +20 -0
  237. package/image/presets.js.map +1 -0
  238. package/image/types.d.ts +10 -0
  239. package/image/types.js +0 -0
  240. package/index.d.ts +10 -0
  241. package/index.js +10 -2
  242. package/jsonPatch.js +5 -9
  243. package/jsonPatch.js.map +1 -1
  244. package/messages.js +12 -11
  245. package/messages.js.map +1 -1
  246. package/messenger/MessageOrigin.js +12 -11
  247. package/messenger/MessageOrigin.js.map +1 -1
  248. package/messenger/Messenger.js +58 -69
  249. package/messenger/Messenger.js.map +1 -1
  250. package/messenger/index.js +0 -2
  251. package/package.json +12 -9
  252. package/registerComponentGroup.js +5 -6
  253. package/registerComponentGroup.js.map +1 -1
  254. package/tokenBinding.d.ts +26 -0
  255. package/tokenBinding.js +15 -0
  256. package/tokenBinding.js.map +1 -0
  257. package/tokenBinding.test.d.ts +1 -0
  258. package/tokenBinding.test.js +165 -0
  259. package/tokenBinding.test.js.map +1 -0
  260. package/types/ShorthandCssProperties.js +0 -3
  261. package/types/WebsiteBuilderTheme.d.ts +12 -0
  262. package/types/WebsiteBuilderTheme.js +0 -3
  263. package/types.d.ts +96 -1
  264. package/types.js +0 -3
  265. package/IBindingsUpdater.js.map +0 -1
  266. package/IRedirects.js.map +0 -1
  267. package/documentOperations/IDocumentOperation.js.map +0 -1
  268. package/index.js.map +0 -1
  269. package/messenger/index.js.map +0 -1
  270. package/types/ShorthandCssProperties.js.map +0 -1
  271. package/types/WebsiteBuilderTheme.js.map +0 -1
  272. package/types.js.map +0 -1
package/createInput.js CHANGED
@@ -1,160 +1,109 @@
1
1
  import { functionConverter } from "./FunctionConverter.js";
2
-
3
- /**
4
- * TypeScript Overload Resolution and Input Factory Design
5
- *
6
- * Each input factory (e.g., createTextInput) is defined with two TypeScript overload signatures:
7
- * 1. One overload requires a `name` property in the input (used for array-based APIs, where inference is needed).
8
- * 2. The other overload omits the `name` property (used for object-based APIs, where the key provides the name).
9
- *
10
- * TypeScript resolves overloads by scanning from top to bottom and picking the first matching signature.
11
- * The implementation signature uses `any` for the argument, and the return type is unified to match all overloads.
12
- *
13
- * In array mode, the `name` must be explicitly provided in the input object, so inference for `TName` works.
14
- * In object mode, the input does not require a `name` property; instead, the key in the object (e.g., `{ foo: createTextInput({ ... }) }`)
15
- * provides the name via contextual typing from the consuming function (such as `createComponent`). TypeScript uses this context
16
- * to resolve the correct type for `TName` even when `name` is omitted from the input.
17
- *
18
- * This pattern ensures that all returned input objects are typed as `{ name: TName }`, whether `name` is provided explicitly or inferred,
19
- * so consumers of these factories do not need to worry about the presence of the `name` property in the result.
20
- */
21
- // Text
22
-
23
- export function createTextInput(input) {
24
- return createInput({
25
- type: "text",
26
- renderer: "Webiny/Input",
27
- ...input
28
- });
2
+ function createTextInput(input) {
3
+ return createInput({
4
+ type: "text",
5
+ renderer: "Webiny/Input",
6
+ ...input
7
+ });
29
8
  }
30
-
31
- // Long Text
32
-
33
- export function createLongTextInput(input) {
34
- return createInput({
35
- type: "longText",
36
- renderer: "Webiny/Textarea",
37
- ...input
38
- });
9
+ function createLongTextInput(input) {
10
+ return createInput({
11
+ type: "longText",
12
+ renderer: "Webiny/Textarea",
13
+ ...input
14
+ });
39
15
  }
40
-
41
- // Number
42
-
43
- export function createNumberInput(input) {
44
- return createInput({
45
- type: "number",
46
- renderer: "Webiny/Number",
47
- ...input
48
- });
16
+ function createNumberInput(input) {
17
+ return createInput({
18
+ type: "number",
19
+ renderer: "Webiny/Number",
20
+ ...input
21
+ });
49
22
  }
50
-
51
- // Boolean
52
-
53
- export function createBooleanInput(input) {
54
- return createInput({
55
- type: "boolean",
56
- renderer: "Webiny/Switch",
57
- ...input
58
- });
23
+ function createBooleanInput(input) {
24
+ return createInput({
25
+ type: "boolean",
26
+ renderer: "Webiny/Switch",
27
+ ...input
28
+ });
59
29
  }
60
-
61
- // Color
62
-
63
- export function createColorInput(input) {
64
- return createInput({
65
- type: "color",
66
- renderer: "Webiny/ColorPicker",
67
- ...input
68
- });
30
+ function createColorInput(input) {
31
+ return createInput({
32
+ type: "color",
33
+ renderer: "Webiny/ColorPicker",
34
+ ...input
35
+ });
69
36
  }
70
-
71
- // File
72
-
73
- export function createFileInput(input) {
74
- return createInput({
75
- type: "file",
76
- renderer: "Webiny/FileManager",
77
- ...input
78
- });
37
+ function createFileInput(input) {
38
+ return createInput({
39
+ type: "file",
40
+ renderer: "Webiny/FileManager",
41
+ ...input
42
+ });
79
43
  }
80
-
81
- // Date
82
-
83
- export function createDateInput(input) {
84
- return createInput({
85
- type: "datetime",
86
- renderer: "Webiny/DateTime",
87
- ...input
88
- });
44
+ function createDateInput(input) {
45
+ return createInput({
46
+ type: "datetime",
47
+ renderer: "Webiny/DateTime",
48
+ ...input
49
+ });
89
50
  }
90
-
91
- // Rich Text
92
-
93
- export function createLexicalInput(input) {
94
- return createInput({
95
- type: "lexical",
96
- renderer: "Webiny/Lexical",
97
- ...input
98
- });
51
+ function createLexicalInput(input) {
52
+ return createInput({
53
+ type: "lexical",
54
+ renderer: "Webiny/Lexical",
55
+ ...input
56
+ });
99
57
  }
100
-
101
- // Select
102
-
103
- export function createSelectInput(input) {
104
- return createInput({
105
- type: "select",
106
- renderer: "Webiny/Select",
107
- ...input
108
- });
58
+ function createSelectInput(input) {
59
+ return createInput({
60
+ type: "select",
61
+ renderer: "Webiny/Select",
62
+ ...input
63
+ });
109
64
  }
110
-
111
- // Radio
112
-
113
- export function createRadioInput(input) {
114
- return createInput({
115
- type: "radio",
116
- renderer: "Webiny/RadioGroup",
117
- ...input
118
- });
65
+ function createRadioInput(input) {
66
+ return createInput({
67
+ type: "radio",
68
+ renderer: "Webiny/RadioGroup",
69
+ ...input
70
+ });
119
71
  }
120
-
121
- // Object
122
-
123
- export function createObjectInput(input) {
124
- return createInput({
125
- type: "object",
126
- renderer: "Webiny/Object",
127
- ...input
128
- });
72
+ function createObjectInput(input) {
73
+ return createInput({
74
+ type: "object",
75
+ renderer: "Webiny/Object",
76
+ ...input
77
+ });
129
78
  }
130
-
131
- // Tags
132
-
133
- export function createTagsInput(input) {
134
- return createInput({
135
- type: "text",
136
- list: true,
137
- renderer: "Webiny/Tags",
138
- ...input
139
- });
79
+ function createTagsInput(input) {
80
+ return createInput({
81
+ type: "text",
82
+ list: true,
83
+ renderer: "Webiny/Tags",
84
+ ...input
85
+ });
140
86
  }
141
- export function createSlotInput(input) {
142
- return createInput({
143
- type: "slot",
144
- list: true,
145
- renderer: "Webiny/Slot",
146
- defaultValue: [],
147
- ...input
148
- });
87
+ function createSlotInput(input) {
88
+ return createInput({
89
+ type: "slot",
90
+ list: true,
91
+ renderer: "Webiny/Slot",
92
+ defaultValue: [],
93
+ ...input
94
+ });
149
95
  }
150
-
151
- // Implementation
152
- export function createInput(input) {
153
- if (input.onChange) {
154
- // @ts-expect-error We don't use this function on the frontend, so this is ok.
155
- input.onChange = functionConverter.serialize(input.onChange);
156
- }
157
- return input;
96
+ function createContentEntryInput(input) {
97
+ return createInput({
98
+ type: "contentEntry",
99
+ renderer: "Webiny/ContentEntry",
100
+ ...input
101
+ });
102
+ }
103
+ function createInput(input) {
104
+ if (input.onChange) input.onChange = functionConverter.serialize(input.onChange);
105
+ return input;
158
106
  }
107
+ export { createBooleanInput, createColorInput, createContentEntryInput, createDateInput, createFileInput, createInput, createLexicalInput, createLongTextInput, createNumberInput, createObjectInput, createRadioInput, createSelectInput, createSlotInput, createTagsInput, createTextInput };
159
108
 
160
109
  //# sourceMappingURL=createInput.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["functionConverter","createTextInput","input","createInput","type","renderer","createLongTextInput","createNumberInput","createBooleanInput","createColorInput","createFileInput","createDateInput","createLexicalInput","createSelectInput","createRadioInput","createObjectInput","createTagsInput","list","createSlotInput","defaultValue","onChange","serialize"],"sources":["createInput.ts"],"sourcesContent":["import type {\n TextInput,\n LongTextInput,\n NumberInput,\n BooleanInput,\n ColorInput,\n FileInput,\n LexicalInput,\n SelectInput,\n RadioInput,\n ObjectInput,\n DateTimeInput,\n ComponentInput,\n TagsInput,\n SlotInput\n} from \"./types.js\";\nimport { functionConverter } from \"~/FunctionConverter.js\";\n\nexport type InputFactory<Name extends string> =\n | ReturnType<typeof createTextInput<Name>>\n | ReturnType<typeof createLongTextInput<Name>>\n | ReturnType<typeof createNumberInput<Name>>\n | ReturnType<typeof createBooleanInput<Name>>\n | ReturnType<typeof createColorInput<Name>>\n | ReturnType<typeof createFileInput<Name>>\n | ReturnType<typeof createDateInput<Name>>\n | ReturnType<typeof createLexicalInput<Name>>\n | ReturnType<typeof createSelectInput<Name>>\n | ReturnType<typeof createRadioInput<Name>>\n | ReturnType<typeof createObjectInput<Name>>\n | ReturnType<typeof createTagsInput<Name>>\n | ReturnType<typeof createSlotInput<Name>>;\n\n/**\n * TypeScript Overload Resolution and Input Factory Design\n *\n * Each input factory (e.g., createTextInput) is defined with two TypeScript overload signatures:\n * 1. One overload requires a `name` property in the input (used for array-based APIs, where inference is needed).\n * 2. The other overload omits the `name` property (used for object-based APIs, where the key provides the name).\n *\n * TypeScript resolves overloads by scanning from top to bottom and picking the first matching signature.\n * The implementation signature uses `any` for the argument, and the return type is unified to match all overloads.\n *\n * In array mode, the `name` must be explicitly provided in the input object, so inference for `TName` works.\n * In object mode, the input does not require a `name` property; instead, the key in the object (e.g., `{ foo: createTextInput({ ... }) }`)\n * provides the name via contextual typing from the consuming function (such as `createComponent`). TypeScript uses this context\n * to resolve the correct type for `TName` even when `name` is omitted from the input.\n *\n * This pattern ensures that all returned input objects are typed as `{ name: TName }`, whether `name` is provided explicitly or inferred,\n * so consumers of these factories do not need to worry about the presence of the `name` property in the result.\n */\n// Text\nexport function createTextInput<TName extends string>(\n input: { name: TName } & Omit<TextInput, \"type\" | \"name\">\n): TextInput & { name: TName };\nexport function createTextInput<TName extends string>(\n input: Omit<TextInput, \"type\" | \"name\">\n): TextInput & { name: TName };\nexport function createTextInput<TName extends string>(input: any): TextInput & { name: TName } {\n return createInput({\n type: \"text\",\n renderer: \"Webiny/Input\",\n ...input\n }) as TextInput & { name: TName };\n}\n\n// Long Text\nexport function createLongTextInput<TName extends string>(\n input: { name: TName } & Omit<LongTextInput, \"type\" | \"name\">\n): LongTextInput & { name: TName };\nexport function createLongTextInput<TName extends string>(\n input: Omit<LongTextInput, \"type\" | \"name\">\n): LongTextInput & { name: TName };\nexport function createLongTextInput<TName extends string>(\n input: any\n): LongTextInput & { name: TName } {\n return createInput({\n type: \"longText\",\n renderer: \"Webiny/Textarea\",\n ...input\n }) as LongTextInput & { name: TName };\n}\n\n// Number\nexport function createNumberInput<TName extends string>(\n input: { name: TName } & Omit<NumberInput, \"type\" | \"name\">\n): NumberInput & { name: TName };\nexport function createNumberInput<TName extends string>(\n input: Omit<NumberInput, \"type\" | \"name\">\n): NumberInput & { name: TName };\nexport function createNumberInput<TName extends string>(input: any): NumberInput & { name: TName } {\n return createInput({\n type: \"number\",\n renderer: \"Webiny/Number\",\n ...input\n }) as NumberInput & { name: TName };\n}\n\n// Boolean\nexport function createBooleanInput<TName extends string>(\n input: { name: TName } & Omit<BooleanInput, \"type\" | \"name\">\n): BooleanInput & { name: TName };\nexport function createBooleanInput<TName extends string>(\n input: Omit<BooleanInput, \"type\" | \"name\">\n): BooleanInput & { name: TName };\nexport function createBooleanInput<TName extends string>(\n input: any\n): BooleanInput & { name: TName } {\n return createInput({\n type: \"boolean\",\n renderer: \"Webiny/Switch\",\n ...input\n }) as BooleanInput & { name: TName };\n}\n\n// Color\nexport function createColorInput<TName extends string>(\n input: { name: TName } & Omit<ColorInput, \"type\" | \"name\">\n): ColorInput & { name: TName };\nexport function createColorInput<TName extends string>(\n input: Omit<ColorInput, \"type\" | \"name\">\n): ColorInput & { name: TName };\nexport function createColorInput<TName extends string>(input: any): ColorInput & { name: TName } {\n return createInput({\n type: \"color\",\n renderer: \"Webiny/ColorPicker\",\n ...input\n }) as ColorInput & { name: TName };\n}\n\n// File\nexport function createFileInput<TName extends string>(\n input: { name: TName } & Omit<FileInput, \"type\" | \"name\">\n): FileInput & { name: TName };\nexport function createFileInput<TName extends string>(\n input: Omit<FileInput, \"type\" | \"name\">\n): FileInput & { name: TName };\nexport function createFileInput<TName extends string>(input: any): FileInput & { name: TName } {\n return createInput({\n type: \"file\",\n renderer: \"Webiny/FileManager\",\n ...input\n }) as FileInput & { name: TName };\n}\n\n// Date\nexport function createDateInput<TName extends string>(\n input: { name: TName } & Omit<DateTimeInput, \"type\" | \"name\">\n): DateTimeInput & { name: TName };\nexport function createDateInput<TName extends string>(\n input: Omit<DateTimeInput, \"type\" | \"name\">\n): DateTimeInput & { name: TName };\nexport function createDateInput<TName extends string>(input: any): DateTimeInput & { name: TName } {\n return createInput({\n type: \"datetime\",\n renderer: \"Webiny/DateTime\",\n ...input\n }) as DateTimeInput & { name: TName };\n}\n\n// Rich Text\nexport function createLexicalInput<TName extends string>(\n input: { name: TName } & Omit<LexicalInput, \"type\" | \"name\">\n): LexicalInput & { name: TName };\nexport function createLexicalInput<TName extends string>(\n input: Omit<LexicalInput, \"type\" | \"name\">\n): LexicalInput & { name: TName };\nexport function createLexicalInput<TName extends string>(\n input: any\n): LexicalInput & { name: TName } {\n return createInput({\n type: \"lexical\",\n renderer: \"Webiny/Lexical\",\n ...input\n }) as LexicalInput & { name: TName };\n}\n\n// Select\nexport function createSelectInput<TName extends string>(\n input: { name: TName } & Omit<SelectInput, \"type\" | \"name\">\n): SelectInput & { name: TName };\nexport function createSelectInput<TName extends string>(\n input: Omit<SelectInput, \"type\" | \"name\">\n): SelectInput & { name: TName };\nexport function createSelectInput<TName extends string>(input: any): SelectInput & { name: TName } {\n return createInput({\n type: \"select\",\n renderer: \"Webiny/Select\",\n ...input\n }) as SelectInput & { name: TName };\n}\n\n// Radio\nexport function createRadioInput<TName extends string>(\n input: { name: TName } & Omit<RadioInput, \"type\" | \"name\">\n): RadioInput & { name: TName };\nexport function createRadioInput<TName extends string>(\n input: Omit<RadioInput, \"type\" | \"name\">\n): RadioInput & { name: TName };\nexport function createRadioInput<TName extends string>(input: any): RadioInput & { name: TName } {\n return createInput({\n type: \"radio\",\n renderer: \"Webiny/RadioGroup\",\n ...input\n }) as RadioInput & { name: TName };\n}\n\n// Object\nexport function createObjectInput<TName extends string>(\n input: { name: TName } & Omit<ObjectInput, \"type\" | \"name\">\n): ObjectInput & { name: TName };\nexport function createObjectInput<TName extends string>(\n input: Omit<ObjectInput, \"type\" | \"name\">\n): ObjectInput & { name: TName };\nexport function createObjectInput<TName extends string>(input: any): ObjectInput & { name: TName } {\n return createInput({\n type: \"object\",\n renderer: \"Webiny/Object\",\n ...input\n }) as ObjectInput & { name: TName };\n}\n\n// Tags\nexport function createTagsInput<TName extends string>(\n input: { name: TName } & Omit<TagsInput, \"type\" | \"name\">\n): TagsInput & { name: TName };\nexport function createTagsInput<TName extends string>(\n input: Omit<TagsInput, \"type\" | \"name\">\n): TagsInput & { name: TName };\nexport function createTagsInput<TName extends string>(input: any): TagsInput & { name: TName } {\n return createInput({\n type: \"text\",\n list: true,\n renderer: \"Webiny/Tags\",\n ...input\n }) as TagsInput & { name: TName };\n}\n\nexport function createSlotInput<TName extends string>(\n input: { name: TName } & Omit<SlotInput, \"type\" | \"name\">\n): SlotInput & { name: TName };\nexport function createSlotInput<TName extends string>(\n input: Omit<SlotInput, \"type\" | \"name\">\n): SlotInput & { name: TName };\nexport function createSlotInput<TName extends string>(input: any): SlotInput & { name: TName } {\n return createInput({\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n defaultValue: [],\n ...input\n }) as SlotInput & { name: TName };\n}\n\n// Implementation\nexport function createInput(input: ComponentInput): ComponentInput {\n if (input.onChange) {\n // @ts-expect-error We don't use this function on the frontend, so this is ok.\n input.onChange = functionConverter.serialize(input.onChange!);\n }\n return input;\n}\n"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"file":"createInput.js","sources":["../src/createInput.ts"],"sourcesContent":["import type {\n TextInput,\n LongTextInput,\n NumberInput,\n BooleanInput,\n ColorInput,\n FileInput,\n LexicalInput,\n SelectInput,\n RadioInput,\n ObjectInput,\n DateTimeInput,\n ComponentInput,\n TagsInput,\n SlotInput,\n ContentEntryInput\n} from \"./types.js\";\nimport { functionConverter } from \"~/FunctionConverter.js\";\n\nexport type InputFactory<Name extends string> =\n | ReturnType<typeof createTextInput<Name>>\n | ReturnType<typeof createLongTextInput<Name>>\n | ReturnType<typeof createNumberInput<Name>>\n | ReturnType<typeof createBooleanInput<Name>>\n | ReturnType<typeof createColorInput<Name>>\n | ReturnType<typeof createFileInput<Name>>\n | ReturnType<typeof createDateInput<Name>>\n | ReturnType<typeof createLexicalInput<Name>>\n | ReturnType<typeof createSelectInput<Name>>\n | ReturnType<typeof createRadioInput<Name>>\n | ReturnType<typeof createObjectInput<Name>>\n | ReturnType<typeof createTagsInput<Name>>\n | ReturnType<typeof createSlotInput<Name>>\n | ReturnType<typeof createContentEntryInput<Name>>;\n\n/**\n * TypeScript Overload Resolution and Input Factory Design\n *\n * Each input factory (e.g., createTextInput) is defined with two TypeScript overload signatures:\n * 1. One overload requires a `name` property in the input (used for array-based APIs, where inference is needed).\n * 2. The other overload omits the `name` property (used for object-based APIs, where the key provides the name).\n *\n * TypeScript resolves overloads by scanning from top to bottom and picking the first matching signature.\n * The implementation signature uses `any` for the argument, and the return type is unified to match all overloads.\n *\n * In array mode, the `name` must be explicitly provided in the input object, so inference for `TName` works.\n * In object mode, the input does not require a `name` property; instead, the key in the object (e.g., `{ foo: createTextInput({ ... }) }`)\n * provides the name via contextual typing from the consuming function (such as `createComponent`). TypeScript uses this context\n * to resolve the correct type for `TName` even when `name` is omitted from the input.\n *\n * This pattern ensures that all returned input objects are typed as `{ name: TName }`, whether `name` is provided explicitly or inferred,\n * so consumers of these factories do not need to worry about the presence of the `name` property in the result.\n */\n// Text\nexport function createTextInput<TName extends string>(\n input: { name: TName } & Omit<TextInput, \"type\" | \"name\">\n): TextInput & { name: TName };\nexport function createTextInput<TName extends string>(\n input: Omit<TextInput, \"type\" | \"name\">\n): TextInput & { name: TName };\nexport function createTextInput<TName extends string>(input: any): TextInput & { name: TName } {\n return createInput({\n type: \"text\",\n renderer: \"Webiny/Input\",\n ...input\n }) as TextInput & { name: TName };\n}\n\n// Long Text\nexport function createLongTextInput<TName extends string>(\n input: { name: TName } & Omit<LongTextInput, \"type\" | \"name\">\n): LongTextInput & { name: TName };\nexport function createLongTextInput<TName extends string>(\n input: Omit<LongTextInput, \"type\" | \"name\">\n): LongTextInput & { name: TName };\nexport function createLongTextInput<TName extends string>(\n input: any\n): LongTextInput & { name: TName } {\n return createInput({\n type: \"longText\",\n renderer: \"Webiny/Textarea\",\n ...input\n }) as LongTextInput & { name: TName };\n}\n\n// Number\nexport function createNumberInput<TName extends string>(\n input: { name: TName } & Omit<NumberInput, \"type\" | \"name\">\n): NumberInput & { name: TName };\nexport function createNumberInput<TName extends string>(\n input: Omit<NumberInput, \"type\" | \"name\">\n): NumberInput & { name: TName };\nexport function createNumberInput<TName extends string>(input: any): NumberInput & { name: TName } {\n return createInput({\n type: \"number\",\n renderer: \"Webiny/Number\",\n ...input\n }) as NumberInput & { name: TName };\n}\n\n// Boolean\nexport function createBooleanInput<TName extends string>(\n input: { name: TName } & Omit<BooleanInput, \"type\" | \"name\">\n): BooleanInput & { name: TName };\nexport function createBooleanInput<TName extends string>(\n input: Omit<BooleanInput, \"type\" | \"name\">\n): BooleanInput & { name: TName };\nexport function createBooleanInput<TName extends string>(\n input: any\n): BooleanInput & { name: TName } {\n return createInput({\n type: \"boolean\",\n renderer: \"Webiny/Switch\",\n ...input\n }) as BooleanInput & { name: TName };\n}\n\n// Color\nexport function createColorInput<TName extends string>(\n input: { name: TName } & Omit<ColorInput, \"type\" | \"name\">\n): ColorInput & { name: TName };\nexport function createColorInput<TName extends string>(\n input: Omit<ColorInput, \"type\" | \"name\">\n): ColorInput & { name: TName };\nexport function createColorInput<TName extends string>(input: any): ColorInput & { name: TName } {\n return createInput({\n type: \"color\",\n renderer: \"Webiny/ColorPicker\",\n ...input\n }) as ColorInput & { name: TName };\n}\n\n// File\nexport function createFileInput<TName extends string>(\n input: { name: TName } & Omit<FileInput, \"type\" | \"name\">\n): FileInput & { name: TName };\nexport function createFileInput<TName extends string>(\n input: Omit<FileInput, \"type\" | \"name\">\n): FileInput & { name: TName };\nexport function createFileInput<TName extends string>(input: any): FileInput & { name: TName } {\n return createInput({\n type: \"file\",\n renderer: \"Webiny/FileManager\",\n ...input\n }) as FileInput & { name: TName };\n}\n\n// Date\nexport function createDateInput<TName extends string>(\n input: { name: TName } & Omit<DateTimeInput, \"type\" | \"name\">\n): DateTimeInput & { name: TName };\nexport function createDateInput<TName extends string>(\n input: Omit<DateTimeInput, \"type\" | \"name\">\n): DateTimeInput & { name: TName };\nexport function createDateInput<TName extends string>(input: any): DateTimeInput & { name: TName } {\n return createInput({\n type: \"datetime\",\n renderer: \"Webiny/DateTime\",\n ...input\n }) as DateTimeInput & { name: TName };\n}\n\n// Rich Text\nexport function createLexicalInput<TName extends string>(\n input: { name: TName } & Omit<LexicalInput, \"type\" | \"name\">\n): LexicalInput & { name: TName };\nexport function createLexicalInput<TName extends string>(\n input: Omit<LexicalInput, \"type\" | \"name\">\n): LexicalInput & { name: TName };\nexport function createLexicalInput<TName extends string>(\n input: any\n): LexicalInput & { name: TName } {\n return createInput({\n type: \"lexical\",\n renderer: \"Webiny/Lexical\",\n ...input\n }) as LexicalInput & { name: TName };\n}\n\n// Select\nexport function createSelectInput<TName extends string>(\n input: { name: TName } & Omit<SelectInput, \"type\" | \"name\">\n): SelectInput & { name: TName };\nexport function createSelectInput<TName extends string>(\n input: Omit<SelectInput, \"type\" | \"name\">\n): SelectInput & { name: TName };\nexport function createSelectInput<TName extends string>(input: any): SelectInput & { name: TName } {\n return createInput({\n type: \"select\",\n renderer: \"Webiny/Select\",\n ...input\n }) as SelectInput & { name: TName };\n}\n\n// Radio\nexport function createRadioInput<TName extends string>(\n input: { name: TName } & Omit<RadioInput, \"type\" | \"name\">\n): RadioInput & { name: TName };\nexport function createRadioInput<TName extends string>(\n input: Omit<RadioInput, \"type\" | \"name\">\n): RadioInput & { name: TName };\nexport function createRadioInput<TName extends string>(input: any): RadioInput & { name: TName } {\n return createInput({\n type: \"radio\",\n renderer: \"Webiny/RadioGroup\",\n ...input\n }) as RadioInput & { name: TName };\n}\n\n// Object\nexport function createObjectInput<TName extends string>(\n input: { name: TName } & Omit<ObjectInput, \"type\" | \"name\">\n): ObjectInput & { name: TName };\nexport function createObjectInput<TName extends string>(\n input: Omit<ObjectInput, \"type\" | \"name\">\n): ObjectInput & { name: TName };\nexport function createObjectInput<TName extends string>(input: any): ObjectInput & { name: TName } {\n return createInput({\n type: \"object\",\n renderer: \"Webiny/Object\",\n ...input\n }) as ObjectInput & { name: TName };\n}\n\n// Tags\nexport function createTagsInput<TName extends string>(\n input: { name: TName } & Omit<TagsInput, \"type\" | \"name\">\n): TagsInput & { name: TName };\nexport function createTagsInput<TName extends string>(\n input: Omit<TagsInput, \"type\" | \"name\">\n): TagsInput & { name: TName };\nexport function createTagsInput<TName extends string>(input: any): TagsInput & { name: TName } {\n return createInput({\n type: \"text\",\n list: true,\n renderer: \"Webiny/Tags\",\n ...input\n }) as TagsInput & { name: TName };\n}\n\nexport function createSlotInput<TName extends string>(\n input: { name: TName } & Omit<SlotInput, \"type\" | \"name\">\n): SlotInput & { name: TName };\nexport function createSlotInput<TName extends string>(\n input: Omit<SlotInput, \"type\" | \"name\">\n): SlotInput & { name: TName };\nexport function createSlotInput<TName extends string>(input: any): SlotInput & { name: TName } {\n return createInput({\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n defaultValue: [],\n ...input\n }) as SlotInput & { name: TName };\n}\n\n// Content Entry\nexport function createContentEntryInput<TName extends string>(\n input: { name: TName } & Omit<ContentEntryInput, \"type\" | \"name\">\n): ContentEntryInput & { name: TName };\nexport function createContentEntryInput<TName extends string>(\n input: Omit<ContentEntryInput, \"type\" | \"name\">\n): ContentEntryInput & { name: TName };\nexport function createContentEntryInput<TName extends string>(\n input: any\n): ContentEntryInput & { name: TName } {\n return createInput({\n type: \"contentEntry\",\n renderer: \"Webiny/ContentEntry\",\n ...input\n }) as ContentEntryInput & { name: TName };\n}\n\n// Implementation\nexport function createInput(input: ComponentInput): ComponentInput {\n if (input.onChange) {\n // @ts-expect-error We don't use this function on the frontend, so this is ok.\n input.onChange = functionConverter.serialize(input.onChange!);\n }\n return input;\n}\n"],"names":["createTextInput","input","createInput","createLongTextInput","createNumberInput","createBooleanInput","createColorInput","createFileInput","createDateInput","createLexicalInput","createSelectInput","createRadioInput","createObjectInput","createTagsInput","createSlotInput","createContentEntryInput","functionConverter"],"mappings":";AA4DO,SAASA,gBAAsCC,KAAU;IAC5D,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AASO,SAASE,oBACZF,KAAU;IAEV,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AASO,SAASG,kBAAwCH,KAAU;IAC9D,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AASO,SAASI,mBACZJ,KAAU;IAEV,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AASO,SAASK,iBAAuCL,KAAU;IAC7D,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AASO,SAASM,gBAAsCN,KAAU;IAC5D,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AASO,SAASO,gBAAsCP,KAAU;IAC5D,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AASO,SAASQ,mBACZR,KAAU;IAEV,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AASO,SAASS,kBAAwCT,KAAU;IAC9D,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AASO,SAASU,iBAAuCV,KAAU;IAC7D,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AASO,SAASW,kBAAwCX,KAAU;IAC9D,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AASO,SAASY,gBAAsCZ,KAAU;IAC5D,OAAOC,YAAY;QACf,MAAM;QACN,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AAQO,SAASa,gBAAsCb,KAAU;IAC5D,OAAOC,YAAY;QACf,MAAM;QACN,MAAM;QACN,UAAU;QACV,cAAc,EAAE;QAChB,GAAGD,KAAK;IACZ;AACJ;AASO,SAASc,wBACZd,KAAU;IAEV,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IACZ;AACJ;AAGO,SAASC,YAAYD,KAAqB;IAC7C,IAAIA,MAAM,QAAQ,EAEdA,MAAM,QAAQ,GAAGe,kBAAkB,SAAS,CAACf,MAAM,QAAQ;IAE/D,OAAOA;AACX"}
package/createTheme.js CHANGED
@@ -1,5 +1,4 @@
1
- export const createTheme = theme => {
2
- return theme;
3
- };
1
+ const createTheme = (theme)=>theme;
2
+ export { createTheme };
4
3
 
5
4
  //# sourceMappingURL=createTheme.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createTheme","theme"],"sources":["createTheme.ts"],"sourcesContent":["import type { WebsiteBuilderThemeInput } from \"~/types/WebsiteBuilderTheme.js\";\n\nexport type { WebsiteBuilderThemeInput };\n\nexport const createTheme = (theme: WebsiteBuilderThemeInput) => {\n return theme;\n};\n"],"mappings":"AAIA,OAAO,MAAMA,WAAW,GAAIC,KAA+B,IAAK;EAC5D,OAAOA,KAAK;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"createTheme.js","sources":["../src/createTheme.ts"],"sourcesContent":["import type { WebsiteBuilderThemeInput } from \"~/types/WebsiteBuilderTheme.js\";\n\nexport type { WebsiteBuilderThemeInput };\n\nexport const createTheme = (theme: WebsiteBuilderThemeInput) => {\n return theme;\n};\n"],"names":["createTheme","theme"],"mappings":"AAIO,MAAMA,cAAc,CAACC,QACjBA"}
@@ -1,6 +1,11 @@
1
1
  interface QueryParams {
2
2
  query: string;
3
3
  variables: Record<string, any>;
4
+ }
5
+ export interface ApiClientConfig {
6
+ apiHost: string;
7
+ apiKey: string;
8
+ apiTenant: string;
4
9
  preview?: boolean;
5
10
  }
6
11
  type WithPath<T> = T & {
@@ -8,11 +13,11 @@ type WithPath<T> = T & {
8
13
  next?: Record<string, any>;
9
14
  };
10
15
  export declare class ApiClient {
11
- private readonly apiHost;
12
- private readonly apiKey;
13
- private readonly apiTenant;
14
- constructor(apiHost: string, apiKey: string, apiTenant: string);
16
+ private readonly config;
17
+ constructor(config: ApiClientConfig);
15
18
  fetch({ headers, path, ...params }: WithPath<RequestInit>): Promise<any>;
16
- query({ query, variables, preview }: QueryParams): Promise<any>;
19
+ query({ query, variables }: QueryParams, options?: {
20
+ noStore?: boolean;
21
+ }): Promise<any>;
17
22
  }
18
23
  export {};
@@ -1,54 +1,45 @@
1
- export class ApiClient {
2
- constructor(apiHost, apiKey, apiTenant) {
3
- this.apiTenant = apiTenant;
4
- this.apiHost = apiHost;
5
- this.apiKey = apiKey;
6
- }
7
- async fetch({
8
- headers,
9
- path,
10
- ...params
11
- }) {
12
- return fetch(`${this.apiHost}${path}`, {
13
- method: "GET",
14
- headers: {
15
- "Content-Type": "application/json",
16
- "X-Tenant": this.apiTenant,
17
- Authorization: "Bearer " + this.apiKey,
18
- ...headers
19
- },
20
- ...params
21
- }).then(res => res.json());
22
- }
23
- async query({
24
- query,
25
- variables,
26
- preview
27
- }) {
28
- const fetchOptions = {
29
- next: {
30
- revalidate: preview ? 0 : 60
31
- }
32
- };
33
- const request = {
34
- ...fetchOptions,
35
- path: "/graphql",
36
- method: "POST",
37
- body: JSON.stringify({
38
- query,
39
- variables
40
- })
41
- };
42
- const json = await this.fetch(request);
43
- if (json.message) {
44
- throw new Error(json.message);
1
+ class ApiClient {
2
+ constructor(config){
3
+ this.config = config;
45
4
  }
46
- if (json.errors) {
47
- console.error(json.errors);
48
- throw new Error("Failed to fetch API");
5
+ async fetch({ headers, path, ...params }) {
6
+ return fetch(`${this.config.apiHost}${path}`, {
7
+ method: "GET",
8
+ headers: {
9
+ "Content-Type": "application/json",
10
+ "X-Tenant": this.config.apiTenant,
11
+ Authorization: "Bearer " + this.config.apiKey,
12
+ ...headers
13
+ },
14
+ ...params
15
+ }).then((res)=>res.json());
16
+ }
17
+ async query({ query, variables }, options) {
18
+ const fetchOptions = options?.noStore ? {
19
+ cache: "no-store"
20
+ } : {
21
+ next: {
22
+ revalidate: this.config.preview ? 0 : 60
23
+ }
24
+ };
25
+ const request = {
26
+ ...fetchOptions,
27
+ path: "/graphql",
28
+ method: "POST",
29
+ body: JSON.stringify({
30
+ query,
31
+ variables
32
+ })
33
+ };
34
+ const json = await this.fetch(request);
35
+ if (json.message) throw new Error(json.message);
36
+ if (json.errors) {
37
+ console.error(json.errors);
38
+ throw new Error("Failed to fetch API");
39
+ }
40
+ return json.data;
49
41
  }
50
- return json.data;
51
- }
52
42
  }
43
+ export { ApiClient };
53
44
 
54
45
  //# sourceMappingURL=ApiClient.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ApiClient","constructor","apiHost","apiKey","apiTenant","fetch","headers","path","params","method","Authorization","then","res","json","query","variables","preview","fetchOptions","next","revalidate","request","body","JSON","stringify","message","Error","errors","console","error","data"],"sources":["ApiClient.ts"],"sourcesContent":["interface QueryParams {\n query: string;\n variables: Record<string, any>;\n preview?: boolean;\n}\n\ntype WithPath<T> = T & {\n path?: string;\n next?: Record<string, any>;\n};\n\nexport class ApiClient {\n private readonly apiHost: string;\n private readonly apiKey: string;\n private readonly apiTenant: string;\n\n constructor(apiHost: string, apiKey: string, apiTenant: string) {\n this.apiTenant = apiTenant;\n this.apiHost = apiHost;\n this.apiKey = apiKey;\n }\n\n async fetch({ headers, path, ...params }: WithPath<RequestInit>): Promise<any> {\n return fetch(`${this.apiHost}${path}`, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-Tenant\": this.apiTenant,\n Authorization: \"Bearer \" + this.apiKey,\n ...headers\n },\n ...params\n }).then(res => res.json());\n }\n\n async query({ query, variables, preview }: QueryParams) {\n const fetchOptions = {\n next: {\n revalidate: preview ? 0 : 60\n }\n };\n\n const request: WithPath<RequestInit> = {\n ...fetchOptions,\n path: \"/graphql\",\n method: \"POST\",\n body: JSON.stringify({\n query,\n variables\n })\n };\n\n const json = await this.fetch(request);\n\n if (json.message) {\n throw new Error(json.message);\n }\n\n if (json.errors) {\n console.error(json.errors);\n throw new Error(\"Failed to fetch API\");\n }\n\n return json.data;\n }\n}\n"],"mappings":"AAWA,OAAO,MAAMA,SAAS,CAAC;EAKnBC,WAAWA,CAACC,OAAe,EAAEC,MAAc,EAAEC,SAAiB,EAAE;IAC5D,IAAI,CAACA,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACF,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAME,KAAKA,CAAC;IAAEC,OAAO;IAAEC,IAAI;IAAE,GAAGC;EAA8B,CAAC,EAAgB;IAC3E,OAAOH,KAAK,CAAC,GAAG,IAAI,CAACH,OAAO,GAAGK,IAAI,EAAE,EAAE;MACnCE,MAAM,EAAE,KAAK;MACbH,OAAO,EAAE;QACL,cAAc,EAAE,kBAAkB;QAClC,UAAU,EAAE,IAAI,CAACF,SAAS;QAC1BM,aAAa,EAAE,SAAS,GAAG,IAAI,CAACP,MAAM;QACtC,GAAGG;MACP,CAAC;MACD,GAAGE;IACP,CAAC,CAAC,CAACG,IAAI,CAACC,GAAG,IAAIA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC;EAC9B;EAEA,MAAMC,KAAKA,CAAC;IAAEA,KAAK;IAAEC,SAAS;IAAEC;EAAqB,CAAC,EAAE;IACpD,MAAMC,YAAY,GAAG;MACjBC,IAAI,EAAE;QACFC,UAAU,EAAEH,OAAO,GAAG,CAAC,GAAG;MAC9B;IACJ,CAAC;IAED,MAAMI,OAA8B,GAAG;MACnC,GAAGH,YAAY;MACfV,IAAI,EAAE,UAAU;MAChBE,MAAM,EAAE,MAAM;MACdY,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;QACjBT,KAAK;QACLC;MACJ,CAAC;IACL,CAAC;IAED,MAAMF,IAAI,GAAG,MAAM,IAAI,CAACR,KAAK,CAACe,OAAO,CAAC;IAEtC,IAAIP,IAAI,CAACW,OAAO,EAAE;MACd,MAAM,IAAIC,KAAK,CAACZ,IAAI,CAACW,OAAO,CAAC;IACjC;IAEA,IAAIX,IAAI,CAACa,MAAM,EAAE;MACbC,OAAO,CAACC,KAAK,CAACf,IAAI,CAACa,MAAM,CAAC;MAC1B,MAAM,IAAID,KAAK,CAAC,qBAAqB,CAAC;IAC1C;IAEA,OAAOZ,IAAI,CAACgB,IAAI;EACpB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"dataProviders/ApiClient.js","sources":["../../src/dataProviders/ApiClient.ts"],"sourcesContent":["interface QueryParams {\n query: string;\n variables: Record<string, any>;\n}\n\nexport interface ApiClientConfig {\n apiHost: string;\n apiKey: string;\n apiTenant: string;\n preview?: boolean;\n}\n\ntype WithPath<T> = T & {\n path?: string;\n next?: Record<string, any>;\n};\n\nexport class ApiClient {\n private readonly config: ApiClientConfig;\n\n constructor(config: ApiClientConfig) {\n this.config = config;\n }\n\n async fetch({ headers, path, ...params }: WithPath<RequestInit>): Promise<any> {\n return fetch(`${this.config.apiHost}${path}`, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-Tenant\": this.config.apiTenant,\n Authorization: \"Bearer \" + this.config.apiKey,\n ...headers\n },\n ...params\n }).then(res => res.json());\n }\n\n async query({ query, variables }: QueryParams, options?: { noStore?: boolean }) {\n // Runtime reads (e.g. the experiment kill-switch) must bypass the cache so they take\n // effect immediately; everything else caches and revalidates on an interval.\n const fetchOptions: Pick<WithPath<RequestInit>, \"cache\" | \"next\"> = options?.noStore\n ? { cache: \"no-store\" }\n : { next: { revalidate: this.config.preview ? 0 : 60 } };\n\n const request: WithPath<RequestInit> = {\n ...fetchOptions,\n path: \"/graphql\",\n method: \"POST\",\n body: JSON.stringify({\n query,\n variables\n })\n };\n\n const json = await this.fetch(request);\n\n if (json.message) {\n throw new Error(json.message);\n }\n\n if (json.errors) {\n console.error(json.errors);\n throw new Error(\"Failed to fetch API\");\n }\n\n return json.data;\n }\n}\n"],"names":["ApiClient","config","headers","path","params","fetch","res","query","variables","options","fetchOptions","request","JSON","json","Error","console"],"mappings":"AAiBO,MAAMA;IAGT,YAAYC,MAAuB,CAAE;QACjC,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,MAAM,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAGC,QAA+B,EAAgB;QAC3E,OAAOC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,GAAGF,MAAM,EAAE;YAC1C,QAAQ;YACR,SAAS;gBACL,gBAAgB;gBAChB,YAAY,IAAI,CAAC,MAAM,CAAC,SAAS;gBACjC,eAAe,YAAY,IAAI,CAAC,MAAM,CAAC,MAAM;gBAC7C,GAAGD,OAAO;YACd;YACA,GAAGE,MAAM;QACb,GAAG,IAAI,CAACE,CAAAA,MAAOA,IAAI,IAAI;IAC3B;IAEA,MAAM,MAAM,EAAEC,KAAK,EAAEC,SAAS,EAAe,EAAEC,OAA+B,EAAE;QAG5E,MAAMC,eAA8DD,SAAS,UACvE;YAAE,OAAO;QAAW,IACpB;YAAE,MAAM;gBAAE,YAAY,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI;YAAG;QAAE;QAE3D,MAAME,UAAiC;YACnC,GAAGD,YAAY;YACf,MAAM;YACN,QAAQ;YACR,MAAME,KAAK,SAAS,CAAC;gBACjBL;gBACAC;YACJ;QACJ;QAEA,MAAMK,OAAO,MAAM,IAAI,CAAC,KAAK,CAACF;QAE9B,IAAIE,KAAK,OAAO,EACZ,MAAM,IAAIC,MAAMD,KAAK,OAAO;QAGhC,IAAIA,KAAK,MAAM,EAAE;YACbE,QAAQ,KAAK,CAACF,KAAK,MAAM;YACzB,MAAM,IAAIC,MAAM;QACpB;QAEA,OAAOD,KAAK,IAAI;IACpB;AACJ"}
@@ -1,4 +1,5 @@
1
1
  import type { IDataProvider, ListPagesOptions, ListPagesResult, PublicPage } from "../types.js";
2
+ import type { ActiveExperiment, VariantContent } from "../experiments/types.js";
2
3
  import type { ApiClient } from "../dataProviders/ApiClient.js";
3
4
  interface DefaultDataProviderConfig {
4
5
  apiClient: ApiClient;
@@ -9,6 +10,9 @@ export declare class DefaultDataProvider implements IDataProvider {
9
10
  getPageByPath(path: string): Promise<PublicPage | null>;
10
11
  getPageById(id: string): Promise<PublicPage | null>;
11
12
  listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
13
+ getPageExperiment(path: string): Promise<ActiveExperiment | null>;
14
+ getVariantContent(variantId: string): Promise<VariantContent | null>;
15
+ getExperimentPaused(experimentId: string): Promise<boolean>;
12
16
  private checkForErrors;
13
17
  }
14
18
  export {};