@embeddable.com/sdk-core 3.13.3-next.1 → 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.1",
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,38 +207,40 @@ export async function archive(args: {
209
207
  });
210
208
  }
211
209
 
212
- export async function sendBuildByApiKey(
213
- ctx: ResolvedEmbeddableConfig,
214
- {
215
- apiKey,
216
- email,
217
- message,
218
- }: { apiKey: string; email: string; message?: string },
210
+ export async function createFormData(
211
+ filePath: string,
212
+ metadata: Record<string, any>,
219
213
  ) {
220
214
  const { FormData, Blob } = await import("formdata-node");
221
215
  const { fileFromPath } = await import("formdata-node/file-from-path");
222
216
 
223
- const file = await fileFromPath(
224
- ctx.client.archiveFile,
225
- "embeddable-build.zip",
226
- );
227
-
217
+ const file = await fileFromPath(filePath, "embeddable-build.zip");
228
218
  const form = new FormData();
229
219
  form.set("file", file, "embeddable-build.zip");
230
220
 
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
- );
221
+ const metadataBlob = new Blob([JSON.stringify(metadata)], {
222
+ type: "application/json",
223
+ });
242
224
  form.set("request", metadataBlob, "request.json");
243
225
 
226
+ return form;
227
+ }
228
+
229
+ export async function sendBuildByApiKey(
230
+ ctx: ResolvedEmbeddableConfig,
231
+ {
232
+ apiKey,
233
+ email,
234
+ message,
235
+ }: { apiKey: string; email: string; message?: string },
236
+ ) {
237
+ const form = await createFormData(ctx.client.archiveFile, {
238
+ pushModels: ctx.pushModels,
239
+ pushComponents: ctx.pushComponents,
240
+ authorEmail: email,
241
+ description: message,
242
+ });
243
+
244
244
  const response = await uploadFile(
245
245
  form,
246
246
  `${ctx.pushBaseUrl}/api/v1/bundle/upload`,
@@ -248,23 +248,19 @@ export async function sendBuildByApiKey(
248
248
  );
249
249
  await fs.rm(ctx.client.archiveFile);
250
250
 
251
- return { bundleId: response.data?.bundleId, email, message };
251
+ return { ...response.data, message };
252
252
  }
253
253
 
254
254
  export async function sendBuild(
255
255
  ctx: ResolvedEmbeddableConfig,
256
256
  { workspaceId, token }: { workspaceId: string; token: string },
257
257
  ) {
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");
258
+ const form = await createFormData(ctx.client.archiveFile, {
259
+ pushModels: ctx.pushModels,
260
+ pushComponents: ctx.pushComponents,
261
+ authorEmail: "",
262
+ description: "",
263
+ });
268
264
 
269
265
  await uploadFile(
270
266
  form,