carrick 0.3.155 → 0.3.157
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/contract.d.ts +22 -23
- package/dist/contract.js.map +1 -1
- package/dist/facts/enabled.d.ts +28 -0
- package/dist/facts/enabled.js +36 -0
- package/dist/facts/enabled.js.map +1 -1
- package/dist/facts/fetch.js +20 -8
- package/dist/facts/fetch.js.map +1 -1
- package/dist/facts/lines.d.ts +75 -2
- package/dist/facts/lines.js +302 -46
- package/dist/facts/lines.js.map +1 -1
- package/dist/facts/match.d.ts +2 -0
- package/dist/facts/match.js +189 -28
- package/dist/facts/match.js.map +1 -1
- package/dist/facts/peers.d.ts +2 -0
- package/dist/facts/peers.js +7 -2
- package/dist/facts/peers.js.map +1 -1
- package/dist/facts/store.d.ts +98 -2
- package/dist/facts/store.js +110 -12
- package/dist/facts/store.js.map +1 -1
- package/dist/held/client.d.ts +34 -0
- package/dist/held/client.js +85 -0
- package/dist/held/client.js.map +1 -0
- package/dist/held/daemon.d.ts +106 -0
- package/dist/held/daemon.js +307 -0
- package/dist/held/daemon.js.map +1 -0
- package/dist/held/engine.d.ts +50 -0
- package/dist/held/engine.js +166 -0
- package/dist/held/engine.js.map +1 -0
- package/dist/held/paths.d.ts +9 -0
- package/dist/held/paths.js +27 -0
- package/dist/held/paths.js.map +1 -0
- package/dist/held/place.d.ts +84 -0
- package/dist/held/place.js +198 -0
- package/dist/held/place.js.map +1 -0
- package/dist/held/registry.d.ts +22 -0
- package/dist/held/registry.js +72 -0
- package/dist/held/registry.js.map +1 -0
- package/dist/held/run.d.ts +2 -0
- package/dist/held/run.js +60 -0
- package/dist/held/run.js.map +1 -0
- package/dist/hook/bash-targets.d.ts +7 -2
- package/dist/hook/bash-targets.js +82 -27
- package/dist/hook/bash-targets.js.map +1 -1
- package/dist/hook/edit-flow.js +11 -7
- package/dist/hook/edit-flow.js.map +1 -1
- package/dist/hook/late.d.ts +1 -1
- package/dist/hook/late.js +3 -3
- package/dist/hook/late.js.map +1 -1
- package/dist/hook/lock.d.ts +26 -0
- package/dist/hook/lock.js +122 -0
- package/dist/hook/lock.js.map +1 -0
- package/dist/hook/post-bash.js +22 -7
- package/dist/hook/post-bash.js.map +1 -1
- package/dist/hook/post-read.js +9 -4
- package/dist/hook/post-read.js.map +1 -1
- package/dist/hook/probe.js +4 -2
- package/dist/hook/probe.js.map +1 -1
- package/dist/hook/read-answer.d.ts +23 -4
- package/dist/hook/read-answer.js +74 -19
- package/dist/hook/read-answer.js.map +1 -1
- package/dist/hook/rechecks.d.ts +2 -5
- package/dist/hook/rechecks.js +23 -130
- package/dist/hook/rechecks.js.map +1 -1
- package/dist/hook/similar.d.ts +13 -0
- package/dist/hook/similar.js +60 -0
- package/dist/hook/similar.js.map +1 -0
- package/dist/hook/stop-wait.d.ts +1 -0
- package/dist/hook/stop-wait.js +19 -24
- package/dist/hook/stop-wait.js.map +1 -1
- package/dist/hook/timings.d.ts +17 -3
- package/dist/hook/timings.js +10 -2
- package/dist/hook/timings.js.map +1 -1
- package/dist/lsp-frame.d.ts +20 -0
- package/dist/lsp-frame.js +47 -0
- package/dist/lsp-frame.js.map +1 -0
- package/dist/render.js +9 -3
- package/dist/render.js.map +1 -1
- package/dist/scan.d.ts +9 -0
- package/dist/scan.js +39 -8
- package/dist/scan.js.map +1 -1
- package/dist/server.js +4 -28
- package/dist/server.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/bundler.d.ts +5 -0
- package/sidecar/dist/src/bundler.js +20 -0
- package/sidecar/dist/src/capture/anchors.js +19 -4
- package/sidecar/dist/src/capture/api.d.ts +52 -4
- package/sidecar/dist/src/capture/check-probe.d.ts +17 -1
- package/sidecar/dist/src/capture/check-probe.js +39 -2
- package/sidecar/dist/src/capture/index.d.ts +12 -4
- package/sidecar/dist/src/capture/index.js +19 -3
- package/sidecar/dist/src/capture/result-label.js +3 -1
- package/sidecar/dist/src/capture/self-check.js +12 -31
- package/sidecar/dist/src/capture/serialised-arms.d.ts +27 -0
- package/sidecar/dist/src/capture/serialised-arms.js +76 -0
- package/sidecar/dist/src/capture/site-node.d.ts +17 -0
- package/sidecar/dist/src/capture/site-node.js +36 -0
- package/sidecar/dist/src/capture/stub-resolution.d.ts +63 -0
- package/sidecar/dist/src/capture/stub-resolution.js +102 -0
- package/sidecar/dist/src/capture/type-reasons.json +78 -0
- package/sidecar/dist/src/capture/unresolved.js +8 -1
- package/sidecar/dist/src/definition-resolver.d.ts +18 -9
- package/sidecar/dist/src/definition-resolver.js +66 -42
- package/sidecar/dist/src/engine-stamp.json +1 -0
- package/sidecar/dist/src/held-shadow.d.ts +60 -0
- package/sidecar/dist/src/held-shadow.js +222 -0
- package/sidecar/dist/src/index.js +47 -1
- package/sidecar/dist/src/library-claims.d.ts +3 -1
- package/sidecar/dist/src/library-claims.js +79 -3
- package/sidecar/dist/src/retype.js +1 -61
- package/sidecar/dist/src/type-home.d.ts +42 -0
- package/sidecar/dist/src/type-home.js +94 -0
- package/sidecar/dist/src/type-inferrer.d.ts +245 -28
- package/sidecar/dist/src/type-inferrer.js +938 -192
- package/sidecar/dist/src/type-parameters.d.ts +41 -0
- package/sidecar/dist/src/type-parameters.js +126 -0
- package/sidecar/dist/src/type-structural-expander.d.ts +1 -11
- package/sidecar/dist/src/type-structural-expander.js +9 -1
- package/sidecar/dist/src/types.d.ts +132 -20
- package/sidecar/dist/src/validators.d.ts +450 -244
- package/sidecar/dist/src/validators.js +27 -1
- package/dist/hook/lead.d.ts +0 -13
- package/dist/hook/lead.js +0 -39
- package/dist/hook/lead.js.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* carrick#2148: where a named type is declared, as a reader would open it.
|
|
3
|
+
* The compiler engine's answers (`type_home`, `stated_body.root_home`) and
|
|
4
|
+
* the bundle's manifest (`home`) read it from here.
|
|
5
|
+
*/
|
|
6
|
+
import { Node, VariableDeclarationKind } from 'ts-morph';
|
|
7
|
+
import { startLineOf } from './line-index.js';
|
|
8
|
+
/** A declaration that names a type: an interface, a type alias, a class or an enum. */
|
|
9
|
+
export function isTypeSpaceDeclaration(declaration) {
|
|
10
|
+
return (Node.isInterfaceDeclaration(declaration) ||
|
|
11
|
+
Node.isTypeAliasDeclaration(declaration) ||
|
|
12
|
+
Node.isClassDeclaration(declaration) ||
|
|
13
|
+
Node.isEnumDeclaration(declaration));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The name a reader knows a type declaration by. The compiler names a default
|
|
17
|
+
* export `default`; the name it declares (`export default interface Ticket`)
|
|
18
|
+
* is the one a reader can import. `undefined` for a default export with no
|
|
19
|
+
* name (`export default class {}`).
|
|
20
|
+
*/
|
|
21
|
+
export function declaredTypeName(name, declaration) {
|
|
22
|
+
if (name !== 'default')
|
|
23
|
+
return name;
|
|
24
|
+
return declaration.getNameNode?.()?.getText();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The home a type declaration gives under the name `name`: the declaring
|
|
28
|
+
* file (absolute) and the 1-based line of the declaration's name, never of a
|
|
29
|
+
* JSDoc block above it. A default export (`export default interface
|
|
30
|
+
* Ticket`, the symbol `default`) is named by the name it declares.
|
|
31
|
+
*
|
|
32
|
+
* None where the declaration is not the repository's or a package's own
|
|
33
|
+
* contract:
|
|
34
|
+
* - a TypeScript lib file (`Uint8Array`, `Blob`);
|
|
35
|
+
* - a declaration inside an ambient `declare module "<specifier>"` block,
|
|
36
|
+
* which states a package's types wherever the stub file sits;
|
|
37
|
+
* - a declaration with no name to point at (`export default class {}`).
|
|
38
|
+
*/
|
|
39
|
+
export function homeOfTypeDeclaration(name, declaration, program) {
|
|
40
|
+
const sourceFile = declaration.getSourceFile();
|
|
41
|
+
if (sourceFile.compilerNode.hasNoDefaultLib || program.isSourceFileDefaultLibrary(sourceFile.compilerNode)) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const inAmbientModule = declaration
|
|
45
|
+
.getAncestors()
|
|
46
|
+
.some((ancestor) => Node.isModuleDeclaration(ancestor) && Node.isStringLiteral(ancestor.getNameNode()));
|
|
47
|
+
if (inAmbientModule)
|
|
48
|
+
return undefined;
|
|
49
|
+
const nameNode = declaration.getNameNode?.();
|
|
50
|
+
const symbol = declaredTypeName(name, declaration);
|
|
51
|
+
if (!nameNode || symbol === undefined)
|
|
52
|
+
return undefined;
|
|
53
|
+
return { symbol, file_path: sourceFile.getFilePath(), line: startLineOf(nameNode) };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* carrick#2148 H3: the home of a schema value a contract was read off, where
|
|
57
|
+
* the value is one name for a `const` the repository declares
|
|
58
|
+
* (`guard('json', NewTicket)`, `NewTicket.safeParse(body)`). The schema is
|
|
59
|
+
* where that contract is written, so the home is the const's name, marked
|
|
60
|
+
* `kind: "schema"`: it is a value, never a type a reader can import as one.
|
|
61
|
+
*
|
|
62
|
+
* None for a schema built at its use (`record({ … })`), a name that is not a
|
|
63
|
+
* `const` (it can be reassigned, so the declaration is not the contract), an
|
|
64
|
+
* ambient `declare const`, and a declaration in a package or a `.d.ts`.
|
|
65
|
+
*/
|
|
66
|
+
export function homeOfSchemaValue(value) {
|
|
67
|
+
if (!Node.isIdentifier(value))
|
|
68
|
+
return undefined;
|
|
69
|
+
let symbol = value.getSymbol();
|
|
70
|
+
if (symbol?.isAlias())
|
|
71
|
+
symbol = symbol.getAliasedSymbol() ?? symbol;
|
|
72
|
+
const declarations = symbol?.getDeclarations() ?? [];
|
|
73
|
+
if (declarations.length !== 1)
|
|
74
|
+
return undefined;
|
|
75
|
+
const [declaration] = declarations;
|
|
76
|
+
if (!Node.isVariableDeclaration(declaration) || !declaration.hasInitializer())
|
|
77
|
+
return undefined;
|
|
78
|
+
const list = declaration.getParent();
|
|
79
|
+
if (!Node.isVariableDeclarationList(list) || list.getDeclarationKind() !== VariableDeclarationKind.Const) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const sourceFile = declaration.getSourceFile();
|
|
83
|
+
if (sourceFile.isDeclarationFile() || sourceFile.isInNodeModules())
|
|
84
|
+
return undefined;
|
|
85
|
+
const nameNode = declaration.getNameNode();
|
|
86
|
+
if (!Node.isIdentifier(nameNode))
|
|
87
|
+
return undefined;
|
|
88
|
+
return {
|
|
89
|
+
symbol: nameNode.getText(),
|
|
90
|
+
file_path: sourceFile.getFilePath(),
|
|
91
|
+
line: startLineOf(nameNode),
|
|
92
|
+
kind: 'schema',
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -20,6 +20,13 @@
|
|
|
20
20
|
import { Project, SourceFile, type CallExpression } from 'ts-morph';
|
|
21
21
|
import type { InferRequestItem, InferResult, ModelSymbol, ExtractionConfig } from './types.js';
|
|
22
22
|
import { type LabelledMembers } from './library-claims.js';
|
|
23
|
+
/**
|
|
24
|
+
* The reasons an `unknown` answer is a decision, not a failure to read, on the
|
|
25
|
+
* response path that reads this set: the words `capture/type-reasons.json`
|
|
26
|
+
* marks `always` (carrick#4231). A stated reply never replaces one
|
|
27
|
+
* (carrick#2674).
|
|
28
|
+
*/
|
|
29
|
+
export declare const DECIDED_ABSTAIN_REASONS: ReadonlySet<string>;
|
|
23
30
|
/**
|
|
24
31
|
* Options for TypeInferrer construction
|
|
25
32
|
*/
|
|
@@ -84,6 +91,11 @@ export declare class TypeInferrer {
|
|
|
84
91
|
* unwidened reading re-reads from here (carrick#1516).
|
|
85
92
|
*/
|
|
86
93
|
private readonly readNodes;
|
|
94
|
+
/**
|
|
95
|
+
* The type each inferred type's text was printed from, where the builder
|
|
96
|
+
* named one. The open-parameter check (carrick#4201) reads it.
|
|
97
|
+
*/
|
|
98
|
+
private readonly printedTypes;
|
|
87
99
|
private readonly unwidenedLimits;
|
|
88
100
|
private readonly now;
|
|
89
101
|
/**
|
|
@@ -219,6 +231,29 @@ export declare class TypeInferrer {
|
|
|
219
231
|
* Infer a single type from a request
|
|
220
232
|
*/
|
|
221
233
|
private inferSingle;
|
|
234
|
+
/**
|
|
235
|
+
* carrick#4201: a response, call result, return or variable read inside a
|
|
236
|
+
* generic function whose type still holds that function's (or its class's)
|
|
237
|
+
* type parameter states no type of its own: only the function's callers set
|
|
238
|
+
* it. The answer is a decided `unknown` with `bound_by_callers`, never a
|
|
239
|
+
* type naming the parameter. The kinds that describe the generic function
|
|
240
|
+
* itself (`function_param`, `signature_return`, `receiver_type`) never come
|
|
241
|
+
* here: `T` belongs there.
|
|
242
|
+
*
|
|
243
|
+
* The read is anchored inside the node the answer was read from, so a
|
|
244
|
+
* return read at the function finds the function's own parameters
|
|
245
|
+
* (`enclosingTypeParameterIn` starts from the anchor's parent).
|
|
246
|
+
*/
|
|
247
|
+
private withoutOpenTypeParameter;
|
|
248
|
+
/**
|
|
249
|
+
* The name of a type parameter `type` holds that a declaration around
|
|
250
|
+
* `node`, or `node` itself, declares. A function or class read at itself is
|
|
251
|
+
* anchored inside it: `enclosingTypeParameterIn` starts from the anchor's
|
|
252
|
+
* parent, so it would miss the declaration's own parameters.
|
|
253
|
+
*/
|
|
254
|
+
private openTypeParameterAt;
|
|
255
|
+
/** The decided answer for a read holding the open type parameter `name` (carrick#4201). */
|
|
256
|
+
private boundByCallers;
|
|
222
257
|
/**
|
|
223
258
|
* The call a `call_result` locator names, located exactly as `infer` locates
|
|
224
259
|
* it (span, else expression text near a line). The retype check
|
|
@@ -370,6 +405,24 @@ export declare class TypeInferrer {
|
|
|
370
405
|
* helper's `account: Account`).
|
|
371
406
|
*/
|
|
372
407
|
private isRouteHandlerParameter;
|
|
408
|
+
/**
|
|
409
|
+
* True when a located call hands back the reply of the registration handler
|
|
410
|
+
* it sits in (`handsBackHandlerParameter`, `isRegisteredHandler`), is
|
|
411
|
+
* handed a status-shaped value, read as a chain's status call is read
|
|
412
|
+
* (`statusOfValue`, as `chainStatus` reads it), and does not take any
|
|
413
|
+
* value in that slot (`takesAnyValue`): `reply.code(204)`,
|
|
414
|
+
* `res.status(204)`. Such a call states a status and names no body
|
|
415
|
+
* (carrick#4300); a send of a number (`reply.send(count)`) keeps its
|
|
416
|
+
* reading. No method name is read.
|
|
417
|
+
*/
|
|
418
|
+
private locatedStatusHandsBackReply;
|
|
419
|
+
/**
|
|
420
|
+
* The one status-only shape: a call that hands one of the handler's
|
|
421
|
+
* parameters back, is handed a status-shaped value (`statusOfValue`), and
|
|
422
|
+
* does not take any value in that slot (`takesAnyValue`). Read by the
|
|
423
|
+
* located-call check and by `returnsHandlerParameterType` (carrick#4341).
|
|
424
|
+
*/
|
|
425
|
+
private statesOnlyStatus;
|
|
373
426
|
/**
|
|
374
427
|
* True when a located call's own result is the route's payload, so the
|
|
375
428
|
* transitional drill into its first argument must not run (carrick#1732).
|
|
@@ -510,6 +563,57 @@ export declare class TypeInferrer {
|
|
|
510
563
|
* keys. Its result is transport whatever its type looks like, so the body
|
|
511
564
|
* is read from the send's argument.
|
|
512
565
|
*/
|
|
566
|
+
/**
|
|
567
|
+
* True when the handler's awaited return is the type of one of its own
|
|
568
|
+
* parameters: the reply a fluent send hands back (`reply.send(x)` returns
|
|
569
|
+
* `reply`). That value is the object the framework passed in, never the
|
|
570
|
+
* body.
|
|
571
|
+
*
|
|
572
|
+
* A type declared outside the repository is read this way whatever the
|
|
573
|
+
* function returns it from (carrick#4269). A type the repository declares
|
|
574
|
+
* is read this way only by its shape (carrick#4283): the function is a
|
|
575
|
+
* route registration's handler, every return is a call that hands one of
|
|
576
|
+
* its parameters back (`handsBackHandlerParameter`), and at least one of
|
|
577
|
+
* them is given a value of any type (`takesAnyValue`) or states only a
|
|
578
|
+
* status (`statesOnlyStatus`, carrick#4341). A function returning
|
|
579
|
+
* its own options type, or a callback returning a builder's typed setter,
|
|
580
|
+
* returns data.
|
|
581
|
+
*/
|
|
582
|
+
private returnsHandlerParameterType;
|
|
583
|
+
/**
|
|
584
|
+
* True when `node` is a method call on a handler's own parameter that hands
|
|
585
|
+
* that parameter back (carrick#4283): given at least one argument, its
|
|
586
|
+
* result is the type of the object it was called on, and that type is one
|
|
587
|
+
* of the handler's parameters (`reply.send(x)`, `reply.code(201)`).
|
|
588
|
+
*/
|
|
589
|
+
private handsBackHandlerParameter;
|
|
590
|
+
/**
|
|
591
|
+
* True when the first parameter of the signature `call` resolves to is
|
|
592
|
+
* declared as taking any value (`typeNodeStatesNothing`): the slot of a
|
|
593
|
+
* send (`send(payload?: unknown)`), never a typed setter (`set(v: string)`,
|
|
594
|
+
* `code(status: number)`).
|
|
595
|
+
*/
|
|
596
|
+
private takesAnyValue;
|
|
597
|
+
/**
|
|
598
|
+
* True when a located call is a send that hands back the reply of the
|
|
599
|
+
* registration handler it sits in (carrick#4283), read by the same shape
|
|
600
|
+
* `returnsHandlerParameterType` reads a returned send with.
|
|
601
|
+
*/
|
|
602
|
+
private locatedSendHandsBackReply;
|
|
603
|
+
/**
|
|
604
|
+
* True when `func` is a route registration's handler: the one the
|
|
605
|
+
* registration on the request's line hands in (found as
|
|
606
|
+
* `registrationAtLine` finds it), or an inline function a registration
|
|
607
|
+
* call is handed, for a request on a line inside it.
|
|
608
|
+
*/
|
|
609
|
+
private isRegisteredHandler;
|
|
610
|
+
/**
|
|
611
|
+
* `any` or `unknown` when every returned send hands over a value whose code
|
|
612
|
+
* declares that top type (`reply.send(request.body)` with `body: unknown`),
|
|
613
|
+
* else `undefined`. The body is read where a send reads it: the slot a
|
|
614
|
+
* label states, else the first argument.
|
|
615
|
+
*/
|
|
616
|
+
private sentValuesDeclaredTop;
|
|
513
617
|
private returnsLabelledSend;
|
|
514
618
|
/**
|
|
515
619
|
* True when `candidate` is a response send: a call or `new` whose result is
|
|
@@ -537,6 +641,14 @@ export declare class TypeInferrer {
|
|
|
537
641
|
* of the raw call does not publish the envelope in its place.
|
|
538
642
|
*/
|
|
539
643
|
private labelledCallResult;
|
|
644
|
+
/**
|
|
645
|
+
* The type of a call result read inside a maker, as the call `through_call`
|
|
646
|
+
* names instantiates it (carrick#4375): the same read a built body takes,
|
|
647
|
+
* `typeAtThroughCall`. Only a request that names a call is read this way; a
|
|
648
|
+
* result with none keeps the reading it has. `undefined` where the read
|
|
649
|
+
* holds nothing the call binds.
|
|
650
|
+
*/
|
|
651
|
+
private callResultAtThroughCall;
|
|
540
652
|
private inferCallResult;
|
|
541
653
|
/**
|
|
542
654
|
* The terminal of a call's def-use walk is a zero-argument `.text()` read of
|
|
@@ -619,6 +731,31 @@ export declare class TypeInferrer {
|
|
|
619
731
|
private statedRootRelation;
|
|
620
732
|
private inferVariable;
|
|
621
733
|
private inferExpression;
|
|
734
|
+
/**
|
|
735
|
+
* The type of `node`, a payload the scanner reads inside the wrapper that
|
|
736
|
+
* builds it (carrick#4128), as the call it names in `through_call`
|
|
737
|
+
* instantiates that wrapper: `{ body: item }` in `place<T>(item: T)` reads
|
|
738
|
+
* `{ body: Book }` at `place(book)`. A type parameter the call leaves open
|
|
739
|
+
* is never published: the answer is a decided `unknown`. A request with no
|
|
740
|
+
* `through_call` (the wrapper's own row) names no call to bind one, so a
|
|
741
|
+
* type parameter its read holds stays open and is never published either
|
|
742
|
+
* (carrick#4164); a read that holds none is the type at `node` as it stands.
|
|
743
|
+
*/
|
|
744
|
+
private typeAtThroughCall;
|
|
745
|
+
/**
|
|
746
|
+
* Where a read's answer points. An instantiated read is not re-read
|
|
747
|
+
* unwidened: that reading is made at the node, inside the generic
|
|
748
|
+
* function, where the type parameter is open again (carrick#4128).
|
|
749
|
+
*/
|
|
750
|
+
private locationOfRead;
|
|
751
|
+
/**
|
|
752
|
+
* An instantiated read whose function writes a literal on its path is
|
|
753
|
+
* marked as the unwidened reading not made: that reading is the one that
|
|
754
|
+
* keeps such a literal (`kind: 'order'`) at its literal type, and without
|
|
755
|
+
* it the body is judged on the widened type alone, so its pair abstains on
|
|
756
|
+
* a mismatch rather than report one (carrick#2011).
|
|
757
|
+
*/
|
|
758
|
+
private unwidenedAtCaller;
|
|
622
759
|
private inferRequestBody;
|
|
623
760
|
private resolveCallResultTerminalNode;
|
|
624
761
|
/**
|
|
@@ -877,6 +1014,18 @@ export declare class TypeInferrer {
|
|
|
877
1014
|
* re-reading the raw call (`inference_decided_no_contract`,
|
|
878
1015
|
* engine/type_compat_v2.rs).
|
|
879
1016
|
*/
|
|
1017
|
+
/**
|
|
1018
|
+
* carrick#4185: the member of the object a call's function hands back that
|
|
1019
|
+
* holds the response's parsed body, decided from that function's code:
|
|
1020
|
+
* every `return` of it is an object literal, and in each exactly one member
|
|
1021
|
+
* is filled from a platform whole-body read (`json: (await res.json()) as
|
|
1022
|
+
* Reply`), itself or through a `const` it initialises, and every return
|
|
1023
|
+
* names the same member. The member's name never decides it. A function
|
|
1024
|
+
* the service does not declare (a library, a declaration with no body)
|
|
1025
|
+
* decides nothing. `textRead` says every return fills it from a text read
|
|
1026
|
+
* (carrick#4288).
|
|
1027
|
+
*/
|
|
1028
|
+
private handBackBodyMember;
|
|
880
1029
|
private transportAbstain;
|
|
881
1030
|
/**
|
|
882
1031
|
* `Future<T>` -> `T` for a thenable, read off the await protocol rather
|
|
@@ -1221,6 +1370,12 @@ export declare class TypeInferrer {
|
|
|
1221
1370
|
* `JSON.stringify()` with no argument, is left alone.
|
|
1222
1371
|
*/
|
|
1223
1372
|
private unwrapJsonStringifyArg;
|
|
1373
|
+
/**
|
|
1374
|
+
* The union of a conditional serialised body's arms (carrick#4285), or
|
|
1375
|
+
* undefined where `node` is no such conditional or the union holds a type
|
|
1376
|
+
* parameter, which only a caller binds.
|
|
1377
|
+
*/
|
|
1378
|
+
private serialisedConditionalPayload;
|
|
1224
1379
|
private extractExplicitTypeFromAncestor;
|
|
1225
1380
|
/** The annotation `extractExplicitTypeFromAncestor` prints, as a node. */
|
|
1226
1381
|
private explicitTypeNodeFromAncestor;
|
|
@@ -1390,6 +1545,12 @@ export declare class TypeInferrer {
|
|
|
1390
1545
|
* itself; the checks above it are this kind's own.
|
|
1391
1546
|
*/
|
|
1392
1547
|
private inferRequestConfig;
|
|
1548
|
+
/**
|
|
1549
|
+
* carrick#4148: the handler returns at least one expression and every
|
|
1550
|
+
* branch of every return is a send stating an error or redirect status.
|
|
1551
|
+
* A branch that states no status (or a computed one) makes this false.
|
|
1552
|
+
*/
|
|
1553
|
+
private everyReturnStatesDroppedStatus;
|
|
1393
1554
|
/** An `unknown` answer the inferrer decided, carrying its reason at the root. */
|
|
1394
1555
|
private decidedAbstain;
|
|
1395
1556
|
/**
|
|
@@ -1698,33 +1859,31 @@ export declare class TypeInferrer {
|
|
|
1698
1859
|
*/
|
|
1699
1860
|
private primaryTypeSymbol;
|
|
1700
1861
|
/**
|
|
1701
|
-
*
|
|
1702
|
-
*
|
|
1703
|
-
*
|
|
1704
|
-
*
|
|
1705
|
-
*
|
|
1706
|
-
*
|
|
1707
|
-
*
|
|
1708
|
-
*
|
|
1709
|
-
*
|
|
1710
|
-
*
|
|
1711
|
-
* The
|
|
1712
|
-
*
|
|
1713
|
-
*
|
|
1714
|
-
*
|
|
1715
|
-
*
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
*
|
|
1720
|
-
*
|
|
1721
|
-
*
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
*/
|
|
1727
|
-
private primaryTypeSymbolSource;
|
|
1862
|
+
* carrick#2148: where `type` is declared, as a reader would open it: the
|
|
1863
|
+
* name, the declaring file (absolute) and the 1-based line of the
|
|
1864
|
+
* declaration's name. Every answer's `type_home` comes from here.
|
|
1865
|
+
*
|
|
1866
|
+
* The type read is the named one: array levels are peeled, and so is a
|
|
1867
|
+
* `| null`/`| undefined` around exactly one other type (`Invoice | null`
|
|
1868
|
+
* is homed at `Invoice`). A type that already has a name is not peeled, so
|
|
1869
|
+
* an alias of a union keeps its own home. A union of several types has no
|
|
1870
|
+
* one home.
|
|
1871
|
+
*
|
|
1872
|
+
* The symbol is the one `primaryTypeSymbol` names (`anchorSymbolOf`), so a
|
|
1873
|
+
* name imported through a barrel is homed at the file that declares it and
|
|
1874
|
+
* an instantiated generic alias (`Page<Order>`) at `Page`. There is no home
|
|
1875
|
+
* for framework machinery, a `BUILTIN_ANCHOR_SYMBOLS` name, or where
|
|
1876
|
+
* `homeOfDeclaration` gives none.
|
|
1877
|
+
*/
|
|
1878
|
+
private typeHomeOf;
|
|
1879
|
+
/**
|
|
1880
|
+
* The home of `symbol` under the name a reader knows it by: its first
|
|
1881
|
+
* type-space declaration (interface, type alias, class, enum), by
|
|
1882
|
+
* `homeOfDeclaration`'s rule. A symbol declared only as a value has none.
|
|
1883
|
+
*/
|
|
1884
|
+
private homeOfSymbol;
|
|
1885
|
+
/** `homeOfTypeDeclaration` in this service's program. */
|
|
1886
|
+
private homeOfDeclaration;
|
|
1728
1887
|
/**
|
|
1729
1888
|
* The anchor a `satisfies X` / `as X` / `<X>` annotation states IN SOURCE:
|
|
1730
1889
|
* the name written at the annotation, where its type is declared, and the
|
|
@@ -1881,6 +2040,27 @@ export declare class TypeInferrer {
|
|
|
1881
2040
|
* registration node itself, so the schema anchors need both halves.
|
|
1882
2041
|
*/
|
|
1883
2042
|
private registrationAtLine;
|
|
2043
|
+
/** Whether a registration call's first argument is a string literal the route path ends with. */
|
|
2044
|
+
private registrationStatesPath;
|
|
2045
|
+
/** Every registration that starts on `line`, in source order. */
|
|
2046
|
+
private registrationsOnLine;
|
|
2047
|
+
/**
|
|
2048
|
+
* Whether a call is a route registration, by one test for both sides: it is
|
|
2049
|
+
* handed an inline function and its result is not plain data (`rows.map(fn)`
|
|
2050
|
+
* sends the list), or the ask is located by span alone and the call names a
|
|
2051
|
+
* handler or is handed a callable after its first argument. A model-located
|
|
2052
|
+
* ask keeps today's reading, so `rows.map(toView)` is still a payload. A
|
|
2053
|
+
* call whose own result is a primitive is a value, not a registration
|
|
2054
|
+
* (`JSON.stringify(body, this.replacer)`).
|
|
2055
|
+
*/
|
|
2056
|
+
private registersHandlerAt;
|
|
2057
|
+
/**
|
|
2058
|
+
* A registration's response, read only from its handler: the contract the
|
|
2059
|
+
* registration declares, else what the handler returns, else the bodies it
|
|
2060
|
+
* sends through labelled sends. Shared by a line ask, a registry object and
|
|
2061
|
+
* a registration call.
|
|
2062
|
+
*/
|
|
2063
|
+
private responseAtRegistration;
|
|
1884
2064
|
/**
|
|
1885
2065
|
* Follow a route-registration locator ONE indirection to the handler function.
|
|
1886
2066
|
*
|
|
@@ -1929,8 +2109,17 @@ export declare class TypeInferrer {
|
|
|
1929
2109
|
* reading the first function read a middleware as the route. The path
|
|
1930
2110
|
* literal is not function-valued, so it is skipped naturally. No callee-name
|
|
1931
2111
|
* check: a call whose argument resolves to a function is structurally a
|
|
1932
|
-
* registration regardless of the framework
|
|
2112
|
+
* registration regardless of the framework, unless it is called on an array
|
|
2113
|
+
* or a promise (carrick#4379).
|
|
1933
2114
|
*/
|
|
2115
|
+
/**
|
|
2116
|
+
* carrick#4379: whether a call is made on an array or a promise (`rows.map(cb)`,
|
|
2117
|
+
* `rows.filter(cb)`, `pending.then(cb)`). Such a call hands its function to
|
|
2118
|
+
* an iteration or a continuation, never to a server or router, so the
|
|
2119
|
+
* function is no route handler and the call's result is the value to read.
|
|
2120
|
+
* Decided by the receiver's compiler type, so it names no method.
|
|
2121
|
+
*/
|
|
2122
|
+
private calledOnCollectionOrPromise;
|
|
1934
2123
|
private handlerFromRegistrationCall;
|
|
1935
2124
|
/**
|
|
1936
2125
|
* The handler function carried by a route-registry object literal. Matches a
|
|
@@ -2016,6 +2205,8 @@ export declare class TypeInferrer {
|
|
|
2016
2205
|
* at the first body read" without assuming which framework produced it.
|
|
2017
2206
|
* Returns null (not a spurious type) for a genuinely payload-less handler.
|
|
2018
2207
|
*/
|
|
2208
|
+
/** The property access that reads a member straight off `cast`, parentheses aside. */
|
|
2209
|
+
private memberReadOffCast;
|
|
2019
2210
|
private inferRequestReadFromHandler;
|
|
2020
2211
|
/**
|
|
2021
2212
|
* The call in a handler that reads the request's body off the platform
|
|
@@ -2559,6 +2750,10 @@ export declare class TypeInferrer {
|
|
|
2559
2750
|
* `unknown`.
|
|
2560
2751
|
*/
|
|
2561
2752
|
private schemaContract;
|
|
2753
|
+
/**
|
|
2754
|
+
* `schemaContract`'s text and provenance, read off the schema's types.
|
|
2755
|
+
*/
|
|
2756
|
+
private schemaContractText;
|
|
2562
2757
|
/**
|
|
2563
2758
|
* Print a schema's input with each coerced position replaced by the output's
|
|
2564
2759
|
* type at that position (carrick#1105). Null when any position cannot be
|
|
@@ -2655,8 +2850,30 @@ export declare class TypeInferrer {
|
|
|
2655
2850
|
*/
|
|
2656
2851
|
private splitTopLevelUnion;
|
|
2657
2852
|
private isBracketBalanced;
|
|
2853
|
+
/**
|
|
2854
|
+
* carrick#4244: stamp the nodes `inferred`'s text was built from on it, as
|
|
2855
|
+
* `read_spans`. Called at each builder's return with exactly those nodes.
|
|
2856
|
+
* Offsets are taken now, as numbers, so a later rewrite of the file (the
|
|
2857
|
+
* unwidened reading) cannot move them, and a spread of the answer keeps
|
|
2858
|
+
* them. An answer whose text is bare `any`/`unknown`, a no-value type
|
|
2859
|
+
* (`void`, `undefined`, `never`) or empty has no value to place and gets
|
|
2860
|
+
* none, annotated or not; a decided abstain is built by
|
|
2861
|
+
* `decidedAbstain` and never passes through here. Outer parentheses are
|
|
2862
|
+
* peeled: `({ ... })` is the literal.
|
|
2863
|
+
*/
|
|
2864
|
+
private withReads;
|
|
2658
2865
|
private getNodeLocation;
|
|
2659
2866
|
private createInferredType;
|
|
2867
|
+
/**
|
|
2868
|
+
* carrick#2148: the `type_home` of an answer. Where the builder reports
|
|
2869
|
+
* `primary_type_symbol`, the home is that symbol's: read off the anchor
|
|
2870
|
+
* type the symbol was named from, or the annotation it was read off as
|
|
2871
|
+
* written (`writtenHome`), so it is that symbol's declaration and never
|
|
2872
|
+
* another type's. Where no symbol is reported, the home is the printed
|
|
2873
|
+
* type's (`typeHomeOf`), unless the builder passes `null`: the printed type
|
|
2874
|
+
* is one it deliberately anchors nothing on.
|
|
2875
|
+
*/
|
|
2876
|
+
private homeField;
|
|
2660
2877
|
private generateAlias;
|
|
2661
2878
|
private inferKindSuffix;
|
|
2662
2879
|
private log;
|