@embeddable.com/sdk-core 3.14.2-next.0 → 3.14.2-next.2

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 CHANGED
@@ -16,6 +16,7 @@ import { loadConfig, createCompiler } from '@stencil/core/compiler';
16
16
  import * as sorcery from 'sorcery';
17
17
  import * as os from 'node:os';
18
18
  import * as YAML from 'yaml';
19
+ import { MEASURE_TYPES, DIMENSION_TYPES } from '@embeddable.com/core';
19
20
  import * as url from 'node:url';
20
21
  import require$$4$1 from 'util';
21
22
  import require$$1 from 'os';
@@ -471,6 +472,7 @@ var buildGlobalHooks = async (ctx) => {
471
472
  const watch = (_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch;
472
473
  const progress = watch ? undefined : ora("Building global hooks...").start();
473
474
  try {
475
+ await fs.mkdir(ctx.client.tmpDir, { recursive: true });
474
476
  const { fileName: themeProvider, watcher: themeWatcher } = await buildThemeHook(ctx);
475
477
  const { lifecycleHooks, watcher: lifecycleWatcher } = await buildLifecycleHooks(ctx);
476
478
  await saveGlobalHooksMeta(ctx, themeProvider, lifecycleHooks);
@@ -610,7 +612,7 @@ async function cleanupTemporaryHookFile(ctx) {
610
612
  * Get the path to the temporary hook file in the build directory.
611
613
  */
612
614
  function getTempHookFilePath(ctx) {
613
- return path$1.resolve(ctx.client.buildDir, TEMP_JS_HOOK_FILE);
615
+ return path$1.resolve(ctx.client.tmpDir, TEMP_JS_HOOK_FILE);
614
616
  }
615
617
  function waitForInitialBuild(watcher) {
616
618
  return new Promise((resolve, reject) => {
@@ -1003,6 +1005,10 @@ async function createManifest({ ctx, typesFileName, metaFileName, editorsMetaFil
1003
1005
  await fs.writeFile(path$1.join(ctx.client.tmpDir, "embeddable-manifest.json"), JSON.stringify(manifest));
1004
1006
  }
1005
1007
  async function extractBuild(ctx) {
1008
+ // Ensure tmpDir is removed before attempting to rename a directory to it.
1009
+ // This helps prevent EPERM errors on Windows if tmpDir already exists and is non-empty
1010
+ // from a previous failed run or other reasons.
1011
+ await fs.rm(ctx.client.tmpDir, { recursive: true, force: true });
1006
1012
  const stencilBuildFiles = await findFiles(ctx.client.stencilBuild, /embeddable-wrapper.esm-[a-z0-9]+\.js/);
1007
1013
  const [[, stencilWrapperFilePath]] = stencilBuildFiles || [];
1008
1014
  const stencilWrapperFileName = path$1.basename(stencilWrapperFilePath);
@@ -5552,28 +5558,6 @@ async function clientContextValidation(filesList) {
5552
5558
  }
5553
5559
  return errors;
5554
5560
  }
5555
- var MeasureTypeEnum;
5556
- (function (MeasureTypeEnum) {
5557
- MeasureTypeEnum["string"] = "string";
5558
- MeasureTypeEnum["time"] = "time";
5559
- MeasureTypeEnum["boolean"] = "boolean";
5560
- MeasureTypeEnum["number"] = "number";
5561
- MeasureTypeEnum["count"] = "count";
5562
- MeasureTypeEnum["count_distinct"] = "count_distinct";
5563
- MeasureTypeEnum["count_distinct_approx"] = "count_distinct_approx";
5564
- MeasureTypeEnum["sum"] = "sum";
5565
- MeasureTypeEnum["avg"] = "avg";
5566
- MeasureTypeEnum["min"] = "min";
5567
- MeasureTypeEnum["max"] = "max";
5568
- })(MeasureTypeEnum || (MeasureTypeEnum = {}));
5569
- var DimensionTypeEnum;
5570
- (function (DimensionTypeEnum) {
5571
- DimensionTypeEnum["string"] = "string";
5572
- DimensionTypeEnum["time"] = "time";
5573
- DimensionTypeEnum["boolean"] = "boolean";
5574
- DimensionTypeEnum["number"] = "number";
5575
- DimensionTypeEnum["geo"] = "geo";
5576
- })(DimensionTypeEnum || (DimensionTypeEnum = {}));
5577
5561
  const cubeModelSchema = z
5578
5562
  .object({
5579
5563
  cubes: z
@@ -5582,14 +5566,14 @@ const cubeModelSchema = z
5582
5566
  dimensions: z
5583
5567
  .object({
5584
5568
  name: z.string(),
5585
- type: z.nativeEnum(DimensionTypeEnum),
5569
+ type: z.enum(DIMENSION_TYPES),
5586
5570
  })
5587
5571
  .array()
5588
5572
  .optional(),
5589
5573
  measures: z
5590
5574
  .object({
5591
5575
  name: z.string(),
5592
- type: z.nativeEnum(MeasureTypeEnum),
5576
+ type: z.enum(MEASURE_TYPES),
5593
5577
  })
5594
5578
  .array()
5595
5579
  .optional(),
@@ -21876,6 +21860,7 @@ var push = async () => {
21876
21860
  breadcrumbs.push("checkNodeVersion");
21877
21861
  const isBuildSuccess = await checkBuildSuccess();
21878
21862
  const config = await provideConfig();
21863
+ const cubeVersion = getArgumentByKey(["--cube-version"]);
21879
21864
  if (!isBuildSuccess && config.pushComponents) {
21880
21865
  console.error("Build failed or not completed. Please run `embeddable:build` first.");
21881
21866
  process.exit(1);
@@ -21884,7 +21869,7 @@ var push = async () => {
21884
21869
  spinnerPushing = ora("Using API key...").start();
21885
21870
  breadcrumbs.push("push by api key");
21886
21871
  try {
21887
- await pushByApiKey(config, spinnerPushing);
21872
+ await pushByApiKey(config, spinnerPushing, cubeVersion);
21888
21873
  }
21889
21874
  catch (error) {
21890
21875
  if (((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errorCode) === "BUILDER-998") {
@@ -21915,7 +21900,7 @@ Read more about deployment regions at https://docs.embeddable.com/deployment/dep
21915
21900
  await buildArchive(config);
21916
21901
  spinnerPushing.info(`Publishing to ${workspaceName} using ${workspacePreviewUrl}...`);
21917
21902
  breadcrumbs.push("send build");
21918
- await sendBuild(config, { workspaceId, token, message });
21903
+ await sendBuild(config, { workspaceId, token, message, cubeVersion });
21919
21904
  publishedSectionFeedback(config, spinnerPushing);
21920
21905
  spinnerPushing.succeed(`Published to ${workspaceName} using ${workspacePreviewUrl}`);
21921
21906
  }
@@ -21931,7 +21916,7 @@ const publishedSectionFeedback = (config, spinnerPushing) => {
21931
21916
  config.pushModels && spinnerPushing.succeed("Models published");
21932
21917
  config.pushComponents && spinnerPushing.succeed("Components published");
21933
21918
  };
21934
- async function pushByApiKey(config, spinner) {
21919
+ async function pushByApiKey(config, spinner, cubeVersion) {
21935
21920
  const apiKey = getArgumentByKey(["--api-key", "-k"]);
21936
21921
  if (!apiKey) {
21937
21922
  spinner.fail("No API key provided");
@@ -21949,6 +21934,7 @@ async function pushByApiKey(config, spinner) {
21949
21934
  apiKey,
21950
21935
  email,
21951
21936
  message,
21937
+ cubeVersion,
21952
21938
  });
21953
21939
  }
21954
21940
  async function verify(ctx) {
@@ -22036,23 +22022,25 @@ async function createFormData(filePath, metadata) {
22036
22022
  form.set("request", metadataBlob, "request.json");
22037
22023
  return form;
22038
22024
  }
22039
- async function sendBuildByApiKey(ctx, { apiKey, email, message, }) {
22025
+ async function sendBuildByApiKey(ctx, { apiKey, email, message, cubeVersion, }) {
22040
22026
  const form = await createFormData(ctx.client.archiveFile, {
22041
22027
  pushModels: ctx.pushModels,
22042
22028
  pushComponents: ctx.pushComponents,
22043
22029
  authorEmail: email,
22044
22030
  description: message,
22031
+ ...(cubeVersion ? { cubeVersion } : {}),
22045
22032
  });
22046
22033
  const response = await uploadFile(form, `${ctx.pushBaseUrl}/api/v1/bundle/upload`, apiKey);
22047
22034
  await fs.rm(ctx.client.archiveFile);
22048
- return { ...response.data, message };
22035
+ return { ...response.data, message, cubeVersion };
22049
22036
  }
22050
- async function sendBuild(ctx, { workspaceId, token, message, }) {
22037
+ async function sendBuild(ctx, { workspaceId, token, message, cubeVersion, }) {
22051
22038
  const form = await createFormData(ctx.client.archiveFile, {
22052
22039
  pushModels: ctx.pushModels,
22053
22040
  pushComponents: ctx.pushComponents,
22054
22041
  authorEmail: "",
22055
22042
  description: message,
22043
+ ...(cubeVersion ? { cubeVersion } : {}),
22056
22044
  });
22057
22045
  await uploadFile(form, `${ctx.pushBaseUrl}/bundle/${workspaceId}/upload`, token);
22058
22046
  await fs.rm(ctx.client.archiveFile);