@nestm/storage 0.1.0-alpha.1 → 0.1.0-alpha.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +257 -0
  2. package/README.md +724 -25
  3. package/SECURITY.md +101 -0
  4. package/dist/ai-sdk/ai-sdk-workspace-tools.d.ts +91 -0
  5. package/dist/ai-sdk/ai-sdk-workspace-tools.d.ts.map +1 -0
  6. package/dist/ai-sdk/ai-sdk-workspace-tools.js +491 -0
  7. package/dist/ai-sdk/ai-sdk-workspace-tools.js.map +1 -0
  8. package/dist/ai-sdk/index.d.ts +2 -0
  9. package/dist/ai-sdk/index.d.ts.map +1 -0
  10. package/dist/ai-sdk/index.js +2 -0
  11. package/dist/ai-sdk/index.js.map +1 -0
  12. package/dist/core/index.d.ts +6 -0
  13. package/dist/core/index.d.ts.map +1 -0
  14. package/dist/core/index.js +4 -0
  15. package/dist/core/index.js.map +1 -0
  16. package/dist/files-sdk/files-sdk.driver.d.ts +85 -3
  17. package/dist/files-sdk/files-sdk.driver.d.ts.map +1 -1
  18. package/dist/files-sdk/files-sdk.driver.js +1437 -37
  19. package/dist/files-sdk/files-sdk.driver.js.map +1 -1
  20. package/dist/files-sdk/fs/index.d.ts +42 -0
  21. package/dist/files-sdk/fs/index.d.ts.map +1 -0
  22. package/dist/files-sdk/fs/index.js +1117 -0
  23. package/dist/files-sdk/fs/index.js.map +1 -0
  24. package/dist/files-sdk/index.d.ts +1 -1
  25. package/dist/files-sdk/index.d.ts.map +1 -1
  26. package/dist/files-sdk/index.js.map +1 -1
  27. package/dist/files-sdk/provider/index.d.ts +58 -0
  28. package/dist/files-sdk/provider/index.d.ts.map +1 -0
  29. package/dist/files-sdk/provider/index.js +147 -0
  30. package/dist/files-sdk/provider/index.js.map +1 -0
  31. package/dist/files-sdk/s3/construction-metadata.d.ts +9 -0
  32. package/dist/files-sdk/s3/construction-metadata.d.ts.map +1 -0
  33. package/dist/files-sdk/s3/construction-metadata.js +24 -0
  34. package/dist/files-sdk/s3/construction-metadata.js.map +1 -0
  35. package/dist/files-sdk/s3/index.d.ts +54 -0
  36. package/dist/files-sdk/s3/index.d.ts.map +1 -0
  37. package/dist/files-sdk/s3/index.js +1505 -0
  38. package/dist/files-sdk/s3/index.js.map +1 -0
  39. package/dist/gateway/index.d.ts +1 -1
  40. package/dist/gateway/index.d.ts.map +1 -1
  41. package/dist/gateway/index.js.map +1 -1
  42. package/dist/gateway/storage-gateway-fastify-parser.d.ts.map +1 -1
  43. package/dist/gateway/storage-gateway-fastify-parser.js.map +1 -1
  44. package/dist/gateway/storage-gateway.controller.d.ts +12 -11
  45. package/dist/gateway/storage-gateway.controller.d.ts.map +1 -1
  46. package/dist/gateway/storage-gateway.controller.js +240 -70
  47. package/dist/gateway/storage-gateway.controller.js.map +1 -1
  48. package/dist/gateway/storage-gateway.guard.d.ts.map +1 -1
  49. package/dist/gateway/storage-gateway.guard.js.map +1 -1
  50. package/dist/gateway/storage-gateway.module.d.ts.map +1 -1
  51. package/dist/gateway/storage-gateway.module.js +60 -1
  52. package/dist/gateway/storage-gateway.module.js.map +1 -1
  53. package/dist/gateway/storage-gateway.tokens.d.ts +1 -0
  54. package/dist/gateway/storage-gateway.tokens.d.ts.map +1 -1
  55. package/dist/gateway/storage-gateway.tokens.js +1 -0
  56. package/dist/gateway/storage-gateway.tokens.js.map +1 -1
  57. package/dist/gateway/storage-gateway.types.d.ts +53 -10
  58. package/dist/gateway/storage-gateway.types.d.ts.map +1 -1
  59. package/dist/gateway/storage-gateway.types.js.map +1 -1
  60. package/dist/index.d.ts +1 -5
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +1 -3
  63. package/dist/index.js.map +1 -1
  64. package/dist/inject-storage.decorator.js.map +1 -1
  65. package/dist/storage-etag.d.ts +13 -0
  66. package/dist/storage-etag.d.ts.map +1 -0
  67. package/dist/storage-etag.js +31 -0
  68. package/dist/storage-etag.js.map +1 -0
  69. package/dist/storage-upload-control.d.ts.map +1 -1
  70. package/dist/storage.client.d.ts +15 -3
  71. package/dist/storage.client.d.ts.map +1 -1
  72. package/dist/storage.client.js +204 -2
  73. package/dist/storage.client.js.map +1 -1
  74. package/dist/storage.driver.d.ts +28 -1
  75. package/dist/storage.driver.d.ts.map +1 -1
  76. package/dist/storage.driver.js.map +1 -1
  77. package/dist/storage.error.d.ts +17 -10
  78. package/dist/storage.error.d.ts.map +1 -1
  79. package/dist/storage.error.js +47 -1
  80. package/dist/storage.error.js.map +1 -1
  81. package/dist/storage.module.d.ts.map +1 -1
  82. package/dist/storage.module.js.map +1 -1
  83. package/dist/storage.service.d.ts.map +1 -1
  84. package/dist/storage.service.js +28 -3
  85. package/dist/storage.service.js.map +1 -1
  86. package/dist/storage.tokens.js.map +1 -1
  87. package/dist/storage.types.d.ts +150 -1
  88. package/dist/storage.types.d.ts.map +1 -1
  89. package/dist/storage.types.js.map +1 -1
  90. package/dist/testing/index.d.ts +1 -0
  91. package/dist/testing/index.d.ts.map +1 -1
  92. package/dist/testing/index.js +1 -0
  93. package/dist/testing/index.js.map +1 -1
  94. package/dist/testing/provider-conformance.d.ts +65 -0
  95. package/dist/testing/provider-conformance.d.ts.map +1 -0
  96. package/dist/testing/provider-conformance.js +869 -0
  97. package/dist/testing/provider-conformance.js.map +1 -0
  98. package/dist/workspace/index.d.ts +5 -0
  99. package/dist/workspace/index.d.ts.map +1 -0
  100. package/dist/workspace/index.js +5 -0
  101. package/dist/workspace/index.js.map +1 -0
  102. package/dist/workspace/storage-workspace.cursor.d.ts +71 -0
  103. package/dist/workspace/storage-workspace.cursor.d.ts.map +1 -0
  104. package/dist/workspace/storage-workspace.cursor.js +408 -0
  105. package/dist/workspace/storage-workspace.cursor.js.map +1 -0
  106. package/dist/workspace/storage-workspace.d.ts +6 -0
  107. package/dist/workspace/storage-workspace.d.ts.map +1 -0
  108. package/dist/workspace/storage-workspace.error.d.ts +32 -0
  109. package/dist/workspace/storage-workspace.error.d.ts.map +1 -0
  110. package/dist/workspace/storage-workspace.error.js +75 -0
  111. package/dist/workspace/storage-workspace.error.js.map +1 -0
  112. package/dist/workspace/storage-workspace.js +849 -0
  113. package/dist/workspace/storage-workspace.js.map +1 -0
  114. package/dist/workspace/storage-workspace.path.d.ts +9 -0
  115. package/dist/workspace/storage-workspace.path.d.ts.map +1 -0
  116. package/dist/workspace/storage-workspace.path.js +68 -0
  117. package/dist/workspace/storage-workspace.path.js.map +1 -0
  118. package/dist/workspace/storage-workspace.types.d.ts +123 -0
  119. package/dist/workspace/storage-workspace.types.d.ts.map +1 -0
  120. package/dist/workspace/storage-workspace.types.js +22 -0
  121. package/dist/workspace/storage-workspace.types.js.map +1 -0
  122. package/package.json +90 -20
package/CHANGELOG.md CHANGED
@@ -1,5 +1,262 @@
1
1
  # @nestm/storage
2
2
 
3
+ ## 0.1.0-alpha.10
4
+
5
+ ### Minor Changes
6
+
7
+ - 0d6cf3c: Delegate conditional create, replace, exact ETag read, delete, and paired copy
8
+ to the Files SDK 2.3 operation pipeline so plugins, hooks, retries, and receipts
9
+ apply without bypassing native provider preconditions. Keep the direct NestM
10
+ fallback only for version predicates, conditional multipart/resumable
11
+ completion, and one-sided conditional copies, and fail those shapes closed when
12
+ caller Files policy is configured.
13
+
14
+ Expose paired-copy dependency flags in provider capabilities and preserve
15
+ `StorageError.applied` plus `appliedEtag` so callers can reconcile a conditional
16
+ mutation that committed before a post-operation failure. Preserve the same
17
+ bounded reconciliation signal through workspace, AI-tool, and gateway error
18
+ boundaries.
19
+
20
+ ### Patch Changes
21
+
22
+ - 0d6cf3c: Replace the NestJS 12 prerelease peer range and test matrix with the stable NestJS 12 line, and refresh the package toolchain and optional integration dependencies.
23
+
24
+ ## 0.1.0-alpha.9
25
+
26
+ ### Minor Changes
27
+
28
+ - aec25d6: Add explicit last-write-wins workspace write, copy, and unconditional-delete
29
+ operations that traverse the ordinary Files SDK plugin, hook, and receipt
30
+ pipeline while retaining the existing native conditional create, replace,
31
+ copy, move, and delete variants. Unconditional delete requires both `write` and
32
+ `delete`; move remains conditional-only because a non-atomic
33
+ download/upload/delete sequence could delete a newer source generation. Add a
34
+ separate `write` permission and an AI tool factory mutation-mode switch whose
35
+ default remains conditional.
36
+
37
+ Add bounded binary workspace reads through `readBytes`, alongside the existing
38
+ UTF-8 `readText` API. `readBytes` is a required `StorageWorkspace` member, so
39
+ custom interface implementations and typed test doubles must add it when
40
+ upgrading; workspaces returned by `mountStorageWorkspace` need no changes.
41
+
42
+ ### Patch Changes
43
+
44
+ - 37e0d8d: Fail conditional storage operations closed when caller-configured Files SDK
45
+ plugins, hooks, or receipts would be bypassed by native adapter extensions.
46
+ Ordinary operations continue through Files SDK while incompatible conditional
47
+ capabilities are hidden until Files SDK exposes one shared interception boundary.
48
+
49
+ ## 0.1.0-alpha.8
50
+
51
+ ### Minor Changes
52
+
53
+ - d81c6f4: Add a typed `mapCreateConflict` hook to the AI SDK workspace adapter so
54
+ applications can represent atomic create collisions as domain results without
55
+ mutating generated tools. Keep replace/ETag conflicts fail-closed and sanitize
56
+ mapper failures at the tool boundary.
57
+
58
+ Mark workspace tools with optional inputs or a combined create/replace union as
59
+ non-strict for provider schema generation while retaining strict Zod runtime
60
+ validation.
61
+
62
+ - a0ea392: Add injectable, replica-safe workspace pagination cursors. The workspace now
63
+ binds versioned cursor payloads to stable store, mount, tenant/workspace, prefix,
64
+ operation, query, limit, and expiry context; authorizes non-consuming replay
65
+ before that expiry; and rejects altered or cross-context continuations.
66
+ Successful continuation still depends on the embedded provider cursor remaining
67
+ valid and available.
68
+
69
+ Export an AES-256-GCM key-ring codec for stateless multi-replica deployments and
70
+ an asynchronous byte-payload codec contract for shared durable opaque-token
71
+ stores. Cursor payloads and tokens are bounded, provider continuations remain
72
+ opaque, and pagination fails closed when no cursor mechanism is configured.
73
+ Compatible replicas rely on the universal driver contract for non-consuming,
74
+ instance-portable provider cursors whose position is independent of page size
75
+ while the provider token remains valid. Cursor expiry is not a provider-token
76
+ retention, snapshot-isolation, or uptime promise; provider invalidation remains
77
+ an operational list failure.
78
+
79
+ - d996b92: Split the aggregate S3 conditional-mutation and copy declarations into exact
80
+ create, replace, delete, read, source-copy, destination-copy, atomic-promotion,
81
+ and multipart-completion capabilities. Add independent AWS S3, Cloudflare R2,
82
+ and fail-closed custom-endpoint profiles that force unverified drivers
83
+ read-only; enforce complete physical-key byte budgets; normalize provider
84
+ errors without retaining raw provider payloads or causes; and publish a reusable
85
+ provider conformance contract with gated filesystem, AWS, R2, and custom suites.
86
+
87
+ Normalize every provider ETag to a canonical bare 1–1024-byte visible ASCII
88
+ token and serialize exactly one HTTP quote pair at S3 request boundaries.
89
+ Quoted, weak, wildcard, list-shaped, control-bearing, non-ASCII, and otherwise
90
+ unsafe values now fail closed instead of being accepted as arbitrary non-empty
91
+ strings. Applications that persisted quoted ETags must refresh them from
92
+ provider metadata before conditional mutation; this prevents wildcard/list and
93
+ header-ambiguity inputs from widening an exact-match precondition.
94
+
95
+ Specify and test provider list cursors as non-consuming replayable tokens for
96
+ unchanged provider state, so higher-level replayable pagination can fail closed
97
+ when a provider cannot meet that contract.
98
+
99
+ Exercise the complete advertised source-condition by destination-condition
100
+ promotion matrix, including stale-state preservation and competing stale/valid
101
+ requests. Provider documentation or audited implementation evidence remains
102
+ required for the internal one-linearization-point claim.
103
+
104
+ Ordinary and conditional provider failures now expose stable public messages
105
+ and preserve only normalized codes and retry flags; raw provider bodies,
106
+ request metadata, and nested causes are not retained in loggable error shapes.
107
+
108
+ Raise the `@aws-sdk/client-s3` peer floor to 3.919.0, the first release that
109
+ serializes destination conditions for `CopyObject`, and verify the real wire
110
+ headers in the packed minimum-peer consumer. Native AWS construction now
111
+ disables environment and shared-config endpoint URL overrides, while the public
112
+ capability helper derives custom-endpoint provenance from the actual SDK client
113
+ instead of a duplicated caller hint. Capability decoration is now single-use
114
+ per raw S3 adapter, preventing broader operations from surviving a later
115
+ narrower profile application.
116
+
117
+ Bind S3 provider authority to package-private raw-client and adapter-method
118
+ identity plus the exact surface snapshot installed by capability decoration.
119
+ Structurally S3-backed raw adapters are rejected until they pass through the
120
+ package helper, regardless of adapter name, proxying, or forged global symbols;
121
+ same-client aliases cannot replace their raw client, ordinary methods, policies,
122
+ or conditional operations. Unverified custom endpoints and noncanonical
123
+ S3-backed provider slugs are forced read-only, while an explicit branded profile
124
+ unlocks only its declared conditional operations. Endpoint and public-URL
125
+ provenance now follows the adapter actually produced by the provider loader,
126
+ including `configJson`.
127
+
128
+ Retain `publicBaseUrl` construction policy in the package-owned `s3()` helper
129
+ so omitted decorator hints cannot re-enable an expiring-download claim. Unknown
130
+ foreign S3 construction conservatively disables that claim. Validate the exact
131
+ physical adapter key without stripping leading slashes, and include configured
132
+ separators plus list/search-derived prefixes in the provider byte budget before
133
+ dispatch. Search uses files-sdk's own inferred glob-prefix and zero-result
134
+ semantics instead of duplicating its matcher logic. The innermost dispatch guard
135
+ repeats these checks after supported in-process plugins have transformed an
136
+ operation; adapters and plugins remain trusted code rather than a sandbox
137
+ boundary.
138
+
139
+ Derive signed-upload policy claims from the branded provider profile instead
140
+ of granting them to every S3-compatible endpoint. Native AWS proves content
141
+ type and POST size-range enforcement; Cloudflare R2 proves content type but not
142
+ POST form size ranges; omitted custom declarations normalize to false/false so
143
+ the gateway fails closed. Profile authority is backed by a package-private
144
+ WeakSet after deep freezing, so reflecting and copying the nominal brand symbol
145
+ cannot forge conformance evidence.
146
+
147
+ Treat the built-in AWS profile as an immutable ceiling for every SDK client
148
+ with native endpoint provenance, independent of mutable adapter display names.
149
+ Explicit profiles may narrow its operations, policy bits, and key limit but
150
+ cannot raise the 1,024-byte physical-key budget or add unsupported claims.
151
+
152
+ Enforce every requested signed-upload constraint at URL creation time.
153
+ Content-type-constrained PUT URLs now sign the `content-type` header; bounded
154
+ AWS uploads use exact POST MIME and byte-range conditions; unsupported profile
155
+ constraints and lower-only S3 ranges fail before signing. Bounded POST uploads
156
+ also reject physical keys ending in AWS's `${filename}` template so an exact
157
+ authorized key cannot be widened into a prefix policy.
158
+
159
+ ## 0.1.0-alpha.7
160
+
161
+ ### Minor Changes
162
+
163
+ - 842ff34: Add a backend-neutral `StorageWorkspace` capability and optional AI SDK 7 tool
164
+ adapter. Workspaces expose only canonical mount-relative paths, enforce
165
+ permissions and resource limits, hide provider coordinates and cursors, and use
166
+ atomic create/ETag mutation preconditions. S3 now advertises and implements the
167
+ conditional mutation primitives used by writable workspaces.
168
+
169
+ Harden local filesystem workspace reads and conditional mutations against
170
+ symlink aliases. Moves retain their create-only destination whenever source
171
+ deletion cannot be confirmed, avoiding data loss after provider or
172
+ post-operation hook ambiguity.
173
+
174
+ Fix cross-store sync so `destinationPrefix` is applied to uploaded keys as well
175
+ as pruning, keeping every mutation inside the selected destination scope.
176
+
177
+ ## 0.1.0-alpha.6
178
+
179
+ ### Minor Changes
180
+
181
+ - 5bb646e: Remove the product-specific artifact protocol, encryption codec, and Nest composition entry
182
+ points. `@nestm/storage` remains a generic storage library; applications should compose domain
183
+ protocols over its clients and provider drivers in their own packages.
184
+
185
+ ## 0.1.0-alpha.5
186
+
187
+ ### Minor Changes
188
+
189
+ - 227df5b: Add byte-compatible encrypted artifact storage through the
190
+ `@nestm/storage/artifacts` and `@nestm/storage/artifacts/nest` entry points.
191
+
192
+ The framework-neutral facade stores self-contained CAE1 AES-256-GCM envelopes,
193
+ binds ciphertext to its tenant, artifact, version, and path context, supports
194
+ local and AWS KMS key providers, and preserves authenticated content types,
195
+ bounded reads, versioned bundles, legacy migration reads, and encrypted generic
196
+ objects. The Nest entry point composes artifact and object adapters over two
197
+ named storage clients and clears cached data keys on shutdown.
198
+
199
+ The public protocol keeps the deployed filesystem and object-provider layouts,
200
+ reserves configurable ObjectStore namespaces from artifact ids, validates all
201
+ artifact/version paths, and bounds ZIP entry count and expansion before any
202
+ write. CAE1 now rejects unauthenticated empty content types and writer-side
203
+ oversized headers, KMS verifies the stored key id, DEK cache lifetimes are
204
+ capped at five minutes, filesystem `.ct` collisions are rejected, and sweepers
205
+ skip objects without trustworthy timestamps.
206
+
207
+ ## 0.1.0-alpha.4
208
+
209
+ ### Minor Changes
210
+
211
+ - 79ad3af: Add runtime provider selection and a package-owned filesystem driver.
212
+
213
+ `@nestm/storage/files-sdk/provider` builds a driver from a provider slug carried
214
+ as data — `createProviderStorageDriver({ provider: 's3' | 'gcs' | 'azure' | 'r2'
215
+ | 'fs' | … })` — importing that provider's adapter, and only that one, on
216
+ demand. A deployment now selects its store with an environment variable and
217
+ installs a single native SDK instead of the application hard-coding a driver per
218
+ backend. The same entry point exposes the provider catalog (`listStorageProviders`,
219
+ `getStorageProvider`, `listStorageProviderEnvVars`,
220
+ `listStorageProviderSecretEnvVars`, `isStorageProvider`) as pure data, so config
221
+ validation and health checks can read a provider's env contract without loading
222
+ an adapter. An unknown slug fails closed with `INVALID_ARGUMENT` before anything
223
+ is imported.
224
+
225
+ `@nestm/storage/files-sdk/fs` adds `createFsStorageDriver` for local filesystem
226
+ storage, mirroring the S3 factory. Its adapter reaches only `node:fs`, so it adds
227
+ no native SDK to an install.
228
+
229
+ `@nestm/storage/files-sdk/s3` additionally exports `withS3Capabilities`, which
230
+ applies S3's conditional-copy promotion and signed-policy declarations to an
231
+ adapter built by `s3(...)`. The provider factory uses it so the `s3` slug keeps
232
+ those capabilities without re-deriving `S3AdapterOptions` from flat config.
233
+ `EnhancedS3Adapter` is now `S3StorageAdapter`; the type was not previously
234
+ exported.
235
+
236
+ ## 0.1.0-alpha.3
237
+
238
+ ### Minor Changes
239
+
240
+ - b947634: Harden storage integration boundaries with cross-copy-safe `StorageError`
241
+ detection, a package-owned S3 driver factory, conditional staged-object
242
+ promotion, and a mandatory parsed key policy plus signed-transfer limits for
243
+ the optional HTTP gateway.
244
+
245
+ ### Patch Changes
246
+
247
+ - b947634: Map structurally branded `files-sdk` errors, including errors wrapped across
248
+ duplicate package copies, so missing objects retain the `NOT_FOUND` storage
249
+ error code.
250
+
251
+ ## 0.1.0-alpha.2
252
+
253
+ ### Minor Changes
254
+
255
+ - c4b54e7: Add a framework-neutral `@nestm/storage/core` entry point for the storage
256
+ client, driver contract, errors, operation types, and upload controls. NestJS
257
+ peers are now optional so non-Nest consumers can install and use the core API
258
+ without pulling in the framework.
259
+
3
260
  ## 0.1.0-alpha.1
4
261
 
5
262
  ### Minor Changes