@suss/packs 0.11.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/LICENSE +205 -0
- package/README.md +29 -0
- package/dist/activerecord.d.ts +30 -0
- package/dist/activerecord.js +45 -0
- package/dist/apollo-client.d.ts +1 -0
- package/dist/apollo-client.js +137 -0
- package/dist/apollo.d.ts +1 -0
- package/dist/apollo.js +90 -0
- package/dist/aws-dynamodb.d.ts +1 -0
- package/dist/aws-dynamodb.js +386 -0
- package/dist/aws-eventbridge.d.ts +1 -0
- package/dist/aws-eventbridge.js +240 -0
- package/dist/aws-lambda.d.ts +1 -0
- package/dist/aws-lambda.js +382 -0
- package/dist/aws-s3.d.ts +1 -0
- package/dist/aws-s3.js +120 -0
- package/dist/aws-sqs.d.ts +1 -0
- package/dist/aws-sqs.js +296 -0
- package/dist/axios.d.ts +1 -0
- package/dist/axios.js +107 -0
- package/dist/cloudflare-workers.d.ts +1 -0
- package/dist/cloudflare-workers.js +562 -0
- package/dist/drizzle.d.ts +1 -0
- package/dist/drizzle.js +383 -0
- package/dist/express.d.ts +1 -0
- package/dist/express.js +124 -0
- package/dist/fastapi.d.ts +1 -0
- package/dist/fastapi.js +42 -0
- package/dist/fastify.d.ts +1 -0
- package/dist/fastify.js +116 -0
- package/dist/fetch.d.ts +1 -0
- package/dist/fetch.js +64 -0
- package/dist/flask-restx.d.ts +1 -0
- package/dist/flask-restx.js +59 -0
- package/dist/gcs.d.ts +1 -0
- package/dist/gcs.js +134 -0
- package/dist/graphql-ruby.d.ts +1 -0
- package/dist/graphql-ruby.js +84 -0
- package/dist/hono.d.ts +1 -0
- package/dist/hono.js +184 -0
- package/dist/mongoose.d.ts +1 -0
- package/dist/mongoose.js +379 -0
- package/dist/nestjs-graphql.d.ts +1 -0
- package/dist/nestjs-graphql.js +77 -0
- package/dist/nestjs-rest.d.ts +1 -0
- package/dist/nestjs-rest.js +89 -0
- package/dist/nextjs.d.ts +1 -0
- package/dist/nextjs.js +154 -0
- package/dist/node.d.ts +1 -0
- package/dist/node.js +667 -0
- package/dist/prisma.d.ts +1 -0
- package/dist/prisma.js +448 -0
- package/dist/react-router.d.ts +1 -0
- package/dist/react-router.js +197 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +221 -0
- package/dist/redis.d.ts +1 -0
- package/dist/redis.js +93 -0
- package/dist/sqlalchemy.d.ts +1 -0
- package/dist/sqlalchemy.js +48 -0
- package/dist/ts-rest.d.ts +1 -0
- package/dist/ts-rest.js +89 -0
- package/package.json +208 -0
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@suss/runtime-node';
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,667 @@
|
|
|
1
|
+
// ../runtime/node/dist/index.js
|
|
2
|
+
import {
|
|
3
|
+
Node as N,
|
|
4
|
+
VariableDeclarationKind
|
|
5
|
+
} from "ts-morph";
|
|
6
|
+
import { runtimeConfigBinding } from "@suss/behavioral-ir";
|
|
7
|
+
import { Node } from "ts-morph";
|
|
8
|
+
import { runtimeConfigBinding as runtimeConfigBinding2 } from "@suss/behavioral-ir";
|
|
9
|
+
import {
|
|
10
|
+
Node as Node2
|
|
11
|
+
} from "ts-morph";
|
|
12
|
+
import { runtimeConfigBinding as runtimeConfigBinding3 } from "@suss/behavioral-ir";
|
|
13
|
+
import {
|
|
14
|
+
Node as Node3
|
|
15
|
+
} from "ts-morph";
|
|
16
|
+
import { functionCallBinding } from "@suss/behavioral-ir";
|
|
17
|
+
var readName = (name) => `process.env.${name}`;
|
|
18
|
+
function isProcessEnv(node) {
|
|
19
|
+
if (!N.isPropertyAccessExpression(node) || node.getName() !== "env") {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const root = node.getExpression();
|
|
23
|
+
return N.isIdentifier(root) && root.getText() === "process";
|
|
24
|
+
}
|
|
25
|
+
function dottedRead(node) {
|
|
26
|
+
if (!isProcessEnv(node.getExpression())) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
return [{ name: node.getName(), defaulted: isDefaultedAt(node), node }];
|
|
30
|
+
}
|
|
31
|
+
function bracketRead(access) {
|
|
32
|
+
const argument = access.getArgumentExpression();
|
|
33
|
+
if (argument === void 0) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
if (N.isStringLiteral(argument) || N.isNoSubstitutionTemplateLiteral(argument)) {
|
|
37
|
+
const name = argument.getLiteralValue();
|
|
38
|
+
if (name.length === 0) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
return [{ name, defaulted: isDefaultedAt(access), node: access }];
|
|
42
|
+
}
|
|
43
|
+
if (N.isIdentifier(argument)) {
|
|
44
|
+
return readsThroughParameter(access, argument);
|
|
45
|
+
}
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
var CALLER_LOOKUPS = /* @__PURE__ */ new WeakMap();
|
|
49
|
+
function readsThroughParameter(access, index) {
|
|
50
|
+
const remembered = CALLER_LOOKUPS.get(access);
|
|
51
|
+
if (remembered !== void 0) {
|
|
52
|
+
return remembered;
|
|
53
|
+
}
|
|
54
|
+
const found = callerLiteralReads(access, index);
|
|
55
|
+
CALLER_LOOKUPS.set(access, found);
|
|
56
|
+
return found;
|
|
57
|
+
}
|
|
58
|
+
function callerLiteralReads(access, index) {
|
|
59
|
+
const enclosing = enclosingFunction(access);
|
|
60
|
+
if (enclosing === void 0) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
const at = enclosing.getParameters().findIndex((parameter) => parameter.getName() === index.getText());
|
|
64
|
+
if (at === -1) {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
const defaulted = isDefaultedAt(access);
|
|
68
|
+
const reads = [];
|
|
69
|
+
const pending = [{ fn: enclosing, at }];
|
|
70
|
+
const taken = /* @__PURE__ */ new Set();
|
|
71
|
+
while (pending.length > 0) {
|
|
72
|
+
const wanted = pending.pop();
|
|
73
|
+
const key = `${wanted.fn.getPos()}:${wanted.at}`;
|
|
74
|
+
if (taken.has(key)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
taken.add(key);
|
|
78
|
+
for (const call of callSitesOf(wanted.fn)) {
|
|
79
|
+
const passed = call.getArguments()[wanted.at];
|
|
80
|
+
if (passed === void 0) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const literal = literalBehind(passed);
|
|
84
|
+
if (literal !== null && literal.length > 0) {
|
|
85
|
+
reads.push({ name: literal, defaulted, node: call });
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const forwarded = forwardedParameter(passed, call);
|
|
89
|
+
if (forwarded !== null) {
|
|
90
|
+
pending.push(forwarded);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return reads;
|
|
95
|
+
}
|
|
96
|
+
function enclosingFunction(node) {
|
|
97
|
+
return node.getFirstAncestor(
|
|
98
|
+
(candidate) => N.isFunctionDeclaration(candidate) || N.isArrowFunction(candidate) || N.isFunctionExpression(candidate) || N.isMethodDeclaration(candidate)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
function literalBehind(passed) {
|
|
102
|
+
if (N.isStringLiteral(passed) || N.isNoSubstitutionTemplateLiteral(passed)) {
|
|
103
|
+
return passed.getLiteralValue();
|
|
104
|
+
}
|
|
105
|
+
if (!N.isIdentifier(passed)) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
for (const definition of passed.getDefinitionNodes()) {
|
|
109
|
+
if (!N.isVariableDeclaration(definition)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const initializer = definition.getInitializer();
|
|
113
|
+
if (initializer !== void 0 && definition.getVariableStatement()?.getDeclarationKind() === VariableDeclarationKind.Const && (N.isStringLiteral(initializer) || N.isNoSubstitutionTemplateLiteral(initializer))) {
|
|
114
|
+
return initializer.getLiteralValue();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
function forwardedParameter(passed, call) {
|
|
120
|
+
if (!N.isIdentifier(passed)) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
const caller = enclosingFunction(call);
|
|
124
|
+
if (caller === void 0) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const at = caller.getParameters().findIndex((parameter) => parameter.getName() === passed.getText());
|
|
128
|
+
return at === -1 ? null : { fn: caller, at };
|
|
129
|
+
}
|
|
130
|
+
function callSitesOf(fn) {
|
|
131
|
+
const named = N.isVariableDeclaration(fn.getParent()) ? fn.getParent().getNameNode() : fn.getNameNode?.();
|
|
132
|
+
if (named === void 0 || !N.isIdentifier(named)) {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
const calls = [];
|
|
136
|
+
for (const reference of named.findReferencesAsNodes()) {
|
|
137
|
+
const parent = reference.getParent();
|
|
138
|
+
if (parent === void 0) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (N.isCallExpression(parent) && parent.getExpression() === reference) {
|
|
142
|
+
calls.push(parent);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (N.isPropertyAccessExpression(parent) && parent.getNameNode() === reference) {
|
|
146
|
+
const grandparent = parent.getParent();
|
|
147
|
+
if (grandparent !== void 0 && N.isCallExpression(grandparent) && grandparent.getExpression() === parent) {
|
|
148
|
+
calls.push(grandparent);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return calls;
|
|
153
|
+
}
|
|
154
|
+
function bindingRead(element) {
|
|
155
|
+
if (element.getDotDotDotToken() !== void 0) {
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
const named = element.getPropertyNameNode() ?? element.getNameNode();
|
|
159
|
+
if (!(N.isIdentifier(named) || N.isStringLiteral(named))) {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
const name = N.isIdentifier(named) ? named.getText() : named.getLiteralValue();
|
|
163
|
+
if (name.length === 0) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
return [
|
|
167
|
+
{
|
|
168
|
+
name,
|
|
169
|
+
// A binding default supplies the value the variable is missing,
|
|
170
|
+
// which is what `??` does for the other two spellings.
|
|
171
|
+
defaulted: element.getInitializer() !== void 0,
|
|
172
|
+
node: element
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
function destructuredReads(declaration) {
|
|
177
|
+
const pattern = declaration.getNameNode();
|
|
178
|
+
if (!N.isObjectBindingPattern(pattern)) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
return pattern.getElements().flatMap(bindingRead);
|
|
182
|
+
}
|
|
183
|
+
function readsThroughEnvObject(envNode) {
|
|
184
|
+
const parent = envNode.getParent();
|
|
185
|
+
if (N.isElementAccessExpression(parent)) {
|
|
186
|
+
return bracketRead(parent);
|
|
187
|
+
}
|
|
188
|
+
if (N.isVariableDeclaration(parent)) {
|
|
189
|
+
return destructuredReads(parent);
|
|
190
|
+
}
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
function envReadsAt(node) {
|
|
194
|
+
if (N.isCallExpression(node)) {
|
|
195
|
+
return readsThroughHelperCall(node);
|
|
196
|
+
}
|
|
197
|
+
if (!N.isPropertyAccessExpression(node)) {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
return isProcessEnv(node) ? readsThroughEnvObject(node) : dottedRead(node);
|
|
201
|
+
}
|
|
202
|
+
function readsThroughHelperCall(call) {
|
|
203
|
+
const reads = [];
|
|
204
|
+
const callee = functionBehindCallee(call.getExpression());
|
|
205
|
+
if (callee === null) {
|
|
206
|
+
return reads;
|
|
207
|
+
}
|
|
208
|
+
call.getArguments().forEach((passed, at) => {
|
|
209
|
+
const literal = literalBehind(passed);
|
|
210
|
+
if (literal === null || literal.length === 0) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const read = parameterReachesEnvRead(callee, at);
|
|
214
|
+
if (read !== null) {
|
|
215
|
+
reads.push({ name: literal, defaulted: read.defaulted, node: call });
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
return reads;
|
|
219
|
+
}
|
|
220
|
+
function functionBehindCallee(callee) {
|
|
221
|
+
const nameNode = N.isPropertyAccessExpression(callee) ? callee.getNameNode() : callee;
|
|
222
|
+
if (!N.isIdentifier(nameNode)) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
for (const definition of nameNode.getDefinitionNodes()) {
|
|
226
|
+
if (N.isFunctionDeclaration(definition) || N.isMethodDeclaration(definition)) {
|
|
227
|
+
return definition;
|
|
228
|
+
}
|
|
229
|
+
if (N.isVariableDeclaration(definition)) {
|
|
230
|
+
const initializer = definition.getInitializer();
|
|
231
|
+
if (initializer !== void 0 && (N.isArrowFunction(initializer) || N.isFunctionExpression(initializer))) {
|
|
232
|
+
return initializer;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
var PARAM_ENV_READS = /* @__PURE__ */ new WeakMap();
|
|
239
|
+
function parameterReachesEnvRead(fn, at) {
|
|
240
|
+
const byParameter = PARAM_ENV_READS.get(fn.compilerNode) ?? /* @__PURE__ */ new Map();
|
|
241
|
+
PARAM_ENV_READS.set(fn.compilerNode, byParameter);
|
|
242
|
+
const remembered = byParameter.get(at);
|
|
243
|
+
if (remembered !== void 0) {
|
|
244
|
+
return remembered;
|
|
245
|
+
}
|
|
246
|
+
let found = null;
|
|
247
|
+
const pending = [{ fn, at }];
|
|
248
|
+
const taken = /* @__PURE__ */ new Set();
|
|
249
|
+
while (pending.length > 0 && found === null) {
|
|
250
|
+
const wanted = pending.pop();
|
|
251
|
+
const key = `${wanted.fn.getPos()}:${wanted.at}`;
|
|
252
|
+
if (taken.has(key)) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
taken.add(key);
|
|
256
|
+
const parameter = wanted.fn.getParameters()[wanted.at];
|
|
257
|
+
if (parameter === void 0) {
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const name = parameter.getName();
|
|
261
|
+
wanted.fn.forEachDescendant((node) => {
|
|
262
|
+
if (found !== null) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (N.isElementAccessExpression(node) && isProcessEnv(node.getExpression())) {
|
|
266
|
+
const argument = node.getArgumentExpression();
|
|
267
|
+
if (argument !== void 0 && argument.getText() === name) {
|
|
268
|
+
found = { defaulted: isDefaultedAt(node) };
|
|
269
|
+
}
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (N.isCallExpression(node)) {
|
|
273
|
+
node.getArguments().forEach((argument, position) => {
|
|
274
|
+
if (!N.isIdentifier(argument) || argument.getText() !== name) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const next = functionBehindCallee(node.getExpression());
|
|
278
|
+
if (next !== null && next !== wanted.fn) {
|
|
279
|
+
pending.push({ fn: next, at: position });
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
byParameter.set(at, found);
|
|
286
|
+
return found;
|
|
287
|
+
}
|
|
288
|
+
function isDefaultedAt(node) {
|
|
289
|
+
let child = node;
|
|
290
|
+
let parent = child.getParent();
|
|
291
|
+
while (parent !== void 0) {
|
|
292
|
+
if (N.isParenthesizedExpression(parent)) {
|
|
293
|
+
child = parent;
|
|
294
|
+
parent = parent.getParent();
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
if (!N.isBinaryExpression(parent)) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
const op = parent.getOperatorToken().getText();
|
|
301
|
+
if (op !== "??" && op !== "||") {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
if (parent.getLeft() === child) {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
child = parent;
|
|
308
|
+
parent = parent.getParent();
|
|
309
|
+
}
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
function configReadEffect(read, deploymentTarget, instanceName) {
|
|
313
|
+
return {
|
|
314
|
+
type: "interaction",
|
|
315
|
+
binding: runtimeConfigBinding({
|
|
316
|
+
recognition: "@suss/runtime-node",
|
|
317
|
+
deploymentTarget,
|
|
318
|
+
instanceName
|
|
319
|
+
}),
|
|
320
|
+
callee: readName(read.name),
|
|
321
|
+
interaction: {
|
|
322
|
+
class: "config-read",
|
|
323
|
+
name: read.name,
|
|
324
|
+
defaulted: read.defaulted
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function recognizeProcessEnvRead(access, deploymentTarget, instanceName) {
|
|
329
|
+
const reads = envReadsAt(access);
|
|
330
|
+
if (reads.length === 0) {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
return reads.map(
|
|
334
|
+
(read) => configReadEffect(read, deploymentTarget, instanceName)
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
function envVarRecognizer(opts = {}) {
|
|
338
|
+
const deploymentTarget = opts.deploymentTarget ?? "lambda";
|
|
339
|
+
const instanceName = opts.instanceName ?? "<unknown>";
|
|
340
|
+
return (access, _ctx) => recognizeProcessEnvRead(access, deploymentTarget, instanceName);
|
|
341
|
+
}
|
|
342
|
+
var FILE_LOCATION_GLOBALS = /* @__PURE__ */ new Set(["__dirname", "__filename"]);
|
|
343
|
+
function moduleMetaRead(callee) {
|
|
344
|
+
return {
|
|
345
|
+
type: "interaction",
|
|
346
|
+
binding: runtimeConfigBinding2({
|
|
347
|
+
recognition: "@suss/runtime-node",
|
|
348
|
+
deploymentTarget: "lambda",
|
|
349
|
+
instanceName: "<runtime>"
|
|
350
|
+
}),
|
|
351
|
+
callee,
|
|
352
|
+
interaction: {
|
|
353
|
+
class: "config-read",
|
|
354
|
+
name: callee,
|
|
355
|
+
defaulted: false
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
var importMetaRecognizer = (access, _ctx) => {
|
|
360
|
+
const node = access;
|
|
361
|
+
if (!Node.isPropertyAccessExpression(node)) {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
const inner = node.getExpression();
|
|
365
|
+
if (!Node.isMetaProperty(inner)) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
const keyword = inner.getKeywordToken();
|
|
369
|
+
if (keyword === void 0 || inner.getNameNode().getText() !== "meta") {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
return [moduleMetaRead(node.getText())];
|
|
373
|
+
};
|
|
374
|
+
var fileLocationRecognizer = (access, _ctx) => {
|
|
375
|
+
const node = access;
|
|
376
|
+
if (!Node.isPropertyAccessExpression(node)) {
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
const subject = node.getExpression();
|
|
380
|
+
if (!Node.isIdentifier(subject)) {
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
const text = subject.getText();
|
|
384
|
+
if (!FILE_LOCATION_GLOBALS.has(text)) {
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
return [moduleMetaRead(text)];
|
|
388
|
+
};
|
|
389
|
+
function isProcessEnvVarRead(node) {
|
|
390
|
+
const inner = node.getExpression();
|
|
391
|
+
if (!Node2.isPropertyAccessExpression(inner)) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
if (inner.getName() !== "env") {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
const root = inner.getExpression();
|
|
398
|
+
return Node2.isIdentifier(root) && root.getText() === "process";
|
|
399
|
+
}
|
|
400
|
+
function isProcessIdentifier(node) {
|
|
401
|
+
return Node2.isIdentifier(node) && node.getText() === "process";
|
|
402
|
+
}
|
|
403
|
+
var OPAQUE_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
404
|
+
"cwd",
|
|
405
|
+
"platform",
|
|
406
|
+
"version",
|
|
407
|
+
"versions",
|
|
408
|
+
"pid",
|
|
409
|
+
"ppid",
|
|
410
|
+
"arch",
|
|
411
|
+
"execPath",
|
|
412
|
+
"execArgv"
|
|
413
|
+
]);
|
|
414
|
+
function makeProcessSurfaceRecognizer(opts) {
|
|
415
|
+
const deploymentTarget = opts.deploymentTarget ?? "lambda";
|
|
416
|
+
const instanceName = opts.instanceName ?? "<unknown>";
|
|
417
|
+
return (access, _ctx) => {
|
|
418
|
+
const node = access;
|
|
419
|
+
if (Node2.isPropertyAccessExpression(node)) {
|
|
420
|
+
return recognizeProperty(node, deploymentTarget, instanceName);
|
|
421
|
+
}
|
|
422
|
+
if (Node2.isElementAccessExpression(node)) {
|
|
423
|
+
return recognizeElementAccess(node, deploymentTarget, instanceName);
|
|
424
|
+
}
|
|
425
|
+
return null;
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
function recognizeProperty(node, deploymentTarget, instanceName) {
|
|
429
|
+
if (isProcessEnvVarRead(node)) {
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
const subject = node.getExpression();
|
|
433
|
+
const name = node.getName();
|
|
434
|
+
if (isProcessIdentifier(subject) && name === "argv") {
|
|
435
|
+
return [argvRead(deploymentTarget, instanceName, node.getText(), null)];
|
|
436
|
+
}
|
|
437
|
+
if (isProcessIdentifier(subject) && OPAQUE_PROPERTY_NAMES.has(name)) {
|
|
438
|
+
return [opaqueProcessRead(node.getText(), `process.${name}`)];
|
|
439
|
+
}
|
|
440
|
+
return null;
|
|
441
|
+
}
|
|
442
|
+
function recognizeElementAccess(node, deploymentTarget, instanceName) {
|
|
443
|
+
const subject = node.getExpression();
|
|
444
|
+
if (!Node2.isPropertyAccessExpression(subject)) {
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
if (subject.getName() !== "argv") {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
const root = subject.getExpression();
|
|
451
|
+
if (!isProcessIdentifier(root)) {
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
const arg = node.getArgumentExpression();
|
|
455
|
+
let indexLabel = null;
|
|
456
|
+
if (arg !== void 0 && Node2.isNumericLiteral(arg)) {
|
|
457
|
+
indexLabel = String(arg.getLiteralValue());
|
|
458
|
+
}
|
|
459
|
+
return [argvRead(deploymentTarget, instanceName, node.getText(), indexLabel)];
|
|
460
|
+
}
|
|
461
|
+
function argvRead(deploymentTarget, instanceName, callee, indexLabel) {
|
|
462
|
+
const name = indexLabel !== null ? `argv[${indexLabel}]` : "argv";
|
|
463
|
+
return {
|
|
464
|
+
type: "interaction",
|
|
465
|
+
binding: runtimeConfigBinding3({
|
|
466
|
+
recognition: "@suss/runtime-node",
|
|
467
|
+
deploymentTarget,
|
|
468
|
+
instanceName
|
|
469
|
+
}),
|
|
470
|
+
callee,
|
|
471
|
+
interaction: {
|
|
472
|
+
class: "config-read",
|
|
473
|
+
name,
|
|
474
|
+
defaulted: false
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
function opaqueProcessRead(callee, _label) {
|
|
479
|
+
return {
|
|
480
|
+
type: "interaction",
|
|
481
|
+
binding: runtimeConfigBinding3({
|
|
482
|
+
recognition: "@suss/runtime-node",
|
|
483
|
+
deploymentTarget: "lambda",
|
|
484
|
+
instanceName: "<runtime>"
|
|
485
|
+
}),
|
|
486
|
+
callee,
|
|
487
|
+
interaction: {
|
|
488
|
+
class: "config-read",
|
|
489
|
+
name: callee,
|
|
490
|
+
defaulted: false
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function processSurfaceRecognizer(opts = {}) {
|
|
495
|
+
return makeProcessSurfaceRecognizer(opts);
|
|
496
|
+
}
|
|
497
|
+
var PRIMITIVES = [
|
|
498
|
+
{
|
|
499
|
+
via: "setImmediate",
|
|
500
|
+
hasDelayArg: false,
|
|
501
|
+
matches: (c) => isBareIdentifierCall(c, "setImmediate")
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
via: "setTimeout",
|
|
505
|
+
hasDelayArg: true,
|
|
506
|
+
matches: (c) => isBareIdentifierCall(c, "setTimeout")
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
via: "setInterval",
|
|
510
|
+
hasDelayArg: true,
|
|
511
|
+
matches: (c) => isBareIdentifierCall(c, "setInterval")
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
via: "queueMicrotask",
|
|
515
|
+
hasDelayArg: false,
|
|
516
|
+
matches: (c) => isBareIdentifierCall(c, "queueMicrotask")
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
via: "process.nextTick",
|
|
520
|
+
hasDelayArg: false,
|
|
521
|
+
matches: (c) => isPropertyAccessCall(c, "process", "nextTick")
|
|
522
|
+
}
|
|
523
|
+
];
|
|
524
|
+
function isBareIdentifierCall(call, name) {
|
|
525
|
+
const callee = call.getExpression();
|
|
526
|
+
return Node3.isIdentifier(callee) && callee.getText() === name;
|
|
527
|
+
}
|
|
528
|
+
function isPropertyAccessCall(call, rootName, propName) {
|
|
529
|
+
const callee = call.getExpression();
|
|
530
|
+
if (!Node3.isPropertyAccessExpression(callee)) {
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
const pae = callee;
|
|
534
|
+
if (pae.getName() !== propName) {
|
|
535
|
+
return false;
|
|
536
|
+
}
|
|
537
|
+
const root = pae.getExpression();
|
|
538
|
+
return Node3.isIdentifier(root) && root.getText() === rootName;
|
|
539
|
+
}
|
|
540
|
+
function recognizePrimitive(call) {
|
|
541
|
+
for (const p of PRIMITIVES) {
|
|
542
|
+
if (p.matches(call)) {
|
|
543
|
+
return p;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
548
|
+
function describeCallback(arg) {
|
|
549
|
+
if (arg === void 0) {
|
|
550
|
+
return { type: "opaque", reason: "missing-callback-argument" };
|
|
551
|
+
}
|
|
552
|
+
if (Node3.isArrowFunction(arg) || Node3.isFunctionExpression(arg)) {
|
|
553
|
+
return { type: "literal" };
|
|
554
|
+
}
|
|
555
|
+
if (Node3.isIdentifier(arg)) {
|
|
556
|
+
return { type: "identifier", name: arg.getText() };
|
|
557
|
+
}
|
|
558
|
+
return { type: "opaque", reason: "non-literal-callback" };
|
|
559
|
+
}
|
|
560
|
+
var schedulingRecognizer = (call, _ctx) => {
|
|
561
|
+
const c = call;
|
|
562
|
+
if (!Node3.isCallExpression(c)) {
|
|
563
|
+
return null;
|
|
564
|
+
}
|
|
565
|
+
const primitive = recognizePrimitive(c);
|
|
566
|
+
if (primitive === null) {
|
|
567
|
+
return null;
|
|
568
|
+
}
|
|
569
|
+
const callback = describeCallback(c.getArguments()[0]);
|
|
570
|
+
const callbackRef = callback.type === "literal" ? { type: "literal" } : callback.type === "identifier" ? { type: "identifier", name: callback.name ?? "<unknown>" } : {
|
|
571
|
+
type: "opaque",
|
|
572
|
+
reason: callback.reason ?? "non-literal-callback"
|
|
573
|
+
};
|
|
574
|
+
const effect = {
|
|
575
|
+
type: "interaction",
|
|
576
|
+
binding: functionCallBinding({
|
|
577
|
+
transport: "in-process",
|
|
578
|
+
recognition: "@suss/runtime-node"
|
|
579
|
+
}),
|
|
580
|
+
callee: c.getExpression().getText(),
|
|
581
|
+
interaction: {
|
|
582
|
+
class: "schedule",
|
|
583
|
+
via: primitive.via,
|
|
584
|
+
callbackRef,
|
|
585
|
+
hasDelay: primitive.hasDelayArg && c.getArguments().length >= 2
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
return [effect];
|
|
589
|
+
};
|
|
590
|
+
var SCHEDULED_CALLBACK_INPUT = {
|
|
591
|
+
type: "positionalParams",
|
|
592
|
+
// Timer callbacks receive whatever `...args` were passed at the
|
|
593
|
+
// schedule site. v0 doesn't track these positions individually,
|
|
594
|
+
// packs that need argument-shape modeling can layer it on top.
|
|
595
|
+
params: []
|
|
596
|
+
};
|
|
597
|
+
function nodeSchedulingSubUnits(parent, _ctx) {
|
|
598
|
+
const parentFunc = parent.func;
|
|
599
|
+
const out = [];
|
|
600
|
+
const counters = /* @__PURE__ */ new Map();
|
|
601
|
+
parentFunc.forEachDescendant((node, traversal) => {
|
|
602
|
+
if (node !== parentFunc && (Node3.isFunctionDeclaration(node) || Node3.isFunctionExpression(node) || Node3.isArrowFunction(node) || Node3.isMethodDeclaration(node))) {
|
|
603
|
+
traversal.skip();
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (!Node3.isCallExpression(node)) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
const primitive = recognizePrimitive(node);
|
|
610
|
+
if (primitive === null) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
const arg = node.getArguments()[0];
|
|
614
|
+
if (arg === void 0 || !(Node3.isArrowFunction(arg) || Node3.isFunctionExpression(arg))) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
const idx = counters.get(primitive.via) ?? 0;
|
|
618
|
+
counters.set(primitive.via, idx + 1);
|
|
619
|
+
out.push({
|
|
620
|
+
func: arg,
|
|
621
|
+
kind: "scheduled-callback",
|
|
622
|
+
// Naming convention: `<parent>.<via>#<index>`. Multiple
|
|
623
|
+
// setImmediate calls in the same parent get distinct indices.
|
|
624
|
+
name: `${parent.name}.${primitive.via}#${idx}`,
|
|
625
|
+
inputMapping: SCHEDULED_CALLBACK_INPUT,
|
|
626
|
+
metadata: {
|
|
627
|
+
node: {
|
|
628
|
+
schedulingPrimitive: primitive.via
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
});
|
|
633
|
+
return out;
|
|
634
|
+
}
|
|
635
|
+
var PACK_VERSION = "0.1.0";
|
|
636
|
+
function nodeRuntimePack(options = {}) {
|
|
637
|
+
const configOptions = {
|
|
638
|
+
...options.deploymentTarget !== void 0 ? { deploymentTarget: options.deploymentTarget } : {},
|
|
639
|
+
...options.instanceName !== void 0 ? { instanceName: options.instanceName } : {}
|
|
640
|
+
};
|
|
641
|
+
const processRecognizer = processSurfaceRecognizer(configOptions);
|
|
642
|
+
const envRecognizer = envVarRecognizer(configOptions);
|
|
643
|
+
return {
|
|
644
|
+
name: "node",
|
|
645
|
+
version: PACK_VERSION,
|
|
646
|
+
protocol: "in-process",
|
|
647
|
+
languages: ["typescript", "javascript"],
|
|
648
|
+
discovery: [],
|
|
649
|
+
terminals: [],
|
|
650
|
+
inputMapping: { type: "positionalParams", params: [] },
|
|
651
|
+
invocationRecognizers: [schedulingRecognizer],
|
|
652
|
+
accessRecognizers: [
|
|
653
|
+
// `envRecognizer` owns `process.env.X`; `processRecognizer`
|
|
654
|
+
// owns the rest of the process surface and skips env reads,
|
|
655
|
+
// together they partition `process.*` without duplication.
|
|
656
|
+
envRecognizer,
|
|
657
|
+
processRecognizer,
|
|
658
|
+
importMetaRecognizer,
|
|
659
|
+
fileLocationRecognizer
|
|
660
|
+
],
|
|
661
|
+
subUnits: nodeSchedulingSubUnits
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
var index_default = nodeRuntimePack;
|
|
665
|
+
export {
|
|
666
|
+
index_default as default
|
|
667
|
+
};
|
package/dist/prisma.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@suss/framework-prisma';
|