@embeddable.com/sdk-core 3.13.3-next.1 → 3.13.4-next.0

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
@@ -8,18 +8,15 @@ export declare function archive(args: {
8
8
  ctx: ResolvedEmbeddableConfig;
9
9
  filesList: [string, string][];
10
10
  isDev: boolean;
11
- includeComponents: boolean;
12
11
  }): Promise<unknown>;
12
+ export declare function createFormData(filePath: string, metadata: Record<string, any>): Promise<import("formdata-node").FormData>;
13
13
  export declare function sendBuildByApiKey(ctx: ResolvedEmbeddableConfig, { apiKey, email, message, }: {
14
14
  apiKey: string;
15
15
  email: string;
16
16
  message?: string;
17
- }): Promise<{
18
- bundleId: any;
19
- email: string;
20
- message: string | undefined;
21
- }>;
22
- export declare function sendBuild(ctx: ResolvedEmbeddableConfig, { workspaceId, token }: {
17
+ }): Promise<any>;
18
+ export declare function sendBuild(ctx: ResolvedEmbeddableConfig, { workspaceId, token, message, }: {
23
19
  workspaceId: string;
24
20
  token: string;
21
+ message?: string;
25
22
  }): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "3.13.3-next.1",
3
+ "version": "3.13.4-next.0",
4
4
  "description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
5
5
  "keywords": [
6
6
  "embeddable",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "license": "MIT",
41
41
  "dependencies": {
42
- "@embeddable.com/sdk-utils": "0.7.1",
42
+ "@embeddable.com/sdk-utils": "0.7.2",
43
43
  "@inquirer/prompts": "^7.2.1",
44
44
  "@stencil/core": "^4.23.0",
45
45
  "@swc-node/register": "^1.10.9",
package/src/dev.ts CHANGED
@@ -343,7 +343,6 @@ const sendDataModelsAndContextsChanges = async (ctx: any) => {
343
343
  ctx,
344
344
  filesList,
345
345
  isDev: true,
346
- includeComponents: false,
347
346
  });
348
347
  await sendBuild(ctx, { workspaceId: previewWorkspace, token });
349
348
  sending.succeed(`Data models and/or security context synchronized`);
package/src/push.test.ts CHANGED
@@ -227,29 +227,6 @@ describe("push", () => {
227
227
  expect(process.exit).toHaveBeenCalledWith(1);
228
228
  });
229
229
 
230
- it("should only include model files when pushComponents is false", async () => {
231
- const mockArchiver = {
232
- finalize: vi.fn(),
233
- pipe: vi.fn(),
234
- directory: vi.fn(),
235
- file: vi.fn(),
236
- };
237
- vi.mocked(archiver.create).mockReturnValue(mockArchiver as any);
238
-
239
- vi.mocked(provideConfig).mockResolvedValue({
240
- ...config,
241
- pushModels: true,
242
- pushComponents: false,
243
- });
244
-
245
- await push();
246
-
247
- // Should not include component build directory
248
- expect(mockArchiver.directory).not.toHaveBeenCalled();
249
- // Should include model files
250
- expect(mockArchiver.file).toHaveBeenCalled();
251
- });
252
-
253
230
  it("should only include component files when pushModels is false", async () => {
254
231
  const mockArchiver = {
255
232
  finalize: vi.fn(),
@@ -498,45 +475,6 @@ describe("push", () => {
498
475
  );
499
476
  });
500
477
 
501
- it("should only include model files when pushComponents is false", async () => {
502
- vi.mocked(findFiles)
503
- .mockResolvedValueOnce([["model.cube.yml", "/path/to/model.cube.yml"]])
504
- .mockResolvedValueOnce([["context.sc.yml", "/path/to/context.sc.yml"]]);
505
-
506
- const testConfig = {
507
- ...config,
508
- pushModels: true,
509
- pushComponents: false,
510
- client: {
511
- ...config.client,
512
- srcDir: "/src",
513
- },
514
- } as ResolvedEmbeddableConfig;
515
-
516
- await buildArchive(testConfig);
517
-
518
- // Should not include component build directory
519
- expect(mockArchiver.directory).not.toHaveBeenCalled();
520
- // Should not include global.css
521
- expect(mockArchiver.file).not.toHaveBeenCalledWith(
522
- expect.anything(),
523
- expect.objectContaining({ name: "global.css" }),
524
- );
525
- // Should include model files
526
- expect(mockArchiver.file).toHaveBeenCalledWith(
527
- "/path/to/model.cube.yml",
528
- {
529
- name: "model.cube.yml",
530
- },
531
- );
532
- expect(mockArchiver.file).toHaveBeenCalledWith(
533
- "/path/to/context.sc.yml",
534
- {
535
- name: "context.sc.yml",
536
- },
537
- );
538
- });
539
-
540
478
  it("should only include component files when pushModels is false", async () => {
541
479
  const testConfig = {
542
480
  ...config,
package/src/push.ts CHANGED
@@ -64,6 +64,7 @@ export default async () => {
64
64
  );
65
65
 
66
66
  const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`;
67
+ const message = getArgumentByKey(["--message", "-m"]);
67
68
 
68
69
  breadcrumbs.push("build archive");
69
70
  await buildArchive(config);
@@ -72,7 +73,7 @@ export default async () => {
72
73
  );
73
74
 
74
75
  breadcrumbs.push("send build");
75
- await sendBuild(config, { workspaceId, token });
76
+ await sendBuild(config, { workspaceId, token, message });
76
77
  spinnerPushing.succeed(
77
78
  `Published to ${workspaceName} using ${workspacePreviewUrl}`,
78
79
  );
@@ -170,7 +171,6 @@ export async function buildArchive(config: ResolvedEmbeddableConfig) {
170
171
  ctx: config,
171
172
  filesList,
172
173
  isDev: false,
173
- includeComponents: config.pushComponents,
174
174
  });
175
175
  return spinnerArchive.succeed("Bundling completed");
176
176
  }
@@ -179,9 +179,8 @@ export async function archive(args: {
179
179
  ctx: ResolvedEmbeddableConfig;
180
180
  filesList: [string, string][];
181
181
  isDev: boolean;
182
- includeComponents: boolean;
183
182
  }) {
184
- const { ctx, filesList, isDev, includeComponents } = args;
183
+ const { ctx, filesList, isDev } = args;
185
184
  const output = fsSync.createWriteStream(ctx.client.archiveFile);
186
185
 
187
186
  const archive = archiver.create("zip", {
@@ -189,7 +188,7 @@ export async function archive(args: {
189
188
  });
190
189
 
191
190
  archive.pipe(output);
192
- if (!isDev && includeComponents) {
191
+ if (!isDev) {
193
192
  archive.directory(ctx.client.buildDir, false);
194
193
  archive.file(ctx.client.globalCss, {
195
194
  name: "global.css",
@@ -209,38 +208,40 @@ export async function archive(args: {
209
208
  });
210
209
  }
211
210
 
212
- export async function sendBuildByApiKey(
213
- ctx: ResolvedEmbeddableConfig,
214
- {
215
- apiKey,
216
- email,
217
- message,
218
- }: { apiKey: string; email: string; message?: string },
211
+ export async function createFormData(
212
+ filePath: string,
213
+ metadata: Record<string, any>,
219
214
  ) {
220
215
  const { FormData, Blob } = await import("formdata-node");
221
216
  const { fileFromPath } = await import("formdata-node/file-from-path");
222
217
 
223
- const file = await fileFromPath(
224
- ctx.client.archiveFile,
225
- "embeddable-build.zip",
226
- );
227
-
218
+ const file = await fileFromPath(filePath, "embeddable-build.zip");
228
219
  const form = new FormData();
229
220
  form.set("file", file, "embeddable-build.zip");
230
221
 
231
- const metadataBlob = new Blob(
232
- [
233
- JSON.stringify({
234
- pushModels: ctx.pushModels,
235
- pushComponents: ctx.pushComponents,
236
- authorEmail: email,
237
- description: message,
238
- }),
239
- ],
240
- { type: "application/json" },
241
- );
222
+ const metadataBlob = new Blob([JSON.stringify(metadata)], {
223
+ type: "application/json",
224
+ });
242
225
  form.set("request", metadataBlob, "request.json");
243
226
 
227
+ return form;
228
+ }
229
+
230
+ export async function sendBuildByApiKey(
231
+ ctx: ResolvedEmbeddableConfig,
232
+ {
233
+ apiKey,
234
+ email,
235
+ message,
236
+ }: { apiKey: string; email: string; message?: string },
237
+ ) {
238
+ const form = await createFormData(ctx.client.archiveFile, {
239
+ pushModels: ctx.pushModels,
240
+ pushComponents: ctx.pushComponents,
241
+ authorEmail: email,
242
+ description: message,
243
+ });
244
+
244
245
  const response = await uploadFile(
245
246
  form,
246
247
  `${ctx.pushBaseUrl}/api/v1/bundle/upload`,
@@ -248,23 +249,23 @@ export async function sendBuildByApiKey(
248
249
  );
249
250
  await fs.rm(ctx.client.archiveFile);
250
251
 
251
- return { bundleId: response.data?.bundleId, email, message };
252
+ return { ...response.data, message };
252
253
  }
253
254
 
254
255
  export async function sendBuild(
255
256
  ctx: ResolvedEmbeddableConfig,
256
- { workspaceId, token }: { workspaceId: string; token: string },
257
+ {
258
+ workspaceId,
259
+ token,
260
+ message,
261
+ }: { workspaceId: string; token: string; message?: string },
257
262
  ) {
258
- const { FormData } = await import("formdata-node");
259
- const { fileFromPath } = await import("formdata-node/file-from-path");
260
-
261
- const file = await fileFromPath(
262
- ctx.client.archiveFile,
263
- "embeddable-build.zip",
264
- );
265
-
266
- const form = new FormData();
267
- form.set("file", file, "embeddable-build.zip");
263
+ const form = await createFormData(ctx.client.archiveFile, {
264
+ pushModels: ctx.pushModels,
265
+ pushComponents: ctx.pushComponents,
266
+ authorEmail: "",
267
+ description: message,
268
+ });
268
269
 
269
270
  await uploadFile(
270
271
  form,