@suss/recognize 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +294 -2
- package/dist/ast.d.cts +1 -1
- package/dist/ast.d.ts +1 -1
- package/dist/chain-BaxjT_-k.d.cts +530 -0
- package/dist/chain-BaxjT_-k.d.ts +530 -0
- package/dist/index.cjs +385 -85
- package/dist/index.d.cts +141 -40
- package/dist/index.d.ts +141 -40
- package/dist/index.js +383 -85
- package/package.json +4 -3
- package/dist/chain-DTSij2Mn.d.cts +0 -197
- package/dist/chain-DTSij2Mn.d.ts +0 -197
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The operations a chain performs at one call site, and what a language
|
|
3
|
+
* adapter has to be able to work out for it.
|
|
4
|
+
*
|
|
5
|
+
* A chain is data, so something has to turn "did this module declare
|
|
6
|
+
* the method" into a yes or no about a particular program. That is the
|
|
7
|
+
* adapter's job, and this interface is the whole of what a chain asks
|
|
8
|
+
* for. An adapter implements it once and every declared pack runs
|
|
9
|
+
* there, which is what lets one pack drive several languages.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here mentions a syntax tree. A link that needs the tree goes
|
|
12
|
+
* through `@suss/recognize/ast`, a separate import so that reaching for
|
|
13
|
+
* it shows up in a diff and in the pack health report.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* How a pack pins down the receiver a call is on.
|
|
17
|
+
*
|
|
18
|
+
* The migration plan for #542 lists four more: `factoryMade` (`app =
|
|
19
|
+
* express()`), `imported`, `anchored` (a chain read from its anchor
|
|
20
|
+
* call), `inherits` (a Ruby or Python receiver matched by ancestry) and
|
|
21
|
+
* `global` (`process.env`, bare `fetch`). Each arrives as a member here
|
|
22
|
+
* with an entry in every adapter's dispatch table. The README beside
|
|
23
|
+
* this file says which starts are not receiver-shaped at all.
|
|
24
|
+
*/
|
|
25
|
+
type ReceiverOrigin = DeclaredBy | ConstructedFrom;
|
|
26
|
+
/**
|
|
27
|
+
* A receiver whose method one of these modules declared.
|
|
28
|
+
*
|
|
29
|
+
* This is the origin for a client the source never spells out. `const
|
|
30
|
+
* redis = await this.getClient()` says nothing about ioredis, and the
|
|
31
|
+
* declaration behind `redis.get` says everything.
|
|
32
|
+
*/
|
|
33
|
+
interface DeclaredBy {
|
|
34
|
+
readonly origin: "declaredBy";
|
|
35
|
+
/** The modules whose declarations settle the call. */
|
|
36
|
+
readonly importedFrom: readonly string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A client made from a module's export, however the program caches it.
|
|
40
|
+
* Asked of the receiver itself, so it still works where the method is untyped
|
|
41
|
+
* and `declaredBy` finds nothing to read. A call that reaches for no
|
|
42
|
+
* receiver, `new GetObjectCommand(...)`, is made by its own callee.
|
|
43
|
+
*/
|
|
44
|
+
interface ConstructedFrom {
|
|
45
|
+
readonly origin: "constructed";
|
|
46
|
+
/** The modules whose export the client was made from. */
|
|
47
|
+
readonly importedFrom: readonly string[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A receiver whose method one of these modules declared. Pass every
|
|
51
|
+
* module that ships the same client, the way three packages all speak
|
|
52
|
+
* one wire protocol.
|
|
53
|
+
*/
|
|
54
|
+
declare function declaredBy(...importedFrom: readonly string[]): DeclaredBy;
|
|
55
|
+
/** A client made from one of these modules' exports. */
|
|
56
|
+
declare function constructedFrom(...importedFrom: readonly string[]): ConstructedFrom;
|
|
57
|
+
/**
|
|
58
|
+
* What a reader gives back for a name nothing in the source settles.
|
|
59
|
+
* `"nothing"` gives null, `"reference"` gives the value to go and ask
|
|
60
|
+
* about instead.
|
|
61
|
+
*/
|
|
62
|
+
type UnsettledName = "nothing" | "reference";
|
|
63
|
+
/**
|
|
64
|
+
* One value a call states, as the questions a pack can ask about it.
|
|
65
|
+
*
|
|
66
|
+
* `CallOps` reaches a call beside the one in hand, and this reaches the
|
|
67
|
+
* values that are not calls. A library that takes one request object
|
|
68
|
+
* puts everything the call is doing inside it, sometimes as a list and
|
|
69
|
+
* sometimes as a string in a little language of the library's own, and
|
|
70
|
+
* a pack that reads those is handed this rather than the adapter's own
|
|
71
|
+
* node. So the rule it writes runs wherever the ops do.
|
|
72
|
+
*/
|
|
73
|
+
interface ValueOps {
|
|
74
|
+
/** The text of the string the source wrote, or null for anything else. */
|
|
75
|
+
text(): string | null;
|
|
76
|
+
/**
|
|
77
|
+
* The yes or no the source wrote here, or null for anything else. A
|
|
78
|
+
* library that asks which fields a call wants states them as a map of
|
|
79
|
+
* flags, `{ name: 1, password: 0 }`, and a number and a boolean mean
|
|
80
|
+
* the same thing in one of those.
|
|
81
|
+
*/
|
|
82
|
+
flag(): boolean | null;
|
|
83
|
+
/** What this object states, entry by entry. Empty for anything else. */
|
|
84
|
+
entries(unsettled: UnsettledName): readonly ValueEntry[];
|
|
85
|
+
/** What this list states, item by item. Empty for anything else. */
|
|
86
|
+
items(): readonly ValueOps[];
|
|
87
|
+
/** What one named property of this object states, or null for none. */
|
|
88
|
+
property(name: string): ValueOps | null;
|
|
89
|
+
/**
|
|
90
|
+
* The pieces of text the source wrote here, in order, with whatever
|
|
91
|
+
* it interpolated between them left out. A string is one piece and a
|
|
92
|
+
* template is one piece per hole plus one, so a reader that means to
|
|
93
|
+
* put its own placeholders in the holes can. Null when the source
|
|
94
|
+
* wrote neither.
|
|
95
|
+
*/
|
|
96
|
+
parts(): readonly string[] | null;
|
|
97
|
+
/**
|
|
98
|
+
* What the source interpolated between those pieces, in order, each
|
|
99
|
+
* as the call it was written as. There is one per gap, one fewer than
|
|
100
|
+
* `parts` gives, and a hole the source wrote as something other than
|
|
101
|
+
* a call is null rather than being dropped, so the two lists stay in
|
|
102
|
+
* step.
|
|
103
|
+
*
|
|
104
|
+
* What a hole comes to is the pack's to say. This says what was
|
|
105
|
+
* there, so a query that hands over a table object can still be read.
|
|
106
|
+
*/
|
|
107
|
+
holes(): readonly (CallOps | null)[];
|
|
108
|
+
}
|
|
109
|
+
/** One entry of an object a call states. */
|
|
110
|
+
interface ValueEntry {
|
|
111
|
+
/**
|
|
112
|
+
* What the entry is called. A key the source computes,
|
|
113
|
+
* `{ [table]: ... }`, is read the way any other name is.
|
|
114
|
+
*/
|
|
115
|
+
readonly key: string | null;
|
|
116
|
+
/** What the entry says. */
|
|
117
|
+
readonly value: ValueOps;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* One call site, as the questions a chain asks about it.
|
|
121
|
+
*
|
|
122
|
+
* An adapter builds one of these per call and hands it to the
|
|
123
|
+
* recognizer through its context. Every member is about the call in
|
|
124
|
+
* hand, so there is no node to pass around and no place for a pack to
|
|
125
|
+
* reach past what it declared.
|
|
126
|
+
*
|
|
127
|
+
* Two members give back another `CallOps`, which is how these questions
|
|
128
|
+
* reach a call next to this one. A chain of calls and a command object
|
|
129
|
+
* are both these same questions asked one step along, so neither needed
|
|
130
|
+
* a question of its own.
|
|
131
|
+
*/
|
|
132
|
+
interface CallOps {
|
|
133
|
+
/** Which method the call reaches for, spelled as the source spells it. */
|
|
134
|
+
method(): string | null;
|
|
135
|
+
/** Whether the receiver came from where the origin says. */
|
|
136
|
+
receiverIsFrom(origin: ReceiverOrigin): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Whether the call itself came from where the origin says, which is
|
|
139
|
+
* the same question asked of the callee rather than of what it was
|
|
140
|
+
* called on. `new GetCommand(...)` is the case: a pack that steps to
|
|
141
|
+
* an argument asks this of it before reading anything, so it never
|
|
142
|
+
* reads an argument that was never the one.
|
|
143
|
+
*/
|
|
144
|
+
isFrom(origin: ReceiverOrigin): boolean;
|
|
145
|
+
/** How many arguments the call passes. */
|
|
146
|
+
argumentCount(): number;
|
|
147
|
+
/** The name the argument in this position gives. */
|
|
148
|
+
nameAt(index: number, unsettled: UnsettledName): string | null;
|
|
149
|
+
/** The callee, as the source writes it. */
|
|
150
|
+
calleeText(): string;
|
|
151
|
+
/**
|
|
152
|
+
* The call the receiver is, or null when the receiver is not a call.
|
|
153
|
+
* A receiver the source wrote into a variable comes back as the call
|
|
154
|
+
* it was written as.
|
|
155
|
+
*/
|
|
156
|
+
receiver(): CallOps | null;
|
|
157
|
+
/**
|
|
158
|
+
* The call the argument in this position is, or null when that
|
|
159
|
+
* argument is neither a call nor a construction. `new
|
|
160
|
+
* GetObjectCommand(...)` comes back as a call whose callee is the
|
|
161
|
+
* class, the same as any other call.
|
|
162
|
+
*/
|
|
163
|
+
argument(index: number): CallOps | null;
|
|
164
|
+
/**
|
|
165
|
+
* The call the callee itself was written as, or null when nothing
|
|
166
|
+
* wrote it as one. A class a factory made is the case: `new
|
|
167
|
+
* User({...})` says nothing about what `User` is, and the
|
|
168
|
+
* `model("User", schema)` call it was declared as says everything.
|
|
169
|
+
*/
|
|
170
|
+
callee(): CallOps | null;
|
|
171
|
+
/**
|
|
172
|
+
* What a named property of the object an argument states says. A
|
|
173
|
+
* property bag is not a call, so nothing else here reaches into one.
|
|
174
|
+
*/
|
|
175
|
+
propertyAt(index: number, property: string, unsettled: UnsettledName): string | null;
|
|
176
|
+
/**
|
|
177
|
+
* The value the argument in this position states, or null when the
|
|
178
|
+
* call passes none. `propertyAt` reads one name out of a property
|
|
179
|
+
* bag, which covers a pack that wants one; this hands the bag over
|
|
180
|
+
* for a pack whose rule has to walk it.
|
|
181
|
+
*/
|
|
182
|
+
valueAt(index: number): ValueOps | null;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The property an adapter puts its ops on, in the context it hands a
|
|
186
|
+
* recognizer. A context without it belongs to an adapter that has not
|
|
187
|
+
* implemented the ops, and a declared pack matches nothing there.
|
|
188
|
+
*/
|
|
189
|
+
interface OpsCarrier {
|
|
190
|
+
ops?: CallOps;
|
|
191
|
+
}
|
|
192
|
+
/** The ops in a recognizer context, or null when the adapter has none. */
|
|
193
|
+
declare function opsIn(ctx: unknown): CallOps | null;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The spine every pack shares, as a chain of links.
|
|
197
|
+
*
|
|
198
|
+
* A pack does four jobs, and all four start the same way: match the
|
|
199
|
+
* receiver, match the method, read the arguments, then yield. What
|
|
200
|
+
* differs is the ending. Recognition yields effects, discovery yields a
|
|
201
|
+
* unit, a terminal yields a response write, and a claimed callback
|
|
202
|
+
* yields a sub-unit. Two recognition endings are built, one that asks
|
|
203
|
+
* the call what it reached and one that reads the statement the call
|
|
204
|
+
* was handed; the other three jobs are further members of `Ending`
|
|
205
|
+
* with an entry in the compile table.
|
|
206
|
+
*
|
|
207
|
+
* A link's answer is data wherever it can be. A link given a function
|
|
208
|
+
* instead is code, that link alone, and pack health says which ones.
|
|
209
|
+
*/
|
|
210
|
+
|
|
211
|
+
/** A link whose answer a pack wrote as code rather than as data. */
|
|
212
|
+
interface LinkFunction<A extends unknown[], R> {
|
|
213
|
+
(...args: A): R;
|
|
214
|
+
/** Set when the function was built through `@suss/recognize/ast`. */
|
|
215
|
+
readonly reachesAst?: boolean;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* What a match starts from.
|
|
219
|
+
*
|
|
220
|
+
* Most of what the shipped packs match starts from a receiver, and none
|
|
221
|
+
* of what discovery matches does: an exported name, a file path, a
|
|
222
|
+
* decorator, a parameter's type, a template file beside the module and
|
|
223
|
+
* a function's return type each start somewhere else. So the start is
|
|
224
|
+
* its own axis, and a receiver origin is one value on it.
|
|
225
|
+
*/
|
|
226
|
+
type MatchStart = FromReceiver;
|
|
227
|
+
/** A match that starts from the receiver a call is on. */
|
|
228
|
+
interface FromReceiver {
|
|
229
|
+
readonly starts: "receiver";
|
|
230
|
+
readonly origin: ReceiverOrigin;
|
|
231
|
+
}
|
|
232
|
+
/** Where the match begins. */
|
|
233
|
+
interface StartLink {
|
|
234
|
+
readonly asks: "start";
|
|
235
|
+
readonly at: MatchStart;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* One step from a call to another call it reaches.
|
|
239
|
+
*
|
|
240
|
+
* A pack that has to read a chain of calls, or a command a call was
|
|
241
|
+
* handed, states the steps to it and asks the same questions there. The
|
|
242
|
+
* steps are data, so a pack that reads three calls still declares three
|
|
243
|
+
* links rather than one function that walks.
|
|
244
|
+
*/
|
|
245
|
+
type CallStep = ToReceiver | ToArgument;
|
|
246
|
+
/**
|
|
247
|
+
* The call the receiver is. With a method, the walk keeps going up the
|
|
248
|
+
* receivers until it reaches a call to that method, which is how a pack
|
|
249
|
+
* says which hop it means where the shape varies:
|
|
250
|
+
* `bucket(b).file(p).download()` and `bucket(b).getFiles()` put the
|
|
251
|
+
* bucket a different distance away.
|
|
252
|
+
*/
|
|
253
|
+
interface ToReceiver {
|
|
254
|
+
readonly to: "receiver";
|
|
255
|
+
readonly method?: string;
|
|
256
|
+
}
|
|
257
|
+
/** The call an argument is, when the argument is a call or a construction. */
|
|
258
|
+
interface ToArgument {
|
|
259
|
+
readonly to: "argument";
|
|
260
|
+
/** Which argument, or every argument from a position on. */
|
|
261
|
+
readonly at: number | {
|
|
262
|
+
readonly from: number;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Where the argument has to have come from, for a step that tries
|
|
266
|
+
* several. `send(command)` takes one argument and a presigner takes
|
|
267
|
+
* two, and the one that matters is the command the SDK declares, so
|
|
268
|
+
* the step says so rather than reading whatever it lands on.
|
|
269
|
+
*/
|
|
270
|
+
readonly origin?: ReceiverOrigin;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Which call a chain is about, when it is not the one in hand.
|
|
274
|
+
*
|
|
275
|
+
* The method is `send` at every AWS SDK call site in a codebase, and
|
|
276
|
+
* what the call does is inside the command it was handed. A chain about
|
|
277
|
+
* the command reads the operation, the container and the selector off
|
|
278
|
+
* it, and the effect still records the call in hand as its callee.
|
|
279
|
+
*/
|
|
280
|
+
interface SubjectLink {
|
|
281
|
+
readonly asks: "subject";
|
|
282
|
+
readonly of: readonly CallStep[];
|
|
283
|
+
}
|
|
284
|
+
/** Which methods count, and what each one does. */
|
|
285
|
+
interface MethodsLink<TMeaning> {
|
|
286
|
+
readonly asks: "methods";
|
|
287
|
+
readonly table: Readonly<Record<string, TMeaning>>;
|
|
288
|
+
/**
|
|
289
|
+
* Whether two spellings of one method name are the same method. One
|
|
290
|
+
* client library lower-cases where another camel-cases, and both are
|
|
291
|
+
* sending the same command.
|
|
292
|
+
*/
|
|
293
|
+
readonly ignoringCase: boolean;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Which container a call's selector belongs to, as an argument the call
|
|
297
|
+
* states or as the pack's own rule over what the call reached.
|
|
298
|
+
*/
|
|
299
|
+
type ContainerLink = ContainerArgument | ContainerRule;
|
|
300
|
+
/** The container as one of the call's own arguments states it. */
|
|
301
|
+
interface ContainerArgument {
|
|
302
|
+
readonly asks: "container";
|
|
303
|
+
readonly argument: ArgumentPick;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The container worked out by the pack. The call the chain is about
|
|
307
|
+
* comes second so that a rule written over the selector alone, which is
|
|
308
|
+
* most of them, ignores it. A rule that has to read the syntax tree
|
|
309
|
+
* goes through `astLink`, which is what puts the call to use.
|
|
310
|
+
*/
|
|
311
|
+
interface ContainerRule {
|
|
312
|
+
readonly asks: "container";
|
|
313
|
+
readonly from: LinkFunction<[readonly string[], CallOps], string | null>;
|
|
314
|
+
}
|
|
315
|
+
/** Which way into the container the call took, when it states one. */
|
|
316
|
+
interface AccessPathLink {
|
|
317
|
+
readonly asks: "accessPath";
|
|
318
|
+
readonly argument: ArgumentPick;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Where a call states the containers it reached, for a call that
|
|
322
|
+
* reaches several at once. A batch or a transaction states them as a
|
|
323
|
+
* map, one entry per container, so the chain yields one effect per
|
|
324
|
+
* entry: the entry's own key is what the container is called, and its
|
|
325
|
+
* value says what the call did there.
|
|
326
|
+
*/
|
|
327
|
+
interface ContainersLink {
|
|
328
|
+
readonly asks: "containers";
|
|
329
|
+
readonly in: OneArgument;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Where a call states its inputs, when it states them as one object
|
|
333
|
+
* rather than as positional arguments. A call that states none is not
|
|
334
|
+
* one of these calls, so the chain stops there, and a rule the pack
|
|
335
|
+
* writes over the inputs is handed the object rather than a position to
|
|
336
|
+
* go looking in.
|
|
337
|
+
*/
|
|
338
|
+
interface InputLink {
|
|
339
|
+
readonly asks: "input";
|
|
340
|
+
readonly at: OneArgument;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* What the values a statement interpolates come to.
|
|
344
|
+
*
|
|
345
|
+
* A query that says which table it reached by handing over the schema
|
|
346
|
+
* object leaves the name out of the text, and a parameter in its place
|
|
347
|
+
* does not parse. Only the pack knows the object is a table rather than
|
|
348
|
+
* a value, so the pack says which argument of the call behind it gives
|
|
349
|
+
* the name, and where that call had to have come from.
|
|
350
|
+
*/
|
|
351
|
+
interface InterpolatesLink {
|
|
352
|
+
readonly asks: "interpolates";
|
|
353
|
+
/** Which argument of the call the value was written as gives the name. */
|
|
354
|
+
readonly named: ArgumentPick;
|
|
355
|
+
/** Where the value had to have come from. Left out, every hole is read. */
|
|
356
|
+
readonly from?: ReceiverOrigin;
|
|
357
|
+
}
|
|
358
|
+
/** One question in a chain, and the answer the pack gave for it. */
|
|
359
|
+
type Link<TMeaning> = StartLink | SubjectLink | MethodsLink<TMeaning> | ContainerLink | AccessPathLink | ContainersLink | InputLink | InterpolatesLink;
|
|
360
|
+
/**
|
|
361
|
+
* Which argument or arguments say what a call reached, and where to go
|
|
362
|
+
* looking. Without `of` the argument belongs to the chain's subject.
|
|
363
|
+
*/
|
|
364
|
+
type ArgumentPick = OneArgument | ArgumentsFrom;
|
|
365
|
+
/** The argument in one position. */
|
|
366
|
+
interface OneArgument {
|
|
367
|
+
/** The steps to the call the argument belongs to. */
|
|
368
|
+
readonly of?: readonly CallStep[];
|
|
369
|
+
readonly at: number;
|
|
370
|
+
/**
|
|
371
|
+
* Properties of the object the argument states, tried in order, when
|
|
372
|
+
* what the call reached is inside the argument rather than being it.
|
|
373
|
+
*/
|
|
374
|
+
readonly property?: readonly string[];
|
|
375
|
+
}
|
|
376
|
+
/** Every argument the call passes from one position on. */
|
|
377
|
+
interface ArgumentsFrom {
|
|
378
|
+
/** The steps to the call the arguments belong to. */
|
|
379
|
+
readonly of?: readonly CallStep[];
|
|
380
|
+
readonly from: number;
|
|
381
|
+
/** Properties of the object each argument states, tried in order. */
|
|
382
|
+
readonly property?: readonly string[];
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* What one method of a storage client does to the store: a read, a
|
|
386
|
+
* write, or whichever of the two one of its arguments asked for.
|
|
387
|
+
*/
|
|
388
|
+
type AccessKind = "read" | "write" | KindAsAsked;
|
|
389
|
+
/** A method the caller tells which way round it goes. */
|
|
390
|
+
interface KindAsAsked {
|
|
391
|
+
/** Where the call says what it is for. */
|
|
392
|
+
readonly asks: ArgumentPick;
|
|
393
|
+
/** What each thing the caller can ask for comes to. */
|
|
394
|
+
readonly means: Readonly<Record<string, "read" | "write">>;
|
|
395
|
+
/**
|
|
396
|
+
* What it comes to when the call says nothing. Left out, a call that
|
|
397
|
+
* asks for something the table does not list is not one of these
|
|
398
|
+
* calls, which is how a pack reads a helper whose operations a
|
|
399
|
+
* project lists in its own config.
|
|
400
|
+
*/
|
|
401
|
+
readonly otherwise?: "read" | "write";
|
|
402
|
+
}
|
|
403
|
+
/** What a pack's own rule is handed: one value, and what the call does. */
|
|
404
|
+
interface StatedInputs {
|
|
405
|
+
/**
|
|
406
|
+
* The value the rule reads. That is the object the call states its
|
|
407
|
+
* inputs as when the chain says where with `input`, and the value the
|
|
408
|
+
* rule was pointed at when it says where for itself. A call that
|
|
409
|
+
* passed nothing there states nothing, rather than the rule being
|
|
410
|
+
* skipped: a projection the caller left out is still a read of every
|
|
411
|
+
* field there is, and only the pack knows that.
|
|
412
|
+
*/
|
|
413
|
+
readonly input: ValueOps;
|
|
414
|
+
/** The container's own entry, when the call reached several. */
|
|
415
|
+
readonly entry: ValueOps | null;
|
|
416
|
+
/** What the call does to the store. */
|
|
417
|
+
readonly kind: "read" | "write";
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* A pack's own rule over the inputs a call states, for a library that
|
|
421
|
+
* writes what a reader wants somewhere no pick can reach.
|
|
422
|
+
*/
|
|
423
|
+
type InputRule = LinkFunction<[StatedInputs], readonly string[]>;
|
|
424
|
+
/**
|
|
425
|
+
* A pack's own rule, pointed at the value it reads.
|
|
426
|
+
*
|
|
427
|
+
* `input` says where a call that states one request object states it,
|
|
428
|
+
* and every rule on that chain reads the one value. A library that
|
|
429
|
+
* spreads what a reader wants over several places needs each rule
|
|
430
|
+
* pointed somewhere of its own: Mongoose picks documents by the first
|
|
431
|
+
* argument and reads the fields the second asks for, and Drizzle puts
|
|
432
|
+
* the fields, the table and the condition on three calls of one chain,
|
|
433
|
+
* which the pick's own `of` steps reach.
|
|
434
|
+
*/
|
|
435
|
+
interface StatedRule {
|
|
436
|
+
/** Which value the rule reads. */
|
|
437
|
+
readonly of: OneArgument;
|
|
438
|
+
/** What the pack works out from it. */
|
|
439
|
+
readonly by: InputRule;
|
|
440
|
+
}
|
|
441
|
+
/** What one method of a storage client does. */
|
|
442
|
+
interface StorageMethod {
|
|
443
|
+
readonly kind: AccessKind;
|
|
444
|
+
/**
|
|
445
|
+
* Which argument says which operation the call performs, when the
|
|
446
|
+
* name the call goes to does not. A project's own request helper is
|
|
447
|
+
* the case: every operation goes through the one function.
|
|
448
|
+
*/
|
|
449
|
+
readonly operation?: ArgumentPick;
|
|
450
|
+
/**
|
|
451
|
+
* What the call reached. An argument the call passes, a rule the pack
|
|
452
|
+
* wrote, or the plain list a method whose own name settles it states
|
|
453
|
+
* outright: `findById` picks by `_id` however the id is spelt.
|
|
454
|
+
*/
|
|
455
|
+
readonly selector?: readonly string[] | ArgumentPick | InputRule | StatedRule;
|
|
456
|
+
/**
|
|
457
|
+
* Which fields the call touched, said the same three ways. A delete
|
|
458
|
+
* touches the whole document and states `["*"]`, since nothing in its
|
|
459
|
+
* arguments says so.
|
|
460
|
+
*/
|
|
461
|
+
readonly fields?: readonly string[] | ArgumentPick | InputRule | StatedRule;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* What one method of a client that takes a statement written as SQL
|
|
465
|
+
* does. The statement says which tables it touches and what it does to
|
|
466
|
+
* each, so the only thing a pack has to state is where the call puts
|
|
467
|
+
* it.
|
|
468
|
+
*/
|
|
469
|
+
interface SqlMethod {
|
|
470
|
+
/**
|
|
471
|
+
* Where the call states the statement. The pick's steps reach a call
|
|
472
|
+
* beside this one, which is how a pack reads a statement handed to
|
|
473
|
+
* `execute` as a tagged template rather than written on the call.
|
|
474
|
+
*/
|
|
475
|
+
readonly statement: OneArgument;
|
|
476
|
+
}
|
|
477
|
+
/** What one method table can say a method does. */
|
|
478
|
+
type MethodMeaning = StorageMethod | SqlMethod;
|
|
479
|
+
/** What a chain produces when every link matches. */
|
|
480
|
+
type Ending = StorageEnding | SqlEnding;
|
|
481
|
+
/** A storage access: one call, one thing it read or wrote. */
|
|
482
|
+
interface StorageEnding {
|
|
483
|
+
readonly yields: "storageAccess";
|
|
484
|
+
/** The store, in the words OpenTelemetry's semantic conventions use. */
|
|
485
|
+
readonly system: string;
|
|
486
|
+
/** The wire, when it differs from the store's own name. */
|
|
487
|
+
readonly transport?: string;
|
|
488
|
+
/** Which of the store's namespaces the call reached. */
|
|
489
|
+
readonly scope: string;
|
|
490
|
+
/** What a reader gives back for a name nothing in the source settles. */
|
|
491
|
+
readonly unsettledName: "nothing" | "reference";
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Every table a statement touches, as one effect each.
|
|
495
|
+
*
|
|
496
|
+
* The other ending settles what a call reached by asking the call. This
|
|
497
|
+
* one settles it by reading the statement, so one call yields as many
|
|
498
|
+
* effects as the statement has tables, and each of them states its own
|
|
499
|
+
* kind: a statement that writes one table while reading another says
|
|
500
|
+
* both.
|
|
501
|
+
*/
|
|
502
|
+
interface SqlEnding {
|
|
503
|
+
readonly yields: "sqlAccess";
|
|
504
|
+
/** The store, in the words OpenTelemetry's semantic conventions use. */
|
|
505
|
+
readonly system: string;
|
|
506
|
+
/** The wire, when it differs from the store's own name. */
|
|
507
|
+
readonly transport?: string;
|
|
508
|
+
/** Which of the store's namespaces the call reached. */
|
|
509
|
+
readonly scope: string;
|
|
510
|
+
/**
|
|
511
|
+
* Which dialect the statements are written in. A pack states it
|
|
512
|
+
* outright because nothing here can work it out: a Cloudflare D1
|
|
513
|
+
* database is a store of its own whose statements are SQLite, and a
|
|
514
|
+
* reader that guessed Postgres for a MySQL project would report the
|
|
515
|
+
* wrong tables rather than none.
|
|
516
|
+
*/
|
|
517
|
+
readonly dialect: string;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* A pack's declaration for one kind of call: the links, the ending, and
|
|
521
|
+
* a line of code it matches.
|
|
522
|
+
*/
|
|
523
|
+
interface Chain<TMeaning = MethodMeaning> {
|
|
524
|
+
readonly links: readonly Link<TMeaning>[];
|
|
525
|
+
readonly ending: Ending;
|
|
526
|
+
/** A line of code this matches, which the pack's tests run. */
|
|
527
|
+
readonly example: string | null;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export { type ArgumentPick as A, declaredBy as B, type CallOps as C, type DeclaredBy as D, type Ending as E, type FromReceiver as F, opsIn as G, type InterpolatesLink as I, type KindAsAsked as K, type LinkFunction as L, type MethodMeaning as M, type OneArgument as O, type ReceiverOrigin as R, type SqlMethod as S, type ToArgument as T, type UnsettledName as U, type ValueEntry as V, type Chain as a, type CallStep as b, type StorageMethod as c, type AccessKind as d, type AccessPathLink as e, type ArgumentsFrom as f, type ConstructedFrom as g, type ContainerArgument as h, type ContainerLink as i, type ContainerRule as j, type ContainersLink as k, type InputLink as l, type InputRule as m, type Link as n, type MatchStart as o, type MethodsLink as p, type OpsCarrier as q, type SqlEnding as r, type StartLink as s, type StatedInputs as t, type StatedRule as u, type StorageEnding as v, type SubjectLink as w, type ToReceiver as x, type ValueOps as y, constructedFrom as z };
|