@zenstackhq/trpc 1.0.0-beta.2 → 1.0.0-beta.21

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/generator.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DMMF } from '@prisma/generator-helper';
1
+ import type { DMMF } from '@prisma/generator-helper';
2
2
  import { PluginOptions } from '@zenstackhq/sdk';
3
3
  import { Model } from '@zenstackhq/sdk/ast';
4
4
  export declare function generate(model: Model, options: PluginOptions, dmmf: DMMF.Document): Promise<void>;
package/generator.js CHANGED
@@ -25,85 +25,129 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.generate = void 0;
27
27
  const sdk_1 = require("@zenstackhq/sdk");
28
- const fs_1 = require("fs");
28
+ const fs_1 = __importDefault(require("fs"));
29
29
  const lower_case_first_1 = require("lower-case-first");
30
30
  const path_1 = __importDefault(require("path"));
31
+ const ts_morph_1 = require("ts-morph");
32
+ const upper_case_first_1 = require("upper-case-first");
31
33
  const _1 = require(".");
32
34
  const helpers_1 = require("./helpers");
33
35
  const project_1 = require("./project");
34
36
  const removeDir_1 = __importDefault(require("./utils/removeDir"));
35
- const generator_1 = require("./zod/generator");
36
37
  function generate(model, options, dmmf) {
38
+ var _a;
37
39
  return __awaiter(this, void 0, void 0, function* () {
38
40
  let outDir = (0, sdk_1.requireOption)(options, 'output');
39
41
  outDir = (0, sdk_1.resolvePath)(outDir, options);
40
42
  // resolve "generateModelActions" option
41
- let generateModelActions = undefined;
42
- if (options.generateModelActions) {
43
- if (typeof options.generateModelActions === 'string') {
44
- // comma separated string
45
- generateModelActions = options.generateModelActions
46
- .split(',')
47
- .filter((i) => !!i)
48
- .map((i) => i.trim());
49
- }
50
- else if (Array.isArray(options.generateModelActions) &&
51
- options.generateModelActions.every((i) => typeof i === 'string')) {
52
- // string array
53
- generateModelActions = options.generateModelActions;
54
- }
55
- else {
56
- throw new sdk_1.PluginError(_1.name, `Invalid "generateModelActions" option: must be a comma-separated string or an array of strings`);
57
- }
43
+ const generateModelActions = parseOptionAsStrings(options, 'generateModelActions');
44
+ // resolve "generateClientHelpers" option
45
+ const generateClientHelpers = parseOptionAsStrings(options, 'generateClientHelpers');
46
+ if (generateClientHelpers && !generateClientHelpers.every((v) => ['react', 'next'].includes(v))) {
47
+ throw new sdk_1.PluginError(_1.name, `Option "generateClientHelpers" only support values "react" and "next"`);
58
48
  }
59
- yield fs_1.promises.mkdir(outDir, { recursive: true });
49
+ if (options.zodSchemasImport && typeof options.zodSchemasImport !== 'string') {
50
+ throw new sdk_1.PluginError(_1.name, `Option "zodSchemasImport" must be a string`);
51
+ }
52
+ yield fs_1.default.promises.mkdir(outDir, { recursive: true });
60
53
  yield (0, removeDir_1.default)(outDir, true);
61
- yield (0, generator_1.generate)(model, options, dmmf);
62
54
  const prismaClientDmmf = dmmf;
63
55
  const modelOperations = prismaClientDmmf.mappings.modelOperations;
64
56
  const models = prismaClientDmmf.datamodel.models;
65
57
  const hiddenModels = [];
66
58
  (0, helpers_1.resolveModelsComments)(models, hiddenModels);
67
- createAppRouter(outDir, modelOperations, hiddenModels, generateModelActions);
59
+ const zodSchemasImport = (_a = options.zodSchemasImport) !== null && _a !== void 0 ? _a : '@zenstackhq/runtime/zod';
60
+ createAppRouter(outDir, modelOperations, hiddenModels, generateModelActions, generateClientHelpers, model, zodSchemasImport);
68
61
  createHelper(outDir);
69
62
  yield (0, sdk_1.saveProject)(project_1.project);
70
63
  });
71
64
  }
72
65
  exports.generate = generate;
73
- function createAppRouter(outDir, modelOperations, hiddenModels, generateModelActions) {
74
- const appRouter = project_1.project.createSourceFile(path_1.default.resolve(outDir, 'routers', `index.ts`), undefined, {
66
+ function createAppRouter(outDir, modelOperations, hiddenModels, generateModelActions, generateClientHelpers, zmodel, zodSchemasImport) {
67
+ const indexFile = path_1.default.resolve(outDir, 'routers', `index.ts`);
68
+ const appRouter = project_1.project.createSourceFile(indexFile, undefined, {
75
69
  overwrite: true,
76
70
  });
77
71
  appRouter.addStatements('/* eslint-disable */');
72
+ const prismaImport = (0, sdk_1.getPrismaClientImportSpec)(zmodel, path_1.default.dirname(indexFile));
78
73
  appRouter.addImportDeclarations([
79
74
  {
80
- namedImports: ['AnyRootConfig'],
75
+ namedImports: ['type AnyRootConfig', 'type Procedure', 'type ProcedureParams', 'type ProcedureType'],
81
76
  moduleSpecifier: '@trpc/server',
82
77
  },
83
78
  {
84
- namedImports: ['PrismaClient'],
85
- moduleSpecifier: '@prisma/client',
79
+ namedImports: ['type PrismaClient', 'type Prisma'],
80
+ moduleSpecifier: prismaImport,
86
81
  },
87
82
  {
88
- namedImports: ['createRouterFactory'],
83
+ namedImports: ['type createRouterFactory', 'AnyRouter'],
89
84
  moduleSpecifier: '@trpc/server/dist/core/router',
90
85
  },
91
86
  {
92
- namedImports: ['createBuilder'],
87
+ namedImports: ['type ProcedureBuilder'],
93
88
  moduleSpecifier: '@trpc/server/dist/core/internals/procedureBuilder',
94
89
  },
90
+ { defaultImport: 'z', moduleSpecifier: 'zod', isTypeOnly: true },
95
91
  ]);
96
92
  appRouter.addStatements(`
93
+ ${ /** to be used by the other routers without making a bigger commit */''}
94
+ export { PrismaClient } from '${prismaImport}';
95
+
97
96
  export type BaseConfig = AnyRootConfig;
98
97
 
99
98
  export type RouterFactory<Config extends BaseConfig> = ReturnType<
100
99
  typeof createRouterFactory<Config>
101
100
  >;
102
101
 
103
- export type ProcBuilder<Config extends BaseConfig> = ReturnType<
104
- typeof createBuilder<Config>
105
- >;
102
+ ${
103
+ /** this is needed in order to prevent type errors between a procedure and a middleware-extended procedure */ ''}
104
+ export type ProcBuilder<Config extends BaseConfig> = ProcedureBuilder<{
105
+ _config: Config;
106
+ _ctx_out: Config['$types']['ctx'];
107
+ _input_in: any;
108
+ _input_out: any;
109
+ _output_in: any;
110
+ _output_out: any;
111
+ _meta: Config['$types']['meta'];
112
+ }>;
113
+
114
+ type ExtractParamsFromProcBuilder<Builder extends ProcedureBuilder<any>> =
115
+ Builder extends ProcedureBuilder<infer P> ? P : never;
106
116
 
117
+ type FromPromise<P extends Promise<any>> = P extends Promise<infer T>
118
+ ? T
119
+ : never;
120
+
121
+ ${ /** workaround to avoid creating 'typeof unsetMarker & object' on the procedure output */''}
122
+ type Join<A, B> = A extends symbol ? B : A & B;
123
+
124
+ ${
125
+ /** you can name it whatever you want, but this is to make sure that
126
+ the types from the middleware and the procedure are correctly merged */ ''}
127
+ export type ProcReturns<
128
+ PType extends ProcedureType,
129
+ PBuilder extends ProcBuilder<BaseConfig>,
130
+ ZType extends z.ZodType,
131
+ PPromise extends Prisma.PrismaPromise<any>
132
+ > = Procedure<
133
+ PType,
134
+ ProcedureParams<
135
+ ExtractParamsFromProcBuilder<PBuilder>["_config"],
136
+ ExtractParamsFromProcBuilder<PBuilder>["_ctx_out"],
137
+ Join<ExtractParamsFromProcBuilder<PBuilder>["_input_in"], z.infer<ZType>>,
138
+ Join<ExtractParamsFromProcBuilder<PBuilder>["_input_out"], z.infer<ZType>>,
139
+ Join<
140
+ ExtractParamsFromProcBuilder<PBuilder>["_output_in"],
141
+ FromPromise<PPromise>
142
+ >,
143
+ Join<
144
+ ExtractParamsFromProcBuilder<PBuilder>["_output_out"],
145
+ FromPromise<PPromise>
146
+ >,
147
+ ExtractParamsFromProcBuilder<PBuilder>["_meta"]
148
+ >
149
+ >;
150
+
107
151
  export function db(ctx: any) {
108
152
  if (!ctx.prisma) {
109
153
  throw new Error('Missing "prisma" field in trpc context');
@@ -112,73 +156,148 @@ function createAppRouter(outDir, modelOperations, hiddenModels, generateModelAct
112
156
  }
113
157
 
114
158
  `);
115
- const createFunction = appRouter.addFunction({
116
- name: 'createRouter<Config extends BaseConfig>',
159
+ const filteredModelOperations = modelOperations.filter((mo) => !hiddenModels.includes(mo.model));
160
+ appRouter
161
+ .addFunction({
162
+ name: 'createRouter<Router extends RouterFactory<BaseConfig>, Proc extends ProcBuilder<BaseConfig>>',
117
163
  parameters: [
118
- { name: 'router', type: 'RouterFactory<Config>' },
119
- { name: 'procedure', type: 'ProcBuilder<Config>' },
164
+ { name: 'router', type: 'Router' },
165
+ { name: 'procedure', type: 'Proc' },
120
166
  ],
121
167
  isExported: true,
122
- });
123
- createFunction.setBodyText((writer) => {
168
+ })
169
+ .setBodyText((writer) => {
124
170
  writer.write('return router(');
125
171
  writer.block(() => {
126
- for (const modelOperation of modelOperations) {
172
+ for (const modelOperation of filteredModelOperations) {
127
173
  const { model } = modelOperation, operations = __rest(modelOperation, ["model"]);
128
- if (hiddenModels.includes(model)) {
129
- continue;
130
- }
131
- generateModelCreateRouter(project_1.project, model, operations, outDir, generateModelActions);
174
+ // "count" operation is missing from Prisma DMMF, add it here
175
+ operations.count = `count${model}`;
176
+ generateModelCreateRouter(project_1.project, model, operations, outDir, generateModelActions, generateClientHelpers, zmodel, zodSchemasImport);
132
177
  appRouter.addImportDeclaration({
133
178
  defaultImport: `create${model}Router`,
134
179
  moduleSpecifier: `./${model}.router`,
135
180
  });
136
- writer.writeLine(`${(0, lower_case_first_1.lowerCaseFirst)(model)}: create${model}Router<Config>(router, procedure),`);
181
+ writer.writeLine(`${(0, lower_case_first_1.lowerCaseFirst)(model)}: create${model}Router<Router, Proc>(router, procedure),`);
137
182
  }
138
183
  });
139
184
  writer.write(');');
140
185
  });
186
+ if (generateClientHelpers) {
187
+ appRouter.addInterface({
188
+ name: 'ClientType',
189
+ typeParameters: ['AppRouter extends AnyRouter'],
190
+ isExported: true,
191
+ properties: filteredModelOperations.map(({ model }) => {
192
+ appRouter.addImportDeclaration({
193
+ namedImports: [{ name: 'ClientType', alias: `${(0, upper_case_first_1.upperCaseFirst)(model)}ClientType` }],
194
+ moduleSpecifier: `./${model}.router`,
195
+ });
196
+ return {
197
+ name: (0, lower_case_first_1.lowerCaseFirst)(model),
198
+ type: `${(0, upper_case_first_1.upperCaseFirst)(model)}ClientType<AppRouter>`,
199
+ };
200
+ }),
201
+ });
202
+ createClientHelpers(outDir, generateClientHelpers);
203
+ }
141
204
  appRouter.formatText();
142
205
  }
143
- function generateModelCreateRouter(project, model, operations, outputDir, generateModelActions) {
206
+ function createClientHelpers(outputDir, generateClientHelpers) {
207
+ const utils = project_1.project.createSourceFile(path_1.default.resolve(outputDir, 'client', `utils.ts`), undefined, {
208
+ overwrite: true,
209
+ });
210
+ utils.replaceWithText(fs_1.default.readFileSync(path_1.default.join(__dirname, './res/client/utils.ts'), 'utf-8'));
211
+ for (const client of generateClientHelpers) {
212
+ switch (client) {
213
+ case 'react': {
214
+ const content = fs_1.default.readFileSync(path_1.default.join(__dirname, './res/client/react.ts'), 'utf-8');
215
+ project_1.project.createSourceFile(path_1.default.resolve(outputDir, 'client', 'react.ts'), content, {
216
+ overwrite: true,
217
+ });
218
+ break;
219
+ }
220
+ case 'next': {
221
+ const content = fs_1.default.readFileSync(path_1.default.join(__dirname, './res/client/next.ts'), 'utf-8');
222
+ project_1.project.createSourceFile(path_1.default.resolve(outputDir, 'client', 'next.ts'), content, { overwrite: true });
223
+ break;
224
+ }
225
+ }
226
+ }
227
+ }
228
+ function generateModelCreateRouter(project, model, operations, outputDir, generateModelActions, generateClientHelpers, zmodel, zodSchemasImport) {
144
229
  const modelRouter = project.createSourceFile(path_1.default.resolve(outputDir, 'routers', `${model}.router.ts`), undefined, {
145
230
  overwrite: true,
146
231
  });
147
232
  modelRouter.addStatements('/* eslint-disable */');
148
233
  modelRouter.addImportDeclarations([
149
234
  {
150
- namedImports: ['type RouterFactory', 'type ProcBuilder', 'type BaseConfig', 'db'],
235
+ namedImports: [
236
+ 'type RouterFactory',
237
+ 'type ProcBuilder',
238
+ 'type BaseConfig',
239
+ 'type ProcReturns',
240
+ 'type PrismaClient',
241
+ 'db',
242
+ ],
151
243
  moduleSpecifier: '.',
152
244
  },
153
245
  ]);
154
- (0, helpers_1.generateRouterSchemaImports)(modelRouter, model);
246
+ (0, helpers_1.generateRouterSchemaImports)(modelRouter, (0, upper_case_first_1.upperCaseFirst)(model), zodSchemasImport);
155
247
  (0, helpers_1.generateHelperImport)(modelRouter);
156
- modelRouter
157
- .addFunction({
158
- name: 'createRouter<Config extends BaseConfig>',
248
+ if (generateClientHelpers) {
249
+ (0, helpers_1.generateRouterTypingImports)(modelRouter, zmodel);
250
+ }
251
+ const createRouterFunc = modelRouter.addFunction({
252
+ name: 'createRouter<Router extends RouterFactory<BaseConfig>, Proc extends ProcBuilder<BaseConfig>>',
159
253
  parameters: [
160
- { name: 'router', type: 'RouterFactory<Config>' },
161
- { name: 'procedure', type: 'ProcBuilder<Config>' },
254
+ { name: 'router', type: 'Router' },
255
+ { name: 'procedure', type: 'Proc' },
162
256
  ],
163
257
  isExported: true,
164
258
  isDefaultExport: true,
165
- })
166
- .setBodyText((writer) => {
167
- writer.write('return router(');
168
- writer.block(() => {
259
+ });
260
+ let routerTypingStructure = undefined;
261
+ if (generateClientHelpers) {
262
+ // generate an interface for precise Prisma-like typing for the router procedures
263
+ // which will be used to correct tRPC's typing on the client side
264
+ routerTypingStructure = {
265
+ kind: ts_morph_1.StructureKind.Interface,
266
+ name: 'ClientType',
267
+ isExported: true,
268
+ typeParameters: ['AppRouter extends AnyRouter', `Context = AppRouter['_def']['_config']['$types']['ctx']`],
269
+ properties: [],
270
+ };
271
+ }
272
+ createRouterFunc.setBodyText((funcWriter) => {
273
+ funcWriter.write('return router(');
274
+ funcWriter.block(() => {
275
+ var _a;
169
276
  for (const [opType, opNameWithModel] of Object.entries(operations)) {
170
277
  const baseOpType = opType.replace('OrThrow', '');
171
- const inputType = (0, helpers_1.getInputTypeByOpName)(baseOpType, model);
278
+ const inputType = (0, helpers_1.getInputSchemaByOpName)(baseOpType, model);
172
279
  const generateOpName = opType.replace(/One$/, '');
173
280
  if (opNameWithModel &&
174
281
  inputType &&
175
282
  (!generateModelActions || generateModelActions.includes(generateOpName))) {
176
- (0, helpers_1.generateProcedure)(writer, generateOpName, inputType, model, baseOpType);
283
+ (0, helpers_1.generateProcedure)(funcWriter, generateOpName, (0, upper_case_first_1.upperCaseFirst)(inputType), model, baseOpType);
284
+ if (routerTypingStructure) {
285
+ (_a = routerTypingStructure.properties) === null || _a === void 0 ? void 0 : _a.push({
286
+ kind: ts_morph_1.StructureKind.PropertySignature,
287
+ name: generateOpName,
288
+ type: (writer) => {
289
+ (0, helpers_1.generateRouterTyping)(writer, generateOpName, model, baseOpType);
290
+ },
291
+ });
292
+ }
177
293
  }
178
294
  }
179
295
  });
180
- writer.write(');');
296
+ funcWriter.write(');');
181
297
  });
298
+ if (routerTypingStructure) {
299
+ modelRouter.addInterface(routerTypingStructure);
300
+ }
182
301
  modelRouter.formatText();
183
302
  }
184
303
  function createHelper(outDir) {
@@ -276,4 +395,24 @@ function createHelper(outDir) {
276
395
  `);
277
396
  checkRead.formatText();
278
397
  }
398
+ function parseOptionAsStrings(options, optionaName) {
399
+ const value = options[optionaName];
400
+ if (value === undefined) {
401
+ return undefined;
402
+ }
403
+ else if (typeof value === 'string') {
404
+ // comma separated string
405
+ return value
406
+ .split(',')
407
+ .filter((i) => !!i)
408
+ .map((i) => i.trim());
409
+ }
410
+ else if (Array.isArray(value) && value.every((i) => typeof i === 'string')) {
411
+ // string array
412
+ return value;
413
+ }
414
+ else {
415
+ throw new sdk_1.PluginError(_1.name, `Invalid "${optionaName}" option: must be a comma-separated string or an array of strings`);
416
+ }
417
+ }
279
418
  //# sourceMappingURL=generator.js.map
package/generator.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAQyB;AAEzB,2BAAoC;AACpC,uDAAkD;AAClD,gDAAwB;AAExB,wBAAyB;AACzB,uCAMmB;AACnB,uCAAoC;AACpC,kEAA0C;AAC1C,+CAAiE;AAEjE,SAAsB,QAAQ,CAAC,KAAY,EAAE,OAAsB,EAAE,IAAmB;;QACpF,IAAI,MAAM,GAAG,IAAA,mBAAa,EAA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AC3B,CAAC;AAED,SAAS,oBAAoB,CAAC,OAAsB,EAAE,WAAmB;IACrE,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACnC,IAAI,KAAK,KAAK,SAAS,EAAE;QACrB,OAAO,SAAS,CAAC;KACpB;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAClC,yBAAyB;QACzB,OAAO,KAAK;aACP,KAAK,CAAC,GAAG,CAAC;aACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;aAClB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;KAC7B;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,EAAE;QAC1E,eAAe;QACf,OAAO,KAAiB,CAAC;KAC5B;SAAM;QACH,MAAM,IAAI,iBAAW,CACjB,OAAI,EACJ,YAAY,WAAW,mEAAmE,CAC7F,CAAC;KACL;AACL,CAAC"}
package/helpers.d.ts CHANGED
@@ -1,8 +1,14 @@
1
- import { DMMF } from '@prisma/generator-helper';
1
+ import type { DMMF } from '@prisma/generator-helper';
2
+ import { Model } from '@zenstackhq/sdk/ast';
2
3
  import { CodeBlockWriter, SourceFile } from 'ts-morph';
3
4
  export declare function generateProcedure(writer: CodeBlockWriter, opType: string, typeName: string, modelName: string, baseOpType: string): void;
4
- export declare function generateRouterSchemaImports(sourceFile: SourceFile, name: string): void;
5
+ /**
6
+ * Generate precise Prisma-like typing for router procedures.
7
+ */
8
+ export declare function generateRouterTyping(writer: CodeBlockWriter, opType: string, modelName: string, baseOpType: string): void;
9
+ export declare function generateRouterTypingImports(sourceFile: SourceFile, model: Model): void;
10
+ export declare function generateRouterSchemaImports(sourceFile: SourceFile, name: string, zodSchemasImport: string): void;
5
11
  export declare function generateHelperImport(sourceFile: SourceFile): void;
6
- export declare const getInputTypeByOpName: (opName: string, modelName: string) => string | undefined;
12
+ export declare const getInputSchemaByOpName: (opName: string, modelName: string) => string | undefined;
7
13
  export declare const getProcedureTypeByOpName: (opName: string) => string | undefined;
8
14
  export declare function resolveModelsComments(models: DMMF.Model[], hiddenModels: string[]): void;