@superblocksteam/sdk 2.0.56-next.0 → 2.0.56-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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @superblocksteam/sdk@2.0.56-next.0 build /home/runner/_work/superblocks/superblocks/packages/cli/packages/sdk
2
+ > @superblocksteam/sdk@2.0.56-next.1 build /home/runner/_work/superblocks/superblocks/packages/cli/packages/sdk
3
3
  > tsc --build
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"application-build.d.mts","sourceRoot":"","sources":["../src/application-build.mts"],"names":[],"mappings":"AAaA,wBAAsB,gBAAgB,CAAC,EACrC,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,eAAe,EACf,KAAK,EACL,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,iBAuBA"}
1
+ {"version":3,"file":"application-build.d.mts","sourceRoot":"","sources":["../src/application-build.mts"],"names":[],"mappings":"AAcA,wBAAsB,gBAAgB,CAAC,EACrC,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,eAAe,EACf,KAAK,EACL,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,iBAuBA"}
@@ -8,6 +8,7 @@ import tsconfigPaths from "vite-tsconfig-paths";
8
8
  import { customComponentsPlugin } from "./dev-utils/custom-build.mjs";
9
9
  import { ddRumPlugin } from "./dev-utils/vite-plugin-dd-rum.mjs";
10
10
  import { getLogger } from "./telemetry/logging.js";
11
+ import { generateApiBuildManifestPlugin } from "./vite-plugin-generate-api-build-manifest.mjs";
11
12
  import { injectSuperblocksIdsPlugin } from "./vite-plugin-inject-sb-ids-transform.mjs";
12
13
  import createLucideReactImportOptimizer from "./vite-plugin-optimize-lucide-imports.js";
13
14
  export async function buildApplication({ root, dest, mode, assetsCdnUrl, ddClientToken, ddApplicationId, ddEnv, ddVersion, }) {
@@ -72,6 +73,7 @@ async function buildWithVite({ root, dest, mode, assetsCdnUrl, ddClientToken, dd
72
73
  injectSuperblocksIdsPlugin(root),
73
74
  react(),
74
75
  createLucideReactImportOptimizer(),
76
+ generateApiBuildManifestPlugin(root),
75
77
  ddRumPlugin({
76
78
  clientToken: ddClientToken ?? "",
77
79
  applicationId: ddApplicationId ?? "",
@@ -1 +1 @@
1
- {"version":3,"file":"application-build.mjs","sourceRoot":"","sources":["../src/application-build.mts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAC5F,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,O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ACjB,KAAK,EAAE;YACL,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,IAAI;YACjB,KAAK,EAAE,IAAI;YACX,SAAS,EAAE,IAAI;YACf,aAAa,EAAE;gBACb,QAAQ,EAAE,CAAC,GAAG,YAAY,OAAO,CAAC;gBAClC,uBAAuB,EAAE,iBAAiB;aAC3C;SACF;QACD,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE;YACP,aAAa,EAAE;YACf,qBAAqB,CAAC,EAAE,YAAY,EAAE,CAAC;YACvC,sBAAsB,EAAE;YACxB,0BAA0B,CAAC,IAAI,CAAC;YAChC,KAAK,EAAE;YACP,gCAAgC,EAAE;YAClC,8BAA8B,CAAC,IAAI,CAAC;YACpC,WAAW,CAAC;gBACV,WAAW,EAAE,aAAa,IAAI,EAAE;gBAChC,aAAa,EAAE,eAAe,IAAI,EAAE;gBACpC,GAAG,EAAE,KAAK,IAAI,MAAM;gBACpB,OAAO,EAAE,SAAS,IAAI,OAAO;aAC9B,CAAC;SACH;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { Plugin } from "vite";
2
+ export declare const scopeFileBaseName = "scope.ts";
3
+ export declare const apiFileBaseName = "api.yaml";
4
+ /**
5
+ * Vite plugin that generates a build manifest for the application.
6
+ *
7
+ * This plugin will:
8
+ * 1. Read all api.yaml and api.yml files in the application
9
+ * 2. Read all scope.ts files in the application
10
+ * 3. Generate a build manifest for the application
11
+ * 4. Write the build manifest to a file in the build output directory
12
+ *
13
+ * The build manifest is a JSON object with the following properties:
14
+ * - apis: a map of all apis in the application keyed by their file path
15
+ * - apiDependencies: an array where each item represents an api and its dependencies
16
+ *
17
+ * @param root - The root directory of the application
18
+ * @returns A Vite plugin that generates a build manifest for the application
19
+ */
20
+ export declare function generateApiBuildManifestPlugin(root: string): Plugin;
21
+ //# sourceMappingURL=vite-plugin-generate-api-build-manifest.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-generate-api-build-manifest.d.mts","sourceRoot":"","sources":["../src/vite-plugin-generate-api-build-manifest.mts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAC5C,eAAO,MAAM,eAAe,aAAa,CAAC;AAS1C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAkFpD,MAAM,CACZ"}
@@ -0,0 +1,90 @@
1
+ import path from "node:path";
2
+ import { resolveLanguageSpecificStepContentFromBlocks } from "@superblocksteam/util";
3
+ import { getPageName } from "@superblocksteam/vite-plugin-file-sync";
4
+ import { yellow, red } from "colorette";
5
+ import fg from "fast-glob";
6
+ import fs from "fs-extra";
7
+ import { createLogger } from "vite";
8
+ import yaml from "yaml";
9
+ import { getScopeIdFromName } from "../../../../vite-plugin-file-sync/dist/util.js";
10
+ import { getLogger } from "./telemetry/logging.js";
11
+ export const scopeFileBaseName = "scope.ts";
12
+ export const apiFileBaseName = "api.yaml";
13
+ /**
14
+ * Vite plugin that generates a build manifest for the application.
15
+ *
16
+ * This plugin will:
17
+ * 1. Read all api.yaml and api.yml files in the application
18
+ * 2. Read all scope.ts files in the application
19
+ * 3. Generate a build manifest for the application
20
+ * 4. Write the build manifest to a file in the build output directory
21
+ *
22
+ * The build manifest is a JSON object with the following properties:
23
+ * - apis: a map of all apis in the application keyed by their file path
24
+ * - apiDependencies: an array where each item represents an api and its dependencies
25
+ *
26
+ * @param root - The root directory of the application
27
+ * @returns A Vite plugin that generates a build manifest for the application
28
+ */
29
+ export function generateApiBuildManifestPlugin(root) {
30
+ const viteLogger = createLogger();
31
+ const logger = getLogger();
32
+ viteLogger.info = (msg) => logger.info(msg);
33
+ viteLogger.warn = (msg) => {
34
+ logger.warn(yellow(msg));
35
+ };
36
+ viteLogger.warnOnce = (msg) => {
37
+ logger.warn(yellow(msg));
38
+ };
39
+ viteLogger.error = (msg) => {
40
+ logger.error(red(msg));
41
+ };
42
+ viteLogger.clearScreen = () => { };
43
+ const apiFiles = {};
44
+ let buildManifest = { apis: {}, apiDependencies: [] };
45
+ return {
46
+ name: "sb-generate-build-manifest",
47
+ apply: "build",
48
+ enforce: "pre",
49
+ async buildStart() {
50
+ const apiDocuments = await fg(["**/api.yaml", "**/api.yml"], {
51
+ cwd: root,
52
+ });
53
+ for (const apiFilePath of apiDocuments) {
54
+ const absoluteApiFilePath = path.join(root, apiFilePath);
55
+ const document = await fs.readFile(absoluteApiFilePath, "utf-8");
56
+ const apiPb = yaml.parse(document);
57
+ await resolveLanguageSpecificStepContentFromBlocks(path.dirname(absoluteApiFilePath), apiPb.blocks ?? [], {});
58
+ const pageName = getPageName(apiFilePath);
59
+ apiPb.metadata.id = apiPb.metadata.name;
60
+ apiFiles[apiFilePath] = { apiPb, pageName };
61
+ }
62
+ },
63
+ async generateBundle(_options, bundle) {
64
+ const allApis = Object.entries(apiFiles).reduce((acc, [id, api]) => {
65
+ acc[id] = {
66
+ api,
67
+ scopeId: getScopeIdFromName("App"),
68
+ };
69
+ return acc;
70
+ }, {});
71
+ buildManifest = {
72
+ apis: allApis,
73
+ apiDependencies: [],
74
+ };
75
+ // Find the existing hashed build-manifest file in the bundle and replace its content
76
+ for (const [fileName, chunk] of Object.entries(bundle)) {
77
+ // Look for build-manifest files specifically in the assets folder
78
+ if (fileName.startsWith("assets/build-manifest") &&
79
+ fileName.endsWith(".js")) {
80
+ // This is the hashed build-manifest file, replace its content
81
+ if (chunk.type === "chunk") {
82
+ chunk.code =
83
+ `export default ${JSON.stringify(buildManifest)};`;
84
+ }
85
+ }
86
+ }
87
+ },
88
+ };
89
+ }
90
+ //# sourceMappingURL=vite-plugin-generate-api-build-manifest.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-generate-api-build-manifest.mjs","sourceRoot":"","sources":["../src/vite-plugin-generate-api-build-manifest.mts"],"names":[],"mappings":"AAAA,OAAO,IAA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EAAE,EAAE;gBACjB,GAAG,CAAC,EAAE,CAAC,GAAG;oBACR,GAAG;oBACH,OAAO,EAAE,kBAAkB,CAAC,KAAK,CAAC;iBACnC,CAAC;gBACF,OAAO,GAAG,CAAC;YACb,CAAC,EACD,EAAkE,CACnE,CAAC;YAEF,aAAa,GAAG;gBACd,IAAI,EAAE,OAAO;gBACb,eAAe,EAAE,EAAE;aACpB,CAAC;YAEF,qFAAqF;YACrF,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACvD,kEAAkE;gBAClE,IACE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC;oBAC5C,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EACxB,CAAC;oBACD,8DAA8D;oBAC9D,IAAK,KAAa,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;wBACnC,KAAa,CAAC,IAAI;4BACjB,kBAAkB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC;oBACvD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACQ,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superblocksteam/sdk",
3
- "version": "2.0.56-next.0",
3
+ "version": "2.0.56-next.1",
4
4
  "type": "module",
5
5
  "description": "Superblocks JS SDK",
6
6
  "homepage": "https://www.superblocks.com",
@@ -34,11 +34,11 @@
34
34
  "@opentelemetry/semantic-conventions": "^1.28.0",
35
35
  "@rollup/wasm-node": "^4.35.0",
36
36
  "@superblocksteam/bucketeer-sdk": "0.5.0",
37
- "@superblocksteam/library": "2.0.56-next.0",
38
- "@superblocksteam/library-shared": "2.0.56-next.0",
39
- "@superblocksteam/shared": "v0.9546.0",
40
- "@superblocksteam/util": "2.0.56-next.0",
41
- "@superblocksteam/vite-plugin-file-sync": "2.0.56-next.0",
37
+ "@superblocksteam/library": "2.0.56-next.1",
38
+ "@superblocksteam/library-shared": "2.0.56-next.1",
39
+ "@superblocksteam/shared": "v0.9546.1",
40
+ "@superblocksteam/util": "2.0.56-next.1",
41
+ "@superblocksteam/vite-plugin-file-sync": "2.0.56-next.1",
42
42
  "@vitejs/plugin-react": "4.3.4",
43
43
  "axios": "^1.4.0",
44
44
  "chokidar": "^4.0.3",
@@ -8,6 +8,7 @@ import tsconfigPaths from "vite-tsconfig-paths";
8
8
  import { customComponentsPlugin } from "./dev-utils/custom-build.mjs";
9
9
  import { ddRumPlugin } from "./dev-utils/vite-plugin-dd-rum.mjs";
10
10
  import { getLogger } from "./telemetry/logging.js";
11
+ import { generateApiBuildManifestPlugin } from "./vite-plugin-generate-api-build-manifest.mjs";
11
12
  import { injectSuperblocksIdsPlugin } from "./vite-plugin-inject-sb-ids-transform.mjs";
12
13
  import createLucideReactImportOptimizer from "./vite-plugin-optimize-lucide-imports.js";
13
14
 
@@ -113,6 +114,7 @@ async function buildWithVite({
113
114
  injectSuperblocksIdsPlugin(root),
114
115
  react(),
115
116
  createLucideReactImportOptimizer(),
117
+ generateApiBuildManifestPlugin(root),
116
118
  ddRumPlugin({
117
119
  clientToken: ddClientToken ?? "",
118
120
  applicationId: ddApplicationId ?? "",
@@ -0,0 +1,123 @@
1
+ import path from "node:path";
2
+ import { resolveLanguageSpecificStepContentFromBlocks } from "@superblocksteam/util";
3
+ import { getPageName } from "@superblocksteam/vite-plugin-file-sync";
4
+ import { yellow, red } from "colorette";
5
+ import fg from "fast-glob";
6
+ import fs from "fs-extra";
7
+ import { createLogger } from "vite";
8
+ import yaml from "yaml";
9
+ import { getScopeIdFromName } from "../../../../vite-plugin-file-sync/dist/util.js";
10
+ import { getLogger } from "./telemetry/logging.js";
11
+ import type { DeleteMeLibraryApi } from "@superblocksteam/library-shared/types";
12
+ import type { Plugin } from "vite";
13
+
14
+ export const scopeFileBaseName = "scope.ts";
15
+ export const apiFileBaseName = "api.yaml";
16
+
17
+ type ApiDependency = {
18
+ apiName: string;
19
+ scopeId: string;
20
+ params: string[];
21
+ dependencies: string[];
22
+ };
23
+
24
+ /**
25
+ * Vite plugin that generates a build manifest for the application.
26
+ *
27
+ * This plugin will:
28
+ * 1. Read all api.yaml and api.yml files in the application
29
+ * 2. Read all scope.ts files in the application
30
+ * 3. Generate a build manifest for the application
31
+ * 4. Write the build manifest to a file in the build output directory
32
+ *
33
+ * The build manifest is a JSON object with the following properties:
34
+ * - apis: a map of all apis in the application keyed by their file path
35
+ * - apiDependencies: an array where each item represents an api and its dependencies
36
+ *
37
+ * @param root - The root directory of the application
38
+ * @returns A Vite plugin that generates a build manifest for the application
39
+ */
40
+ export function generateApiBuildManifestPlugin(root: string) {
41
+ const viteLogger = createLogger();
42
+ const logger = getLogger();
43
+ viteLogger.info = (msg: string) => logger.info(msg);
44
+ viteLogger.warn = (msg: string) => {
45
+ logger.warn(yellow(msg));
46
+ };
47
+ viteLogger.warnOnce = (msg: string) => {
48
+ logger.warn(yellow(msg));
49
+ };
50
+ viteLogger.error = (msg: string) => {
51
+ logger.error(red(msg));
52
+ };
53
+
54
+ viteLogger.clearScreen = () => {};
55
+
56
+ const apiFiles: Record<string, DeleteMeLibraryApi> = {};
57
+ let buildManifest: {
58
+ apis: Record<string, { api: DeleteMeLibraryApi; scopeId: string }>;
59
+ apiDependencies: ApiDependency[];
60
+ } = { apis: {}, apiDependencies: [] };
61
+
62
+ return {
63
+ name: "sb-generate-build-manifest",
64
+ apply: "build",
65
+ enforce: "pre",
66
+
67
+ async buildStart() {
68
+ const apiDocuments = await fg(["**/api.yaml", "**/api.yml"], {
69
+ cwd: root,
70
+ });
71
+
72
+ for (const apiFilePath of apiDocuments) {
73
+ const absoluteApiFilePath = path.join(root, apiFilePath);
74
+
75
+ const document = await fs.readFile(absoluteApiFilePath, "utf-8");
76
+ const apiPb = yaml.parse(document);
77
+
78
+ await resolveLanguageSpecificStepContentFromBlocks(
79
+ path.dirname(absoluteApiFilePath),
80
+ apiPb.blocks ?? [],
81
+ {},
82
+ );
83
+
84
+ const pageName = getPageName(apiFilePath);
85
+ apiPb.metadata.id = apiPb.metadata.name;
86
+ apiFiles[apiFilePath] = { apiPb, pageName };
87
+ }
88
+ },
89
+
90
+ async generateBundle(_options: any, bundle: any) {
91
+ const allApis = Object.entries(apiFiles).reduce(
92
+ (acc, [id, api]) => {
93
+ acc[id] = {
94
+ api,
95
+ scopeId: getScopeIdFromName("App"),
96
+ };
97
+ return acc;
98
+ },
99
+ {} as Record<string, { api: DeleteMeLibraryApi; scopeId: string }>,
100
+ );
101
+
102
+ buildManifest = {
103
+ apis: allApis,
104
+ apiDependencies: [],
105
+ };
106
+
107
+ // Find the existing hashed build-manifest file in the bundle and replace its content
108
+ for (const [fileName, chunk] of Object.entries(bundle)) {
109
+ // Look for build-manifest files specifically in the assets folder
110
+ if (
111
+ fileName.startsWith("assets/build-manifest") &&
112
+ fileName.endsWith(".js")
113
+ ) {
114
+ // This is the hashed build-manifest file, replace its content
115
+ if ((chunk as any).type === "chunk") {
116
+ (chunk as any).code =
117
+ `export default ${JSON.stringify(buildManifest)};`;
118
+ }
119
+ }
120
+ }
121
+ },
122
+ } as Plugin;
123
+ }