@superblocksteam/sdk 2.0.104 → 2.0.105-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/.turbo/turbo-build.log +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -5
- package/dist/client.js.map +1 -1
- package/dist/collect-sdk-apis.d.mts +3 -2
- package/dist/collect-sdk-apis.d.mts.map +1 -1
- package/dist/collect-sdk-apis.mjs +10 -7
- package/dist/collect-sdk-apis.mjs.map +1 -1
- package/dist/collect-sdk-apis.test.mjs +35 -0
- package/dist/collect-sdk-apis.test.mjs.map +1 -1
- package/dist/parse-sdk-registry.d.mts +9 -1
- package/dist/parse-sdk-registry.d.mts.map +1 -1
- package/dist/parse-sdk-registry.mjs +10 -1
- package/dist/parse-sdk-registry.mjs.map +1 -1
- package/dist/parse-sdk-registry.test.mjs +13 -1
- package/dist/parse-sdk-registry.test.mjs.map +1 -1
- package/dist/vite-plugin-generate-api-build-manifest.d.mts.map +1 -1
- package/dist/vite-plugin-generate-api-build-manifest.mjs.map +1 -1
- package/package.json +6 -6
- package/src/client.ts +6 -6
- package/src/collect-sdk-apis.mts +11 -7
- package/src/collect-sdk-apis.test.mts +38 -0
- package/src/parse-sdk-registry.mts +23 -1
- package/src/parse-sdk-registry.test.mts +19 -1
- package/src/vite-plugin-generate-api-build-manifest.mts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { parseSdkRegistryFromContent } from "@superblocksteam/vite-plugin-file-sync/parsing";
|
|
2
|
+
import { parseSdkRegistryFromContent, parseSdkRegistryEntries, } from "@superblocksteam/vite-plugin-file-sync/parsing";
|
|
3
3
|
const RESOLUTION_EXTENSIONS = [".ts", ".tsx", ".js"];
|
|
4
4
|
/**
|
|
5
5
|
* Parse server/apis/index.ts to extract the mapping from registry key (used in
|
|
@@ -8,6 +8,8 @@ const RESOLUTION_EXTENSIONS = [".ts", ".tsx", ".js"];
|
|
|
8
8
|
*
|
|
9
9
|
* Supports:
|
|
10
10
|
* - import X from './Path/api.js'; const apis = { X }; export default apis;
|
|
11
|
+
* - import { A, B } from './Path/apis.js'; export default { A, B };
|
|
12
|
+
* - import X, { Y } from './Path/apis.js'; export default { X, Y };
|
|
11
13
|
* - const apis = { X: () => import('./Path/api') }; export default apis;
|
|
12
14
|
* - export default { X, Y: () => import('./Path/api') };
|
|
13
15
|
*
|
|
@@ -19,6 +21,13 @@ const RESOLUTION_EXTENSIONS = [".ts", ".tsx", ".js"];
|
|
|
19
21
|
export async function parseSdkRegistry(registryContent, registryDir, root, pathExists) {
|
|
20
22
|
return parseSdkRegistryFromContent(registryContent, (importPath) => resolveImportPath(importPath, registryDir, root, pathExists));
|
|
21
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Parse server/apis/index.ts to extract rich metadata including exportName.
|
|
26
|
+
* Used by the build manifest generator to include exportName for named imports.
|
|
27
|
+
*/
|
|
28
|
+
export async function parseSdkRegistryWithExportNames(registryContent, registryDir, root, pathExists) {
|
|
29
|
+
return parseSdkRegistryEntries(registryContent, (importPath) => resolveImportPath(importPath, registryDir, root, pathExists));
|
|
30
|
+
}
|
|
22
31
|
async function resolveImportPath(importPath, registryDir, root, pathExists) {
|
|
23
32
|
if (!importPath.startsWith("."))
|
|
24
33
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-sdk-registry.mjs","sourceRoot":"","sources":["../src/parse-sdk-registry.mts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,
|
|
1
|
+
{"version":3,"file":"parse-sdk-registry.mjs","sourceRoot":"","sources":["../src/parse-sdk-registry.mts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,GAExB,MAAM,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IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -9,7 +9,8 @@ describe("parseSdkRegistry", () => {
|
|
|
9
9
|
return (rel === "server/apis/GetUsers/api.ts" ||
|
|
10
10
|
rel === "server/apis/v2/GetUsers/api.ts" ||
|
|
11
11
|
rel === "server/apis/CreateOrder/api.ts" ||
|
|
12
|
-
rel === "server/apis/JsOnly/api.js"
|
|
12
|
+
rel === "server/apis/JsOnly/api.js" ||
|
|
13
|
+
rel === "server/apis/shared/user-apis.ts");
|
|
13
14
|
};
|
|
14
15
|
it("extracts registry keys from direct imports", async () => {
|
|
15
16
|
const content = `
|
|
@@ -89,5 +90,16 @@ export default { JsOnly };
|
|
|
89
90
|
expect(result.get("JsOnly")).toBe("server/apis/JsOnly/api.js");
|
|
90
91
|
expect(result.size).toBe(1);
|
|
91
92
|
});
|
|
93
|
+
it("resolves named imports from a shared entrypoint file", async () => {
|
|
94
|
+
const content = `
|
|
95
|
+
import { GetUsers, CreateOrder } from './shared/user-apis.js';
|
|
96
|
+
const apis = { GetUsers, CreateOrder } as const;
|
|
97
|
+
export default apis;
|
|
98
|
+
`;
|
|
99
|
+
const result = await parseSdkRegistry(content, registryDir, root, pathExists);
|
|
100
|
+
expect(result.get("GetUsers")).toBe("server/apis/shared/user-apis.ts");
|
|
101
|
+
expect(result.get("CreateOrder")).toBe("server/apis/shared/user-apis.ts");
|
|
102
|
+
expect(result.size).toBe(2);
|
|
103
|
+
});
|
|
92
104
|
});
|
|
93
105
|
//# sourceMappingURL=parse-sdk-registry.test.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-sdk-registry.test.mjs","sourceRoot":"","sources":["../src/parse-sdk-registry.test.mts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM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plugin-generate-api-build-manifest.d.mts","sourceRoot":"","sources":["../src/vite-plugin-generate-api-build-manifest.mts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAqBnC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"vite-plugin-generate-api-build-manifest.d.mts","sourceRoot":"","sources":["../src/vite-plugin-generate-api-build-manifest.mts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAqBnC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAuGpD,MAAM,CACZ"}
|
|
@@ -1 +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,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,4CAA4C,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EACL,WAAW,EACX,kBAAkB,GACnB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AASnD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,8BAA8B,CAAC,IAAY;IACzD,MAAM,UAAU,GAA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,CAAC,CAAC,MAAM,0BAA0B,CAAC,IAAI,EAAE;oBACrC,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;oBACnC,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;iBAC1C,CAAC;gBACJ,CAAC,CAAC,EAAE,CAAC;YAEP,aAAa,GAAG;gBACd,IAAI,EAAE,OAAO;gBACb,eAAe,EAAE,EAAE;gBACnB,OAAO;aACR,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.
|
|
3
|
+
"version": "2.0.105-next.1",
|
|
4
4
|
"description": "Superblocks JS SDK",
|
|
5
5
|
"homepage": "https://www.superblocks.com",
|
|
6
6
|
"license": "Superblocks Community Software License",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"vite-tsconfig-paths": "^6.0.4",
|
|
49
49
|
"winston": "^3.17.0",
|
|
50
50
|
"yaml": "^2.7.1",
|
|
51
|
-
"@superblocksteam/library-shared": "2.0.
|
|
52
|
-
"@superblocksteam/shared": "0.
|
|
53
|
-
"@superblocksteam/telemetry": "2.0.
|
|
54
|
-
"@superblocksteam/util": "2.0.
|
|
55
|
-
"@superblocksteam/vite-plugin-file-sync": "2.0.
|
|
51
|
+
"@superblocksteam/library-shared": "2.0.105-next.1",
|
|
52
|
+
"@superblocksteam/shared": "0.9577.0",
|
|
53
|
+
"@superblocksteam/telemetry": "2.0.105-next.1",
|
|
54
|
+
"@superblocksteam/util": "2.0.105-next.1",
|
|
55
|
+
"@superblocksteam/vite-plugin-file-sync": "2.0.105-next.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@eslint/js": "^9.39.2",
|
package/src/client.ts
CHANGED
|
@@ -2169,13 +2169,13 @@ export interface IntegrationSummary {
|
|
|
2169
2169
|
created: string;
|
|
2170
2170
|
updated: string;
|
|
2171
2171
|
ownerEmail?: string;
|
|
2172
|
+
isUserConfigured: boolean;
|
|
2172
2173
|
}
|
|
2173
2174
|
|
|
2174
2175
|
export interface IntegrationDetail extends IntegrationSummary {
|
|
2175
2176
|
configurations?: unknown[];
|
|
2176
2177
|
demoIntegrationId?: string;
|
|
2177
2178
|
enabledForV2?: boolean;
|
|
2178
|
-
isUserConfigured?: boolean;
|
|
2179
2179
|
}
|
|
2180
2180
|
|
|
2181
2181
|
export interface IntegrationMutationPayload {
|
|
@@ -2195,13 +2195,13 @@ export async function fetchIntegrations({
|
|
|
2195
2195
|
}): Promise<IntegrationSummary[]> {
|
|
2196
2196
|
try {
|
|
2197
2197
|
const url = new URL(
|
|
2198
|
-
`${BASE_SERVER_API_URL_V1}/integrations`,
|
|
2198
|
+
`${BASE_SERVER_API_URL_V1}/integrations/superset`,
|
|
2199
2199
|
superblocksBaseUrl,
|
|
2200
2200
|
);
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2201
|
+
const ALL_INTEGRATION_KINDS = ["PLUGIN", "SECRET"]; // superset endpoint requires `kind`; these cover all IntegrationKind values
|
|
2202
|
+
const kinds = filters?.kind?.length ? filters.kind : ALL_INTEGRATION_KINDS;
|
|
2203
|
+
for (const k of kinds) {
|
|
2204
|
+
url.searchParams.append("kind", k);
|
|
2205
2205
|
}
|
|
2206
2206
|
if (filters?.slug) {
|
|
2207
2207
|
for (const s of filters.slug) {
|
package/src/collect-sdk-apis.mts
CHANGED
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
extractIntegrationsFromSource,
|
|
5
5
|
type IntegrationInfo,
|
|
6
6
|
} from "./extract-api-integrations.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { parseSdkRegistryWithExportNames } from "./parse-sdk-registry.mjs";
|
|
8
8
|
|
|
9
9
|
export type SdkApiEntry = {
|
|
10
10
|
entryPoint: string;
|
|
11
|
+
exportName?: string;
|
|
11
12
|
integrations?: IntegrationInfo[];
|
|
12
13
|
};
|
|
13
14
|
|
|
@@ -25,8 +26,8 @@ export type CollectSdkApisFs = {
|
|
|
25
26
|
*
|
|
26
27
|
* @param root - App root directory
|
|
27
28
|
* @param fs - File system operations (pathExists, readFile)
|
|
28
|
-
* @returns Map of API name → { entryPoint, integrations? } or
|
|
29
|
-
* if no registry exists
|
|
29
|
+
* @returns Map of API name → { entryPoint, exportName?, integrations? } or
|
|
30
|
+
* empty object if no registry exists
|
|
30
31
|
*/
|
|
31
32
|
export async function collectSdkApisFromRegistry(
|
|
32
33
|
root: string,
|
|
@@ -39,7 +40,7 @@ export async function collectSdkApisFromRegistry(
|
|
|
39
40
|
|
|
40
41
|
const registryContent = await fs.readFile(sdkRegistryPath, "utf-8");
|
|
41
42
|
const registryDir = path.dirname(sdkRegistryPath);
|
|
42
|
-
const
|
|
43
|
+
const keyToEntry = await parseSdkRegistryWithExportNames(
|
|
43
44
|
registryContent,
|
|
44
45
|
registryDir,
|
|
45
46
|
root,
|
|
@@ -47,9 +48,12 @@ export async function collectSdkApisFromRegistry(
|
|
|
47
48
|
);
|
|
48
49
|
|
|
49
50
|
const sdkApis: SdkApisResult = {};
|
|
50
|
-
for (const [apiName,
|
|
51
|
-
const entry: SdkApiEntry = { entryPoint };
|
|
52
|
-
|
|
51
|
+
for (const [apiName, registryEntry] of keyToEntry) {
|
|
52
|
+
const entry: SdkApiEntry = { entryPoint: registryEntry.entryPoint };
|
|
53
|
+
if (registryEntry.exportName) {
|
|
54
|
+
entry.exportName = registryEntry.exportName;
|
|
55
|
+
}
|
|
56
|
+
const absolutePath = path.join(root, registryEntry.entryPoint);
|
|
53
57
|
|
|
54
58
|
try {
|
|
55
59
|
const source = await fs.readFile(absolutePath, "utf-8");
|
|
@@ -12,6 +12,7 @@ describe("collectSdkApisFromRegistry", () => {
|
|
|
12
12
|
return (
|
|
13
13
|
rel === "server/apis/index.ts" ||
|
|
14
14
|
rel === "server/apis/GetUsers/api.ts" ||
|
|
15
|
+
rel === "server/apis/orders.ts" ||
|
|
15
16
|
rel === "server/apis/v2/GetUsers/api.ts" ||
|
|
16
17
|
rel === "server/apis/CreateOrder/api.ts"
|
|
17
18
|
);
|
|
@@ -104,6 +105,43 @@ export default apis;
|
|
|
104
105
|
});
|
|
105
106
|
});
|
|
106
107
|
|
|
108
|
+
it("captures exportName for named and aliased imports", async () => {
|
|
109
|
+
const registryContent = `
|
|
110
|
+
import { CreateOrder, GetOrders as ListOrders } from './orders.js';
|
|
111
|
+
const apis = { CreateOrder, ListOrders } as const;
|
|
112
|
+
export default apis;
|
|
113
|
+
`;
|
|
114
|
+
const readFile = vi.fn(async (filePath: string) => {
|
|
115
|
+
const rel = path.relative(root, filePath).replace(/\\/g, "/");
|
|
116
|
+
if (rel === "server/apis/index.ts") {
|
|
117
|
+
return registryContent;
|
|
118
|
+
}
|
|
119
|
+
if (rel === "server/apis/orders.ts") {
|
|
120
|
+
return `
|
|
121
|
+
export const CreateOrder = api({});
|
|
122
|
+
export const GetOrders = api({});
|
|
123
|
+
`;
|
|
124
|
+
}
|
|
125
|
+
throw new Error(`Unexpected read: ${rel}`);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const result = await collectSdkApisFromRegistry(root, {
|
|
129
|
+
pathExists,
|
|
130
|
+
readFile,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
expect(result).toEqual({
|
|
134
|
+
CreateOrder: {
|
|
135
|
+
entryPoint: "server/apis/orders.ts",
|
|
136
|
+
exportName: "CreateOrder",
|
|
137
|
+
},
|
|
138
|
+
ListOrders: {
|
|
139
|
+
entryPoint: "server/apis/orders.ts",
|
|
140
|
+
exportName: "GetOrders",
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
107
145
|
it("keeps entryPoint when integration extraction fails", async () => {
|
|
108
146
|
const registryContent = `
|
|
109
147
|
import GetUsers from './GetUsers/api.js';
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
parseSdkRegistryFromContent,
|
|
5
|
+
parseSdkRegistryEntries,
|
|
6
|
+
type RegistryKeyToEntry,
|
|
7
|
+
} from "@superblocksteam/vite-plugin-file-sync/parsing";
|
|
4
8
|
|
|
5
9
|
export type RegistryKeyToPath = Map<string, string>;
|
|
10
|
+
export type { RegistryKeyToEntry };
|
|
6
11
|
|
|
7
12
|
type PathExists = (p: string) => Promise<boolean>;
|
|
8
13
|
const RESOLUTION_EXTENSIONS = [".ts", ".tsx", ".js"] as const;
|
|
@@ -14,6 +19,8 @@ const RESOLUTION_EXTENSIONS = [".ts", ".tsx", ".js"] as const;
|
|
|
14
19
|
*
|
|
15
20
|
* Supports:
|
|
16
21
|
* - import X from './Path/api.js'; const apis = { X }; export default apis;
|
|
22
|
+
* - import { A, B } from './Path/apis.js'; export default { A, B };
|
|
23
|
+
* - import X, { Y } from './Path/apis.js'; export default { X, Y };
|
|
17
24
|
* - const apis = { X: () => import('./Path/api') }; export default apis;
|
|
18
25
|
* - export default { X, Y: () => import('./Path/api') };
|
|
19
26
|
*
|
|
@@ -33,6 +40,21 @@ export async function parseSdkRegistry(
|
|
|
33
40
|
);
|
|
34
41
|
}
|
|
35
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Parse server/apis/index.ts to extract rich metadata including exportName.
|
|
45
|
+
* Used by the build manifest generator to include exportName for named imports.
|
|
46
|
+
*/
|
|
47
|
+
export async function parseSdkRegistryWithExportNames(
|
|
48
|
+
registryContent: string,
|
|
49
|
+
registryDir: string,
|
|
50
|
+
root: string,
|
|
51
|
+
pathExists: PathExists,
|
|
52
|
+
): Promise<RegistryKeyToEntry> {
|
|
53
|
+
return parseSdkRegistryEntries(registryContent, (importPath) =>
|
|
54
|
+
resolveImportPath(importPath, registryDir, root, pathExists),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
36
58
|
async function resolveImportPath(
|
|
37
59
|
importPath: string,
|
|
38
60
|
registryDir: string,
|
|
@@ -13,7 +13,8 @@ describe("parseSdkRegistry", () => {
|
|
|
13
13
|
rel === "server/apis/GetUsers/api.ts" ||
|
|
14
14
|
rel === "server/apis/v2/GetUsers/api.ts" ||
|
|
15
15
|
rel === "server/apis/CreateOrder/api.ts" ||
|
|
16
|
-
rel === "server/apis/JsOnly/api.js"
|
|
16
|
+
rel === "server/apis/JsOnly/api.js" ||
|
|
17
|
+
rel === "server/apis/shared/user-apis.ts"
|
|
17
18
|
);
|
|
18
19
|
};
|
|
19
20
|
|
|
@@ -148,4 +149,21 @@ export default { JsOnly };
|
|
|
148
149
|
expect(result.get("JsOnly")).toBe("server/apis/JsOnly/api.js");
|
|
149
150
|
expect(result.size).toBe(1);
|
|
150
151
|
});
|
|
152
|
+
|
|
153
|
+
it("resolves named imports from a shared entrypoint file", async () => {
|
|
154
|
+
const content = `
|
|
155
|
+
import { GetUsers, CreateOrder } from './shared/user-apis.js';
|
|
156
|
+
const apis = { GetUsers, CreateOrder } as const;
|
|
157
|
+
export default apis;
|
|
158
|
+
`;
|
|
159
|
+
const result = await parseSdkRegistry(
|
|
160
|
+
content,
|
|
161
|
+
registryDir,
|
|
162
|
+
root,
|
|
163
|
+
pathExists,
|
|
164
|
+
);
|
|
165
|
+
expect(result.get("GetUsers")).toBe("server/apis/shared/user-apis.ts");
|
|
166
|
+
expect(result.get("CreateOrder")).toBe("server/apis/shared/user-apis.ts");
|
|
167
|
+
expect(result.size).toBe(2);
|
|
168
|
+
});
|
|
151
169
|
});
|