@gate-forge/pack-http 0.14.0 → 0.15.0
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/README.md +14 -0
- package/dist/client-calls.d.ts +33 -4
- package/dist/client-calls.d.ts.map +1 -1
- package/dist/client-calls.js +796 -32
- package/dist/client-calls.js.map +1 -1
- package/dist/detector.js +1 -1
- package/dist/detector.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -64,6 +64,20 @@ wrapper: calling it without declaring it blocks with
|
|
|
64
64
|
`FRONTEND_CALL_TARGET_UNRESOLVED` — removing wrapper support can never
|
|
65
65
|
make a call silently disappear (red probe).
|
|
66
66
|
|
|
67
|
+
The URL model also resolves, and only resolves, these finite shapes:
|
|
68
|
+
a single-assignment `const` (a closer `let` stays unresolved), both
|
|
69
|
+
branches of a conditional, a `const` object-literal lookup (every
|
|
70
|
+
literal-keyed value; computed keys, spreads, and `let` tables stay
|
|
71
|
+
unresolved), a destructured relative `import()` alias of a configured
|
|
72
|
+
symbol or builder, and a same-file function whose returned expressions
|
|
73
|
+
are a finite resolvable set. A `const` named `fetch` whose initializer
|
|
74
|
+
is not the Fetch API is not a fetch call. A wrapper entry may name
|
|
75
|
+
`parameter` (the endpoint argument; absent means the first parameter)
|
|
76
|
+
and set `methodFromBody: true` when the body issues more than one
|
|
77
|
+
concrete verb. The declaration may be a relative import, including a
|
|
78
|
+
default export, and a JSX attribute of `parameter` is a callsite.
|
|
79
|
+
Anything outside that set stays a typed unresolved entry.
|
|
80
|
+
|
|
67
81
|
### Instance baseURL joining (source-proven, fail-closed)
|
|
68
82
|
|
|
69
83
|
Frontends commonly create one Axios client with a base path and then
|
package/dist/client-calls.d.ts
CHANGED
|
@@ -40,7 +40,18 @@
|
|
|
40
40
|
* in the scanned set is a single `return <client call>(...)` arrow or
|
|
41
41
|
* function resolves its internal call with the callsite's first
|
|
42
42
|
* argument substituted for the wrapper's first parameter (one level,
|
|
43
|
-
* one parameter — anything deeper is typed unresolved).
|
|
43
|
+
* one parameter — anything deeper is typed unresolved). A wrapper may
|
|
44
|
+
* also name the endpoint parameter (`parameter`) and, when
|
|
45
|
+
* `methodFromBody` is set, keep each concrete verb in its body. The
|
|
46
|
+
* declaration may live in another scanned file, including a default
|
|
47
|
+
* export, and a JSX attribute of that parameter is a callsite.
|
|
48
|
+
* - **Local shapes** (still fail closed): a single-assignment `const`
|
|
49
|
+
* (a closer `let` stays unresolved), both branches of a conditional,
|
|
50
|
+
* a `const` object-literal lookup (every literal value), a destructured
|
|
51
|
+
* relative dynamic-import alias of a configured symbol or builder, and
|
|
52
|
+
* a same-file function whose returns are a finite resolvable set.
|
|
53
|
+
* A `const` named `fetch` whose initializer is not the Fetch API is
|
|
54
|
+
* not a fetch call.
|
|
44
55
|
*/
|
|
45
56
|
import { FRONTEND_CALL_TARGET_UNRESOLVED, HTTP_METHOD_DYNAMIC, HTTP_PATH_DYNAMIC } from '@gate-forge/http-contract';
|
|
46
57
|
import type { HttpMethod } from '@gate-forge/http-contract';
|
|
@@ -72,10 +83,22 @@ export interface ClientSymbolConfig extends ClientSymbolScoping {
|
|
|
72
83
|
export interface WrapperFunctionConfig extends ClientSymbolScoping {
|
|
73
84
|
name: string;
|
|
74
85
|
/**
|
|
75
|
-
* The concrete method the wrapper always issues
|
|
76
|
-
*
|
|
86
|
+
* The concrete method the wrapper always issues, unless
|
|
87
|
+
* {@link methodFromBody} is set. A body verb that disagrees with this
|
|
88
|
+
* method stays unresolved — the configuration must not relabel a POST
|
|
89
|
+
* as GET.
|
|
77
90
|
*/
|
|
78
91
|
method: HttpMethod;
|
|
92
|
+
/**
|
|
93
|
+
* The parameter that carries the endpoint path. Absent means the first
|
|
94
|
+
* parameter — the original single-parameter wrapper contract.
|
|
95
|
+
*/
|
|
96
|
+
parameter?: string;
|
|
97
|
+
/**
|
|
98
|
+
* When true, each client call in the body keeps its own concrete verb.
|
|
99
|
+
* Required when one wrapper issues more than one verb.
|
|
100
|
+
*/
|
|
101
|
+
methodFromBody?: boolean;
|
|
79
102
|
}
|
|
80
103
|
/** A configured pure URL builder: `name` + optional base + scoping. */
|
|
81
104
|
export interface UrlBuilderConfig extends ClientSymbolScoping {
|
|
@@ -170,7 +193,7 @@ export interface ResponseRead {
|
|
|
170
193
|
*/
|
|
171
194
|
chain?: number;
|
|
172
195
|
}
|
|
173
|
-
/** One discovered frontend call
|
|
196
|
+
/** One discovered frontend call. One callsite may emit several when it provably reaches several targets. */
|
|
174
197
|
export interface ClientCall {
|
|
175
198
|
method: HttpMethod;
|
|
176
199
|
/** Path exactly as written after constant substitution. */
|
|
@@ -196,6 +219,12 @@ export interface ClientCall {
|
|
|
196
219
|
* the pre-feature contract.
|
|
197
220
|
*/
|
|
198
221
|
responseReads?: ResponseRead[];
|
|
222
|
+
/**
|
|
223
|
+
* Present only when this callsite emits more than one canonical target.
|
|
224
|
+
* Appended to the fact id so siblings do not collide. Absent on a
|
|
225
|
+
* single-target callsite — that id stays byte-identical.
|
|
226
|
+
*/
|
|
227
|
+
idDisambiguator?: string;
|
|
199
228
|
}
|
|
200
229
|
export interface ClientScanUnresolved {
|
|
201
230
|
code: typeof FRONTEND_CALL_TARGET_UNRESOLVED | typeof HTTP_METHOD_DYNAMIC | typeof HTTP_PATH_DYNAMIC;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-calls.d.ts","sourceRoot":"","sources":["../src/client-calls.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"client-calls.d.ts","sourceRoot":"","sources":["../src/client-calls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAIH,OAAO,EACL,+BAA+B,EAC/B,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAe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