@embeddable.com/sdk-core 2.4.18 → 2.4.19
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 +36 -7
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +36 -7
- package/lib/index.js.map +1 -1
- package/lib/push.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -4522,6 +4522,7 @@ var z = /*#__PURE__*/Object.freeze({
|
|
|
4522
4522
|
});
|
|
4523
4523
|
|
|
4524
4524
|
const CUBE_YAML_FILE_REGEX = /^(.*)\.cube\.ya?ml$/;
|
|
4525
|
+
const SECURITY_CONTEXT_FILE_REGEX = /^(.*)\.sc\.ya?ml$/;
|
|
4525
4526
|
const checkNodeVersion$1 = () => {
|
|
4526
4527
|
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
4527
4528
|
const engines = require("../package.json").engines.node;
|
|
@@ -4535,6 +4536,7 @@ var validate = async (ctx, exitIfInvalid = true) => {
|
|
|
4535
4536
|
const ora = (await import('ora')).default;
|
|
4536
4537
|
const spinnerValidate = ora("data model validation...").start();
|
|
4537
4538
|
const filesList = await findFiles(ctx.client.srcDir, CUBE_YAML_FILE_REGEX);
|
|
4539
|
+
const securityContextFilesList = await findFiles(ctx.client.srcDir, SECURITY_CONTEXT_FILE_REGEX);
|
|
4538
4540
|
const dataModelErrors = await dataModelsValidation(filesList);
|
|
4539
4541
|
if (dataModelErrors.length) {
|
|
4540
4542
|
spinnerValidate.fail("One or more cube.yaml files are invalid:");
|
|
@@ -4544,7 +4546,15 @@ var validate = async (ctx, exitIfInvalid = true) => {
|
|
|
4544
4546
|
}
|
|
4545
4547
|
}
|
|
4546
4548
|
spinnerValidate.succeed("data model validation completed");
|
|
4547
|
-
|
|
4549
|
+
const securityContextErrors = await securityContextValidation(securityContextFilesList);
|
|
4550
|
+
if (securityContextErrors.length) {
|
|
4551
|
+
spinnerValidate.fail("One or more security context files are invalid:");
|
|
4552
|
+
securityContextErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
|
|
4553
|
+
if (exitIfInvalid) {
|
|
4554
|
+
process.exit(1);
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
return dataModelErrors.length === 0 && securityContextErrors.length === 0;
|
|
4548
4558
|
};
|
|
4549
4559
|
async function dataModelsValidation(filesList) {
|
|
4550
4560
|
const errors = [];
|
|
@@ -4560,6 +4570,20 @@ async function dataModelsValidation(filesList) {
|
|
|
4560
4570
|
}
|
|
4561
4571
|
return errors;
|
|
4562
4572
|
}
|
|
4573
|
+
async function securityContextValidation(filesList) {
|
|
4574
|
+
const errors = [];
|
|
4575
|
+
for (const [_, filePath] of filesList) {
|
|
4576
|
+
const fileContentRaw = await fs__namespace.readFile(filePath, "utf8");
|
|
4577
|
+
const cube = YAML__namespace.parse(fileContentRaw);
|
|
4578
|
+
const safeParse = securityContextSchema.safeParse(cube);
|
|
4579
|
+
if (!safeParse.success) {
|
|
4580
|
+
errorFormatter(safeParse.error.issues).forEach((error) => {
|
|
4581
|
+
errors.push(`${filePath}: ${error}`);
|
|
4582
|
+
});
|
|
4583
|
+
}
|
|
4584
|
+
}
|
|
4585
|
+
return errors;
|
|
4586
|
+
}
|
|
4563
4587
|
const cubeModelSchema = z
|
|
4564
4588
|
.object({
|
|
4565
4589
|
cubes: z
|
|
@@ -4587,6 +4611,10 @@ const cubeModelSchema = z
|
|
|
4587
4611
|
message: "At least one measure or dimension must be defined",
|
|
4588
4612
|
path: ["cubes"],
|
|
4589
4613
|
});
|
|
4614
|
+
const securityContextSchema = z.array(z.object({
|
|
4615
|
+
name: z.string(),
|
|
4616
|
+
securityContext: z.object({}), // can be any object
|
|
4617
|
+
}));
|
|
4590
4618
|
|
|
4591
4619
|
var provideConfig = async () => {
|
|
4592
4620
|
const configFilePath = `${process.cwd()}/embeddable.config.js`;
|
|
@@ -20037,7 +20065,8 @@ async function resolveFiles() {
|
|
|
20037
20065
|
|
|
20038
20066
|
const oraP$1 = import('ora');
|
|
20039
20067
|
const inquirerSelect = import('@inquirer/select');
|
|
20040
|
-
|
|
20068
|
+
// grab .cube.yml|js and .sc.yml|js files
|
|
20069
|
+
const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
|
|
20041
20070
|
let ora$1;
|
|
20042
20071
|
var push = async () => {
|
|
20043
20072
|
try {
|
|
@@ -20047,7 +20076,7 @@ var push = async () => {
|
|
|
20047
20076
|
const token = await verify(config);
|
|
20048
20077
|
const { workspaceId, name: workspaceName } = await selectWorkspace(config, token);
|
|
20049
20078
|
const spinnerArchive = ora$1("archivation...").start();
|
|
20050
|
-
const filesList = await findFiles(config.client.srcDir,
|
|
20079
|
+
const filesList = await findFiles(config.client.srcDir, YAML_OR_JS_FILES);
|
|
20051
20080
|
await archive(config, filesList);
|
|
20052
20081
|
spinnerArchive.succeed("archivation competed");
|
|
20053
20082
|
const spinnerPushing = ora$1(`publishing to ${workspaceName} using ${config.pushBaseUrl}...`).start();
|
|
@@ -20115,9 +20144,9 @@ async function archive(ctx, yamlFiles, includeBuild = true) {
|
|
|
20115
20144
|
_archiver.directory(ctx.client.buildDir, false);
|
|
20116
20145
|
}
|
|
20117
20146
|
for (const fileData of yamlFiles) {
|
|
20118
|
-
const
|
|
20147
|
+
const fileName = fileData[1].split("/").pop();
|
|
20119
20148
|
_archiver.file(fileData[1], {
|
|
20120
|
-
name:
|
|
20149
|
+
name: fileName,
|
|
20121
20150
|
});
|
|
20122
20151
|
}
|
|
20123
20152
|
await _archiver.finalize();
|
|
@@ -20263,7 +20292,7 @@ const onBundleBuildEnd = async (ctx) => {
|
|
|
20263
20292
|
}
|
|
20264
20293
|
};
|
|
20265
20294
|
const dataModelWatcher = (ctx) => {
|
|
20266
|
-
const fsWatcher = chokidar__namespace.watch([path__namespace$1.resolve(ctx.client.srcDir, "**/*.cube.{yaml,yml}")], {
|
|
20295
|
+
const fsWatcher = chokidar__namespace.watch([path__namespace$1.resolve(ctx.client.srcDir, "**/*.cube.{yaml,yml,js}")], {
|
|
20267
20296
|
ignoreInitial: true,
|
|
20268
20297
|
});
|
|
20269
20298
|
fsWatcher.on("all", async () => {
|
|
@@ -20277,7 +20306,7 @@ const sendDataModels = async (ctx) => {
|
|
|
20277
20306
|
if (isValid) {
|
|
20278
20307
|
const token = await getToken();
|
|
20279
20308
|
const sending = ora("synchronising data models...").start();
|
|
20280
|
-
const filesList = await findFiles(ctx.client.srcDir,
|
|
20309
|
+
const filesList = await findFiles(ctx.client.srcDir, YAML_OR_JS_FILES);
|
|
20281
20310
|
await archive(ctx, filesList, false);
|
|
20282
20311
|
await sendBuild(ctx, { workspaceId: previewWorkspace, token });
|
|
20283
20312
|
sending.succeed(`data models synchronized`);
|