@embeddable.com/sdk-core 3.14.1 → 3.14.2-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/push.d.ts CHANGED
@@ -12,13 +12,15 @@ export declare function archive(args: {
12
12
  isDev: boolean;
13
13
  }): Promise<void>;
14
14
  export declare function createFormData(filePath: string, metadata: Record<string, any>): Promise<import("formdata-node").FormData>;
15
- export declare function sendBuildByApiKey(ctx: ResolvedEmbeddableConfig, { apiKey, email, message, }: {
15
+ export declare function sendBuildByApiKey(ctx: ResolvedEmbeddableConfig, { apiKey, email, message, cubeVersion, }: {
16
16
  apiKey: string;
17
17
  email: string;
18
18
  message?: string;
19
+ cubeVersion?: string;
19
20
  }): Promise<any>;
20
- export declare function sendBuild(ctx: ResolvedEmbeddableConfig, { workspaceId, token, message, }: {
21
+ export declare function sendBuild(ctx: ResolvedEmbeddableConfig, { workspaceId, token, message, cubeVersion, }: {
21
22
  workspaceId: string;
22
23
  token: string;
23
24
  message?: string;
25
+ cubeVersion?: string;
24
26
  }): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "3.14.1",
3
+ "version": "3.14.2-next.1",
4
4
  "description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
5
5
  "keywords": [
6
6
  "embeddable",
@@ -86,6 +86,7 @@ describe("defineConfig", () => {
86
86
  "pushBaseUrl": "pushBaseUrl",
87
87
  "pushComponents": true,
88
88
  "pushModels": true,
89
+ "region": "legacy-US",
89
90
  "rollbarAccessToken": "rollbarAccessToken",
90
91
  }
91
92
  `);
@@ -94,6 +94,7 @@ export type ResolvedEmbeddableConfig = {
94
94
  logger: any;
95
95
  sys: any;
96
96
  };
97
+ region: Region;
97
98
  [PLUGIN_NAME]: {
98
99
  rootDir: string;
99
100
  templatesDir: string;
@@ -284,6 +285,7 @@ export default (config: EmbeddableConfig) => {
284
285
  logger: undefined,
285
286
  sys: undefined,
286
287
  },
288
+ region,
287
289
  pushModels,
288
290
  pushComponents,
289
291
  pushBaseUrl: pushBaseUrl ?? regionConfig.pushBaseUrl,
package/src/push.test.ts CHANGED
@@ -320,13 +320,20 @@ describe("push", () => {
320
320
  "valid@email.com",
321
321
  "--message",
322
322
  "test message",
323
+ "--cube-version",
324
+ "v1.34",
323
325
  ],
324
326
  },
325
327
  });
326
328
  vi.mocked(getArgumentByKey)
327
- .mockReturnValueOnce("some-key") // API key
328
- .mockReturnValueOnce("valid@email.com") // Email
329
- .mockReturnValueOnce("test message"); // Message
329
+ .mockImplementation((keysArg) => {
330
+ const key = Array.isArray(keysArg) ? keysArg[0] : keysArg;
331
+ if (key === '--api-key') return 'some-key';
332
+ if (key === '--email') return 'valid@email.com';
333
+ if (key === '--message') return 'test message';
334
+ if (key === '--cube-version') return 'v1.34';
335
+ return undefined;
336
+ });
330
337
 
331
338
  await push();
332
339
 
package/src/push.ts CHANGED
@@ -32,6 +32,7 @@ export default async () => {
32
32
  breadcrumbs.push("checkNodeVersion");
33
33
  const isBuildSuccess = await checkBuildSuccess();
34
34
  const config = await provideConfig();
35
+ const cubeVersion = getArgumentByKey(["--cube-version"]);
35
36
 
36
37
  if (!isBuildSuccess && config.pushComponents) {
37
38
  console.error(
@@ -44,12 +45,13 @@ export default async () => {
44
45
  spinnerPushing = ora("Using API key...").start();
45
46
  breadcrumbs.push("push by api key");
46
47
  try {
47
- await pushByApiKey(config, spinnerPushing);
48
+ await pushByApiKey(config, spinnerPushing, cubeVersion);
48
49
  } catch (error: any) {
49
50
  if (error.response?.data?.errorCode === "BUILDER-998") {
50
51
  spinnerPushing.fail(
51
- `Authentication failure. Server responded with: "${error.response?.data?.errorMessage}". Ensure that your API key is valid for the region specified in the embeddable.config.ts|js file.
52
- You are trying to push to the following app url: ${config.previewBaseUrl}
52
+ `Authentication failure. Server responded with: "${error.response?.data?.errorMessage}".
53
+ Ensure that your API key is valid for the region specified in the embeddable.config.ts|js file.
54
+ You are using the following region: ${config.region.replace("legacy-", "")} (${config.previewBaseUrl.replace("https://", "")} via ${config.pushBaseUrl})
53
55
  Read more about deployment regions at https://docs.embeddable.com/deployment/deployment-regions`,
54
56
  );
55
57
  process.exit(1);
@@ -87,7 +89,7 @@ Read more about deployment regions at https://docs.embeddable.com/deployment/dep
87
89
  );
88
90
 
89
91
  breadcrumbs.push("send build");
90
- await sendBuild(config, { workspaceId, token, message });
92
+ await sendBuild(config, { workspaceId, token, message, cubeVersion });
91
93
 
92
94
  publishedSectionFeedback(config, spinnerPushing);
93
95
  spinnerPushing.succeed(
@@ -110,7 +112,7 @@ const publishedSectionFeedback = (
110
112
  config.pushComponents && spinnerPushing.succeed("Components published");
111
113
  };
112
114
 
113
- async function pushByApiKey(config: ResolvedEmbeddableConfig, spinner: any) {
115
+ async function pushByApiKey(config: ResolvedEmbeddableConfig, spinner: any, cubeVersion?: string) {
114
116
  const apiKey = getArgumentByKey(["--api-key", "-k"]);
115
117
 
116
118
  if (!apiKey) {
@@ -136,6 +138,7 @@ async function pushByApiKey(config: ResolvedEmbeddableConfig, spinner: any) {
136
138
  apiKey,
137
139
  email,
138
140
  message,
141
+ cubeVersion,
139
142
  });
140
143
  }
141
144
 
@@ -276,13 +279,15 @@ export async function sendBuildByApiKey(
276
279
  apiKey,
277
280
  email,
278
281
  message,
279
- }: { apiKey: string; email: string; message?: string },
282
+ cubeVersion,
283
+ }: { apiKey: string; email: string; message?: string; cubeVersion?: string },
280
284
  ) {
281
285
  const form = await createFormData(ctx.client.archiveFile, {
282
286
  pushModels: ctx.pushModels,
283
287
  pushComponents: ctx.pushComponents,
284
288
  authorEmail: email,
285
289
  description: message,
290
+ ...(cubeVersion ? { cubeVersion } : {}),
286
291
  });
287
292
 
288
293
  const response = await uploadFile(
@@ -292,7 +297,7 @@ export async function sendBuildByApiKey(
292
297
  );
293
298
  await fs.rm(ctx.client.archiveFile);
294
299
 
295
- return { ...response.data, message };
300
+ return { ...response.data, message, cubeVersion };
296
301
  }
297
302
 
298
303
  export async function sendBuild(
@@ -301,13 +306,15 @@ export async function sendBuild(
301
306
  workspaceId,
302
307
  token,
303
308
  message,
304
- }: { workspaceId: string; token: string; message?: string },
309
+ cubeVersion,
310
+ }: { workspaceId: string; token: string; message?: string; cubeVersion?: string },
305
311
  ) {
306
312
  const form = await createFormData(ctx.client.archiveFile, {
307
313
  pushModels: ctx.pushModels,
308
314
  pushComponents: ctx.pushComponents,
309
315
  authorEmail: "",
310
316
  description: message,
317
+ ...(cubeVersion ? { cubeVersion } : {}),
311
318
  });
312
319
 
313
320
  await uploadFile(