@spacefast/wpcloud-sdk 0.2.2 → 0.4.1
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/dist/runtime.d.ts +10 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +16 -13
- package/package.json +1 -1
package/dist/runtime.d.ts
CHANGED
|
@@ -21,6 +21,15 @@ export declare function createWpCloudClient(options: {
|
|
|
21
21
|
auth: string;
|
|
22
22
|
baseUrl?: string;
|
|
23
23
|
}): Client;
|
|
24
|
-
export declare function setWpCloudCallSignalProvider(fn: (() => AbortSignal | null) | null): void;
|
|
25
24
|
export declare function wpCloudRawFetch(input: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]): Promise<Response>;
|
|
25
|
+
/**
|
|
26
|
+
* The proxy wp.cloud egress dials through, if any.
|
|
27
|
+
*
|
|
28
|
+
* SPACEFAST_WPCLOUD_HTTPS_PROXY is where the control plane's proxy scrub
|
|
29
|
+
* (apps/control-plane/src/config/proxy-scrub.ts) parks the operator's proxy
|
|
30
|
+
* after deleting the generic variables: wp.cloud is the one egress that keeps
|
|
31
|
+
* it, everything else (connectors included) dials direct. The generic names
|
|
32
|
+
* still work for a process that never ran the scrub.
|
|
33
|
+
*/
|
|
34
|
+
export declare function wpCloudProxyFromEnvironment(source?: Record<string, string | undefined>): string | undefined;
|
|
26
35
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAA8B,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,YAAY,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAejD,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,M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M,EACf,OAAO,EAAE,OAAO,EAChB,iBAAiB,GAAE,MAAM,GAAG,IAAW;CAQ1C;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAa1E;AAKD,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,OAAO,CAAC;CACb,CAAC;AAIF,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,sBAAsB,KAAK,IAAI,CAAC,GAAG,IAAI,GACzD,IAAI,CAEN;AAED,eAAO,MAAM,kBAAkB,EAAE,kBAO/B,CAAC;AAOH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAUvF;AAmMD,wBAAsB,eAAe,CACnC,KAAK,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAClC,IAAI,CAAC,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,qBAGnC;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACvD,MAAM,GAAG,SAAS,CAOpB"}
|
package/dist/runtime.js
CHANGED
|
@@ -57,19 +57,7 @@ export function createWpCloudClient(options) {
|
|
|
57
57
|
auth: options.auth,
|
|
58
58
|
})));
|
|
59
59
|
}
|
|
60
|
-
// An ambient cancellation source consulted per call — the control plane
|
|
61
|
-
// registers its operation-lease signal here (wp-cloud/config.ts) so a fenced
|
|
62
|
-
// executor's in-flight provider calls cancel instead of running to completion.
|
|
63
|
-
let wpCloudCallSignalProvider = null;
|
|
64
|
-
export function setWpCloudCallSignalProvider(fn) {
|
|
65
|
-
wpCloudCallSignalProvider = fn;
|
|
66
|
-
}
|
|
67
60
|
async function wpCloudFetch(input, init) {
|
|
68
|
-
const ambient = wpCloudCallSignalProvider?.() ?? null;
|
|
69
|
-
if (ambient) {
|
|
70
|
-
const own = init?.signal ?? (input instanceof Request ? input.signal : null);
|
|
71
|
-
init = { ...init, signal: own ? AbortSignal.any([own, ambient]) : ambient };
|
|
72
|
-
}
|
|
73
61
|
const request = wpCloudRequestIdentity(input, init);
|
|
74
62
|
const startedAt = performance.now();
|
|
75
63
|
let ok = false;
|
|
@@ -222,6 +210,21 @@ function errorMessage(error) {
|
|
|
222
210
|
export async function wpCloudRawFetch(input, init) {
|
|
223
211
|
return wpCloudNetworkFetch(input, init);
|
|
224
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* The proxy wp.cloud egress dials through, if any.
|
|
215
|
+
*
|
|
216
|
+
* SPACEFAST_WPCLOUD_HTTPS_PROXY is where the control plane's proxy scrub
|
|
217
|
+
* (apps/control-plane/src/config/proxy-scrub.ts) parks the operator's proxy
|
|
218
|
+
* after deleting the generic variables: wp.cloud is the one egress that keeps
|
|
219
|
+
* it, everything else (connectors included) dials direct. The generic names
|
|
220
|
+
* still work for a process that never ran the scrub.
|
|
221
|
+
*/
|
|
222
|
+
export function wpCloudProxyFromEnvironment(source = process.env) {
|
|
223
|
+
return (source.SPACEFAST_WPCLOUD_HTTPS_PROXY?.trim() ||
|
|
224
|
+
source.HTTPS_PROXY?.trim() ||
|
|
225
|
+
source.https_proxy?.trim() ||
|
|
226
|
+
undefined);
|
|
227
|
+
}
|
|
225
228
|
async function wpCloudNetworkFetch(input, init) {
|
|
226
229
|
const controller = new AbortController();
|
|
227
230
|
let didTimeout = false;
|
|
@@ -241,7 +244,7 @@ async function wpCloudNetworkFetch(input, init) {
|
|
|
241
244
|
// Atomic API access in development can require the operator's authenticated
|
|
242
245
|
// HTTPS proxy. Bun does not consistently apply the environment value to
|
|
243
246
|
// fetch, so pass it explicitly; production without one keeps direct I/O.
|
|
244
|
-
const proxy =
|
|
247
|
+
const proxy = wpCloudProxyFromEnvironment();
|
|
245
248
|
const requestInit = {
|
|
246
249
|
...init,
|
|
247
250
|
signal: controller.signal,
|