carrick 0.3.110 → 0.3.112

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.
@@ -38,6 +38,21 @@ import type { InferRequestItem, InferResult, ExtractionConfig } from './types.js
38
38
  * test (`machinery-indicator-mirror.test.ts`) asserts the two sets stay equal.
39
39
  */
40
40
  export declare const MACHINERY_MEMBER_INDICATORS: Set<string>;
41
+ /**
42
+ * `text` is `string`, alone or beside `null` and `undefined` in either order:
43
+ * the only payload a raw-text read publishes (carrick#1842).
44
+ */
45
+ /**
46
+ * Source text with every plain string literal written in double quotes:
47
+ * `'/a'`, `"/a"` and an interpolation-free `` `/a` `` are one value, so text
48
+ * that differs only in its quotes compares equal (carrick#2056).
49
+ *
50
+ * The text is read left to right, pairing quotes the way the scanner does,
51
+ * so a template's closing backtick never pairs with the next template's
52
+ * opening one. A literal holding a quote, a backslash or an interpolation is
53
+ * copied as it is, and so is an unterminated one with everything after it.
54
+ */
55
+ export declare function canonicalStringQuotes(text: string): string;
41
56
  /**
42
57
  * Options for TypeInferrer construction
43
58
  */
@@ -273,6 +288,24 @@ export declare class TypeInferrer {
273
288
  * returns the repo's own type (`toInstance(View, plain)`) is the payload.
274
289
  */
275
290
  private callResultIsPayload;
291
+ /**
292
+ * True when a located call evaluates to plain data, so it is the payload
293
+ * whatever its arguments and wherever its type is declared (carrick#2055).
294
+ *
295
+ * `rows.map(toDto)`, `rows.filter(cb)` and `listItems(ownerId)` produce the
296
+ * list a route sends. Read as a send, the first produced the mapper's
297
+ * function type, the second a callback's return, and the third `string`.
298
+ * What a send or a registration hands back is never plain data: a reply
299
+ * builder or a router carries methods, a bare send returns `void`, and a
300
+ * serialiser returns a primitive. So the result alone tells them apart.
301
+ *
302
+ * Plain data, once promise levels are taken off: an object with at least
303
+ * one member, no call or construct signature, and no member that is itself
304
+ * callable; an array of one; or a union whose members other than `null` and
305
+ * `undefined` all are. Tuples and empty objects are left to the callers'
306
+ * own reading.
307
+ */
308
+ private callResultIsPlainData;
276
309
  /**
277
310
  * The wire representation a request's printed type takes. A route response
278
311
  * is serialised as JSON by every sender this layer reads a payload out of,
@@ -297,7 +330,8 @@ export declare class TypeInferrer {
297
330
  *
298
331
  * Returns `undefined` when this does not apply, which leaves the caller's
299
332
  * own reading of the located expression untouched:
300
- * - the row's line is not a route registration;
333
+ * - the row's line is neither a route registration nor a line inside the
334
+ * handler the located send sits in;
301
335
  * - the located expression is neither a send nor the argument of one;
302
336
  * - that send is not one the handler returns;
303
337
  * - it is a success send and the only one that survives, so the join would
@@ -366,6 +400,11 @@ export declare class TypeInferrer {
366
400
  * belongs to a read.
367
401
  */
368
402
  private typeNodeStatedAtRead;
403
+ /**
404
+ * A wrapper between a body read and the binding it initialises that leaves
405
+ * the read's value as it is: `await`, parentheses, `!`, a cast, `satisfies`.
406
+ */
407
+ private wrapsReadTransparently;
369
408
  /**
370
409
  * A stated type with `any` or `unknown` written anywhere in it (`unknown`,
371
410
  * `Record<string, unknown>`, `{ items: any[] }`) leaves a position open: it
@@ -1067,6 +1106,16 @@ export declare class TypeInferrer {
1067
1106
  * No method or framework name is consulted anywhere.
1068
1107
  */
1069
1108
  private responseSiteStatus;
1109
+ /**
1110
+ * The status an earlier call of a send's own chain states: the receiver
1111
+ * calls `call` is invoked on (`a.status(401).json(body)` has `a.status(401)`),
1112
+ * innermost last. Each receiver call's first argument is read by the rule
1113
+ * an argument past a body is, so a numeric literal or a literal-typed value
1114
+ * counts and a plain `number` is `variable`. `undefined` when no receiver
1115
+ * call states a status. No method name is consulted: a receiver call that
1116
+ * is handed no status-shaped value says nothing.
1117
+ */
1118
+ private chainStatus;
1070
1119
  /**
1071
1120
  * The HTTP status codes an argument states, `'variable'` when it is a
1072
1121
  * status-shaped value the source does not fix, or `undefined` when it says
@@ -1104,6 +1153,19 @@ export declare class TypeInferrer {
1104
1153
  * followed to a small depth; anything else is returned as itself.
1105
1154
  */
1106
1155
  private expandResponseBranches;
1156
+ /**
1157
+ * The symbol an anchor is named from: the type's own symbol, unless that
1158
+ * symbol's name is synthetic (`__type`, `__object`, ...), in which case the
1159
+ * alias symbol (carrick#2148).
1160
+ *
1161
+ * `type Widget = { id: string }` and an instantiated `Page<Order>` carry
1162
+ * the anonymous `__type` as their own symbol and the alias as their alias
1163
+ * symbol. Reading the own symbol first and stopping because it is truthy
1164
+ * left every object-literal alias without an anchor, while the same shape
1165
+ * declared as an interface had one. The own symbol still wins whenever it
1166
+ * has a real name, so every type anchored before keeps its anchor.
1167
+ */
1168
+ private anchorSymbolOf;
1107
1169
  /**
1108
1170
  * The deterministic source symbol of a resolved type (`Payment` for a payload
1109
1171
  * typed `Payment`), or `undefined` when there is no single user-defined
@@ -1125,7 +1187,8 @@ export declare class TypeInferrer {
1125
1187
  * declarations IN its `source_file`, so the request must point at the file
1126
1188
  * that actually declares the tsc-witnessed payload type.
1127
1189
  *
1128
- * The declarations read are those of the type's own symbol, so a name
1190
+ * The declarations read are those of the symbol the anchor is named from
1191
+ * (`anchorSymbolOf`: the type's own symbol, or its alias's), so a name
1129
1192
  * imported through a barrel reports the file that declares it, and a name
1130
1193
  * two files declare reports the one this type resolves to. A declaration in
1131
1194
  * an installed package or a TypeScript lib is reported as it is found, as
@@ -1431,6 +1494,18 @@ export declare class TypeInferrer {
1431
1494
  * The first such call in source order: a body is read once.
1432
1495
  */
1433
1496
  private platformBodyReadIn;
1497
+ /**
1498
+ * The platform body read whose result `located` is a MEMBER of, or
1499
+ * `undefined` (carrick#2057).
1500
+ *
1501
+ * A member is a property or element access off a binding, or a name
1502
+ * destructured out of one. The binding must be initialised by the body read
1503
+ * `platformBodyReadIn` finds in the function that declares it, with only
1504
+ * transparent wrappers between the two (`await`, parentheses, `!`, a cast,
1505
+ * `satisfies`). The binding itself is not a member, and neither is a member
1506
+ * of anything else (a query object, a parameter, an outbound response).
1507
+ */
1508
+ private parsedBodyReadHolding;
1434
1509
  /**
1435
1510
  * The request contract the source states AT a body read, or null when it
1436
1511
  * states none there (carrick#807).
@@ -1544,6 +1619,27 @@ export declare class TypeInferrer {
1544
1619
  * whose type does not resolve the member, or an opaque config, abstains.
1545
1620
  */
1546
1621
  private requestBodyInCall;
1622
+ /** A string, a string literal, a template literal, or a union of strings. */
1623
+ private isStringLikeType;
1624
+ /**
1625
+ * carrick#1841, request half: a request call that states its URL on its one
1626
+ * object argument (`client.post({ url: '/items', ...options })`, the way a
1627
+ * generated client issues every operation). The method's own parameter
1628
+ * types the body `unknown`, so the object is the only statement of it: its
1629
+ * `body` member, the member `RequestInit` defines, written on the object or
1630
+ * carried in by a spread whose type says what it is.
1631
+ *
1632
+ * - A `body` written after the object's last spread is the body.
1633
+ * - Otherwise the object's own type has the answer. No `body` member, or
1634
+ * one typed `undefined` or `never`, means the call sends no body.
1635
+ * - A member typed `any`, `unknown` or a type parameter, or one only the
1636
+ * compiler's default library declares (a spread `RequestInit` carries the
1637
+ * serialised `BodyInit`, not a payload), states no payload: abstain. So
1638
+ * does an object that carries another body-named member and no `body`.
1639
+ *
1640
+ * An object with no string-typed `url` member is not a request object.
1641
+ */
1642
+ private requestObjectBody;
1547
1643
  /**
1548
1644
  * The body a config-slot argument supplies through `member`: an object
1549
1645
  * literal's own member, or a variable's member read off its type.
@@ -1838,6 +1934,20 @@ export declare class TypeInferrer {
1838
1934
  * then substring match (preferring containing matches).
1839
1935
  */
1840
1936
  private matchByText;
1937
+ /**
1938
+ * What a locator's text names, read off its own parse (carrick#2056):
1939
+ *
1940
+ * - `texts`: the normalized text of the expression it names and of each
1941
+ * wrapper it carries around it (`return`, a `const x =` binding, a label,
1942
+ * `await`, parentheses, a cast, `satisfies`, `!`). A node strictly inside
1943
+ * that expression is not among them;
1944
+ * - `rootKind` and `rootStart`: the innermost of those, its kind, and where
1945
+ * its text starts in the locator.
1946
+ *
1947
+ * `null` when the text does not parse as one expression or one statement:
1948
+ * there is no structure to read, and the caller keeps its text rule.
1949
+ */
1950
+ private locatorNames;
1841
1951
  /**
1842
1952
  * Pick the best match from a set of candidate nodes:
1843
1953
  * smallest range, then closest to target line.