carrick 0.3.124 → 0.3.126
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 +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/capture/api.d.ts +5 -1
- package/sidecar/dist/src/capture/check-classify.js +11 -5
- package/sidecar/dist/src/capture/check.js +8 -1
- package/sidecar/dist/src/capture/deep-walk.d.ts +31 -0
- package/sidecar/dist/src/capture/deep-walk.js +43 -1
- package/sidecar/dist/src/capture/deno-project.d.ts +7 -0
- package/sidecar/dist/src/capture/deno-project.js +7 -0
- package/sidecar/dist/src/capture/index.d.ts +1 -1
- package/sidecar/dist/src/capture/index.js +1 -1
- package/sidecar/dist/src/capture/service-config.d.ts +11 -0
- package/sidecar/dist/src/capture/service-config.js +40 -0
- package/sidecar/dist/src/declaration-attribution.d.ts +11 -0
- package/sidecar/dist/src/declaration-attribution.js +16 -0
- package/sidecar/dist/src/implementations.d.ts +43 -0
- package/sidecar/dist/src/implementations.js +224 -0
- package/sidecar/dist/src/index.js +35 -1
- package/sidecar/dist/src/library-claims.d.ts +17 -2
- package/sidecar/dist/src/library-claims.js +242 -47
- package/sidecar/dist/src/position-rows.d.ts +119 -1
- package/sidecar/dist/src/position-rows.js +163 -9
- package/sidecar/dist/src/project-loader.d.ts +31 -0
- package/sidecar/dist/src/project-loader.js +67 -4
- package/sidecar/dist/src/type-inferrer.d.ts +150 -16
- package/sidecar/dist/src/type-inferrer.js +651 -94
- package/sidecar/dist/src/types.d.ts +46 -2
- package/sidecar/dist/src/validators.d.ts +73 -0
- package/sidecar/dist/src/validators.js +10 -0
|
@@ -479,11 +479,29 @@ export declare class TypeInferrer {
|
|
|
479
479
|
* guard, so that binding stays unread and the capture answers the row.
|
|
480
480
|
*/
|
|
481
481
|
private destructuredValueTerminal;
|
|
482
|
+
/**
|
|
483
|
+
* Between `callExpr` and the return statement around it there is an object
|
|
484
|
+
* or array literal: the call's result is one part of a value the function
|
|
485
|
+
* builds and returns.
|
|
486
|
+
*/
|
|
487
|
+
private callIsPartOfReturnedLiteral;
|
|
482
488
|
/**
|
|
483
489
|
* `expr` declares a name for what a call returns when it is handed a
|
|
484
490
|
* tracked name whole (`const data: T = await parseJson(response, 'op')`).
|
|
485
491
|
*/
|
|
486
492
|
private handsTrackedValueToACall;
|
|
493
|
+
/**
|
|
494
|
+
* The call whose result `expr` declares or assigns a name for, and the
|
|
495
|
+
* index of its argument that is a tracked name whole, or undefined.
|
|
496
|
+
*/
|
|
497
|
+
private callTakingTrackedValue;
|
|
498
|
+
/**
|
|
499
|
+
* `expr` names the result of a call that states the tracked value it takes
|
|
500
|
+
* (`callStatesItsArgument`): a schema validates it, or the callee returns it
|
|
501
|
+
* unchanged. A converter's result describes what it built from the value,
|
|
502
|
+
* not the value (carrick#2595).
|
|
503
|
+
*/
|
|
504
|
+
private statesTrackedValue;
|
|
487
505
|
/** `expr` holds a binary whole-body read taken on a tracked name. */
|
|
488
506
|
private holdsBinaryBodyRead;
|
|
489
507
|
/**
|
|
@@ -696,7 +714,10 @@ export declare class TypeInferrer {
|
|
|
696
714
|
* serialiser answering `string` describes what the caller did with the
|
|
697
715
|
* body, not what the body is, and publishing it would be a
|
|
698
716
|
* concrete-but-wrong contract where the honest `any` of the read is
|
|
699
|
-
* merely unresolved
|
|
717
|
+
* merely unresolved;
|
|
718
|
+
* - the call states its argument (`callStatesItsArgument`): a schema
|
|
719
|
+
* validates it, or the callee returns it unchanged. A converter's
|
|
720
|
+
* object result describes what it built, not the body (carrick#2595).
|
|
700
721
|
*/
|
|
701
722
|
private statedPayloadAroundBodyRead;
|
|
702
723
|
/**
|
|
@@ -1800,8 +1821,10 @@ export declare class TypeInferrer {
|
|
|
1800
1821
|
* - a cast on it: `(await request.json()) as NewWidget`;
|
|
1801
1822
|
* - the annotation of the binding it initialises:
|
|
1802
1823
|
* `const input: NewWidget = await request.json()`;
|
|
1803
|
-
* - a
|
|
1804
|
-
* (`
|
|
1824
|
+
* - a type the handler states for the read further on
|
|
1825
|
+
* (`statedInFunction`): a schema it is handed to, the annotation of a
|
|
1826
|
+
* name it is assigned to, a pass-through function, a cast of the whole
|
|
1827
|
+
* value.
|
|
1805
1828
|
*
|
|
1806
1829
|
* The first two are `typeNodeStatedAtRead`, the reading a consumer's
|
|
1807
1830
|
* response read already gets. An annotation further out is not one of them:
|
|
@@ -1904,6 +1927,62 @@ export declare class TypeInferrer {
|
|
|
1904
1927
|
* whose type does not resolve the member, or an opaque config, abstains.
|
|
1905
1928
|
*/
|
|
1906
1929
|
private requestBodyInCall;
|
|
1930
|
+
/**
|
|
1931
|
+
* carrick#2628: the located node is an argument of a call into a function
|
|
1932
|
+
* whose body the program holds (an in-repo client method,
|
|
1933
|
+
* `client.addTags(project, unique(tags))`), at a parameter that is not a
|
|
1934
|
+
* body slot. What the call sends is decided inside that function, so the
|
|
1935
|
+
* argument is the body only when the function sends it unchanged. One
|
|
1936
|
+
* level, read off each use of the parameter in the function's body:
|
|
1937
|
+
*
|
|
1938
|
+
* - the use IS the value of a body-named member (`body: tags`,
|
|
1939
|
+
* `body: JSON.stringify(tags)`) or of a body slot of a call: the
|
|
1940
|
+
* argument is the body, and its own type stands (`none`);
|
|
1941
|
+
* - the use sits inside such a value (`body: { tags }`,
|
|
1942
|
+
* `body: (event ?? {}) as never`): the body is that value, read at the
|
|
1943
|
+
* function without the casts around it;
|
|
1944
|
+
* - the use sits inside an object or array literal that is no body value
|
|
1945
|
+
* (`send(project, [labels])`): the body cannot be told, abstain.
|
|
1946
|
+
*
|
|
1947
|
+
* Uses that disagree abstain. A generic function's body may be typed by
|
|
1948
|
+
* its type parameters, so it abstains too. A library's declaration
|
|
1949
|
+
* (`fetch`, an installed client) has no body to read and is left alone,
|
|
1950
|
+
* and so is an untyped argument (a handler's `request.body` handed to a
|
|
1951
|
+
* helper): it states no contract to mistake, and the untyped-read path
|
|
1952
|
+
* below reads it.
|
|
1953
|
+
*/
|
|
1954
|
+
private bodyBuiltByCallee;
|
|
1955
|
+
/**
|
|
1956
|
+
* The request body value `use` is part of, inside `scope`: the value of a
|
|
1957
|
+
* body-named object member, or the argument at a body slot of a call,
|
|
1958
|
+
* looking through parentheses, casts, `await` and a `JSON.stringify`
|
|
1959
|
+
* around it. `use` itself when it is that value whole.
|
|
1960
|
+
*/
|
|
1961
|
+
private bodyValueAround;
|
|
1962
|
+
/** `value` is `use` behind what `sentValue` sees through. */
|
|
1963
|
+
private isSameValue;
|
|
1964
|
+
/**
|
|
1965
|
+
* The value a body slot sends when it sends anything, behind parentheses,
|
|
1966
|
+
* casts, `await`, a `JSON.stringify`, and (carrick#2668) a choice whose
|
|
1967
|
+
* other side sends nothing: `x ? JSON.stringify(x) : undefined`,
|
|
1968
|
+
* `x || null`, `x ?? undefined`. A `?? {}` sends `{}`, so it is a body the
|
|
1969
|
+
* function builds and is not seen through.
|
|
1970
|
+
*/
|
|
1971
|
+
private sentValue;
|
|
1972
|
+
/**
|
|
1973
|
+
* The branch of `choice` that sends something, when its other branch sends
|
|
1974
|
+
* nothing (`undefined`, `null`, `void 0`, or `{}` spread into a request).
|
|
1975
|
+
*/
|
|
1976
|
+
private sendingBranch;
|
|
1977
|
+
/** `undefined`, `null`, `void 0`, or (where `emptyObject`) `{}`. */
|
|
1978
|
+
private sendsNothing;
|
|
1979
|
+
/**
|
|
1980
|
+
* carrick#2668, #2664: `use` sits in the test of a choice whose other side
|
|
1981
|
+
* sends nothing (`body ? JSON.stringify(body) : null`,
|
|
1982
|
+
* `...(body === undefined ? {} : { body: JSON.stringify(body) })`). The
|
|
1983
|
+
* test only decides whether the argument is sent.
|
|
1984
|
+
*/
|
|
1985
|
+
private inSendNothingTest;
|
|
1907
1986
|
/** A string, a string literal, a template literal, or a union of strings. */
|
|
1908
1987
|
private isStringLikeType;
|
|
1909
1988
|
/**
|
|
@@ -2030,19 +2109,74 @@ export declare class TypeInferrer {
|
|
|
2030
2109
|
*/
|
|
2031
2110
|
private middlewareBodySchemaValues;
|
|
2032
2111
|
/**
|
|
2033
|
-
* The
|
|
2034
|
-
* (carrick#
|
|
2035
|
-
*
|
|
2036
|
-
*
|
|
2037
|
-
*
|
|
2038
|
-
*
|
|
2039
|
-
*
|
|
2040
|
-
* (`
|
|
2041
|
-
*
|
|
2042
|
-
*
|
|
2043
|
-
*
|
|
2044
|
-
|
|
2045
|
-
|
|
2112
|
+
* The type the function a value is made in states for it, where the
|
|
2113
|
+
* compiler types the value itself `any` or `unknown` (carrick#2594), or
|
|
2114
|
+
* null.
|
|
2115
|
+
*
|
|
2116
|
+
* `value` is the located expression: a body read, or a call whose result is
|
|
2117
|
+
* untyped. The value is followed through the names that hold it: a
|
|
2118
|
+
* declaration it initialises, and a name it is assigned to later
|
|
2119
|
+
* (`let body: unknown; body = await read()`). At each place the value or
|
|
2120
|
+
* one of those names is used whole, the source can state a type:
|
|
2121
|
+
*
|
|
2122
|
+
* 0. the annotation of the name that holds it (`let body: Upload`), or the
|
|
2123
|
+
* declared return type of the function that returns it unchanged (only
|
|
2124
|
+
* with `reads.returned`);
|
|
2125
|
+
* 1. a schema it is handed to (`Schema.safeParse(body ?? {})`,
|
|
2126
|
+
* `parse(Schema, body)`): the schema's input is what a sender may send
|
|
2127
|
+
* (carrick#1166). A candidate counts only when it declares schema types,
|
|
2128
|
+
* so no method or library name is matched;
|
|
2129
|
+
* 2. a function of the project it is handed to that returns that argument
|
|
2130
|
+
* unchanged (through casts) or an empty default: its declared return
|
|
2131
|
+
* type. A function that builds a new value from its argument is a
|
|
2132
|
+
* converter, and its return type describes what it built, never the
|
|
2133
|
+
* value it was handed, so it states nothing here;
|
|
2134
|
+
* 3. a cast of the whole value (`(body as { phone: string }).phone`);
|
|
2135
|
+
* 4. the parameter of a call it is handed to (only with
|
|
2136
|
+
* `reads.parameters`), where that parameter's type is a body shape once
|
|
2137
|
+
* any callable member is dropped (a function never crosses the wire).
|
|
2138
|
+
*
|
|
2139
|
+
* The first rank with an answer decides. A placeholder (`unknown`,
|
|
2140
|
+
* `Record<string, unknown>`, any type node with `any` or `unknown` written
|
|
2141
|
+
* in it) states nothing, and two different statements in one rank decide
|
|
2142
|
+
* nothing: the answer is null.
|
|
2143
|
+
*/
|
|
2144
|
+
private statedInFunction;
|
|
2145
|
+
/**
|
|
2146
|
+
* What a call that takes the value at argument `index` states for it:
|
|
2147
|
+
* a schema among its receiver and other arguments (rank 1), a callee of the
|
|
2148
|
+
* project that returns that argument unchanged (rank 2), or, with
|
|
2149
|
+
* `reads.parameters`, the parameter's own type (rank 4).
|
|
2150
|
+
*/
|
|
2151
|
+
private stateAtReceivingCall;
|
|
2152
|
+
/**
|
|
2153
|
+
* The input contract of a schema `call` validates its argument at `index`
|
|
2154
|
+
* with: its receiver (`Schema.safeParse(body)`) or one of its other
|
|
2155
|
+
* arguments (`parse(Schema, body)`), or null. A candidate counts only when
|
|
2156
|
+
* it declares schema types, so no method or library name is matched
|
|
2157
|
+
* (carrick#1166).
|
|
2158
|
+
*/
|
|
2159
|
+
private schemaHandedArgument;
|
|
2160
|
+
/**
|
|
2161
|
+
* `call`'s result describes the value it takes at argument `index`: it
|
|
2162
|
+
* validates it with a schema, or its callee returns it unchanged
|
|
2163
|
+
* (`passThroughFunction`). Any other call builds something new from the
|
|
2164
|
+
* value, and its result describes what it built, never the value it was
|
|
2165
|
+
* handed (carrick#2595).
|
|
2166
|
+
*/
|
|
2167
|
+
private callStatesItsArgument;
|
|
2168
|
+
/**
|
|
2169
|
+
* The project function `call` invokes, when every value it returns is its
|
|
2170
|
+
* argument at `index` as it was handed in (through parentheses, casts,
|
|
2171
|
+
* `satisfies` and `!`) or an empty default (`{}`, `[]`, `null`,
|
|
2172
|
+
* `undefined`), and at least one return is that argument. Such a function
|
|
2173
|
+
* narrows its argument, so its declared return type describes the value it
|
|
2174
|
+
* was handed. Any other function builds something new from it, and is not
|
|
2175
|
+
* this.
|
|
2176
|
+
*/
|
|
2177
|
+
private passThroughFunction;
|
|
2178
|
+
/** `{}`, `[]`, `null` or `undefined`: a default that states no member. */
|
|
2179
|
+
private isEmptyDefault;
|
|
2046
2180
|
/**
|
|
2047
2181
|
* The part a validated read names when that part is not a body, or
|
|
2048
2182
|
* `undefined` (carrick#1166).
|