@embeddable.com/sdk-core 3.9.4 → 3.9.5
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/defineConfig.d.ts +3 -1
- package/lib/index.esm.js +69 -15
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +69 -15
- package/lib/index.js.map +1 -1
- package/lib/push.d.ts +2 -1
- package/lib/validate.d.ts +1 -0
- package/package.json +1 -1
- package/src/defineConfig.test.ts +2 -0
- package/src/defineConfig.ts +11 -0
- package/src/dev.test.ts +1 -0
- package/src/dev.ts +15 -6
- package/src/push.ts +13 -5
- package/src/validate.test.ts +36 -1
- package/src/validate.ts +69 -4
- package/templates/component.tsx.template +4 -1
package/lib/defineConfig.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type EmbeddableConfig = {
|
|
|
16
16
|
previewBaseUrl?: string;
|
|
17
17
|
componentsSrc?: string;
|
|
18
18
|
modelsSrc?: string;
|
|
19
|
+
presetsSrc?: string;
|
|
19
20
|
globalCss?: string;
|
|
20
21
|
viteConfig?: {
|
|
21
22
|
resolve?: {
|
|
@@ -24,7 +25,7 @@ export type EmbeddableConfig = {
|
|
|
24
25
|
};
|
|
25
26
|
rollupOptions?: RollupOptions;
|
|
26
27
|
};
|
|
27
|
-
declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc, componentsSrc, globalCss, viteConfig, rollupOptions, }: EmbeddableConfig) => {
|
|
28
|
+
declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc, presetsSrc, componentsSrc, globalCss, viteConfig, rollupOptions, }: EmbeddableConfig) => {
|
|
28
29
|
core: {
|
|
29
30
|
rootDir: string;
|
|
30
31
|
templatesDir: string;
|
|
@@ -34,6 +35,7 @@ declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authCl
|
|
|
34
35
|
rootDir: string;
|
|
35
36
|
srcDir: string;
|
|
36
37
|
modelsSrc: string | undefined;
|
|
38
|
+
presetsSrc: string | undefined;
|
|
37
39
|
buildDir: string;
|
|
38
40
|
tmpDir: string;
|
|
39
41
|
globalCss: string;
|
package/lib/index.esm.js
CHANGED
|
@@ -4989,13 +4989,15 @@ var z = /*#__PURE__*/Object.freeze({
|
|
|
4989
4989
|
|
|
4990
4990
|
const CUBE_YAML_FILE_REGEX = /^(.*)\.cube\.ya?ml$/;
|
|
4991
4991
|
const SECURITY_CONTEXT_FILE_REGEX = /^(.*)\.sc\.ya?ml$/;
|
|
4992
|
+
const CLIENT_CONTEXT_FILE_REGEX = /^(.*)\.cc\.ya?ml$/;
|
|
4992
4993
|
var validate = async (ctx, exitIfInvalid = true) => {
|
|
4993
4994
|
checkNodeVersion();
|
|
4994
4995
|
const ora = (await import('ora')).default;
|
|
4995
4996
|
const spinnerValidate = ora("Data model validation...").start();
|
|
4996
|
-
const
|
|
4997
|
-
const securityContextFilesList = await findFiles(ctx.client.
|
|
4998
|
-
const
|
|
4997
|
+
const cubeFilesList = await findFiles(ctx.client.modelsSrc || ctx.client.srcDir, CUBE_YAML_FILE_REGEX);
|
|
4998
|
+
const securityContextFilesList = await findFiles(ctx.client.presetsSrc || ctx.client.srcDir, SECURITY_CONTEXT_FILE_REGEX);
|
|
4999
|
+
const clientContextFilesList = await findFiles(ctx.client.presetsSrc || ctx.client.srcDir, CLIENT_CONTEXT_FILE_REGEX);
|
|
5000
|
+
const dataModelErrors = await dataModelsValidation(cubeFilesList);
|
|
4999
5001
|
if (dataModelErrors.length) {
|
|
5000
5002
|
spinnerValidate.fail("One or more cube.yaml files are invalid:");
|
|
5001
5003
|
dataModelErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
|
|
@@ -5005,6 +5007,7 @@ var validate = async (ctx, exitIfInvalid = true) => {
|
|
|
5005
5007
|
}
|
|
5006
5008
|
spinnerValidate.succeed("Data model validation completed");
|
|
5007
5009
|
const securityContextErrors = await securityContextValidation(securityContextFilesList);
|
|
5010
|
+
const clientContextErrors = await clientContextValidation(clientContextFilesList);
|
|
5008
5011
|
if (securityContextErrors.length) {
|
|
5009
5012
|
spinnerValidate.fail("One or more security context files are invalid:");
|
|
5010
5013
|
securityContextErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
|
|
@@ -5012,7 +5015,16 @@ var validate = async (ctx, exitIfInvalid = true) => {
|
|
|
5012
5015
|
process.exit(1);
|
|
5013
5016
|
}
|
|
5014
5017
|
}
|
|
5015
|
-
|
|
5018
|
+
if (clientContextErrors.length) {
|
|
5019
|
+
spinnerValidate.fail("One or more client context files are invalid:");
|
|
5020
|
+
clientContextErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
|
|
5021
|
+
if (exitIfInvalid) {
|
|
5022
|
+
process.exit(1);
|
|
5023
|
+
}
|
|
5024
|
+
}
|
|
5025
|
+
return (dataModelErrors.length === 0 &&
|
|
5026
|
+
securityContextErrors.length === 0 &&
|
|
5027
|
+
clientContextErrors.length === 0);
|
|
5016
5028
|
};
|
|
5017
5029
|
async function dataModelsValidation(filesList) {
|
|
5018
5030
|
const errors = [];
|
|
@@ -5065,6 +5077,29 @@ async function securityContextValidation(filesList) {
|
|
|
5065
5077
|
}
|
|
5066
5078
|
return errors;
|
|
5067
5079
|
}
|
|
5080
|
+
async function clientContextValidation(filesList) {
|
|
5081
|
+
const errors = [];
|
|
5082
|
+
const nameSet = new Set();
|
|
5083
|
+
for (const [_, filePath] of filesList) {
|
|
5084
|
+
const fileContentRaw = await fs.readFile(filePath, "utf8");
|
|
5085
|
+
const cube = YAML.parse(fileContentRaw);
|
|
5086
|
+
cube.forEach((item) => {
|
|
5087
|
+
if (nameSet.has(item.name)) {
|
|
5088
|
+
errors.push(`${filePath}: client context with name "${item.name}" already exists`);
|
|
5089
|
+
}
|
|
5090
|
+
else {
|
|
5091
|
+
nameSet.add(item.name);
|
|
5092
|
+
}
|
|
5093
|
+
});
|
|
5094
|
+
const safeParse = clientContextSchema.safeParse(cube);
|
|
5095
|
+
if (!safeParse.success) {
|
|
5096
|
+
errorFormatter(safeParse.error.issues).forEach((error) => {
|
|
5097
|
+
errors.push(`${filePath}: ${error}`);
|
|
5098
|
+
});
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
return errors;
|
|
5102
|
+
}
|
|
5068
5103
|
var MeasureTypeEnum;
|
|
5069
5104
|
(function (MeasureTypeEnum) {
|
|
5070
5105
|
MeasureTypeEnum["string"] = "string";
|
|
@@ -5131,6 +5166,10 @@ const securityContextSchema = z.array(z.object({
|
|
|
5131
5166
|
name: z.string(),
|
|
5132
5167
|
securityContext: z.object({}), // can be any object
|
|
5133
5168
|
}));
|
|
5169
|
+
const clientContextSchema = z.array(z.object({
|
|
5170
|
+
name: z.string(),
|
|
5171
|
+
clientContext: z.object({}), // can be any object
|
|
5172
|
+
}));
|
|
5134
5173
|
|
|
5135
5174
|
var provideConfig = async () => {
|
|
5136
5175
|
const configFilePath = `${process.cwd()}/embeddable.config.js`;
|
|
@@ -21473,8 +21512,10 @@ async function selectWorkspace(ora, ctx, token) {
|
|
|
21473
21512
|
}
|
|
21474
21513
|
|
|
21475
21514
|
const oraP$1 = import('ora');
|
|
21476
|
-
// grab
|
|
21477
|
-
const
|
|
21515
|
+
// grab cube files
|
|
21516
|
+
const CUBE_FILES = /^(.*)\.cube\.(ya?ml|js)$/;
|
|
21517
|
+
// grab security context and client context files
|
|
21518
|
+
const PRESET_FILES = /^(.*)\.(sc|cc)\.ya?ml$/;
|
|
21478
21519
|
let ora$1;
|
|
21479
21520
|
var push = async () => {
|
|
21480
21521
|
await initLogger("push");
|
|
@@ -21557,8 +21598,9 @@ async function verify(ctx) {
|
|
|
21557
21598
|
}
|
|
21558
21599
|
async function buildArchive(config) {
|
|
21559
21600
|
const spinnerArchive = ora$1("Building...").start();
|
|
21560
|
-
const
|
|
21561
|
-
await
|
|
21601
|
+
const cubeFilesList = await findFiles(config.client.modelsSrc || config.client.srcDir, CUBE_FILES);
|
|
21602
|
+
const contextFilesList = await findFiles(config.client.presetsSrc || config.client.srcDir, PRESET_FILES);
|
|
21603
|
+
await archive(config, [...cubeFilesList, ...contextFilesList]);
|
|
21562
21604
|
return spinnerArchive.succeed("Bundling completed");
|
|
21563
21605
|
}
|
|
21564
21606
|
async function archive(ctx, yamlFiles, isDev = false) {
|
|
@@ -21737,7 +21779,7 @@ var dev = async () => {
|
|
|
21737
21779
|
metaFileName: "embeddable-components-meta.js",
|
|
21738
21780
|
editorsMetaFileName: "embeddable-editors-meta.js",
|
|
21739
21781
|
});
|
|
21740
|
-
await
|
|
21782
|
+
await sendDataModelsAndContextsChanges(config);
|
|
21741
21783
|
for (const getPlugin of config.plugins) {
|
|
21742
21784
|
const plugin = getPlugin();
|
|
21743
21785
|
breadcrumbs.push("validate plugin");
|
|
@@ -21806,9 +21848,12 @@ const onBundleBuildEnd = async (ctx) => {
|
|
|
21806
21848
|
}
|
|
21807
21849
|
};
|
|
21808
21850
|
const dataModelAndSecurityContextWatcher = (ctx) => {
|
|
21809
|
-
const fsWatcher = chokidar.watch([
|
|
21851
|
+
const fsWatcher = chokidar.watch([
|
|
21852
|
+
path$1.resolve(ctx.client.modelsSrc, "**/*.{cube}.{yaml,yml,js}"),
|
|
21853
|
+
path$1.resolve(ctx.client.presetsSrc, "**/*.{sc,cc}.{yaml,yml}"),
|
|
21854
|
+
], chokidarWatchOptions);
|
|
21810
21855
|
fsWatcher.on("all", async () => {
|
|
21811
|
-
await
|
|
21856
|
+
await sendDataModelsAndContextsChanges(ctx);
|
|
21812
21857
|
});
|
|
21813
21858
|
return fsWatcher;
|
|
21814
21859
|
};
|
|
@@ -21819,13 +21864,15 @@ const globalCssWatcher = (ctx) => {
|
|
|
21819
21864
|
});
|
|
21820
21865
|
return fsWatcher;
|
|
21821
21866
|
};
|
|
21822
|
-
const
|
|
21867
|
+
const sendDataModelsAndContextsChanges = async (ctx) => {
|
|
21823
21868
|
sendMessage("dataModelsAndOrSecurityContextUpdateStart");
|
|
21824
21869
|
const isValid = await validate(ctx, false);
|
|
21825
21870
|
if (isValid) {
|
|
21826
21871
|
const token = await getToken();
|
|
21827
21872
|
const sending = ora("Synchronising data models and/or security contexts...").start();
|
|
21828
|
-
const
|
|
21873
|
+
const cubeFilesList = await findFiles(ctx.client.modelsSrc, CUBE_FILES);
|
|
21874
|
+
const contextFilesList = await findFiles(ctx.client.presetsSrc, PRESET_FILES);
|
|
21875
|
+
const filesList = [...cubeFilesList, ...contextFilesList];
|
|
21829
21876
|
// add manifest to the archive
|
|
21830
21877
|
filesList.push([
|
|
21831
21878
|
"embeddable-manifest",
|
|
@@ -21888,7 +21935,7 @@ const getPreviewWorkspace = async (startedOra, ctx) => {
|
|
|
21888
21935
|
}
|
|
21889
21936
|
};
|
|
21890
21937
|
|
|
21891
|
-
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, }) => {
|
|
21938
|
+
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", presetsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, }) => {
|
|
21892
21939
|
const coreRoot = path.resolve(__dirname, "..");
|
|
21893
21940
|
const clientRoot = process.cwd();
|
|
21894
21941
|
if (!path.isAbsolute(componentsSrc)) {
|
|
@@ -21903,6 +21950,12 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21903
21950
|
throw new Error(`modelsSrc directory ${modelsSrc} does not exist`);
|
|
21904
21951
|
}
|
|
21905
21952
|
}
|
|
21953
|
+
if (presetsSrc && !path.isAbsolute(presetsSrc)) {
|
|
21954
|
+
presetsSrc = path.resolve(clientRoot, presetsSrc);
|
|
21955
|
+
if (!existsSync(presetsSrc)) {
|
|
21956
|
+
throw new Error(`presetsSrc directory ${presetsSrc} does not exist`);
|
|
21957
|
+
}
|
|
21958
|
+
}
|
|
21906
21959
|
return {
|
|
21907
21960
|
core: {
|
|
21908
21961
|
rootDir: coreRoot,
|
|
@@ -21913,6 +21966,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21913
21966
|
rootDir: clientRoot,
|
|
21914
21967
|
srcDir: path.resolve(clientRoot, componentsSrc),
|
|
21915
21968
|
modelsSrc: modelsSrc ? path.resolve(clientRoot, modelsSrc) : undefined,
|
|
21969
|
+
presetsSrc: presetsSrc ? path.resolve(clientRoot, presetsSrc) : undefined,
|
|
21916
21970
|
buildDir: path.resolve(clientRoot, ".embeddable-build"),
|
|
21917
21971
|
tmpDir: path.resolve(clientRoot, ".embeddable-tmp"),
|
|
21918
21972
|
globalCss: path.resolve(clientRoot, globalCss),
|
|
@@ -21941,7 +21995,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21941
21995
|
};
|
|
21942
21996
|
|
|
21943
21997
|
var name = "@embeddable.com/sdk-core";
|
|
21944
|
-
var version = "3.9.
|
|
21998
|
+
var version = "3.9.5";
|
|
21945
21999
|
var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
|
|
21946
22000
|
var keywords = [
|
|
21947
22001
|
"embeddable",
|