@pi-r/gcp 0.3.6 → 0.3.7
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/client/index.js +124 -117
- package/download/index.js +1 -1
- package/package.json +1 -1
- package/upload/index.js +1 -1
package/client/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProjectId = exports.createBucketRequest = exports.setPredefinedAcl = exports.setPublicRead = exports.executeBatchQuery = exports.executeQuery = exports.deleteObjectsV2 = exports.deleteObjects = exports.setBucketWebsite = exports.setBucketPolicy = exports.createBucketV2 = exports.createBucket = exports.createDatabaseClient = exports.createStorageClient = exports.validateDatabase = exports.validateStorage = exports.isFirebaseApp = void 0;
|
|
3
|
+
exports.CLOUD_UPLOAD_FROMDISK = exports.getProjectId = exports.createBucketRequest = exports.setPredefinedAcl = exports.setPublicRead = exports.executeBatchQuery = exports.executeQuery = exports.deleteObjectsV2 = exports.deleteObjects = exports.setBucketWebsite = exports.setBucketPolicy = exports.createBucketV2 = exports.createBucket = exports.createDatabaseClient = exports.createStorageClient = exports.validateDatabase = exports.validateStorage = exports.isFirebaseApp = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
+
const storage = require("@google-cloud/storage");
|
|
6
|
+
const firestore = require("@google-cloud/firestore");
|
|
5
7
|
const util_1 = require("@e-mc/cloud/util");
|
|
6
8
|
const types_1 = require("@e-mc/types");
|
|
7
9
|
const Module = require("@e-mc/module");
|
|
@@ -61,23 +63,29 @@ async function hasBucket(client) {
|
|
|
61
63
|
const [exists] = await client.exists().catch(err => isErrorConflict(err) ? [true] : [false]);
|
|
62
64
|
return exists;
|
|
63
65
|
}
|
|
64
|
-
function updatePredefinedAcl(acl, values, metadata) {
|
|
65
|
-
const { generation, userProject } = metadata;
|
|
66
|
+
function updatePredefinedAcl(acl, values, metadata = {}) {
|
|
66
67
|
const items = [];
|
|
68
|
+
let projectNumber;
|
|
69
|
+
if ('projectNumber' in metadata || 'defaultObjectAcl' in metadata) {
|
|
70
|
+
let defaultObjectAcl;
|
|
71
|
+
({ projectNumber, defaultObjectAcl } = metadata);
|
|
72
|
+
if (projectNumber === undefined && (0, types_1.isArray)(defaultObjectAcl)) {
|
|
73
|
+
const target = defaultObjectAcl.find(item => { var _a; return (_a = item.projectTeam) === null || _a === void 0 ? void 0 : _a.projectNumber; });
|
|
74
|
+
if (target !== undefined) {
|
|
75
|
+
projectNumber = target.projectTeam.projectNumber;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
67
79
|
for (const target of acl.default ? [acl, acl.default] : [acl]) {
|
|
68
80
|
items.push(...values.map(async (value) => {
|
|
69
|
-
var _a;
|
|
70
|
-
if (generation !== undefined) {
|
|
71
|
-
(_a = value.generation) !== null && _a !== void 0 ? _a : (value.generation = +generation);
|
|
72
|
-
}
|
|
73
|
-
if (userProject) {
|
|
74
|
-
value.userProject || (value.userProject = userProject);
|
|
75
|
-
}
|
|
76
81
|
const entity = await target.get({ entity: value.entity }).catch(() => null);
|
|
77
82
|
if (entity) {
|
|
78
83
|
return (0, types_1.isString)(value.role) ? target.update(value) : target.delete(value);
|
|
79
84
|
}
|
|
80
85
|
if ((0, types_1.isString)(value.role)) {
|
|
86
|
+
if (projectNumber !== undefined) {
|
|
87
|
+
value.userProject || (value.userProject = projectNumber.toString());
|
|
88
|
+
}
|
|
81
89
|
return target.add(value);
|
|
82
90
|
}
|
|
83
91
|
}));
|
|
@@ -100,8 +108,8 @@ function setUniformBucketLevel(bucket, enabled) {
|
|
|
100
108
|
const getFirebasePackageName = (credential) => credential.apiKey && credential.authDomain ? 'firebase' : 'firebase-admin';
|
|
101
109
|
const hasKeyFile = (credential) => !!(credential.keyFile || credential.keyFilename || process.env.GOOGLE_APPLICATION_CREDENTIALS);
|
|
102
110
|
const isErrorConflict = (err) => (err instanceof Error) && err.code === 409;
|
|
103
|
-
function isFirebaseApp(credential,
|
|
104
|
-
return !!(credential.apiKey && credential.authDomain && (
|
|
111
|
+
function isFirebaseApp(credential, store, admin) {
|
|
112
|
+
return !!(credential.apiKey && credential.authDomain && (store || credential.databaseURL) || credential.product === 'firebase' && process.env.GOOGLE_APPLICATION_CREDENTIALS) && (!admin || !credential.admin);
|
|
105
113
|
}
|
|
106
114
|
exports.isFirebaseApp = isFirebaseApp;
|
|
107
115
|
function validateStorage(credential) {
|
|
@@ -113,59 +121,60 @@ function validateDatabase(credential, data) {
|
|
|
113
121
|
}
|
|
114
122
|
exports.validateDatabase = validateDatabase;
|
|
115
123
|
function createStorageClient(credential, bucket) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
124
|
+
if (isFirebaseApp(credential, true)) {
|
|
125
|
+
let packageName = '';
|
|
126
|
+
try {
|
|
119
127
|
if (bucket) {
|
|
120
128
|
credential.storageBucket = bucket;
|
|
121
129
|
}
|
|
122
130
|
packageName = getFirebasePackageName(credential);
|
|
123
131
|
return getApp(credential, false);
|
|
124
132
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
catch (err) {
|
|
130
|
-
this.checkPackage(err, packageName, { passThrough: true });
|
|
131
|
-
throw err;
|
|
133
|
+
catch (err) {
|
|
134
|
+
this.checkPackage(err, packageName, { passThrough: true });
|
|
135
|
+
throw err;
|
|
136
|
+
}
|
|
132
137
|
}
|
|
138
|
+
credential.projectId || (credential.projectId = getProjectId(credential));
|
|
139
|
+
return new storage.Storage(credential);
|
|
133
140
|
}
|
|
134
141
|
exports.createStorageClient = createStorageClient;
|
|
135
142
|
function createDatabaseClient(credential, data) {
|
|
136
143
|
let packageName = '';
|
|
137
144
|
try {
|
|
138
|
-
|
|
145
|
+
let product, name, table;
|
|
146
|
+
if (data) {
|
|
147
|
+
({ product, name, table } = data);
|
|
148
|
+
}
|
|
139
149
|
if (product === 'firebase' || isFirebaseApp(credential)) {
|
|
140
150
|
packageName = getFirebasePackageName(credential);
|
|
141
151
|
return getApp(credential, true);
|
|
142
152
|
}
|
|
143
153
|
credential.projectId || (credential.projectId = getProjectId(credential));
|
|
144
154
|
if (data) {
|
|
145
|
-
if (product === 'spanner' || !product &&
|
|
155
|
+
if (product === 'spanner' || !product && name && data.database) {
|
|
146
156
|
const { Spanner } = require(packageName = '@google-cloud/spanner');
|
|
147
157
|
return new Spanner(credential);
|
|
148
158
|
}
|
|
149
|
-
if (product === 'bigtable' || !product &&
|
|
159
|
+
if (product === 'bigtable' || !product && name && table) {
|
|
150
160
|
const { Bigtable } = require(packageName = '@google-cloud/bigtable');
|
|
151
161
|
return new Bigtable(credential);
|
|
152
162
|
}
|
|
153
|
-
if (product === 'bigquery' || !product && !
|
|
163
|
+
if (product === 'bigquery' || !product && !table && typeof data.query === 'string') {
|
|
154
164
|
const { BigQuery } = require(packageName = '@google-cloud/bigquery');
|
|
155
165
|
return new BigQuery(credential);
|
|
156
166
|
}
|
|
157
|
-
if (product === 'datastore' || !product && !
|
|
167
|
+
if (product === 'datastore' || !product && !table && (data.keys || data.query)) {
|
|
158
168
|
const { Datastore } = require(packageName = '@google-cloud/datastore');
|
|
159
169
|
return new Datastore(credential);
|
|
160
170
|
}
|
|
161
171
|
}
|
|
162
|
-
const { Firestore } = require(packageName = '@google-cloud/firestore');
|
|
163
|
-
return new Firestore(credential);
|
|
164
172
|
}
|
|
165
173
|
catch (err) {
|
|
166
174
|
this.checkPackage(err, packageName, { passThrough: true });
|
|
167
175
|
throw err;
|
|
168
176
|
}
|
|
177
|
+
return new firestore.Firestore(credential);
|
|
169
178
|
}
|
|
170
179
|
exports.createDatabaseClient = createDatabaseClient;
|
|
171
180
|
async function createBucket(credential, bucket, publicRead, service = 'gcp') {
|
|
@@ -176,14 +185,14 @@ async function createBucketV2(credential, bucket, acl, options, service = 'gcp')
|
|
|
176
185
|
if (isFirebaseApp(credential, true, true)) {
|
|
177
186
|
return false;
|
|
178
187
|
}
|
|
179
|
-
const
|
|
180
|
-
if (await hasBucket(
|
|
188
|
+
const instance = createStorageClient.call(this, credential, bucket);
|
|
189
|
+
if (await hasBucket(instance.bucket(bucket))) {
|
|
181
190
|
if (acl) {
|
|
182
191
|
await setBucketPolicy.call(this, credential, bucket, { acl }, service);
|
|
183
192
|
}
|
|
184
193
|
return true;
|
|
185
194
|
}
|
|
186
|
-
return
|
|
195
|
+
return instance.createBucket(bucket, options)
|
|
187
196
|
.then(async ([target]) => {
|
|
188
197
|
this.formatMessage(64, service, ["Bucket created", bucket], '', { ...Cloud.LOG_CLOUD_COMMAND });
|
|
189
198
|
if (acl) {
|
|
@@ -207,7 +216,7 @@ async function setBucketPolicy(credential, bucket, options, service = 'gcp') {
|
|
|
207
216
|
}
|
|
208
217
|
const client = createStorageClient.call(this, credential, bucket).bucket(bucket);
|
|
209
218
|
if (!await hasBucket(client)) {
|
|
210
|
-
this.formatFail(64, service, ["Bucket does not exist", bucket], (0,
|
|
219
|
+
this.formatFail(64, service, ["Bucket does not exist", bucket], (0, types_1.errorMessage)(service, "Bucket does not exist"), { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
|
|
211
220
|
return false;
|
|
212
221
|
}
|
|
213
222
|
const errors = [];
|
|
@@ -218,7 +227,7 @@ async function setBucketPolicy(credential, bucket, options, service = 'gcp') {
|
|
|
218
227
|
case 'private':
|
|
219
228
|
case 'projectPrivate':
|
|
220
229
|
await client.makePrivate(options).catch(err => !isErrorConflict(err) && errors.push(err));
|
|
221
|
-
await setPredefinedAcl.call(this, client.acl, acl, client, '', (_a = options.bucket) === null || _a === void 0 ? void 0 : _a.metadata);
|
|
230
|
+
await setPredefinedAcl.call(this, client.acl, acl, client, '', (_a = options.bucket) === null || _a === void 0 ? void 0 : _a.metadata).catch(err => errors.push(err));
|
|
222
231
|
break;
|
|
223
232
|
case 'authenticatedRead':
|
|
224
233
|
await client.makePublic(options).catch(err => !isErrorConflict(err) && errors.push(err));
|
|
@@ -245,7 +254,7 @@ async function setBucketPolicy(credential, bucket, options, service = 'gcp') {
|
|
|
245
254
|
}
|
|
246
255
|
}
|
|
247
256
|
if (options.acl && (options.acl = options.acl.filter(user => (0, types_1.isString)(user.entity))).length) {
|
|
248
|
-
errors.push(...await updatePredefinedAcl(client.acl, options.acl, options));
|
|
257
|
+
errors.push(...await updatePredefinedAcl(client.acl, options.acl, options.metadata));
|
|
249
258
|
}
|
|
250
259
|
if (errors.length) {
|
|
251
260
|
this.formatFail(64, service, ["Unable to update bucket policy", bucket], errors[0], { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
|
|
@@ -260,11 +269,12 @@ function setBucketWebsite(credential, bucket, options, service = 'gcp') {
|
|
|
260
269
|
return Promise.resolve(false);
|
|
261
270
|
}
|
|
262
271
|
const website = {};
|
|
263
|
-
|
|
264
|
-
|
|
272
|
+
const { indexPage, errorPage } = options;
|
|
273
|
+
if ((0, types_1.isString)(indexPage)) {
|
|
274
|
+
website.mainPageSuffix = indexPage;
|
|
265
275
|
}
|
|
266
|
-
if ((0, types_1.isString)(
|
|
267
|
-
website.notFoundPage =
|
|
276
|
+
if ((0, types_1.isString)(errorPage)) {
|
|
277
|
+
website.notFoundPage = errorPage;
|
|
268
278
|
}
|
|
269
279
|
return createStorageClient.call(this, credential, bucket).bucket(bucket).setMetadata({ website })
|
|
270
280
|
.then(() => {
|
|
@@ -282,7 +292,7 @@ function deleteObjects(credential, Bucket, service) {
|
|
|
282
292
|
}
|
|
283
293
|
exports.deleteObjects = deleteObjects;
|
|
284
294
|
async function deleteObjectsV2(credential, bucket, recursive = true, service = 'gcp') {
|
|
285
|
-
const
|
|
295
|
+
const instance = createStorageClient.call(this, credential, bucket);
|
|
286
296
|
const errors = [];
|
|
287
297
|
let promise;
|
|
288
298
|
if (isFirebaseApp(credential, true, true)) {
|
|
@@ -290,7 +300,7 @@ async function deleteObjectsV2(credential, bucket, recursive = true, service = '
|
|
|
290
300
|
const files = [];
|
|
291
301
|
await (async function recurse(prefix) {
|
|
292
302
|
try {
|
|
293
|
-
const { items, prefixes } = await listAll(ref(
|
|
303
|
+
const { items, prefixes } = await listAll(ref(instance, prefix));
|
|
294
304
|
if (items.length) {
|
|
295
305
|
files.push(...items.map(value => value.fullPath));
|
|
296
306
|
}
|
|
@@ -305,11 +315,11 @@ async function deleteObjectsV2(credential, bucket, recursive = true, service = '
|
|
|
305
315
|
}
|
|
306
316
|
})('');
|
|
307
317
|
if (files.length) {
|
|
308
|
-
promise = Promise.allSettled(files.map(value => deleteObject(ref(
|
|
318
|
+
promise = Promise.allSettled(files.map(value => deleteObject(ref(instance, value))));
|
|
309
319
|
}
|
|
310
320
|
}
|
|
311
321
|
else {
|
|
312
|
-
const client =
|
|
322
|
+
const client = instance.bucket(bucket);
|
|
313
323
|
if (await hasBucket(client)) {
|
|
314
324
|
if (recursive) {
|
|
315
325
|
return client.deleteFiles({ force: true }).then(() => this.formatMessage(64, service, "Bucket emptied" + ' (recursive)', bucket, { ...Cloud.LOG_CLOUD_COMMAND }));
|
|
@@ -375,9 +385,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
375
385
|
};
|
|
376
386
|
const closeClient = () => {
|
|
377
387
|
const fs = clients[3];
|
|
378
|
-
|
|
379
|
-
fs.terminate();
|
|
380
|
-
}
|
|
388
|
+
fs === null || fs === void 0 ? void 0 : fs.terminate();
|
|
381
389
|
};
|
|
382
390
|
const getFamily = (data, row, family) => {
|
|
383
391
|
const familyData = data[family];
|
|
@@ -520,29 +528,30 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
520
528
|
if ((0, types_1.isArray)(orderBy)) {
|
|
521
529
|
const sort = require('@firebase/database');
|
|
522
530
|
for (const items of orderBy) {
|
|
523
|
-
if ((0, types_1.isArray)(items)) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
531
|
+
if (!(0, types_1.isArray)(items)) {
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
const method = items[0];
|
|
535
|
+
switch (method) {
|
|
536
|
+
case 'orderByChild':
|
|
537
|
+
constraints.push(sort.orderByChild(items[1]));
|
|
538
|
+
break;
|
|
539
|
+
case 'orderByKey':
|
|
540
|
+
case 'orderByValue':
|
|
541
|
+
case 'orderByPriority':
|
|
542
|
+
constraints.push(sort[method]());
|
|
543
|
+
break;
|
|
544
|
+
case 'limitToFirst':
|
|
545
|
+
case 'limitToLast':
|
|
546
|
+
constraints.push(sort[method](limiter = +items[1]));
|
|
547
|
+
break;
|
|
548
|
+
case 'startAt':
|
|
549
|
+
case 'startAfter':
|
|
550
|
+
case 'endAt':
|
|
551
|
+
case 'endBefore':
|
|
552
|
+
case 'equalTo':
|
|
553
|
+
constraints.push(sort[method](items[1], items[2]));
|
|
554
|
+
break;
|
|
546
555
|
}
|
|
547
556
|
}
|
|
548
557
|
}
|
|
@@ -588,21 +597,22 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
588
597
|
else {
|
|
589
598
|
const task = db.createQuery(item.kind);
|
|
590
599
|
for (const args of query) {
|
|
591
|
-
if ((0, types_1.isArray)(args)) {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
600
|
+
if (!(0, types_1.isArray)(args)) {
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
const method = args[0];
|
|
604
|
+
switch (method) {
|
|
605
|
+
case 'end':
|
|
606
|
+
case 'filter':
|
|
607
|
+
case 'groupBy':
|
|
608
|
+
case 'hasAncestor':
|
|
609
|
+
case 'limit':
|
|
610
|
+
case 'offset':
|
|
611
|
+
case 'order':
|
|
612
|
+
case 'select':
|
|
613
|
+
case 'start':
|
|
614
|
+
task[method].apply(task, args.slice(1));
|
|
615
|
+
break;
|
|
606
616
|
}
|
|
607
617
|
}
|
|
608
618
|
if (limit > 0) {
|
|
@@ -643,23 +653,24 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
643
653
|
}
|
|
644
654
|
let db = createClient(item, 3).collection(table);
|
|
645
655
|
for (const args of query) {
|
|
646
|
-
if ((0, types_1.isArray)(args)) {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
656
|
+
if (!(0, types_1.isArray)(args)) {
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
const method = args[0];
|
|
660
|
+
switch (method) {
|
|
661
|
+
case 'endAt':
|
|
662
|
+
case 'endBefore':
|
|
663
|
+
case 'limit':
|
|
664
|
+
case 'limitToLast':
|
|
665
|
+
case 'offset':
|
|
666
|
+
case 'orderBy':
|
|
667
|
+
case 'select':
|
|
668
|
+
case 'startAfter':
|
|
669
|
+
case 'startAt':
|
|
670
|
+
case 'where':
|
|
671
|
+
case 'withConverter':
|
|
672
|
+
db = db[method].apply(db, args.slice(1));
|
|
673
|
+
break;
|
|
663
674
|
}
|
|
664
675
|
}
|
|
665
676
|
if ((0, types_1.isArray)(orderBy)) {
|
|
@@ -725,25 +736,19 @@ async function setPredefinedAcl(target, value, bucket, pathname = '', metadata =
|
|
|
725
736
|
items = [];
|
|
726
737
|
}
|
|
727
738
|
else {
|
|
728
|
-
|
|
729
|
-
const [users] = await bucket.acl.get().catch(() => [[]]);
|
|
730
|
-
acl = Array.isArray(users) ? users : [users];
|
|
731
|
-
}
|
|
732
|
-
else {
|
|
733
|
-
acl = [];
|
|
734
|
-
}
|
|
739
|
+
acl = bucket ? [(await bucket.acl.get())[1]] : [];
|
|
735
740
|
items = [{ entity: 'allUsers' }, { entity: 'allAuthenticatedUsers' }];
|
|
736
741
|
}
|
|
737
742
|
switch (value) {
|
|
738
743
|
case 'private': {
|
|
739
|
-
const owners = new Set(acl.filter(item => item.role === 'OWNER').map(item => item.entity));
|
|
744
|
+
const owners = new Set(acl.filter(item => item.role === 'OWNER' && item.entity).map(item => item.entity));
|
|
740
745
|
if (owner) {
|
|
741
746
|
owners.add(owner);
|
|
742
747
|
}
|
|
743
748
|
if (owners.size) {
|
|
744
749
|
for (const user of acl) {
|
|
745
750
|
const entity = user.entity;
|
|
746
|
-
if (!owners.has(entity)) {
|
|
751
|
+
if (entity && !owners.has(entity)) {
|
|
747
752
|
items.push({ entity });
|
|
748
753
|
}
|
|
749
754
|
}
|
|
@@ -753,19 +758,18 @@ async function setPredefinedAcl(target, value, bucket, pathname = '', metadata =
|
|
|
753
758
|
case 'projectPrivate':
|
|
754
759
|
for (const user of acl) {
|
|
755
760
|
const entity = user.entity;
|
|
756
|
-
if (entity
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
else {
|
|
760
|
-
items.push({ ...user, role: undefined });
|
|
761
|
+
if (entity) {
|
|
762
|
+
const role = entity.startsWith('project-') ? entity.startsWith('project-editors-') || entity.startsWith('project-owners-') ? 'OWNER' : 'READER' : '';
|
|
763
|
+
items.push({ entity, role });
|
|
761
764
|
}
|
|
762
765
|
}
|
|
763
766
|
break;
|
|
764
767
|
case 'bucketOwnerRead':
|
|
765
768
|
if (bucket && owner) {
|
|
766
769
|
for (const user of acl) {
|
|
767
|
-
|
|
768
|
-
|
|
770
|
+
const entity = user.entity;
|
|
771
|
+
if (entity && entity !== owner) {
|
|
772
|
+
items.push({ entity, role: 'READER' });
|
|
769
773
|
}
|
|
770
774
|
}
|
|
771
775
|
}
|
|
@@ -794,10 +798,12 @@ function createBucketRequest(credential) {
|
|
|
794
798
|
for (const attr in credential) {
|
|
795
799
|
switch (attr) {
|
|
796
800
|
case 'archive':
|
|
801
|
+
case 'autoclass':
|
|
797
802
|
case 'coldline':
|
|
798
803
|
case 'cors':
|
|
799
804
|
case 'customPlacementConfig':
|
|
800
805
|
case 'dra':
|
|
806
|
+
case 'enableObjectRetention':
|
|
801
807
|
case 'location':
|
|
802
808
|
case 'multiRegional':
|
|
803
809
|
case 'nearline':
|
|
@@ -831,3 +837,4 @@ function getProjectId(credential) {
|
|
|
831
837
|
return '';
|
|
832
838
|
}
|
|
833
839
|
exports.getProjectId = getProjectId;
|
|
840
|
+
exports.CLOUD_UPLOAD_FROMDISK = true;
|
package/download/index.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const https = require("https");
|
|
5
|
-
const client_1 = require("@pi-r/gcp");
|
|
6
5
|
const types_1 = require("@e-mc/types");
|
|
7
6
|
const Module = require("@e-mc/module");
|
|
8
7
|
const Cloud = require("@e-mc/cloud");
|
|
8
|
+
const client_1 = require("@pi-r/gcp");
|
|
9
9
|
function download(credential, service = 'gcp') {
|
|
10
10
|
const storage = client_1.createStorageClient.call(this, credential);
|
|
11
11
|
return (data, callback) => {
|
package/package.json
CHANGED
package/upload/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const fs = require("fs");
|
|
4
|
-
const client_1 = require("@pi-r/gcp");
|
|
5
4
|
const util_1 = require("@e-mc/cloud/util");
|
|
6
5
|
const types_1 = require("@e-mc/types");
|
|
7
6
|
const Module = require("@e-mc/module");
|
|
8
7
|
const Cloud = require("@e-mc/cloud");
|
|
8
|
+
const client_1 = require("@pi-r/gcp");
|
|
9
9
|
const BUCKET_SESSION = new Set();
|
|
10
10
|
const BUCKET_RESPONSE = {};
|
|
11
11
|
const getBucketKey = (credential, bucket, acl = '') => Module.asString(credential, true) + bucket + '_' + acl;
|