@suss/packs 0.30.0 → 0.31.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/aiohttp.js +4 -1
- package/dist/aws-sqs.js +2 -5
- package/dist/cloudflare-workers.js +90 -204
- package/dist/drizzle.js +56 -88
- package/dist/httpx.js +5 -0
- package/dist/node.js +90 -141
- package/dist/requests.js +4 -1
- package/package.json +10 -10
package/dist/aiohttp.js
CHANGED
|
@@ -27,7 +27,10 @@ function aiohttpClient() {
|
|
|
27
27
|
},
|
|
28
28
|
receiverConstructors: ["ClientSession"]
|
|
29
29
|
}
|
|
30
|
-
]
|
|
30
|
+
],
|
|
31
|
+
// `ClientSession.__aenter__` returns the session, so `async with
|
|
32
|
+
// aiohttp.ClientSession() as s` puts the constructed session in s.
|
|
33
|
+
contextManagers: [{ module: "aiohttp", returnsSelf: ["ClientSession"] }]
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
var declares = {
|
package/dist/aws-sqs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ../framework/aws-sqs/dist/index.js
|
|
2
2
|
import { Node as N } from "ts-morph";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { readConfiguredCall } from "@suss/adapter-typescript";
|
|
4
|
+
import { climbSyntax, readConfiguredCall } from "@suss/adapter-typescript";
|
|
5
5
|
import { messageBusBinding } from "@suss/behavioral-ir";
|
|
6
6
|
import { configuredCallOption } from "@suss/extractor";
|
|
7
7
|
import { constructedFrom, messageSends, pack } from "@suss/recognize";
|
|
@@ -123,10 +123,7 @@ function isSqsRecordIdentifier(recordExpr) {
|
|
|
123
123
|
return false;
|
|
124
124
|
}
|
|
125
125
|
function extractDestructuredFields(call) {
|
|
126
|
-
|
|
127
|
-
while (parent !== void 0 && (N.isAsExpression(parent) || N.isParenthesizedExpression(parent))) {
|
|
128
|
-
parent = parent.getParent();
|
|
129
|
-
}
|
|
126
|
+
const parent = climbSyntax(call).getParent();
|
|
130
127
|
if (parent === void 0 || !N.isVariableDeclaration(parent)) {
|
|
131
128
|
return null;
|
|
132
129
|
}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
// ../framework/cloudflare-workers/dist/index.js
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { Node as N } from "ts-morph";
|
|
4
|
+
import {
|
|
5
|
+
functionValueOf,
|
|
6
|
+
propertiesOf,
|
|
7
|
+
propertyFunctionOf,
|
|
8
|
+
propertyNameOf
|
|
9
|
+
} from "@suss/adapter-typescript";
|
|
4
10
|
import { Node as N2 } from "ts-morph";
|
|
11
|
+
import {
|
|
12
|
+
isDefaultedAt,
|
|
13
|
+
propertyFunctionOf as propertyFunctionOf2,
|
|
14
|
+
propertyNameOf as propertyNameOf2
|
|
15
|
+
} from "@suss/adapter-typescript";
|
|
5
16
|
import { runtimeConfigBinding } from "@suss/behavioral-ir";
|
|
6
17
|
import { Node as N3 } from "ts-morph";
|
|
7
|
-
import { readName as readName2 } from "@suss/adapter-typescript";
|
|
18
|
+
import { readName as readName2, stringValueOf } from "@suss/adapter-typescript";
|
|
8
19
|
import { storageBinding } from "@suss/behavioral-ir";
|
|
9
20
|
import { readSqlAccess } from "@suss/sql";
|
|
10
21
|
var TRIGGERS = {
|
|
@@ -29,9 +40,13 @@ var TRIGGERS = {
|
|
|
29
40
|
};
|
|
30
41
|
var METADATA_NAMESPACE = "cloudflareWorkers";
|
|
31
42
|
function cloudflareWorkersDiscovery(options = {}) {
|
|
32
|
-
return (sourceFile) => {
|
|
43
|
+
return (sourceFile, ctx) => {
|
|
33
44
|
const sf = sourceFile;
|
|
34
|
-
const
|
|
45
|
+
const { resolution } = ctx;
|
|
46
|
+
const triggers = [
|
|
47
|
+
...defaultExportTriggers(sf, resolution),
|
|
48
|
+
...listenerTriggers(sf, resolution)
|
|
49
|
+
];
|
|
35
50
|
const units = [];
|
|
36
51
|
const taken = /* @__PURE__ */ new Set();
|
|
37
52
|
for (const trigger of triggers) {
|
|
@@ -66,124 +81,58 @@ function unitFor(trigger, scriptName) {
|
|
|
66
81
|
}
|
|
67
82
|
};
|
|
68
83
|
}
|
|
69
|
-
function defaultExportTriggers(sf) {
|
|
70
|
-
const literal = defaultExportObject(sf);
|
|
84
|
+
function defaultExportTriggers(sf, resolution) {
|
|
85
|
+
const literal = defaultExportObject(sf, resolution);
|
|
71
86
|
if (literal === null) {
|
|
72
87
|
return [];
|
|
73
88
|
}
|
|
74
89
|
const triggers = [];
|
|
75
|
-
for (const property of literal
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
|
|
90
|
+
for (const property of propertiesOf(literal, resolution)) {
|
|
91
|
+
const name = propertyNameOf(property);
|
|
92
|
+
if (name === null || TRIGGERS[name] === void 0) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const func = propertyFunctionOf(property, resolution);
|
|
96
|
+
if (func !== null) {
|
|
97
|
+
triggers.push({ name, func, registration: "default-export" });
|
|
79
98
|
}
|
|
80
99
|
}
|
|
81
100
|
return triggers;
|
|
82
101
|
}
|
|
83
|
-
function
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
function entrypointTriggerFunctions(sf, resolution) {
|
|
103
|
+
let perRun = triggerFunctionsPerRun.get(resolution);
|
|
104
|
+
if (perRun === void 0) {
|
|
105
|
+
perRun = /* @__PURE__ */ new Map();
|
|
106
|
+
triggerFunctionsPerRun.set(resolution, perRun);
|
|
107
|
+
}
|
|
108
|
+
const filePath = sf.getFilePath();
|
|
109
|
+
let found = perRun.get(filePath);
|
|
110
|
+
if (found === void 0) {
|
|
111
|
+
found = new Set(
|
|
112
|
+
defaultExportTriggers(sf, resolution).map((trigger) => trigger.func)
|
|
113
|
+
);
|
|
114
|
+
perRun.set(filePath, found);
|
|
115
|
+
}
|
|
116
|
+
return found;
|
|
90
117
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
var triggerFunctionsPerRun = /* @__PURE__ */ new WeakMap();
|
|
119
|
+
function defaultExportObject(sf, resolution) {
|
|
120
|
+
for (const exported of resolution.exportsOf(sf).get("default") ?? []) {
|
|
121
|
+
const object = resolution.resolveObject(exported);
|
|
122
|
+
if (object !== null && N.isObjectLiteralExpression(object)) {
|
|
123
|
+
return object;
|
|
96
124
|
}
|
|
97
|
-
return N.isStringLiteral(name) ? name.getLiteralValue() : null;
|
|
98
|
-
}
|
|
99
|
-
return N.isShorthandPropertyAssignment(property) ? property.getName() : null;
|
|
100
|
-
}
|
|
101
|
-
function functionOfProperty(property, sf) {
|
|
102
|
-
if (N.isMethodDeclaration(property)) {
|
|
103
|
-
return property;
|
|
104
|
-
}
|
|
105
|
-
if (N.isPropertyAssignment(property)) {
|
|
106
|
-
const written = property.getInitializer();
|
|
107
|
-
return written === void 0 ? null : functionBehind(written, sf);
|
|
108
|
-
}
|
|
109
|
-
if (N.isShorthandPropertyAssignment(property)) {
|
|
110
|
-
return functionBehind(property.getNameNode(), sf);
|
|
111
125
|
}
|
|
112
126
|
return null;
|
|
113
127
|
}
|
|
114
|
-
function
|
|
115
|
-
if (N.isArrowFunction(expression) || N.isFunctionExpression(expression)) {
|
|
116
|
-
return expression;
|
|
117
|
-
}
|
|
118
|
-
if (!N.isIdentifier(expression)) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
for (const definition of expression.getDefinitionNodes()) {
|
|
122
|
-
const declared = declaredFunction(definition);
|
|
123
|
-
if (declared !== null) {
|
|
124
|
-
return declared;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return localFunction(sf, expression.getText());
|
|
128
|
-
}
|
|
129
|
-
function declaredFunction(definition) {
|
|
130
|
-
if (N.isFunctionDeclaration(definition)) {
|
|
131
|
-
return definition;
|
|
132
|
-
}
|
|
133
|
-
if (!N.isVariableDeclaration(definition)) {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
const written = definition.getInitializer();
|
|
137
|
-
if (written === void 0) {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
return N.isArrowFunction(written) || N.isFunctionExpression(written) ? written : null;
|
|
141
|
-
}
|
|
142
|
-
function localFunction(sf, name) {
|
|
143
|
-
const declaration = sf.getFunction(name);
|
|
144
|
-
if (declaration !== void 0) {
|
|
145
|
-
return declaration;
|
|
146
|
-
}
|
|
147
|
-
const variable = sf.getVariableDeclaration(name);
|
|
148
|
-
return variable === void 0 ? null : declaredFunction(variable);
|
|
149
|
-
}
|
|
150
|
-
function defaultExportObject(sf) {
|
|
151
|
-
const assignment = sf.getExportAssignment((a) => !a.isExportEquals());
|
|
152
|
-
if (assignment === void 0) {
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
return objectBehind(unwrap(assignment.getExpression()), sf);
|
|
156
|
-
}
|
|
157
|
-
function unwrap(expression) {
|
|
158
|
-
let inner = expression;
|
|
159
|
-
while (N.isSatisfiesExpression(inner) || N.isAsExpression(inner) || N.isParenthesizedExpression(inner)) {
|
|
160
|
-
inner = inner.getExpression();
|
|
161
|
-
}
|
|
162
|
-
return inner;
|
|
163
|
-
}
|
|
164
|
-
function objectBehind(expression, sf) {
|
|
165
|
-
if (N.isObjectLiteralExpression(expression)) {
|
|
166
|
-
return expression;
|
|
167
|
-
}
|
|
168
|
-
if (!N.isIdentifier(expression)) {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
const declaration = sf.getVariableDeclaration(expression.getText());
|
|
172
|
-
const written = declaration?.getInitializer();
|
|
173
|
-
if (written === void 0) {
|
|
174
|
-
return null;
|
|
175
|
-
}
|
|
176
|
-
const inner = unwrap(written);
|
|
177
|
-
return N.isObjectLiteralExpression(inner) ? inner : null;
|
|
178
|
-
}
|
|
179
|
-
function listenerTriggers(sf) {
|
|
128
|
+
function listenerTriggers(sf, resolution) {
|
|
180
129
|
const triggers = [];
|
|
181
130
|
sf.forEachDescendant((node) => {
|
|
182
131
|
const registered = listenerAt(node);
|
|
183
132
|
if (registered === null) {
|
|
184
133
|
return;
|
|
185
134
|
}
|
|
186
|
-
const func =
|
|
135
|
+
const func = functionValueOf(registered.handler, resolution);
|
|
187
136
|
if (func !== null) {
|
|
188
137
|
triggers.push({
|
|
189
138
|
name: registered.event,
|
|
@@ -215,118 +164,57 @@ var ENV_PARAMETER_POSITION = 1;
|
|
|
215
164
|
var readName = (name) => `env.${name}`;
|
|
216
165
|
function envBindingRecognizer(options = {}) {
|
|
217
166
|
const instanceName = options.scriptName ?? "<unknown>";
|
|
218
|
-
return (access) => {
|
|
219
|
-
const
|
|
167
|
+
return (access, ctx) => {
|
|
168
|
+
const { resolution } = ctx;
|
|
169
|
+
const read = envReadAt(access, resolution);
|
|
220
170
|
return read === null ? null : [configReadEffect(read, instanceName)];
|
|
221
171
|
};
|
|
222
172
|
}
|
|
223
|
-
function envReadAt(node) {
|
|
173
|
+
function envReadAt(node, resolution) {
|
|
224
174
|
if (!N2.isPropertyAccessExpression(node)) {
|
|
225
175
|
return null;
|
|
226
176
|
}
|
|
227
177
|
const subject = node.getExpression();
|
|
228
|
-
if (!N2.isIdentifier(subject) || !isTriggerEnvArgument(subject)) {
|
|
178
|
+
if (!N2.isIdentifier(subject) || !isTriggerEnvArgument(subject, resolution)) {
|
|
229
179
|
return null;
|
|
230
180
|
}
|
|
231
181
|
const name = node.getName();
|
|
232
182
|
return name.length === 0 ? null : { name, defaulted: isDefaultedAt(node) };
|
|
233
183
|
}
|
|
234
|
-
function isTriggerEnvArgument(subject) {
|
|
184
|
+
function isTriggerEnvArgument(subject, resolution) {
|
|
235
185
|
for (const definition of subject.getSymbol()?.getDeclarations() ?? []) {
|
|
236
|
-
if (N2.isParameterDeclaration(definition) && isTriggerEnvParameter(definition)) {
|
|
186
|
+
if (N2.isParameterDeclaration(definition) && isTriggerEnvParameter(definition, resolution)) {
|
|
237
187
|
return true;
|
|
238
188
|
}
|
|
239
189
|
}
|
|
240
190
|
return false;
|
|
241
191
|
}
|
|
242
|
-
function isTriggerEnvParameter(parameter) {
|
|
192
|
+
function isTriggerEnvParameter(parameter, resolution) {
|
|
243
193
|
const owner = parameter.getParent();
|
|
244
194
|
const parameters = owner.getParameters?.() ?? [];
|
|
245
195
|
if (parameters[ENV_PARAMETER_POSITION] !== parameter) {
|
|
246
196
|
return false;
|
|
247
197
|
}
|
|
248
|
-
return isTriggerBody(owner);
|
|
249
|
-
}
|
|
250
|
-
function isTriggerBody(owner) {
|
|
251
|
-
const named = triggerNameOf(owner);
|
|
252
|
-
if (named !== null) {
|
|
253
|
-
return TRIGGERS[named] !== void 0;
|
|
254
|
-
}
|
|
255
|
-
return referredToByEntrypoint(owner);
|
|
198
|
+
return isTriggerBody(owner, resolution);
|
|
256
199
|
}
|
|
257
|
-
function
|
|
258
|
-
if (
|
|
259
|
-
|
|
260
|
-
|
|
200
|
+
function isTriggerBody(owner, resolution) {
|
|
201
|
+
if (resolution !== void 0) {
|
|
202
|
+
return entrypointTriggerFunctions(owner.getSourceFile(), resolution).has(
|
|
203
|
+
owner
|
|
204
|
+
);
|
|
261
205
|
}
|
|
262
|
-
|
|
263
|
-
if (parent !== void 0 && N2.isPropertyAssignment(parent)) {
|
|
264
|
-
const name = parent.getNameNode();
|
|
265
|
-
return N2.isIdentifier(name) ? name.getText() : null;
|
|
266
|
-
}
|
|
267
|
-
return null;
|
|
206
|
+
return writtenUnderTriggerName(owner);
|
|
268
207
|
}
|
|
269
|
-
function
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
208
|
+
function writtenUnderTriggerName(owner) {
|
|
209
|
+
const property = N2.isMethodDeclaration(owner) ? owner : owner.getParent();
|
|
210
|
+
if (property === void 0) {
|
|
272
211
|
return false;
|
|
273
212
|
}
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
213
|
+
const name = propertyNameOf2(property);
|
|
214
|
+
if (name === null || TRIGGERS[name] === void 0) {
|
|
276
215
|
return false;
|
|
277
216
|
}
|
|
278
|
-
return
|
|
279
|
-
}
|
|
280
|
-
function declaredName(owner) {
|
|
281
|
-
if (N2.isFunctionDeclaration(owner)) {
|
|
282
|
-
return owner.getName() ?? null;
|
|
283
|
-
}
|
|
284
|
-
const parent = owner.getParent();
|
|
285
|
-
return parent !== void 0 && N2.isVariableDeclaration(parent) ? parent.getName() : null;
|
|
286
|
-
}
|
|
287
|
-
function triggerReferences(expression) {
|
|
288
|
-
const names = /* @__PURE__ */ new Set();
|
|
289
|
-
if (!N2.isObjectLiteralExpression(expression)) {
|
|
290
|
-
return names;
|
|
291
|
-
}
|
|
292
|
-
for (const property of expression.getProperties()) {
|
|
293
|
-
if (!N2.isPropertyAssignment(property)) {
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
const key = property.getNameNode();
|
|
297
|
-
if (!N2.isIdentifier(key) || TRIGGERS[key.getText()] === void 0) {
|
|
298
|
-
continue;
|
|
299
|
-
}
|
|
300
|
-
const written = property.getInitializer();
|
|
301
|
-
if (written !== void 0 && N2.isIdentifier(written)) {
|
|
302
|
-
names.add(written.getText());
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
return names;
|
|
306
|
-
}
|
|
307
|
-
function isDefaultedAt(node) {
|
|
308
|
-
let child = node;
|
|
309
|
-
let parent = child.getParent();
|
|
310
|
-
while (parent !== void 0) {
|
|
311
|
-
if (N2.isParenthesizedExpression(parent)) {
|
|
312
|
-
child = parent;
|
|
313
|
-
parent = parent.getParent();
|
|
314
|
-
continue;
|
|
315
|
-
}
|
|
316
|
-
if (!N2.isBinaryExpression(parent)) {
|
|
317
|
-
return false;
|
|
318
|
-
}
|
|
319
|
-
const operator = parent.getOperatorToken().getText();
|
|
320
|
-
if (operator !== "??" && operator !== "||") {
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
if (parent.getLeft() === child) {
|
|
324
|
-
return true;
|
|
325
|
-
}
|
|
326
|
-
child = parent;
|
|
327
|
-
parent = parent.getParent();
|
|
328
|
-
}
|
|
329
|
-
return false;
|
|
217
|
+
return propertyFunctionOf2(property, void 0) === owner;
|
|
330
218
|
}
|
|
331
219
|
function configReadEffect(read, instanceName) {
|
|
332
220
|
return {
|
|
@@ -360,21 +248,25 @@ var KEYED_OPERATIONS = /* @__PURE__ */ new Set([
|
|
|
360
248
|
"put",
|
|
361
249
|
"delete"
|
|
362
250
|
]);
|
|
363
|
-
var objectStoreAccess = (method, call,
|
|
251
|
+
var objectStoreAccess = (method, call, reading) => {
|
|
364
252
|
const kind = OBJECT_OPERATIONS[method];
|
|
365
253
|
if (kind === void 0) {
|
|
366
254
|
return null;
|
|
367
255
|
}
|
|
368
256
|
const argument = call.getArguments()[0];
|
|
369
|
-
const selector = argument !== void 0 && KEYED_OPERATIONS.has(method) ? readName2(argument, {
|
|
257
|
+
const selector = argument !== void 0 && KEYED_OPERATIONS.has(method) ? readName2(argument, {
|
|
258
|
+
resolve: reading.resolve,
|
|
259
|
+
unsettled: "reference"
|
|
260
|
+
}) : null;
|
|
370
261
|
return { kind, ...selector !== null ? { selector } : {} };
|
|
371
262
|
};
|
|
372
263
|
var D1_STATEMENT_METHODS = /* @__PURE__ */ new Set(["prepare", "exec"]);
|
|
373
|
-
var d1Access = (method, call,
|
|
264
|
+
var d1Access = (method, call, reading) => {
|
|
374
265
|
if (!D1_STATEMENT_METHODS.has(method)) {
|
|
375
266
|
return null;
|
|
376
267
|
}
|
|
377
|
-
const
|
|
268
|
+
const statement = call.getArguments()[0];
|
|
269
|
+
const sql = statement === void 0 ? null : stringValueOf(statement, reading.resolution);
|
|
378
270
|
if (sql === null) {
|
|
379
271
|
return null;
|
|
380
272
|
}
|
|
@@ -392,12 +284,16 @@ var STORES = {
|
|
|
392
284
|
};
|
|
393
285
|
function storeBindingRecognizer(call, ctx) {
|
|
394
286
|
const callNode = call;
|
|
395
|
-
const
|
|
287
|
+
const given = ctx;
|
|
288
|
+
const reading = {
|
|
289
|
+
resolve: given.resolveWrittenValue ?? (() => null),
|
|
290
|
+
resolution: given.resolution
|
|
291
|
+
};
|
|
396
292
|
const callee = callNode.getExpression();
|
|
397
293
|
if (!N3.isPropertyAccessExpression(callee)) {
|
|
398
294
|
return null;
|
|
399
295
|
}
|
|
400
|
-
const binding = boundReceiver(callee.getExpression(),
|
|
296
|
+
const binding = boundReceiver(callee.getExpression(), reading);
|
|
401
297
|
if (binding === null) {
|
|
402
298
|
return null;
|
|
403
299
|
}
|
|
@@ -406,7 +302,7 @@ function storeBindingRecognizer(call, ctx) {
|
|
|
406
302
|
return null;
|
|
407
303
|
}
|
|
408
304
|
const method = callee.getName();
|
|
409
|
-
const access = store.read(method, callNode,
|
|
305
|
+
const access = store.read(method, callNode, reading);
|
|
410
306
|
if (access === null) {
|
|
411
307
|
return null;
|
|
412
308
|
}
|
|
@@ -433,10 +329,10 @@ function storeBindingRecognizer(call, ctx) {
|
|
|
433
329
|
}
|
|
434
330
|
];
|
|
435
331
|
}
|
|
436
|
-
function boundReceiver(subject,
|
|
332
|
+
function boundReceiver(subject, reading) {
|
|
437
333
|
let receiver = subject;
|
|
438
334
|
if (N3.isIdentifier(receiver)) {
|
|
439
|
-
const written = declaredInitializer(receiver) ?? resolve(receiver);
|
|
335
|
+
const written = declaredInitializer(receiver) ?? reading.resolve(receiver);
|
|
440
336
|
if (written !== null && written !== receiver) {
|
|
441
337
|
receiver = written;
|
|
442
338
|
}
|
|
@@ -445,7 +341,7 @@ function boundReceiver(subject, resolve) {
|
|
|
445
341
|
return null;
|
|
446
342
|
}
|
|
447
343
|
const env = receiver.getExpression();
|
|
448
|
-
if (!N3.isIdentifier(env) || !isTriggerEnvArgument(env)) {
|
|
344
|
+
if (!N3.isIdentifier(env) || !isTriggerEnvArgument(env, reading.resolution)) {
|
|
449
345
|
return null;
|
|
450
346
|
}
|
|
451
347
|
const typeName = declaredTypeName(receiver);
|
|
@@ -475,16 +371,6 @@ function declaredTypeName(receiver) {
|
|
|
475
371
|
}
|
|
476
372
|
return null;
|
|
477
373
|
}
|
|
478
|
-
function literalText(argument, resolve) {
|
|
479
|
-
if (argument === void 0) {
|
|
480
|
-
return null;
|
|
481
|
-
}
|
|
482
|
-
const written = resolve(argument) ?? argument;
|
|
483
|
-
if (N3.isStringLiteral(written) || N3.isNoSubstitutionTemplateLiteral(written)) {
|
|
484
|
-
return written.getLiteralValue();
|
|
485
|
-
}
|
|
486
|
-
return null;
|
|
487
|
-
}
|
|
488
374
|
var optionsSchema = z.object({
|
|
489
375
|
/**
|
|
490
376
|
* The name the deployment gives this Worker, which is `name` in
|
package/dist/drizzle.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
// ../framework/drizzle/dist/index.js
|
|
2
2
|
import { Node as N } from "ts-morph";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
arrayLiteralOf,
|
|
6
|
+
objectLiteralOf,
|
|
7
|
+
propertiesOf,
|
|
8
|
+
propertyNameOf,
|
|
9
|
+
propertyOf,
|
|
10
|
+
stringValueOf,
|
|
11
|
+
writtenNodeOf
|
|
12
|
+
} from "@suss/adapter-typescript";
|
|
5
13
|
import { storageBinding } from "@suss/behavioral-ir";
|
|
6
14
|
import { scopeOption, storageSystemOption } from "@suss/extractor";
|
|
7
15
|
import {
|
|
@@ -13,6 +21,7 @@ import {
|
|
|
13
21
|
} from "@suss/recognize";
|
|
14
22
|
var QUERY_API_METHODS = /* @__PURE__ */ new Set(["findMany", "findFirst"]);
|
|
15
23
|
var TABLE_FACTORIES = /* @__PURE__ */ new Set(["pgTable", "mysqlTable", "sqliteTable"]);
|
|
24
|
+
var DRIZZLE_PACKAGE = "drizzle-orm";
|
|
16
25
|
var CHAIN_WALK_LIMIT = 12;
|
|
17
26
|
var optionsSchema = z.object({
|
|
18
27
|
/**
|
|
@@ -36,8 +45,9 @@ function rawStatements(opts) {
|
|
|
36
45
|
function makeRecognizer(opts) {
|
|
37
46
|
const storageSystem = opts.storageSystem ?? "postgresql";
|
|
38
47
|
const scope = opts.scope ?? "default";
|
|
39
|
-
return (call) => {
|
|
40
|
-
const
|
|
48
|
+
return (call, ctx) => {
|
|
49
|
+
const { resolution } = ctx;
|
|
50
|
+
const query = recognizeAnchor(call, resolution);
|
|
41
51
|
if (query === null) {
|
|
42
52
|
return null;
|
|
43
53
|
}
|
|
@@ -62,24 +72,24 @@ function makeRecognizer(opts) {
|
|
|
62
72
|
];
|
|
63
73
|
};
|
|
64
74
|
}
|
|
65
|
-
function recognizeAnchor(call) {
|
|
75
|
+
function recognizeAnchor(call, resolution) {
|
|
66
76
|
const callee = call.getExpression();
|
|
67
77
|
if (!N.isPropertyAccessExpression(callee)) {
|
|
68
78
|
return null;
|
|
69
79
|
}
|
|
70
80
|
const method = callee.getName();
|
|
71
81
|
if (method === "from") {
|
|
72
|
-
return recognizeSelect(call, callee.getExpression());
|
|
82
|
+
return recognizeSelect(call, callee.getExpression(), resolution);
|
|
73
83
|
}
|
|
74
84
|
if (method === "insert" || method === "update" || method === "delete") {
|
|
75
|
-
return recognizeMutation(call, callee.getExpression(), method);
|
|
85
|
+
return recognizeMutation(call, callee.getExpression(), method, resolution);
|
|
76
86
|
}
|
|
77
87
|
if (QUERY_API_METHODS.has(method)) {
|
|
78
|
-
return recognizeQueryApi(call, callee.getExpression(), method);
|
|
88
|
+
return recognizeQueryApi(call, callee.getExpression(), method, resolution);
|
|
79
89
|
}
|
|
80
90
|
return null;
|
|
81
91
|
}
|
|
82
|
-
function recognizeSelect(fromCall, receiver) {
|
|
92
|
+
function recognizeSelect(fromCall, receiver, resolution) {
|
|
83
93
|
if (!N.isCallExpression(receiver)) {
|
|
84
94
|
return null;
|
|
85
95
|
}
|
|
@@ -98,10 +108,11 @@ function recognizeSelect(fromCall, receiver) {
|
|
|
98
108
|
if (tableArg === void 0) {
|
|
99
109
|
return null;
|
|
100
110
|
}
|
|
101
|
-
const table = resolveTableName(tableArg);
|
|
111
|
+
const table = resolveTableName(tableArg, resolution);
|
|
102
112
|
const tableExprText = tableArg.getText();
|
|
103
113
|
const selectArg = receiver.getArguments()[0];
|
|
104
|
-
const
|
|
114
|
+
const projected = selectArg === void 0 ? [] : objectKeys(selectArg, resolution);
|
|
115
|
+
const fields = projected.length > 0 ? projected : ["*"];
|
|
105
116
|
const chain = collectChainCalls(fromCall);
|
|
106
117
|
const selector = selectorFromWhere(chain.get("where"), tableExprText);
|
|
107
118
|
return {
|
|
@@ -114,7 +125,7 @@ function recognizeSelect(fromCall, receiver) {
|
|
|
114
125
|
calleeText: fromCall.getExpression().getText()
|
|
115
126
|
};
|
|
116
127
|
}
|
|
117
|
-
function recognizeMutation(call, receiver, operation) {
|
|
128
|
+
function recognizeMutation(call, receiver, operation, resolution) {
|
|
118
129
|
if (!isDrizzleReceiver(receiver)) {
|
|
119
130
|
return null;
|
|
120
131
|
}
|
|
@@ -122,10 +133,10 @@ function recognizeMutation(call, receiver, operation) {
|
|
|
122
133
|
if (tableArg === void 0) {
|
|
123
134
|
return null;
|
|
124
135
|
}
|
|
125
|
-
const table = resolveTableName(tableArg);
|
|
136
|
+
const table = resolveTableName(tableArg, resolution);
|
|
126
137
|
const tableExprText = tableArg.getText();
|
|
127
138
|
const chain = collectChainCalls(call);
|
|
128
|
-
const fields = operation === "insert" ? valuesKeys(chain.get("values")) : operation === "update" ? setKeys(chain.get("set")) : ["*"];
|
|
139
|
+
const fields = operation === "insert" ? valuesKeys(chain.get("values"), resolution) : operation === "update" ? setKeys(chain.get("set"), resolution) : ["*"];
|
|
129
140
|
const selector = selectorFromWhere(chain.get("where"), tableExprText);
|
|
130
141
|
return {
|
|
131
142
|
kind: "write",
|
|
@@ -137,7 +148,7 @@ function recognizeMutation(call, receiver, operation) {
|
|
|
137
148
|
calleeText: call.getExpression().getText()
|
|
138
149
|
};
|
|
139
150
|
}
|
|
140
|
-
function recognizeQueryApi(call, receiver, operation) {
|
|
151
|
+
function recognizeQueryApi(call, receiver, operation, resolution) {
|
|
141
152
|
if (!N.isPropertyAccessExpression(receiver)) {
|
|
142
153
|
return null;
|
|
143
154
|
}
|
|
@@ -148,17 +159,14 @@ function recognizeQueryApi(call, receiver, operation) {
|
|
|
148
159
|
if (!isDrizzleReceiver(queryAccess.getExpression())) {
|
|
149
160
|
return null;
|
|
150
161
|
}
|
|
151
|
-
const table = resolveTableName(receiver) ?? receiver.getName();
|
|
162
|
+
const table = resolveTableName(receiver, resolution) ?? receiver.getName();
|
|
152
163
|
const optionsArg = call.getArguments()[0];
|
|
164
|
+
const options = optionsArg === void 0 ? null : objectLiteralOf(optionsArg, resolution);
|
|
153
165
|
const fields = [];
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
fields.push(...objectKeys(
|
|
158
|
-
}
|
|
159
|
-
const withProp = objectProperty(optionsArg, "with");
|
|
160
|
-
if (withProp !== null && N.isObjectLiteralExpression(withProp)) {
|
|
161
|
-
fields.push(...objectKeys(withProp));
|
|
166
|
+
for (const key of ["columns", "with"]) {
|
|
167
|
+
const written = options === null ? null : propertyOf(options, key, resolution);
|
|
168
|
+
if (written !== null) {
|
|
169
|
+
fields.push(...objectKeys(written, resolution));
|
|
162
170
|
}
|
|
163
171
|
}
|
|
164
172
|
return {
|
|
@@ -204,98 +212,58 @@ function isDrizzleReceiver(node) {
|
|
|
204
212
|
}
|
|
205
213
|
return false;
|
|
206
214
|
}
|
|
207
|
-
function resolveTableName(tableExpr) {
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
215
|
+
function resolveTableName(tableExpr, resolution) {
|
|
216
|
+
const written = writtenNodeOf(tableExpr, resolution);
|
|
217
|
+
if (written === null || !N.isCallExpression(written) || !isTableFactory(written.getExpression(), resolution)) {
|
|
210
218
|
return null;
|
|
211
219
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (declared !== null) {
|
|
215
|
-
return declared;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return null;
|
|
220
|
+
const first = written.getArguments()[0];
|
|
221
|
+
return first === void 0 ? null : stringValueOf(first, resolution);
|
|
219
222
|
}
|
|
220
|
-
function
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
const aliased = symbol === void 0 ? void 0 : resolveAliasedSymbol(symbol);
|
|
224
|
-
for (const target of aliased?.getDeclarations() ?? []) {
|
|
225
|
-
const name = tableNameFromDeclaration(target);
|
|
226
|
-
if (name !== null) {
|
|
227
|
-
return name;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return null;
|
|
231
|
-
}
|
|
232
|
-
if (!N.isVariableDeclaration(decl)) {
|
|
233
|
-
return null;
|
|
234
|
-
}
|
|
235
|
-
const init = decl.getInitializer();
|
|
236
|
-
if (init === void 0 || !N.isCallExpression(init)) {
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
const calleeText = init.getExpression().getText();
|
|
240
|
-
const calleeName = calleeText.split(".").pop() ?? calleeText;
|
|
241
|
-
if (!TABLE_FACTORIES.has(calleeName)) {
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
const first = init.getArguments()[0];
|
|
245
|
-
if (first !== void 0 && N.isStringLiteral(first)) {
|
|
246
|
-
return first.getLiteralValue();
|
|
223
|
+
function isTableFactory(callee, resolution) {
|
|
224
|
+
if (resolution === void 0) {
|
|
225
|
+
return false;
|
|
247
226
|
}
|
|
248
|
-
return
|
|
227
|
+
return resolution.importedNamesOf(callee, [DRIZZLE_PACKAGE]).some((name) => TABLE_FACTORIES.has(name));
|
|
249
228
|
}
|
|
250
|
-
function objectKeys(
|
|
251
|
-
|
|
229
|
+
function objectKeys(value, resolution) {
|
|
230
|
+
const object = objectLiteralOf(value, resolution);
|
|
231
|
+
if (object === null) {
|
|
252
232
|
return [];
|
|
253
233
|
}
|
|
254
234
|
const keys = [];
|
|
255
|
-
for (const
|
|
256
|
-
|
|
257
|
-
|
|
235
|
+
for (const property of propertiesOf(object, resolution)) {
|
|
236
|
+
const name = propertyNameOf(property);
|
|
237
|
+
if (name !== null) {
|
|
238
|
+
keys.push(name);
|
|
258
239
|
}
|
|
259
240
|
}
|
|
260
241
|
return keys;
|
|
261
242
|
}
|
|
262
|
-
function
|
|
263
|
-
if (!N.isObjectLiteralExpression(obj)) {
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
|
-
for (const prop of obj.getProperties()) {
|
|
267
|
-
if (N.isPropertyAssignment(prop) && prop.getName() === name) {
|
|
268
|
-
return prop.getInitializer() ?? null;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
function valuesKeys(valuesCall) {
|
|
243
|
+
function valuesKeys(valuesCall, resolution) {
|
|
274
244
|
const arg = valuesCall?.getArguments()[0];
|
|
275
245
|
if (arg === void 0) {
|
|
276
246
|
return ["*"];
|
|
277
247
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
return keys.length > 0 ? keys : ["*"];
|
|
281
|
-
}
|
|
282
|
-
if (N.isArrayLiteralExpression(arg)) {
|
|
248
|
+
const rows = arrayLiteralOf(arg, resolution);
|
|
249
|
+
if (rows !== null) {
|
|
283
250
|
const union = /* @__PURE__ */ new Set();
|
|
284
|
-
for (const element of
|
|
285
|
-
for (const key of objectKeys(element)) {
|
|
251
|
+
for (const element of rows.getElements()) {
|
|
252
|
+
for (const key of objectKeys(element, resolution)) {
|
|
286
253
|
union.add(key);
|
|
287
254
|
}
|
|
288
255
|
}
|
|
289
256
|
return union.size > 0 ? [...union] : ["*"];
|
|
290
257
|
}
|
|
291
|
-
|
|
258
|
+
const keys = objectKeys(arg, resolution);
|
|
259
|
+
return keys.length > 0 ? keys : ["*"];
|
|
292
260
|
}
|
|
293
|
-
function setKeys(setCall) {
|
|
261
|
+
function setKeys(setCall, resolution) {
|
|
294
262
|
const arg = setCall?.getArguments()[0];
|
|
295
263
|
if (arg === void 0) {
|
|
296
264
|
return ["*"];
|
|
297
265
|
}
|
|
298
|
-
const keys = objectKeys(arg);
|
|
266
|
+
const keys = objectKeys(arg, resolution);
|
|
299
267
|
return keys.length > 0 ? keys : ["*"];
|
|
300
268
|
}
|
|
301
269
|
function selectorFromWhere(whereCall, tableExprText) {
|
package/dist/httpx.js
CHANGED
|
@@ -37,6 +37,11 @@ function httpxClient() {
|
|
|
37
37
|
failureDelivery: "response"
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
],
|
|
41
|
+
// Both classes document `__enter__` as giving back the client, so
|
|
42
|
+
// `with httpx.Client() as c` puts the constructed client in c.
|
|
43
|
+
contextManagers: [
|
|
44
|
+
{ module: "httpx", returnsSelf: ["Client", "AsyncClient"] }
|
|
40
45
|
]
|
|
41
46
|
};
|
|
42
47
|
}
|
package/dist/node.js
CHANGED
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import {
|
|
4
4
|
Node as N,
|
|
5
|
-
|
|
5
|
+
SyntaxKind
|
|
6
6
|
} from "ts-morph";
|
|
7
|
+
import {
|
|
8
|
+
findEnclosingFunction,
|
|
9
|
+
functionTargetOf,
|
|
10
|
+
isDefaultedAt,
|
|
11
|
+
stringValueOf,
|
|
12
|
+
symbolBehind
|
|
13
|
+
} from "@suss/adapter-typescript";
|
|
7
14
|
import { runtimeConfigBinding } from "@suss/behavioral-ir";
|
|
8
15
|
import { Node } from "ts-morph";
|
|
9
16
|
import { runtimeConfigBinding as runtimeConfigBinding2 } from "@suss/behavioral-ir";
|
|
@@ -29,7 +36,7 @@ function dottedRead(node) {
|
|
|
29
36
|
}
|
|
30
37
|
return [{ name: node.getName(), defaulted: isDefaultedAt(node), node }];
|
|
31
38
|
}
|
|
32
|
-
function bracketRead(access) {
|
|
39
|
+
function bracketRead(access, resolution) {
|
|
33
40
|
const argument = access.getArgumentExpression();
|
|
34
41
|
if (argument === void 0) {
|
|
35
42
|
return [];
|
|
@@ -42,51 +49,49 @@ function bracketRead(access) {
|
|
|
42
49
|
return [{ name, defaulted: isDefaultedAt(access), node: access }];
|
|
43
50
|
}
|
|
44
51
|
if (N.isIdentifier(argument)) {
|
|
45
|
-
return readsThroughParameter(access, argument);
|
|
52
|
+
return readsThroughParameter(access, argument, resolution);
|
|
46
53
|
}
|
|
47
54
|
return [];
|
|
48
55
|
}
|
|
49
56
|
var CALLER_LOOKUPS = /* @__PURE__ */ new WeakMap();
|
|
50
|
-
function readsThroughParameter(access, index) {
|
|
57
|
+
function readsThroughParameter(access, index, resolution) {
|
|
51
58
|
const remembered = CALLER_LOOKUPS.get(access);
|
|
52
59
|
if (remembered !== void 0) {
|
|
53
60
|
return remembered;
|
|
54
61
|
}
|
|
55
|
-
const found = callerLiteralReads(access, index);
|
|
62
|
+
const found = callerLiteralReads(access, index, resolution);
|
|
56
63
|
CALLER_LOOKUPS.set(access, found);
|
|
57
64
|
return found;
|
|
58
65
|
}
|
|
59
|
-
function callerLiteralReads(access, index) {
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
function callerLiteralReads(access, index, resolution) {
|
|
67
|
+
if (resolution === void 0) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
const enclosing = findEnclosingFunction(access);
|
|
71
|
+
if (enclosing === null) {
|
|
62
72
|
return [];
|
|
63
73
|
}
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
74
|
+
const start = enclosing.getParameters().find((parameter) => parameter.getName() === index.getText());
|
|
75
|
+
if (start === void 0) {
|
|
66
76
|
return [];
|
|
67
77
|
}
|
|
68
78
|
const defaulted = isDefaultedAt(access);
|
|
69
79
|
const reads = [];
|
|
70
|
-
const pending = [
|
|
80
|
+
const pending = [start];
|
|
71
81
|
const taken = /* @__PURE__ */ new Set();
|
|
72
82
|
while (pending.length > 0) {
|
|
73
83
|
const wanted = pending.pop();
|
|
74
|
-
|
|
75
|
-
if (taken.has(key)) {
|
|
84
|
+
if (taken.has(wanted)) {
|
|
76
85
|
continue;
|
|
77
86
|
}
|
|
78
|
-
taken.add(
|
|
79
|
-
for (const
|
|
80
|
-
const
|
|
81
|
-
if (passed === void 0) {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
const literal = literalBehind(passed);
|
|
87
|
+
taken.add(wanted);
|
|
88
|
+
for (const passed of resolution.argumentsPassedTo(wanted)) {
|
|
89
|
+
const literal = stringValueOf(passed.argument, resolution);
|
|
85
90
|
if (literal !== null && literal.length > 0) {
|
|
86
|
-
reads.push({ name: literal, defaulted, node: call });
|
|
91
|
+
reads.push({ name: literal, defaulted, node: passed.call });
|
|
87
92
|
continue;
|
|
88
93
|
}
|
|
89
|
-
const forwarded = forwardedParameter(passed, call);
|
|
94
|
+
const forwarded = forwardedParameter(passed.argument, passed.call);
|
|
90
95
|
if (forwarded !== null) {
|
|
91
96
|
pending.push(forwarded);
|
|
92
97
|
}
|
|
@@ -94,63 +99,19 @@ function callerLiteralReads(access, index) {
|
|
|
94
99
|
}
|
|
95
100
|
return reads;
|
|
96
101
|
}
|
|
97
|
-
function enclosingFunction(node) {
|
|
98
|
-
return node.getFirstAncestor(
|
|
99
|
-
(candidate) => N.isFunctionDeclaration(candidate) || N.isArrowFunction(candidate) || N.isFunctionExpression(candidate) || N.isMethodDeclaration(candidate)
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
function literalBehind(passed) {
|
|
103
|
-
if (N.isStringLiteral(passed) || N.isNoSubstitutionTemplateLiteral(passed)) {
|
|
104
|
-
return passed.getLiteralValue();
|
|
105
|
-
}
|
|
106
|
-
if (!N.isIdentifier(passed)) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
for (const definition of passed.getDefinitionNodes()) {
|
|
110
|
-
if (!N.isVariableDeclaration(definition)) {
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
const initializer = definition.getInitializer();
|
|
114
|
-
if (initializer !== void 0 && definition.getVariableStatement()?.getDeclarationKind() === VariableDeclarationKind.Const && (N.isStringLiteral(initializer) || N.isNoSubstitutionTemplateLiteral(initializer))) {
|
|
115
|
-
return initializer.getLiteralValue();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
102
|
function forwardedParameter(passed, call) {
|
|
121
103
|
if (!N.isIdentifier(passed)) {
|
|
122
104
|
return null;
|
|
123
105
|
}
|
|
124
|
-
const caller =
|
|
125
|
-
if (caller ===
|
|
106
|
+
const caller = findEnclosingFunction(call);
|
|
107
|
+
if (caller === null) {
|
|
126
108
|
return null;
|
|
127
109
|
}
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
function callSitesOf(fn) {
|
|
132
|
-
const named = N.isVariableDeclaration(fn.getParent()) ? fn.getParent().getNameNode() : fn.getNameNode?.();
|
|
133
|
-
if (named === void 0 || !N.isIdentifier(named)) {
|
|
134
|
-
return [];
|
|
135
|
-
}
|
|
136
|
-
const calls = [];
|
|
137
|
-
for (const reference of named.findReferencesAsNodes()) {
|
|
138
|
-
const parent = reference.getParent();
|
|
139
|
-
if (parent === void 0) {
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
if (N.isCallExpression(parent) && parent.getExpression() === reference) {
|
|
143
|
-
calls.push(parent);
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
if (N.isPropertyAccessExpression(parent) && parent.getNameNode() === reference) {
|
|
147
|
-
const grandparent = parent.getParent();
|
|
148
|
-
if (grandparent !== void 0 && N.isCallExpression(grandparent) && grandparent.getExpression() === parent) {
|
|
149
|
-
calls.push(grandparent);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
110
|
+
const behind = symbolBehind(passed)?.getValueDeclaration();
|
|
111
|
+
if (behind === void 0 || !N.isParameterDeclaration(behind)) {
|
|
112
|
+
return null;
|
|
152
113
|
}
|
|
153
|
-
return
|
|
114
|
+
return behind.getParent() === caller ? behind : null;
|
|
154
115
|
}
|
|
155
116
|
function bindingRead(element) {
|
|
156
117
|
if (element.getDotDotDotToken() !== void 0) {
|
|
@@ -181,37 +142,37 @@ function destructuredReads(declaration) {
|
|
|
181
142
|
}
|
|
182
143
|
return pattern.getElements().flatMap(bindingRead);
|
|
183
144
|
}
|
|
184
|
-
function readsThroughEnvObject(envNode) {
|
|
145
|
+
function readsThroughEnvObject(envNode, resolution) {
|
|
185
146
|
const parent = envNode.getParent();
|
|
186
147
|
if (N.isElementAccessExpression(parent)) {
|
|
187
|
-
return bracketRead(parent);
|
|
148
|
+
return bracketRead(parent, resolution);
|
|
188
149
|
}
|
|
189
150
|
if (N.isVariableDeclaration(parent)) {
|
|
190
151
|
return destructuredReads(parent);
|
|
191
152
|
}
|
|
192
153
|
return [];
|
|
193
154
|
}
|
|
194
|
-
function envReadsAt(node) {
|
|
155
|
+
function envReadsAt(node, resolution) {
|
|
195
156
|
if (N.isCallExpression(node)) {
|
|
196
|
-
return readsThroughHelperCall(node);
|
|
157
|
+
return readsThroughHelperCall(node, resolution);
|
|
197
158
|
}
|
|
198
159
|
if (!N.isPropertyAccessExpression(node)) {
|
|
199
160
|
return [];
|
|
200
161
|
}
|
|
201
|
-
return isProcessEnv(node) ? readsThroughEnvObject(node) : dottedRead(node);
|
|
162
|
+
return isProcessEnv(node) ? readsThroughEnvObject(node, resolution) : dottedRead(node);
|
|
202
163
|
}
|
|
203
|
-
function readsThroughHelperCall(call) {
|
|
164
|
+
function readsThroughHelperCall(call, resolution) {
|
|
204
165
|
const reads = [];
|
|
205
166
|
const callee = functionBehindCallee(call.getExpression());
|
|
206
167
|
if (callee === null) {
|
|
207
168
|
return reads;
|
|
208
169
|
}
|
|
209
170
|
call.getArguments().forEach((passed, at) => {
|
|
210
|
-
const literal =
|
|
171
|
+
const literal = stringValueOf(passed, resolution);
|
|
211
172
|
if (literal === null || literal.length === 0) {
|
|
212
173
|
return;
|
|
213
174
|
}
|
|
214
|
-
const read = parameterReachesEnvRead(callee, at);
|
|
175
|
+
const read = parameterReachesEnvRead(callee, at, resolution);
|
|
215
176
|
if (read !== null) {
|
|
216
177
|
reads.push({ name: literal, defaulted: read.defaulted, node: call });
|
|
217
178
|
}
|
|
@@ -223,31 +184,24 @@ function functionBehindCallee(callee) {
|
|
|
223
184
|
if (!N.isIdentifier(nameNode)) {
|
|
224
185
|
return null;
|
|
225
186
|
}
|
|
226
|
-
|
|
227
|
-
if (N.isFunctionDeclaration(definition) || N.isMethodDeclaration(definition)) {
|
|
228
|
-
return definition;
|
|
229
|
-
}
|
|
230
|
-
if (N.isVariableDeclaration(definition)) {
|
|
231
|
-
const initializer = definition.getInitializer();
|
|
232
|
-
if (initializer !== void 0 && (N.isArrowFunction(initializer) || N.isFunctionExpression(initializer))) {
|
|
233
|
-
return initializer;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return null;
|
|
187
|
+
return functionTargetOf(nameNode)?.func ?? null;
|
|
238
188
|
}
|
|
239
189
|
var PARAM_ENV_READS = /* @__PURE__ */ new WeakMap();
|
|
240
|
-
function parameterReachesEnvRead(fn, at) {
|
|
190
|
+
function parameterReachesEnvRead(fn, at, resolution) {
|
|
241
191
|
const byParameter = PARAM_ENV_READS.get(fn.compilerNode) ?? /* @__PURE__ */ new Map();
|
|
242
192
|
PARAM_ENV_READS.set(fn.compilerNode, byParameter);
|
|
243
193
|
const remembered = byParameter.get(at);
|
|
244
194
|
if (remembered !== void 0) {
|
|
245
195
|
return remembered;
|
|
246
196
|
}
|
|
247
|
-
|
|
197
|
+
const found = reachesEnvRead(fn, at, resolution);
|
|
198
|
+
byParameter.set(at, found);
|
|
199
|
+
return found;
|
|
200
|
+
}
|
|
201
|
+
function reachesEnvRead(fn, at, resolution) {
|
|
248
202
|
const pending = [{ fn, at }];
|
|
249
203
|
const taken = /* @__PURE__ */ new Set();
|
|
250
|
-
while (pending.length > 0
|
|
204
|
+
while (pending.length > 0) {
|
|
251
205
|
const wanted = pending.pop();
|
|
252
206
|
const key = `${wanted.fn.getPos()}:${wanted.at}`;
|
|
253
207
|
if (taken.has(key)) {
|
|
@@ -258,57 +212,47 @@ function parameterReachesEnvRead(fn, at) {
|
|
|
258
212
|
if (parameter === void 0) {
|
|
259
213
|
continue;
|
|
260
214
|
}
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return;
|
|
215
|
+
const direct = directEnvRead(wanted.fn, parameter);
|
|
216
|
+
if (direct !== null) {
|
|
217
|
+
return direct;
|
|
218
|
+
}
|
|
219
|
+
if (resolution === void 0) {
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
for (const passed of resolution.callsPassing(parameter)) {
|
|
223
|
+
if (!N.isCallExpression(passed.call)) {
|
|
224
|
+
continue;
|
|
272
225
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (next !== null && next !== wanted.fn) {
|
|
280
|
-
pending.push({ fn: next, at: position });
|
|
281
|
-
}
|
|
282
|
-
});
|
|
226
|
+
const position = passed.call.getArguments().indexOf(passed.argument);
|
|
227
|
+
const next = functionLikeOf(
|
|
228
|
+
resolution.resolveCallable(passed.call.getExpression())
|
|
229
|
+
);
|
|
230
|
+
if (position >= 0 && next !== null && next !== wanted.fn) {
|
|
231
|
+
pending.push({ fn: next, at: position });
|
|
283
232
|
}
|
|
284
|
-
}
|
|
233
|
+
}
|
|
285
234
|
}
|
|
286
|
-
|
|
287
|
-
return found;
|
|
235
|
+
return null;
|
|
288
236
|
}
|
|
289
|
-
function
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (
|
|
294
|
-
child = parent;
|
|
295
|
-
parent = parent.getParent();
|
|
237
|
+
function directEnvRead(fn, parameter) {
|
|
238
|
+
for (const access of fn.getDescendantsOfKind(
|
|
239
|
+
SyntaxKind.ElementAccessExpression
|
|
240
|
+
)) {
|
|
241
|
+
if (!isProcessEnv(access.getExpression())) {
|
|
296
242
|
continue;
|
|
297
243
|
}
|
|
298
|
-
|
|
299
|
-
|
|
244
|
+
const argument = access.getArgumentExpression();
|
|
245
|
+
if (argument !== void 0 && N.isIdentifier(argument) && symbolBehind(argument)?.getValueDeclaration() === parameter) {
|
|
246
|
+
return { defaulted: isDefaultedAt(access) };
|
|
300
247
|
}
|
|
301
|
-
const op = parent.getOperatorToken().getText();
|
|
302
|
-
if (op !== "??" && op !== "||") {
|
|
303
|
-
return false;
|
|
304
|
-
}
|
|
305
|
-
if (parent.getLeft() === child) {
|
|
306
|
-
return true;
|
|
307
|
-
}
|
|
308
|
-
child = parent;
|
|
309
|
-
parent = parent.getParent();
|
|
310
248
|
}
|
|
311
|
-
return
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
function functionLikeOf(node) {
|
|
252
|
+
if (node === null) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
return N.isFunctionDeclaration(node) || N.isArrowFunction(node) || N.isFunctionExpression(node) || N.isMethodDeclaration(node) ? node : null;
|
|
312
256
|
}
|
|
313
257
|
function configReadEffect(read, deploymentTarget, instanceName) {
|
|
314
258
|
return {
|
|
@@ -326,8 +270,8 @@ function configReadEffect(read, deploymentTarget, instanceName) {
|
|
|
326
270
|
}
|
|
327
271
|
};
|
|
328
272
|
}
|
|
329
|
-
function recognizeProcessEnvRead(access, deploymentTarget, instanceName) {
|
|
330
|
-
const reads = envReadsAt(access);
|
|
273
|
+
function recognizeProcessEnvRead(access, deploymentTarget, instanceName, resolution) {
|
|
274
|
+
const reads = envReadsAt(access, resolution);
|
|
331
275
|
if (reads.length === 0) {
|
|
332
276
|
return null;
|
|
333
277
|
}
|
|
@@ -338,7 +282,12 @@ function recognizeProcessEnvRead(access, deploymentTarget, instanceName) {
|
|
|
338
282
|
function envVarRecognizer(opts = {}) {
|
|
339
283
|
const deploymentTarget = opts.deploymentTarget ?? "lambda";
|
|
340
284
|
const instanceName = opts.instanceName ?? "<unknown>";
|
|
341
|
-
return (access,
|
|
285
|
+
return (access, ctx) => recognizeProcessEnvRead(
|
|
286
|
+
access,
|
|
287
|
+
deploymentTarget,
|
|
288
|
+
instanceName,
|
|
289
|
+
ctx.resolution
|
|
290
|
+
);
|
|
342
291
|
}
|
|
343
292
|
var FILE_LOCATION_GLOBALS = /* @__PURE__ */ new Set(["__dirname", "__filename"]);
|
|
344
293
|
function moduleMetaRead(callee) {
|
package/dist/requests.js
CHANGED
|
@@ -38,7 +38,10 @@ function requestsClient() {
|
|
|
38
38
|
failureDelivery: "response"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
]
|
|
41
|
+
],
|
|
42
|
+
// `Session.__enter__` returns the session, so `with
|
|
43
|
+
// requests.Session() as s` puts the constructed session in s.
|
|
44
|
+
contextManagers: [{ module: "requests", returnsSelf: ["Session"] }]
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
var declares = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suss/packs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Every pack suss ships in one install, so it can read Express, Hono, NestJS, FastAPI, Rails, Prisma, OpenAPI and the rest.",
|
|
6
6
|
"keywords": [
|
|
@@ -218,15 +218,15 @@
|
|
|
218
218
|
"ts-morph": "^23.0.0"
|
|
219
219
|
},
|
|
220
220
|
"dependencies": {
|
|
221
|
-
"@suss/adapter-python": "0.
|
|
222
|
-
"@suss/adapter-ruby": "0.
|
|
223
|
-
"@suss/adapter-typescript": "0.
|
|
224
|
-
"@suss/behavioral-ir": "0.
|
|
225
|
-
"@suss/contract-graphql": "0.
|
|
226
|
-
"@suss/extractor": "0.
|
|
227
|
-
"@suss/manifest-aws": "0.
|
|
228
|
-
"@suss/recognize": "0.
|
|
229
|
-
"@suss/sql": "0.
|
|
221
|
+
"@suss/adapter-python": "0.31.0",
|
|
222
|
+
"@suss/adapter-ruby": "0.31.0",
|
|
223
|
+
"@suss/adapter-typescript": "0.31.0",
|
|
224
|
+
"@suss/behavioral-ir": "0.31.0",
|
|
225
|
+
"@suss/contract-graphql": "0.31.0",
|
|
226
|
+
"@suss/extractor": "0.31.0",
|
|
227
|
+
"@suss/manifest-aws": "0.31.0",
|
|
228
|
+
"@suss/recognize": "0.31.0",
|
|
229
|
+
"@suss/sql": "0.31.0",
|
|
230
230
|
"zod": "^4.0.0"
|
|
231
231
|
},
|
|
232
232
|
"devDependencies": {
|