schemock 0.0.4-alpha.13 → 0.0.4-alpha.14

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,7 +1,7 @@
1
- import { A as Adapter, a as AdapterContext, b as AdapterResponse, d as MswjsDataFactory, F as FetchAdapterOptions } from '../types-vPJ91BuY.mjs';
2
- export { c as AdapterResponseMeta, D as Database, M as MockAdapterOptions, S as SchemaRegistry } from '../types-vPJ91BuY.mjs';
3
- import { o as EntitySchema, b as FieldDefinition } from '../types-CWZQ6vqt.mjs';
4
- import { M as Middleware } from '../types-D-u5uw1E.mjs';
1
+ import { A as Adapter, a as AdapterContext, b as AdapterResponse, d as MswjsDataFactory, F as FetchAdapterOptions } from '../types-BBeKlEd1.mjs';
2
+ export { c as AdapterResponseMeta, D as Database, M as MockAdapterOptions, S as SchemaRegistry } from '../types-BBeKlEd1.mjs';
3
+ import { o as EntitySchema, b as FieldDefinition } from '../types-BCLdZDSF.mjs';
4
+ import { M as Middleware } from '../types-DKrOkBcu.mjs';
5
5
 
6
6
  /**
7
7
  * Storage Driver Types - Abstract storage interface for different backends
@@ -1,7 +1,7 @@
1
- import { A as Adapter, a as AdapterContext, b as AdapterResponse, d as MswjsDataFactory, F as FetchAdapterOptions } from '../types-4EDTne0h.js';
2
- export { c as AdapterResponseMeta, D as Database, M as MockAdapterOptions, S as SchemaRegistry } from '../types-4EDTne0h.js';
3
- import { o as EntitySchema, b as FieldDefinition } from '../types-CWZQ6vqt.js';
4
- import { M as Middleware } from '../types-Ku_ykMzx.js';
1
+ import { A as Adapter, a as AdapterContext, b as AdapterResponse, d as MswjsDataFactory, F as FetchAdapterOptions } from '../types-CVeLQjhD.js';
2
+ export { c as AdapterResponseMeta, D as Database, M as MockAdapterOptions, S as SchemaRegistry } from '../types-CVeLQjhD.js';
3
+ import { o as EntitySchema, b as FieldDefinition } from '../types-BCLdZDSF.js';
4
+ import { M as Middleware } from '../types-CZdze7Tl.js';
5
5
 
6
6
  /**
7
7
  * Storage Driver Types - Abstract storage interface for different backends
@@ -1,5 +1,5 @@
1
- import { l as RLSScopeMapping, m as RLSBypass, n as RLSConfig, o as EntitySchema, v as EndpointSchema, b as FieldDefinition } from '../types-CWZQ6vqt.mjs';
2
- export { I as IndexConfig, j as RLSContext, k as RLSFilter, f as RPCArgument, g as RPCConfig } from '../types-CWZQ6vqt.mjs';
1
+ import { l as RLSScopeMapping, m as RLSBypass, n as RLSConfig, o as EntitySchema, v as EndpointSchema, b as FieldDefinition } from '../types-BCLdZDSF.mjs';
2
+ export { I as IndexConfig, j as RLSContext, k as RLSFilter, f as RPCArgument, g as RPCConfig } from '../types-BCLdZDSF.mjs';
3
3
 
4
4
  /**
5
5
  * CLI type definitions for Schemock code generation
@@ -412,6 +412,17 @@ interface AnalyzedEndpointField {
412
412
  /** Enum values if enum type */
413
413
  enumValues?: string[];
414
414
  }
415
+ /**
416
+ * Dependency import for inline resolvers
417
+ */
418
+ interface ResolverDependency {
419
+ /** Identifier name used in the resolver */
420
+ name: string;
421
+ /** Module path to import from */
422
+ from: string;
423
+ /** Whether it's a default import */
424
+ isDefault?: boolean;
425
+ }
415
426
  /**
416
427
  * Fully analyzed endpoint with all computed properties
417
428
  */
@@ -440,6 +451,10 @@ interface AnalyzedEndpoint {
440
451
  mockResolverImportPath?: string;
441
452
  /** Export name in the source file */
442
453
  mockResolverExportName?: string;
454
+ /** Source file path where this endpoint is defined */
455
+ sourceFile?: string;
456
+ /** Dependencies detected in inline resolver (functions used but not defined locally) */
457
+ resolverDependencies?: ResolverDependency[];
443
458
  /** Description */
444
459
  description?: string;
445
460
  }
@@ -1053,4 +1068,4 @@ declare function generateFetchClient(schemas: AnalyzedSchema[], config: FetchAda
1053
1068
  */
1054
1069
  declare function generateFormSchemas(schemas: AnalyzedSchema[]): string;
1055
1070
 
1056
- export { type AnalyzedComputed, type AnalyzedEndpoint, type AnalyzedEndpointField, type AnalyzedField, type AnalyzedIndex, type AnalyzedRLS, type AnalyzedRPC, type AnalyzedRelation, type AnalyzedSchema, type AuthProviderConfig, CodeBuilder, type FakerMapping, type FetchAdapterConfig, type FirebaseAdapterConfig, type FrameworkType, type GenerateOptions, type GenerateSQLOptions, type GenerationTarget, type GraphQLAdapterConfig, type MockAdapterConfig, type PGliteAdapterConfig, type PluralizeConfig, RLSBypass, RLSConfig, RLSScopeMapping, type SQLGeneratorResult, type SchemockConfig, type SupabaseAdapterConfig, type TargetMiddlewareConfig, type TargetType, analyzeSchemas, defineConfig, discoverSchemas, fieldToFakerCall, fieldToTsType, generate, generateClaudeMd, generateCursorRules, generateFetchClient, generateFirebaseClient, generateFormSchemas, generateHooks, generateMockClient, generateMockDb, generateMockHandlers, generateSchemockSection, generateSeed, generateSupabaseClient, generateTypes, getDefaultConfig, getRelativePath, loadConfig, mergeClaudeMdContent, pluralize, primitiveToTs, setupAI, toCamelCase, toPascalCase };
1071
+ export { type AnalyzedComputed, type AnalyzedEndpoint, type AnalyzedEndpointField, type AnalyzedField, type AnalyzedIndex, type AnalyzedRLS, type AnalyzedRPC, type AnalyzedRelation, type AnalyzedSchema, type AuthProviderConfig, CodeBuilder, type FakerMapping, type FetchAdapterConfig, type FirebaseAdapterConfig, type FrameworkType, type GenerateOptions, type GenerateSQLOptions, type GenerationTarget, type GraphQLAdapterConfig, type MockAdapterConfig, type PGliteAdapterConfig, type PluralizeConfig, RLSBypass, RLSConfig, RLSScopeMapping, type ResolverDependency, type SQLGeneratorResult, type SchemockConfig, type SupabaseAdapterConfig, type TargetMiddlewareConfig, type TargetType, analyzeSchemas, defineConfig, discoverSchemas, fieldToFakerCall, fieldToTsType, generate, generateClaudeMd, generateCursorRules, generateFetchClient, generateFirebaseClient, generateFormSchemas, generateHooks, generateMockClient, generateMockDb, generateMockHandlers, generateSchemockSection, generateSeed, generateSupabaseClient, generateTypes, getDefaultConfig, getRelativePath, loadConfig, mergeClaudeMdContent, pluralize, primitiveToTs, setupAI, toCamelCase, toPascalCase };
@@ -1,5 +1,5 @@
1
- import { l as RLSScopeMapping, m as RLSBypass, n as RLSConfig, o as EntitySchema, v as EndpointSchema, b as FieldDefinition } from '../types-CWZQ6vqt.js';
2
- export { I as IndexConfig, j as RLSContext, k as RLSFilter, f as RPCArgument, g as RPCConfig } from '../types-CWZQ6vqt.js';
1
+ import { l as RLSScopeMapping, m as RLSBypass, n as RLSConfig, o as EntitySchema, v as EndpointSchema, b as FieldDefinition } from '../types-BCLdZDSF.js';
2
+ export { I as IndexConfig, j as RLSContext, k as RLSFilter, f as RPCArgument, g as RPCConfig } from '../types-BCLdZDSF.js';
3
3
 
4
4
  /**
5
5
  * CLI type definitions for Schemock code generation
@@ -412,6 +412,17 @@ interface AnalyzedEndpointField {
412
412
  /** Enum values if enum type */
413
413
  enumValues?: string[];
414
414
  }
415
+ /**
416
+ * Dependency import for inline resolvers
417
+ */
418
+ interface ResolverDependency {
419
+ /** Identifier name used in the resolver */
420
+ name: string;
421
+ /** Module path to import from */
422
+ from: string;
423
+ /** Whether it's a default import */
424
+ isDefault?: boolean;
425
+ }
415
426
  /**
416
427
  * Fully analyzed endpoint with all computed properties
417
428
  */
@@ -440,6 +451,10 @@ interface AnalyzedEndpoint {
440
451
  mockResolverImportPath?: string;
441
452
  /** Export name in the source file */
442
453
  mockResolverExportName?: string;
454
+ /** Source file path where this endpoint is defined */
455
+ sourceFile?: string;
456
+ /** Dependencies detected in inline resolver (functions used but not defined locally) */
457
+ resolverDependencies?: ResolverDependency[];
443
458
  /** Description */
444
459
  description?: string;
445
460
  }
@@ -1053,4 +1068,4 @@ declare function generateFetchClient(schemas: AnalyzedSchema[], config: FetchAda
1053
1068
  */
1054
1069
  declare function generateFormSchemas(schemas: AnalyzedSchema[]): string;
1055
1070
 
1056
- export { type AnalyzedComputed, type AnalyzedEndpoint, type AnalyzedEndpointField, type AnalyzedField, type AnalyzedIndex, type AnalyzedRLS, type AnalyzedRPC, type AnalyzedRelation, type AnalyzedSchema, type AuthProviderConfig, CodeBuilder, type FakerMapping, type FetchAdapterConfig, type FirebaseAdapterConfig, type FrameworkType, type GenerateOptions, type GenerateSQLOptions, type GenerationTarget, type GraphQLAdapterConfig, type MockAdapterConfig, type PGliteAdapterConfig, type PluralizeConfig, RLSBypass, RLSConfig, RLSScopeMapping, type SQLGeneratorResult, type SchemockConfig, type SupabaseAdapterConfig, type TargetMiddlewareConfig, type TargetType, analyzeSchemas, defineConfig, discoverSchemas, fieldToFakerCall, fieldToTsType, generate, generateClaudeMd, generateCursorRules, generateFetchClient, generateFirebaseClient, generateFormSchemas, generateHooks, generateMockClient, generateMockDb, generateMockHandlers, generateSchemockSection, generateSeed, generateSupabaseClient, generateTypes, getDefaultConfig, getRelativePath, loadConfig, mergeClaudeMdContent, pluralize, primitiveToTs, setupAI, toCamelCase, toPascalCase };
1071
+ export { type AnalyzedComputed, type AnalyzedEndpoint, type AnalyzedEndpointField, type AnalyzedField, type AnalyzedIndex, type AnalyzedRLS, type AnalyzedRPC, type AnalyzedRelation, type AnalyzedSchema, type AuthProviderConfig, CodeBuilder, type FakerMapping, type FetchAdapterConfig, type FirebaseAdapterConfig, type FrameworkType, type GenerateOptions, type GenerateSQLOptions, type GenerationTarget, type GraphQLAdapterConfig, type MockAdapterConfig, type PGliteAdapterConfig, type PluralizeConfig, RLSBypass, RLSConfig, RLSScopeMapping, type ResolverDependency, type SQLGeneratorResult, type SchemockConfig, type SupabaseAdapterConfig, type TargetMiddlewareConfig, type TargetType, analyzeSchemas, defineConfig, discoverSchemas, fieldToFakerCall, fieldToTsType, generate, generateClaudeMd, generateCursorRules, generateFetchClient, generateFirebaseClient, generateFormSchemas, generateHooks, generateMockClient, generateMockDb, generateMockHandlers, generateSchemockSection, generateSeed, generateSupabaseClient, generateTypes, getDefaultConfig, getRelativePath, loadConfig, mergeClaudeMdContent, pluralize, primitiveToTs, setupAI, toCamelCase, toPascalCase };
package/dist/cli/index.js CHANGED
@@ -1230,8 +1230,141 @@ function topologicalSort(schemas) {
1230
1230
  }
1231
1231
  return sorted;
1232
1232
  }
1233
-
1234
- // src/cli/analyze-endpoints.ts
1233
+ var importCache = /* @__PURE__ */ new Map();
1234
+ function parseImportsFromFile(filePath) {
1235
+ if (importCache.has(filePath)) {
1236
+ return importCache.get(filePath);
1237
+ }
1238
+ const imports = /* @__PURE__ */ new Map();
1239
+ try {
1240
+ const content = fs.readFileSync(filePath, "utf-8");
1241
+ const importRegex = /import\s+(?:(?:(\w+)(?:\s*,\s*)?)?(?:\{([^}]+)\})?\s+from\s+)?['"]([^'"]+)['"]/g;
1242
+ let match;
1243
+ while ((match = importRegex.exec(content)) !== null) {
1244
+ const [, defaultImport, namedImports, modulePath] = match;
1245
+ if (defaultImport) {
1246
+ imports.set(defaultImport, modulePath);
1247
+ }
1248
+ if (namedImports) {
1249
+ const names = namedImports.split(",").map((s) => s.trim());
1250
+ for (const name of names) {
1251
+ const asMatch = name.match(/(\w+)\s+as\s+(\w+)/);
1252
+ if (asMatch) {
1253
+ imports.set(asMatch[2], modulePath);
1254
+ } else if (name && /^\w+$/.test(name)) {
1255
+ imports.set(name, modulePath);
1256
+ }
1257
+ }
1258
+ }
1259
+ }
1260
+ } catch (error) {
1261
+ console.warn(`Warning: Could not parse imports from ${filePath}`);
1262
+ }
1263
+ importCache.set(filePath, imports);
1264
+ return imports;
1265
+ }
1266
+ function detectUsedIdentifiers(functionSource) {
1267
+ const withoutStrings = functionSource.replace(/'[^']*'/g, "").replace(/"[^"]*"/g, "").replace(/`[^`]*`/g, "");
1268
+ const identifiers = /* @__PURE__ */ new Set();
1269
+ const callRegex = /\b([A-Z][a-zA-Z0-9]*|[a-z][a-zA-Z0-9]*)\s*\(/g;
1270
+ let match;
1271
+ while ((match = callRegex.exec(withoutStrings)) !== null) {
1272
+ const name = match[1];
1273
+ if (!isBuiltIn(name) && !isContextProperty(name)) {
1274
+ identifiers.add(name);
1275
+ }
1276
+ }
1277
+ const newRegex = /\bnew\s+([A-Z][a-zA-Z0-9]*)/g;
1278
+ while ((match = newRegex.exec(withoutStrings)) !== null) {
1279
+ const name = match[1];
1280
+ if (!isBuiltIn(name)) {
1281
+ identifiers.add(name);
1282
+ }
1283
+ }
1284
+ const throwRegex = /\bthrow\s+new\s+([A-Z][a-zA-Z0-9]*)/g;
1285
+ while ((match = throwRegex.exec(withoutStrings)) !== null) {
1286
+ identifiers.add(match[1]);
1287
+ }
1288
+ return Array.from(identifiers);
1289
+ }
1290
+ function isBuiltIn(name) {
1291
+ const builtIns = /* @__PURE__ */ new Set([
1292
+ // Functions
1293
+ "console",
1294
+ "JSON",
1295
+ "Object",
1296
+ "Array",
1297
+ "String",
1298
+ "Number",
1299
+ "Boolean",
1300
+ "Date",
1301
+ "Math",
1302
+ "Promise",
1303
+ "Map",
1304
+ "Set",
1305
+ "WeakMap",
1306
+ "WeakSet",
1307
+ "parseInt",
1308
+ "parseFloat",
1309
+ "isNaN",
1310
+ "isFinite",
1311
+ "fetch",
1312
+ "setTimeout",
1313
+ "setInterval",
1314
+ "clearTimeout",
1315
+ "clearInterval",
1316
+ // Errors
1317
+ "Error",
1318
+ "TypeError",
1319
+ "ReferenceError",
1320
+ "SyntaxError",
1321
+ "RangeError",
1322
+ // Common methods that look like function calls
1323
+ "toString",
1324
+ "valueOf",
1325
+ "hasOwnProperty",
1326
+ "length",
1327
+ "push",
1328
+ "pop",
1329
+ "map",
1330
+ "filter",
1331
+ "reduce",
1332
+ "find",
1333
+ "findIndex",
1334
+ "some",
1335
+ "every",
1336
+ "includes",
1337
+ "indexOf",
1338
+ "slice",
1339
+ "splice",
1340
+ "concat",
1341
+ "join",
1342
+ "split"
1343
+ ]);
1344
+ return builtIns.has(name);
1345
+ }
1346
+ function isContextProperty(name) {
1347
+ const contextProps = /* @__PURE__ */ new Set([
1348
+ "params",
1349
+ "body",
1350
+ "db",
1351
+ "headers",
1352
+ "ctx",
1353
+ // Common db methods
1354
+ "findMany",
1355
+ "findFirst",
1356
+ "findUnique",
1357
+ "create",
1358
+ "update",
1359
+ "delete",
1360
+ "count",
1361
+ "getAll",
1362
+ "deleteMany",
1363
+ "updateMany",
1364
+ "upsert"
1365
+ ]);
1366
+ return contextProps.has(name);
1367
+ }
1235
1368
  function analyzeEndpoints(endpoints, endpointFiles) {
1236
1369
  return endpoints.map((endpoint) => analyzeEndpoint(endpoint, endpointFiles));
1237
1370
  }
@@ -1243,16 +1376,32 @@ function analyzeEndpoint(endpoint, endpointFiles) {
1243
1376
  const body = analyzeFields(endpoint.body);
1244
1377
  const response = analyzeFields(endpoint.response);
1245
1378
  const mockResolverSource = serializeMockResolver(endpoint.mockResolver);
1379
+ const sourceFile = endpointFiles?.get(endpoint.path);
1246
1380
  const resolverName = endpoint.mockResolver.name;
1247
1381
  const isNamedFunction = resolverName && !resolverName.startsWith("bound ") && resolverName !== "mockResolver";
1248
1382
  let mockResolverName;
1249
1383
  let mockResolverImportPath;
1384
+ let resolverDependencies;
1250
1385
  if (isNamedFunction) {
1251
1386
  mockResolverName = resolverName;
1252
- const sourceFile = endpointFiles?.get(endpoint.path);
1253
1387
  if (sourceFile) {
1254
1388
  mockResolverImportPath = sourceFile;
1255
1389
  }
1390
+ } else if (sourceFile) {
1391
+ const usedIdentifiers = detectUsedIdentifiers(mockResolverSource);
1392
+ if (usedIdentifiers.length > 0) {
1393
+ const fileImports = parseImportsFromFile(sourceFile);
1394
+ const deps = [];
1395
+ for (const identifier of usedIdentifiers) {
1396
+ const importPath = fileImports.get(identifier);
1397
+ if (importPath) {
1398
+ deps.push({ name: identifier, from: importPath });
1399
+ }
1400
+ }
1401
+ if (deps.length > 0) {
1402
+ resolverDependencies = deps;
1403
+ }
1404
+ }
1256
1405
  }
1257
1406
  return {
1258
1407
  path: endpoint.path,
@@ -1266,6 +1415,8 @@ function analyzeEndpoint(endpoint, endpointFiles) {
1266
1415
  mockResolverSource,
1267
1416
  mockResolverName,
1268
1417
  mockResolverImportPath,
1418
+ sourceFile,
1419
+ resolverDependencies,
1269
1420
  description: endpoint.description
1270
1421
  };
1271
1422
  }
@@ -3041,9 +3192,35 @@ function generateEndpointResolvers(endpoints, outputDir) {
3041
3192
  code.comment("");
3042
3193
  code.comment("These resolvers are copied from your defineEndpoint() calls.");
3043
3194
  code.comment("They receive { params, body, db, headers } and return the response.");
3195
+ code.comment("");
3196
+ code.comment("NOTE: If your inline resolvers use external functions (e.g., hashPassword, generateToken),");
3197
+ code.comment("consider using named exported functions instead - they will be automatically imported.");
3198
+ code.line();
3199
+ code.line("import type { Database } from './db';");
3200
+ code.line();
3201
+ code.comment("Resolver context with typed database access");
3202
+ code.block("export interface ResolverContext {", () => {
3203
+ code.line("params: Record<string, unknown>;");
3204
+ code.line("body: Record<string, unknown>;");
3205
+ code.line("db: Database;");
3206
+ code.line("headers: Record<string, string>;");
3207
+ });
3208
+ code.line();
3209
+ code.comment("Error class for HTTP errors in resolvers");
3210
+ code.block("export class HttpError extends Error {", () => {
3211
+ code.line("readonly status: number;");
3212
+ code.line("readonly code?: string;");
3213
+ code.line();
3214
+ code.block("constructor(message: string, status: number, code?: string) {", () => {
3215
+ code.line("super(message);");
3216
+ code.line('this.name = "HttpError";');
3217
+ code.line("this.status = status;");
3218
+ code.line("this.code = code;");
3219
+ });
3220
+ });
3044
3221
  code.line();
3045
- code.line("import type { MockResolverContext } from 'schemock/schema';");
3046
3222
  const externalResolvers = /* @__PURE__ */ new Map();
3223
+ const inlineDependencies = /* @__PURE__ */ new Map();
3047
3224
  for (const endpoint of endpoints) {
3048
3225
  if (endpoint.mockResolverName && endpoint.mockResolverImportPath) {
3049
3226
  const key = `${endpoint.mockResolverImportPath}:${endpoint.mockResolverName}`;
@@ -3054,7 +3231,37 @@ function generateEndpointResolvers(endpoints, outputDir) {
3054
3231
  });
3055
3232
  }
3056
3233
  }
3234
+ if (endpoint.resolverDependencies) {
3235
+ for (const dep of endpoint.resolverDependencies) {
3236
+ const key = `${dep.from}:${dep.name}`;
3237
+ if (!inlineDependencies.has(key)) {
3238
+ inlineDependencies.set(key, {
3239
+ name: dep.name,
3240
+ importPath: dep.from
3241
+ });
3242
+ }
3243
+ }
3244
+ }
3057
3245
  }
3246
+ const calculateRelativePath = (importPath) => {
3247
+ let relativePath = importPath;
3248
+ if (outputDir) {
3249
+ const toPosix = (p) => p.replace(/\\/g, "/");
3250
+ const from = toPosix(outputDir);
3251
+ const to = toPosix(importPath);
3252
+ const fromParts = from.split("/").filter(Boolean);
3253
+ const toParts = to.split("/").filter(Boolean);
3254
+ while (fromParts.length && toParts.length && fromParts[0] === toParts[0]) {
3255
+ fromParts.shift();
3256
+ toParts.shift();
3257
+ }
3258
+ let rel = "../".repeat(fromParts.length) + toParts.join("/");
3259
+ if (!rel.startsWith(".") && rel !== "") rel = "./" + rel;
3260
+ rel = rel.replace(/\.(ts|js)$/, "");
3261
+ relativePath = rel;
3262
+ }
3263
+ return relativePath;
3264
+ };
3058
3265
  if (externalResolvers.size > 0) {
3059
3266
  code.line();
3060
3267
  code.comment("External resolver imports");
@@ -3066,27 +3273,29 @@ function generateEndpointResolvers(endpoints, outputDir) {
3066
3273
  importsByPath.get(importPath).push(name);
3067
3274
  }
3068
3275
  for (const [importPath, names] of importsByPath) {
3069
- let relativePath = importPath;
3070
- if (outputDir) {
3071
- const toPosix = (p) => p.replace(/\\/g, "/");
3072
- const from = toPosix(outputDir);
3073
- const to = toPosix(importPath);
3074
- const fromParts = from.split("/").filter(Boolean);
3075
- const toParts = to.split("/").filter(Boolean);
3076
- while (fromParts.length && toParts.length && fromParts[0] === toParts[0]) {
3077
- fromParts.shift();
3078
- toParts.shift();
3079
- }
3080
- let rel = "../".repeat(fromParts.length) + toParts.join("/");
3081
- if (!rel.startsWith(".") && rel !== "") rel = "./" + rel;
3082
- rel = rel.replace(/\.(ts|js)$/, "");
3083
- relativePath = rel;
3084
- }
3276
+ const relativePath = calculateRelativePath(importPath);
3085
3277
  code.line(`import { ${names.join(", ")} } from '${relativePath}';`);
3086
3278
  }
3087
3279
  }
3280
+ if (inlineDependencies.size > 0) {
3281
+ code.line();
3282
+ code.comment("Dependencies used by inline resolvers");
3283
+ const importsByPath = /* @__PURE__ */ new Map();
3284
+ for (const { name, importPath } of inlineDependencies.values()) {
3285
+ if (!importsByPath.has(importPath)) {
3286
+ importsByPath.set(importPath, []);
3287
+ }
3288
+ const names = importsByPath.get(importPath);
3289
+ if (!names.includes(name)) {
3290
+ names.push(name);
3291
+ }
3292
+ }
3293
+ for (const [importPath, names] of importsByPath) {
3294
+ code.line(`import { ${names.join(", ")} } from '${importPath}';`);
3295
+ }
3296
+ }
3088
3297
  code.line();
3089
- code.line("type ResolverFn = (ctx: MockResolverContext) => unknown | Promise<unknown>;");
3298
+ code.line("type ResolverFn = (ctx: ResolverContext) => unknown | Promise<unknown>;");
3090
3299
  code.line();
3091
3300
  code.block("export const endpointResolvers: Record<string, ResolverFn> = {", () => {
3092
3301
  for (const endpoint of endpoints) {