@spacefast/wpcloud-sdk 0.0.9 → 0.0.10
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/fake/router.d.ts +0 -5
- package/dist/fake/router.d.ts.map +1 -1
- package/dist/fake/router.js +19 -0
- package/dist/fake/server.d.ts +15 -8
- package/dist/fake/server.d.ts.map +1 -1
- package/dist/fake/server.js +22 -6
- package/dist/fake/store.d.ts +3 -0
- package/dist/fake/store.d.ts.map +1 -1
- package/dist/fake/store.js +4 -1
- package/package.json +1 -1
package/dist/fake/router.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Routes a parsed wp.cloud request to the in-memory store and returns the `{message, data}` envelope
|
|
3
|
-
* the real API uses. Errors are `{message, data: []}` + an HTTP status with NO machine code — exactly
|
|
4
|
-
* what the captured fixtures show (the control plane classifies on status + message text).
|
|
5
|
-
*/
|
|
6
1
|
import { FakeAtomicStore } from "./store.js";
|
|
7
2
|
export type FakeResult = {
|
|
8
3
|
status: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/fake/router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/fake/router.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,UAAU,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AA6C3D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,UAAU,CA0NZ"}
|
package/dist/fake/router.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* the real API uses. Errors are `{message, data: []}` + an HTTP status with NO machine code — exactly
|
|
4
4
|
* what the captured fixtures show (the control plane classifies on status + message text).
|
|
5
5
|
*/
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
6
7
|
import { FakeAtomicStore } from "./store.js";
|
|
7
8
|
const ok = (data) => ({ status: 200, body: { message: "OK", data } });
|
|
8
9
|
const fail = (status, message) => ({
|
|
@@ -64,6 +65,24 @@ export function routeFakeRequest(store, method, path, body) {
|
|
|
64
65
|
}
|
|
65
66
|
return ok([]); // claimable
|
|
66
67
|
}
|
|
68
|
+
// GET /get-domain-verification-code/{client}/{domain} — `data` is the bare code string
|
|
69
|
+
// (docs/wpcloud/openapi.json). Deterministic per domain so repeated DNS refreshes hand
|
|
70
|
+
// out the same TXT value, like the real API's stable per-client+domain code.
|
|
71
|
+
if (method === "GET" && head === "get-domain-verification-code") {
|
|
72
|
+
const domain = decodeURIComponent(seg[2] ?? "");
|
|
73
|
+
if (!domain)
|
|
74
|
+
return fail(400, "Missing or invalid domain name");
|
|
75
|
+
return ok(`atomic-domain-${createHash("sha256").update(domain).digest("hex")}`);
|
|
76
|
+
}
|
|
77
|
+
// GET /get-ips/{client}[/{domain}] — client IPs/CIDRs; `suggested` is only present when a
|
|
78
|
+
// domain is supplied (docs/wpcloud/openapi.json example values).
|
|
79
|
+
if (method === "GET" && head === "get-ips") {
|
|
80
|
+
const domain = decodeURIComponent(seg[2] ?? "");
|
|
81
|
+
return ok({
|
|
82
|
+
ips: ["192.0.78.128/25"],
|
|
83
|
+
...(domain ? { suggested: ["192.0.78.150", "192.0.78.200"] } : {}),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
67
86
|
// --- sites lifecycle ------------------------------------------------------------------------
|
|
68
87
|
// GET /get-sites/{client}[/_data]?limit=… — only return requested meta,
|
|
69
88
|
// matching Atomic's slash-delimited additional-meta contract.
|
package/dist/fake/server.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The lean wp.cloud fake exposed as a `fetch`-shaped function — the same seam `wpCloudRawFetch` uses.
|
|
3
|
-
* `makeFakeAtomic()` gives a fresh, isolated store (per-suite use via `setWpCloudFakeFetch`);
|
|
4
|
-
* `defaultFakeFetch` is a process-global instance for env-driven `WP_CLOUD_PROVIDER_MODE=fake`.
|
|
5
|
-
*/
|
|
6
1
|
import type { WpCloudFakeFetch } from "../runtime.js";
|
|
7
2
|
import { FakeAtomicStore } from "./store.js";
|
|
8
3
|
/**
|
|
@@ -11,11 +6,23 @@ import { FakeAtomicStore } from "./store.js";
|
|
|
11
6
|
* effect, not that a mock was called) — e.g. crontab registration, aliases,
|
|
12
7
|
* persistent data.
|
|
13
8
|
*/
|
|
14
|
-
export declare function makeFakeAtomicWithStore(
|
|
9
|
+
export declare function makeFakeAtomicWithStore(options?: {
|
|
10
|
+
siteSequenceStart?: number;
|
|
11
|
+
}): {
|
|
15
12
|
fetch: WpCloudFakeFetch;
|
|
16
13
|
store: FakeAtomicStore;
|
|
17
14
|
};
|
|
18
|
-
export declare function makeFakeAtomic(
|
|
19
|
-
|
|
15
|
+
export declare function makeFakeAtomic(options?: {
|
|
16
|
+
siteSequenceStart?: number;
|
|
17
|
+
}): WpCloudFakeFetch;
|
|
18
|
+
/**
|
|
19
|
+
* Process-global fake for `WP_CLOUD_PROVIDER_MODE=fake` (no per-suite override
|
|
20
|
+
* installed). The site sequence starts at a per-process random offset: several
|
|
21
|
+
* processes can share one database in fake mode (the e2e seed script on the
|
|
22
|
+
* host, the control-plane container) and each runs its own store — with a
|
|
23
|
+
* fixed base every process mints atomic_site_id 151000001 first and collides
|
|
24
|
+
* on the DB's unique provider_ref index. Per-suite `makeFakeAtomic()` stores
|
|
25
|
+
* keep the deterministic default.
|
|
26
|
+
*/
|
|
20
27
|
export declare const defaultFakeFetch: WpCloudFakeFetch;
|
|
21
28
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/fake/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/fake/server.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA2C7C;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,GAAE;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG;IACrF,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,eAAe,CAAC;CACxB,CAkBA;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,gBAAgB,CAE7F;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAE7B,CAAC"}
|
package/dist/fake/server.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lean wp.cloud fake exposed as a `fetch`-shaped function — the same seam `wpCloudRawFetch` uses.
|
|
3
|
+
* `makeFakeAtomic()` gives a fresh, isolated store (per-suite use via `setWpCloudFakeFetch`);
|
|
4
|
+
* `defaultFakeFetch` is a process-global instance for env-driven `WP_CLOUD_PROVIDER_MODE=fake`.
|
|
5
|
+
*/
|
|
6
|
+
import { randomInt } from "node:crypto";
|
|
1
7
|
import { routeFakeRequest } from "./router.js";
|
|
2
8
|
import { FakeAtomicStore } from "./store.js";
|
|
3
9
|
/** Decode an `application/x-www-form-urlencoded` body, un-nesting `key[child]` / `key[]` keys. */
|
|
@@ -48,8 +54,8 @@ async function readBody(input, init) {
|
|
|
48
54
|
* effect, not that a mock was called) — e.g. crontab registration, aliases,
|
|
49
55
|
* persistent data.
|
|
50
56
|
*/
|
|
51
|
-
export function makeFakeAtomicWithStore() {
|
|
52
|
-
const store = new FakeAtomicStore();
|
|
57
|
+
export function makeFakeAtomicWithStore(options = {}) {
|
|
58
|
+
const store = new FakeAtomicStore(options);
|
|
53
59
|
const fetch = async (input, init) => {
|
|
54
60
|
const rawUrl = input instanceof Request ? input.url : String(input);
|
|
55
61
|
const url = new URL(rawUrl);
|
|
@@ -65,8 +71,18 @@ export function makeFakeAtomicWithStore() {
|
|
|
65
71
|
};
|
|
66
72
|
return { fetch, store };
|
|
67
73
|
}
|
|
68
|
-
export function makeFakeAtomic() {
|
|
69
|
-
return makeFakeAtomicWithStore().fetch;
|
|
74
|
+
export function makeFakeAtomic(options = {}) {
|
|
75
|
+
return makeFakeAtomicWithStore(options).fetch;
|
|
70
76
|
}
|
|
71
|
-
/**
|
|
72
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Process-global fake for `WP_CLOUD_PROVIDER_MODE=fake` (no per-suite override
|
|
79
|
+
* installed). The site sequence starts at a per-process random offset: several
|
|
80
|
+
* processes can share one database in fake mode (the e2e seed script on the
|
|
81
|
+
* host, the control-plane container) and each runs its own store — with a
|
|
82
|
+
* fixed base every process mints atomic_site_id 151000001 first and collides
|
|
83
|
+
* on the DB's unique provider_ref index. Per-suite `makeFakeAtomic()` stores
|
|
84
|
+
* keep the deterministic default.
|
|
85
|
+
*/
|
|
86
|
+
export const defaultFakeFetch = makeFakeAtomic({
|
|
87
|
+
siteSequenceStart: 151_000_000 + randomInt(0, 800_000) * 1_000,
|
|
88
|
+
});
|
package/dist/fake/store.d.ts
CHANGED
package/dist/fake/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/fake/store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,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EAAE,MAAM,CAAC,GAAG,IAAI;IAMzD;8FAC0F;IAC1F,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA0BlD,oDAAoD;IACpD,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE;QAAE,WAAW,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOtF"}
|
package/dist/fake/store.js
CHANGED
|
@@ -14,9 +14,12 @@ export class FakeAtomicStore {
|
|
|
14
14
|
clientMeta = new Map();
|
|
15
15
|
metricsResponses = new Map();
|
|
16
16
|
metricRequestLog = [];
|
|
17
|
-
siteSeq
|
|
17
|
+
siteSeq;
|
|
18
18
|
jobSeq = 154_000_000;
|
|
19
19
|
cronSeq = 900_000;
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
this.siteSeq = options.siteSequenceStart ?? 151_000_000;
|
|
22
|
+
}
|
|
20
23
|
datacenters() {
|
|
21
24
|
return [...DATACENTERS];
|
|
22
25
|
}
|