@constructive-io/bucket-provisioner 0.4.1 → 0.5.0

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.
@@ -93,6 +93,10 @@ export declare class BucketProvisioner {
93
93
  setPublicAccessBlock(bucketName: string, config: PublicAccessBlockConfig): Promise<void>;
94
94
  /**
95
95
  * Apply an S3 bucket policy.
96
+ *
97
+ * Gracefully skips if the S3-compatible backend does not support
98
+ * PutBucketPolicy — bucket policies are best-effort since not all
99
+ * providers implement this AWS-specific API.
96
100
  */
97
101
  setBucketPolicy(bucketName: string, policy: BucketPolicyDocument): Promise<void>;
98
102
  /**
@@ -112,10 +116,18 @@ export declare class BucketProvisioner {
112
116
  setCors(bucketName: string, rules: CorsRule[]): Promise<void>;
113
117
  /**
114
118
  * Enable versioning on an S3 bucket.
119
+ *
120
+ * Gracefully skips if the S3-compatible backend (e.g. MinIO edge-cicd)
121
+ * does not support PutBucketVersioning — versioning is best-effort
122
+ * since not all providers implement this API.
115
123
  */
116
124
  enableVersioning(bucketName: string): Promise<void>;
117
125
  /**
118
126
  * Set lifecycle rules on an S3 bucket.
127
+ *
128
+ * Gracefully skips if the S3-compatible backend (e.g. MinIO edge-cicd)
129
+ * does not support PutBucketLifecycleConfiguration — lifecycle rules
130
+ * are best-effort since not all providers implement this API.
119
131
  */
120
132
  setLifecycleRules(bucketName: string, rules: LifecycleRule[]): Promise<void>;
121
133
  /**
@@ -198,6 +198,10 @@ export class BucketProvisioner {
198
198
  }
199
199
  /**
200
200
  * Apply an S3 bucket policy.
201
+ *
202
+ * Gracefully skips if the S3-compatible backend does not support
203
+ * PutBucketPolicy — bucket policies are best-effort since not all
204
+ * providers implement this AWS-specific API.
201
205
  */
202
206
  async setBucketPolicy(bucketName, policy) {
203
207
  try {
@@ -207,6 +211,17 @@ export class BucketProvisioner {
207
211
  }));
208
212
  }
209
213
  catch (err) {
214
+ // Some S3-compatible backends don't fully support bucket policies.
215
+ // Treat XML parse errors or "not implemented" responses as non-fatal.
216
+ if (err.Code === 'XmlParseException' ||
217
+ err.name === 'XmlParseException' ||
218
+ err.Code === 'NotImplemented' ||
219
+ err.name === 'NotImplemented' ||
220
+ err.message?.includes('not well-formed') ||
221
+ err.message?.includes('not implemented') ||
222
+ err.message?.includes('policy')) {
223
+ return;
224
+ }
210
225
  throw new ProvisionerError('POLICY_FAILED', `Failed to set bucket policy on '${bucketName}': ${err.message}`, err);
211
226
  }
212
227
  }
@@ -275,6 +290,10 @@ export class BucketProvisioner {
275
290
  }
276
291
  /**
277
292
  * Enable versioning on an S3 bucket.
293
+ *
294
+ * Gracefully skips if the S3-compatible backend (e.g. MinIO edge-cicd)
295
+ * does not support PutBucketVersioning — versioning is best-effort
296
+ * since not all providers implement this API.
278
297
  */
279
298
  async enableVersioning(bucketName) {
280
299
  try {
@@ -284,11 +303,27 @@ export class BucketProvisioner {
284
303
  }));
285
304
  }
286
305
  catch (err) {
306
+ // Some S3-compatible backends (e.g. MinIO edge-cicd) don't support
307
+ // PutBucketVersioning. Treat XML parse errors or "not implemented"
308
+ // responses as non-fatal.
309
+ if (err.Code === 'XmlParseException' ||
310
+ err.name === 'XmlParseException' ||
311
+ err.Code === 'NotImplemented' ||
312
+ err.name === 'NotImplemented' ||
313
+ err.message?.includes('not well-formed') ||
314
+ err.message?.includes('not implemented') ||
315
+ err.message?.includes('VersioningConfiguration')) {
316
+ return;
317
+ }
287
318
  throw new ProvisionerError('VERSIONING_FAILED', `Failed to enable versioning on '${bucketName}': ${err.message}`, err);
288
319
  }
289
320
  }
290
321
  /**
291
322
  * Set lifecycle rules on an S3 bucket.
323
+ *
324
+ * Gracefully skips if the S3-compatible backend (e.g. MinIO edge-cicd)
325
+ * does not support PutBucketLifecycleConfiguration — lifecycle rules
326
+ * are best-effort since not all providers implement this API.
292
327
  */
293
328
  async setLifecycleRules(bucketName, rules) {
294
329
  try {
@@ -305,6 +340,22 @@ export class BucketProvisioner {
305
340
  }));
306
341
  }
307
342
  catch (err) {
343
+ // Some S3-compatible backends (e.g. MinIO edge-cicd) don't support
344
+ // PutBucketLifecycleConfiguration (may require Content-MD5 header
345
+ // the SDK doesn't send). Treat XML parse errors, "not implemented",
346
+ // or missing-header responses as non-fatal.
347
+ if (err.Code === 'XmlParseException' ||
348
+ err.name === 'XmlParseException' ||
349
+ err.Code === 'NotImplemented' ||
350
+ err.name === 'NotImplemented' ||
351
+ err.Code === 'MissingContentMD5' ||
352
+ err.name === 'MissingContentMD5' ||
353
+ err.message?.includes('not well-formed') ||
354
+ err.message?.includes('not implemented') ||
355
+ err.message?.includes('Content-Md5') ||
356
+ err.message?.includes('LifecycleConfiguration')) {
357
+ return;
358
+ }
308
359
  throw new ProvisionerError('LIFECYCLE_FAILED', `Failed to set lifecycle rules on '${bucketName}': ${err.message}`, err);
309
360
  }
310
361
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/bucket-provisioner",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "S3-compatible bucket provisioning library — create buckets, configure privacy policies, CORS, and access controls",
6
6
  "main": "index.js",
@@ -44,5 +44,5 @@
44
44
  "storage",
45
45
  "constructive"
46
46
  ],
47
- "gitHead": "a8ccaed4f3a7c6c82495241ee1581700db9dd2dd"
47
+ "gitHead": "4ec54068fedd13e6145808b8059121f4a1b3891d"
48
48
  }
package/provisioner.d.ts CHANGED
@@ -93,6 +93,10 @@ export declare class BucketProvisioner {
93
93
  setPublicAccessBlock(bucketName: string, config: PublicAccessBlockConfig): Promise<void>;
94
94
  /**
95
95
  * Apply an S3 bucket policy.
96
+ *
97
+ * Gracefully skips if the S3-compatible backend does not support
98
+ * PutBucketPolicy — bucket policies are best-effort since not all
99
+ * providers implement this AWS-specific API.
96
100
  */
97
101
  setBucketPolicy(bucketName: string, policy: BucketPolicyDocument): Promise<void>;
98
102
  /**
@@ -112,10 +116,18 @@ export declare class BucketProvisioner {
112
116
  setCors(bucketName: string, rules: CorsRule[]): Promise<void>;
113
117
  /**
114
118
  * Enable versioning on an S3 bucket.
119
+ *
120
+ * Gracefully skips if the S3-compatible backend (e.g. MinIO edge-cicd)
121
+ * does not support PutBucketVersioning — versioning is best-effort
122
+ * since not all providers implement this API.
115
123
  */
116
124
  enableVersioning(bucketName: string): Promise<void>;
117
125
  /**
118
126
  * Set lifecycle rules on an S3 bucket.
127
+ *
128
+ * Gracefully skips if the S3-compatible backend (e.g. MinIO edge-cicd)
129
+ * does not support PutBucketLifecycleConfiguration — lifecycle rules
130
+ * are best-effort since not all providers implement this API.
119
131
  */
120
132
  setLifecycleRules(bucketName: string, rules: LifecycleRule[]): Promise<void>;
121
133
  /**
package/provisioner.js CHANGED
@@ -201,6 +201,10 @@ class BucketProvisioner {
201
201
  }
202
202
  /**
203
203
  * Apply an S3 bucket policy.
204
+ *
205
+ * Gracefully skips if the S3-compatible backend does not support
206
+ * PutBucketPolicy — bucket policies are best-effort since not all
207
+ * providers implement this AWS-specific API.
204
208
  */
205
209
  async setBucketPolicy(bucketName, policy) {
206
210
  try {
@@ -210,6 +214,17 @@ class BucketProvisioner {
210
214
  }));
211
215
  }
212
216
  catch (err) {
217
+ // Some S3-compatible backends don't fully support bucket policies.
218
+ // Treat XML parse errors or "not implemented" responses as non-fatal.
219
+ if (err.Code === 'XmlParseException' ||
220
+ err.name === 'XmlParseException' ||
221
+ err.Code === 'NotImplemented' ||
222
+ err.name === 'NotImplemented' ||
223
+ err.message?.includes('not well-formed') ||
224
+ err.message?.includes('not implemented') ||
225
+ err.message?.includes('policy')) {
226
+ return;
227
+ }
213
228
  throw new types_1.ProvisionerError('POLICY_FAILED', `Failed to set bucket policy on '${bucketName}': ${err.message}`, err);
214
229
  }
215
230
  }
@@ -278,6 +293,10 @@ class BucketProvisioner {
278
293
  }
279
294
  /**
280
295
  * Enable versioning on an S3 bucket.
296
+ *
297
+ * Gracefully skips if the S3-compatible backend (e.g. MinIO edge-cicd)
298
+ * does not support PutBucketVersioning — versioning is best-effort
299
+ * since not all providers implement this API.
281
300
  */
282
301
  async enableVersioning(bucketName) {
283
302
  try {
@@ -287,11 +306,27 @@ class BucketProvisioner {
287
306
  }));
288
307
  }
289
308
  catch (err) {
309
+ // Some S3-compatible backends (e.g. MinIO edge-cicd) don't support
310
+ // PutBucketVersioning. Treat XML parse errors or "not implemented"
311
+ // responses as non-fatal.
312
+ if (err.Code === 'XmlParseException' ||
313
+ err.name === 'XmlParseException' ||
314
+ err.Code === 'NotImplemented' ||
315
+ err.name === 'NotImplemented' ||
316
+ err.message?.includes('not well-formed') ||
317
+ err.message?.includes('not implemented') ||
318
+ err.message?.includes('VersioningConfiguration')) {
319
+ return;
320
+ }
290
321
  throw new types_1.ProvisionerError('VERSIONING_FAILED', `Failed to enable versioning on '${bucketName}': ${err.message}`, err);
291
322
  }
292
323
  }
293
324
  /**
294
325
  * Set lifecycle rules on an S3 bucket.
326
+ *
327
+ * Gracefully skips if the S3-compatible backend (e.g. MinIO edge-cicd)
328
+ * does not support PutBucketLifecycleConfiguration — lifecycle rules
329
+ * are best-effort since not all providers implement this API.
295
330
  */
296
331
  async setLifecycleRules(bucketName, rules) {
297
332
  try {
@@ -308,6 +343,22 @@ class BucketProvisioner {
308
343
  }));
309
344
  }
310
345
  catch (err) {
346
+ // Some S3-compatible backends (e.g. MinIO edge-cicd) don't support
347
+ // PutBucketLifecycleConfiguration (may require Content-MD5 header
348
+ // the SDK doesn't send). Treat XML parse errors, "not implemented",
349
+ // or missing-header responses as non-fatal.
350
+ if (err.Code === 'XmlParseException' ||
351
+ err.name === 'XmlParseException' ||
352
+ err.Code === 'NotImplemented' ||
353
+ err.name === 'NotImplemented' ||
354
+ err.Code === 'MissingContentMD5' ||
355
+ err.name === 'MissingContentMD5' ||
356
+ err.message?.includes('not well-formed') ||
357
+ err.message?.includes('not implemented') ||
358
+ err.message?.includes('Content-Md5') ||
359
+ err.message?.includes('LifecycleConfiguration')) {
360
+ return;
361
+ }
311
362
  throw new types_1.ProvisionerError('LIFECYCLE_FAILED', `Failed to set lifecycle rules on '${bucketName}': ${err.message}`, err);
312
363
  }
313
364
  }