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

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,17 +8,13 @@ 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
- }>;
17
+ }): Promise<any>;
22
18
  export declare function sendBuild(ctx: ResolvedEmbeddableConfig, { workspaceId, token }: {
23
19
  workspaceId: string;
24
20
  token: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "3.13.3-next.0",
3
+ "version": "3.13.3",
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
@@ -170,7 +170,6 @@ export async function buildArchive(config: ResolvedEmbeddableConfig) {
170
170
  ctx: config,
171
171
  filesList,
172
172
  isDev: false,
173
- includeComponents: config.pushComponents,
174
173
  });
175
174
  return spinnerArchive.succeed("Bundling completed");
176
175
  }
@@ -179,9 +178,8 @@ export async function archive(args: {
179
178
  ctx: ResolvedEmbeddableConfig;
180
179
  filesList: [string, string][];
181
180
  isDev: boolean;
182
- includeComponents: boolean;
183
181
  }) {
184
- const { ctx, filesList, isDev, includeComponents } = args;
182
+ const { ctx, filesList, isDev } = args;
185
183
  const output = fsSync.createWriteStream(ctx.client.archiveFile);
186
184
 
187
185
  const archive = archiver.create("zip", {
@@ -189,7 +187,7 @@ export async function archive(args: {
189
187
  });
190
188
 
191
189
  archive.pipe(output);
192
- if (!isDev && includeComponents) {
190
+ if (!isDev) {
193
191
  archive.directory(ctx.client.buildDir, false);
194
192
  archive.file(ctx.client.globalCss, {
195
193
  name: "global.css",
@@ -209,6 +207,25 @@ export async function archive(args: {
209
207
  });
210
208
  }
211
209
 
210
+ export async function createFormData(
211
+ filePath: string,
212
+ metadata: Record<string, any>,
213
+ ) {
214
+ const { FormData, Blob } = await import("formdata-node");
215
+ const { fileFromPath } = await import("formdata-node/file-from-path");
216
+
217
+ const file = await fileFromPath(filePath, "embeddable-build.zip");
218
+ const form = new FormData();
219
+ form.set("file", file, "embeddable-build.zip");
220
+
221
+ const metadataBlob = new Blob([JSON.stringify(metadata)], {
222
+ type: "application/json",
223
+ });
224
+ form.set("request", metadataBlob, "request.json");
225
+
226
+ return form;
227
+ }
228
+
212
229
  export async function sendBuildByApiKey(
213
230
  ctx: ResolvedEmbeddableConfig,
214
231
  {
@@ -217,22 +234,12 @@ export async function sendBuildByApiKey(
217
234
  message,
218
235
  }: { apiKey: string; email: string; message?: string },
219
236
  ) {
220
- const { FormData, Blob } = await import("formdata-node");
221
- const { fileFromPath } = await import("formdata-node/file-from-path");
222
-
223
- const file = await fileFromPath(
224
- ctx.client.archiveFile,
225
- "embeddable-build.zip",
226
- );
227
-
228
- const form = new FormData();
229
- form.set("file", file, "embeddable-build.zip");
230
-
231
- const metadataBlob = new Blob(
232
- [JSON.stringify({ authorEmail: email, description: message })],
233
- { type: "application/json" },
234
- );
235
- form.set("metadata", metadataBlob, "metadata.json");
237
+ const form = await createFormData(ctx.client.archiveFile, {
238
+ pushModels: ctx.pushModels,
239
+ pushComponents: ctx.pushComponents,
240
+ authorEmail: email,
241
+ description: message,
242
+ });
236
243
 
237
244
  const response = await uploadFile(
238
245
  form,
@@ -241,23 +248,19 @@ export async function sendBuildByApiKey(
241
248
  );
242
249
  await fs.rm(ctx.client.archiveFile);
243
250
 
244
- return { bundleId: response.data?.bundleId, email, message };
251
+ return { ...response.data, message };
245
252
  }
246
253
 
247
254
  export async function sendBuild(
248
255
  ctx: ResolvedEmbeddableConfig,
249
256
  { workspaceId, token }: { workspaceId: string; token: string },
250
257
  ) {
251
- const { FormData } = await import("formdata-node");
252
- const { fileFromPath } = await import("formdata-node/file-from-path");
253
-
254
- const file = await fileFromPath(
255
- ctx.client.archiveFile,
256
- "embeddable-build.zip",
257
- );
258
-
259
- const form = new FormData();
260
- form.set("file", file, "embeddable-build.zip");
258
+ const form = await createFormData(ctx.client.archiveFile, {
259
+ pushModels: ctx.pushModels,
260
+ pushComponents: ctx.pushComponents,
261
+ authorEmail: "",
262
+ description: "",
263
+ });
261
264
 
262
265
  await uploadFile(
263
266
  form,