@embeddable.com/sdk-core 3.9.4 → 3.9.6
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/index.js
CHANGED
|
@@ -5017,13 +5017,15 @@ var z = /*#__PURE__*/Object.freeze({
|
|
|
5017
5017
|
|
|
5018
5018
|
const CUBE_YAML_FILE_REGEX = /^(.*)\.cube\.ya?ml$/;
|
|
5019
5019
|
const SECURITY_CONTEXT_FILE_REGEX = /^(.*)\.sc\.ya?ml$/;
|
|
5020
|
+
const CLIENT_CONTEXT_FILE_REGEX = /^(.*)\.cc\.ya?ml$/;
|
|
5020
5021
|
var validate = async (ctx, exitIfInvalid = true) => {
|
|
5021
5022
|
checkNodeVersion();
|
|
5022
5023
|
const ora = (await import('ora')).default;
|
|
5023
5024
|
const spinnerValidate = ora("Data model validation...").start();
|
|
5024
|
-
const
|
|
5025
|
-
const securityContextFilesList = await findFiles(ctx.client.
|
|
5026
|
-
const
|
|
5025
|
+
const cubeFilesList = await findFiles(ctx.client.modelsSrc || ctx.client.srcDir, CUBE_YAML_FILE_REGEX);
|
|
5026
|
+
const securityContextFilesList = await findFiles(ctx.client.presetsSrc || ctx.client.srcDir, SECURITY_CONTEXT_FILE_REGEX);
|
|
5027
|
+
const clientContextFilesList = await findFiles(ctx.client.presetsSrc || ctx.client.srcDir, CLIENT_CONTEXT_FILE_REGEX);
|
|
5028
|
+
const dataModelErrors = await dataModelsValidation(cubeFilesList);
|
|
5027
5029
|
if (dataModelErrors.length) {
|
|
5028
5030
|
spinnerValidate.fail("One or more cube.yaml files are invalid:");
|
|
5029
5031
|
dataModelErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
|
|
@@ -5033,6 +5035,7 @@ var validate = async (ctx, exitIfInvalid = true) => {
|
|
|
5033
5035
|
}
|
|
5034
5036
|
spinnerValidate.succeed("Data model validation completed");
|
|
5035
5037
|
const securityContextErrors = await securityContextValidation(securityContextFilesList);
|
|
5038
|
+
const clientContextErrors = await clientContextValidation(clientContextFilesList);
|
|
5036
5039
|
if (securityContextErrors.length) {
|
|
5037
5040
|
spinnerValidate.fail("One or more security context files are invalid:");
|
|
5038
5041
|
securityContextErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
|
|
@@ -5040,7 +5043,16 @@ var validate = async (ctx, exitIfInvalid = true) => {
|
|
|
5040
5043
|
process.exit(1);
|
|
5041
5044
|
}
|
|
5042
5045
|
}
|
|
5043
|
-
|
|
5046
|
+
if (clientContextErrors.length) {
|
|
5047
|
+
spinnerValidate.fail("One or more client context files are invalid:");
|
|
5048
|
+
clientContextErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
|
|
5049
|
+
if (exitIfInvalid) {
|
|
5050
|
+
process.exit(1);
|
|
5051
|
+
}
|
|
5052
|
+
}
|
|
5053
|
+
return (dataModelErrors.length === 0 &&
|
|
5054
|
+
securityContextErrors.length === 0 &&
|
|
5055
|
+
clientContextErrors.length === 0);
|
|
5044
5056
|
};
|
|
5045
5057
|
async function dataModelsValidation(filesList) {
|
|
5046
5058
|
const errors = [];
|
|
@@ -5093,6 +5105,29 @@ async function securityContextValidation(filesList) {
|
|
|
5093
5105
|
}
|
|
5094
5106
|
return errors;
|
|
5095
5107
|
}
|
|
5108
|
+
async function clientContextValidation(filesList) {
|
|
5109
|
+
const errors = [];
|
|
5110
|
+
const nameSet = new Set();
|
|
5111
|
+
for (const [_, filePath] of filesList) {
|
|
5112
|
+
const fileContentRaw = await fs__namespace.readFile(filePath, "utf8");
|
|
5113
|
+
const cube = YAML__namespace.parse(fileContentRaw);
|
|
5114
|
+
cube.forEach((item) => {
|
|
5115
|
+
if (nameSet.has(item.name)) {
|
|
5116
|
+
errors.push(`${filePath}: client context with name "${item.name}" already exists`);
|
|
5117
|
+
}
|
|
5118
|
+
else {
|
|
5119
|
+
nameSet.add(item.name);
|
|
5120
|
+
}
|
|
5121
|
+
});
|
|
5122
|
+
const safeParse = clientContextSchema.safeParse(cube);
|
|
5123
|
+
if (!safeParse.success) {
|
|
5124
|
+
errorFormatter(safeParse.error.issues).forEach((error) => {
|
|
5125
|
+
errors.push(`${filePath}: ${error}`);
|
|
5126
|
+
});
|
|
5127
|
+
}
|
|
5128
|
+
}
|
|
5129
|
+
return errors;
|
|
5130
|
+
}
|
|
5096
5131
|
var MeasureTypeEnum;
|
|
5097
5132
|
(function (MeasureTypeEnum) {
|
|
5098
5133
|
MeasureTypeEnum["string"] = "string";
|
|
@@ -5159,6 +5194,10 @@ const securityContextSchema = z.array(z.object({
|
|
|
5159
5194
|
name: z.string(),
|
|
5160
5195
|
securityContext: z.object({}), // can be any object
|
|
5161
5196
|
}));
|
|
5197
|
+
const clientContextSchema = z.array(z.object({
|
|
5198
|
+
name: z.string(),
|
|
5199
|
+
clientContext: z.object({}), // can be any object
|
|
5200
|
+
}));
|
|
5162
5201
|
|
|
5163
5202
|
var provideConfig = async () => {
|
|
5164
5203
|
const configFilePath = `${process.cwd()}/embeddable.config.js`;
|
|
@@ -21501,8 +21540,10 @@ async function selectWorkspace(ora, ctx, token) {
|
|
|
21501
21540
|
}
|
|
21502
21541
|
|
|
21503
21542
|
const oraP$1 = import('ora');
|
|
21504
|
-
// grab
|
|
21505
|
-
const
|
|
21543
|
+
// grab cube files
|
|
21544
|
+
const CUBE_FILES = /^(.*)\.cube\.(ya?ml|js)$/;
|
|
21545
|
+
// grab security context and client context files
|
|
21546
|
+
const PRESET_FILES = /^(.*)\.(sc|cc)\.ya?ml$/;
|
|
21506
21547
|
let ora$1;
|
|
21507
21548
|
var push = async () => {
|
|
21508
21549
|
await initLogger("push");
|
|
@@ -21585,8 +21626,9 @@ async function verify(ctx) {
|
|
|
21585
21626
|
}
|
|
21586
21627
|
async function buildArchive(config) {
|
|
21587
21628
|
const spinnerArchive = ora$1("Building...").start();
|
|
21588
|
-
const
|
|
21589
|
-
await
|
|
21629
|
+
const cubeFilesList = await findFiles(config.client.modelsSrc || config.client.srcDir, CUBE_FILES);
|
|
21630
|
+
const contextFilesList = await findFiles(config.client.presetsSrc || config.client.srcDir, PRESET_FILES);
|
|
21631
|
+
await archive(config, [...cubeFilesList, ...contextFilesList]);
|
|
21590
21632
|
return spinnerArchive.succeed("Bundling completed");
|
|
21591
21633
|
}
|
|
21592
21634
|
async function archive(ctx, yamlFiles, isDev = false) {
|
|
@@ -21765,7 +21807,7 @@ var dev = async () => {
|
|
|
21765
21807
|
metaFileName: "embeddable-components-meta.js",
|
|
21766
21808
|
editorsMetaFileName: "embeddable-editors-meta.js",
|
|
21767
21809
|
});
|
|
21768
|
-
await
|
|
21810
|
+
await sendDataModelsAndContextsChanges(config);
|
|
21769
21811
|
for (const getPlugin of config.plugins) {
|
|
21770
21812
|
const plugin = getPlugin();
|
|
21771
21813
|
breadcrumbs.push("validate plugin");
|
|
@@ -21834,9 +21876,12 @@ const onBundleBuildEnd = async (ctx) => {
|
|
|
21834
21876
|
}
|
|
21835
21877
|
};
|
|
21836
21878
|
const dataModelAndSecurityContextWatcher = (ctx) => {
|
|
21837
|
-
const fsWatcher = chokidar__namespace.watch([
|
|
21879
|
+
const fsWatcher = chokidar__namespace.watch([
|
|
21880
|
+
path__namespace$1.resolve(ctx.client.modelsSrc, "**/*.{cube}.{yaml,yml,js}"),
|
|
21881
|
+
path__namespace$1.resolve(ctx.client.presetsSrc, "**/*.{sc,cc}.{yaml,yml}"),
|
|
21882
|
+
], chokidarWatchOptions);
|
|
21838
21883
|
fsWatcher.on("all", async () => {
|
|
21839
|
-
await
|
|
21884
|
+
await sendDataModelsAndContextsChanges(ctx);
|
|
21840
21885
|
});
|
|
21841
21886
|
return fsWatcher;
|
|
21842
21887
|
};
|
|
@@ -21847,13 +21892,15 @@ const globalCssWatcher = (ctx) => {
|
|
|
21847
21892
|
});
|
|
21848
21893
|
return fsWatcher;
|
|
21849
21894
|
};
|
|
21850
|
-
const
|
|
21895
|
+
const sendDataModelsAndContextsChanges = async (ctx) => {
|
|
21851
21896
|
sendMessage("dataModelsAndOrSecurityContextUpdateStart");
|
|
21852
21897
|
const isValid = await validate(ctx, false);
|
|
21853
21898
|
if (isValid) {
|
|
21854
21899
|
const token = await getToken();
|
|
21855
21900
|
const sending = ora("Synchronising data models and/or security contexts...").start();
|
|
21856
|
-
const
|
|
21901
|
+
const cubeFilesList = await findFiles(ctx.client.modelsSrc, CUBE_FILES);
|
|
21902
|
+
const contextFilesList = await findFiles(ctx.client.presetsSrc, PRESET_FILES);
|
|
21903
|
+
const filesList = [...cubeFilesList, ...contextFilesList];
|
|
21857
21904
|
// add manifest to the archive
|
|
21858
21905
|
filesList.push([
|
|
21859
21906
|
"embeddable-manifest",
|
|
@@ -21916,7 +21963,7 @@ const getPreviewWorkspace = async (startedOra, ctx) => {
|
|
|
21916
21963
|
}
|
|
21917
21964
|
};
|
|
21918
21965
|
|
|
21919
|
-
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, }) => {
|
|
21966
|
+
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", presetsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, }) => {
|
|
21920
21967
|
const coreRoot = path__namespace.resolve(__dirname, "..");
|
|
21921
21968
|
const clientRoot = process.cwd();
|
|
21922
21969
|
if (!path__namespace.isAbsolute(componentsSrc)) {
|
|
@@ -21931,6 +21978,12 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21931
21978
|
throw new Error(`modelsSrc directory ${modelsSrc} does not exist`);
|
|
21932
21979
|
}
|
|
21933
21980
|
}
|
|
21981
|
+
if (presetsSrc && !path__namespace.isAbsolute(presetsSrc)) {
|
|
21982
|
+
presetsSrc = path__namespace.resolve(clientRoot, presetsSrc);
|
|
21983
|
+
if (!fs$1.existsSync(presetsSrc)) {
|
|
21984
|
+
throw new Error(`presetsSrc directory ${presetsSrc} does not exist`);
|
|
21985
|
+
}
|
|
21986
|
+
}
|
|
21934
21987
|
return {
|
|
21935
21988
|
core: {
|
|
21936
21989
|
rootDir: coreRoot,
|
|
@@ -21941,6 +21994,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21941
21994
|
rootDir: clientRoot,
|
|
21942
21995
|
srcDir: path__namespace.resolve(clientRoot, componentsSrc),
|
|
21943
21996
|
modelsSrc: modelsSrc ? path__namespace.resolve(clientRoot, modelsSrc) : undefined,
|
|
21997
|
+
presetsSrc: presetsSrc ? path__namespace.resolve(clientRoot, presetsSrc) : undefined,
|
|
21944
21998
|
buildDir: path__namespace.resolve(clientRoot, ".embeddable-build"),
|
|
21945
21999
|
tmpDir: path__namespace.resolve(clientRoot, ".embeddable-tmp"),
|
|
21946
22000
|
globalCss: path__namespace.resolve(clientRoot, globalCss),
|
|
@@ -21969,7 +22023,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21969
22023
|
};
|
|
21970
22024
|
|
|
21971
22025
|
var name = "@embeddable.com/sdk-core";
|
|
21972
|
-
var version = "3.9.
|
|
22026
|
+
var version = "3.9.6";
|
|
21973
22027
|
var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
|
|
21974
22028
|
var keywords = [
|
|
21975
22029
|
"embeddable",
|