@webiny/website-builder-sdk 0.0.0-unstable.3bc8100a7f → 0.0.0-unstable.3fddf667ea
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BindingsApi.d.ts +4 -4
- package/BindingsApi.js +32 -39
- package/BindingsApi.js.map +1 -1
- package/BindingsProcessor.d.ts +1 -1
- package/BindingsProcessor.js +34 -43
- package/BindingsProcessor.js.map +1 -1
- package/BindingsProcessor.test.js +83 -78
- package/BindingsProcessor.test.js.map +1 -1
- package/BindingsResolver.d.ts +6 -3
- package/BindingsResolver.js +92 -122
- package/BindingsResolver.js.map +1 -1
- package/BindingsResolver.test.js +402 -365
- package/BindingsResolver.test.js.map +1 -1
- package/ComponentInputTraverser.d.ts +1 -1
- package/ComponentInputTraverser.js +29 -49
- package/ComponentInputTraverser.js.map +1 -1
- package/ComponentManifestToAstConverter.d.ts +23 -1
- package/ComponentManifestToAstConverter.js +140 -21
- package/ComponentManifestToAstConverter.js.map +1 -1
- package/ComponentRegistry.d.ts +2 -1
- package/ComponentRegistry.js +40 -22
- package/ComponentRegistry.js.map +1 -1
- package/ComponentResolver.d.ts +7 -4
- package/ComponentResolver.js +33 -32
- package/ComponentResolver.js.map +1 -1
- package/ConstraintEvaluator.d.ts +41 -0
- package/ConstraintEvaluator.js +304 -0
- package/ConstraintEvaluator.js.map +1 -0
- package/ConstraintEvaluator.test.d.ts +1 -0
- package/ConstraintEvaluator.test.js +1771 -0
- package/ConstraintEvaluator.test.js.map +1 -0
- package/ContentSdk.d.ts +90 -8
- package/ContentSdk.js +195 -78
- package/ContentSdk.js.map +1 -1
- package/DocumentStore.d.ts +3 -3
- package/DocumentStore.js +48 -60
- package/DocumentStore.js.map +1 -1
- package/DocumentStoreManager.d.ts +11 -4
- package/DocumentStoreManager.js +37 -17
- package/DocumentStoreManager.js.map +1 -1
- package/EditingSdk.d.ts +21 -5
- package/EditingSdk.js +119 -131
- package/EditingSdk.js.map +1 -1
- package/ElementBindings.d.ts +28 -0
- package/ElementBindings.js +88 -0
- package/ElementBindings.js.map +1 -0
- package/ElementBindings.test.d.ts +1 -0
- package/ElementBindings.test.js +127 -0
- package/ElementBindings.test.js.map +1 -0
- package/ElementFactory.d.ts +15 -7
- package/ElementFactory.js +165 -168
- package/ElementFactory.js.map +1 -1
- package/ElementFactory.test.d.ts +1 -0
- package/ElementFactory.test.js +511 -0
- package/ElementFactory.test.js.map +1 -0
- package/ElementSelection.d.ts +20 -0
- package/ElementSelection.js +32 -0
- package/ElementSelection.js.map +1 -0
- package/ElementSelection.test.d.ts +1 -0
- package/ElementSelection.test.js +73 -0
- package/ElementSelection.test.js.map +1 -0
- package/Environment.d.ts +7 -0
- package/Environment.js +19 -19
- package/Environment.js.map +1 -1
- package/Environment.test.d.ts +1 -0
- package/Environment.test.js +39 -0
- package/Environment.test.js.map +1 -0
- package/FunctionConverter.js +8 -7
- package/FunctionConverter.js.map +1 -1
- package/GlobalComponentLanguage.d.ts +31 -0
- package/GlobalComponentLanguage.js +37 -0
- package/GlobalComponentLanguage.js.map +1 -0
- package/HashObject.js +11 -12
- package/HashObject.js.map +1 -1
- package/HotkeyManager.js +41 -48
- package/HotkeyManager.js.map +1 -1
- package/IBindingsUpdater.d.ts +2 -2
- package/IBindingsUpdater.js +0 -3
- package/IRedirects.d.ts +5 -0
- package/IRedirects.js +0 -0
- package/InheritanceProcessor.d.ts +4 -4
- package/InheritanceProcessor.js +99 -139
- package/InheritanceProcessor.js.map +1 -1
- package/InheritanceProcessor.test.js +185 -177
- package/InheritanceProcessor.test.js.map +1 -1
- package/InheritedValueResolver.d.ts +7 -1
- package/InheritedValueResolver.js +22 -20
- package/InheritedValueResolver.js.map +1 -1
- package/InputBindingsProcessor.d.ts +4 -4
- package/InputBindingsProcessor.js +196 -294
- package/InputBindingsProcessor.js.map +1 -1
- package/InputRenderer.test.d.ts +1 -0
- package/InputRenderer.test.js +186 -0
- package/InputRenderer.test.js.map +1 -0
- package/InputsBindingsProcessor.test.js +466 -315
- package/InputsBindingsProcessor.test.js.map +1 -1
- package/InputsUpdater.d.ts +5 -5
- package/InputsUpdater.js +26 -28
- package/InputsUpdater.js.map +1 -1
- package/LayoutContentArea.d.ts +68 -0
- package/LayoutContentArea.js +78 -0
- package/LayoutContentArea.js.map +1 -0
- package/LayoutContentArea.test.d.ts +1 -0
- package/LayoutContentArea.test.js +111 -0
- package/LayoutContentArea.test.js.map +1 -0
- package/LiveSdk.d.ts +6 -3
- package/LiveSdk.js +17 -14
- package/LiveSdk.js.map +1 -1
- package/Logger.d.ts +2 -1
- package/Logger.js +10 -6
- package/Logger.js.map +1 -1
- package/MouseTracker.js +77 -83
- package/MouseTracker.js.map +1 -1
- package/NullSdk.d.ts +6 -3
- package/NullSdk.js +25 -11
- package/NullSdk.js.map +1 -1
- package/PreviewDocument.d.ts +3 -1
- package/PreviewDocument.js +31 -31
- package/PreviewDocument.js.map +1 -1
- package/PreviewSdk.d.ts +7 -3
- package/PreviewSdk.js +24 -18
- package/PreviewSdk.js.map +1 -1
- package/PreviewViewport.d.ts +6 -2
- package/PreviewViewport.js +60 -83
- package/PreviewViewport.js.map +1 -1
- package/PreviewViewport.test.d.ts +1 -0
- package/PreviewViewport.test.js +27 -0
- package/PreviewViewport.test.js.map +1 -0
- package/README.md +10 -2
- package/RadioOptionInputs.test.d.ts +1 -0
- package/RadioOptionInputs.test.js +521 -0
- package/RadioOptionInputs.test.js.map +1 -0
- package/ResizeObserver.js +24 -31
- package/ResizeObserver.js.map +1 -1
- package/StylesBindingsProcessor.d.ts +2 -2
- package/StylesBindingsProcessor.js +45 -83
- package/StylesBindingsProcessor.js.map +1 -1
- package/StylesUpdater.d.ts +4 -4
- package/StylesUpdater.js +25 -27
- package/StylesUpdater.js.map +1 -1
- package/Theme.d.ts +1 -1
- package/Theme.js +31 -33
- package/Theme.js.map +1 -1
- package/ViewportManager.d.ts +3 -1
- package/ViewportManager.js +90 -95
- package/ViewportManager.js.map +1 -1
- package/asset/deliveryUrl.d.ts +41 -0
- package/asset/deliveryUrl.js +34 -0
- package/asset/deliveryUrl.js.map +1 -0
- package/asset/deliveryUrl.test.d.ts +1 -0
- package/asset/deliveryUrl.test.js +127 -0
- package/asset/deliveryUrl.test.js.map +1 -0
- package/asset/geometry.d.ts +7 -0
- package/asset/geometry.js +10 -0
- package/asset/geometry.js.map +1 -0
- package/asset/imageSrcSet.d.ts +63 -0
- package/asset/imageSrcSet.js +98 -0
- package/asset/imageSrcSet.js.map +1 -0
- package/asset/imageSrcSet.test.d.ts +1 -0
- package/asset/imageSrcSet.test.js +103 -0
- package/asset/imageSrcSet.test.js.map +1 -0
- package/asset/index.d.ts +5 -0
- package/asset/index.js +5 -0
- package/asset/normalize.d.ts +24 -0
- package/asset/normalize.js +106 -0
- package/asset/normalize.js.map +1 -0
- package/asset/normalize.test.d.ts +1 -0
- package/asset/normalize.test.js +263 -0
- package/asset/normalize.test.js.map +1 -0
- package/asset/types.d.ts +2 -0
- package/asset/types.js +0 -0
- package/componentLoader/ComponentLoader.d.ts +16 -0
- package/componentLoader/ComponentLoader.js +0 -0
- package/componentLoader/RegistryOnlyComponentLoader.d.ts +9 -0
- package/componentLoader/RegistryOnlyComponentLoader.js +8 -0
- package/componentLoader/RegistryOnlyComponentLoader.js.map +1 -0
- package/componentLoader/createComponentLoader.d.ts +7 -0
- package/componentLoader/createComponentLoader.js +10 -0
- package/componentLoader/createComponentLoader.js.map +1 -0
- package/componentLoader/defaultComponentLoader.d.ts +7 -0
- package/componentLoader/defaultComponentLoader.js +8 -0
- package/componentLoader/defaultComponentLoader.js.map +1 -0
- package/componentLoader/index.d.ts +3 -0
- package/componentLoader/index.js +3 -0
- package/constants.d.ts +1 -0
- package/constants.js +7 -5
- package/constants.js.map +1 -1
- package/contentClientState.test.d.ts +1 -0
- package/contentClientState.test.js +404 -0
- package/contentClientState.test.js.map +1 -0
- package/contentEntry/ContentEntryBindingsResolver.d.ts +33 -0
- package/contentEntry/ContentEntryBindingsResolver.js +52 -0
- package/contentEntry/ContentEntryBindingsResolver.js.map +1 -0
- package/contentEntry/ContentEntryCache.d.ts +49 -0
- package/contentEntry/ContentEntryCache.js +51 -0
- package/contentEntry/ContentEntryCache.js.map +1 -0
- package/contentEntry/resolveContentEntry.d.ts +74 -0
- package/contentEntry/resolveContentEntry.js +53 -0
- package/contentEntry/resolveContentEntry.js.map +1 -0
- package/contentEntry/resolveContentEntry.test.d.ts +1 -0
- package/contentEntry/resolveContentEntry.test.js +213 -0
- package/contentEntry/resolveContentEntry.test.js.map +1 -0
- package/createComponent.d.ts +5 -0
- package/createComponent.js +32 -0
- package/createComponent.js.map +1 -0
- package/createContentClient.d.ts +17 -0
- package/createContentClient.js +16 -0
- package/createContentClient.js.map +1 -0
- package/createContentClient.test.d.ts +1 -0
- package/createContentClient.test.js +165 -0
- package/createContentClient.test.js.map +1 -0
- package/createElement.d.ts +1 -1
- package/createElement.js +5 -6
- package/createElement.js.map +1 -1
- package/createGlobalElementDocument.d.ts +6 -0
- package/createGlobalElementDocument.js +23 -0
- package/createGlobalElementDocument.js.map +1 -0
- package/createInput.d.ts +132 -16
- package/createInput.js +93 -112
- package/createInput.js.map +1 -1
- package/createTheme.d.ts +1 -1
- package/createTheme.js +2 -3
- package/createTheme.js.map +1 -1
- package/dataProviders/ApiClient.d.ts +18 -5
- package/dataProviders/ApiClient.js +58 -38
- package/dataProviders/ApiClient.js.map +1 -1
- package/dataProviders/ApiClient.test.d.ts +1 -0
- package/dataProviders/ApiClient.test.js +116 -0
- package/dataProviders/ApiClient.test.js.map +1 -0
- package/dataProviders/DefaultDataProvider.d.ts +9 -3
- package/dataProviders/DefaultDataProvider.js +106 -35
- package/dataProviders/DefaultDataProvider.js.map +1 -1
- package/dataProviders/DefaultDataProvider.test.d.ts +1 -0
- package/dataProviders/DefaultDataProvider.test.js +81 -0
- package/dataProviders/DefaultDataProvider.test.js.map +1 -0
- package/dataProviders/GET_EXPERIMENT_PAUSED.d.ts +1 -0
- package/dataProviders/GET_EXPERIMENT_PAUSED.js +17 -0
- package/dataProviders/GET_EXPERIMENT_PAUSED.js.map +1 -0
- package/dataProviders/GET_LAYOUT_BY_SLUG.d.ts +1 -0
- package/dataProviders/GET_LAYOUT_BY_SLUG.js +27 -0
- package/dataProviders/GET_LAYOUT_BY_SLUG.js.map +1 -0
- package/dataProviders/GET_PAGE_BY_ID.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_ID.js +11 -1
- package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.js +11 -1
- package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
- package/dataProviders/GET_PAGE_EXPERIMENT.d.ts +1 -0
- package/dataProviders/GET_PAGE_EXPERIMENT.js +32 -0
- package/dataProviders/GET_PAGE_EXPERIMENT.js.map +1 -0
- package/dataProviders/GET_VARIANT_CONTENT.d.ts +1 -0
- package/dataProviders/GET_VARIANT_CONTENT.js +24 -0
- package/dataProviders/GET_VARIANT_CONTENT.js.map +1 -0
- package/dataProviders/LIST_PUBLISHED_PAGES.d.ts +1 -1
- package/dataProviders/LIST_PUBLISHED_PAGES.js +17 -5
- package/dataProviders/LIST_PUBLISHED_PAGES.js.map +1 -1
- package/dataProviders/NullDataProvider.d.ts +18 -4
- package/dataProviders/NullDataProvider.js +33 -10
- package/dataProviders/NullDataProvider.js.map +1 -1
- package/dataProviders/RedirectsProvider.d.ts +11 -0
- package/dataProviders/RedirectsProvider.js +29 -0
- package/dataProviders/RedirectsProvider.js.map +1 -0
- package/dataProviders/queries.test.d.ts +1 -0
- package/dataProviders/queries.test.js +53 -0
- package/dataProviders/queries.test.js.map +1 -0
- package/defaultBreakpoints.d.ts +1 -1
- package/defaultBreakpoints.js +43 -22
- package/defaultBreakpoints.js.map +1 -1
- package/documentOperations/$addElementReferenceToParent.d.ts +1 -1
- package/documentOperations/$addElementReferenceToParent.js +30 -26
- package/documentOperations/$addElementReferenceToParent.js.map +1 -1
- package/documentOperations/AddElement.d.ts +1 -1
- package/documentOperations/AddElement.js +8 -7
- package/documentOperations/AddElement.js.map +1 -1
- package/documentOperations/AddToParent.d.ts +3 -3
- package/documentOperations/AddToParent.js +14 -13
- package/documentOperations/AddToParent.js.map +1 -1
- package/documentOperations/IDocumentOperation.js +0 -3
- package/documentOperations/RemoveElement.d.ts +1 -1
- package/documentOperations/RemoveElement.js +10 -7
- package/documentOperations/RemoveElement.js.map +1 -1
- package/documentOperations/SetGlobalInputBinding.d.ts +1 -1
- package/documentOperations/SetGlobalInputBinding.js +23 -22
- package/documentOperations/SetGlobalInputBinding.js.map +1 -1
- package/documentOperations/SetGlobalStyleBinding.d.ts +1 -1
- package/documentOperations/SetGlobalStyleBinding.js +23 -23
- package/documentOperations/SetGlobalStyleBinding.js.map +1 -1
- package/documentOperations/SetInputBindingOverride.d.ts +1 -1
- package/documentOperations/SetInputBindingOverride.js +30 -29
- package/documentOperations/SetInputBindingOverride.js.map +1 -1
- package/documentOperations/SetStyleBindingOverride.d.ts +1 -1
- package/documentOperations/SetStyleBindingOverride.js +30 -31
- package/documentOperations/SetStyleBindingOverride.js.map +1 -1
- package/documentOperations/index.d.ts +8 -8
- package/documentOperations/index.js +16 -15
- package/documentOperations/index.js.map +1 -1
- package/experiments/PostHogAnalyticsProvider.d.ts +31 -0
- package/experiments/PostHogAnalyticsProvider.js +28 -0
- package/experiments/PostHogAnalyticsProvider.js.map +1 -0
- package/experiments/analyticsProvider.d.ts +4 -0
- package/experiments/analyticsProvider.js +11 -0
- package/experiments/analyticsProvider.js.map +1 -0
- package/experiments/bucketing.d.ts +27 -0
- package/experiments/bucketing.js +91 -0
- package/experiments/bucketing.js.map +1 -0
- package/experiments/bucketing.test.d.ts +1 -0
- package/experiments/bucketing.test.js +183 -0
- package/experiments/bucketing.test.js.map +1 -0
- package/experiments/index.d.ts +5 -0
- package/experiments/index.js +5 -0
- package/experiments/render.d.ts +82 -0
- package/experiments/render.js +149 -0
- package/experiments/render.js.map +1 -0
- package/experiments/types.d.ts +108 -0
- package/experiments/types.js +4 -0
- package/experiments/types.js.map +1 -0
- package/findMatchingAstNode.d.ts +1 -1
- package/findMatchingAstNode.js +11 -13
- package/findMatchingAstNode.js.map +1 -1
- package/generateElementId.d.ts +1 -1
- package/generateElementId.js +2 -2
- package/generateElementId.js.map +1 -1
- package/globalElements.d.ts +43 -0
- package/globalElements.js +79 -0
- package/globalElements.js.map +1 -0
- package/globalElements.test.d.ts +1 -0
- package/globalElements.test.js +343 -0
- package/globalElements.test.js.map +1 -0
- package/headersProvider.d.ts +1 -2
- package/headersProvider.js +4 -3
- package/headersProvider.js.map +1 -1
- package/image/geometry.d.ts +54 -0
- package/image/geometry.js +112 -0
- package/image/geometry.js.map +1 -0
- package/image/geometry.test.d.ts +1 -0
- package/image/geometry.test.js +190 -0
- package/image/geometry.test.js.map +1 -0
- package/image/index.d.ts +3 -0
- package/image/index.js +3 -0
- package/image/presets.d.ts +6 -0
- package/image/presets.js +20 -0
- package/image/presets.js.map +1 -0
- package/image/types.d.ts +10 -0
- package/image/types.js +0 -0
- package/index.d.ts +22 -3
- package/index.js +21 -5
- package/jsonPatch.d.ts +1 -1
- package/jsonPatch.js +5 -9
- package/jsonPatch.js.map +1 -1
- package/messages.d.ts +3 -0
- package/messages.js +15 -11
- package/messages.js.map +1 -1
- package/messenger/MessageOrigin.js +12 -11
- package/messenger/MessageOrigin.js.map +1 -1
- package/messenger/Messenger.js +59 -70
- package/messenger/Messenger.js.map +1 -1
- package/messenger/index.js +0 -2
- package/package.json +19 -23
- package/radioOptionInputs.d.ts +24 -0
- package/radioOptionInputs.js +26 -0
- package/radioOptionInputs.js.map +1 -0
- package/registerComponentGroup.d.ts +1 -1
- package/registerComponentGroup.js +6 -7
- package/registerComponentGroup.js.map +1 -1
- package/types/ShorthandCssProperties.js +0 -3
- package/types/WebsiteBuilderTheme.d.ts +54 -45
- package/types/WebsiteBuilderTheme.js +0 -3
- package/types.d.ts +369 -24
- package/types.js +0 -3
- package/withGlobalElementDefaults.d.ts +8 -0
- package/withGlobalElementDefaults.js +60 -0
- package/withGlobalElementDefaults.js.map +1 -0
- package/IBindingsUpdater.js.map +0 -1
- package/documentOperations/IDocumentOperation.js.map +0 -1
- package/index.js.map +0 -1
- package/lexical/createDefaultLexicalTheme.d.ts +0 -2
- package/lexical/createDefaultLexicalTheme.js +0 -84
- package/lexical/createDefaultLexicalTheme.js.map +0 -1
- package/lexical/createLexicalTheme.d.ts +0 -2
- package/lexical/createLexicalTheme.js +0 -7
- package/lexical/createLexicalTheme.js.map +0 -1
- package/lexical/deepMerge.d.ts +0 -1
- package/lexical/deepMerge.js +0 -23
- package/lexical/deepMerge.js.map +0 -1
- package/messenger/index.js.map +0 -1
- package/types/LexicalEditorTheme.d.ts +0 -2
- package/types/LexicalEditorTheme.js +0 -3
- package/types/LexicalEditorTheme.js.map +0 -1
- package/types/ShorthandCssProperties.js.map +0 -1
- package/types/WebsiteBuilderTheme.js.map +0 -1
- package/types.js.map +0 -1
package/createInput.js
CHANGED
|
@@ -1,128 +1,109 @@
|
|
|
1
|
-
import { functionConverter } from "./FunctionConverter";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
1
|
+
import { functionConverter } from "./FunctionConverter.js";
|
|
2
|
+
function createTextInput(input) {
|
|
3
|
+
return createInput({
|
|
4
|
+
type: "text",
|
|
5
|
+
renderer: "Webiny/Input",
|
|
6
|
+
...input
|
|
7
|
+
});
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
...input
|
|
17
|
-
});
|
|
9
|
+
function createLongTextInput(input) {
|
|
10
|
+
return createInput({
|
|
11
|
+
type: "longText",
|
|
12
|
+
renderer: "Webiny/Textarea",
|
|
13
|
+
...input
|
|
14
|
+
});
|
|
18
15
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
...input
|
|
26
|
-
});
|
|
16
|
+
function createNumberInput(input) {
|
|
17
|
+
return createInput({
|
|
18
|
+
type: "number",
|
|
19
|
+
renderer: "Webiny/Number",
|
|
20
|
+
...input
|
|
21
|
+
});
|
|
27
22
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
...input
|
|
35
|
-
});
|
|
23
|
+
function createBooleanInput(input) {
|
|
24
|
+
return createInput({
|
|
25
|
+
type: "boolean",
|
|
26
|
+
renderer: "Webiny/Switch",
|
|
27
|
+
...input
|
|
28
|
+
});
|
|
36
29
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
...input
|
|
44
|
-
});
|
|
30
|
+
function createColorInput(input) {
|
|
31
|
+
return createInput({
|
|
32
|
+
type: "color",
|
|
33
|
+
renderer: "Webiny/ColorPicker",
|
|
34
|
+
...input
|
|
35
|
+
});
|
|
45
36
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
...input
|
|
53
|
-
});
|
|
37
|
+
function createFileInput(input) {
|
|
38
|
+
return createInput({
|
|
39
|
+
type: "file",
|
|
40
|
+
renderer: "Webiny/FileManager",
|
|
41
|
+
...input
|
|
42
|
+
});
|
|
54
43
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
...input
|
|
62
|
-
});
|
|
44
|
+
function createDateInput(input) {
|
|
45
|
+
return createInput({
|
|
46
|
+
type: "datetime",
|
|
47
|
+
renderer: "Webiny/DateTime",
|
|
48
|
+
...input
|
|
49
|
+
});
|
|
63
50
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
...input
|
|
71
|
-
});
|
|
51
|
+
function createLexicalInput(input) {
|
|
52
|
+
return createInput({
|
|
53
|
+
type: "lexical",
|
|
54
|
+
renderer: "Webiny/Lexical",
|
|
55
|
+
...input
|
|
56
|
+
});
|
|
72
57
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
...input
|
|
80
|
-
});
|
|
58
|
+
function createSelectInput(input) {
|
|
59
|
+
return createInput({
|
|
60
|
+
type: "select",
|
|
61
|
+
renderer: "Webiny/Select",
|
|
62
|
+
...input
|
|
63
|
+
});
|
|
81
64
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
...input
|
|
89
|
-
});
|
|
65
|
+
function createRadioInput(input) {
|
|
66
|
+
return createInput({
|
|
67
|
+
type: "radio",
|
|
68
|
+
renderer: "Webiny/RadioGroup",
|
|
69
|
+
...input
|
|
70
|
+
});
|
|
90
71
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
...input
|
|
98
|
-
});
|
|
72
|
+
function createObjectInput(input) {
|
|
73
|
+
return createInput({
|
|
74
|
+
type: "object",
|
|
75
|
+
renderer: "Webiny/Object",
|
|
76
|
+
...input
|
|
77
|
+
});
|
|
99
78
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
package/createInput.js.map
CHANGED
|
@@ -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\";\nimport { functionConverter } from \"~/FunctionConverter\";\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.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { WebsiteBuilderThemeInput } from "./types/WebsiteBuilderTheme";
|
|
1
|
+
import type { WebsiteBuilderThemeInput } from "./types/WebsiteBuilderTheme.js";
|
|
2
2
|
export type { WebsiteBuilderThemeInput };
|
|
3
3
|
export declare const createTheme: (theme: WebsiteBuilderThemeInput) => WebsiteBuilderThemeInput;
|
package/createTheme.js
CHANGED
package/createTheme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,13 +1,26 @@
|
|
|
1
|
+
import { type HeadersConfig } from "@webiny/sdk";
|
|
1
2
|
interface QueryParams {
|
|
2
3
|
query: string;
|
|
3
4
|
variables: Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
export interface ApiClientConfig {
|
|
7
|
+
apiHost: string;
|
|
8
|
+
apiKey: string;
|
|
9
|
+
apiTenant: string;
|
|
10
|
+
/** Extra headers sent with every request; a function is called before each request. */
|
|
11
|
+
headers?: HeadersConfig;
|
|
4
12
|
preview?: boolean;
|
|
5
13
|
}
|
|
14
|
+
type WithPath<T> = T & {
|
|
15
|
+
path?: string;
|
|
16
|
+
next?: Record<string, any>;
|
|
17
|
+
};
|
|
6
18
|
export declare class ApiClient {
|
|
7
|
-
private readonly
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
private readonly config;
|
|
20
|
+
constructor(config: ApiClientConfig);
|
|
21
|
+
fetch({ headers, path, ...params }: WithPath<RequestInit>): Promise<any>;
|
|
22
|
+
query({ query, variables }: QueryParams, options?: {
|
|
23
|
+
noStore?: boolean;
|
|
24
|
+
}): Promise<any>;
|
|
12
25
|
}
|
|
13
26
|
export {};
|
|
@@ -1,43 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { resolveHeaders } from "@webiny/sdk";
|
|
2
|
+
const PROTECTED_HEADERS = [
|
|
3
|
+
"x-tenant",
|
|
4
|
+
"authorization"
|
|
5
|
+
];
|
|
6
|
+
function headerEntries(headers) {
|
|
7
|
+
if (!headers) return [];
|
|
8
|
+
if (headers instanceof Headers) return Array.from(headers.entries());
|
|
9
|
+
return Array.isArray(headers) ? headers : Object.entries(headers);
|
|
10
|
+
}
|
|
11
|
+
function mergeHeaders(...sources) {
|
|
12
|
+
const merged = new Map();
|
|
13
|
+
for (const source of sources)for (const [name, value] of headerEntries(source))merged.set(name.toLowerCase(), [
|
|
14
|
+
name,
|
|
15
|
+
value
|
|
16
|
+
]);
|
|
17
|
+
return Object.fromEntries(merged.values());
|
|
18
|
+
}
|
|
19
|
+
class ApiClient {
|
|
20
|
+
constructor(config){
|
|
21
|
+
this.config = config;
|
|
22
|
+
}
|
|
23
|
+
async fetch({ headers, path, ...params }) {
|
|
24
|
+
return fetch(`${this.config.apiHost}${path}`, {
|
|
25
|
+
method: "GET",
|
|
26
|
+
headers: mergeHeaders({
|
|
27
|
+
"Content-Type": "application/json"
|
|
28
|
+
}, headerEntries(await resolveHeaders(this.config.headers)).filter(([name])=>!PROTECTED_HEADERS.includes(name.toLowerCase())), {
|
|
29
|
+
"X-Tenant": this.config.apiTenant,
|
|
30
|
+
Authorization: "Bearer " + this.config.apiKey
|
|
31
|
+
}, headers),
|
|
32
|
+
...params
|
|
33
|
+
}).then((res)=>res.json());
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
async query({ query, variables }, options) {
|
|
36
|
+
const fetchOptions = options?.noStore ? {
|
|
37
|
+
cache: "no-store"
|
|
38
|
+
} : {
|
|
39
|
+
next: {
|
|
40
|
+
revalidate: this.config.preview ? 0 : 60
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const request = {
|
|
44
|
+
...fetchOptions,
|
|
45
|
+
path: "/graphql",
|
|
46
|
+
method: "POST",
|
|
47
|
+
body: JSON.stringify({
|
|
48
|
+
query,
|
|
49
|
+
variables
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
const json = await this.fetch(request);
|
|
53
|
+
if (json.message) throw new Error(json.message);
|
|
54
|
+
if (json.errors) {
|
|
55
|
+
console.error(json.errors);
|
|
56
|
+
throw new Error("Failed to fetch API");
|
|
57
|
+
}
|
|
58
|
+
return json.data;
|
|
38
59
|
}
|
|
39
|
-
return json.data;
|
|
40
|
-
}
|
|
41
60
|
}
|
|
61
|
+
export { ApiClient };
|
|
42
62
|
|
|
43
63
|
//# sourceMappingURL=ApiClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"dataProviders/ApiClient.js","sources":["../../src/dataProviders/ApiClient.ts"],"sourcesContent":["import { resolveHeaders, type HeadersConfig } from \"@webiny/sdk\";\n\ninterface QueryParams {\n query: string;\n variables: Record<string, any>;\n}\n\nexport interface ApiClientConfig {\n apiHost: string;\n apiKey: string;\n apiTenant: string;\n /** Extra headers sent with every request; a function is called before each request. */\n headers?: HeadersConfig;\n preview?: boolean;\n}\n\ntype WithPath<T> = T & {\n path?: string;\n next?: Record<string, any>;\n};\n\n// Set by the client itself: configured extra headers can't replace them.\nconst PROTECTED_HEADERS = [\"x-tenant\", \"authorization\"];\n\nfunction headerEntries(headers: HeadersInit | undefined): [string, string][] {\n if (!headers) {\n return [];\n }\n if (headers instanceof Headers) {\n return Array.from(headers.entries());\n }\n return Array.isArray(headers) ? (headers as [string, string][]) : Object.entries(headers);\n}\n\n/**\n * The headers of several sources, a later one's value replacing an earlier one's whatever the case of the\n * name (header names are case-insensitive; `fetch` would otherwise send both values, joined).\n */\nfunction mergeHeaders(...sources: Array<HeadersInit | undefined>): Record<string, string> {\n const merged = new Map<string, [string, string]>();\n for (const source of sources) {\n for (const [name, value] of headerEntries(source)) {\n merged.set(name.toLowerCase(), [name, value]);\n }\n }\n return Object.fromEntries(merged.values());\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: mergeHeaders(\n { \"Content-Type\": \"application/json\" },\n // Under the tenant and the API key: extra headers can't replace either.\n headerEntries(await resolveHeaders(this.config.headers)).filter(\n ([name]) => !PROTECTED_HEADERS.includes(name.toLowerCase())\n ),\n {\n \"X-Tenant\": this.config.apiTenant,\n Authorization: \"Bearer \" + this.config.apiKey\n },\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":["PROTECTED_HEADERS","headerEntries","headers","Headers","Array","Object","mergeHeaders","sources","merged","Map","source","name","value","ApiClient","config","path","params","fetch","resolveHeaders","res","query","variables","options","fetchOptions","request","JSON","json","Error","console"],"mappings":";AAsBA,MAAMA,oBAAoB;IAAC;IAAY;CAAgB;AAEvD,SAASC,cAAcC,OAAgC;IACnD,IAAI,CAACA,SACD,OAAO,EAAE;IAEb,IAAIA,mBAAmBC,SACnB,OAAOC,MAAM,IAAI,CAACF,QAAQ,OAAO;IAErC,OAAOE,MAAM,OAAO,CAACF,WAAYA,UAAiCG,OAAO,OAAO,CAACH;AACrF;AAMA,SAASI,aAAa,GAAGC,OAAuC;IAC5D,MAAMC,SAAS,IAAIC;IACnB,KAAK,MAAMC,UAAUH,QACjB,KAAK,MAAM,CAACI,MAAMC,MAAM,IAAIX,cAAcS,QACtCF,OAAO,GAAG,CAACG,KAAK,WAAW,IAAI;QAACA;QAAMC;KAAM;IAGpD,OAAOP,OAAO,WAAW,CAACG,OAAO,MAAM;AAC3C;AAEO,MAAMK;IAGT,YAAYC,MAAuB,CAAE;QACjC,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,MAAM,MAAM,EAAEZ,OAAO,EAAEa,IAAI,EAAE,GAAGC,QAA+B,EAAgB;QAC3E,OAAOC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,GAAGF,MAAM,EAAE;YAC1C,QAAQ;YACR,SAAST,aACL;gBAAE,gBAAgB;YAAmB,GAErCL,cAAc,MAAMiB,eAAe,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,MAAM,CAC3D,CAAC,CAACP,KAAK,GAAK,CAACX,kBAAkB,QAAQ,CAACW,KAAK,WAAW,MAE5D;gBACI,YAAY,IAAI,CAAC,MAAM,CAAC,SAAS;gBACjC,eAAe,YAAY,IAAI,CAAC,MAAM,CAAC,MAAM;YACjD,GACAT;YAEJ,GAAGc,MAAM;QACb,GAAG,IAAI,CAACG,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { ApiClient } from "./ApiClient.js";
|
|
3
|
+
const mockFetch = ()=>{
|
|
4
|
+
const fetchMock = vi.fn().mockResolvedValue({
|
|
5
|
+
json: async ()=>({
|
|
6
|
+
data: {}
|
|
7
|
+
})
|
|
8
|
+
});
|
|
9
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
10
|
+
return fetchMock;
|
|
11
|
+
};
|
|
12
|
+
const sentHeaders = (fetchMock, call = 0)=>fetchMock.mock.calls[call][1].headers;
|
|
13
|
+
const config = {
|
|
14
|
+
apiHost: "https://api.test",
|
|
15
|
+
apiKey: "key",
|
|
16
|
+
apiTenant: "root"
|
|
17
|
+
};
|
|
18
|
+
describe("ApiClient headers", ()=>{
|
|
19
|
+
afterEach(()=>{
|
|
20
|
+
vi.unstubAllGlobals();
|
|
21
|
+
});
|
|
22
|
+
it("sends the configured headers with every request", async ()=>{
|
|
23
|
+
const fetchMock = mockFetch();
|
|
24
|
+
const client = new ApiClient({
|
|
25
|
+
...config,
|
|
26
|
+
headers: {
|
|
27
|
+
"x-extra": "a"
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
await client.query({
|
|
31
|
+
query: "{ a }",
|
|
32
|
+
variables: {}
|
|
33
|
+
});
|
|
34
|
+
await client.fetch({
|
|
35
|
+
path: "/wb/redirects"
|
|
36
|
+
});
|
|
37
|
+
expect(sentHeaders(fetchMock, 0)["x-extra"]).toBe("a");
|
|
38
|
+
expect(sentHeaders(fetchMock, 1)["x-extra"]).toBe("a");
|
|
39
|
+
});
|
|
40
|
+
it("calls a headers function before each request", async ()=>{
|
|
41
|
+
const fetchMock = mockFetch();
|
|
42
|
+
let value = "first";
|
|
43
|
+
const client = new ApiClient({
|
|
44
|
+
...config,
|
|
45
|
+
headers: async ()=>({
|
|
46
|
+
"x-extra": value
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
await client.query({
|
|
50
|
+
query: "{ a }",
|
|
51
|
+
variables: {}
|
|
52
|
+
});
|
|
53
|
+
value = "second";
|
|
54
|
+
await client.query({
|
|
55
|
+
query: "{ a }",
|
|
56
|
+
variables: {}
|
|
57
|
+
});
|
|
58
|
+
expect(sentHeaders(fetchMock, 0)["x-extra"]).toBe("first");
|
|
59
|
+
expect(sentHeaders(fetchMock, 1)["x-extra"]).toBe("second");
|
|
60
|
+
});
|
|
61
|
+
it("doesn't let extra headers replace the tenant or the API key", async ()=>{
|
|
62
|
+
const fetchMock = mockFetch();
|
|
63
|
+
const client = new ApiClient({
|
|
64
|
+
...config,
|
|
65
|
+
headers: {
|
|
66
|
+
"X-Tenant": "other",
|
|
67
|
+
Authorization: "Bearer other"
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
await client.query({
|
|
71
|
+
query: "{ a }",
|
|
72
|
+
variables: {}
|
|
73
|
+
});
|
|
74
|
+
expect(sentHeaders(fetchMock)["X-Tenant"]).toBe("root");
|
|
75
|
+
expect(sentHeaders(fetchMock).Authorization).toBe("Bearer key");
|
|
76
|
+
});
|
|
77
|
+
it("doesn't send a configured tenant or API key in another case either", async ()=>{
|
|
78
|
+
const fetchMock = mockFetch();
|
|
79
|
+
const client = new ApiClient({
|
|
80
|
+
...config,
|
|
81
|
+
headers: {
|
|
82
|
+
"x-tenant": "other",
|
|
83
|
+
authorization: "Bearer other",
|
|
84
|
+
"x-extra": "a"
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
await client.query({
|
|
88
|
+
query: "{ a }",
|
|
89
|
+
variables: {}
|
|
90
|
+
});
|
|
91
|
+
expect(sentHeaders(fetchMock)).toMatchObject({
|
|
92
|
+
"X-Tenant": "root",
|
|
93
|
+
Authorization: "Bearer key",
|
|
94
|
+
"x-extra": "a"
|
|
95
|
+
});
|
|
96
|
+
expect(sentHeaders(fetchMock)).not.toHaveProperty("x-tenant");
|
|
97
|
+
expect(sentHeaders(fetchMock)).not.toHaveProperty("authorization");
|
|
98
|
+
});
|
|
99
|
+
it("lets a configured header replace the content type, whatever the case", async ()=>{
|
|
100
|
+
const fetchMock = mockFetch();
|
|
101
|
+
const client = new ApiClient({
|
|
102
|
+
...config,
|
|
103
|
+
headers: {
|
|
104
|
+
"content-type": "application/graphql+json"
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
await client.query({
|
|
108
|
+
query: "{ a }",
|
|
109
|
+
variables: {}
|
|
110
|
+
});
|
|
111
|
+
expect(sentHeaders(fetchMock)["content-type"]).toBe("application/graphql+json");
|
|
112
|
+
expect(sentHeaders(fetchMock)).not.toHaveProperty("Content-Type");
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=ApiClient.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataProviders/ApiClient.test.js","sources":["../../src/dataProviders/ApiClient.test.ts"],"sourcesContent":["import { afterEach, describe, expect, it, vi } from \"vitest\";\nimport { ApiClient } from \"./ApiClient.js\";\n\nconst mockFetch = () => {\n const fetchMock = vi.fn().mockResolvedValue({ json: async () => ({ data: {} }) });\n vi.stubGlobal(\"fetch\", fetchMock);\n return fetchMock;\n};\n\nconst sentHeaders = (fetchMock: ReturnType<typeof mockFetch>, call = 0) => {\n return fetchMock.mock.calls[call][1].headers as Record<string, string>;\n};\n\nconst config = {\n apiHost: \"https://api.test\",\n apiKey: \"key\",\n apiTenant: \"root\"\n};\n\ndescribe(\"ApiClient headers\", () => {\n afterEach(() => {\n vi.unstubAllGlobals();\n });\n\n it(\"sends the configured headers with every request\", async () => {\n const fetchMock = mockFetch();\n const client = new ApiClient({ ...config, headers: { \"x-extra\": \"a\" } });\n\n await client.query({ query: \"{ a }\", variables: {} });\n await client.fetch({ path: \"/wb/redirects\" });\n\n expect(sentHeaders(fetchMock, 0)[\"x-extra\"]).toBe(\"a\");\n expect(sentHeaders(fetchMock, 1)[\"x-extra\"]).toBe(\"a\");\n });\n\n it(\"calls a headers function before each request\", async () => {\n const fetchMock = mockFetch();\n let value = \"first\";\n const client = new ApiClient({\n ...config,\n headers: async () => ({ \"x-extra\": value })\n });\n\n await client.query({ query: \"{ a }\", variables: {} });\n value = \"second\";\n await client.query({ query: \"{ a }\", variables: {} });\n\n expect(sentHeaders(fetchMock, 0)[\"x-extra\"]).toBe(\"first\");\n expect(sentHeaders(fetchMock, 1)[\"x-extra\"]).toBe(\"second\");\n });\n\n it(\"doesn't let extra headers replace the tenant or the API key\", async () => {\n const fetchMock = mockFetch();\n const client = new ApiClient({\n ...config,\n headers: { \"X-Tenant\": \"other\", Authorization: \"Bearer other\" }\n });\n\n await client.query({ query: \"{ a }\", variables: {} });\n\n expect(sentHeaders(fetchMock)[\"X-Tenant\"]).toBe(\"root\");\n expect(sentHeaders(fetchMock).Authorization).toBe(\"Bearer key\");\n });\n\n it(\"doesn't send a configured tenant or API key in another case either\", async () => {\n const fetchMock = mockFetch();\n const client = new ApiClient({\n ...config,\n headers: {\n \"x-tenant\": \"other\",\n authorization: \"Bearer other\",\n \"x-extra\": \"a\"\n }\n });\n\n await client.query({ query: \"{ a }\", variables: {} });\n\n expect(sentHeaders(fetchMock)).toMatchObject({\n \"X-Tenant\": \"root\",\n Authorization: \"Bearer key\",\n \"x-extra\": \"a\"\n });\n expect(sentHeaders(fetchMock)).not.toHaveProperty(\"x-tenant\");\n expect(sentHeaders(fetchMock)).not.toHaveProperty(\"authorization\");\n });\n\n it(\"lets a configured header replace the content type, whatever the case\", async () => {\n const fetchMock = mockFetch();\n const client = new ApiClient({\n ...config,\n headers: { \"content-type\": \"application/graphql+json\" }\n });\n\n await client.query({ query: \"{ a }\", variables: {} });\n\n expect(sentHeaders(fetchMock)[\"content-type\"]).toBe(\"application/graphql+json\");\n expect(sentHeaders(fetchMock)).not.toHaveProperty(\"Content-Type\");\n });\n});\n"],"names":["mockFetch","fetchMock","vi","sentHeaders","call","config","describe","afterEach","it","client","ApiClient","expect","value"],"mappings":";;AAGA,MAAMA,YAAY;IACd,MAAMC,YAAYC,GAAG,EAAE,GAAG,iBAAiB,CAAC;QAAE,MAAM,UAAa;gBAAE,MAAM,CAAC;YAAE;IAAG;IAC/EA,GAAG,UAAU,CAAC,SAASD;IACvB,OAAOA;AACX;AAEA,MAAME,cAAc,CAACF,WAAyCG,OAAO,CAAC,GAC3DH,UAAU,IAAI,CAAC,KAAK,CAACG,KAAK,CAAC,EAAE,CAAC,OAAO;AAGhD,MAAMC,SAAS;IACX,SAAS;IACT,QAAQ;IACR,WAAW;AACf;AAEAC,SAAS,qBAAqB;IAC1BC,UAAU;QACNL,GAAG,gBAAgB;IACvB;IAEAM,GAAG,mDAAmD;QAClD,MAAMP,YAAYD;QAClB,MAAMS,SAAS,IAAIC,UAAU;YAAE,GAAGL,MAAM;YAAE,SAAS;gBAAE,WAAW;YAAI;QAAE;QAEtE,MAAMI,OAAO,KAAK,CAAC;YAAE,OAAO;YAAS,WAAW,CAAC;QAAE;QACnD,MAAMA,OAAO,KAAK,CAAC;YAAE,MAAM;QAAgB;QAE3CE,OAAOR,YAAYF,WAAW,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;QAClDU,OAAOR,YAAYF,WAAW,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;IACtD;IAEAO,GAAG,gDAAgD;QAC/C,MAAMP,YAAYD;QAClB,IAAIY,QAAQ;QACZ,MAAMH,SAAS,IAAIC,UAAU;YACzB,GAAGL,MAAM;YACT,SAAS,UAAa;oBAAE,WAAWO;gBAAM;QAC7C;QAEA,MAAMH,OAAO,KAAK,CAAC;YAAE,OAAO;YAAS,WAAW,CAAC;QAAE;QACnDG,QAAQ;QACR,MAAMH,OAAO,KAAK,CAAC;YAAE,OAAO;YAAS,WAAW,CAAC;QAAE;QAEnDE,OAAOR,YAAYF,WAAW,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;QAClDU,OAAOR,YAAYF,WAAW,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;IACtD;IAEAO,GAAG,+DAA+D;QAC9D,MAAMP,YAAYD;QAClB,MAAMS,SAAS,IAAIC,UAAU;YACzB,GAAGL,MAAM;YACT,SAAS;gBAAE,YAAY;gBAAS,eAAe;YAAe;QAClE;QAEA,MAAMI,OAAO,KAAK,CAAC;YAAE,OAAO;YAAS,WAAW,CAAC;QAAE;QAEnDE,OAAOR,YAAYF,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC;QAChDU,OAAOR,YAAYF,WAAW,aAAa,EAAE,IAAI,CAAC;IACtD;IAEAO,GAAG,sEAAsE;QACrE,MAAMP,YAAYD;QAClB,MAAMS,SAAS,IAAIC,UAAU;YACzB,GAAGL,MAAM;YACT,SAAS;gBACL,YAAY;gBACZ,eAAe;gBACf,WAAW;YACf;QACJ;QAEA,MAAMI,OAAO,KAAK,CAAC;YAAE,OAAO;YAAS,WAAW,CAAC;QAAE;QAEnDE,OAAOR,YAAYF,YAAY,aAAa,CAAC;YACzC,YAAY;YACZ,eAAe;YACf,WAAW;QACf;QACAU,OAAOR,YAAYF,YAAY,GAAG,CAAC,cAAc,CAAC;QAClDU,OAAOR,YAAYF,YAAY,GAAG,CAAC,cAAc,CAAC;IACtD;IAEAO,GAAG,wEAAwE;QACvE,MAAMP,YAAYD;QAClB,MAAMS,SAAS,IAAIC,UAAU;YACzB,GAAGL,MAAM;YACT,SAAS;gBAAE,gBAAgB;YAA2B;QAC1D;QAEA,MAAMI,OAAO,KAAK,CAAC;YAAE,OAAO;YAAS,WAAW,CAAC;QAAE;QAEnDE,OAAOR,YAAYF,UAAU,CAAC,eAAe,EAAE,IAAI,CAAC;QACpDU,OAAOR,YAAYF,YAAY,GAAG,CAAC,cAAc,CAAC;IACtD;AACJ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { IDataProvider, PublicPage } from "../types.js";
|
|
2
|
-
import type {
|
|
1
|
+
import type { GetLayoutParams, IDataProvider, ListPagesOptions, ListPagesResult, PublicLayout, 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,6 +9,11 @@ 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
|
-
|
|
12
|
+
getLayoutBySlug(params: GetLayoutParams): Promise<PublicLayout | null>;
|
|
13
|
+
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
14
|
+
getPageExperiment(path: string): Promise<ActiveExperiment | null>;
|
|
15
|
+
getVariantContent(variantId: string): Promise<VariantContent | null>;
|
|
16
|
+
getExperimentPaused(experimentId: string): Promise<boolean>;
|
|
17
|
+
private checkForErrors;
|
|
12
18
|
}
|
|
13
19
|
export {};
|