carrick 0.3.125 → 0.3.127

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.
@@ -167,7 +167,10 @@ export declare class TypeInferrer {
167
167
  * read is the project the scan loaded.
168
168
  *
169
169
  * Nothing is read past `deadline`: a batch that runs out keeps the readings
170
- * it made and publishes none for the rest.
170
+ * it made and publishes none for the rest, and marks each of the rest
171
+ * `unwidened_out_of_budget` (carrick#2100). A request that never needed a
172
+ * reading (a declared return, nothing to mark) or lost it for a reason of
173
+ * its own (a marking that added a diagnostic) is never marked.
171
174
  */
172
175
  private addUnwidenedReadings;
173
176
  /**
@@ -295,6 +298,17 @@ export declare class TypeInferrer {
295
298
  * when the located expression is not part of what the handler returns.
296
299
  */
297
300
  private returnedSendHolding;
301
+ /**
302
+ * True when `node` is a bare reference to a parameter of the handler the
303
+ * route registration on the request's line hands in (found as
304
+ * `registrationAtLine` finds it, wrappers included): the request, the reply
305
+ * or the context the framework passes, never a body the route sends
306
+ * (carrick-cloud#2576). Where the parameter's type is declared is not read:
307
+ * a parameter of any other function is data, whether the repo or an
308
+ * installed package types it (`.then((account) => reply.send(account))`, a
309
+ * helper's `account: Account`).
310
+ */
311
+ private isRouteHandlerParameter;
298
312
  /**
299
313
  * True when a located call's own result is the route's payload, so the
300
314
  * transitional drill into its first argument must not run (carrick#1732).
@@ -479,11 +493,29 @@ export declare class TypeInferrer {
479
493
  * guard, so that binding stays unread and the capture answers the row.
480
494
  */
481
495
  private destructuredValueTerminal;
496
+ /**
497
+ * Between `callExpr` and the return statement around it there is an object
498
+ * or array literal: the call's result is one part of a value the function
499
+ * builds and returns.
500
+ */
501
+ private callIsPartOfReturnedLiteral;
482
502
  /**
483
503
  * `expr` declares a name for what a call returns when it is handed a
484
504
  * tracked name whole (`const data: T = await parseJson(response, 'op')`).
485
505
  */
486
506
  private handsTrackedValueToACall;
507
+ /**
508
+ * The call whose result `expr` declares or assigns a name for, and the
509
+ * index of its argument that is a tracked name whole, or undefined.
510
+ */
511
+ private callTakingTrackedValue;
512
+ /**
513
+ * `expr` names the result of a call that states the tracked value it takes
514
+ * (`callStatesItsArgument`): a schema validates it, or the callee returns it
515
+ * unchanged. A converter's result describes what it built from the value,
516
+ * not the value (carrick#2595).
517
+ */
518
+ private statesTrackedValue;
487
519
  /** `expr` holds a binary whole-body read taken on a tracked name. */
488
520
  private holdsBinaryBodyRead;
489
521
  /**
@@ -696,7 +728,10 @@ export declare class TypeInferrer {
696
728
  * serialiser answering `string` describes what the caller did with the
697
729
  * body, not what the body is, and publishing it would be a
698
730
  * concrete-but-wrong contract where the honest `any` of the read is
699
- * merely unresolved.
731
+ * merely unresolved;
732
+ * - the call states its argument (`callStatesItsArgument`): a schema
733
+ * validates it, or the callee returns it unchanged. A converter's
734
+ * object result describes what it built, not the body (carrick#2595).
700
735
  */
701
736
  private statedPayloadAroundBodyRead;
702
737
  /**
@@ -1682,11 +1717,14 @@ export declare class TypeInferrer {
1682
1717
  */
1683
1718
  private registrationHandlerAt;
1684
1719
  /**
1685
- * The handler function referenced by a route-registration call: the first
1720
+ * The handler function referenced by a route-registration call: the LAST
1686
1721
  * argument that is an inline function, or an identifier bound to a function
1687
- * (typically the 2nd+ arg — the path literal is not function-valued, so it is
1688
- * skipped naturally). No callee-name check: a call whose argument resolves to
1689
- * a function is structurally a registration regardless of the framework.
1722
+ * (carrick#2472 P3-2b). The functions before it are middleware
1723
+ * (`route(path).post(auth, audit, handler)`), which runs first and hands on;
1724
+ * reading the first function read a middleware as the route. The path
1725
+ * literal is not function-valued, so it is skipped naturally. No callee-name
1726
+ * check: a call whose argument resolves to a function is structurally a
1727
+ * registration regardless of the framework.
1690
1728
  */
1691
1729
  private handlerFromRegistrationCall;
1692
1730
  /**
@@ -1701,16 +1739,32 @@ export declare class TypeInferrer {
1701
1739
  * declaration (via the compiler's definition nodes) and returned when that
1702
1740
  * declaration is — or initializes to — a function. Anything else (a path
1703
1741
  * literal, an object, a non-function binding) yields undefined.
1742
+ * `followWrapperCalls` false reads a binding to a wrapper call as no
1743
+ * function, so a name the wrapper walk meets is never walked again.
1704
1744
  */
1705
1745
  private asHandlerFunction;
1706
1746
  /**
1707
1747
  * Extract a `FunctionLike` from a declaration node the compiler resolved an
1708
1748
  * identifier to: a function declaration is itself the function; a variable
1709
1749
  * declaration / binding whose initializer is an inline function yields that
1710
- * function (`const h = async () => { … }`). Import/re-export shims are walked
1711
- * by ts-morph's `getDefinitionNodes`, so no manual import chasing is needed.
1750
+ * function (`const h = async () => { … }`), and one whose initializer is a
1751
+ * wrapper call yields the function the call wraps
1752
+ * (`const h = wrap<Contract>(async (req, res) => { … })`, carrick#2472
1753
+ * P3-2b; `functionWrappedBy`). Import/re-export shims are walked by
1754
+ * ts-morph's `getDefinitionNodes`, so no manual import chasing is needed.
1712
1755
  */
1713
1756
  private functionFromDeclaration;
1757
+ /**
1758
+ * The function a call wraps, for a name bound to that call and used as a
1759
+ * handler (carrick#2472 P3-2b): the call's one argument that is a function
1760
+ * literal, a name bound to one, or another such call, a few calls deep.
1761
+ *
1762
+ * Two conditions keep this to wrappers. The call's own value has to be
1763
+ * callable, because the name is used as a function: `rows.map((row) => …)`
1764
+ * is handed a function and yields a list. And exactly one argument may be a
1765
+ * function: with two there is no saying which of them is wrapped.
1766
+ */
1767
+ private functionWrappedBy;
1714
1768
  /**
1715
1769
  * True when `handler` reads nothing from the incoming message (carrick#827):
1716
1770
  * every use of one of its parameters, named or destructured, is the receiver
@@ -1906,6 +1960,77 @@ export declare class TypeInferrer {
1906
1960
  * whose type does not resolve the member, or an opaque config, abstains.
1907
1961
  */
1908
1962
  private requestBodyInCall;
1963
+ /**
1964
+ * carrick#2628: the located node is an argument of a call into a function
1965
+ * whose body the program holds (an in-repo client method,
1966
+ * `client.addTags(project, unique(tags))`), at a parameter that is not a
1967
+ * body slot. What the call sends is decided inside that function, so the
1968
+ * argument is the body only when the function sends it unchanged. One
1969
+ * level, read off each use of the parameter in the function's body:
1970
+ *
1971
+ * - the use IS the value of a body-named member (`body: tags`,
1972
+ * `body: JSON.stringify(tags)`) or of a body slot of a call: the
1973
+ * argument is the body, and its own type stands (`none`);
1974
+ * - the use sits inside such a value (`body: { tags }`,
1975
+ * `body: (event ?? {}) as never`): the body is that value, read at the
1976
+ * function without the casts around it;
1977
+ * - the use sits inside an object or array literal that is no body value
1978
+ * (`send(project, [labels])`): the body cannot be told, abstain.
1979
+ *
1980
+ * Uses that disagree abstain. A generic function's body may be typed by
1981
+ * its type parameters, so it abstains too. A library's declaration
1982
+ * (`fetch`, an installed client) has no body to read and is left alone,
1983
+ * and so is an untyped argument (a handler's `request.body` handed to a
1984
+ * helper): it states no contract to mistake, and the untyped-read path
1985
+ * below reads it.
1986
+ */
1987
+ private bodyBuiltByCallee;
1988
+ /**
1989
+ * `bodyBuiltByCallee`, telling apart a callee that sends the argument
1990
+ * unchanged (`passes`) from one that states nothing about it (`none`).
1991
+ * `depth` counts the forwarded locals followed (carrick#2671).
1992
+ */
1993
+ private calleeBodyRead;
1994
+ /**
1995
+ * The request body value `use` is part of, inside `scope`: the value of a
1996
+ * body-named object member, or the argument at a body slot of a call,
1997
+ * looking through parentheses, casts, `await` and a `JSON.stringify`
1998
+ * around it. `use` itself when it is that value whole.
1999
+ */
2000
+ private bodyValueAround;
2001
+ /**
2002
+ * carrick#2671: the `const` local whose initializer holds `use`, inside
2003
+ * `scope`, when `scope` sends that local unchanged as the body: whole in a
2004
+ * body slot, or as an argument into a function that passes it on as its
2005
+ * body. The local's name, so its declared type is read. Undefined when the
2006
+ * local is never sent, when a further body is built from it, or when a
2007
+ * function lies between `use` and the declaration.
2008
+ */
2009
+ private forwardedLocalHolding;
2010
+ /** `value` is `use` behind what `sentValue` sees through. */
2011
+ private isSameValue;
2012
+ /**
2013
+ * The value a body slot sends when it sends anything, behind parentheses,
2014
+ * casts, `await`, a `JSON.stringify`, and (carrick#2668) a choice whose
2015
+ * other side sends nothing: `x ? JSON.stringify(x) : undefined`,
2016
+ * `x || null`, `x ?? undefined`. A `?? {}` sends `{}`, so it is a body the
2017
+ * function builds and is not seen through.
2018
+ */
2019
+ private sentValue;
2020
+ /**
2021
+ * The branch of `choice` that sends something, when its other branch sends
2022
+ * nothing (`undefined`, `null`, `void 0`, or `{}` spread into a request).
2023
+ */
2024
+ private sendingBranch;
2025
+ /** `undefined`, `null`, `void 0`, or (where `emptyObject`) `{}`. */
2026
+ private sendsNothing;
2027
+ /**
2028
+ * carrick#2668, #2664: `use` sits in the test of a choice whose other side
2029
+ * sends nothing (`body ? JSON.stringify(body) : null`,
2030
+ * `...(body === undefined ? {} : { body: JSON.stringify(body) })`). The
2031
+ * test only decides whether the argument is sent.
2032
+ */
2033
+ private inSendNothingTest;
1909
2034
  /** A string, a string literal, a template literal, or a union of strings. */
1910
2035
  private isStringLikeType;
1911
2036
  /**
@@ -2072,6 +2197,22 @@ export declare class TypeInferrer {
2072
2197
  * `reads.parameters`, the parameter's own type (rank 4).
2073
2198
  */
2074
2199
  private stateAtReceivingCall;
2200
+ /**
2201
+ * The input contract of a schema `call` validates its argument at `index`
2202
+ * with: its receiver (`Schema.safeParse(body)`) or one of its other
2203
+ * arguments (`parse(Schema, body)`), or null. A candidate counts only when
2204
+ * it declares schema types, so no method or library name is matched
2205
+ * (carrick#1166).
2206
+ */
2207
+ private schemaHandedArgument;
2208
+ /**
2209
+ * `call`'s result describes the value it takes at argument `index`: it
2210
+ * validates it with a schema, or its callee returns it unchanged
2211
+ * (`passThroughFunction`). Any other call builds something new from the
2212
+ * value, and its result describes what it built, never the value it was
2213
+ * handed (carrick#2595).
2214
+ */
2215
+ private callStatesItsArgument;
2075
2216
  /**
2076
2217
  * The project function `call` invokes, when every value it returns is its
2077
2218
  * argument at `index` as it was handed in (through parentheses, casts,