@pithy-sh/cloudflare 0.1.2 → 0.1.3
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/ai/aiManager.d.ts +99 -0
- package/dist/ai/aiManager.d.ts.map +1 -0
- package/dist/ai/aiManager.js +148 -0
- package/dist/ai/vectorizeManager.d.ts +67 -0
- package/dist/ai/vectorizeManager.d.ts.map +1 -0
- package/dist/ai/vectorizeManager.js +101 -0
- package/dist/ai/vectorizeProvisioner.d.ts +123 -0
- package/dist/ai/vectorizeProvisioner.d.ts.map +1 -0
- package/dist/ai/vectorizeProvisioner.js +195 -0
- package/dist/client/accounts.d.ts +48 -0
- package/dist/client/accounts.d.ts.map +1 -0
- package/dist/client/accounts.js +55 -0
- package/dist/client/clients.d.ts +122 -0
- package/dist/client/clients.d.ts.map +1 -0
- package/dist/client/clients.js +216 -0
- package/dist/client/errors.d.ts +73 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +98 -0
- package/dist/client/manager.d.ts +45 -0
- package/dist/client/manager.d.ts.map +1 -0
- package/dist/client/manager.js +51 -0
- package/dist/d1/d1Manager.d.ts +74 -0
- package/dist/d1/d1Manager.d.ts.map +1 -0
- package/dist/d1/d1Manager.js +128 -0
- package/dist/d1/d1PreparedStatement.d.ts +24 -0
- package/dist/d1/d1PreparedStatement.d.ts.map +1 -0
- package/dist/d1/d1PreparedStatement.js +91 -0
- package/dist/d1/d1Provisioner.d.ts +28 -0
- package/dist/d1/d1Provisioner.d.ts.map +1 -0
- package/dist/d1/d1Provisioner.js +67 -0
- package/dist/email/emailRoutingManager.d.ts +36 -0
- package/dist/email/emailRoutingManager.d.ts.map +1 -0
- package/dist/email/emailRoutingManager.js +124 -0
- package/dist/email/emailSendManager.d.ts +45 -0
- package/dist/email/emailSendManager.d.ts.map +1 -0
- package/dist/email/emailSendManager.js +52 -0
- package/dist/env/devVars.d.ts +65 -0
- package/dist/env/devVars.d.ts.map +1 -0
- package/dist/env/devVars.js +84 -0
- package/dist/hostnames/customHostnamesManager.d.ts +51 -0
- package/dist/hostnames/customHostnamesManager.d.ts.map +1 -0
- package/dist/hostnames/customHostnamesManager.js +84 -0
- package/dist/kv/kvManager.d.ts +76 -0
- package/dist/kv/kvManager.d.ts.map +1 -0
- package/dist/kv/kvManager.js +135 -0
- package/dist/kv/kvProvisioner.d.ts +28 -0
- package/dist/kv/kvProvisioner.d.ts.map +1 -0
- package/dist/kv/kvProvisioner.js +71 -0
- package/dist/media/assetSeeder.d.ts +31 -0
- package/dist/media/assetSeeder.d.ts.map +1 -0
- package/dist/media/assetSeeder.js +70 -0
- package/dist/media/imageManager.d.ts +34 -0
- package/dist/media/imageManager.d.ts.map +1 -0
- package/dist/media/imageManager.js +103 -0
- package/dist/media/ownership.d.ts +40 -0
- package/dist/media/ownership.d.ts.map +1 -0
- package/dist/media/ownership.js +46 -0
- package/dist/media/streamManager.d.ts +83 -0
- package/dist/media/streamManager.d.ts.map +1 -0
- package/dist/media/streamManager.js +145 -0
- package/dist/queue/queueManager.d.ts +84 -0
- package/dist/queue/queueManager.d.ts.map +1 -0
- package/dist/queue/queueManager.js +114 -0
- package/dist/r2/r2Credentials.d.ts +12 -0
- package/dist/r2/r2Credentials.d.ts.map +1 -0
- package/dist/r2/r2Credentials.js +13 -0
- package/dist/r2/r2Manager.d.ts +226 -0
- package/dist/r2/r2Manager.d.ts.map +1 -0
- package/dist/r2/r2Manager.js +405 -0
- package/dist/r2/r2Provisioner.d.ts +39 -0
- package/dist/r2/r2Provisioner.d.ts.map +1 -0
- package/dist/r2/r2Provisioner.js +86 -0
- package/dist/secrets/secretsStoreManager.d.ts +82 -0
- package/dist/secrets/secretsStoreManager.d.ts.map +1 -0
- package/dist/secrets/secretsStoreManager.js +147 -0
- package/dist/secrets/secretsStores.d.ts +47 -0
- package/dist/secrets/secretsStores.d.ts.map +1 -0
- package/dist/secrets/secretsStores.js +65 -0
- package/dist/test-utils/emailRoutingRules.d.ts +39 -0
- package/dist/test-utils/emailRoutingRules.d.ts.map +1 -0
- package/dist/test-utils/emailRoutingRules.js +89 -0
- package/dist/test-utils/fixtureReportSetup.d.ts +25 -0
- package/dist/test-utils/fixtureReportSetup.d.ts.map +1 -0
- package/dist/test-utils/fixtureReportSetup.js +30 -0
- package/dist/test-utils/fixtures.d.ts +224 -0
- package/dist/test-utils/fixtures.d.ts.map +1 -0
- package/dist/test-utils/fixtures.js +277 -0
- package/dist/test-utils/harness.d.ts +192 -0
- package/dist/test-utils/harness.d.ts.map +1 -0
- package/dist/test-utils/harness.js +351 -0
- package/dist/test-utils/inboundRecorder.d.ts +91 -0
- package/dist/test-utils/inboundRecorder.d.ts.map +1 -0
- package/dist/test-utils/inboundRecorder.js +141 -0
- package/dist/test-utils/integrationSetup.d.ts +22 -0
- package/dist/test-utils/integrationSetup.d.ts.map +1 -0
- package/dist/test-utils/integrationSetup.js +37 -0
- package/dist/test-utils/reap.d.ts +112 -0
- package/dist/test-utils/reap.d.ts.map +1 -0
- package/dist/test-utils/reap.js +185 -0
- package/dist/tokens/accountTokensManager.d.ts +157 -0
- package/dist/tokens/accountTokensManager.d.ts.map +1 -0
- package/dist/tokens/accountTokensManager.js +280 -0
- package/dist/tokens/permissions.d.ts +36 -0
- package/dist/tokens/permissions.d.ts.map +1 -0
- package/dist/tokens/permissions.js +50 -0
- package/dist/tokens/profiles.d.ts +102 -0
- package/dist/tokens/profiles.d.ts.map +1 -0
- package/dist/tokens/profiles.js +137 -0
- package/dist/turnstile/turnstileManager.d.ts +75 -0
- package/dist/turnstile/turnstileManager.d.ts.map +1 -0
- package/dist/turnstile/turnstileManager.js +138 -0
- package/dist/user/userManager.d.ts +36 -0
- package/dist/user/userManager.d.ts.map +1 -0
- package/dist/user/userManager.js +58 -0
- package/dist/workers/buildsManager.d.ts +116 -0
- package/dist/workers/buildsManager.d.ts.map +1 -0
- package/dist/workers/buildsManager.js +237 -0
- package/dist/workers/buildsTypes.d.ts +102 -0
- package/dist/workers/buildsTypes.d.ts.map +1 -0
- package/dist/workers/buildsTypes.js +87 -0
- package/dist/workers/workersBuildEvent.d.ts +64 -0
- package/dist/workers/workersBuildEvent.d.ts.map +1 -0
- package/dist/workers/workersBuildEvent.js +47 -0
- package/dist/workers/workersManager.d.ts +136 -0
- package/dist/workers/workersManager.d.ts.map +1 -0
- package/dist/workers/workersManager.js +312 -0
- package/dist/workers/workersProvisioner.d.ts +80 -0
- package/dist/workers/workersProvisioner.d.ts.map +1 -0
- package/dist/workers/workersProvisioner.js +106 -0
- package/dist/workflows/stepFailure.d.ts +180 -0
- package/dist/workflows/stepFailure.d.ts.map +1 -0
- package/dist/workflows/stepFailure.js +227 -0
- package/dist/workflows/workflowsClient.d.ts +87 -0
- package/dist/workflows/workflowsClient.d.ts.map +1 -0
- package/dist/workflows/workflowsClient.js +156 -0
- package/dist/zones/zonesManager.d.ts +50 -0
- package/dist/zones/zonesManager.d.ts.map +1 -0
- package/dist/zones/zonesManager.js +74 -0
- package/package.json +18 -9
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CloudflareManager } from "../client/manager";
|
|
3
|
+
/**
|
|
4
|
+
* The account's zones — the registrable domains a custom domain can attach to.
|
|
5
|
+
*
|
|
6
|
+
* **Nothing here listed zones before.** Every zone-scoped operation in this package takes a `zoneId` the
|
|
7
|
+
* caller already knows: `CloudflareCustomHostnamesManager` takes it as constructor config,
|
|
8
|
+
* `CloudflareEmailRoutingManager` takes it per method, `CloudflareWorkersManager.addRoute` takes it
|
|
9
|
+
* positionally — and `pithy email provision` makes a human paste one, telling them to "find it on the
|
|
10
|
+
* zone's Overview page". So the CLI never *discovered* a zone; it demanded one.
|
|
11
|
+
*
|
|
12
|
+
* That is what this exists to change. When `pithy init` and `pithy worker add` ask where a Worker will
|
|
13
|
+
* answer, offering the account's real zones means a typo fails at `init` with a list of what exists,
|
|
14
|
+
* rather than at `deploy` with a Cloudflare error to decode.
|
|
15
|
+
*
|
|
16
|
+
* Read-only, deliberately. Pithy attaches routes to zones and never creates, transfers, or deletes one —
|
|
17
|
+
* a zone is the adopter's relationship with their registrar, not a resource this toolset provisions. The
|
|
18
|
+
* scoped token needs only `Zone:Read`.
|
|
19
|
+
*/
|
|
20
|
+
/** One zone on the account. */
|
|
21
|
+
export declare const ZoneInfo: z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
status: z.ZodString;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export type ZoneInfo = z.output<typeof ZoneInfo>;
|
|
27
|
+
/** Read the account's zones. Never creates or deletes — a zone is the adopter's, not ours to provision. */
|
|
28
|
+
export declare class CloudflareZonesManager extends CloudflareManager {
|
|
29
|
+
getServiceType(): string;
|
|
30
|
+
/** Prove access by listing. A read, and never throws — the caller decides what an inaccessible account means. */
|
|
31
|
+
validateServiceAccess(): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Every zone on this account, name-sorted so a picker is stable between runs.
|
|
34
|
+
*
|
|
35
|
+
* Filtered to the account, because a user-bound token can see zones on accounts this project has
|
|
36
|
+
* nothing to do with — offering those would invite someone to attach a Worker to a zone that another
|
|
37
|
+
* account owns, which fails at deploy with an error that names neither problem.
|
|
38
|
+
*/
|
|
39
|
+
listZones(): Promise<ZoneInfo[]>;
|
|
40
|
+
/**
|
|
41
|
+
* The zone a hostname belongs to, or `null`.
|
|
42
|
+
*
|
|
43
|
+
* Matches the **longest** zone name that the hostname sits under, which is the only correct rule when
|
|
44
|
+
* an account holds both `example.com` and `eu.example.com`: `api.eu.example.com` belongs to the latter,
|
|
45
|
+
* and picking the first match would attach it to the wrong zone. A public-suffix guess is not used at
|
|
46
|
+
* all — a zone can itself be a subdomain, and the account's own list is the authority.
|
|
47
|
+
*/
|
|
48
|
+
findZoneForHostname(hostname: string): Promise<ZoneInfo | null>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=zonesManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zonesManager.d.ts","sourceRoot":"","sources":["../../src/zones/zonesManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AAEH,+BAA+B;AAC/B,eAAO,MAAM,QAAQ;;;;iBAc4F,CAAC;AAClH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEjD,2GAA2G;AAC3G,qBAAa,sBAAuB,SAAQ,iBAAiB;IAC3D,cAAc,IAAI,MAAM,CAEvB;IAED,iHAAiH;IAC3G,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC,CAO9C;IAED;;;;;;OAMG;IACG,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CASrC;IAED;;;;;;;OAOG;IACG,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAKpE;CACF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { cloudflareRequest } from "../client/errors.js";
|
|
2
|
+
import { CloudflareManager } from "../client/manager.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/zones/zonesManager.ts
|
|
5
|
+
/**
|
|
6
|
+
* The account's zones — the registrable domains a custom domain can attach to.
|
|
7
|
+
*
|
|
8
|
+
* **Nothing here listed zones before.** Every zone-scoped operation in this package takes a `zoneId` the
|
|
9
|
+
* caller already knows: `CloudflareCustomHostnamesManager` takes it as constructor config,
|
|
10
|
+
* `CloudflareEmailRoutingManager` takes it per method, `CloudflareWorkersManager.addRoute` takes it
|
|
11
|
+
* positionally — and `pithy email provision` makes a human paste one, telling them to "find it on the
|
|
12
|
+
* zone's Overview page". So the CLI never *discovered* a zone; it demanded one.
|
|
13
|
+
*
|
|
14
|
+
* That is what this exists to change. When `pithy init` and `pithy worker add` ask where a Worker will
|
|
15
|
+
* answer, offering the account's real zones means a typo fails at `init` with a list of what exists,
|
|
16
|
+
* rather than at `deploy` with a Cloudflare error to decode.
|
|
17
|
+
*
|
|
18
|
+
* Read-only, deliberately. Pithy attaches routes to zones and never creates, transfers, or deletes one —
|
|
19
|
+
* a zone is the adopter's relationship with their registrar, not a resource this toolset provisions. The
|
|
20
|
+
* scoped token needs only `Zone:Read`.
|
|
21
|
+
*/
|
|
22
|
+
/** One zone on the account. */
|
|
23
|
+
const ZoneInfo = z.object({
|
|
24
|
+
id: z.string().describe("The CF-assigned zone id, which every zone-scoped API call is addressed by."),
|
|
25
|
+
name: z.string().describe("The registrable domain, e.g. `example.com`. This is the value a Worker's `domains` declaration names as its `zone`, and what wrangler writes as `zone_name`."),
|
|
26
|
+
status: z.string().describe("The zone's lifecycle status — `active` once Cloudflare is serving it, otherwise `pending`, `initializing`, or `moved`. A non-active zone cannot carry a custom domain yet, so a picker shows it and says so rather than hiding it.")
|
|
27
|
+
}).describe("One Cloudflare zone: the registrable domain a custom domain can attach to, and whether it is live.");
|
|
28
|
+
/** Read the account's zones. Never creates or deletes — a zone is the adopter's, not ours to provision. */
|
|
29
|
+
var CloudflareZonesManager = class extends CloudflareManager {
|
|
30
|
+
getServiceType() {
|
|
31
|
+
return "Cloudflare Zones";
|
|
32
|
+
}
|
|
33
|
+
/** Prove access by listing. A read, and never throws — the caller decides what an inaccessible account means. */
|
|
34
|
+
async validateServiceAccess() {
|
|
35
|
+
try {
|
|
36
|
+
await this.listZones();
|
|
37
|
+
return true;
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Every zone on this account, name-sorted so a picker is stable between runs.
|
|
44
|
+
*
|
|
45
|
+
* Filtered to the account, because a user-bound token can see zones on accounts this project has
|
|
46
|
+
* nothing to do with — offering those would invite someone to attach a Worker to a zone that another
|
|
47
|
+
* account owns, which fails at deploy with an error that names neither problem.
|
|
48
|
+
*/
|
|
49
|
+
async listZones() {
|
|
50
|
+
return cloudflareRequest("list zones", async () => {
|
|
51
|
+
const zones = [];
|
|
52
|
+
for await (const zone of this.getClient().zones.list({ account: { id: this.accountId } })) {
|
|
53
|
+
const parsed = ZoneInfo.safeParse(zone);
|
|
54
|
+
if (parsed.success) zones.push(parsed.data);
|
|
55
|
+
}
|
|
56
|
+
return zones.sort((a, b) => a.name.localeCompare(b.name));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The zone a hostname belongs to, or `null`.
|
|
61
|
+
*
|
|
62
|
+
* Matches the **longest** zone name that the hostname sits under, which is the only correct rule when
|
|
63
|
+
* an account holds both `example.com` and `eu.example.com`: `api.eu.example.com` belongs to the latter,
|
|
64
|
+
* and picking the first match would attach it to the wrong zone. A public-suffix guess is not used at
|
|
65
|
+
* all — a zone can itself be a subdomain, and the account's own list is the authority.
|
|
66
|
+
*/
|
|
67
|
+
async findZoneForHostname(hostname) {
|
|
68
|
+
const candidates = (await this.listZones()).filter((zone) => hostname === zone.name || hostname.endsWith(`.${zone.name}`));
|
|
69
|
+
if (candidates.length === 0) return null;
|
|
70
|
+
return candidates.reduce((longest, zone) => zone.name.length > longest.name.length ? zone : longest);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
74
|
+
export { CloudflareZonesManager, ZoneInfo };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pithy-sh/cloudflare",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,18 +8,23 @@
|
|
|
8
8
|
"directory": "packages/cloudflare"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
+
"dist",
|
|
11
12
|
"src",
|
|
12
|
-
"!src/**/*.test.*"
|
|
13
|
+
"!src/**/*.test.*",
|
|
14
|
+
"!dist/**/*.test.*"
|
|
13
15
|
],
|
|
14
16
|
"type": "module",
|
|
15
17
|
"engines": {
|
|
16
18
|
"node": ">=22"
|
|
17
19
|
},
|
|
18
20
|
"exports": {
|
|
19
|
-
"./src/*":
|
|
21
|
+
"./src/*": {
|
|
22
|
+
"types": "./dist/*.d.ts",
|
|
23
|
+
"default": "./dist/*.js"
|
|
24
|
+
}
|
|
20
25
|
},
|
|
21
26
|
"scripts": {
|
|
22
|
-
"build": "tsc -p tsconfig.json
|
|
27
|
+
"build": "tsdown && tsc -p tsconfig.build.json",
|
|
23
28
|
"typecheck": "tsc -p tsconfig.json",
|
|
24
29
|
"test": "vitest run",
|
|
25
30
|
"test:node": "vitest run --project=node",
|
|
@@ -31,18 +36,22 @@
|
|
|
31
36
|
"@aws-sdk/client-s3": "^3.1111.0",
|
|
32
37
|
"@aws-sdk/s3-request-presigner": "^3.1111.0",
|
|
33
38
|
"@cloudflare/workers-types": "^5.20260729.1",
|
|
34
|
-
"@pithy-sh/core": "^0.1.
|
|
39
|
+
"@pithy-sh/core": "^0.1.3",
|
|
35
40
|
"cloudflare": "^7.0.0",
|
|
36
|
-
"js-base64": "^3.9.2"
|
|
37
|
-
"kysely": "^0.29.0",
|
|
38
|
-
"zod": "^4.0.0"
|
|
41
|
+
"js-base64": "^3.9.2"
|
|
39
42
|
},
|
|
40
43
|
"devDependencies": {
|
|
41
44
|
"@pithy-sh/tsconfig": "workspace:*",
|
|
42
45
|
"@types/node": "^22.15.0",
|
|
43
46
|
"@vitest/coverage-v8": "^4.1.0",
|
|
47
|
+
"kysely": "^0.29.0",
|
|
44
48
|
"kysely-d1": "^0.4.0",
|
|
49
|
+
"tsdown": "^0.23.0",
|
|
45
50
|
"typescript": "^7.0.2",
|
|
46
|
-
"vitest": "^4.1.0"
|
|
51
|
+
"vitest": "^4.1.0",
|
|
52
|
+
"zod": "^4.4.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"zod": "^4.4.0"
|
|
47
56
|
}
|
|
48
57
|
}
|