@suss/packs 0.32.0 → 0.33.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/activerecord.d.ts +5 -0
- package/dist/activerecord.js +74 -2
- package/dist/aws-lambda.js +12 -0
- package/dist/axios.js +8 -4
- package/dist/bigquery-python.d.ts +1 -0
- package/dist/bigquery-python.js +122 -0
- package/dist/bigquery-ruby.d.ts +1 -0
- package/dist/bigquery-ruby.js +56 -0
- package/dist/bigquery.d.ts +1 -0
- package/dist/bigquery.js +54 -0
- package/dist/express.js +8 -0
- package/dist/fastify.js +8 -0
- package/dist/graphql-ruby.js +4 -1
- package/dist/hono.js +8 -0
- package/dist/node.js +353 -101
- package/dist/pg-ruby.d.ts +1 -0
- package/dist/pg-ruby.js +50 -0
- package/dist/pg.d.ts +1 -0
- package/dist/pg.js +28 -0
- package/dist/prisma.js +19 -9
- package/package.json +35 -10
package/dist/node.js
CHANGED
|
@@ -1,34 +1,302 @@
|
|
|
1
1
|
// ../runtime/node/dist/index.js
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import {
|
|
4
|
-
Node as
|
|
5
|
-
SyntaxKind
|
|
4
|
+
Node as N2,
|
|
5
|
+
SyntaxKind as SyntaxKind2
|
|
6
6
|
} from "ts-morph";
|
|
7
7
|
import {
|
|
8
|
+
declarationsBehind,
|
|
8
9
|
findEnclosingFunction,
|
|
9
10
|
functionTargetOf,
|
|
10
11
|
isDefaultedAt,
|
|
11
12
|
stringValueOf,
|
|
12
|
-
symbolBehind
|
|
13
|
+
symbolBehind,
|
|
14
|
+
toFunctionRoot
|
|
13
15
|
} from "@suss/adapter-typescript";
|
|
14
16
|
import { runtimeConfigBinding } from "@suss/behavioral-ir";
|
|
17
|
+
import { Node as N, SyntaxKind } from "ts-morph";
|
|
18
|
+
import {
|
|
19
|
+
objectLiteralOf,
|
|
20
|
+
propertiesOf,
|
|
21
|
+
propertyNameOf,
|
|
22
|
+
propertyOf,
|
|
23
|
+
propertyValueOf,
|
|
24
|
+
writtenNodeOf
|
|
25
|
+
} from "@suss/adapter-typescript";
|
|
15
26
|
import { Node } from "ts-morph";
|
|
16
|
-
import { runtimeConfigBinding as runtimeConfigBinding2 } from "@suss/behavioral-ir";
|
|
17
27
|
import {
|
|
18
28
|
Node as Node2
|
|
19
29
|
} from "ts-morph";
|
|
20
|
-
import { runtimeConfigBinding as runtimeConfigBinding3 } from "@suss/behavioral-ir";
|
|
21
30
|
import {
|
|
22
31
|
Node as Node3
|
|
23
32
|
} from "ts-morph";
|
|
24
33
|
import { functionCallBinding } from "@suss/behavioral-ir";
|
|
34
|
+
var RECOGNITION = "@suss/runtime-node";
|
|
35
|
+
function configBinding(where) {
|
|
36
|
+
return runtimeConfigBinding({ recognition: RECOGNITION, ...where });
|
|
37
|
+
}
|
|
38
|
+
function opaqueRuntimeRead(callee) {
|
|
39
|
+
return {
|
|
40
|
+
type: "interaction",
|
|
41
|
+
binding: configBinding({}),
|
|
42
|
+
callee,
|
|
43
|
+
interaction: { class: "metadata-read", name: callee }
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var SCHEMA_READERS = [
|
|
47
|
+
// cleanEnv(process.env, { PORT: port({ default: 8080 }), DB_NAME: str() })
|
|
48
|
+
{
|
|
49
|
+
modules: ["envalid"],
|
|
50
|
+
calls: ["cleanEnv"],
|
|
51
|
+
environment: { in: "argument", at: 0 },
|
|
52
|
+
schema: { in: "argument", at: 1 }
|
|
53
|
+
},
|
|
54
|
+
// parseEnv(process.env, { PORT: z.number().default(8080) })
|
|
55
|
+
{
|
|
56
|
+
modules: ["znv"],
|
|
57
|
+
calls: ["parseEnv"],
|
|
58
|
+
environment: { in: "argument", at: 0 },
|
|
59
|
+
schema: { in: "argument", at: 1 }
|
|
60
|
+
},
|
|
61
|
+
// createEnv({ server: { DB_NAME: z.string() }, runtimeEnv: process.env })
|
|
62
|
+
{
|
|
63
|
+
modules: ["@t3-oss/env-core", "@t3-oss/env-nextjs"],
|
|
64
|
+
calls: ["createEnv"],
|
|
65
|
+
environment: { in: "property", at: 0, named: "runtimeEnv" },
|
|
66
|
+
schema: { in: "properties", at: 0, named: ["server", "client", "shared"] }
|
|
67
|
+
},
|
|
68
|
+
// v.parse(v.object({ DB_NAME: v.string() }), process.env)
|
|
69
|
+
{
|
|
70
|
+
modules: ["valibot"],
|
|
71
|
+
calls: ["parse", "safeParse", "parseAsync", "safeParseAsync"],
|
|
72
|
+
environment: { in: "argument", at: 1 },
|
|
73
|
+
schema: { in: "builtAt", at: 0, builders: ["object"] }
|
|
74
|
+
},
|
|
75
|
+
// Env.parse(process.env), where Env came from z.object({ ... })
|
|
76
|
+
{
|
|
77
|
+
modules: ["zod"],
|
|
78
|
+
calls: ["parse", "safeParse", "parseAsync", "safeParseAsync"],
|
|
79
|
+
onSchema: true,
|
|
80
|
+
environment: { in: "argument", at: 0 },
|
|
81
|
+
schema: { in: "builtAtReceiver", builders: ["object"] }
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
var PARSE_CALL_NAMES = new Set(
|
|
85
|
+
SCHEMA_READERS.flatMap((reader) => [...reader.calls])
|
|
86
|
+
);
|
|
87
|
+
var MODULES_MENTIONED = /* @__PURE__ */ new WeakMap();
|
|
88
|
+
function writtenCalleeName(callee) {
|
|
89
|
+
if (N.isIdentifier(callee)) {
|
|
90
|
+
return callee.getText();
|
|
91
|
+
}
|
|
92
|
+
return N.isPropertyAccessExpression(callee) ? callee.getName() : null;
|
|
93
|
+
}
|
|
94
|
+
function modulesMentionedIn(sourceFile) {
|
|
95
|
+
const remembered = MODULES_MENTIONED.get(sourceFile);
|
|
96
|
+
if (remembered !== void 0) {
|
|
97
|
+
return remembered;
|
|
98
|
+
}
|
|
99
|
+
const text = sourceFile.getFullText();
|
|
100
|
+
const found = new Set(
|
|
101
|
+
SCHEMA_READERS.flatMap((reader) => [...reader.modules]).filter(
|
|
102
|
+
(module) => text.includes(module)
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
MODULES_MENTIONED.set(sourceFile, found);
|
|
106
|
+
return found;
|
|
107
|
+
}
|
|
108
|
+
function readerCouldFire(call, reader, written) {
|
|
109
|
+
if (!reader.calls.includes(written)) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
if (reader.onSchema === true) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
const mentioned = modulesMentionedIn(call.getSourceFile());
|
|
116
|
+
return reader.modules.some((module) => mentioned.has(module));
|
|
117
|
+
}
|
|
118
|
+
function schemaEnvReads(call, resolution) {
|
|
119
|
+
if (resolution === void 0) {
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
const written = writtenCalleeName(call.getExpression());
|
|
123
|
+
if (written === null || !PARSE_CALL_NAMES.has(written)) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
for (const reader of SCHEMA_READERS) {
|
|
127
|
+
if (!readerCouldFire(call, reader, written) || !callMatches(call, reader, resolution)) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const environment = environmentArgument(call, reader, resolution);
|
|
131
|
+
if (environment === null || !resolution.isEnvironmentValue(environment)) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const reads = readsFromSchema(call, reader, resolution);
|
|
135
|
+
if (reads.length > 0) {
|
|
136
|
+
return reads;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
function callMatches(call, reader, resolution) {
|
|
142
|
+
const callee = call.getExpression();
|
|
143
|
+
if (reader.onSchema === true) {
|
|
144
|
+
return N.isPropertyAccessExpression(callee) && reader.calls.includes(callee.getName());
|
|
145
|
+
}
|
|
146
|
+
const name = moduleCallName(callee, reader.modules, resolution);
|
|
147
|
+
return name !== null && reader.calls.includes(name);
|
|
148
|
+
}
|
|
149
|
+
function moduleCallName(callee, modules, resolution) {
|
|
150
|
+
if (N.isIdentifier(callee)) {
|
|
151
|
+
return resolution.importedNamesOf(callee, [...modules])[0] ?? null;
|
|
152
|
+
}
|
|
153
|
+
if (!N.isPropertyAccessExpression(callee)) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const fromPackage = resolution.importedNamesOf(callee.getExpression(), [
|
|
157
|
+
...modules
|
|
158
|
+
]);
|
|
159
|
+
return fromPackage.length > 0 ? callee.getName() : null;
|
|
160
|
+
}
|
|
161
|
+
function environmentArgument(call, reader, resolution) {
|
|
162
|
+
const at = call.getArguments()[reader.environment.at];
|
|
163
|
+
if (at === void 0) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
if (reader.environment.in === "argument") {
|
|
167
|
+
return at;
|
|
168
|
+
}
|
|
169
|
+
return namedValue(at, reader.environment.named, resolution);
|
|
170
|
+
}
|
|
171
|
+
function readsFromSchema(call, reader, resolution) {
|
|
172
|
+
return schemaLiterals(call, reader, resolution).flatMap(
|
|
173
|
+
(literal) => keysOf(literal, resolution)
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
function schemaLiterals(call, reader, resolution) {
|
|
177
|
+
const { schema } = reader;
|
|
178
|
+
if (schema.in === "builtAtReceiver") {
|
|
179
|
+
const callee = call.getExpression();
|
|
180
|
+
if (!N.isPropertyAccessExpression(callee)) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
return builtSchema(
|
|
184
|
+
callee.getExpression(),
|
|
185
|
+
reader.modules,
|
|
186
|
+
schema.builders,
|
|
187
|
+
resolution
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
const at = call.getArguments()[schema.at];
|
|
191
|
+
if (at === void 0) {
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
if (schema.in === "argument") {
|
|
195
|
+
return [at];
|
|
196
|
+
}
|
|
197
|
+
if (schema.in === "builtAt") {
|
|
198
|
+
return builtSchema(at, reader.modules, schema.builders, resolution);
|
|
199
|
+
}
|
|
200
|
+
return schema.named.map((name) => namedValue(at, name, resolution)).filter((found) => found !== null);
|
|
201
|
+
}
|
|
202
|
+
function namedValue(value, named, resolution) {
|
|
203
|
+
const object = objectLiteralOf(value, resolution);
|
|
204
|
+
return object === null ? null : propertyOf(object, named, resolution);
|
|
205
|
+
}
|
|
206
|
+
function builtSchema(value, modules, builders, resolution) {
|
|
207
|
+
const built = chainRoot(writtenCallOf(value, resolution));
|
|
208
|
+
if (built === null) {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
const name = moduleCallName(built.getExpression(), modules, resolution);
|
|
212
|
+
if (name === null || !builders.includes(name)) {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
const literal = built.getArguments()[0];
|
|
216
|
+
return literal === void 0 ? [] : [literal];
|
|
217
|
+
}
|
|
218
|
+
function writtenCallOf(value, resolution) {
|
|
219
|
+
const written = writtenNodeOf(value, resolution);
|
|
220
|
+
return written !== null && N.isCallExpression(written) ? written : null;
|
|
221
|
+
}
|
|
222
|
+
function chainRoot(call) {
|
|
223
|
+
let at = call;
|
|
224
|
+
while (at !== null) {
|
|
225
|
+
const callee = at.getExpression();
|
|
226
|
+
if (!N.isPropertyAccessExpression(callee)) {
|
|
227
|
+
return at;
|
|
228
|
+
}
|
|
229
|
+
const receiver = callee.getExpression();
|
|
230
|
+
if (!N.isCallExpression(receiver)) {
|
|
231
|
+
return at;
|
|
232
|
+
}
|
|
233
|
+
at = receiver;
|
|
234
|
+
}
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
function keysOf(literal, resolution) {
|
|
238
|
+
const object = objectLiteralOf(literal, resolution);
|
|
239
|
+
if (object === null) {
|
|
240
|
+
return [];
|
|
241
|
+
}
|
|
242
|
+
const reads = [];
|
|
243
|
+
for (const property of propertiesOf(object, resolution)) {
|
|
244
|
+
const name = propertyNameOf(property);
|
|
245
|
+
if (name === null || name.length === 0) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
const value = propertyValueOf(property);
|
|
249
|
+
reads.push({ name, defaulted: value !== null && suppliesValue(value) });
|
|
250
|
+
}
|
|
251
|
+
return reads;
|
|
252
|
+
}
|
|
253
|
+
var DEFAULTING_CALLS = /* @__PURE__ */ new Set([
|
|
254
|
+
"default",
|
|
255
|
+
"optional",
|
|
256
|
+
"nullish",
|
|
257
|
+
"catch",
|
|
258
|
+
"or"
|
|
259
|
+
]);
|
|
260
|
+
var DEFAULTING_OPTIONS = /* @__PURE__ */ new Set(["default", "devDefault"]);
|
|
261
|
+
function suppliesValue(value) {
|
|
262
|
+
let found = defaults(value);
|
|
263
|
+
value.forEachDescendant((node, traversal) => {
|
|
264
|
+
if (!defaults(node)) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
found = true;
|
|
268
|
+
traversal.stop();
|
|
269
|
+
});
|
|
270
|
+
return found;
|
|
271
|
+
}
|
|
272
|
+
function defaults(node) {
|
|
273
|
+
if (N.isCallExpression(node)) {
|
|
274
|
+
const written = writtenCalleeName(node.getExpression());
|
|
275
|
+
return written !== null && DEFAULTING_CALLS.has(written);
|
|
276
|
+
}
|
|
277
|
+
if (!N.isPropertyAssignment(node)) {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
const option = propertyNameOf(node);
|
|
281
|
+
return option !== null && DEFAULTING_OPTIONS.has(option);
|
|
282
|
+
}
|
|
283
|
+
var SCHEMA_READS_INSIDE = /* @__PURE__ */ new WeakMap();
|
|
284
|
+
function schemaEnvReadsInside(callee, resolution) {
|
|
285
|
+
const remembered = SCHEMA_READS_INSIDE.get(callee);
|
|
286
|
+
if (remembered !== void 0) {
|
|
287
|
+
return remembered;
|
|
288
|
+
}
|
|
289
|
+
const found = callee.getDescendantsOfKind(SyntaxKind.CallExpression).flatMap((inner) => schemaEnvReads(inner, resolution));
|
|
290
|
+
SCHEMA_READS_INSIDE.set(callee, found);
|
|
291
|
+
return found;
|
|
292
|
+
}
|
|
25
293
|
var readName = (name) => `process.env.${name}`;
|
|
26
294
|
function isProcessEnv(node) {
|
|
27
|
-
if (!
|
|
295
|
+
if (!N2.isPropertyAccessExpression(node) || node.getName() !== "env") {
|
|
28
296
|
return false;
|
|
29
297
|
}
|
|
30
298
|
const root = node.getExpression();
|
|
31
|
-
return
|
|
299
|
+
return N2.isIdentifier(root) && root.getText() === "process";
|
|
32
300
|
}
|
|
33
301
|
function dottedRead(node) {
|
|
34
302
|
if (!isProcessEnv(node.getExpression())) {
|
|
@@ -41,14 +309,14 @@ function bracketRead(access, resolution) {
|
|
|
41
309
|
if (argument === void 0) {
|
|
42
310
|
return [];
|
|
43
311
|
}
|
|
44
|
-
if (
|
|
312
|
+
if (N2.isStringLiteral(argument) || N2.isNoSubstitutionTemplateLiteral(argument)) {
|
|
45
313
|
const name = argument.getLiteralValue();
|
|
46
314
|
if (name.length === 0) {
|
|
47
315
|
return [];
|
|
48
316
|
}
|
|
49
317
|
return [{ name, defaulted: isDefaultedAt(access), node: access }];
|
|
50
318
|
}
|
|
51
|
-
if (
|
|
319
|
+
if (N2.isIdentifier(argument)) {
|
|
52
320
|
return readsThroughParameter(access, argument, resolution);
|
|
53
321
|
}
|
|
54
322
|
return [];
|
|
@@ -100,7 +368,7 @@ function callerLiteralReads(access, index, resolution) {
|
|
|
100
368
|
return reads;
|
|
101
369
|
}
|
|
102
370
|
function forwardedParameter(passed, call) {
|
|
103
|
-
if (!
|
|
371
|
+
if (!N2.isIdentifier(passed)) {
|
|
104
372
|
return null;
|
|
105
373
|
}
|
|
106
374
|
const caller = findEnclosingFunction(call);
|
|
@@ -108,7 +376,7 @@ function forwardedParameter(passed, call) {
|
|
|
108
376
|
return null;
|
|
109
377
|
}
|
|
110
378
|
const behind = symbolBehind(passed)?.getValueDeclaration();
|
|
111
|
-
if (behind === void 0 || !
|
|
379
|
+
if (behind === void 0 || !N2.isParameterDeclaration(behind)) {
|
|
112
380
|
return null;
|
|
113
381
|
}
|
|
114
382
|
return behind.getParent() === caller ? behind : null;
|
|
@@ -118,10 +386,10 @@ function bindingRead(element) {
|
|
|
118
386
|
return [];
|
|
119
387
|
}
|
|
120
388
|
const named = element.getPropertyNameNode() ?? element.getNameNode();
|
|
121
|
-
if (!(
|
|
389
|
+
if (!(N2.isIdentifier(named) || N2.isStringLiteral(named))) {
|
|
122
390
|
return [];
|
|
123
391
|
}
|
|
124
|
-
const name =
|
|
392
|
+
const name = N2.isIdentifier(named) ? named.getText() : named.getLiteralValue();
|
|
125
393
|
if (name.length === 0) {
|
|
126
394
|
return [];
|
|
127
395
|
}
|
|
@@ -137,32 +405,33 @@ function bindingRead(element) {
|
|
|
137
405
|
}
|
|
138
406
|
function destructuredReads(declaration) {
|
|
139
407
|
const pattern = declaration.getNameNode();
|
|
140
|
-
if (!
|
|
408
|
+
if (!N2.isObjectBindingPattern(pattern)) {
|
|
141
409
|
return [];
|
|
142
410
|
}
|
|
143
411
|
return pattern.getElements().flatMap(bindingRead);
|
|
144
412
|
}
|
|
145
413
|
function readsThroughEnvObject(envNode, resolution) {
|
|
146
414
|
const parent = envNode.getParent();
|
|
147
|
-
if (
|
|
415
|
+
if (N2.isElementAccessExpression(parent)) {
|
|
148
416
|
return bracketRead(parent, resolution);
|
|
149
417
|
}
|
|
150
|
-
if (
|
|
418
|
+
if (N2.isVariableDeclaration(parent)) {
|
|
151
419
|
return destructuredReads(parent);
|
|
152
420
|
}
|
|
153
421
|
return [];
|
|
154
422
|
}
|
|
155
423
|
function envReadsAt(node, resolution) {
|
|
156
|
-
if (
|
|
157
|
-
|
|
424
|
+
if (N2.isCallExpression(node)) {
|
|
425
|
+
const parsed = anchoredAt(schemaEnvReads(node, resolution), node);
|
|
426
|
+
return parsed.length > 0 ? parsed : readsThroughHelperCall(node, resolution);
|
|
158
427
|
}
|
|
159
|
-
if (!
|
|
428
|
+
if (!N2.isPropertyAccessExpression(node)) {
|
|
160
429
|
return [];
|
|
161
430
|
}
|
|
162
431
|
return isProcessEnv(node) ? readsThroughEnvObject(node, resolution) : dottedRead(node);
|
|
163
432
|
}
|
|
164
433
|
function readsThroughHelperCall(call, resolution) {
|
|
165
|
-
const callee = functionBehindCallee(call.getExpression());
|
|
434
|
+
const callee = functionBehindCallee(call.getExpression(), resolution);
|
|
166
435
|
if (callee === null) {
|
|
167
436
|
return [];
|
|
168
437
|
}
|
|
@@ -189,18 +458,48 @@ function readsThroughHelperCall(call, resolution) {
|
|
|
189
458
|
);
|
|
190
459
|
});
|
|
191
460
|
const wrapped = isDefaultedAt(call);
|
|
192
|
-
return [
|
|
193
|
-
name,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
461
|
+
return [
|
|
462
|
+
...[...defaultedByName].map(([name, atSites]) => ({
|
|
463
|
+
name,
|
|
464
|
+
defaulted: atSites || wrapped,
|
|
465
|
+
node: call
|
|
466
|
+
})),
|
|
467
|
+
// A config module parses its schema once and every handler calls
|
|
468
|
+
// the function around it, so the call reports what the parse reads.
|
|
469
|
+
...anchoredAt(schemaEnvReadsInside(callee, resolution), call)
|
|
470
|
+
];
|
|
471
|
+
}
|
|
472
|
+
function anchoredAt(reads, node) {
|
|
473
|
+
return reads.map((read) => ({ ...read, node }));
|
|
474
|
+
}
|
|
475
|
+
function functionBehindCallee(callee, resolution) {
|
|
476
|
+
const nameNode = N2.isPropertyAccessExpression(callee) ? callee.getNameNode() : callee;
|
|
477
|
+
if (!N2.isIdentifier(nameNode)) {
|
|
201
478
|
return null;
|
|
202
479
|
}
|
|
203
|
-
|
|
480
|
+
const declared = functionTargetOf(nameNode)?.func;
|
|
481
|
+
if (declared !== void 0 || resolution === void 0) {
|
|
482
|
+
return declared ?? null;
|
|
483
|
+
}
|
|
484
|
+
return factoryReturnedCallee(nameNode, callee, resolution);
|
|
485
|
+
}
|
|
486
|
+
function factoryReturnedCallee(nameNode, callee, resolution) {
|
|
487
|
+
if (!isDeclaredAsCall(nameNode)) {
|
|
488
|
+
return null;
|
|
489
|
+
}
|
|
490
|
+
const returned = resolution.resolveReturnedCallable(callee);
|
|
491
|
+
return returned === null ? null : toFunctionRoot(returned);
|
|
492
|
+
}
|
|
493
|
+
function isDeclaredAsCall(nameNode) {
|
|
494
|
+
const declarations = declarationsBehind(symbolBehind(nameNode));
|
|
495
|
+
return declarations.length > 0 && declarations.every(isVariableSetToCall);
|
|
496
|
+
}
|
|
497
|
+
function isVariableSetToCall(declaration) {
|
|
498
|
+
if (!N2.isVariableDeclaration(declaration)) {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
const initializer = declaration.getInitializer();
|
|
502
|
+
return initializer !== void 0 && N2.isCallExpression(initializer);
|
|
204
503
|
}
|
|
205
504
|
function namesSomething(value) {
|
|
206
505
|
return value !== null && value.length > 0;
|
|
@@ -218,26 +517,22 @@ function directEnvReads(fn, parameter) {
|
|
|
218
517
|
}
|
|
219
518
|
function directEnvRead(fn, parameter) {
|
|
220
519
|
for (const access of fn.getDescendantsOfKind(
|
|
221
|
-
|
|
520
|
+
SyntaxKind2.ElementAccessExpression
|
|
222
521
|
)) {
|
|
223
522
|
if (!isProcessEnv(access.getExpression())) {
|
|
224
523
|
continue;
|
|
225
524
|
}
|
|
226
525
|
const argument = access.getArgumentExpression();
|
|
227
|
-
if (argument !== void 0 &&
|
|
526
|
+
if (argument !== void 0 && N2.isIdentifier(argument) && symbolBehind(argument)?.getValueDeclaration() === parameter) {
|
|
228
527
|
return access;
|
|
229
528
|
}
|
|
230
529
|
}
|
|
231
530
|
return null;
|
|
232
531
|
}
|
|
233
|
-
function configReadEffect(read,
|
|
532
|
+
function configReadEffect(read, where) {
|
|
234
533
|
return {
|
|
235
534
|
type: "interaction",
|
|
236
|
-
binding:
|
|
237
|
-
recognition: "@suss/runtime-node",
|
|
238
|
-
deploymentTarget,
|
|
239
|
-
instanceName
|
|
240
|
-
}),
|
|
535
|
+
binding: configBinding(where),
|
|
241
536
|
callee: readName(read.name),
|
|
242
537
|
interaction: {
|
|
243
538
|
class: "config-read",
|
|
@@ -246,42 +541,21 @@ function configReadEffect(read, deploymentTarget, instanceName) {
|
|
|
246
541
|
}
|
|
247
542
|
};
|
|
248
543
|
}
|
|
249
|
-
function recognizeProcessEnvRead(access,
|
|
544
|
+
function recognizeProcessEnvRead(access, where, resolution) {
|
|
250
545
|
const reads = envReadsAt(access, resolution);
|
|
251
546
|
if (reads.length === 0) {
|
|
252
547
|
return null;
|
|
253
548
|
}
|
|
254
|
-
return reads.map(
|
|
255
|
-
(read) => configReadEffect(read, deploymentTarget, instanceName)
|
|
256
|
-
);
|
|
549
|
+
return reads.map((read) => configReadEffect(read, where));
|
|
257
550
|
}
|
|
258
551
|
function envVarRecognizer(opts = {}) {
|
|
259
|
-
const deploymentTarget = opts.deploymentTarget ?? "lambda";
|
|
260
|
-
const instanceName = opts.instanceName ?? "<unknown>";
|
|
261
552
|
return (access, ctx) => recognizeProcessEnvRead(
|
|
262
553
|
access,
|
|
263
|
-
|
|
264
|
-
instanceName,
|
|
554
|
+
opts,
|
|
265
555
|
ctx.resolution
|
|
266
556
|
);
|
|
267
557
|
}
|
|
268
558
|
var FILE_LOCATION_GLOBALS = /* @__PURE__ */ new Set(["__dirname", "__filename"]);
|
|
269
|
-
function moduleMetaRead(callee) {
|
|
270
|
-
return {
|
|
271
|
-
type: "interaction",
|
|
272
|
-
binding: runtimeConfigBinding2({
|
|
273
|
-
recognition: "@suss/runtime-node",
|
|
274
|
-
deploymentTarget: "lambda",
|
|
275
|
-
instanceName: "<runtime>"
|
|
276
|
-
}),
|
|
277
|
-
callee,
|
|
278
|
-
interaction: {
|
|
279
|
-
class: "config-read",
|
|
280
|
-
name: callee,
|
|
281
|
-
defaulted: false
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
559
|
var importMetaRecognizer = (access, _ctx) => {
|
|
286
560
|
const node = access;
|
|
287
561
|
if (!Node.isPropertyAccessExpression(node)) {
|
|
@@ -295,7 +569,7 @@ var importMetaRecognizer = (access, _ctx) => {
|
|
|
295
569
|
if (keyword === void 0 || inner.getNameNode().getText() !== "meta") {
|
|
296
570
|
return null;
|
|
297
571
|
}
|
|
298
|
-
return [
|
|
572
|
+
return [opaqueRuntimeRead(node.getText())];
|
|
299
573
|
};
|
|
300
574
|
var fileLocationRecognizer = (access, _ctx) => {
|
|
301
575
|
const node = access;
|
|
@@ -310,7 +584,7 @@ var fileLocationRecognizer = (access, _ctx) => {
|
|
|
310
584
|
if (!FILE_LOCATION_GLOBALS.has(text)) {
|
|
311
585
|
return null;
|
|
312
586
|
}
|
|
313
|
-
return [
|
|
587
|
+
return [opaqueRuntimeRead(text)];
|
|
314
588
|
};
|
|
315
589
|
function isProcessEnvVarRead(node) {
|
|
316
590
|
const inner = node.getExpression();
|
|
@@ -337,35 +611,33 @@ var OPAQUE_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
|
337
611
|
"execPath",
|
|
338
612
|
"execArgv"
|
|
339
613
|
]);
|
|
340
|
-
function makeProcessSurfaceRecognizer(
|
|
341
|
-
const deploymentTarget = opts.deploymentTarget ?? "lambda";
|
|
342
|
-
const instanceName = opts.instanceName ?? "<unknown>";
|
|
614
|
+
function makeProcessSurfaceRecognizer(where) {
|
|
343
615
|
return (access, _ctx) => {
|
|
344
616
|
const node = access;
|
|
345
617
|
if (Node2.isPropertyAccessExpression(node)) {
|
|
346
|
-
return recognizeProperty(node,
|
|
618
|
+
return recognizeProperty(node, where);
|
|
347
619
|
}
|
|
348
620
|
if (Node2.isElementAccessExpression(node)) {
|
|
349
|
-
return recognizeElementAccess(node,
|
|
621
|
+
return recognizeElementAccess(node, where);
|
|
350
622
|
}
|
|
351
623
|
return null;
|
|
352
624
|
};
|
|
353
625
|
}
|
|
354
|
-
function recognizeProperty(node,
|
|
626
|
+
function recognizeProperty(node, where) {
|
|
355
627
|
if (isProcessEnvVarRead(node)) {
|
|
356
628
|
return null;
|
|
357
629
|
}
|
|
358
630
|
const subject = node.getExpression();
|
|
359
631
|
const name = node.getName();
|
|
360
632
|
if (isProcessIdentifier(subject) && name === "argv") {
|
|
361
|
-
return [argvRead(
|
|
633
|
+
return [argvRead(where, node.getText(), null)];
|
|
362
634
|
}
|
|
363
635
|
if (isProcessIdentifier(subject) && OPAQUE_PROPERTY_NAMES.has(name)) {
|
|
364
|
-
return [
|
|
636
|
+
return [opaqueRuntimeRead(node.getText())];
|
|
365
637
|
}
|
|
366
638
|
return null;
|
|
367
639
|
}
|
|
368
|
-
function recognizeElementAccess(node,
|
|
640
|
+
function recognizeElementAccess(node, where) {
|
|
369
641
|
const subject = node.getExpression();
|
|
370
642
|
if (!Node2.isPropertyAccessExpression(subject)) {
|
|
371
643
|
return null;
|
|
@@ -382,17 +654,13 @@ function recognizeElementAccess(node, deploymentTarget, instanceName) {
|
|
|
382
654
|
if (arg !== void 0 && Node2.isNumericLiteral(arg)) {
|
|
383
655
|
indexLabel = String(arg.getLiteralValue());
|
|
384
656
|
}
|
|
385
|
-
return [argvRead(
|
|
657
|
+
return [argvRead(where, node.getText(), indexLabel)];
|
|
386
658
|
}
|
|
387
|
-
function argvRead(
|
|
659
|
+
function argvRead(where, callee, indexLabel) {
|
|
388
660
|
const name = indexLabel !== null ? `argv[${indexLabel}]` : "argv";
|
|
389
661
|
return {
|
|
390
662
|
type: "interaction",
|
|
391
|
-
binding:
|
|
392
|
-
recognition: "@suss/runtime-node",
|
|
393
|
-
deploymentTarget,
|
|
394
|
-
instanceName
|
|
395
|
-
}),
|
|
663
|
+
binding: configBinding(where),
|
|
396
664
|
callee,
|
|
397
665
|
interaction: {
|
|
398
666
|
class: "config-read",
|
|
@@ -401,22 +669,6 @@ function argvRead(deploymentTarget, instanceName, callee, indexLabel) {
|
|
|
401
669
|
}
|
|
402
670
|
};
|
|
403
671
|
}
|
|
404
|
-
function opaqueProcessRead(callee, _label) {
|
|
405
|
-
return {
|
|
406
|
-
type: "interaction",
|
|
407
|
-
binding: runtimeConfigBinding3({
|
|
408
|
-
recognition: "@suss/runtime-node",
|
|
409
|
-
deploymentTarget: "lambda",
|
|
410
|
-
instanceName: "<runtime>"
|
|
411
|
-
}),
|
|
412
|
-
callee,
|
|
413
|
-
interaction: {
|
|
414
|
-
class: "config-read",
|
|
415
|
-
name: callee,
|
|
416
|
-
defaulted: false
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
672
|
function processSurfaceRecognizer(opts = {}) {
|
|
421
673
|
return makeProcessSurfaceRecognizer(opts);
|
|
422
674
|
}
|
|
@@ -558,16 +810,16 @@ function nodeSchedulingSubUnits(parent, _ctx) {
|
|
|
558
810
|
});
|
|
559
811
|
return out;
|
|
560
812
|
}
|
|
561
|
-
var PACK_VERSION = "0.
|
|
813
|
+
var PACK_VERSION = "0.2.0";
|
|
562
814
|
var optionsSchema = z.object({
|
|
563
815
|
/**
|
|
564
816
|
* Deployment context for runtime-config reads (process.env.X,
|
|
565
|
-
* process.argv).
|
|
817
|
+
* process.argv). Left off the binding unless a run sets it.
|
|
566
818
|
*/
|
|
567
819
|
deploymentTarget: z.enum(["lambda", "ecs-task", "container", "k8s-deployment"]).optional(),
|
|
568
820
|
/**
|
|
569
|
-
*
|
|
570
|
-
*
|
|
821
|
+
* The deployed instance the reads belong to. Left off the binding
|
|
822
|
+
* unless a run sets it.
|
|
571
823
|
*/
|
|
572
824
|
instanceName: z.string().optional()
|
|
573
825
|
}).strict();
|
|
@@ -605,7 +857,7 @@ var declares = {
|
|
|
605
857
|
package: "@suss/runtime-node",
|
|
606
858
|
dependencies: [],
|
|
607
859
|
shippedWith: "typescript",
|
|
608
|
-
reads: "Node.js runtime primitives, scheduling, the `process` surface (incl. `process.env.X` config-read interactions), module-loading globals, emitted as interaction effects."
|
|
860
|
+
reads: "Node.js runtime primitives, scheduling, the `process` surface (incl. `process.env.X` config-read interactions and the keys of a schema parsed against `process.env`), module-loading globals as metadata-read interactions, emitted as interaction effects."
|
|
609
861
|
};
|
|
610
862
|
var index_default = nodeRuntimePack;
|
|
611
863
|
export {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { declares, default } from '@suss/framework-pg-ruby';
|