@suss/packs 0.12.0 → 0.13.0

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/dist/mongoose.js CHANGED
@@ -1,377 +1,156 @@
1
1
  // ../framework/mongoose/dist/index.js
2
2
  import {
3
- Node as N
4
- } from "ts-morph";
5
- import { methodDeclaredIn } from "@suss/adapter-typescript";
6
- import { storageBinding } from "@suss/behavioral-ir";
7
- var RECOGNITION = "@suss/framework-mongoose";
8
- var STORAGE_SYSTEM = "mongodb";
9
- var METHODS = {
10
- find: { kind: "read", filterArg: 0, projectionArg: 1 },
11
- findOne: { kind: "read", filterArg: 0, projectionArg: 1 },
12
- findById: { kind: "read", idArg: 0, projectionArg: 1 },
13
- countDocuments: { kind: "read", filterArg: 0 },
14
- exists: { kind: "read", filterArg: 0 },
15
- distinct: { kind: "read", fieldArg: 0, filterArg: 1 },
16
- create: { kind: "write", payloadArg: 0 },
17
- insertMany: { kind: "write", payloadArg: 0 },
18
- updateOne: { kind: "write", filterArg: 0, updateArg: 1 },
19
- updateMany: { kind: "write", filterArg: 0, updateArg: 1 },
20
- replaceOne: { kind: "write", filterArg: 0, payloadArg: 1 },
21
- deleteOne: { kind: "write", filterArg: 0 },
22
- deleteMany: { kind: "write", filterArg: 0 },
23
- findOneAndUpdate: { kind: "write", filterArg: 0, updateArg: 1 },
24
- findByIdAndUpdate: { kind: "write", idArg: 0, updateArg: 1 },
25
- findOneAndDelete: { kind: "write", filterArg: 0 },
26
- findByIdAndDelete: { kind: "write", idArg: 0 },
27
- findOneAndReplace: { kind: "write", filterArg: 0, payloadArg: 1 }
3
+ constructedFrom,
4
+ declaredBy,
5
+ pack,
6
+ storageCalls
7
+ } from "@suss/recognize";
8
+ var CLIENT_MODULE = "mongoose";
9
+ var WHOLE_DOCUMENT = ["*"];
10
+ var BY_ID = ["_id"];
11
+ var FILTER_KEYS = ({ input }) => keysOf(input);
12
+ var PROJECTED = ({ input }) => {
13
+ const written = input.text();
14
+ if (written !== null) {
15
+ return namedInProjection(written);
16
+ }
17
+ const asked = keysOf(input, asksForIt);
18
+ return asked.length > 0 ? asked : WHOLE_DOCUMENT;
28
19
  };
29
- function defaultCollectionName(modelName) {
30
- const lower = modelName.toLowerCase();
31
- if (/[^aeiou]y$/.test(lower)) {
32
- return `${lower.slice(0, -1)}ies`;
33
- }
34
- if (/(s|x|z|ch|sh)$/.test(lower)) {
35
- return `${lower}es`;
36
- }
37
- return `${lower}s`;
38
- }
39
- function resolveModelIdentity(node, resolve) {
40
- if (N.isCallExpression(node)) {
41
- return modelIdentityFromModelCall(node, resolve);
42
- }
43
- if (!N.isIdentifier(node)) {
44
- return null;
45
- }
46
- const symbol = node.getSymbol();
47
- if (symbol === void 0) {
48
- return null;
49
- }
50
- for (const decl of symbol.getDeclarations()) {
51
- const identity = modelIdentityFromDeclaration(decl, resolve);
52
- if (identity !== null) {
53
- return identity;
54
- }
55
- }
56
- return null;
57
- }
58
- function modelIdentityFromDeclaration(decl, resolve) {
59
- if (N.isImportSpecifier(decl)) {
60
- const symbol = decl.getNameNode().getSymbol();
61
- for (const target of symbol?.getAliasedSymbol()?.getDeclarations() ?? []) {
62
- const identity = modelIdentityFromDeclaration(target, resolve);
63
- if (identity !== null) {
64
- return identity;
65
- }
66
- }
67
- return null;
68
- }
69
- if (!N.isVariableDeclaration(decl)) {
70
- return null;
71
- }
72
- const init = decl.getInitializer();
73
- if (init === void 0 || !N.isCallExpression(init)) {
74
- return null;
75
- }
76
- return modelIdentityFromModelCall(init, resolve);
77
- }
78
- function modelIdentityFromModelCall(call, resolve) {
79
- const callee = call.getExpression();
80
- if (!isModelFactoryCall(callee, resolve)) {
81
- return null;
82
- }
83
- const args = call.getArguments();
84
- const modelName = literalString(args[0]);
85
- if (modelName === null) {
86
- return null;
87
- }
88
- const explicitCollection = literalString(args[2]);
89
- const schemaCollection = explicitCollection === null ? collectionFromSchemaArg(args[1]) : null;
90
- const collection = explicitCollection ?? schemaCollection ?? defaultCollectionName(modelName);
91
- return { modelName, collection };
92
- }
93
- function isModelFactoryCall(callee, resolve) {
94
- if (N.isPropertyAccessExpression(callee)) {
95
- return callee.getName() === "model" && methodDeclaredIn(callee, "mongoose", resolve);
96
- }
97
- return N.isIdentifier(callee) && isImportedAs(callee, "mongoose", "model");
98
- }
99
- function isImportedAs(identifier, module, exportName) {
100
- const symbol = identifier.getSymbol();
101
- if (symbol === void 0) {
102
- return false;
103
- }
104
- for (const decl of symbol.getDeclarations()) {
105
- if (N.isImportSpecifier(decl) && decl.getName() === exportName && decl.getImportDeclaration().getModuleSpecifierValue() === module) {
106
- return true;
107
- }
108
- }
109
- return false;
110
- }
111
- function collectionFromSchemaArg(schemaArg) {
112
- if (schemaArg === void 0) {
113
- return null;
114
- }
115
- const ctor = schemaConstructorOf(schemaArg);
116
- const optionsArg = ctor?.getArguments()[1];
117
- if (optionsArg === void 0 || !N.isObjectLiteralExpression(optionsArg)) {
118
- return null;
119
- }
120
- for (const prop of optionsArg.getProperties()) {
121
- if (N.isPropertyAssignment(prop) && prop.getName() === "collection") {
122
- return literalString(prop.getInitializer());
123
- }
124
- }
125
- return null;
126
- }
127
- function schemaConstructorOf(node) {
128
- if (N.isNewExpression(node)) {
129
- return node;
130
- }
131
- if (!N.isIdentifier(node)) {
132
- return null;
133
- }
134
- const symbol = node.getSymbol();
135
- for (const decl of symbol?.getDeclarations() ?? []) {
136
- if (!N.isVariableDeclaration(decl)) {
20
+ var UPDATED = ({ input }) => {
21
+ const touched = /* @__PURE__ */ new Set();
22
+ for (const entry of input.entries("nothing")) {
23
+ if (entry.key === null) {
137
24
  continue;
138
25
  }
139
- const init = decl.getInitializer();
140
- if (init !== void 0 && N.isNewExpression(init)) {
141
- return init;
142
- }
143
- }
144
- return null;
145
- }
146
- function resolveDocumentModelIdentity(node, resolve) {
147
- if (N.isNewExpression(node)) {
148
- return resolveModelIdentity(node.getExpression(), resolve);
149
- }
150
- if (N.isAwaitExpression(node) || N.isParenthesizedExpression(node)) {
151
- return resolveDocumentModelIdentity(node.getExpression(), resolve);
152
- }
153
- if (N.isCallExpression(node)) {
154
- const callee = node.getExpression();
155
- if (!N.isPropertyAccessExpression(callee) || !(callee.getName() in METHODS)) {
156
- return null;
157
- }
158
- return resolveModelIdentity(callee.getExpression(), resolve);
159
- }
160
- if (!N.isIdentifier(node)) {
161
- return null;
162
- }
163
- const symbol = node.getSymbol();
164
- for (const decl of symbol?.getDeclarations() ?? []) {
165
- if (!N.isVariableDeclaration(decl)) {
26
+ if (!entry.key.startsWith(OPERATOR_PREFIX)) {
27
+ touched.add(entry.key);
166
28
  continue;
167
29
  }
168
- const init = decl.getInitializer();
169
- const identity = init === void 0 ? null : resolveDocumentModelIdentity(init, resolve);
170
- if (identity !== null) {
171
- return identity;
30
+ for (const name of keysOf(entry.value)) {
31
+ touched.add(name);
172
32
  }
173
33
  }
174
- return null;
175
- }
176
- function literalString(node) {
177
- if (node === void 0) {
178
- return null;
179
- }
180
- return N.isStringLiteral(node) || N.isNoSubstitutionTemplateLiteral(node) ? node.getLiteralValue() : null;
181
- }
182
- function readObjectArg(arg) {
183
- if (arg === null || arg === void 0 || typeof arg !== "object") {
184
- return null;
185
- }
186
- return arg.kind === "object" ? arg : null;
187
- }
188
- function isTruthyLiteral(value) {
189
- if (value === null || typeof value !== "object") {
190
- return false;
191
- }
192
- if (value.kind === "number") {
193
- return value.value !== 0;
194
- }
195
- return value.kind === "boolean" && value.value;
196
- }
197
- function projectionFromString(text) {
198
- const included = text.trim().split(/\s+/).filter((term) => term.length > 0 && !term.startsWith("-")).map((term) => term.replace(/^\+/, ""));
199
- return included.length > 0 ? included : ["*"];
200
- }
201
- function projectionFields(arg) {
202
- if (arg !== null && typeof arg === "object" && arg.kind === "string") {
203
- return projectionFromString(arg.value);
204
- }
205
- const object = readObjectArg(arg);
206
- if (object === null) {
207
- return ["*"];
208
- }
209
- const included = Object.entries(object.fields).filter(([, value]) => isTruthyLiteral(value)).map(([key]) => key);
210
- return included.length > 0 ? included : ["*"];
211
- }
212
- function updateFields(arg) {
213
- const object = readObjectArg(arg);
214
- if (object === null) {
215
- return ["*"];
34
+ return touched.size > 0 ? [...touched] : WHOLE_DOCUMENT;
35
+ };
36
+ var PAYLOAD = ({ input }) => {
37
+ const documents = input.items();
38
+ if (documents.length === 0) {
39
+ const written = keysOf(input);
40
+ return written.length > 0 ? written : WHOLE_DOCUMENT;
216
41
  }
217
- const fields = /* @__PURE__ */ new Set();
218
- for (const [key, value] of Object.entries(object.fields)) {
219
- if (!key.startsWith("$")) {
220
- fields.add(key);
221
- continue;
42
+ const union = /* @__PURE__ */ new Set();
43
+ for (const document of documents) {
44
+ const written = keysOf(document);
45
+ if (written.length === 0) {
46
+ return WHOLE_DOCUMENT;
222
47
  }
223
- const operand = readObjectArg(value);
224
- for (const inner of Object.keys(operand?.fields ?? {})) {
225
- fields.add(inner);
48
+ for (const name of written) {
49
+ union.add(name);
226
50
  }
227
51
  }
228
- return fields.size > 0 ? [...fields] : ["*"];
52
+ return [...union];
53
+ };
54
+ var OPERATOR_PREFIX = "$";
55
+ function asksForIt(value) {
56
+ return value.flag() === true;
229
57
  }
230
- function payloadFields(arg) {
231
- const object = readObjectArg(arg);
232
- if (object !== null) {
233
- const keys = Object.keys(object.fields);
234
- return keys.length > 0 ? keys : ["*"];
235
- }
236
- if (arg === null || arg === void 0 || typeof arg !== "object" || arg.kind !== "array") {
237
- return ["*"];
238
- }
239
- const union = /* @__PURE__ */ new Set();
240
- for (const item of arg.items) {
241
- const row = readObjectArg(item);
242
- if (row === null) {
243
- return ["*"];
244
- }
245
- for (const key of Object.keys(row.fields)) {
246
- union.add(key);
58
+ function keysOf(value, keep = () => true) {
59
+ const found = [];
60
+ for (const entry of value.entries("nothing")) {
61
+ if (entry.key !== null && keep(entry.value)) {
62
+ found.push(entry.key);
247
63
  }
248
64
  }
249
- return union.size > 0 ? [...union] : ["*"];
65
+ return found;
250
66
  }
251
- function distinctField(arg) {
252
- return arg !== null && typeof arg === "object" && arg.kind === "string" ? [arg.value] : [];
67
+ function namedInProjection(written) {
68
+ const asked = written.trim().split(/\s+/).filter((term) => term.length > 0 && !term.startsWith("-")).map((term) => term.replace(/^\+/, ""));
69
+ return asked.length > 0 ? asked : WHOLE_DOCUMENT;
253
70
  }
254
- function fieldsOf(spec, args) {
255
- if (spec.projectionArg !== void 0) {
256
- return projectionFields(args[spec.projectionArg]);
257
- }
258
- if (spec.updateArg !== void 0) {
259
- return updateFields(args[spec.updateArg]);
260
- }
261
- if (spec.payloadArg !== void 0) {
262
- return payloadFields(args[spec.payloadArg]);
263
- }
264
- if (spec.fieldArg !== void 0) {
265
- return distinctField(args[spec.fieldArg]);
71
+ var filter = (at) => ({ of: { at }, by: FILTER_KEYS });
72
+ var projection = (at) => ({ of: { at }, by: PROJECTED });
73
+ var update = (at) => ({ of: { at }, by: UPDATED });
74
+ var payload = (at) => ({ of: { at }, by: PAYLOAD });
75
+ var METHODS = {
76
+ find: { kind: "read", selector: filter(0), fields: projection(1) },
77
+ findOne: { kind: "read", selector: filter(0), fields: projection(1) },
78
+ findById: { kind: "read", selector: BY_ID, fields: projection(1) },
79
+ countDocuments: { kind: "read", selector: filter(0) },
80
+ exists: { kind: "read", selector: filter(0) },
81
+ distinct: { kind: "read", selector: filter(1), fields: { at: 0 } },
82
+ create: { kind: "write", fields: payload(0) },
83
+ insertMany: { kind: "write", fields: payload(0) },
84
+ updateOne: { kind: "write", selector: filter(0), fields: update(1) },
85
+ updateMany: { kind: "write", selector: filter(0), fields: update(1) },
86
+ replaceOne: { kind: "write", selector: filter(0), fields: payload(1) },
87
+ deleteOne: { kind: "write", selector: filter(0), fields: WHOLE_DOCUMENT },
88
+ deleteMany: { kind: "write", selector: filter(0), fields: WHOLE_DOCUMENT },
89
+ findOneAndUpdate: { kind: "write", selector: filter(0), fields: update(1) },
90
+ findByIdAndUpdate: { kind: "write", selector: BY_ID, fields: update(1) },
91
+ findOneAndDelete: {
92
+ kind: "write",
93
+ selector: filter(0),
94
+ fields: WHOLE_DOCUMENT
95
+ },
96
+ findByIdAndDelete: { kind: "write", selector: BY_ID, fields: WHOLE_DOCUMENT },
97
+ findOneAndReplace: { kind: "write", selector: filter(0), fields: payload(1) },
98
+ // A document can be changed after it was built, which this does not
99
+ // track, so a save is not reported as touching the fields the
100
+ // constructor happened to state.
101
+ save: { kind: "write", fields: WHOLE_DOCUMENT }
102
+ };
103
+ var MODEL_FACTORY = "model";
104
+ function collectionOf(_selector, call) {
105
+ const model = modelCallIn(call);
106
+ const modelName = model?.nameAt(0, "nothing") ?? null;
107
+ if (model === null || modelName === null) {
108
+ return null;
266
109
  }
267
- return spec.kind === "write" ? ["*"] : [];
110
+ return model.nameAt(2, "nothing") ?? schemaCollectionOf(model) ?? pluralized(modelName);
268
111
  }
269
- function selectorOf(spec, args) {
270
- if (spec.idArg !== void 0) {
271
- return args[spec.idArg] !== void 0 ? ["_id"] : null;
272
- }
273
- if (spec.filterArg === void 0) {
112
+ function modelCallIn(call) {
113
+ const receiver = call.receiver();
114
+ if (receiver === null) {
274
115
  return null;
275
116
  }
276
- const object = readObjectArg(args[spec.filterArg]);
277
- if (object === null) {
117
+ return modelFactoryCall(receiver) ?? modelFactoryCall(receiver.callee()) ?? modelFactoryCall(receiver.receiver());
118
+ }
119
+ function modelFactoryCall(call) {
120
+ if (call === null) {
278
121
  return null;
279
122
  }
280
- const keys = Object.keys(object.fields);
281
- return keys.length > 0 ? keys : null;
123
+ const named = call.method() ?? call.calleeText();
124
+ const fromLibrary = call.isFrom(constructedFrom(CLIENT_MODULE));
125
+ return named === MODEL_FACTORY && fromLibrary ? call : null;
282
126
  }
283
- function buildAccess(opts) {
284
- return {
285
- type: "interaction",
286
- binding: storageBinding({
287
- recognition: RECOGNITION,
288
- storageSystem: STORAGE_SYSTEM,
289
- scope: opts.scope,
290
- container: opts.collection
291
- }),
292
- callee: opts.calleeText,
293
- interaction: {
294
- class: "storage-access",
295
- kind: opts.kind,
296
- fields: opts.fields,
297
- ...opts.selector !== null ? { selector: opts.selector } : {},
298
- operation: opts.operation
299
- }
300
- };
127
+ function schemaCollectionOf(model) {
128
+ return model.argument(1)?.propertyAt(1, "collection", "nothing") ?? null;
301
129
  }
302
- function makeStaticRecognizer(scope) {
303
- return (call, ctx) => {
304
- const callNode = call;
305
- const recognizerCtx = ctx;
306
- const resolve = recognizerCtx.resolveWrittenValue ?? (() => null);
307
- const callee = callNode.getExpression();
308
- if (!N.isPropertyAccessExpression(callee)) {
309
- return null;
310
- }
311
- const method = callee.getName();
312
- const spec = METHODS[method];
313
- if (spec === void 0 || !methodDeclaredIn(callee, "mongoose", resolve)) {
314
- return null;
315
- }
316
- const identity = resolveModelIdentity(callee.getExpression(), resolve);
317
- const args = recognizerCtx.extractArgs?.() ?? [];
318
- return [
319
- buildAccess({
320
- scope,
321
- collection: identity?.collection ?? null,
322
- calleeText: callee.getText(),
323
- operation: method,
324
- kind: spec.kind,
325
- fields: fieldsOf(spec, args),
326
- selector: selectorOf(spec, args)
327
- })
328
- ];
329
- };
130
+ function pluralized(modelName) {
131
+ const lower = modelName.toLowerCase();
132
+ if (/[^aeiou]y$/.test(lower)) {
133
+ return `${lower.slice(0, -1)}ies`;
134
+ }
135
+ if (/(s|x|z|ch|sh)$/.test(lower)) {
136
+ return `${lower}es`;
137
+ }
138
+ return `${lower}s`;
330
139
  }
331
- function makeSaveRecognizer(scope) {
332
- return (call, ctx) => {
333
- const callNode = call;
334
- const recognizerCtx = ctx;
335
- const resolve = recognizerCtx.resolveWrittenValue ?? (() => null);
336
- const callee = callNode.getExpression();
337
- if (!N.isPropertyAccessExpression(callee) || callee.getName() !== "save") {
338
- return null;
339
- }
340
- if (!methodDeclaredIn(callee, "mongoose", resolve)) {
341
- return null;
342
- }
343
- const identity = resolveDocumentModelIdentity(
344
- callee.getExpression(),
345
- resolve
346
- );
347
- return [
348
- buildAccess({
349
- scope,
350
- collection: identity?.collection ?? null,
351
- calleeText: callee.getText(),
352
- operation: "save",
353
- kind: "write",
354
- fields: ["*"],
355
- selector: null
356
- })
357
- ];
358
- };
140
+ function modelCalls(scope) {
141
+ return storageCalls({
142
+ system: "mongodb",
143
+ scope,
144
+ client: declaredBy(CLIENT_MODULE),
145
+ unsettledName: "nothing"
146
+ }).methods(METHODS).container(collectionOf).example('User.find({ email: "a@b.c" }, { name: 1 })');
359
147
  }
360
148
  function mongooseFramework(options = {}) {
361
- const scope = options.scope ?? "default";
362
- return {
363
- name: "mongoose",
364
- protocol: "in-process",
149
+ return pack("mongoose", [modelCalls(options.scope ?? "default")], {
365
150
  languages: ["typescript", "javascript"],
366
- discovery: [],
367
- terminals: [],
368
- inputMapping: { type: "positionalParams", params: [] },
369
- requiresImport: ["mongoose"],
370
- invocationRecognizers: [
371
- makeStaticRecognizer(scope),
372
- makeSaveRecognizer(scope)
373
- ]
374
- };
151
+ recognizedAs: "@suss/framework-mongoose",
152
+ protocol: "in-process"
153
+ });
375
154
  }
376
155
  var index_default = mongooseFramework;
377
156
  export {
package/dist/prisma.js CHANGED
@@ -3,13 +3,12 @@ import {
3
3
  Node as N
4
4
  } from "ts-morph";
5
5
  import { storageBinding } from "@suss/behavioral-ir";
6
- import { readSqlAccess, sqlFromParts } from "@suss/sql";
7
- var RAW_METHODS = /* @__PURE__ */ new Set([
8
- "$queryRaw",
9
- "$executeRaw",
10
- "$queryRawUnsafe",
11
- "$executeRawUnsafe"
12
- ]);
6
+ import {
7
+ compile,
8
+ declarationsIn,
9
+ declaredBy,
10
+ sqlStatements
11
+ } from "@suss/recognize";
13
12
  var PRISMA_READ_METHODS = /* @__PURE__ */ new Set([
14
13
  "findUnique",
15
14
  "findFirst",
@@ -360,74 +359,23 @@ function extractSelector(optionsArg) {
360
359
  const keys = Object.keys(where.fields);
361
360
  return keys.length > 0 ? keys : null;
362
361
  }
363
- function makeRawRecognizer(opts) {
364
- const storageSystem = opts.storageSystem ?? "postgresql";
365
- const scope = opts.scope ?? "default";
366
- return ((node) => {
367
- const statement = rawStatementAt(node);
368
- if (statement === null) {
369
- return null;
370
- }
371
- const accesses = readSqlAccess(statement.sql, { dialect: storageSystem });
372
- if (accesses.length === 0) {
373
- return null;
374
- }
375
- return accesses.map((access) => ({
376
- type: "interaction",
377
- binding: storageBinding({
378
- recognition: "@suss/framework-prisma",
379
- storageSystem,
380
- scope,
381
- container: access.table
382
- }),
383
- callee: statement.callee,
384
- interaction: {
385
- class: "storage-access",
386
- kind: access.kind,
387
- fields: access.fields,
388
- ...access.selector.length > 0 ? { selector: access.selector } : {},
389
- operation: statement.method
390
- }
391
- }));
392
- });
393
- }
394
- function rawStatementAt(node) {
395
- const tag = N.isTaggedTemplateExpression(node) ? node.getTag() : N.isCallExpression(node) ? node.getExpression() : null;
396
- if (tag === null || !N.isPropertyAccessExpression(tag)) {
397
- return null;
398
- }
399
- const method = tag.getName();
400
- if (!RAW_METHODS.has(method)) {
401
- return null;
402
- }
403
- if (!isPrismaClientReceiver(tag.getExpression())) {
404
- return null;
405
- }
406
- const sql = N.isTaggedTemplateExpression(node) ? templateSql(node.getTemplate()) : N.isCallExpression(node) ? literalSql(node.getArguments()[0]) : null;
407
- return sql === null ? null : { sql, method, callee: tag.getText() };
408
- }
409
- function templateSql(template) {
410
- if (N.isNoSubstitutionTemplateLiteral(template)) {
411
- return template.getLiteralValue();
412
- }
413
- if (!N.isTemplateExpression(template)) {
414
- return null;
415
- }
416
- return sqlFromParts([
417
- template.getHead().getLiteralText(),
418
- ...template.getTemplateSpans().map((span) => span.getLiteral().getLiteralText())
419
- ]);
420
- }
421
- function literalSql(argument) {
422
- if (argument === void 0) {
423
- return null;
424
- }
425
- if (N.isStringLiteral(argument) || N.isNoSubstitutionTemplateLiteral(argument)) {
426
- return argument.getLiteralValue();
427
- }
428
- return N.isTemplateExpression(argument) ? templateSql(argument) : null;
362
+ var STATEMENT = { statement: { at: 0 } };
363
+ function rawStatements(options) {
364
+ const provider = options.storageSystem ?? "postgresql";
365
+ return sqlStatements({
366
+ system: provider,
367
+ dialect: provider,
368
+ scope: options.scope ?? "default",
369
+ client: declaredBy("@prisma/client", ".prisma/client")
370
+ }).methods({
371
+ $queryRaw: STATEMENT,
372
+ $executeRaw: STATEMENT,
373
+ $queryRawUnsafe: STATEMENT,
374
+ $executeRawUnsafe: STATEMENT
375
+ }).example('prisma.$queryRawUnsafe("SELECT id, email FROM users")');
429
376
  }
430
377
  function prismaFramework(options = {}) {
378
+ const raw = rawStatements(options);
431
379
  return {
432
380
  name: "prisma",
433
381
  protocol: "in-process",
@@ -439,7 +387,10 @@ function prismaFramework(options = {}) {
439
387
  // recognizer's type-resolution check would reject them anyway.
440
388
  requiresImport: ["@prisma/client"],
441
389
  invocationRecognizers: [makeRecognizer(options)],
442
- accessRecognizers: [makeRawRecognizer(options)]
390
+ // A tagged template is not an invocation, so the raw chain runs on
391
+ // the access walk, which visits calls as well.
392
+ accessRecognizers: [compile(raw.declared, "@suss/framework-prisma")],
393
+ declarations: declarationsIn([raw])
443
394
  };
444
395
  }
445
396
  var index_default = prismaFramework;
@@ -181,8 +181,7 @@ function reactRouterFramework(options = {}) {
181
181
  }))
182
182
  ],
183
183
  inputMapping: {
184
- type: "singleObjectParam",
185
- paramPosition: 0,
184
+ type: "objectParam",
186
185
  knownProperties: {
187
186
  request: "request",
188
187
  params: "pathParams",
package/dist/ts-rest.js CHANGED
@@ -68,7 +68,7 @@ function tsRestFramework() {
68
68
  paramsExtraction: { property: "pathParams" }
69
69
  },
70
70
  inputMapping: {
71
- type: "destructuredObject",
71
+ type: "objectParam",
72
72
  knownProperties: {
73
73
  params: "pathParams",
74
74
  body: "requestBody",