@embeddable.com/sdk-react 3.11.4 → 3.11.5-next.1
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/lib/index.esm.js +75 -0
- package/lib/index.esm.js.map +1 -1
- package/lib/validate/schema/componentMetaSchema.d.ts +90 -2
- package/lib/validate/schema/componentMetaSchema.test.d.ts +1 -0
- package/package.json +2 -2
- package/lib/dynamicImportHandler.js +0 -14
- package/lib/index.js +0 -1215
- package/lib/index.js.map +0 -1
- package/lib/plugin.d.ts +0 -21
- package/lib/proxyHandler.d.ts +0 -4
- package/lib/utils/modules.d.ts +0 -13
- package/lib/validate/errorFormatter.d.ts +0 -3
package/lib/index.esm.js
CHANGED
|
@@ -704,6 +704,41 @@ const componentMetaSchema = z
|
|
|
704
704
|
type: embeddableInputTypeSchema,
|
|
705
705
|
required: z.boolean().optional(),
|
|
706
706
|
supportedTypes: embeddableInputSupportedTypesSchema,
|
|
707
|
+
})
|
|
708
|
+
.superRefine((subInput, ctx) => {
|
|
709
|
+
if (subInput.name === "granularity") {
|
|
710
|
+
if (!subInput.supportedTypes ||
|
|
711
|
+
JSON.stringify(subInput.supportedTypes) !==
|
|
712
|
+
JSON.stringify(["time"])) {
|
|
713
|
+
ctx.addIssue({
|
|
714
|
+
code: z.ZodIssueCode.custom,
|
|
715
|
+
message: `A 'granularity' sub-input must have 'supportedTypes' of ['time'].`,
|
|
716
|
+
path: ["supportedTypes"],
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
if (subInput.type !== "granularity") {
|
|
720
|
+
ctx.addIssue({
|
|
721
|
+
code: z.ZodIssueCode.custom,
|
|
722
|
+
message: `A 'granularity' sub-input must have a 'type' of 'granularity'.`,
|
|
723
|
+
path: ["type"],
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
const allowedKeys = [
|
|
727
|
+
"name",
|
|
728
|
+
"type",
|
|
729
|
+
"label",
|
|
730
|
+
"defaultValue",
|
|
731
|
+
"supportedTypes",
|
|
732
|
+
];
|
|
733
|
+
const extraKeys = Object.keys(subInput).filter((key) => !allowedKeys.includes(key));
|
|
734
|
+
if (extraKeys.length > 0) {
|
|
735
|
+
ctx.addIssue({
|
|
736
|
+
code: z.ZodIssueCode.custom,
|
|
737
|
+
message: `The 'granularity' sub-input has forbidden properties: ${extraKeys.join(", ")}. Only 'label' and 'defaultValue' are allowed.`,
|
|
738
|
+
path: [extraKeys[0]],
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
}
|
|
707
742
|
})
|
|
708
743
|
.array()
|
|
709
744
|
.superRefine((inputs, ctx) => uniqueNameRefinement(inputs, ctx, "SubInput names must be unique."))
|
|
@@ -712,6 +747,46 @@ const componentMetaSchema = z
|
|
|
712
747
|
.strict()
|
|
713
748
|
.array()
|
|
714
749
|
.superRefine((inputs, ctx) => uniqueNameRefinement(inputs, ctx, "Input names must be unique."))
|
|
750
|
+
.superRefine((inputs, ctx) => {
|
|
751
|
+
for (const input of inputs) {
|
|
752
|
+
if (input.type === "dimension" && input.inputs) {
|
|
753
|
+
const granularityInput = input.inputs.find((sub) => sub.name === "granularity");
|
|
754
|
+
if (granularityInput) {
|
|
755
|
+
if (!granularityInput.supportedTypes ||
|
|
756
|
+
JSON.stringify(granularityInput.supportedTypes) !==
|
|
757
|
+
JSON.stringify(["time"])) {
|
|
758
|
+
ctx.addIssue({
|
|
759
|
+
code: z.ZodIssueCode.custom,
|
|
760
|
+
message: `Input '${input.name}': a 'granularity' sub-input must have 'supportedTypes' of ['time'].`,
|
|
761
|
+
path: [input.name, "inputs", "granularity", "supportedTypes"],
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
if (granularityInput.type !== "granularity") {
|
|
765
|
+
ctx.addIssue({
|
|
766
|
+
code: z.ZodIssueCode.custom,
|
|
767
|
+
message: `Input '${input.name}': the 'granularity' sub-input must have a 'type' of 'granularity'.`,
|
|
768
|
+
path: [input.name, "inputs", "granularity", "type"],
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
const allowedKeys = [
|
|
772
|
+
"name",
|
|
773
|
+
"type",
|
|
774
|
+
"label",
|
|
775
|
+
"defaultValue",
|
|
776
|
+
"supportedTypes",
|
|
777
|
+
];
|
|
778
|
+
const extraKeys = Object.keys(granularityInput).filter((key) => !allowedKeys.includes(key));
|
|
779
|
+
if (extraKeys.length > 0) {
|
|
780
|
+
ctx.addIssue({
|
|
781
|
+
code: z.ZodIssueCode.custom,
|
|
782
|
+
message: `Input '${input.name}': the 'granularity' sub-input has forbidden overrides: ${extraKeys.join(", ")}. Only 'label' and 'defaultValue' are allowed.`,
|
|
783
|
+
path: [input.name, "inputs", "granularity"],
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
})
|
|
715
790
|
.optional(),
|
|
716
791
|
events: z
|
|
717
792
|
.object({
|