@webiny/website-builder-sdk 0.0.0-unstable.eb196ccd2f → 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 (307) 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 -77
  6. package/BindingsProcessor.test.js.map +1 -1
  7. package/BindingsResolver.d.ts +5 -2
  8. package/BindingsResolver.js +99 -122
  9. package/BindingsResolver.js.map +1 -1
  10. package/BindingsResolver.test.js +399 -362
  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 +38 -22
  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.d.ts +36 -0
  26. package/ConstraintEvaluator.js +288 -0
  27. package/ConstraintEvaluator.js.map +1 -0
  28. package/ConstraintEvaluator.test.d.ts +1 -0
  29. package/ConstraintEvaluator.test.js +1634 -0
  30. package/ConstraintEvaluator.test.js.map +1 -0
  31. package/ContentSdk.d.ts +17 -3
  32. package/ContentSdk.js +113 -90
  33. package/ContentSdk.js.map +1 -1
  34. package/DocumentStore.d.ts +1 -1
  35. package/DocumentStore.js +47 -59
  36. package/DocumentStore.js.map +1 -1
  37. package/DocumentStoreManager.js +17 -16
  38. package/DocumentStoreManager.js.map +1 -1
  39. package/EditingSdk.d.ts +2 -2
  40. package/EditingSdk.js +92 -124
  41. package/EditingSdk.js.map +1 -1
  42. package/ElementFactory.d.ts +2 -3
  43. package/ElementFactory.js +164 -163
  44. package/ElementFactory.js.map +1 -1
  45. package/ElementFactory.objectListDefaults.test.d.ts +1 -0
  46. package/ElementFactory.objectListDefaults.test.js +423 -0
  47. package/ElementFactory.objectListDefaults.test.js.map +1 -0
  48. package/ElementFactory.test.d.ts +1 -0
  49. package/ElementFactory.test.js +353 -0
  50. package/ElementFactory.test.js.map +1 -0
  51. package/Environment.js +18 -19
  52. package/Environment.js.map +1 -1
  53. package/FunctionConverter.js +8 -7
  54. package/FunctionConverter.js.map +1 -1
  55. package/HashObject.js +11 -12
  56. package/HashObject.js.map +1 -1
  57. package/HotkeyManager.js +41 -48
  58. package/HotkeyManager.js.map +1 -1
  59. package/IBindingsUpdater.js +0 -3
  60. package/IRedirects.js +0 -3
  61. package/InheritanceProcessor.d.ts +2 -2
  62. package/InheritanceProcessor.js +99 -139
  63. package/InheritanceProcessor.js.map +1 -1
  64. package/InheritanceProcessor.test.js +178 -178
  65. package/InheritanceProcessor.test.js.map +1 -1
  66. package/InheritedValueResolver.d.ts +18 -1
  67. package/InheritedValueResolver.js +18 -20
  68. package/InheritedValueResolver.js.map +1 -1
  69. package/InputBindingsProcessor.d.ts +23 -2
  70. package/InputBindingsProcessor.js +200 -289
  71. package/InputBindingsProcessor.js.map +1 -1
  72. package/InputBindingsProcessorTokens.test.d.ts +1 -0
  73. package/InputBindingsProcessorTokens.test.js +400 -0
  74. package/InputBindingsProcessorTokens.test.js.map +1 -0
  75. package/InputsBindingsProcessor.test.js +334 -313
  76. package/InputsBindingsProcessor.test.js.map +1 -1
  77. package/InputsUpdater.d.ts +1 -1
  78. package/InputsUpdater.js +23 -26
  79. package/InputsUpdater.js.map +1 -1
  80. package/LiveSdk.d.ts +2 -2
  81. package/LiveSdk.js +12 -13
  82. package/LiveSdk.js.map +1 -1
  83. package/Logger.d.ts +2 -1
  84. package/Logger.js +9 -8
  85. package/Logger.js.map +1 -1
  86. package/MouseTracker.js +77 -83
  87. package/MouseTracker.js.map +1 -1
  88. package/NullSdk.d.ts +4 -3
  89. package/NullSdk.js +22 -14
  90. package/NullSdk.js.map +1 -1
  91. package/PreviewDocument.d.ts +1 -0
  92. package/PreviewDocument.js +30 -30
  93. package/PreviewDocument.js.map +1 -1
  94. package/PreviewSdk.d.ts +4 -3
  95. package/PreviewSdk.js +19 -17
  96. package/PreviewSdk.js.map +1 -1
  97. package/PreviewViewport.d.ts +0 -1
  98. package/PreviewViewport.js +50 -82
  99. package/PreviewViewport.js.map +1 -1
  100. package/README.md +10 -2
  101. package/ResizeObserver.js +24 -31
  102. package/ResizeObserver.js.map +1 -1
  103. package/StylesBindingsProcessor.d.ts +12 -2
  104. package/StylesBindingsProcessor.js +62 -79
  105. package/StylesBindingsProcessor.js.map +1 -1
  106. package/StylesUpdater.d.ts +1 -1
  107. package/StylesUpdater.js +20 -25
  108. package/StylesUpdater.js.map +1 -1
  109. package/Theme.js +30 -32
  110. package/Theme.js.map +1 -1
  111. package/ViewportManager.d.ts +2 -0
  112. package/ViewportManager.js +89 -97
  113. package/ViewportManager.js.map +1 -1
  114. package/assertBindingShapes.d.ts +31 -0
  115. package/assertBindingShapes.js +64 -0
  116. package/assertBindingShapes.js.map +1 -0
  117. package/assertBindingShapes.test.d.ts +1 -0
  118. package/assertBindingShapes.test.js +131 -0
  119. package/assertBindingShapes.test.js.map +1 -0
  120. package/asset/deliveryUrl.d.ts +41 -0
  121. package/asset/deliveryUrl.js +34 -0
  122. package/asset/deliveryUrl.js.map +1 -0
  123. package/asset/deliveryUrl.test.d.ts +1 -0
  124. package/asset/deliveryUrl.test.js +127 -0
  125. package/asset/deliveryUrl.test.js.map +1 -0
  126. package/asset/geometry.d.ts +7 -0
  127. package/asset/geometry.js +10 -0
  128. package/asset/geometry.js.map +1 -0
  129. package/asset/imageSrcSet.d.ts +63 -0
  130. package/asset/imageSrcSet.js +98 -0
  131. package/asset/imageSrcSet.js.map +1 -0
  132. package/asset/imageSrcSet.test.d.ts +1 -0
  133. package/asset/imageSrcSet.test.js +103 -0
  134. package/asset/imageSrcSet.test.js.map +1 -0
  135. package/asset/index.d.ts +5 -0
  136. package/asset/index.js +5 -0
  137. package/asset/normalize.d.ts +24 -0
  138. package/asset/normalize.js +106 -0
  139. package/asset/normalize.js.map +1 -0
  140. package/asset/normalize.test.d.ts +1 -0
  141. package/asset/normalize.test.js +263 -0
  142. package/asset/normalize.test.js.map +1 -0
  143. package/asset/types.d.ts +2 -0
  144. package/asset/types.js +0 -0
  145. package/constants.d.ts +1 -0
  146. package/constants.js +7 -5
  147. package/constants.js.map +1 -1
  148. package/contentEntry/ContentEntryBindingsResolver.d.ts +30 -0
  149. package/contentEntry/ContentEntryBindingsResolver.js +45 -0
  150. package/contentEntry/ContentEntryBindingsResolver.js.map +1 -0
  151. package/contentEntry/ContentEntryCache.d.ts +46 -0
  152. package/contentEntry/ContentEntryCache.js +50 -0
  153. package/contentEntry/ContentEntryCache.js.map +1 -0
  154. package/contentEntry/resolveContentEntry.d.ts +74 -0
  155. package/contentEntry/resolveContentEntry.js +53 -0
  156. package/contentEntry/resolveContentEntry.js.map +1 -0
  157. package/contentEntry/resolveContentEntry.test.d.ts +1 -0
  158. package/contentEntry/resolveContentEntry.test.js +213 -0
  159. package/contentEntry/resolveContentEntry.test.js.map +1 -0
  160. package/createComponent.d.ts +5 -0
  161. package/createComponent.js +32 -0
  162. package/createComponent.js.map +1 -0
  163. package/createElement.js +5 -6
  164. package/createElement.js.map +1 -1
  165. package/createInput.d.ts +132 -16
  166. package/createInput.js +92 -111
  167. package/createInput.js.map +1 -1
  168. package/createTheme.js +2 -3
  169. package/createTheme.js.map +1 -1
  170. package/dataProviders/ApiClient.d.ts +10 -5
  171. package/dataProviders/ApiClient.js +40 -49
  172. package/dataProviders/ApiClient.js.map +1 -1
  173. package/dataProviders/DefaultDataProvider.d.ts +7 -3
  174. package/dataProviders/DefaultDataProvider.js +91 -45
  175. package/dataProviders/DefaultDataProvider.js.map +1 -1
  176. package/dataProviders/GET_EXPERIMENT_PAUSED.d.ts +1 -0
  177. package/dataProviders/GET_EXPERIMENT_PAUSED.js +17 -0
  178. package/dataProviders/GET_EXPERIMENT_PAUSED.js.map +1 -0
  179. package/dataProviders/GET_PAGE_BY_ID.d.ts +1 -1
  180. package/dataProviders/GET_PAGE_BY_ID.js +4 -1
  181. package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
  182. package/dataProviders/GET_PAGE_BY_PATH.d.ts +1 -1
  183. package/dataProviders/GET_PAGE_BY_PATH.js +4 -1
  184. package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
  185. package/dataProviders/GET_PAGE_EXPERIMENT.d.ts +1 -0
  186. package/dataProviders/GET_PAGE_EXPERIMENT.js +32 -0
  187. package/dataProviders/GET_PAGE_EXPERIMENT.js.map +1 -0
  188. package/dataProviders/GET_VARIANT_CONTENT.d.ts +1 -0
  189. package/dataProviders/GET_VARIANT_CONTENT.js +24 -0
  190. package/dataProviders/GET_VARIANT_CONTENT.js.map +1 -0
  191. package/dataProviders/LIST_PUBLISHED_PAGES.d.ts +1 -1
  192. package/dataProviders/LIST_PUBLISHED_PAGES.js +17 -5
  193. package/dataProviders/LIST_PUBLISHED_PAGES.js.map +1 -1
  194. package/dataProviders/NullDataProvider.d.ts +16 -4
  195. package/dataProviders/NullDataProvider.js +30 -13
  196. package/dataProviders/NullDataProvider.js.map +1 -1
  197. package/dataProviders/RedirectsProvider.js +24 -27
  198. package/dataProviders/RedirectsProvider.js.map +1 -1
  199. package/defaultBreakpoints.js +43 -22
  200. package/defaultBreakpoints.js.map +1 -1
  201. package/documentOperations/$addElementReferenceToParent.d.ts +1 -1
  202. package/documentOperations/$addElementReferenceToParent.js +30 -26
  203. package/documentOperations/$addElementReferenceToParent.js.map +1 -1
  204. package/documentOperations/AddElement.js +8 -7
  205. package/documentOperations/AddElement.js.map +1 -1
  206. package/documentOperations/AddToParent.d.ts +2 -2
  207. package/documentOperations/AddToParent.js +14 -13
  208. package/documentOperations/AddToParent.js.map +1 -1
  209. package/documentOperations/IDocumentOperation.js +0 -3
  210. package/documentOperations/RemoveElement.js +10 -7
  211. package/documentOperations/RemoveElement.js.map +1 -1
  212. package/documentOperations/SetGlobalInputBinding.js +23 -22
  213. package/documentOperations/SetGlobalInputBinding.js.map +1 -1
  214. package/documentOperations/SetGlobalStyleBinding.js +23 -23
  215. package/documentOperations/SetGlobalStyleBinding.js.map +1 -1
  216. package/documentOperations/SetInputBindingOverride.js +30 -29
  217. package/documentOperations/SetInputBindingOverride.js.map +1 -1
  218. package/documentOperations/SetStyleBindingOverride.js +30 -31
  219. package/documentOperations/SetStyleBindingOverride.js.map +1 -1
  220. package/documentOperations/index.js +9 -8
  221. package/documentOperations/index.js.map +1 -1
  222. package/experiments/PostHogAnalyticsProvider.d.ts +31 -0
  223. package/experiments/PostHogAnalyticsProvider.js +28 -0
  224. package/experiments/PostHogAnalyticsProvider.js.map +1 -0
  225. package/experiments/analyticsProvider.d.ts +4 -0
  226. package/experiments/analyticsProvider.js +11 -0
  227. package/experiments/analyticsProvider.js.map +1 -0
  228. package/experiments/bucketing.d.ts +27 -0
  229. package/experiments/bucketing.js +91 -0
  230. package/experiments/bucketing.js.map +1 -0
  231. package/experiments/bucketing.test.d.ts +1 -0
  232. package/experiments/bucketing.test.js +183 -0
  233. package/experiments/bucketing.test.js.map +1 -0
  234. package/experiments/index.d.ts +5 -0
  235. package/experiments/index.js +5 -0
  236. package/experiments/render.d.ts +79 -0
  237. package/experiments/render.js +149 -0
  238. package/experiments/render.js.map +1 -0
  239. package/experiments/types.d.ts +108 -0
  240. package/experiments/types.js +4 -0
  241. package/experiments/types.js.map +1 -0
  242. package/findMatchingAstNode.js +11 -13
  243. package/findMatchingAstNode.js.map +1 -1
  244. package/generateElementId.d.ts +1 -1
  245. package/generateElementId.js +2 -2
  246. package/generateElementId.js.map +1 -1
  247. package/headersProvider.js +4 -3
  248. package/headersProvider.js.map +1 -1
  249. package/image/geometry.d.ts +54 -0
  250. package/image/geometry.js +112 -0
  251. package/image/geometry.js.map +1 -0
  252. package/image/geometry.test.d.ts +1 -0
  253. package/image/geometry.test.js +190 -0
  254. package/image/geometry.test.js.map +1 -0
  255. package/image/index.d.ts +3 -0
  256. package/image/index.js +3 -0
  257. package/image/presets.d.ts +6 -0
  258. package/image/presets.js +20 -0
  259. package/image/presets.js.map +1 -0
  260. package/image/types.d.ts +10 -0
  261. package/image/types.js +0 -0
  262. package/index.d.ts +12 -1
  263. package/index.js +11 -3
  264. package/jsonPatch.d.ts +1 -1
  265. package/jsonPatch.js +5 -9
  266. package/jsonPatch.js.map +1 -1
  267. package/messages.js +12 -11
  268. package/messages.js.map +1 -1
  269. package/messenger/MessageOrigin.js +12 -11
  270. package/messenger/MessageOrigin.js.map +1 -1
  271. package/messenger/Messenger.js +59 -70
  272. package/messenger/Messenger.js.map +1 -1
  273. package/messenger/index.js +0 -2
  274. package/package.json +19 -22
  275. package/registerComponentGroup.js +5 -6
  276. package/registerComponentGroup.js.map +1 -1
  277. package/tokenBinding.d.ts +26 -0
  278. package/tokenBinding.js +15 -0
  279. package/tokenBinding.js.map +1 -0
  280. package/tokenBinding.test.d.ts +1 -0
  281. package/tokenBinding.test.js +165 -0
  282. package/tokenBinding.test.js.map +1 -0
  283. package/types/ShorthandCssProperties.js +0 -3
  284. package/types/WebsiteBuilderTheme.d.ts +54 -45
  285. package/types/WebsiteBuilderTheme.js +0 -3
  286. package/types.d.ts +294 -13
  287. package/types.js +0 -3
  288. package/IBindingsUpdater.js.map +0 -1
  289. package/IRedirects.js.map +0 -1
  290. package/documentOperations/IDocumentOperation.js.map +0 -1
  291. package/index.js.map +0 -1
  292. package/lexical/createDefaultLexicalTheme.d.ts +0 -2
  293. package/lexical/createDefaultLexicalTheme.js +0 -84
  294. package/lexical/createDefaultLexicalTheme.js.map +0 -1
  295. package/lexical/createLexicalTheme.d.ts +0 -2
  296. package/lexical/createLexicalTheme.js +0 -7
  297. package/lexical/createLexicalTheme.js.map +0 -1
  298. package/lexical/deepMerge.d.ts +0 -1
  299. package/lexical/deepMerge.js +0 -23
  300. package/lexical/deepMerge.js.map +0 -1
  301. package/messenger/index.js.map +0 -1
  302. package/types/LexicalEditorTheme.d.ts +0 -2
  303. package/types/LexicalEditorTheme.js +0 -3
  304. package/types/LexicalEditorTheme.js.map +0 -1
  305. package/types/ShorthandCssProperties.js.map +0 -1
  306. package/types/WebsiteBuilderTheme.js.map +0 -1
  307. package/types.js.map +0 -1
package/createInput.d.ts CHANGED
@@ -1,17 +1,133 @@
1
- import type { TextInput, LongTextInput, NumberInput, BooleanInput, ColorInput, FileInput, LexicalInput, SelectInput, RadioInput, ObjectInput, DateTimeInput, ComponentInput, TagsInput, SlotInput } from "./types.js";
2
- type OmitType<T> = Omit<T, "type">;
3
- export declare function createTextInput(input: OmitType<TextInput>): TextInput;
4
- export declare function createLongTextInput(input: OmitType<LongTextInput>): ComponentInput;
5
- export declare function createNumberInput(input: OmitType<NumberInput>): NumberInput;
6
- export declare function createBooleanInput(input: OmitType<BooleanInput>): BooleanInput;
7
- export declare function createColorInput(input: OmitType<ColorInput>): ColorInput;
8
- export declare function createFileInput(input: OmitType<FileInput>): FileInput;
9
- export declare function createDateInput(input: OmitType<DateTimeInput>): DateTimeInput;
10
- export declare function createLexicalInput(input: OmitType<LexicalInput>): LexicalInput;
11
- export declare function createSelectInput(input: OmitType<SelectInput>): SelectInput;
12
- export declare function createRadioInput(input: OmitType<RadioInput>): RadioInput;
13
- export declare function createObjectInput(input: OmitType<ObjectInput>): ObjectInput;
14
- export declare function createTagsInput(input: OmitType<TagsInput>): TagsInput;
15
- export declare function createSlotInput(input: OmitType<SlotInput>): SlotInput;
1
+ import type { TextInput, LongTextInput, NumberInput, BooleanInput, ColorInput, FileInput, LexicalInput, SelectInput, RadioInput, ObjectInput, DateTimeInput, ComponentInput, TagsInput, SlotInput, ContentEntryInput } from "./types.js";
2
+ export type InputFactory<Name extends string> = ReturnType<typeof createTextInput<Name>> | ReturnType<typeof createLongTextInput<Name>> | ReturnType<typeof createNumberInput<Name>> | ReturnType<typeof createBooleanInput<Name>> | ReturnType<typeof createColorInput<Name>> | ReturnType<typeof createFileInput<Name>> | ReturnType<typeof createDateInput<Name>> | ReturnType<typeof createLexicalInput<Name>> | ReturnType<typeof createSelectInput<Name>> | ReturnType<typeof createRadioInput<Name>> | ReturnType<typeof createObjectInput<Name>> | ReturnType<typeof createTagsInput<Name>> | ReturnType<typeof createSlotInput<Name>> | ReturnType<typeof createContentEntryInput<Name>>;
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
+ export declare function createTextInput<TName extends string>(input: {
22
+ name: TName;
23
+ } & Omit<TextInput, "type" | "name">): TextInput & {
24
+ name: TName;
25
+ };
26
+ export declare function createTextInput<TName extends string>(input: Omit<TextInput, "type" | "name">): TextInput & {
27
+ name: TName;
28
+ };
29
+ export declare function createLongTextInput<TName extends string>(input: {
30
+ name: TName;
31
+ } & Omit<LongTextInput, "type" | "name">): LongTextInput & {
32
+ name: TName;
33
+ };
34
+ export declare function createLongTextInput<TName extends string>(input: Omit<LongTextInput, "type" | "name">): LongTextInput & {
35
+ name: TName;
36
+ };
37
+ export declare function createNumberInput<TName extends string>(input: {
38
+ name: TName;
39
+ } & Omit<NumberInput, "type" | "name">): NumberInput & {
40
+ name: TName;
41
+ };
42
+ export declare function createNumberInput<TName extends string>(input: Omit<NumberInput, "type" | "name">): NumberInput & {
43
+ name: TName;
44
+ };
45
+ export declare function createBooleanInput<TName extends string>(input: {
46
+ name: TName;
47
+ } & Omit<BooleanInput, "type" | "name">): BooleanInput & {
48
+ name: TName;
49
+ };
50
+ export declare function createBooleanInput<TName extends string>(input: Omit<BooleanInput, "type" | "name">): BooleanInput & {
51
+ name: TName;
52
+ };
53
+ export declare function createColorInput<TName extends string>(input: {
54
+ name: TName;
55
+ } & Omit<ColorInput, "type" | "name">): ColorInput & {
56
+ name: TName;
57
+ };
58
+ export declare function createColorInput<TName extends string>(input: Omit<ColorInput, "type" | "name">): ColorInput & {
59
+ name: TName;
60
+ };
61
+ export declare function createFileInput<TName extends string>(input: {
62
+ name: TName;
63
+ } & Omit<FileInput, "type" | "name">): FileInput & {
64
+ name: TName;
65
+ };
66
+ export declare function createFileInput<TName extends string>(input: Omit<FileInput, "type" | "name">): FileInput & {
67
+ name: TName;
68
+ };
69
+ export declare function createDateInput<TName extends string>(input: {
70
+ name: TName;
71
+ } & Omit<DateTimeInput, "type" | "name">): DateTimeInput & {
72
+ name: TName;
73
+ };
74
+ export declare function createDateInput<TName extends string>(input: Omit<DateTimeInput, "type" | "name">): DateTimeInput & {
75
+ name: TName;
76
+ };
77
+ export declare function createLexicalInput<TName extends string>(input: {
78
+ name: TName;
79
+ } & Omit<LexicalInput, "type" | "name">): LexicalInput & {
80
+ name: TName;
81
+ };
82
+ export declare function createLexicalInput<TName extends string>(input: Omit<LexicalInput, "type" | "name">): LexicalInput & {
83
+ name: TName;
84
+ };
85
+ export declare function createSelectInput<TName extends string>(input: {
86
+ name: TName;
87
+ } & Omit<SelectInput, "type" | "name">): SelectInput & {
88
+ name: TName;
89
+ };
90
+ export declare function createSelectInput<TName extends string>(input: Omit<SelectInput, "type" | "name">): SelectInput & {
91
+ name: TName;
92
+ };
93
+ export declare function createRadioInput<TName extends string>(input: {
94
+ name: TName;
95
+ } & Omit<RadioInput, "type" | "name">): RadioInput & {
96
+ name: TName;
97
+ };
98
+ export declare function createRadioInput<TName extends string>(input: Omit<RadioInput, "type" | "name">): RadioInput & {
99
+ name: TName;
100
+ };
101
+ export declare function createObjectInput<TName extends string>(input: {
102
+ name: TName;
103
+ } & Omit<ObjectInput, "type" | "name">): ObjectInput & {
104
+ name: TName;
105
+ };
106
+ export declare function createObjectInput<TName extends string>(input: Omit<ObjectInput, "type" | "name">): ObjectInput & {
107
+ name: TName;
108
+ };
109
+ export declare function createTagsInput<TName extends string>(input: {
110
+ name: TName;
111
+ } & Omit<TagsInput, "type" | "name">): TagsInput & {
112
+ name: TName;
113
+ };
114
+ export declare function createTagsInput<TName extends string>(input: Omit<TagsInput, "type" | "name">): TagsInput & {
115
+ name: TName;
116
+ };
117
+ export declare function createSlotInput<TName extends string>(input: {
118
+ name: TName;
119
+ } & Omit<SlotInput, "type" | "name">): SlotInput & {
120
+ name: TName;
121
+ };
122
+ export declare function createSlotInput<TName extends string>(input: Omit<SlotInput, "type" | "name">): SlotInput & {
123
+ name: TName;
124
+ };
125
+ export declare function createContentEntryInput<TName extends string>(input: {
126
+ name: TName;
127
+ } & Omit<ContentEntryInput, "type" | "name">): ContentEntryInput & {
128
+ name: TName;
129
+ };
130
+ export declare function createContentEntryInput<TName extends string>(input: Omit<ContentEntryInput, "type" | "name">): ContentEntryInput & {
131
+ name: TName;
132
+ };
16
133
  export declare function createInput(input: ComponentInput): ComponentInput;
17
- export {};
package/createInput.js CHANGED
@@ -1,128 +1,109 @@
1
1
  import { functionConverter } from "./FunctionConverter.js";
2
- // Text
3
- export function createTextInput(input) {
4
- return createInput({
5
- type: "text",
6
- renderer: "Webiny/Input",
7
- ...input
8
- });
2
+ function createTextInput(input) {
3
+ return createInput({
4
+ type: "text",
5
+ renderer: "Webiny/Input",
6
+ ...input
7
+ });
9
8
  }
10
-
11
- // Long Text
12
- export function createLongTextInput(input) {
13
- return createInput({
14
- type: "longText",
15
- renderer: "Webiny/Textarea",
16
- ...input
17
- });
9
+ function createLongTextInput(input) {
10
+ return createInput({
11
+ type: "longText",
12
+ renderer: "Webiny/Textarea",
13
+ ...input
14
+ });
18
15
  }
19
-
20
- // Number
21
- export function createNumberInput(input) {
22
- return createInput({
23
- type: "number",
24
- renderer: "Webiny/Number",
25
- ...input
26
- });
16
+ function createNumberInput(input) {
17
+ return createInput({
18
+ type: "number",
19
+ renderer: "Webiny/Number",
20
+ ...input
21
+ });
27
22
  }
28
-
29
- // Boolean
30
- export function createBooleanInput(input) {
31
- return createInput({
32
- type: "boolean",
33
- renderer: "Webiny/Switch",
34
- ...input
35
- });
23
+ function createBooleanInput(input) {
24
+ return createInput({
25
+ type: "boolean",
26
+ renderer: "Webiny/Switch",
27
+ ...input
28
+ });
36
29
  }
37
-
38
- // Color
39
- export function createColorInput(input) {
40
- return createInput({
41
- type: "color",
42
- renderer: "Webiny/ColorPicker",
43
- ...input
44
- });
30
+ function createColorInput(input) {
31
+ return createInput({
32
+ type: "color",
33
+ renderer: "Webiny/ColorPicker",
34
+ ...input
35
+ });
45
36
  }
46
-
47
- // File
48
- export function createFileInput(input) {
49
- return createInput({
50
- type: "file",
51
- renderer: "Webiny/FileManager",
52
- ...input
53
- });
37
+ function createFileInput(input) {
38
+ return createInput({
39
+ type: "file",
40
+ renderer: "Webiny/FileManager",
41
+ ...input
42
+ });
54
43
  }
55
-
56
- // Date
57
- export function createDateInput(input) {
58
- return createInput({
59
- type: "datetime",
60
- renderer: "Webiny/DateTime",
61
- ...input
62
- });
44
+ function createDateInput(input) {
45
+ return createInput({
46
+ type: "datetime",
47
+ renderer: "Webiny/DateTime",
48
+ ...input
49
+ });
63
50
  }
64
-
65
- // Rich Text
66
- export function createLexicalInput(input) {
67
- return createInput({
68
- type: "lexical",
69
- renderer: "Webiny/Lexical",
70
- ...input
71
- });
51
+ function createLexicalInput(input) {
52
+ return createInput({
53
+ type: "lexical",
54
+ renderer: "Webiny/Lexical",
55
+ ...input
56
+ });
72
57
  }
73
-
74
- // Select
75
- export function createSelectInput(input) {
76
- return createInput({
77
- type: "select",
78
- renderer: "Webiny/Select",
79
- ...input
80
- });
58
+ function createSelectInput(input) {
59
+ return createInput({
60
+ type: "select",
61
+ renderer: "Webiny/Select",
62
+ ...input
63
+ });
81
64
  }
82
-
83
- // Radio
84
- export function createRadioInput(input) {
85
- return createInput({
86
- type: "radio",
87
- renderer: "Webiny/RadioGroup",
88
- ...input
89
- });
65
+ function createRadioInput(input) {
66
+ return createInput({
67
+ type: "radio",
68
+ renderer: "Webiny/RadioGroup",
69
+ ...input
70
+ });
90
71
  }
91
-
92
- // Object
93
- export function createObjectInput(input) {
94
- return createInput({
95
- type: "object",
96
- renderer: "Webiny/Object",
97
- ...input
98
- });
72
+ function createObjectInput(input) {
73
+ return createInput({
74
+ type: "object",
75
+ renderer: "Webiny/Object",
76
+ ...input
77
+ });
99
78
  }
100
-
101
- // Tags
102
- export function createTagsInput(input) {
103
- return createInput({
104
- type: "text",
105
- list: true,
106
- renderer: "Webiny/Tags",
107
- ...input
108
- });
79
+ function createTagsInput(input) {
80
+ return createInput({
81
+ type: "text",
82
+ list: true,
83
+ renderer: "Webiny/Tags",
84
+ ...input
85
+ });
109
86
  }
110
- export function createSlotInput(input) {
111
- return createInput({
112
- type: "slot",
113
- list: true,
114
- renderer: "Webiny/Slot",
115
- ...input
116
- });
87
+ function createSlotInput(input) {
88
+ return createInput({
89
+ type: "slot",
90
+ list: true,
91
+ renderer: "Webiny/Slot",
92
+ defaultValue: [],
93
+ ...input
94
+ });
117
95
  }
118
-
119
- // Implementation
120
- export function createInput(input) {
121
- if (input.onChange) {
122
- // @ts-expect-error We don't use this function on the frontend, so this is ok.
123
- input.onChange = functionConverter.serialize(input.onChange);
124
- }
125
- 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;
126
106
  }
107
+ export { createBooleanInput, createColorInput, createContentEntryInput, createDateInput, createFileInput, createInput, createLexicalInput, createLongTextInput, createNumberInput, createObjectInput, createRadioInput, createSelectInput, createSlotInput, createTagsInput, createTextInput };
127
108
 
128
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","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\ntype OmitType<T> = Omit<T, \"type\">;\n\n// Text\nexport function createTextInput(input: OmitType<TextInput>) {\n return createInput({\n type: \"text\",\n renderer: \"Webiny/Input\",\n ...input\n }) as TextInput;\n}\n\n// Long Text\nexport function createLongTextInput(input: OmitType<LongTextInput>) {\n return createInput({\n type: \"longText\",\n renderer: \"Webiny/Textarea\",\n ...input\n });\n}\n\n// Number\nexport function createNumberInput(input: OmitType<NumberInput>) {\n return createInput({\n type: \"number\",\n renderer: \"Webiny/Number\",\n ...input\n }) as NumberInput;\n}\n\n// Boolean\nexport function createBooleanInput(input: OmitType<BooleanInput>) {\n return createInput({\n type: \"boolean\",\n renderer: \"Webiny/Switch\",\n ...input\n }) as BooleanInput;\n}\n\n// Color\nexport function createColorInput(input: OmitType<ColorInput>) {\n return createInput({\n type: \"color\",\n renderer: \"Webiny/ColorPicker\",\n ...input\n }) as ColorInput;\n}\n\n// File\nexport function createFileInput(input: OmitType<FileInput>) {\n return createInput({\n type: \"file\",\n renderer: \"Webiny/FileManager\",\n ...input\n }) as FileInput;\n}\n\n// Date\nexport function createDateInput(input: OmitType<DateTimeInput>) {\n return createInput({\n type: \"datetime\",\n renderer: \"Webiny/DateTime\",\n ...input\n }) as DateTimeInput;\n}\n\n// Rich Text\nexport function createLexicalInput(input: OmitType<LexicalInput>) {\n return createInput({\n type: \"lexical\",\n renderer: \"Webiny/Lexical\",\n ...input\n }) as LexicalInput;\n}\n\n// Select\nexport function createSelectInput(input: OmitType<SelectInput>) {\n return createInput({\n type: \"select\",\n renderer: \"Webiny/Select\",\n ...input\n }) as SelectInput;\n}\n\n// Radio\nexport function createRadioInput(input: OmitType<RadioInput>) {\n return createInput({\n type: \"radio\",\n renderer: \"Webiny/RadioGroup\",\n ...input\n }) as RadioInput;\n}\n\n// Object\nexport function createObjectInput(input: OmitType<ObjectInput>) {\n return createInput({\n type: \"object\",\n renderer: \"Webiny/Object\",\n ...input\n }) as ObjectInput;\n}\n\n// Tags\nexport function createTagsInput(input: OmitType<TagsInput>) {\n return createInput({\n type: \"text\",\n list: true,\n renderer: \"Webiny/Tags\",\n ...input\n }) as TagsInput;\n}\n\nexport function createSlotInput(input: OmitType<SlotInput>) {\n return createInput({\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n ...input\n }) as SlotInput;\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":"AAgBA,SAASA,iBAAiB;AAI1B;AACA,OAAO,SAASC,eAAeA,CAACC,KAA0B,EAAE;EACxD,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,MAAM;IACZC,QAAQ,EAAE,cAAc;IACxB,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASI,mBAAmBA,CAACJ,KAA8B,EAAE;EAChE,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,UAAU;IAChBC,QAAQ,EAAE,iBAAiB;IAC3B,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASK,iBAAiBA,CAACL,KAA4B,EAAE;EAC5D,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,QAAQ;IACdC,QAAQ,EAAE,eAAe;IACzB,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASM,kBAAkBA,CAACN,KAA6B,EAAE;EAC9D,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,SAAS;IACfC,QAAQ,EAAE,eAAe;IACzB,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASO,gBAAgBA,CAACP,KAA2B,EAAE;EAC1D,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,OAAO;IACbC,QAAQ,EAAE,oBAAoB;IAC9B,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASQ,eAAeA,CAACR,KAA0B,EAAE;EACxD,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,MAAM;IACZC,QAAQ,EAAE,oBAAoB;IAC9B,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASS,eAAeA,CAACT,KAA8B,EAAE;EAC5D,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,UAAU;IAChBC,QAAQ,EAAE,iBAAiB;IAC3B,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASU,kBAAkBA,CAACV,KAA6B,EAAE;EAC9D,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,SAAS;IACfC,QAAQ,EAAE,gBAAgB;IAC1B,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASW,iBAAiBA,CAACX,KAA4B,EAAE;EAC5D,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,QAAQ;IACdC,QAAQ,EAAE,eAAe;IACzB,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASY,gBAAgBA,CAACZ,KAA2B,EAAE;EAC1D,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,OAAO;IACbC,QAAQ,EAAE,mBAAmB;IAC7B,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASa,iBAAiBA,CAACb,KAA4B,EAAE;EAC5D,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,QAAQ;IACdC,QAAQ,EAAE,eAAe;IACzB,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASc,eAAeA,CAACd,KAA0B,EAAE;EACxD,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,MAAM;IACZa,IAAI,EAAE,IAAI;IACVZ,QAAQ,EAAE,aAAa;IACvB,GAAGH;EACP,CAAC,CAAC;AACN;AAEA,OAAO,SAASgB,eAAeA,CAAChB,KAA0B,EAAE;EACxD,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,MAAM;IACZa,IAAI,EAAE,IAAI;IACVZ,QAAQ,EAAE,aAAa;IACvB,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASC,WAAWA,CAACD,KAAqB,EAAkB;EAC/D,IAAIA,KAAK,CAACiB,QAAQ,EAAE;IAChB;IACAjB,KAAK,CAACiB,QAAQ,GAAGnB,iBAAiB,CAACoB,SAAS,CAAClB,KAAK,CAACiB,QAAS,CAAC;EACjE;EACA,OAAOjB,KAAK;AAChB","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,5 +1,6 @@
1
- import type { IDataProvider, PublicPage } from "../types.js";
2
- import type { ApiClient } from "./ApiClient.js";
1
+ import type { IDataProvider, ListPagesOptions, ListPagesResult, PublicPage } from "../types.js";
2
+ import type { ActiveExperiment, VariantContent } from "../experiments/types.js";
3
+ import type { ApiClient } from "../dataProviders/ApiClient.js";
3
4
  interface DefaultDataProviderConfig {
4
5
  apiClient: ApiClient;
5
6
  }
@@ -8,7 +9,10 @@ export declare class DefaultDataProvider implements IDataProvider {
8
9
  constructor(config: DefaultDataProviderConfig);
9
10
  getPageByPath(path: string): Promise<PublicPage | null>;
10
11
  getPageById(id: string): Promise<PublicPage | null>;
11
- listPages(): Promise<any>;
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 {};