@pi-r/aws-lib 0.6.0 → 0.6.1
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/index.js +16 -1
- package/package.json +1 -1
- package/types/index.d.ts +25 -3
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBucketKey = exports.checkBucketCannedACL = exports.setDatabaseEndpoint = exports.setEndpoint = exports.getPrivatePolicy = exports.getBucketPublicReadPolicy = exports.getPublicReadPolicy = exports.isDatabaseDefined = exports.isProviderChainDefined = exports.isSharedCredentialsDefined = exports.isEnvDefined = exports.isAccessDefined = void 0;
|
|
3
|
+
exports.getBucketKey = exports.formatDefaultRetention = exports.checkBucketCannedACL = exports.setDatabaseEndpoint = exports.setEndpoint = exports.getPrivatePolicy = exports.getBucketPublicReadPolicy = exports.getPublicReadPolicy = exports.isDatabaseDefined = exports.isProviderChainDefined = exports.isSharedCredentialsDefined = exports.isEnvDefined = exports.isAccessDefined = void 0;
|
|
4
4
|
const types_1 = require("@e-mc/types");
|
|
5
5
|
function isAccessDefined(credential) {
|
|
6
6
|
return !!(credential.accessKeyId && credential.secretAccessKey);
|
|
@@ -96,5 +96,20 @@ function checkBucketCannedACL(value) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
exports.checkBucketCannedACL = checkBucketCannedACL;
|
|
99
|
+
function formatDefaultRetention(retention) {
|
|
100
|
+
const { Years = 0, Days = 0, Mode } = retention;
|
|
101
|
+
const status = [];
|
|
102
|
+
if (Years > 0) {
|
|
103
|
+
status.push(Years.toString() + 'Y');
|
|
104
|
+
}
|
|
105
|
+
if (Days > 0) {
|
|
106
|
+
status.push(Days.toString() + 'D');
|
|
107
|
+
}
|
|
108
|
+
if (Mode) {
|
|
109
|
+
status.push(status.length ? `(${Mode})` : Mode);
|
|
110
|
+
}
|
|
111
|
+
return status.join(' ');
|
|
112
|
+
}
|
|
113
|
+
exports.formatDefaultRetention = formatDefaultRetention;
|
|
99
114
|
const getBucketKey = (credential, bucket, acl, service, sdk) => JSON.stringify(credential) + bucket + '_' + (acl || '') + service + sdk;
|
|
100
115
|
exports.getBucketKey = getBucketKey;
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { CloudDatabase } from '@e-mc/types/lib/cloud';
|
|
2
|
-
|
|
3
1
|
declare namespace AWS {
|
|
4
2
|
type BucketCannedACL = "authenticated-read" | "private" | "public-read" | "public-read-write";
|
|
5
3
|
type ObjectCannedACL = BucketCannedACL | "bucket-owner-full-control" | "bucket-owner-read";
|
|
@@ -65,18 +63,42 @@ declare namespace AWS {
|
|
|
65
63
|
protocol: string;
|
|
66
64
|
}
|
|
67
65
|
|
|
66
|
+
interface DefaultRetention {
|
|
67
|
+
/**
|
|
68
|
+
* @public
|
|
69
|
+
* <p>The default Object Lock retention mode you want to apply to new objects placed in the
|
|
70
|
+
* specified bucket. Must be used with either <code>Days</code> or <code>Years</code>.</p>
|
|
71
|
+
*/
|
|
72
|
+
Mode?: ObjectLockRetentionMode;
|
|
73
|
+
/**
|
|
74
|
+
* @public
|
|
75
|
+
* <p>The number of days that you want to specify for the default retention period. Must be
|
|
76
|
+
* used with <code>Mode</code>.</p>
|
|
77
|
+
*/
|
|
78
|
+
Days?: number;
|
|
79
|
+
/**
|
|
80
|
+
* @public
|
|
81
|
+
* <p>The number of years that you want to specify for the default retention period. Must be
|
|
82
|
+
* used with <code>Mode</code>.</p>
|
|
83
|
+
*/
|
|
84
|
+
Years?: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
68
87
|
type Provider<T> = () => Promise<T>;
|
|
88
|
+
type ObjectLockRetentionMode = "GOVERNANCE" | "COMPLIANCE" | string; // eslint-disable-line @typescript-eslint/no-redundant-type-constituents
|
|
69
89
|
|
|
70
90
|
function isAccessDefined(credential: AccessConfig): boolean;
|
|
71
91
|
function isEnvDefined(): boolean;
|
|
72
92
|
function isSharedCredentialsDefined(): boolean;
|
|
73
93
|
function isProviderChainDefined(): boolean;
|
|
74
|
-
function isDatabaseDefined(credential: unknown, data:
|
|
94
|
+
function isDatabaseDefined(credential: unknown, data: unknown): boolean;
|
|
75
95
|
function getPublicReadPolicy(bucket: string, authenticated?: boolean, write?: boolean): string;
|
|
76
96
|
function getBucketPublicReadPolicy(bucket: string): string;
|
|
77
97
|
function getPrivatePolicy(bucket: string): string;
|
|
78
98
|
function setDatabaseEndpoint(config: EndpointConfig, fallbackRegion?: string): void;
|
|
79
99
|
function setEndpoint(config: EndpointConfig, instance: string, fallbackRegion?: string): void;
|
|
100
|
+
function checkBucketCannedACL(value: unknown): Undef<BucketCannedACL>;
|
|
101
|
+
function formatDefaultRetention(retention: DefaultRetention): string;
|
|
80
102
|
function getBucketKey(credential: unknown, bucket: string, acl: string | undefined, service: string, sdk: string): string;
|
|
81
103
|
}
|
|
82
104
|
|