@webda/gcp 3.6.3 → 4.0.0-beta.2
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/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.spec.d.ts +1 -0
- package/lib/index.spec.d.ts.map +1 -0
- package/lib/services/firestore.d.ts +3 -1
- package/lib/services/firestore.d.ts.map +1 -0
- package/lib/services/firestore.js +11 -11
- package/lib/services/firestore.js.map +1 -1
- package/lib/services/firestore.spec.d.ts +1 -0
- package/lib/services/firestore.spec.d.ts.map +1 -0
- package/lib/services/firestore.spec.js +24 -30
- package/lib/services/firestore.spec.js.map +1 -1
- package/lib/services/index.d.ts +1 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/kms.d.ts +1 -0
- package/lib/services/kms.d.ts.map +1 -0
- package/lib/services/kms.spec.d.ts +1 -0
- package/lib/services/kms.spec.d.ts.map +1 -0
- package/lib/services/kms.spec.js +3 -3
- package/lib/services/kms.spec.js.map +1 -1
- package/lib/services/pubsub.d.ts +1 -0
- package/lib/services/pubsub.d.ts.map +1 -0
- package/lib/services/pubsub.js +1 -1
- package/lib/services/pubsub.js.map +1 -1
- package/lib/services/pubsub.spec.d.ts +1 -0
- package/lib/services/pubsub.spec.d.ts.map +1 -0
- package/lib/services/pubsub.spec.js +12 -4
- package/lib/services/pubsub.spec.js.map +1 -1
- package/lib/services/queue.d.ts +20 -3
- package/lib/services/queue.d.ts.map +1 -0
- package/lib/services/queue.js +71 -48
- package/lib/services/queue.js.map +1 -1
- package/lib/services/queue.spec.d.ts +1 -0
- package/lib/services/queue.spec.d.ts.map +1 -0
- package/lib/services/queue.spec.js +39 -25
- package/lib/services/queue.spec.js.map +1 -1
- package/lib/services/storage.d.ts +59 -3
- package/lib/services/storage.d.ts.map +1 -0
- package/lib/services/storage.js +92 -24
- package/lib/services/storage.js.map +1 -1
- package/lib/services/storage.spec.d.ts +1 -0
- package/lib/services/storage.spec.d.ts.map +1 -0
- package/lib/services/storage.spec.js +91 -61
- package/lib/services/storage.spec.js.map +1 -1
- package/package.json +17 -14
- package/webda.module.json +17 -104
|
@@ -6,73 +6,63 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Storage as GCS } from "@google-cloud/storage";
|
|
8
8
|
import { suite, test } from "@testdeck/mocha";
|
|
9
|
-
import { getCommonJS } from "@webda/core";
|
|
9
|
+
import { BinaryService, getCommonJS, RESTDomainService } from "@webda/core";
|
|
10
10
|
import { BinaryTest } from "@webda/core/lib/services/binary.spec.js";
|
|
11
11
|
import * as assert from "assert";
|
|
12
12
|
import * as path from "path";
|
|
13
13
|
import * as sinon from "sinon";
|
|
14
|
+
import { GCSFinder, Storage } from "./storage.js";
|
|
14
15
|
const { __dirname } = getCommonJS(import.meta.url);
|
|
15
|
-
class MockFile {
|
|
16
|
-
constructor(path) { }
|
|
17
|
-
async delete() { }
|
|
18
|
-
async getFiles() { }
|
|
19
|
-
async exists() { }
|
|
20
|
-
async save() { }
|
|
21
|
-
async setMetadata() { }
|
|
22
|
-
async createWriteStream() { }
|
|
23
|
-
async getSignedUrl() { }
|
|
24
|
-
async publicUrl() { }
|
|
25
|
-
async getMetadata() { }
|
|
26
|
-
async createReadStream() { }
|
|
27
|
-
async move() { }
|
|
28
|
-
}
|
|
29
|
-
class MockBucket {
|
|
30
|
-
file(path) {
|
|
31
|
-
return new MockFile(path);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
16
|
const BUCKET = "webda-dev";
|
|
35
17
|
let StorageTest = class StorageTest extends BinaryTest {
|
|
36
18
|
async before() {
|
|
37
|
-
this.
|
|
19
|
+
this.apiEndpoint = process.env["GCS_API_ENDPOINT"] || "";
|
|
20
|
+
await this.buildWebda();
|
|
38
21
|
await this.install();
|
|
39
22
|
await super.before();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
23
|
+
}
|
|
24
|
+
getBinary() {
|
|
25
|
+
this.prefix = this.webda.getUuid();
|
|
26
|
+
return this.addService(Storage, {
|
|
27
|
+
bucket: "webda-dev",
|
|
28
|
+
endpoint: this.apiEndpoint,
|
|
29
|
+
prefix: this.prefix
|
|
30
|
+
});
|
|
48
31
|
}
|
|
49
32
|
async after() {
|
|
50
33
|
await this.cleanData();
|
|
51
34
|
}
|
|
52
35
|
async install() {
|
|
53
|
-
|
|
36
|
+
const storage = new GCS({ apiEndpoint: this.apiEndpoint });
|
|
54
37
|
try {
|
|
55
|
-
|
|
56
|
-
if (!
|
|
38
|
+
const [exists] = await storage.bucket(BUCKET).exists();
|
|
39
|
+
if (!exists) {
|
|
40
|
+
console.log("INFO", `Google cloud storage creating bucket '${BUCKET}'`);
|
|
57
41
|
await storage.createBucket(BUCKET, {
|
|
58
42
|
location: "US-WEST2",
|
|
59
43
|
storageClass: "COLDLINE"
|
|
60
44
|
});
|
|
61
|
-
await storage.bucket(BUCKET).getMetadata();
|
|
62
45
|
}
|
|
63
|
-
|
|
46
|
+
else {
|
|
47
|
+
await this.cleanData();
|
|
48
|
+
}
|
|
64
49
|
}
|
|
65
50
|
catch (e) {
|
|
66
|
-
|
|
51
|
+
console.log("ERROR", `Google Cloud Storage error (${e.message})`);
|
|
67
52
|
}
|
|
68
53
|
}
|
|
69
54
|
async cleanData() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
const storage = new GCS({ apiEndpoint: this.apiEndpoint });
|
|
56
|
+
try {
|
|
57
|
+
const [files] = await storage.bucket(BUCKET).getFiles({
|
|
58
|
+
prefix: this.prefix
|
|
59
|
+
});
|
|
60
|
+
for (const file of files) {
|
|
61
|
+
await file.delete();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
console.error("Error cleaning up", err);
|
|
76
66
|
}
|
|
77
67
|
}
|
|
78
68
|
// Override getNotFound as exception is raised after
|
|
@@ -81,8 +71,8 @@ let StorageTest = class StorageTest extends BinaryTest {
|
|
|
81
71
|
async putObject() {
|
|
82
72
|
const body = `RAW Body: ${new Date()}`;
|
|
83
73
|
const name = `${this.prefix}/plop/test`;
|
|
84
|
-
await this.
|
|
85
|
-
|
|
74
|
+
await this.binary.putObject(name, Buffer.from(body), { meta1: "meta1" }, BUCKET);
|
|
75
|
+
const getFile = this.binary.getStorageBucket().file(name);
|
|
86
76
|
assert.deepStrictEqual((await getFile.getMetadata())[0].metadata, {
|
|
87
77
|
meta1: "meta1"
|
|
88
78
|
});
|
|
@@ -94,56 +84,99 @@ let StorageTest = class StorageTest extends BinaryTest {
|
|
|
94
84
|
// Skip it
|
|
95
85
|
}
|
|
96
86
|
async redirectUrl() {
|
|
97
|
-
|
|
87
|
+
const { user1, ctx } = await this.setupDefault();
|
|
88
|
+
await this.addService(RESTDomainService, {});
|
|
98
89
|
// Making sure we are redirected on GET
|
|
99
|
-
|
|
90
|
+
const executor = this.getExecutor(ctx, "test.webda.io", "GET", `${this.webda.getRouter().getModelUrl(user1)}/${user1.getUuid()}/images/0`, {});
|
|
100
91
|
await executor.execute(ctx);
|
|
101
92
|
assert.ok(ctx.getResponseHeaders().Location !== undefined);
|
|
102
93
|
}
|
|
103
|
-
async challenge() {
|
|
104
|
-
await this.testChallenge(false);
|
|
105
|
-
}
|
|
106
94
|
async redirectUrlInfo() {
|
|
107
|
-
|
|
95
|
+
const { user1, ctx } = await this.setupDefault();
|
|
96
|
+
await this.addService(RESTDomainService, {});
|
|
108
97
|
// Making sure we are redirected on GET
|
|
109
|
-
|
|
98
|
+
const executor = this.getExecutor(ctx, "test.webda.io", "GET", `${this.webda.getRouter().getModelUrl(user1)}/${user1.getUuid()}/images/0/url`, {});
|
|
110
99
|
await executor.execute(ctx);
|
|
111
100
|
assert.ok(ctx.getResponseHeaders().Location === undefined);
|
|
112
101
|
assert.notStrictEqual(JSON.parse(ctx.getResponseBody()).Location, undefined);
|
|
113
102
|
}
|
|
114
103
|
async cascadeDelete() {
|
|
115
|
-
|
|
104
|
+
const stubDelete = sinon.stub(await this.getBinary(), "_cleanUsage").callsFake(() => {
|
|
116
105
|
throw new Error();
|
|
117
106
|
});
|
|
118
107
|
try {
|
|
119
108
|
// @ts-ignore
|
|
120
|
-
await this.getBinary().cascadeDelete({ hash: "pp" }, "pp");
|
|
109
|
+
await (await this.getBinary()).cascadeDelete({ hash: "pp" }, "pp");
|
|
121
110
|
}
|
|
122
111
|
finally {
|
|
123
112
|
stubDelete.restore();
|
|
124
113
|
}
|
|
125
114
|
}
|
|
126
115
|
async defaultGCS() {
|
|
127
|
-
|
|
116
|
+
const { user1, ctx } = await this.setupDefault();
|
|
128
117
|
// COV for double
|
|
129
|
-
const binary = this.getBinary();
|
|
118
|
+
const binary = await this.getBinary();
|
|
130
119
|
const from = `${this.prefix}/rawAccess`;
|
|
131
120
|
const to = `${this.prefix}/movedAccess`;
|
|
132
121
|
await binary.putObject(from, path.join(__dirname, "..", "..", "test", "Dockerfile.txt"));
|
|
122
|
+
// Test GCS
|
|
123
|
+
const finder = new GCSFinder({ apiEndpoint: this.apiEndpoint });
|
|
124
|
+
const stub = sinon.stub();
|
|
125
|
+
let files = await finder.find("gs://webda-dev/", { processor: stub });
|
|
126
|
+
assert.strictEqual(stub.callCount, files.length);
|
|
127
|
+
assert.notStrictEqual(files.length, 0);
|
|
128
|
+
files = await finder.find(`gs://webda-dev/${this.prefix}`, { filterPattern: /rawAccess$/, processor: stub });
|
|
129
|
+
assert.strictEqual(files.length, 1);
|
|
130
|
+
const writer = await finder.getWriteStream(`gs://webda-dev/${this.prefix}/test.txt`);
|
|
131
|
+
writer.write("test");
|
|
132
|
+
const p = new Promise(resolve => {
|
|
133
|
+
writer.on("finish", resolve);
|
|
134
|
+
});
|
|
135
|
+
writer.end();
|
|
136
|
+
await p;
|
|
137
|
+
assert.strictEqual((await BinaryService.streamToBuffer(await finder.getReadStream(`gs://webda-dev/${this.prefix}/test.txt`))).toString(), "test");
|
|
138
|
+
assert.throws(() => finder.getInfo("s3://test/plop.txt"), /Invalid protocol path should be gs:/);
|
|
139
|
+
//
|
|
133
140
|
await binary.moveObject({ key: from }, { key: to });
|
|
134
141
|
assert.deepStrictEqual(binary.getSignedUrlHeaders(), {});
|
|
135
142
|
const meta = await binary.getMeta({ bucket: "webda-dev", key: to });
|
|
136
143
|
assert.deepStrictEqual(meta, { size: 311, contentType: "text/plain" });
|
|
137
|
-
|
|
144
|
+
const url = await binary.getPublicUrl({ key: "webda-dev" });
|
|
145
|
+
assert.ok(/\/webda-dev\/webda-dev/.exec(url));
|
|
146
|
+
if (this.apiEndpoint) {
|
|
147
|
+
assert.ok(url.startsWith(this.apiEndpoint));
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
assert.ok(url.startsWith("https://storage.googleapis.com"));
|
|
151
|
+
}
|
|
138
152
|
await binary.deleteObject({ key: to });
|
|
139
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Overwrite the send challenge data to use GCS
|
|
156
|
+
* @param info
|
|
157
|
+
* @param data
|
|
158
|
+
*/
|
|
159
|
+
async sendChallengeData(info, data) {
|
|
160
|
+
const url = new URL(info.url);
|
|
161
|
+
const metadata = {};
|
|
162
|
+
Object.keys(info.headers)
|
|
163
|
+
.filter(k => k.startsWith("x-goog-meta-"))
|
|
164
|
+
.forEach(k => {
|
|
165
|
+
metadata[k.substring(12)] = info.headers[k];
|
|
166
|
+
});
|
|
167
|
+
const file = new GCS({ apiEndpoint: this.apiEndpoint })
|
|
168
|
+
.bucket(BUCKET)
|
|
169
|
+
.file(url.pathname.substring(2 + BUCKET.length));
|
|
170
|
+
await file.save(data);
|
|
171
|
+
await file.setMetadata({ metadata: metadata });
|
|
172
|
+
}
|
|
140
173
|
async bucketSize() {
|
|
141
|
-
const binary = this.getBinary();
|
|
174
|
+
const binary = await this.getBinary();
|
|
142
175
|
sinon.stub(binary["storage"], "bucket").callsFake(() => {
|
|
143
176
|
return {
|
|
144
177
|
getFiles: ({ pageToken }) => {
|
|
145
|
-
|
|
146
|
-
|
|
178
|
+
const res = [];
|
|
179
|
+
const offset = pageToken ? parseInt(pageToken) : 1;
|
|
147
180
|
for (let i = offset; i < 100 + offset; i++) {
|
|
148
181
|
res.push({ name: `a${i}`, getMetadata: async () => [{ size: pageToken ? "20" : "100" }] });
|
|
149
182
|
}
|
|
@@ -173,9 +206,6 @@ __decorate([
|
|
|
173
206
|
__decorate([
|
|
174
207
|
test
|
|
175
208
|
], StorageTest.prototype, "redirectUrl", null);
|
|
176
|
-
__decorate([
|
|
177
|
-
test
|
|
178
|
-
], StorageTest.prototype, "challenge", null);
|
|
179
209
|
__decorate([
|
|
180
210
|
test
|
|
181
211
|
], StorageTest.prototype, "redirectUrlInfo", null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.spec.js","sourceRoot":"","sources":["../../src/services/storage.spec.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.spec.js","sourceRoot":"","sources":["../../src/services/storage.spec.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,IAAI,MAA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AE,CAAC;wBAC3C,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;oBAC7F,CAAC;oBACD,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;gBACrE,CAAC;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,eAAe,CAAC,MAAM,MAAM,CAAC,aAAa,EAAE,EAAE;YACnD,IAAI,EAAE,KAAK;YACX,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;QACH,MAAM,CAAC,eAAe,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE;YAC1E,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA7JO;IADL,IAAI;4CAUJ;AAIK;IADL,IAAI;8CACiB;AAGhB;IADL,IAAI;+CAIJ;AAGK;IADL,IAAI;8CAcJ;AAGK;IADL,IAAI;kDAeJ;AAGK;IADL,IAAI;gDAWJ;AAGK;IADL,IAAI;6CA4CJ;AAuBK;IADL,IAAI;6CAuBJ;AAxNG,WAAW;IADhB,KAAK;GACA,WAAW,CAyNhB"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webda/gcp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.2",
|
|
4
4
|
"description": "Webda GCP Services implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "webda build",
|
|
8
8
|
"build:watch": "webda build --watch",
|
|
9
9
|
"pretest": "npm run build",
|
|
10
|
-
"lint": "
|
|
11
|
-
"lint:fix": "
|
|
10
|
+
"lint": "eslint",
|
|
11
|
+
"lint:fix": "eslint --fix",
|
|
12
12
|
"test": "c8 mocha",
|
|
13
|
-
"test:debug": "mocha src/**/*.spec.ts"
|
|
13
|
+
"test:debug": "mocha src/**/*.spec.ts",
|
|
14
|
+
"format": "prettier --check src/**/*",
|
|
15
|
+
"format:fix": "prettier --write src/**/*"
|
|
14
16
|
},
|
|
15
17
|
"repository": {
|
|
16
18
|
"type": "git",
|
|
@@ -26,7 +28,7 @@
|
|
|
26
28
|
"package.json"
|
|
27
29
|
],
|
|
28
30
|
"author": "abalam666",
|
|
29
|
-
"license": "
|
|
31
|
+
"license": "LGPL-3.0-only",
|
|
30
32
|
"bugs": {
|
|
31
33
|
"url": "https://github.com/loopingz/webda.io/issues"
|
|
32
34
|
},
|
|
@@ -35,8 +37,9 @@
|
|
|
35
37
|
"@google-cloud/firestore": "^7.0.0",
|
|
36
38
|
"@google-cloud/kms": "^4.0.1",
|
|
37
39
|
"@google-cloud/pubsub": "^4.0.1",
|
|
38
|
-
"@google-cloud/storage": "~7.
|
|
39
|
-
"@webda/core": "^
|
|
40
|
+
"@google-cloud/storage": "~7.13.0",
|
|
41
|
+
"@webda/core": "^4.0.0-beta.2",
|
|
42
|
+
"@webda/ql": "^4.0.0-beta.2",
|
|
40
43
|
"mime-types": "^2.1.35"
|
|
41
44
|
},
|
|
42
45
|
"c8": {
|
|
@@ -57,15 +60,15 @@
|
|
|
57
60
|
},
|
|
58
61
|
"devDependencies": {
|
|
59
62
|
"@testdeck/mocha": "^0.3.2",
|
|
60
|
-
"@types/node": "
|
|
61
|
-
"@webda/async": "^
|
|
62
|
-
"@webda/shell": "^
|
|
63
|
-
"sinon": "^
|
|
64
|
-
"
|
|
63
|
+
"@types/node": "20.0.0",
|
|
64
|
+
"@webda/async": "^4.0.0-beta.2",
|
|
65
|
+
"@webda/shell": "^4.0.0-beta.2",
|
|
66
|
+
"sinon": "^19.0.2",
|
|
67
|
+
"tsx": "^4.17.0"
|
|
65
68
|
},
|
|
66
69
|
"type": "module",
|
|
67
70
|
"engines": {
|
|
68
|
-
"node": ">=
|
|
71
|
+
"node": ">=20.0.0"
|
|
69
72
|
},
|
|
70
73
|
"nx": {
|
|
71
74
|
"implicitDependencies": [
|
|
@@ -73,5 +76,5 @@
|
|
|
73
76
|
"@webda/shell"
|
|
74
77
|
]
|
|
75
78
|
},
|
|
76
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "e992dcfb82cefa6cd5c61c54a0e63778b6f53d8e"
|
|
77
80
|
}
|
package/webda.module.json
CHANGED
|
@@ -80,15 +80,6 @@
|
|
|
80
80
|
"description": "Additional models\n\nAllow this store to manage other models",
|
|
81
81
|
"default": []
|
|
82
82
|
},
|
|
83
|
-
"asyncDelete": {
|
|
84
|
-
"type": "boolean",
|
|
85
|
-
"description": "async delete"
|
|
86
|
-
},
|
|
87
|
-
"expose": {
|
|
88
|
-
"$ref": "#/definitions/StoreExposeParameters",
|
|
89
|
-
"description": "Expose the service to an urls",
|
|
90
|
-
"deprecated": "will probably be removed in 4.0 in favor of Expose annotation"
|
|
91
|
-
},
|
|
92
83
|
"strict": {
|
|
93
84
|
"type": "boolean",
|
|
94
85
|
"description": "Allow to load object that does not have the type data\n\nIf set to true, then the Store will only managed the defined _model and no model extending this one",
|
|
@@ -137,7 +128,6 @@
|
|
|
137
128
|
}
|
|
138
129
|
},
|
|
139
130
|
"required": [
|
|
140
|
-
"asyncDelete",
|
|
141
131
|
"collection",
|
|
142
132
|
"compoundIndexes",
|
|
143
133
|
"slowQueryThreshold",
|
|
@@ -146,53 +136,6 @@
|
|
|
146
136
|
"description": "Firebase parameters",
|
|
147
137
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
148
138
|
"definitions": {
|
|
149
|
-
"StoreExposeParameters": {
|
|
150
|
-
"type": "object",
|
|
151
|
-
"properties": {
|
|
152
|
-
"url": {
|
|
153
|
-
"type": "string",
|
|
154
|
-
"description": "URL endpoint to use to expose REST Resources API",
|
|
155
|
-
"default": "service.getName().toLowerCase()"
|
|
156
|
-
},
|
|
157
|
-
"restrict": {
|
|
158
|
-
"type": "object",
|
|
159
|
-
"properties": {
|
|
160
|
-
"create": {
|
|
161
|
-
"type": "boolean",
|
|
162
|
-
"description": "Do not expose the POST"
|
|
163
|
-
},
|
|
164
|
-
"update": {
|
|
165
|
-
"type": "boolean",
|
|
166
|
-
"description": "Do not expose the PUT and PATCH"
|
|
167
|
-
},
|
|
168
|
-
"get": {
|
|
169
|
-
"type": "boolean",
|
|
170
|
-
"description": "Do not expose the GET"
|
|
171
|
-
},
|
|
172
|
-
"delete": {
|
|
173
|
-
"type": "boolean",
|
|
174
|
-
"description": "Do not expose the DELETE"
|
|
175
|
-
},
|
|
176
|
-
"query": {
|
|
177
|
-
"type": "boolean",
|
|
178
|
-
"description": "Do not expose the query endpoint"
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
"description": "You can restrict any part of the CRUD",
|
|
182
|
-
"default": {}
|
|
183
|
-
},
|
|
184
|
-
"queryMethod": {
|
|
185
|
-
"type": "string",
|
|
186
|
-
"enum": [
|
|
187
|
-
"PUT",
|
|
188
|
-
"GET"
|
|
189
|
-
],
|
|
190
|
-
"description": "For confidentiality sometimes you might prefer to expose query through PUT To avoid GET logging",
|
|
191
|
-
"default": "GET"
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
"deprecated": "Store should not be exposed directly anymore\nYou should use the DomainService instead"
|
|
195
|
-
},
|
|
196
139
|
"FireStoreIndex": {
|
|
197
140
|
"type": "object",
|
|
198
141
|
"additionalProperties": {
|
|
@@ -1501,6 +1444,14 @@
|
|
|
1501
1444
|
"type": "number",
|
|
1502
1445
|
"description": "Timeout when receiveMessage is used before returning empty result (in ms)\n\nIf not define then no timeout is applied and receiveMessage can hang forever"
|
|
1503
1446
|
},
|
|
1447
|
+
"mode": {
|
|
1448
|
+
"type": "string",
|
|
1449
|
+
"enum": [
|
|
1450
|
+
"consumer",
|
|
1451
|
+
"receiver"
|
|
1452
|
+
],
|
|
1453
|
+
"description": "If receiver, the usage is to call receiveMessage and deleteMessage manually If consumer, the usage is to call consume, the normal flow is used in parallel"
|
|
1454
|
+
},
|
|
1504
1455
|
"openapi": {
|
|
1505
1456
|
"type": "object",
|
|
1506
1457
|
"additionalProperties": true
|
|
@@ -1508,6 +1459,7 @@
|
|
|
1508
1459
|
},
|
|
1509
1460
|
"required": [
|
|
1510
1461
|
"maxConsumers",
|
|
1462
|
+
"mode",
|
|
1511
1463
|
"subscription",
|
|
1512
1464
|
"topic",
|
|
1513
1465
|
"type"
|
|
@@ -1527,17 +1479,6 @@
|
|
|
1527
1479
|
"type": "string",
|
|
1528
1480
|
"description": "URL on which to serve the content"
|
|
1529
1481
|
},
|
|
1530
|
-
"map": {
|
|
1531
|
-
"type": "object",
|
|
1532
|
-
"additionalProperties": {
|
|
1533
|
-
"type": "array",
|
|
1534
|
-
"items": {
|
|
1535
|
-
"type": "string"
|
|
1536
|
-
}
|
|
1537
|
-
},
|
|
1538
|
-
"description": "Define the map to Object collection\n\nkey is a Store name the string[] represent all valids attributes to store files in",
|
|
1539
|
-
"deprecated": true
|
|
1540
|
-
},
|
|
1541
1482
|
"models": {
|
|
1542
1483
|
"type": "object",
|
|
1543
1484
|
"additionalProperties": {
|
|
@@ -1548,41 +1489,10 @@
|
|
|
1548
1489
|
},
|
|
1549
1490
|
"description": "Define the map of models\n* indicates all models\n\nkey is a Store name the string[] represent all valids attributes to store files in * indicates all attributes"
|
|
1550
1491
|
},
|
|
1551
|
-
"
|
|
1552
|
-
"type": "
|
|
1553
|
-
"
|
|
1554
|
-
|
|
1555
|
-
"type": "string",
|
|
1556
|
-
"description": "URL to expose the service to"
|
|
1557
|
-
},
|
|
1558
|
-
"restrict": {
|
|
1559
|
-
"type": "object",
|
|
1560
|
-
"properties": {
|
|
1561
|
-
"get": {
|
|
1562
|
-
"type": "boolean",
|
|
1563
|
-
"description": "Restrict GET"
|
|
1564
|
-
},
|
|
1565
|
-
"create": {
|
|
1566
|
-
"type": "boolean",
|
|
1567
|
-
"description": "Restrict POST"
|
|
1568
|
-
},
|
|
1569
|
-
"delete": {
|
|
1570
|
-
"type": "boolean",
|
|
1571
|
-
"description": "Restrict DELETE"
|
|
1572
|
-
},
|
|
1573
|
-
"metadata": {
|
|
1574
|
-
"type": "boolean",
|
|
1575
|
-
"description": "Restrict update of metadata"
|
|
1576
|
-
}
|
|
1577
|
-
},
|
|
1578
|
-
"description": "Restrict some APIs"
|
|
1579
|
-
}
|
|
1580
|
-
},
|
|
1581
|
-
"required": [
|
|
1582
|
-
"url"
|
|
1583
|
-
],
|
|
1584
|
-
"description": "Expose the service to http",
|
|
1585
|
-
"deprecated": "will be removed in 4.0"
|
|
1492
|
+
"maxFileSize": {
|
|
1493
|
+
"type": "number",
|
|
1494
|
+
"description": "Define the maximum filesize to accept as direct upload",
|
|
1495
|
+
"default": "10*1024*1024"
|
|
1586
1496
|
},
|
|
1587
1497
|
"prefix": {
|
|
1588
1498
|
"type": "string"
|
|
@@ -1590,6 +1500,10 @@
|
|
|
1590
1500
|
"bucket": {
|
|
1591
1501
|
"type": "string"
|
|
1592
1502
|
},
|
|
1503
|
+
"endpoint": {
|
|
1504
|
+
"type": "string",
|
|
1505
|
+
"description": "Specify endpoint for GCS"
|
|
1506
|
+
},
|
|
1593
1507
|
"openapi": {
|
|
1594
1508
|
"type": "object",
|
|
1595
1509
|
"additionalProperties": true
|
|
@@ -1597,7 +1511,6 @@
|
|
|
1597
1511
|
},
|
|
1598
1512
|
"required": [
|
|
1599
1513
|
"bucket",
|
|
1600
|
-
"map",
|
|
1601
1514
|
"models",
|
|
1602
1515
|
"type"
|
|
1603
1516
|
],
|