@pithy-sh/storage 0.1.5 → 0.1.6
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/provision/provisionStorage.d.ts +12 -3
- package/dist/provision/provisionStorage.d.ts.map +1 -1
- package/dist/provision/provisionStorage.js +12 -3
- package/dist/secret/registry.d.ts.map +1 -1
- package/dist/secret/registry.js +3 -3
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/package.json +4 -4
- package/pithy.manifest.json +1 -1
- package/src/provision/provisionStorage.ts +12 -3
- package/src/secret/registry.ts +11 -2
- package/src/version.generated.ts +1 -1
|
@@ -46,6 +46,14 @@ import { type ManagedEnvironment } from "@pithy-sh/secrets/src/scope";
|
|
|
46
46
|
* genuinely 3–63 lowercase characters, starting and ending alphanumeric. Every other namespace Pithy
|
|
47
47
|
* writes into was once held to that same 63 for no reason; asking for a bucket by name is how this one
|
|
48
48
|
* keeps it on purpose.
|
|
49
|
+
*
|
|
50
|
+
* **The `<thing>` segment is `storage`, and `packages/storage/pithy.manifest.json` now says so too**,
|
|
51
|
+
* with `"resource": "storage"` on the `STORAGE_BUCKET` binding (#519). Until it did, `pithy add` and
|
|
52
|
+
* `pithy provision` composed `<project>-<env>-storage-bucket` from the binding name while this composed
|
|
53
|
+
* `<project>-<env>-storage`: two names for one bucket, which is #513's defect in the two capabilities
|
|
54
|
+
* that issue left out. The binding keeps `_BUCKET` — it is read as `env.STORAGE_BUCKET` in a Worker —
|
|
55
|
+
* and the resource drops it, because `r2` is already the composed name's own kind.
|
|
56
|
+
* `cli/src/ci/bindingResourceNames.test.ts` holds this function and that manifest line to one string.
|
|
49
57
|
*/
|
|
50
58
|
export declare function storageBucketName(project: string, env: ManagedEnvironment): string;
|
|
51
59
|
/**
|
|
@@ -98,9 +106,10 @@ export interface StorageProvisionResult {
|
|
|
98
106
|
* completing one environment end to end before starting the next — means a failure creating prod's
|
|
99
107
|
* bucket stops the run before staging's worker is deployed against a half-provisioned account.
|
|
100
108
|
*
|
|
101
|
-
* `environments` is the
|
|
102
|
-
*
|
|
103
|
-
*
|
|
109
|
+
* `environments` is **what the caller determined it can act on**, which the CLI narrows from the project's
|
|
110
|
+
* declaration (#241) to the environments whose app database exists (pithy-sh/pithy#512). Nothing is
|
|
111
|
+
* skipped here and nothing decides here: an environment reaching this list is provisioned, and one that
|
|
112
|
+
* did not was already reported to the operator by name, with why and with the command that fixes it.
|
|
104
113
|
*/
|
|
105
114
|
export declare function provisionStorage(provisioner: StorageProvisioner, environments: DeclaredEnvironments | readonly string[]): Promise<StorageProvisionResult>;
|
|
106
115
|
/** The teardown seam — the inverse of {@link StorageProvisioner}. Every step idempotent. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provisionStorage.d.ts","sourceRoot":"","sources":["../../src/provision/provisionStorage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,EAAE,KAAK,kBAAkB,EAAuB,MAAM,6BAA6B,CAAC;AAG3F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH
|
|
1
|
+
{"version":3,"file":"provisionStorage.d.ts","sourceRoot":"","sources":["../../src/provision/provisionStorage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,EAAE,KAAK,kBAAkB,EAAuB,MAAM,6BAA6B,CAAC;AAG3F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAElF;AAED,iFAAiF;AAC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C,aAAa,EAAE,oBAAoB,EACnC,YAAY,EAAE,oBAAoB,GAAG,SAAS,MAAM,EAAE,EACtD,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,IAAI,CAAC,CASf"}
|
|
@@ -49,6 +49,14 @@ import { managedEnvironments } from "@pithy-sh/secrets/src/scope";
|
|
|
49
49
|
* genuinely 3–63 lowercase characters, starting and ending alphanumeric. Every other namespace Pithy
|
|
50
50
|
* writes into was once held to that same 63 for no reason; asking for a bucket by name is how this one
|
|
51
51
|
* keeps it on purpose.
|
|
52
|
+
*
|
|
53
|
+
* **The `<thing>` segment is `storage`, and `packages/storage/pithy.manifest.json` now says so too**,
|
|
54
|
+
* with `"resource": "storage"` on the `STORAGE_BUCKET` binding (#519). Until it did, `pithy add` and
|
|
55
|
+
* `pithy provision` composed `<project>-<env>-storage-bucket` from the binding name while this composed
|
|
56
|
+
* `<project>-<env>-storage`: two names for one bucket, which is #513's defect in the two capabilities
|
|
57
|
+
* that issue left out. The binding keeps `_BUCKET` — it is read as `env.STORAGE_BUCKET` in a Worker —
|
|
58
|
+
* and the resource drops it, because `r2` is already the composed name's own kind.
|
|
59
|
+
* `cli/src/ci/bindingResourceNames.test.ts` holds this function and that manifest line to one string.
|
|
52
60
|
*/
|
|
53
61
|
function storageBucketName(project, env) {
|
|
54
62
|
return resourceNames(project).env(env).r2(STORAGE_CAPABILITY);
|
|
@@ -71,9 +79,10 @@ function storageWorkerName(project, env) {
|
|
|
71
79
|
* completing one environment end to end before starting the next — means a failure creating prod's
|
|
72
80
|
* bucket stops the run before staging's worker is deployed against a half-provisioned account.
|
|
73
81
|
*
|
|
74
|
-
* `environments` is the
|
|
75
|
-
*
|
|
76
|
-
*
|
|
82
|
+
* `environments` is **what the caller determined it can act on**, which the CLI narrows from the project's
|
|
83
|
+
* declaration (#241) to the environments whose app database exists (pithy-sh/pithy#512). Nothing is
|
|
84
|
+
* skipped here and nothing decides here: an environment reaching this list is provisioned, and one that
|
|
85
|
+
* did not was already reported to the operator by name, with why and with the command that fixes it.
|
|
77
86
|
*/
|
|
78
87
|
async function provisionStorage(provisioner, environments) {
|
|
79
88
|
await provisioner.preflight();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/secret/registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE/F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;GAeG;AAEH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/secret/registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE/F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;GAeG;AAEH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;iBAkBmF,CAAC;AACrH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEzE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;OAQG;IACH,OAAO,EAAE,IAAI,CAAC;IACd,uEAAuE;IACvE,KAAK,EAAE,aAAa,CAAC;IACrB,uFAAuF;IACvF,SAAS,EAAE,KAAK,CAAC;IACjB,0FAA0F;IAC1F,SAAS,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,MAAM,EAAE,OAAO,oBAAoB,CAAC;IACpC,uFAAuF;IACvF,MAAM,EAAE,YAAY,CAAC;IACrB,qFAAqF;IACrF,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAmCD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAEpG;AAED,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAE1D,uGAAuG;AACvG,eAAO,MAAM,sBAAsB,sDAA2C,CAAC"}
|
package/dist/secret/registry.js
CHANGED
|
@@ -26,9 +26,9 @@ import { defineSecretRegistry } from "@pithy-sh/secrets/src/registry";
|
|
|
26
26
|
* to define, and `CloudflareR2Manager` validates its config against it.
|
|
27
27
|
*/
|
|
28
28
|
const R2StorageCredentials = R2Credentials.extend({
|
|
29
|
-
accountId: z.string().min(1).describe("The Cloudflare account id the bucket lives in — the S3 endpoint host."),
|
|
30
|
-
bucket: z.string().min(1).describe("The R2 bucket name every presigned URL and server-side object call targets."),
|
|
31
|
-
apiToken: z.string().min(1).describe("The R2-scoped Cloudflare API token the key pair was derived from. Carried alongside because an R2 S3 access key IS a CF API token — the id is the key id, the SHA-256 of the value is the secret — so whatever provisions the pair already holds it, and `CloudflareR2Manager` needs it to prove bucket access.")
|
|
29
|
+
accountId: z.string().min(1).meta({ multiline: false }).describe("The Cloudflare account id the bucket lives in — the S3 endpoint host."),
|
|
30
|
+
bucket: z.string().min(1).meta({ multiline: false }).describe("The R2 bucket name every presigned URL and server-side object call targets."),
|
|
31
|
+
apiToken: z.string().min(1).meta({ multiline: false }).describe("The R2-scoped Cloudflare API token the key pair was derived from. Carried alongside because an R2 S3 access key IS a CF API token — the id is the key id, the SHA-256 of the value is the secret — so whatever provisions the pair already holds it, and `CloudflareR2Manager` needs it to prove bucket access.")
|
|
32
32
|
}).describe("The account, key pair, scoped token, and bucket name the object store presigns and addresses R2 with.");
|
|
33
33
|
/**
|
|
34
34
|
* Where a human makes an R2 S3 access-key pair, and where the same human makes the next one.
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
/** This package's npm name — the join key against a release feed. */
|
|
4
4
|
export declare const PACKAGE_NAME = "@pithy-sh/storage";
|
|
5
5
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
6
|
-
export declare const PACKAGE_VERSION = "0.1.
|
|
6
|
+
export declare const PACKAGE_VERSION = "0.1.6";
|
|
7
7
|
//# sourceMappingURL=version.generated.d.ts.map
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
/** This package's npm name — the join key against a release feed. */
|
|
5
5
|
const PACKAGE_NAME = "@pithy-sh/storage";
|
|
6
6
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
7
|
-
const PACKAGE_VERSION = "0.1.
|
|
7
|
+
const PACKAGE_VERSION = "0.1.6";
|
|
8
8
|
//#endregion
|
|
9
9
|
export { PACKAGE_NAME, PACKAGE_VERSION };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pithy-sh/storage",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@cloudflare/workers-types": "^5.20260729.1",
|
|
39
39
|
"@hono/zod-validator": "^0.9.0",
|
|
40
|
-
"@pithy-sh/cloudflare": "^0.1.
|
|
41
|
-
"@pithy-sh/core": "^0.
|
|
42
|
-
"@pithy-sh/secrets": "^0.1.
|
|
40
|
+
"@pithy-sh/cloudflare": "^0.1.6",
|
|
41
|
+
"@pithy-sh/core": "^0.3.0",
|
|
42
|
+
"@pithy-sh/secrets": "^0.1.6"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@cloudflare/vitest-plugin": "^1.0.0",
|
package/pithy.manifest.json
CHANGED
|
@@ -52,6 +52,14 @@ import { STORAGE_CAPABILITY } from "../workflows/specs";
|
|
|
52
52
|
* genuinely 3–63 lowercase characters, starting and ending alphanumeric. Every other namespace Pithy
|
|
53
53
|
* writes into was once held to that same 63 for no reason; asking for a bucket by name is how this one
|
|
54
54
|
* keeps it on purpose.
|
|
55
|
+
*
|
|
56
|
+
* **The `<thing>` segment is `storage`, and `packages/storage/pithy.manifest.json` now says so too**,
|
|
57
|
+
* with `"resource": "storage"` on the `STORAGE_BUCKET` binding (#519). Until it did, `pithy add` and
|
|
58
|
+
* `pithy provision` composed `<project>-<env>-storage-bucket` from the binding name while this composed
|
|
59
|
+
* `<project>-<env>-storage`: two names for one bucket, which is #513's defect in the two capabilities
|
|
60
|
+
* that issue left out. The binding keeps `_BUCKET` — it is read as `env.STORAGE_BUCKET` in a Worker —
|
|
61
|
+
* and the resource drops it, because `r2` is already the composed name's own kind.
|
|
62
|
+
* `cli/src/ci/bindingResourceNames.test.ts` holds this function and that manifest line to one string.
|
|
55
63
|
*/
|
|
56
64
|
export function storageBucketName(project: string, env: ManagedEnvironment): string {
|
|
57
65
|
return resourceNames(project).env(env).r2(STORAGE_CAPABILITY);
|
|
@@ -109,9 +117,10 @@ export interface StorageProvisionResult {
|
|
|
109
117
|
* completing one environment end to end before starting the next — means a failure creating prod's
|
|
110
118
|
* bucket stops the run before staging's worker is deployed against a half-provisioned account.
|
|
111
119
|
*
|
|
112
|
-
* `environments` is the
|
|
113
|
-
*
|
|
114
|
-
*
|
|
120
|
+
* `environments` is **what the caller determined it can act on**, which the CLI narrows from the project's
|
|
121
|
+
* declaration (#241) to the environments whose app database exists (pithy-sh/pithy#512). Nothing is
|
|
122
|
+
* skipped here and nothing decides here: an environment reaching this list is provisioned, and one that
|
|
123
|
+
* did not was already reported to the operator by name, with why and with the command that fixes it.
|
|
115
124
|
*/
|
|
116
125
|
export async function provisionStorage(
|
|
117
126
|
provisioner: StorageProvisioner,
|
package/src/secret/registry.ts
CHANGED
|
@@ -29,11 +29,20 @@ import { z } from "zod";
|
|
|
29
29
|
* to define, and `CloudflareR2Manager` validates its config against it.
|
|
30
30
|
*/
|
|
31
31
|
export const R2StorageCredentials = R2Credentials.extend({
|
|
32
|
-
accountId: z
|
|
33
|
-
|
|
32
|
+
accountId: z
|
|
33
|
+
.string()
|
|
34
|
+
.min(1)
|
|
35
|
+
.meta({ multiline: false })
|
|
36
|
+
.describe("The Cloudflare account id the bucket lives in — the S3 endpoint host."),
|
|
37
|
+
bucket: z
|
|
38
|
+
.string()
|
|
39
|
+
.min(1)
|
|
40
|
+
.meta({ multiline: false })
|
|
41
|
+
.describe("The R2 bucket name every presigned URL and server-side object call targets."),
|
|
34
42
|
apiToken: z
|
|
35
43
|
.string()
|
|
36
44
|
.min(1)
|
|
45
|
+
.meta({ multiline: false })
|
|
37
46
|
.describe(
|
|
38
47
|
"The R2-scoped Cloudflare API token the key pair was derived from. Carried alongside because an R2 S3 access key IS a CF API token — the id is the key id, the SHA-256 of the value is the secret — so whatever provisions the pair already holds it, and `CloudflareR2Manager` needs it to prove bucket access.",
|
|
39
48
|
),
|
package/src/version.generated.ts
CHANGED