carrick 0.3.107 → 0.3.109
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/package.json +9 -10
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/capture/api.d.ts +15 -0
- package/sidecar/dist/src/capture/check-classify.d.ts +9 -0
- package/sidecar/dist/src/capture/check-classify.js +20 -0
- package/sidecar/dist/src/capture/check-deep.js +2 -1
- package/sidecar/dist/src/capture/check-fields.d.ts +24 -0
- package/sidecar/dist/src/capture/check-fields.js +54 -36
- package/sidecar/dist/src/capture/check-union.d.ts +40 -0
- package/sidecar/dist/src/capture/check-union.js +92 -0
- package/sidecar/dist/src/capture/check-workspace.d.ts +1 -0
- package/sidecar/dist/src/capture/check-workspace.js +13 -2
- package/sidecar/dist/src/capture/check.js +5 -0
- package/sidecar/dist/src/capture/compiler-options.d.ts +39 -0
- package/sidecar/dist/src/capture/compiler-options.js +100 -0
- package/sidecar/dist/src/capture/deno-project.js +3 -2
- package/sidecar/dist/src/capture/index.d.ts +1 -0
- package/sidecar/dist/src/capture/index.js +90 -48
- package/sidecar/dist/src/capture/installed-package.js +3 -2
- package/sidecar/dist/src/capture/self-check.js +3 -2
- package/sidecar/dist/src/definition-resolver.d.ts +5 -8
- package/sidecar/dist/src/definition-resolver.js +8 -9
- package/sidecar/dist/src/index.js +124 -11
- package/sidecar/dist/src/infer-timing.d.ts +54 -0
- package/sidecar/dist/src/infer-timing.js +124 -0
- package/sidecar/dist/src/print-type.d.ts +48 -0
- package/sidecar/dist/src/print-type.js +71 -0
- package/sidecar/dist/src/printed-names.js +2 -1
- package/sidecar/dist/src/program-files.d.ts +44 -0
- package/sidecar/dist/src/program-files.js +64 -0
- package/sidecar/dist/src/project-loader.d.ts +5 -0
- package/sidecar/dist/src/project-loader.js +14 -5
- package/sidecar/dist/src/retype.d.ts +4 -2
- package/sidecar/dist/src/retype.js +16 -5
- package/sidecar/dist/src/type-inferrer.d.ts +157 -1
- package/sidecar/dist/src/type-inferrer.js +444 -20
- package/sidecar/dist/src/types.d.ts +104 -2
- package/sidecar/dist/src/validators.d.ts +166 -80
- package/sidecar/dist/src/validators.js +13 -0
- package/templates/skills/carrick-reuse.md +6 -5
|
@@ -86,6 +86,12 @@ export declare class TypeInferrer {
|
|
|
86
86
|
*/
|
|
87
87
|
private readonly readNodes;
|
|
88
88
|
private readonly unwidenedBudgetMs;
|
|
89
|
+
/**
|
|
90
|
+
* The files a request has named to this inferrer, as the requests named
|
|
91
|
+
* them (carrick#1985). It lives as long as the project does, so the first
|
|
92
|
+
* request of a file is the first of the process, not of a batch.
|
|
93
|
+
*/
|
|
94
|
+
private readonly filesAsked;
|
|
89
95
|
constructor(options: TypeInferrerOptions);
|
|
90
96
|
/**
|
|
91
97
|
* What the structural printer needs to tell the user's own declarations from
|
|
@@ -193,6 +199,61 @@ export declare class TypeInferrer {
|
|
|
193
199
|
*/
|
|
194
200
|
private resolveParamTarget;
|
|
195
201
|
private inferResponseBody;
|
|
202
|
+
/**
|
|
203
|
+
* The handler a module exports on `line`: a function that opens on exactly
|
|
204
|
+
* that line, exported at the top of its module, where no call on the line
|
|
205
|
+
* registers a route (carrick#807).
|
|
206
|
+
*
|
|
207
|
+
* That is the anchor of a route its module's place in the project states:
|
|
208
|
+
* the row's line is the handler's own export, and the module's exports are
|
|
209
|
+
* how the framework finds it. Each condition keeps another kind of row out:
|
|
210
|
+
*
|
|
211
|
+
* - the line has to be the function's first, with no tolerance. A model
|
|
212
|
+
* row that names no site of its own can sit on any line of a handler,
|
|
213
|
+
* and the nearest function to such a line is whatever is declared
|
|
214
|
+
* beside it;
|
|
215
|
+
* - a method of a class is a controller's handler, whose rows are
|
|
216
|
+
* anchored on what a model located before the method's own return;
|
|
217
|
+
* - a line that registers a route has a registration to read.
|
|
218
|
+
*/
|
|
219
|
+
private handlerDeclaredAtLine;
|
|
220
|
+
/**
|
|
221
|
+
* `handlerDeclaredAtLine` without its registration test, for a caller that
|
|
222
|
+
* has already looked for a registration on the line.
|
|
223
|
+
*/
|
|
224
|
+
private exportedFunctionOpeningOn;
|
|
225
|
+
/**
|
|
226
|
+
* The response of a handler the request's line declares, for a request
|
|
227
|
+
* that also located an expression inside it (carrick#807).
|
|
228
|
+
*
|
|
229
|
+
* The handler's own return is read first, exactly as a `function_return`
|
|
230
|
+
* request at the line reads it, and that reading stands: a body it
|
|
231
|
+
* recovered, and a decision it made not to publish one. The located
|
|
232
|
+
* expression is consulted in one case only. Where the handler returns a
|
|
233
|
+
* call nothing resolves (its library is not installed), the return walk
|
|
234
|
+
* reads no argument the source does not annotate, because it cannot tell a
|
|
235
|
+
* response sender from a query. A located payload that is an ARGUMENT of
|
|
236
|
+
* such a returned call says which it is, so the same walk runs again with
|
|
237
|
+
* that callee taken as a sender: every success body the handler returns
|
|
238
|
+
* through it, error branches dropped as before. The located expression's
|
|
239
|
+
* own type is never what is published here.
|
|
240
|
+
*
|
|
241
|
+
* Returns `undefined` when the located expression is something the return
|
|
242
|
+
* walk never looked at, so it is left to the readings below:
|
|
243
|
+
* - the handler returns nothing (`void`): it sends through a parameter;
|
|
244
|
+
* - the handler returns transport the walk read no body out of, and the
|
|
245
|
+
* located expression is not part of what it returns. A body built before
|
|
246
|
+
* the response is returned (`const res = send(body); ...; return res`)
|
|
247
|
+
* is one. Named on a send that states an error or redirect status, it is
|
|
248
|
+
* no success body and the row abstains.
|
|
249
|
+
*/
|
|
250
|
+
private responseOfDeclaredHandler;
|
|
251
|
+
/**
|
|
252
|
+
* The call inside one of `returned` that the located expression is, or is
|
|
253
|
+
* an argument of: the send a located payload was handed to. `undefined`
|
|
254
|
+
* when the located expression is not part of what the handler returns.
|
|
255
|
+
*/
|
|
256
|
+
private returnedSendHolding;
|
|
196
257
|
/**
|
|
197
258
|
* True when a located call's own result is the route's payload, so the
|
|
198
259
|
* transitional drill into its first argument must not run (carrick#1732).
|
|
@@ -297,6 +358,14 @@ export declare class TypeInferrer {
|
|
|
297
358
|
* else, and is not reported.
|
|
298
359
|
*/
|
|
299
360
|
private statedBodyAtRead;
|
|
361
|
+
/**
|
|
362
|
+
* The type node `statedBodyAtRead` reads, for a caller that wants the
|
|
363
|
+
* annotation itself: a consumer's response read reports its root, and a
|
|
364
|
+
* handler's request read prints it (carrick#807). One reading of "stated at
|
|
365
|
+
* the read" for both, so the two cannot disagree about which annotation
|
|
366
|
+
* belongs to a read.
|
|
367
|
+
*/
|
|
368
|
+
private typeNodeStatedAtRead;
|
|
300
369
|
/**
|
|
301
370
|
* A stated type with `any` or `unknown` written anywhere in it (`unknown`,
|
|
302
371
|
* `Record<string, unknown>`, `{ items: any[] }`) leaves a position open: it
|
|
@@ -892,9 +961,22 @@ export declare class TypeInferrer {
|
|
|
892
961
|
*
|
|
893
962
|
* Under `statedOnly` the annotation is the ONLY thing that counts, so an
|
|
894
963
|
* unresolvable callee's arguments never become a contract by accident.
|
|
964
|
+
*
|
|
965
|
+
* `asSent` judges the object in the form it is sent in, which is what an
|
|
966
|
+
* ARGUMENT handed to a sender is asked; see `typeIsObjectShaped`.
|
|
895
967
|
*/
|
|
896
968
|
private nodeCarriesPayloadContract;
|
|
897
|
-
/**
|
|
969
|
+
/**
|
|
970
|
+
* Object, array-of-object, or a union/intersection containing one.
|
|
971
|
+
*
|
|
972
|
+
* With `asSent` the object is judged in the form it is SENT in
|
|
973
|
+
* (carrick#1163): a value that declares `toJSON()` travels as what that
|
|
974
|
+
* returns. A `URL` or a `Date` is therefore the string it serialises to,
|
|
975
|
+
* the bare primitive this rule already refuses, and `redirect(new URL(path,
|
|
976
|
+
* base))` hands over a location exactly as `redirect("/next")` does
|
|
977
|
+
* (carrick#807). A value whose JSON form is itself an object is a body like
|
|
978
|
+
* any other.
|
|
979
|
+
*/
|
|
898
980
|
private typeIsObjectShaped;
|
|
899
981
|
/**
|
|
900
982
|
* The `satisfies X` / `as X` / `<X>` annotation node on an expression, when
|
|
@@ -1104,6 +1186,17 @@ export declare class TypeInferrer {
|
|
|
1104
1186
|
* keep both segments.
|
|
1105
1187
|
*/
|
|
1106
1188
|
private declaringPackageOf;
|
|
1189
|
+
/**
|
|
1190
|
+
* The declaration a symbol is attributed to (carrick#2031). One declaration
|
|
1191
|
+
* is itself. Where several files merge one symbol (a global interface the
|
|
1192
|
+
* compiler's library declares and a typings package augments), their order
|
|
1193
|
+
* is the order the checker merged them in, and on TypeScript 6 that changes
|
|
1194
|
+
* once the program is rebuilt, so the first one is not an answer. The
|
|
1195
|
+
* compiler's default library wins where it declares the symbol; otherwise,
|
|
1196
|
+
* and among the library's own files, the declaring file whose path sorts
|
|
1197
|
+
* first, then the earliest declaration in it.
|
|
1198
|
+
*/
|
|
1199
|
+
private attributedDeclaration;
|
|
1107
1200
|
/**
|
|
1108
1201
|
* The awaited return type of the member invoked on the receiver. Reported as
|
|
1109
1202
|
* a fact next to the receiver; a caller that classified on it alone would be
|
|
@@ -1275,6 +1368,46 @@ export declare class TypeInferrer {
|
|
|
1275
1368
|
* Returns null (not a spurious type) for a genuinely payload-less handler.
|
|
1276
1369
|
*/
|
|
1277
1370
|
private inferRequestReadFromHandler;
|
|
1371
|
+
/**
|
|
1372
|
+
* The call in a handler that reads the request's body off the platform
|
|
1373
|
+
* request the handler was handed, or `undefined` (carrick#807).
|
|
1374
|
+
*
|
|
1375
|
+
* Read by shape, with no method name consulted:
|
|
1376
|
+
*
|
|
1377
|
+
* - a call that takes nothing, on a member of a value whose type is request
|
|
1378
|
+
* machinery (`typeIsFrameworkMachinery`: declared by the platform or an
|
|
1379
|
+
* installed library, and carrying its body readers);
|
|
1380
|
+
* - that value is rooted at one of the handler's OWN parameters, named or
|
|
1381
|
+
* destructured. A response read off an outbound call inside the handler
|
|
1382
|
+
* (`(await upstream.json()) as Rate`) has the same shape one variable
|
|
1383
|
+
* away, and is the opposite side of a different exchange;
|
|
1384
|
+
* - and the call's result, awaited, is `any` or `unknown`: the platform's
|
|
1385
|
+
* untyped parse. A read that states its own type (`formData()`, a typed
|
|
1386
|
+
* `json<T>()`) is not this shape and is left to the readers that
|
|
1387
|
+
* already handle it.
|
|
1388
|
+
*
|
|
1389
|
+
* The first such call in source order: a body is read once.
|
|
1390
|
+
*/
|
|
1391
|
+
private platformBodyReadIn;
|
|
1392
|
+
/**
|
|
1393
|
+
* The request contract the source states AT a body read, or null when it
|
|
1394
|
+
* states none there (carrick#807).
|
|
1395
|
+
*
|
|
1396
|
+
* Three statements count, each of them on the read itself:
|
|
1397
|
+
*
|
|
1398
|
+
* - a cast on it: `(await request.json()) as NewWidget`;
|
|
1399
|
+
* - the annotation of the binding it initialises:
|
|
1400
|
+
* `const input: NewWidget = await request.json()`;
|
|
1401
|
+
* - a schema the read, or the binding that holds it, is handed to
|
|
1402
|
+
* (`schemaConsumingRead`): the schema's input is what a caller may send.
|
|
1403
|
+
*
|
|
1404
|
+
* The first two are `typeNodeStatedAtRead`, the reading a consumer's
|
|
1405
|
+
* response read already gets. An annotation further out is not one of them:
|
|
1406
|
+
* `const saved: Saved = await save(await request.json())` types what `save`
|
|
1407
|
+
* returned, and reading it as the body would publish the wrong side of the
|
|
1408
|
+
* handler. Nor is a placeholder (`as unknown`, `Record<string, unknown>`).
|
|
1409
|
+
*/
|
|
1410
|
+
private requestStatedAtBodyRead;
|
|
1278
1411
|
/**
|
|
1279
1412
|
* Resolve a type-annotation/type-argument node to fully-structural text,
|
|
1280
1413
|
* dropping any `Promise<…>` wrapper (`c.req.json<T>()` returns `Promise<T>`,
|
|
@@ -1418,8 +1551,31 @@ export declare class TypeInferrer {
|
|
|
1418
1551
|
* request type resolves `body` to `unknown`/`any`, which the useless-type
|
|
1419
1552
|
* guard rejects. So a handler that declares nothing yields null and the next
|
|
1420
1553
|
* anchor runs.
|
|
1554
|
+
*
|
|
1555
|
+
* The member has to be one the route's own annotation can have filled
|
|
1556
|
+
* (carrick#807). The platform `Request` declares `body` too, as the byte
|
|
1557
|
+
* stream every request carries, and so does each library type that extends
|
|
1558
|
+
* it. That is concrete, so it passed the useless-type guard and a handler
|
|
1559
|
+
* taking the platform request published a stream as its request contract,
|
|
1560
|
+
* ahead of the body read inside it. A `body` a library declares with one
|
|
1561
|
+
* fixed type says nothing about this route and is skipped.
|
|
1421
1562
|
*/
|
|
1422
1563
|
private requestBodyFromHandlerParams;
|
|
1564
|
+
/**
|
|
1565
|
+
* True when a member is declared by a library, or by the platform, with a
|
|
1566
|
+
* type that names none of its declaring type's parameters: the same type on
|
|
1567
|
+
* every value, whichever route the value belongs to.
|
|
1568
|
+
*
|
|
1569
|
+
* `body: ReqBody` on a request type generic in its body is a slot, and the
|
|
1570
|
+
* handler's annotation fills it. `readonly body: ReadableStream<Uint8Array>
|
|
1571
|
+
* | null` on the platform request is not. A member the repo declares itself
|
|
1572
|
+
* is never fixed in this sense: writing `body: NewWidget` on the handler's
|
|
1573
|
+
* own request type is the annotation, and one declaration of the repo's
|
|
1574
|
+
* among several (an intersection with the platform type) decides it. A
|
|
1575
|
+
* declaration that states no type at all is left to the guards that read
|
|
1576
|
+
* the type.
|
|
1577
|
+
*/
|
|
1578
|
+
private memberIsFixedByItsLibrary;
|
|
1423
1579
|
/**
|
|
1424
1580
|
* Anchor (b2): the contract declared by a VALIDATOR MIDDLEWARE on the
|
|
1425
1581
|
* registration (carrick#964).
|