@pithy-sh/storage 0.2.3 → 0.2.4

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.
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
3
  import type { DeclaredEnvironments } from "@pithy-sh/core/src/naming/environment";
4
- import { type ManagedEnvironment } from "@pithy-sh/secrets/src/scope";
4
+ import { type DeprovisionTarget, type ManagedEnvironment } from "@pithy-sh/secrets/src/scope";
5
5
  /**
6
6
  * The provisioning orchestration for the storage capability — the live counterpart to
7
7
  * `pithy add storage`'s config wiring.
@@ -136,13 +136,16 @@ export interface StorageDeprovisionOptions {
136
136
  deleteStorage?: boolean;
137
137
  }
138
138
  /**
139
- * Tear down the storage infrastructure, reversing {@link provisionStorage}: delete every environment's
140
- * sweep worker first (they bind the bucket), then — only when `deleteStorage` is set — the buckets and
141
- * everything in them. Idempotent end to end.
139
+ * Tear down **one named environment's** storage infrastructure, reversing {@link provisionStorage} for it:
140
+ * its sweep worker first (it binds the bucket), then — only when `deleteStorage` is set — its bucket and
141
+ * everything in it. Idempotent end to end.
142
142
  *
143
- * `environments` is the project's declaration from the root `pithy.config.ts` (#241). Every declared
144
- * environment is provisioned; an environment this skipped would be one the project deploys to with no
145
- * resources behind it — the silence the closed `ManagedEnvironment` enum used to produce.
143
+ * The environment is resolved by `@pithy-sh/secrets`' {@link deprovisionTarget}, before anything is deleted:
144
+ * absent, or undeclared, it refuses and lists the project's set. This used to walk every declared environment,
145
+ * so `pithy storage deprovision --storage`, run to clear staging's uploads, emptied and deleted production's
146
+ * bucket with it (#591).
146
147
  */
147
- export declare function deprovisionStorage(deprovisioner: StorageDeprovisioner, environments: DeclaredEnvironments | readonly string[], options?: StorageDeprovisionOptions): Promise<void>;
148
+ export declare function deprovisionStorage(deprovisioner: StorageDeprovisioner, target: DeprovisionTarget, options?: StorageDeprovisionOptions): Promise<{
149
+ env: ManagedEnvironment;
150
+ }>;
148
151
  //# sourceMappingURL=provisionStorage.d.ts.map
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;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;AACjF,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,uEAAuE;AACvE,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,oFAAoF;IACpF,YAAY,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvE;;;;;OAKG;IACH,gBAAgB,CAAC,GAAG,EAAE,kBAAkB,EAAE,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtF,8FAA8F;IAC9F,YAAY,CAAC,GAAG,EAAE,kBAAkB,EAAE,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnF;AAED,mDAAmD;AACnD,MAAM,WAAW,sBAAsB;IACrC,4FAA4F;IAC5F,YAAY,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,kBAAkB,CAAA;KAAE,GAAG,gBAAgB,CAAC,CAAC;CACrE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,kBAAkB,EAC/B,YAAY,EAAE,oBAAoB,GAAG,SAAS,MAAM,EAAE,GACrD,OAAO,CAAC,sBAAsB,CAAC,CAiBjC;AASD,4FAA4F;AAC5F,MAAM,WAAW,oBAAoB;IACnC,wFAAwF;IACxF,YAAY,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD;;;;;;;;OAQG;IACH,YAAY,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD;AAED,qGAAqG;AACrG,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,aAAa,EAAE,oBAAoB,EACnC,YAAY,EAAE,oBAAoB,GAAG,SAAS,MAAM,EAAE,EACtD,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,IAAI,CAAC,CASf"}
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,EACL,KAAK,iBAAiB,EAEtB,KAAK,kBAAkB,EAExB,MAAM,6BAA6B,CAAC;AAGrC;;;;;;;;;;;;;;;;;;;;;;;;;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;AACjF,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AAa,EAAE,oBAAoB,EACnC,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC;IAAE,GAAG,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAKtC"}
@@ -3,7 +3,7 @@
3
3
  import { STORAGE_CAPABILITY } from "../workflows/specs.js";
4
4
  import { InternalError } from "@pithy-sh/core/src/error/pithyError";
5
5
  import { resourceNames } from "@pithy-sh/core/src/naming/resourceNames";
6
- import { managedEnvironments } from "@pithy-sh/secrets/src/scope";
6
+ import { deprovisionTarget, managedEnvironments } from "@pithy-sh/secrets/src/scope";
7
7
  //#region src/provision/provisionStorage.ts
8
8
  /**
9
9
  * The provisioning orchestration for the storage capability — the live counterpart to
@@ -105,17 +105,20 @@ function resourcesFor(resources, env) {
105
105
  return found;
106
106
  }
107
107
  /**
108
- * Tear down the storage infrastructure, reversing {@link provisionStorage}: delete every environment's
109
- * sweep worker first (they bind the bucket), then — only when `deleteStorage` is set — the buckets and
110
- * everything in them. Idempotent end to end.
108
+ * Tear down **one named environment's** storage infrastructure, reversing {@link provisionStorage} for it:
109
+ * its sweep worker first (it binds the bucket), then — only when `deleteStorage` is set — its bucket and
110
+ * everything in it. Idempotent end to end.
111
111
  *
112
- * `environments` is the project's declaration from the root `pithy.config.ts` (#241). Every declared
113
- * environment is provisioned; an environment this skipped would be one the project deploys to with no
114
- * resources behind it — the silence the closed `ManagedEnvironment` enum used to produce.
112
+ * The environment is resolved by `@pithy-sh/secrets`' {@link deprovisionTarget}, before anything is deleted:
113
+ * absent, or undeclared, it refuses and lists the project's set. This used to walk every declared environment,
114
+ * so `pithy storage deprovision --storage`, run to clear staging's uploads, emptied and deleted production's
115
+ * bucket with it (#591).
115
116
  */
116
- async function deprovisionStorage(deprovisioner, environments, options = {}) {
117
- for (const env of managedEnvironments(environments)) await deprovisioner.deleteWorker(env);
118
- if (options.deleteStorage) for (const env of managedEnvironments(environments)) await deprovisioner.deleteBucket(env);
117
+ async function deprovisionStorage(deprovisioner, target, options = {}) {
118
+ const env = deprovisionTarget(target);
119
+ await deprovisioner.deleteWorker(env);
120
+ if (options.deleteStorage) await deprovisioner.deleteBucket(env);
121
+ return { env };
119
122
  }
120
123
  //#endregion
121
124
  export { deprovisionStorage, provisionStorage, storageBucketName, storageWorkerName };
@@ -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.2.3";
6
+ export declare const PACKAGE_VERSION = "0.2.4";
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.2.3";
7
+ const PACKAGE_VERSION = "0.2.4";
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.2.3",
3
+ "version": "0.2.4",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,9 +39,9 @@
39
39
  "@hono/zod-validator": "^0.9.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "@pithy-sh/cloudflare": "^0.2.3",
43
- "@pithy-sh/core": "^0.6.1",
44
- "@pithy-sh/secrets": "^0.2.3",
42
+ "@pithy-sh/cloudflare": "^0.3.0",
43
+ "@pithy-sh/core": "^0.7.0",
44
+ "@pithy-sh/secrets": "^0.2.4",
45
45
  "hono": "^4.13.2",
46
46
  "kysely": "^0.29.0",
47
47
  "zod": "^4.4.0"
@@ -4,7 +4,12 @@
4
4
  import { InternalError } from "@pithy-sh/core/src/error/pithyError";
5
5
  import type { DeclaredEnvironments } from "@pithy-sh/core/src/naming/environment";
6
6
  import { resourceNames } from "@pithy-sh/core/src/naming/resourceNames";
7
- import { type ManagedEnvironment, managedEnvironments } from "@pithy-sh/secrets/src/scope";
7
+ import {
8
+ type DeprovisionTarget,
9
+ deprovisionTarget,
10
+ type ManagedEnvironment,
11
+ managedEnvironments,
12
+ } from "@pithy-sh/secrets/src/scope";
8
13
  import { STORAGE_CAPABILITY } from "../workflows/specs";
9
14
 
10
15
  /**
@@ -177,25 +182,22 @@ export interface StorageDeprovisionOptions {
177
182
  }
178
183
 
179
184
  /**
180
- * Tear down the storage infrastructure, reversing {@link provisionStorage}: delete every environment's
181
- * sweep worker first (they bind the bucket), then — only when `deleteStorage` is set — the buckets and
182
- * everything in them. Idempotent end to end.
185
+ * Tear down **one named environment's** storage infrastructure, reversing {@link provisionStorage} for it:
186
+ * its sweep worker first (it binds the bucket), then — only when `deleteStorage` is set — its bucket and
187
+ * everything in it. Idempotent end to end.
183
188
  *
184
- * `environments` is the project's declaration from the root `pithy.config.ts` (#241). Every declared
185
- * environment is provisioned; an environment this skipped would be one the project deploys to with no
186
- * resources behind it — the silence the closed `ManagedEnvironment` enum used to produce.
189
+ * The environment is resolved by `@pithy-sh/secrets`' {@link deprovisionTarget}, before anything is deleted:
190
+ * absent, or undeclared, it refuses and lists the project's set. This used to walk every declared environment,
191
+ * so `pithy storage deprovision --storage`, run to clear staging's uploads, emptied and deleted production's
192
+ * bucket with it (#591).
187
193
  */
188
194
  export async function deprovisionStorage(
189
195
  deprovisioner: StorageDeprovisioner,
190
- environments: DeclaredEnvironments | readonly string[],
196
+ target: DeprovisionTarget,
191
197
  options: StorageDeprovisionOptions = {},
192
- ): Promise<void> {
193
- for (const env of managedEnvironments(environments)) {
194
- await deprovisioner.deleteWorker(env);
195
- }
196
- if (options.deleteStorage) {
197
- for (const env of managedEnvironments(environments)) {
198
- await deprovisioner.deleteBucket(env);
199
- }
200
- }
198
+ ): Promise<{ env: ManagedEnvironment }> {
199
+ const env = deprovisionTarget(target);
200
+ await deprovisioner.deleteWorker(env);
201
+ if (options.deleteStorage) await deprovisioner.deleteBucket(env);
202
+ return { env };
201
203
  }
@@ -13,4 +13,4 @@
13
13
  export const PACKAGE_NAME = "@pithy-sh/storage";
14
14
 
15
15
  /** This package's version, stamped from its own package.json at generation time. */
16
- export const PACKAGE_VERSION = "0.2.3";
16
+ export const PACKAGE_VERSION = "0.2.4";