@intuitionrobotics/file-upload 0.46.0 → 0.47.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/app-backend/api/_upload.js +2 -2
- package/app-backend/api/_upload.js.map +1 -1
- package/app-backend/api/v1/upload/get-url.js +20 -2
- package/app-backend/api/v1/upload/get-url.js.map +1 -1
- package/app-backend/core/module-pack.d.ts +1 -1
- package/app-backend/core/module-pack.js +20 -2
- package/app-backend/core/module-pack.js.map +1 -1
- package/app-backend/modules/BucketListener.d.ts +1 -1
- package/app-backend/modules/BucketListener.js +22 -5
- package/app-backend/modules/BucketListener.js.map +1 -1
- package/app-backend/modules/ServerUploaderModule.d.ts +3 -4
- package/app-backend/modules/ServerUploaderModule.js +21 -3
- package/app-backend/modules/ServerUploaderModule.js.map +1 -1
- package/app-backend/modules/UploaderModule.d.ts +5 -5
- package/app-backend/modules/UploaderModule.js +12 -15
- package/app-backend/modules/UploaderModule.js.map +1 -1
- package/app-backend/modules/UploaderTempFileModule.d.ts +4 -4
- package/app-backend/modules/UploaderTempFileModule.js +29 -11
- package/app-backend/modules/UploaderTempFileModule.js.map +1 -1
- package/app-frontend/core/module-pack.d.ts +1 -1
- package/app-frontend/core/module-pack.js +20 -2
- package/app-frontend/core/module-pack.js.map +1 -1
- package/app-frontend/modules/UploaderModule.d.ts +4 -5
- package/app-frontend/modules/UploaderModule.js +27 -13
- package/app-frontend/modules/UploaderModule.js.map +1 -1
- package/backend.d.ts +5 -0
- package/backend.js +40 -0
- package/backend.js.map +1 -0
- package/frontend.d.ts +2 -0
- package/frontend.js +37 -0
- package/frontend.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +34 -0
- package/index.js.map +1 -1
- package/package.json +10 -10
- package/shared/modules/BaseUploaderModule.d.ts +7 -9
- package/shared/modules/BaseUploaderModule.js +33 -21
- package/shared/modules/BaseUploaderModule.js.map +1 -1
- package/shared/types.d.ts +12 -11
- package/shared/types.js +1 -1
- package/shared/types.js.map +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
module.exports = new
|
|
3
|
+
const backend_1 = require("@intuitionrobotics/thunderstorm/backend");
|
|
4
|
+
module.exports = new backend_1.RouteResolver(require, __dirname);
|
|
5
5
|
//# sourceMappingURL=_upload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_upload.js","sourceRoot":"","sources":["../../../src/main/app-backend/api/_upload.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"_upload.js","sourceRoot":"","sources":["../../../src/main/app-backend/api/_upload.ts"],"names":[],"mappings":";;AAAA,qEAAsE;AAEtE,MAAM,CAAC,OAAO,GAAG,IAAI,uBAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC"}
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
2
20
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
21
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
22
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -9,9 +27,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
27
|
});
|
|
10
28
|
};
|
|
11
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
30
|
+
const backend_1 = require("@intuitionrobotics/thunderstorm/backend");
|
|
13
31
|
const UploaderModule_1 = require("../../../modules/UploaderModule");
|
|
14
|
-
class ServerApi_GetUploadUrl extends
|
|
32
|
+
class ServerApi_GetUploadUrl extends backend_1.ServerApi_Post {
|
|
15
33
|
constructor() {
|
|
16
34
|
super('get-url');
|
|
17
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-url.js","sourceRoot":"","sources":["../../../../../src/main/app-backend/api/v1/upload/get-url.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"get-url.js","sourceRoot":"","sources":["../../../../../src/main/app-backend/api/v1/upload/get-url.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;AAEH,qEAIiD;AAMjD,oEAA+D;AAG/D,MAAM,sBACL,SAAQ,wBAAgC;IACxC;QACC,KAAK,CAAC,SAAS,CAAC,CAAA;IACjB,CAAC;IAEe,OAAO,CAAC,OAAuB,EAAE,QAAqB,EAAE,WAAwB,EAAE,IAAwB;;YACzH,OAAO,+BAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;KAAA;CACD;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,sBAAsB,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const Backend_ModulePack_Uploader: (import("../modules/UploaderTempFileModule").UploaderTempFileModule_Class | import("
|
|
1
|
+
export declare const Backend_ModulePack_Uploader: (import("../modules/UploaderTempFileModule").UploaderTempFileModule_Class | import("@intuitionrobotics/push-pub-sub/backend").PushPubSubModule_Class | import("@intuitionrobotics/push-pub-sub/backend").ScheduledCleanup_Class | import("../modules/BucketListener").BucketListener_Class | import("../modules/UploaderModule").UploaderModule_Class | import("../modules/ServerUploaderModule").ServerUploaderModule_Class)[];
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
2
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
21
|
exports.Backend_ModulePack_Uploader = void 0;
|
|
4
22
|
const UploaderModule_1 = require("../modules/UploaderModule");
|
|
5
23
|
const UploaderTempFileModule_1 = require("../modules/UploaderTempFileModule");
|
|
6
24
|
const BucketListener_1 = require("../modules/BucketListener");
|
|
7
|
-
const
|
|
25
|
+
const backend_1 = require("@intuitionrobotics/push-pub-sub/backend");
|
|
8
26
|
const ServerUploaderModule_1 = require("../modules/ServerUploaderModule");
|
|
9
27
|
exports.Backend_ModulePack_Uploader = [
|
|
10
|
-
...
|
|
28
|
+
...backend_1.Backend_ModulePack_PushPubSub,
|
|
11
29
|
ServerUploaderModule_1.ServerUploaderModule,
|
|
12
30
|
UploaderModule_1.UploaderModule,
|
|
13
31
|
UploaderTempFileModule_1.UploaderTempFileModule,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-backend/core/module-pack.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-backend/core/module-pack.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,8DAAyD;AACzD,8EAAyE;AACzE,8DAAyD;AACzD,qEAAsF;AACtF,0EAAqE;AAExD,QAAA,2BAA2B,GAAG;IAC1C,GAAG,uCAA6B;IAChC,2CAAoB;IACpB,+BAAc;IACd,+CAAsB;IACtB,+BAAc;CACd,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Firebase_StorageFunction } from "@intuitionrobotics/firebase/
|
|
1
|
+
import { Firebase_StorageFunction } from "@intuitionrobotics/firebase/backend-functions";
|
|
2
2
|
import { ObjectMetadata } from "firebase-functions/lib/v1/providers/storage";
|
|
3
3
|
import { EventContext } from "firebase-functions";
|
|
4
4
|
export interface OnFileUploaded {
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* A backend boilerplate with example apis
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
2
19
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
20
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
21
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,10 +27,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
27
|
};
|
|
11
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
29
|
exports.BucketListener = exports.BucketListener_Class = void 0;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const dispatcher_onFileUploaded = new
|
|
16
|
-
class BucketListener_Class extends
|
|
30
|
+
const backend_functions_1 = require("@intuitionrobotics/firebase/backend-functions");
|
|
31
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
32
|
+
const dispatcher_onFileUploaded = new ts_common_1.Dispatcher("__onFileUploaded");
|
|
33
|
+
class BucketListener_Class extends backend_functions_1.Firebase_StorageFunction {
|
|
17
34
|
constructor() {
|
|
18
35
|
super("BucketListener");
|
|
19
36
|
}
|
|
@@ -26,7 +43,7 @@ class BucketListener_Class extends firebase_function_1.Firebase_StorageFunction
|
|
|
26
43
|
onFinalize(object, context) {
|
|
27
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
45
|
const filePath = object.name;
|
|
29
|
-
yield dispatcher_onFileUploaded.dispatchModuleAsync(
|
|
46
|
+
yield dispatcher_onFileUploaded.dispatchModuleAsync(filePath);
|
|
30
47
|
this.logInfo("Object is ", object);
|
|
31
48
|
this.logInfo("Context is ", context);
|
|
32
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BucketListener.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/BucketListener.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"BucketListener.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/BucketListener.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;AAEH,qFAAuF;AAGvF,4DAAwD;AAMxD,MAAM,yBAAyB,GAAG,IAAI,sBAAU,CAAqC,kBAAkB,CAAC,CAAC;AAGzG,MAAa,oBACZ,SAAQ,4CAAwB;IAChC;QACC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACzB,CAAC;IAGD,IAAI;QACH,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,aAAa;QACb,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QACnD,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC;IAEK,UAAU,CAAC,MAAsB,EAAE,OAAqB;;YAC7D,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC;YAC7B,MAAM,yBAAyB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;YAC9D,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YACnC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC;KAAA;CAED;AArBD,oDAqBC;AAEY,QAAA,cAAc,GAAG,IAAI,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { BaseUploaderFile,
|
|
2
|
+
import { BaseUploaderFile, TempSecureUrl, Request_Uploader } from "../../shared/types";
|
|
3
3
|
import { BaseUploaderModule_Class } from "../../shared/modules/BaseUploaderModule";
|
|
4
|
-
import { AxiosHttpModule_Class } from "@intuitionrobotics/thunderstorm/
|
|
5
|
-
|
|
6
|
-
export declare type ServerFilesToUpload = Request_Uploader & {
|
|
4
|
+
import { Axios_RequestConfig, AxiosHttpModule_Class } from "@intuitionrobotics/thunderstorm/backend";
|
|
5
|
+
export type ServerFilesToUpload = Request_Uploader & {
|
|
7
6
|
file: Buffer;
|
|
8
7
|
};
|
|
9
8
|
export declare class ServerUploaderModule_Class extends BaseUploaderModule_Class<AxiosHttpModule_Class, {
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
2
20
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
21
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
22
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -11,14 +29,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
30
|
exports.ServerUploaderModule = exports.ServerUploaderModule_Class = void 0;
|
|
13
31
|
const BaseUploaderModule_1 = require("../../shared/modules/BaseUploaderModule");
|
|
14
|
-
const
|
|
32
|
+
const backend_1 = require("@intuitionrobotics/thunderstorm/backend");
|
|
15
33
|
class ServerUploaderModule_Class extends BaseUploaderModule_1.BaseUploaderModule_Class {
|
|
16
34
|
constructor() {
|
|
17
|
-
super(
|
|
35
|
+
super(backend_1.AxiosHttpModule, "ServerUploaderModule");
|
|
18
36
|
}
|
|
19
37
|
init() {
|
|
20
38
|
super.init();
|
|
21
|
-
|
|
39
|
+
backend_1.AxiosHttpModule.setRequestOption(this.config.requestConfig);
|
|
22
40
|
}
|
|
23
41
|
upload(files) {
|
|
24
42
|
return this.uploadImpl(files);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerUploaderModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/ServerUploaderModule.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ServerUploaderModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/ServerUploaderModule.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;AAOH,gFAEiD;AACjD,qEAIiD;AAMjD,MAAa,0BACZ,SAAQ,6CAAuF;IAE/F;QACC,KAAK,CAAC,yBAAe,EAAE,sBAAsB,CAAC,CAAC;IAChD,CAAC;IAED,IAAI;QACH,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,yBAAe,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,CAAC,KAA4B;QAClC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEe,eAAe,CAAC,WAA4B;;YAC3D,eAAe;YACf,kBAAkB;QACnB,CAAC;KAAA;CACD;AApBD,gEAoBC;AAEY,QAAA,oBAAoB,GAAG,IAAI,0BAA0B,EAAE,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { Module } from "@intuitionrobotics/ts-common";
|
|
2
|
+
import { FileWrapper } from "@intuitionrobotics/firebase/backend";
|
|
1
3
|
import { BaseUploaderFile, DB_Temp_File, TempSecureUrl } from "../../shared/types";
|
|
2
4
|
import { OnFileUploaded } from "./BucketListener";
|
|
3
|
-
import { FileWrapper } from "@intuitionrobotics/firebase/app-backend/storage/StorageWrapper";
|
|
4
|
-
import { Module } from "@intuitionrobotics/ts-common/core/module";
|
|
5
5
|
export declare const Temp_Path = "files-temp";
|
|
6
|
-
|
|
6
|
+
type Config = {
|
|
7
7
|
bucketName?: string;
|
|
8
8
|
uploaderProjectId?: string;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type PostProcessor = (file: FileWrapper, doc: DB_Temp_File) => Promise<void>;
|
|
11
11
|
export declare class UploaderModule_Class extends Module<Config> implements OnFileUploaded {
|
|
12
12
|
constructor();
|
|
13
13
|
private storage;
|
|
@@ -19,7 +19,7 @@ export declare class UploaderModule_Class extends Module<Config> implements OnFi
|
|
|
19
19
|
getProcessor: (k: string) => PostProcessor;
|
|
20
20
|
init(): void;
|
|
21
21
|
getUrl(body: BaseUploaderFile[], pathPrefix?: string): Promise<TempSecureUrl[]>;
|
|
22
|
-
fileUploaded: (filePath?: string
|
|
22
|
+
fileUploaded: (filePath?: string) => Promise<void>;
|
|
23
23
|
private notifyFrontend;
|
|
24
24
|
}
|
|
25
25
|
export declare const UploaderModule: UploaderModule_Class;
|
|
@@ -10,16 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.UploaderModule = exports.UploaderModule_Class = exports.Temp_Path = void 0;
|
|
13
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
14
|
+
const backend_1 = require("@intuitionrobotics/firebase/backend");
|
|
13
15
|
const types_1 = require("../../shared/types");
|
|
14
16
|
const UploaderTempFileModule_1 = require("./UploaderTempFileModule");
|
|
15
|
-
const
|
|
16
|
-
const exceptions_1 = require("@intuitionrobotics/ts-common/core/exceptions");
|
|
17
|
-
const FirebaseModule_1 = require("@intuitionrobotics/firebase/app-backend/FirebaseModule");
|
|
18
|
-
const random_tools_1 = require("@intuitionrobotics/ts-common/utils/random-tools");
|
|
19
|
-
const date_time_tools_1 = require("@intuitionrobotics/ts-common/utils/date-time-tools");
|
|
20
|
-
const PushPubSubModule_1 = require("@intuitionrobotics/push-pub-sub/app-backend/modules/PushPubSubModule");
|
|
17
|
+
const backend_2 = require("@intuitionrobotics/push-pub-sub/backend");
|
|
21
18
|
exports.Temp_Path = "files-temp";
|
|
22
|
-
class UploaderModule_Class extends
|
|
19
|
+
class UploaderModule_Class extends ts_common_1.Module {
|
|
23
20
|
constructor() {
|
|
24
21
|
super("UploaderModule");
|
|
25
22
|
this.setPostProcessor = (validator) => {
|
|
@@ -28,12 +25,12 @@ class UploaderModule_Class extends module_1.Module {
|
|
|
28
25
|
this.getProcessor = (k) => {
|
|
29
26
|
const postProcessorElement = this.postProcessor[k];
|
|
30
27
|
if (!postProcessorElement)
|
|
31
|
-
throw new
|
|
28
|
+
throw new ts_common_1.ImplementationMissingException(`Missing validator for type ${k}`);
|
|
32
29
|
return postProcessorElement;
|
|
33
30
|
};
|
|
34
31
|
this.fileUploaded = (filePath) => __awaiter(this, void 0, void 0, function* () {
|
|
35
32
|
if (!filePath)
|
|
36
|
-
throw new
|
|
33
|
+
throw new ts_common_1.ThisShouldNotHappenException("Missing file path");
|
|
37
34
|
this.logInfo(`Looking for file with path ${filePath}`);
|
|
38
35
|
// I use collection and not the module directly since I want to handle failure my way
|
|
39
36
|
const tempMeta = yield UploaderTempFileModule_1.UploaderTempFileModule.collection.queryUnique({ where: { path: filePath } });
|
|
@@ -66,7 +63,7 @@ class UploaderModule_Class extends module_1.Module {
|
|
|
66
63
|
this.notifyFrontend = (feId, result, message, cause) => __awaiter(this, void 0, void 0, function* () {
|
|
67
64
|
cause && this.logWarning(cause);
|
|
68
65
|
const data = { message, result, cause };
|
|
69
|
-
yield
|
|
66
|
+
yield backend_2.PushPubSubModule.pushToKey(types_1.fileUploadedKey, { feId }, data);
|
|
70
67
|
});
|
|
71
68
|
}
|
|
72
69
|
__onFileUploaded(filePath) {
|
|
@@ -76,8 +73,8 @@ class UploaderModule_Class extends module_1.Module {
|
|
|
76
73
|
}
|
|
77
74
|
init() {
|
|
78
75
|
if (!this.postProcessor)
|
|
79
|
-
throw new
|
|
80
|
-
this.storage =
|
|
76
|
+
throw new ts_common_1.ImplementationMissingException("You must set a postProcessor for the UploaderModule");
|
|
77
|
+
this.storage = backend_1.FirebaseModule.createAdminSession(this.config.uploaderProjectId).getStorage();
|
|
81
78
|
}
|
|
82
79
|
getUrl(body, pathPrefix = exports.Temp_Path) {
|
|
83
80
|
var _a;
|
|
@@ -87,7 +84,7 @@ class UploaderModule_Class extends module_1.Module {
|
|
|
87
84
|
return Promise.all(body.map((_file) => __awaiter(this, void 0, void 0, function* () {
|
|
88
85
|
const key = _file.key || _file.mimeType;
|
|
89
86
|
this.getProcessor(key);
|
|
90
|
-
const _id =
|
|
87
|
+
const _id = (0, ts_common_1.generateHex)(32);
|
|
91
88
|
const path = `${pathPrefix}/${_id}`;
|
|
92
89
|
const instance = {
|
|
93
90
|
_id,
|
|
@@ -96,7 +93,7 @@ class UploaderModule_Class extends module_1.Module {
|
|
|
96
93
|
mimeType: _file.mimeType,
|
|
97
94
|
key,
|
|
98
95
|
path,
|
|
99
|
-
_audit:
|
|
96
|
+
_audit: (0, ts_common_1.auditBy)("be-stub"),
|
|
100
97
|
bucketName: bucket.bucketName
|
|
101
98
|
};
|
|
102
99
|
if (_file.public)
|
|
@@ -105,7 +102,7 @@ class UploaderModule_Class extends module_1.Module {
|
|
|
105
102
|
instance.metadata = _file.metadata;
|
|
106
103
|
const temp = yield UploaderTempFileModule_1.UploaderTempFileModule.upsert(instance);
|
|
107
104
|
const file = yield bucket.getFile(temp.path);
|
|
108
|
-
const url = yield file.getWriteSecuredUrl(_file.mimeType,
|
|
105
|
+
const url = yield file.getWriteSecuredUrl(_file.mimeType, ts_common_1.Hour);
|
|
109
106
|
return {
|
|
110
107
|
secureUrl: url.securedUrl,
|
|
111
108
|
tempDoc: temp
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploaderModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/UploaderModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAO4B;AAC5B,qEAAgE;
|
|
1
|
+
{"version":3,"file":"UploaderModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/UploaderModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4DAOsC;AACtC,iEAI6C;AAC7C,8CAO4B;AAC5B,qEAAgE;AAChE,qEAAyE;AAG5D,QAAA,SAAS,GAAG,YAAY,CAAC;AAStC,MAAa,oBACZ,SAAQ,kBAAc;IAGtB;QACC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAWzB,qBAAgB,GAAG,CAAC,SAAyC,EAAE,EAAE;YAChE,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QAChC,CAAC,CAAC;QAEK,iBAAY,GAAG,CAAC,CAAS,EAAE,EAAE;YACnC,MAAM,oBAAoB,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YACnD,IAAI,CAAC,oBAAoB;gBACxB,MAAM,IAAI,0CAA8B,CAAC,8BAA8B,CAAC,EAAE,CAAC,CAAC;YAE7E,OAAO,oBAAoB,CAAC;QAC7B,CAAC,CAAC;QA6CF,iBAAY,GAAG,CAAO,QAAiB,EAAE,EAAE;YAC1C,IAAI,CAAC,QAAQ;gBACZ,MAAM,IAAI,wCAA4B,CAAC,mBAAmB,CAAC,CAAC;YAE7D,IAAI,CAAC,OAAO,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC;YAEvD,qFAAqF;YACrF,MAAM,QAAQ,GAAG,MAAM,+CAAsB,CAAC,UAAU,CAAC,WAAW,CAAC,EAAC,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAC,CAAC,CAAC;YAChG,IAAI,CAAC,QAAQ;gBACZ,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,QAAQ,mCAA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ApiGenerator } from "@intuitionrobotics/db-api-generator/
|
|
1
|
+
import { TypeValidator } from "@intuitionrobotics/ts-common";
|
|
2
|
+
import { ServerApi } from "@intuitionrobotics/thunderstorm/backend";
|
|
3
|
+
import { BaseDB_ApiGenerator } from "@intuitionrobotics/db-api-generator/backend";
|
|
4
4
|
import { DB_Temp_File } from "../../shared/types";
|
|
5
5
|
export declare const TEMP_COLLECTION = "temp-files-upload";
|
|
6
|
-
export declare const validateName: import("@intuitionrobotics/ts-common
|
|
6
|
+
export declare const validateName: import("@intuitionrobotics/ts-common").Validator<string>;
|
|
7
7
|
export declare class UploaderTempFileModule_Class extends BaseDB_ApiGenerator<DB_Temp_File> {
|
|
8
8
|
static _validator: TypeValidator<DB_Temp_File>;
|
|
9
9
|
constructor();
|
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UploaderTempFileModule = exports.UploaderTempFileModule_Class = exports.validateName = exports.TEMP_COLLECTION = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/*
|
|
5
|
+
* Permissions management system, define access level for each of
|
|
6
|
+
* your server apis, and restrict users by giving them access levels
|
|
7
|
+
*
|
|
8
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
23
|
+
const backend_1 = require("@intuitionrobotics/db-api-generator/backend");
|
|
6
24
|
exports.TEMP_COLLECTION = "temp-files-upload";
|
|
7
|
-
exports.validateName =
|
|
8
|
-
class UploaderTempFileModule_Class extends
|
|
25
|
+
exports.validateName = (0, ts_common_1.validateRegexp)(/^.{3,}$/);
|
|
26
|
+
class UploaderTempFileModule_Class extends backend_1.BaseDB_ApiGenerator {
|
|
9
27
|
constructor() {
|
|
10
28
|
super(exports.TEMP_COLLECTION, UploaderTempFileModule_Class._validator, "temp-files", "UploaderTempFileModule");
|
|
11
29
|
}
|
|
@@ -15,14 +33,14 @@ class UploaderTempFileModule_Class extends BaseDB_ApiGenerator_1.BaseDB_ApiGener
|
|
|
15
33
|
}
|
|
16
34
|
exports.UploaderTempFileModule_Class = UploaderTempFileModule_Class;
|
|
17
35
|
UploaderTempFileModule_Class._validator = {
|
|
18
|
-
_id:
|
|
36
|
+
_id: backend_1.validateUniqueId,
|
|
19
37
|
name: exports.validateName,
|
|
20
|
-
feId:
|
|
21
|
-
mimeType:
|
|
22
|
-
key:
|
|
23
|
-
path:
|
|
24
|
-
_audit:
|
|
25
|
-
bucketName:
|
|
38
|
+
feId: (0, ts_common_1.validateExists)(true),
|
|
39
|
+
mimeType: (0, ts_common_1.validateExists)(true),
|
|
40
|
+
key: (0, ts_common_1.validateExists)(true),
|
|
41
|
+
path: (0, ts_common_1.validateExists)(true),
|
|
42
|
+
_audit: (0, ts_common_1.auditValidator)(),
|
|
43
|
+
bucketName: (0, ts_common_1.validateExists)(true),
|
|
26
44
|
public: undefined,
|
|
27
45
|
metadata: undefined
|
|
28
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploaderTempFileModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/UploaderTempFileModule.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"UploaderTempFileModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/UploaderTempFileModule.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,4DAKsC;AAEtC,yEAGqD;AAGxC,QAAA,eAAe,GAAG,mBAAmB,CAAC;AAEtC,QAAA,YAAY,GAAG,IAAA,0BAAc,EAAC,SAAS,CAAC,CAAC;AAEtD,MAAa,4BACZ,SAAQ,6BAAiC;IAczC;QACC,KAAK,CAAC,uBAAe,EAAE,4BAA4B,CAAC,UAAU,EAAE,YAAY,EAAE,wBAAwB,CAAC,CAAC;IACzG,CAAC;IAED,IAAI,CAAC,QAAiB;QACrB,OAAO,EAAE,CAAC;IACX,CAAC;;AArBF,oEAsBC;AApBO,uCAAU,GAAgC;IAChD,GAAG,EAAE,0BAAgB;IACrB,IAAI,EAAE,oBAAY;IAClB,IAAI,EAAE,IAAA,0BAAc,EAAC,IAAI,CAAC;IAC1B,QAAQ,EAAE,IAAA,0BAAc,EAAC,IAAI,CAAC;IAC9B,GAAG,EAAE,IAAA,0BAAc,EAAC,IAAI,CAAC;IACzB,IAAI,EAAE,IAAA,0BAAc,EAAC,IAAI,CAAC;IAC1B,MAAM,EAAE,IAAA,0BAAc,GAAE;IACxB,UAAU,EAAE,IAAA,0BAAc,EAAC,IAAI,CAAC;IAChC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,SAAS;CACnB,CAAC;AAWU,QAAA,sBAAsB,GAAG,IAAI,4BAA4B,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const Frontend_ModulePack_Uploader: (import("@intuitionrobotics/push-pub-sub/
|
|
1
|
+
export declare const Frontend_ModulePack_Uploader: (import("@intuitionrobotics/push-pub-sub/frontend").PushPubSubModule_Class | import("@intuitionrobotics/push-pub-sub/frontend").NotificationsModule_Class | import("@intuitionrobotics/firebase/frontend").FirebaseModule_Class | import("../modules/UploaderModule").UploaderModule_Class)[];
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Frontend_ModulePack_Uploader = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Permissions management system, define access level for each of
|
|
6
|
+
* your server apis, and restrict users by giving them access levels
|
|
7
|
+
*
|
|
8
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
4
22
|
const UploaderModule_1 = require("../modules/UploaderModule");
|
|
5
|
-
const
|
|
23
|
+
const frontend_1 = require("@intuitionrobotics/push-pub-sub/frontend");
|
|
6
24
|
exports.Frontend_ModulePack_Uploader = [
|
|
7
|
-
...
|
|
25
|
+
...frontend_1.Frontend_ModulePack_PushPubSub,
|
|
8
26
|
UploaderModule_1.UploaderModule
|
|
9
27
|
];
|
|
10
28
|
//# sourceMappingURL=module-pack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-frontend/core/module-pack.ts"],"names":[],"mappings":";;;AAAA,8DAAyD;AACzD
|
|
1
|
+
{"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-frontend/core/module-pack.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,8DAAyD;AACzD,uEAAwF;AAE3E,QAAA,4BAA4B,GAAG;IAC3C,GAAG,yCAA8B;IACjC,+BAAc;CACd,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { ThunderDispatcher, XhrHttpModule_Class } from "@intuitionrobotics/thunderstorm/frontend";
|
|
1
2
|
import { BaseUploaderFile, Push_FileUploaded, TempSecureUrl } from "../../shared/types";
|
|
3
|
+
import { OnPushMessageReceived } from "@intuitionrobotics/push-pub-sub/frontend";
|
|
2
4
|
import { BaseUploaderModule_Class, OnFileStatusChanged } from "../../shared/modules/BaseUploaderModule";
|
|
3
|
-
import {
|
|
4
|
-
import { OnPushMessageReceived } from "@intuitionrobotics/push-pub-sub/app-frontend/modules/PushPubSubModule";
|
|
5
|
-
import { ThunderDispatcher } from "@intuitionrobotics/thunderstorm/app-frontend/core/thunder-dispatcher";
|
|
6
|
-
import { DB_Notifications } from "@intuitionrobotics/push-pub-sub/shared/types";
|
|
5
|
+
import { DB_Notifications } from "@intuitionrobotics/push-pub-sub";
|
|
7
6
|
export declare class UploaderModule_Class extends BaseUploaderModule_Class<XhrHttpModule_Class> implements OnPushMessageReceived<Push_FileUploaded> {
|
|
8
|
-
protected readonly dispatch_fileStatusChange: ThunderDispatcher<OnFileStatusChanged, "__onFileStatusChanged">;
|
|
7
|
+
protected readonly dispatch_fileStatusChange: ThunderDispatcher<OnFileStatusChanged, "__onFileStatusChanged", [id?: string | undefined], void>;
|
|
9
8
|
constructor();
|
|
10
9
|
protected dispatchFileStatusChange(id?: string): void;
|
|
11
10
|
upload(files: File[], key?: string, _public?: boolean): BaseUploaderFile[];
|
|
@@ -10,19 +10,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.UploaderModule = exports.UploaderModule_Class = void 0;
|
|
13
|
+
/*
|
|
14
|
+
* Permissions management system, define access level for each of
|
|
15
|
+
* your server apis, and restrict users by giving them access levels
|
|
16
|
+
*
|
|
17
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License.
|
|
21
|
+
* You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const frontend_1 = require("@intuitionrobotics/thunderstorm/frontend");
|
|
13
32
|
const types_1 = require("../../shared/types");
|
|
33
|
+
const frontend_2 = require("@intuitionrobotics/push-pub-sub/frontend");
|
|
14
34
|
const BaseUploaderModule_1 = require("../../shared/modules/BaseUploaderModule");
|
|
15
|
-
const
|
|
16
|
-
const PushPubSubModule_1 = require("@intuitionrobotics/push-pub-sub/app-frontend/modules/PushPubSubModule");
|
|
17
|
-
const thunder_dispatcher_1 = require("@intuitionrobotics/thunderstorm/app-frontend/core/thunder-dispatcher");
|
|
18
|
-
const date_time_tools_1 = require("@intuitionrobotics/ts-common/utils/date-time-tools");
|
|
35
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
19
36
|
class UploaderModule_Class extends BaseUploaderModule_1.BaseUploaderModule_Class {
|
|
20
37
|
constructor() {
|
|
21
|
-
super(
|
|
22
|
-
this.dispatch_fileStatusChange = new
|
|
38
|
+
super(frontend_1.XhrHttpModule, 'UploaderModule');
|
|
39
|
+
this.dispatch_fileStatusChange = new frontend_1.ThunderDispatcher("__onFileStatusChanged");
|
|
23
40
|
}
|
|
24
41
|
dispatchFileStatusChange(id) {
|
|
25
|
-
this.dispatch_fileStatusChange.dispatchUI(
|
|
42
|
+
this.dispatch_fileStatusChange.dispatchUI(id);
|
|
26
43
|
super.dispatchFileStatusChange(id);
|
|
27
44
|
}
|
|
28
45
|
upload(files, key, _public) {
|
|
@@ -38,11 +55,8 @@ class UploaderModule_Class extends BaseUploaderModule_1.BaseUploaderModule_Class
|
|
|
38
55
|
}
|
|
39
56
|
subscribeToPush(toSubscribe) {
|
|
40
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
props: { feId: r.tempDoc.feId }
|
|
44
|
-
})));
|
|
45
|
-
yield date_time_tools_1.timeout(date_time_tools_1.Second);
|
|
58
|
+
frontend_2.PushPubSubModule.subscribeMulti(toSubscribe.map(r => ({ pushKey: types_1.fileUploadedKey, props: { feId: r.tempDoc.feId } })));
|
|
59
|
+
yield (0, ts_common_1.timeout)(ts_common_1.Second);
|
|
46
60
|
});
|
|
47
61
|
}
|
|
48
62
|
__onMessageReceived(notification) {
|
|
@@ -58,7 +72,7 @@ class UploaderModule_Class extends BaseUploaderModule_1.BaseUploaderModule_Class
|
|
|
58
72
|
this.setFileInfo((_b = notification.props) === null || _b === void 0 ? void 0 : _b.feId, "status", BaseUploaderModule_1.FileStatus.Error);
|
|
59
73
|
break;
|
|
60
74
|
}
|
|
61
|
-
|
|
75
|
+
frontend_2.PushPubSubModule.unsubscribe({ pushKey: types_1.fileUploadedKey, props: notification.props });
|
|
62
76
|
}
|
|
63
77
|
}
|
|
64
78
|
exports.UploaderModule_Class = UploaderModule_Class;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploaderModule.js","sourceRoot":"","sources":["../../../src/main/app-frontend/modules/UploaderModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"UploaderModule.js","sourceRoot":"","sources":["../../../src/main/app-frontend/modules/UploaderModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,uEAIkD;AAClD,8CAM4B;AAC5B,uEAGkD;AAClD,gFAIiD;AAEjD,4DAGs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K,oBAAY,CAAC,OAAO;gBACxB,IAAI,CAAC,WAAW,CAAC,MAAA,YAAY,CAAC,KAAK,0CAAE,IAAc,EAAE,QAAQ,EAAE,+BAAU,CAAC,SAAS,CAAC,CAAC;gBACrF,MAAM;YACP,KAAK,oBAAY,CAAC,OAAO;gBACxB,IAAI,CAAC,WAAW,CAAC,MAAA,YAAY,CAAC,KAAK,0CAAE,IAAc,EAAE,QAAQ,EAAE,+BAAU,CAAC,KAAK,CAAC,CAAC;gBACjF,MAAM;QACR,CAAC;QAED,2BAAgB,CAAC,WAAW,CAAC,EAAC,OAAO,EAAE,uBAAe,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,EAAC,CAAC,CAAC;IACrF,CAAC;CACD;AAhDD,oDAgDC;AAEY,QAAA,cAAc,GAAG,IAAI,oBAAoB,EAAE,CAAC"}
|
package/backend.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from "./app-backend/core/module-pack";
|
|
2
|
+
export * from "./app-backend/modules/UploaderModule";
|
|
3
|
+
export * from "./app-backend/modules/BucketListener";
|
|
4
|
+
export * from "./app-backend/modules/UploaderTempFileModule";
|
|
5
|
+
export * from "./app-backend/modules/ServerUploaderModule";
|
package/backend.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
__exportStar(require("./app-backend/core/module-pack"), exports);
|
|
36
|
+
__exportStar(require("./app-backend/modules/UploaderModule"), exports);
|
|
37
|
+
__exportStar(require("./app-backend/modules/BucketListener"), exports);
|
|
38
|
+
__exportStar(require("./app-backend/modules/UploaderTempFileModule"), exports);
|
|
39
|
+
__exportStar(require("./app-backend/modules/ServerUploaderModule"), exports);
|
|
40
|
+
//# sourceMappingURL=backend.js.map
|
package/backend.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/main/backend.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;AAEH,iEAA+C;AAE/C,uEAAqD;AACrD,uEAAqD;AACrD,+EAA6D;AAC7D,6EAA2D"}
|
package/frontend.d.ts
ADDED
package/frontend.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
__exportStar(require("./app-frontend/core/module-pack"), exports);
|
|
36
|
+
__exportStar(require("./app-frontend/modules/UploaderModule"), exports);
|
|
37
|
+
//# sourceMappingURL=frontend.js.map
|
package/frontend.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend.js","sourceRoot":"","sources":["../src/main/frontend.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;AAEH,kEAAgD;AAChD,wEAAsD"}
|
package/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './shared/types';
|
package/index.js
CHANGED
|
@@ -1,2 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
__exportStar(require("./shared/types"), exports);
|
|
2
36
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/main/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/main/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;AAEH,iDAA+B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuitionrobotics/file-upload",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.1",
|
|
4
4
|
"description": "File Uploader - Express & Typescript based backend framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"IR",
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
"**/*"
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
|
-
"build": "tsc"
|
|
29
|
+
"build": "tsc -v && tsc -p src/main/tsconfig.json --rootDir ./src/main --outDir dist"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@intuitionrobotics/ts-common": "~0.
|
|
33
|
-
"@intuitionrobotics/thunderstorm": "~0.
|
|
34
|
-
"@intuitionrobotics/firebase": "~0.
|
|
35
|
-
"@intuitionrobotics/db-api-generator": "~0.
|
|
36
|
-
"@intuitionrobotics/push-pub-sub": "~0.
|
|
32
|
+
"@intuitionrobotics/ts-common": "~0.47.0",
|
|
33
|
+
"@intuitionrobotics/thunderstorm": "~0.47.0",
|
|
34
|
+
"@intuitionrobotics/firebase": "~0.47.0",
|
|
35
|
+
"@intuitionrobotics/db-api-generator": "~0.47.0",
|
|
36
|
+
"@intuitionrobotics/push-pub-sub": "~0.47.0",
|
|
37
37
|
"firebase-functions": "^4.4.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@intuitionrobotics/testelot": "~0.
|
|
41
|
-
"@types/node": "^
|
|
42
|
-
"typescript": "
|
|
40
|
+
"@intuitionrobotics/testelot": "~0.47.0",
|
|
41
|
+
"@types/node": "^18.0.0",
|
|
42
|
+
"typescript": "^5.3.0"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseHttpRequest } from "@intuitionrobotics/thunderstorm
|
|
3
|
-
import {
|
|
4
|
-
import { Module } from "@intuitionrobotics/ts-common/core/module";
|
|
5
|
-
import { BaseUploaderFile, DB_Temp_File, Request_Uploader, TempSecureUrl } from "../types";
|
|
1
|
+
import { Dispatcher, Module } from "@intuitionrobotics/ts-common";
|
|
2
|
+
import { BaseHttpModule_Class, BaseHttpRequest } from "@intuitionrobotics/thunderstorm";
|
|
3
|
+
import { BaseUploaderFile, DB_Temp_File, Request_Uploader, TempSecureUrl } from "../../shared/types";
|
|
6
4
|
export declare enum FileStatus {
|
|
7
5
|
ObtainingUrl = "ObtainingUrl",
|
|
8
6
|
UrlObtained = "UrlObtained",
|
|
@@ -11,7 +9,7 @@ export declare enum FileStatus {
|
|
|
11
9
|
Completed = "Completed",
|
|
12
10
|
Error = "Error"
|
|
13
11
|
}
|
|
14
|
-
export
|
|
12
|
+
export type FileInfo = {
|
|
15
13
|
status: FileStatus;
|
|
16
14
|
messageStatus?: string;
|
|
17
15
|
progress?: number;
|
|
@@ -24,10 +22,10 @@ export declare type FileInfo = {
|
|
|
24
22
|
export interface OnFileStatusChanged {
|
|
25
23
|
__onFileStatusChanged: (id?: string) => void;
|
|
26
24
|
}
|
|
27
|
-
export
|
|
25
|
+
export type FilesToUpload = Request_Uploader & {
|
|
28
26
|
file: any;
|
|
29
27
|
};
|
|
30
|
-
|
|
28
|
+
type Config = {
|
|
31
29
|
uploadQueueParallelCount?: number;
|
|
32
30
|
};
|
|
33
31
|
export declare abstract class BaseUploaderModule_Class<HttpModule extends BaseHttpModule_Class, CustomConfig extends object = {}> extends Module<Config & CustomConfig> {
|
|
@@ -35,7 +33,7 @@ export declare abstract class BaseUploaderModule_Class<HttpModule extends BaseHt
|
|
|
35
33
|
[id: string]: FileInfo;
|
|
36
34
|
};
|
|
37
35
|
private readonly uploadQueue;
|
|
38
|
-
protected readonly dispatch_fileStatusChange: Dispatcher<OnFileStatusChanged, "__onFileStatusChanged">;
|
|
36
|
+
protected readonly dispatch_fileStatusChange: Dispatcher<OnFileStatusChanged, "__onFileStatusChanged", [id?: string | undefined], void>;
|
|
39
37
|
private httpModule;
|
|
40
38
|
protected constructor(httpModule: HttpModule, moduleName: string);
|
|
41
39
|
init(): void;
|
|
@@ -10,14 +10,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BaseUploaderModule_Class = exports.FileStatus = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
/*
|
|
14
|
+
* Permissions management system, define access level for each of
|
|
15
|
+
* your server apis, and restrict users by giving them access levels
|
|
16
|
+
*
|
|
17
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License.
|
|
21
|
+
* You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
32
|
+
const thunderstorm_1 = require("@intuitionrobotics/thunderstorm");
|
|
21
33
|
const RequestKey_UploadUrl = 'get-upload-url';
|
|
22
34
|
const RequestKey_UploadFile = 'upload-file';
|
|
23
35
|
var FileStatus;
|
|
@@ -30,13 +42,13 @@ var FileStatus;
|
|
|
30
42
|
FileStatus["PostProcessing"] = "PostProcessing";
|
|
31
43
|
FileStatus["Completed"] = "Completed";
|
|
32
44
|
FileStatus["Error"] = "Error";
|
|
33
|
-
})(FileStatus
|
|
34
|
-
class BaseUploaderModule_Class extends
|
|
45
|
+
})(FileStatus || (exports.FileStatus = FileStatus = {}));
|
|
46
|
+
class BaseUploaderModule_Class extends ts_common_1.Module {
|
|
35
47
|
constructor(httpModule, moduleName) {
|
|
36
48
|
super(moduleName);
|
|
37
49
|
this.files = {};
|
|
38
|
-
this.uploadQueue = new
|
|
39
|
-
this.dispatch_fileStatusChange = new
|
|
50
|
+
this.uploadQueue = new ts_common_1.Queue("File Uploader").setParallelCount(2);
|
|
51
|
+
this.dispatch_fileStatusChange = new ts_common_1.Dispatcher('__onFileStatusChanged');
|
|
40
52
|
this.uploadFiles = (response) => __awaiter(this, void 0, void 0, function* () {
|
|
41
53
|
// Subscribe
|
|
42
54
|
yield this.subscribeToPush(response);
|
|
@@ -51,7 +63,7 @@ class BaseUploaderModule_Class extends module_1.Module {
|
|
|
51
63
|
this.setFileInfo(feId, "status", FileStatus.PostProcessing);
|
|
52
64
|
}, error => {
|
|
53
65
|
this.setFileInfo(feId, "status", FileStatus.Error);
|
|
54
|
-
this.setFileInfo(feId, "messageStatus",
|
|
66
|
+
this.setFileInfo(feId, "messageStatus", (0, ts_common_1.__stringify)(error));
|
|
55
67
|
});
|
|
56
68
|
});
|
|
57
69
|
});
|
|
@@ -61,14 +73,14 @@ class BaseUploaderModule_Class extends module_1.Module {
|
|
|
61
73
|
this.setFileInfo(feId, "tempDoc", response.tempDoc);
|
|
62
74
|
const fileInfo = this.files[feId];
|
|
63
75
|
if (!fileInfo)
|
|
64
|
-
throw new
|
|
76
|
+
throw new ts_common_1.BadImplementationException(`Missing file with id ${feId} and name: ${response.tempDoc.name}`);
|
|
65
77
|
const request = this
|
|
66
78
|
.httpModule
|
|
67
|
-
.createRequest(
|
|
79
|
+
.createRequest(thunderstorm_1.HttpMethod.PUT, RequestKey_UploadFile)
|
|
68
80
|
.setUrl(response.secureUrl)
|
|
69
81
|
// Don't change this because it replaces the default headers which we dont need
|
|
70
82
|
.setDefaultHeaders({ 'Content-Type': response.tempDoc.mimeType })
|
|
71
|
-
.setTimeout(20 *
|
|
83
|
+
.setTimeout(20 * ts_common_1.Minute)
|
|
72
84
|
.setBody(fileInfo.file)
|
|
73
85
|
.setOnProgressListener((ev) => {
|
|
74
86
|
this.setFileInfo(feId, "progress", ev.loaded / ev.total);
|
|
@@ -90,19 +102,19 @@ class BaseUploaderModule_Class extends module_1.Module {
|
|
|
90
102
|
}
|
|
91
103
|
setFileInfo(id, key, value) {
|
|
92
104
|
if (!this.files[id])
|
|
93
|
-
throw new
|
|
105
|
+
throw new ts_common_1.BadImplementationException(`Trying to set ${key} for non existent file with id: ${id}`);
|
|
94
106
|
this.files[id][key] = value;
|
|
95
107
|
this.dispatchFileStatusChange(id);
|
|
96
108
|
}
|
|
97
109
|
dispatchFileStatusChange(id) {
|
|
98
|
-
this.dispatch_fileStatusChange.dispatchModule(
|
|
110
|
+
this.dispatch_fileStatusChange.dispatchModule(id);
|
|
99
111
|
}
|
|
100
112
|
uploadImpl(files) {
|
|
101
113
|
const body = files.map(fileData => {
|
|
102
114
|
const fileInfo = {
|
|
103
115
|
name: fileData.name,
|
|
104
116
|
mimeType: fileData.mimeType,
|
|
105
|
-
feId:
|
|
117
|
+
feId: (0, ts_common_1.generateHex)(32)
|
|
106
118
|
};
|
|
107
119
|
if (fileData.key)
|
|
108
120
|
fileInfo.key = fileData.key;
|
|
@@ -118,12 +130,12 @@ class BaseUploaderModule_Class extends module_1.Module {
|
|
|
118
130
|
});
|
|
119
131
|
this
|
|
120
132
|
.httpModule
|
|
121
|
-
.createRequest(
|
|
133
|
+
.createRequest(thunderstorm_1.HttpMethod.POST, RequestKey_UploadUrl)
|
|
122
134
|
.setRelativeUrl('/v1/upload/get-url')
|
|
123
135
|
.setJsonBody(body)
|
|
124
136
|
.setOnError((request, resError) => {
|
|
125
137
|
body.forEach(f => {
|
|
126
|
-
this.setFileInfo(f.feId, "messageStatus",
|
|
138
|
+
this.setFileInfo(f.feId, "messageStatus", (0, ts_common_1.__stringify)(resError === null || resError === void 0 ? void 0 : resError.debugMessage));
|
|
127
139
|
this.setFileInfo(f.feId, "status", FileStatus.Error);
|
|
128
140
|
});
|
|
129
141
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseUploaderModule.js","sourceRoot":"","sources":["../../../src/main/shared/modules/BaseUploaderModule.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"BaseUploaderModule.js","sourceRoot":"","sources":["../../../src/main/shared/modules/BaseUploaderModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,4DAQsC;AACtC,kEAMyC;AAUzC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAC9C,MAAM,qBAAqB,GAAG,aAAa,CAAC;AAE5C,IAAY,UASX;AATD,WAAY,UAAU;IACrB,2CAA+B,CAAA;IAC/B,yCAA8B,CAAA;IAC9B,6CAAgC,CAAA;IAChC,kDAAkD;IAClD,6CAA6C;IAC7C,+CAAiC,CAAA;IAC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J,OAAO,IAAI,CAAC;IACb,CAAC;CA6CD;AAjID,4DAiIC"}
|
package/shared/types.d.ts
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { AuditBy,
|
|
1
|
+
import { ApiWithBody } from "@intuitionrobotics/thunderstorm";
|
|
2
|
+
import { DB_Object } from "@intuitionrobotics/firebase";
|
|
3
|
+
import { AuditBy, ObjectTS } from "@intuitionrobotics/ts-common";
|
|
4
|
+
import { MessageType } from "@intuitionrobotics/push-pub-sub";
|
|
4
5
|
export declare const fileUploadedKey = "file-uploaded";
|
|
5
|
-
export
|
|
6
|
+
export type Push_FileUploaded = MessageType<"file-uploaded", {
|
|
6
7
|
feId: string;
|
|
7
8
|
}, {
|
|
8
9
|
message: string;
|
|
9
10
|
result: string;
|
|
10
|
-
cause?:
|
|
11
|
+
cause?: any;
|
|
11
12
|
}>;
|
|
12
13
|
export declare enum UploadResult {
|
|
13
14
|
Success = "Success",
|
|
14
15
|
Failure = "Failure"
|
|
15
16
|
}
|
|
16
|
-
export
|
|
17
|
+
export type Request_Uploader = {
|
|
17
18
|
name: string;
|
|
18
19
|
mimeType: string;
|
|
19
20
|
key?: string;
|
|
20
21
|
public?: boolean;
|
|
21
22
|
metadata?: ObjectTS;
|
|
22
23
|
};
|
|
23
|
-
export
|
|
24
|
+
export type BaseUploaderFile = Request_Uploader & {
|
|
24
25
|
feId: string;
|
|
25
26
|
};
|
|
26
|
-
export
|
|
27
|
+
export type DB_Temp_File = DB_Object & BaseUploaderFile & Required<Pick<BaseUploaderFile, "key">> & {
|
|
27
28
|
path: string;
|
|
28
29
|
_audit: AuditBy;
|
|
29
30
|
bucketName: string;
|
|
30
31
|
};
|
|
31
|
-
export
|
|
32
|
-
export
|
|
32
|
+
export type Request_GetUploadUrl = BaseUploaderFile[];
|
|
33
|
+
export type TempSecureUrl = {
|
|
33
34
|
secureUrl: string;
|
|
34
35
|
tempDoc: DB_Temp_File;
|
|
35
36
|
};
|
|
36
|
-
export
|
|
37
|
+
export type Api_GetUploadUrl = ApiWithBody<"/v1/upload/get-url", BaseUploaderFile[], TempSecureUrl[]>;
|
package/shared/types.js
CHANGED
|
@@ -6,5 +6,5 @@ var UploadResult;
|
|
|
6
6
|
(function (UploadResult) {
|
|
7
7
|
UploadResult["Success"] = "Success";
|
|
8
8
|
UploadResult["Failure"] = "Failure";
|
|
9
|
-
})(UploadResult
|
|
9
|
+
})(UploadResult || (exports.UploadResult = UploadResult = {}));
|
|
10
10
|
//# sourceMappingURL=types.js.map
|
package/shared/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/main/shared/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/main/shared/types.ts"],"names":[],"mappings":";;;AAQa,QAAA,eAAe,GAAG,eAAe,CAAC;AAG/C,IAAY,YAGX;AAHD,WAAY,YAAY;IACvB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;AACpB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}
|