@nu-art/file-upload-shared 0.400.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.
@@ -0,0 +1,33 @@
1
+ import { ApiDef, ApiDefResolver, BodyApi, HttpMethod, QueryApi } from '@nu-art/thunderstorm-shared';
2
+ import { DB_Asset } from './types1.js';
3
+ import { DB_BaseObject } from '@nu-art/ts-common';
4
+ import { UI_Asset } from './types.js';
5
+ import { ResponseError } from '@nu-art/ts-common/core/exceptions/types';
6
+ import { FileStatus } from '../types.js';
7
+ export type SignedUrl = {
8
+ signedUrl: string;
9
+ };
10
+ export type TempSignedUrl = SignedUrl & {
11
+ asset: DB_Asset;
12
+ };
13
+ export type ApiStruct_Assets = {
14
+ vv1: {
15
+ getReadSignedUrl: BodyApi<SignedUrl, DB_BaseObject>;
16
+ };
17
+ };
18
+ export declare const ApiDef_Assets: ApiDefResolver<ApiStruct_Assets>;
19
+ export type FileUploadResult = {
20
+ status: FileStatus;
21
+ asset: DB_Asset;
22
+ };
23
+ export type Api_UploadFile = BodyApi<FileUploadResult, any, any, ResponseError, HttpMethod.PUT>;
24
+ export declare const ApiDef_UploadFile: ApiDef<Api_UploadFile>;
25
+ export type ApiStruct_AssetUploader = {
26
+ vv1: {
27
+ getUploadUrl: BodyApi<TempSignedUrl[], UI_Asset[]>;
28
+ processAssetManually: QueryApi<void[], {
29
+ feId?: string;
30
+ }>;
31
+ };
32
+ };
33
+ export declare const ApiDef_AssetUploader: ApiDefResolver<ApiStruct_AssetUploader>;
package/assets/apis.js ADDED
@@ -0,0 +1,13 @@
1
+ import { HttpMethod } from '@nu-art/thunderstorm-shared';
2
+ export const ApiDef_Assets = {
3
+ vv1: {
4
+ getReadSignedUrl: { method: HttpMethod.POST, path: 'v1/assets/get-read-signed-url' },
5
+ }
6
+ };
7
+ export const ApiDef_UploadFile = { method: HttpMethod.PUT, path: '' };
8
+ export const ApiDef_AssetUploader = {
9
+ vv1: {
10
+ getUploadUrl: { method: HttpMethod.POST, path: 'v1/upload/get-url' },
11
+ processAssetManually: { method: HttpMethod.GET, path: 'v1/upload/process-asset-manually' },
12
+ }
13
+ };
@@ -0,0 +1,5 @@
1
+ import { DBDef_V3 } from '@nu-art/ts-common';
2
+ import { DBProto_Assets, DBProto_AssetsDeleted, DBProto_AssetsTemp } from './types.js';
3
+ export declare const DBDef_Assets: DBDef_V3<DBProto_Assets>;
4
+ export declare const DBDef_TempAssets: DBDef_V3<DBProto_AssetsTemp>;
5
+ export declare const DBDef_TempDeleted: DBDef_V3<DBProto_AssetsDeleted>;
@@ -0,0 +1,59 @@
1
+ import { convertUpperCamelCase, tsValidateBoolean, tsValidateDynamicObject, tsValidateExists, tsValidateMustExist, tsValidateNonMandatoryObject, tsValidateNumber, tsValidateRegexp, tsValidateString } from '@nu-art/ts-common';
2
+ import { AssetDBGroup } from './types.js';
3
+ const Validator_ModifiableProps = {
4
+ name: tsValidateRegexp(/^.{3,}$/),
5
+ ext: tsValidateExists(true),
6
+ feId: tsValidateExists(true),
7
+ mimeType: tsValidateExists(true),
8
+ key: tsValidateExists(true),
9
+ };
10
+ const Validator_GeneratedProps = {
11
+ md5Hash: tsValidateExists(false),
12
+ path: tsValidateExists(true),
13
+ bucketName: tsValidateExists(true),
14
+ public: tsValidateBoolean(false),
15
+ metadata: tsValidateDynamicObject(tsValidateMustExist, tsValidateString(), false),
16
+ timestamp: tsValidateNumber(),
17
+ signedUrl: tsValidateNonMandatoryObject({
18
+ url: tsValidateString(),
19
+ validUntil: tsValidateNumber()
20
+ })
21
+ };
22
+ export const DBDef_Assets = {
23
+ modifiablePropsValidator: Validator_ModifiableProps,
24
+ generatedPropsValidator: Validator_GeneratedProps,
25
+ versions: ['1.0.2', '1.0.1', '1.0.0'],
26
+ dbKey: 'assets',
27
+ entityName: convertUpperCamelCase('Assets', '-').toLowerCase(),
28
+ frontend: {
29
+ group: AssetDBGroup,
30
+ name: 'asset'
31
+ },
32
+ backend: {
33
+ name: 'assets',
34
+ }
35
+ };
36
+ export const DBDef_TempAssets = {
37
+ ...DBDef_Assets,
38
+ dbKey: 'assets-temp',
39
+ entityName: 'assets-temp',
40
+ frontend: {
41
+ group: AssetDBGroup,
42
+ name: 'temp'
43
+ },
44
+ backend: {
45
+ name: 'assets-temp',
46
+ }
47
+ };
48
+ export const DBDef_TempDeleted = {
49
+ ...DBDef_Assets,
50
+ dbKey: 'assets-deleted',
51
+ entityName: 'assets-deleted',
52
+ frontend: {
53
+ group: AssetDBGroup,
54
+ name: 'deleted'
55
+ },
56
+ backend: {
57
+ name: 'assets-deleted',
58
+ }
59
+ };
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './db-def.js';
3
+ export * from './apis.js';
@@ -0,0 +1,20 @@
1
+ /*
2
+ * User secured registration and login management system..
3
+ *
4
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ export * from './types.js';
19
+ export * from './db-def.js';
20
+ export * from './apis.js';
@@ -0,0 +1,27 @@
1
+ import { PushMessage } from '@nu-art/push-pub-sub-shared';
2
+ import { DB_Asset } from './types1.js';
3
+ export declare const PushKey_FileUploaded = "file-uploaded";
4
+ export declare enum FileStatus {
5
+ Idle = "Idle",
6
+ ObtainingUrl = "ObtainingUrl",
7
+ UrlObtained = "UrlObtained",
8
+ UploadingFile = "UploadingFile",
9
+ WaitingForProcessing = "WaitingForProcessing",
10
+ Processing = "Processing",
11
+ PostProcessing = "PostProcessing",
12
+ Completed = "Completed",
13
+ ErrorWhileProcessing = "ErrorWhileProcessing",
14
+ ErrorMakingPublic = "ErrorMakingPublic",
15
+ ErrorNoValidator = "ErrorNoValidator",
16
+ ErrorNoConfig = "ErrorNoConfig",
17
+ ErrorRetrievingMetadata = "ErrorRetrievingMetadata",
18
+ Error = "Error"
19
+ }
20
+ type FileUploadResult = {
21
+ status: FileStatus;
22
+ asset: DB_Asset;
23
+ };
24
+ export type PushMessage_FileUploaded = PushMessage<'file-uploaded', {
25
+ feId: string;
26
+ }, FileUploadResult>;
27
+ export {};
@@ -0,0 +1,18 @@
1
+ export const PushKey_FileUploaded = 'file-uploaded';
2
+ export var FileStatus;
3
+ (function (FileStatus) {
4
+ FileStatus["Idle"] = "Idle";
5
+ FileStatus["ObtainingUrl"] = "ObtainingUrl";
6
+ FileStatus["UrlObtained"] = "UrlObtained";
7
+ FileStatus["UploadingFile"] = "UploadingFile";
8
+ FileStatus["WaitingForProcessing"] = "WaitingForProcessing";
9
+ FileStatus["Processing"] = "Processing";
10
+ FileStatus["PostProcessing"] = "PostProcessing";
11
+ FileStatus["Completed"] = "Completed";
12
+ FileStatus["ErrorWhileProcessing"] = "ErrorWhileProcessing";
13
+ FileStatus["ErrorMakingPublic"] = "ErrorMakingPublic";
14
+ FileStatus["ErrorNoValidator"] = "ErrorNoValidator";
15
+ FileStatus["ErrorNoConfig"] = "ErrorNoConfig";
16
+ FileStatus["ErrorRetrievingMetadata"] = "ErrorRetrievingMetadata";
17
+ FileStatus["Error"] = "Error";
18
+ })(FileStatus || (FileStatus = {}));
@@ -0,0 +1,36 @@
1
+ import { DB_Object, DBProto, Proto_DB_Object, TS_Object, VersionsDeclaration } from '@nu-art/ts-common';
2
+ export declare const AssetDBGroup = "asset";
3
+ type VersionTypes_Asset = {
4
+ '1.0.0': DB_Asset;
5
+ '1.0.1': DB_Asset;
6
+ '1.0.2': DB_Asset;
7
+ };
8
+ type Versions = VersionsDeclaration<['1.0.2', '1.0.1', '1.0.0'], VersionTypes_Asset>;
9
+ type Dependencies = {};
10
+ type UniqueKeys = '_id';
11
+ type GeneratedKeys = 'signedUrl' | 'timestamp' | 'md5Hash' | 'path' | 'bucketName' | 'public' | 'metadata';
12
+ type ProtoAssets = Proto_DB_Object<DB_Asset, 'assets', GeneratedKeys, Versions, UniqueKeys, Dependencies>;
13
+ export type DBProto_Assets = DBProto<ProtoAssets>;
14
+ type ProtoAssetsTemp = Proto_DB_Object<DB_Asset, 'assets-temp', GeneratedKeys, Versions, UniqueKeys, Dependencies>;
15
+ export type DBProto_AssetsTemp = DBProto<ProtoAssetsTemp>;
16
+ type ProtoAssetsDeleted = Proto_DB_Object<DB_Asset, 'assets-deleted', GeneratedKeys, Versions, UniqueKeys, Dependencies>;
17
+ export type DBProto_AssetsDeleted = DBProto<ProtoAssetsDeleted>;
18
+ export type UI_Asset = DBProto_Assets['uiType'];
19
+ export type DB_Asset = DB_Object & {
20
+ key: string;
21
+ name: string;
22
+ feId: string;
23
+ ext: string;
24
+ mimeType: string;
25
+ timestamp: number;
26
+ md5Hash?: string;
27
+ path: string;
28
+ bucketName: string;
29
+ public?: boolean;
30
+ metadata?: TS_Object;
31
+ signedUrl?: {
32
+ url: string;
33
+ validUntil: number;
34
+ };
35
+ };
36
+ export {};
@@ -0,0 +1 @@
1
+ export const AssetDBGroup = 'asset';
@@ -0,0 +1,33 @@
1
+ import { BaseHttpRequest } from '@nu-art/thunderstorm-shared';
2
+ import { Auditable, DB_Object, TS_Object } from '@nu-art/ts-common';
3
+ import { FileStatus } from '../types.js';
4
+ export type Request_Uploader = {
5
+ name: string;
6
+ mimeType: string;
7
+ key?: string;
8
+ public?: boolean;
9
+ metadata?: TS_Object;
10
+ };
11
+ export type BaseUploaderFile = Request_Uploader & {
12
+ feId: string;
13
+ };
14
+ export type DB_Asset = DB_Object & BaseUploaderFile & Auditable & Required<Pick<BaseUploaderFile, 'key'>> & {
15
+ timestamp: number;
16
+ ext: string;
17
+ md5Hash?: string;
18
+ path: string;
19
+ bucketName: string;
20
+ signedUrl?: {
21
+ url: string;
22
+ validUntil: number;
23
+ };
24
+ };
25
+ export type FileInfo = {
26
+ status: FileStatus;
27
+ messageStatus?: string;
28
+ progress?: number;
29
+ name: string;
30
+ request?: BaseHttpRequest<any>;
31
+ file?: any;
32
+ asset?: DB_Asset;
33
+ };
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Permissions management system, define access level for each of
3
+ * your server apis, and restrict users by giving them access levels
4
+ *
5
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
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
+ */
19
+ export {};
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './assets/index.js';
2
+ export * from './types.js';
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './assets/index.js';
2
+ export * from './types.js';
@@ -0,0 +1,45 @@
1
+ import { Dispatcher, Module } from '@nu-art/ts-common';
2
+ import { ApiDef, ApiDefCaller, BaseHttpRequest, TypedApi } from '@nu-art/thunderstorm-shared';
3
+ import { OnPushMessageReceived } from '@nu-art/push-pub-sub-shared';
4
+ import { PushMessage_Payload } from '@nu-art/push-pub-sub-shared';
5
+ import { FileStatus, PushMessage_FileUploaded } from '../assets/messages.js';
6
+ import { DB_Asset, UI_Asset } from '../assets/types.js';
7
+ import { ApiStruct_AssetUploader, TempSignedUrl } from '../assets/apis.js';
8
+ import { OnFileStatusChanged } from '../types.js';
9
+ export type FilesToUpload = UI_Asset & {
10
+ file: any;
11
+ };
12
+ export type FileInfo = {
13
+ status: FileStatus;
14
+ messageStatus?: string;
15
+ progress?: number;
16
+ name: string;
17
+ request?: BaseHttpRequest<any>;
18
+ file?: any;
19
+ asset?: DB_Asset;
20
+ };
21
+ export type UploaderConfig = {
22
+ manualProcessTriggering: boolean;
23
+ uploadQueueParallelCount?: number;
24
+ };
25
+ export declare abstract class ModuleBase_AssetUploader<Config extends UploaderConfig = UploaderConfig> extends Module<Config> implements OnPushMessageReceived<PushMessage_FileUploaded> {
26
+ protected vv1: ApiDefCaller<ApiStruct_AssetUploader>['vv1'];
27
+ protected files: {
28
+ [id: string]: FileInfo;
29
+ };
30
+ private readonly uploadQueue;
31
+ protected readonly dispatch_fileStatusChange: Dispatcher<OnFileStatusChanged, "__onFileStatusChanged", [id: string], void>;
32
+ protected constructor();
33
+ __onMessageReceived(notification: PushMessage_Payload<PushMessage_FileUploaded>): void;
34
+ init(): void;
35
+ protected abstract subscribeToPush(toSubscribe: TempSignedUrl[]): Promise<void>;
36
+ getFileInfo<K extends keyof FileInfo>(id: string, key: K): FileInfo[K] | undefined;
37
+ getFullFileInfo(id?: string): FileInfo | undefined;
38
+ protected setFileInfo<K extends keyof FileInfo>(feId: string, values: Partial<FileInfo>): void;
39
+ protected dispatchFileStatusChange(id: string): void;
40
+ uploadImpl(files: FilesToUpload[]): UI_Asset[];
41
+ private uploadFiles;
42
+ private uploadFile;
43
+ processAssetManually: (feId?: string) => void;
44
+ protected abstract createRequest<API extends TypedApi<any, any, any, any>>(uploadFile: ApiDef<API>): BaseHttpRequest<API>;
45
+ }
@@ -0,0 +1,142 @@
1
+ /*
2
+ * Permissions management system, define access level for each of
3
+ * your server apis, and restrict users by giving them access levels
4
+ *
5
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
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
+ */
19
+ import { __stringify, _keys, BadImplementationException, Dispatcher, Minute, Module, Queue } from '@nu-art/ts-common';
20
+ import { HeaderKey_ContentType } from '@nu-art/thunderstorm-shared';
21
+ import { FileStatus, PushKey_FileUploaded } from '../assets/messages.js';
22
+ import { ApiDef_UploadFile } from '../assets/apis.js';
23
+ export class ModuleBase_AssetUploader extends Module {
24
+ vv1;
25
+ files = {};
26
+ uploadQueue = new Queue('File Uploader').setParallelCount(1);
27
+ dispatch_fileStatusChange = new Dispatcher('__onFileStatusChanged');
28
+ constructor() {
29
+ super();
30
+ this.setDefaultConfig({ manualProcessTriggering: false });
31
+ }
32
+ __onMessageReceived(notification) {
33
+ if (notification.topic !== PushKey_FileUploaded)
34
+ return;
35
+ const data = notification.message;
36
+ if (!data)
37
+ return this.logError('file upload push without data');
38
+ const feId = data.asset.feId;
39
+ if (!feId)
40
+ return this.logError('file upload push without feId');
41
+ this.setFileInfo(feId, data);
42
+ }
43
+ init() {
44
+ if (this.config.uploadQueueParallelCount)
45
+ this.uploadQueue.setParallelCount(this.config.uploadQueueParallelCount);
46
+ }
47
+ getFileInfo(id, key) {
48
+ return this.files[id] && this.files[id][key];
49
+ }
50
+ getFullFileInfo(id) {
51
+ if (!id)
52
+ return undefined;
53
+ return this.files[id];
54
+ }
55
+ setFileInfo(feId, values) {
56
+ const fileInfo = this.files[feId];
57
+ if (!fileInfo)
58
+ return this.logError(`file upload push received, but no file info exists for ${feId}`);
59
+ _keys(values).forEach(key => fileInfo[key] = values[key]);
60
+ this.dispatchFileStatusChange(feId);
61
+ }
62
+ dispatchFileStatusChange(id) {
63
+ this.dispatch_fileStatusChange.dispatchModule(id);
64
+ }
65
+ uploadImpl(files) {
66
+ const body = files.map(fileData => {
67
+ const { file, ...fileInfo } = fileData;
68
+ this.files[fileInfo.feId] = {
69
+ file,
70
+ status: FileStatus.ObtainingUrl,
71
+ name: fileData.name
72
+ };
73
+ return fileInfo;
74
+ });
75
+ this.vv1.getUploadUrl?.(body)
76
+ .execute(async (response) => {
77
+ body.forEach(f => this.setFileInfo(f.feId, { status: FileStatus.UrlObtained }));
78
+ if (!response)
79
+ return;
80
+ // Not a relevant await but still...
81
+ await this.uploadFiles(response);
82
+ });
83
+ return body;
84
+ }
85
+ uploadFiles = async (response) => {
86
+ // Subscribe
87
+ await this.subscribeToPush(response);
88
+ response.forEach(r => {
89
+ const feId = r.asset.feId;
90
+ this.uploadQueue.addItem(async () => {
91
+ await this.uploadFile(r);
92
+ delete this.files[feId].file;
93
+ this.setFileInfo(feId, { progress: 0 });
94
+ //TODO: Probably need to set a timer here in case we dont get a push back (contingency)
95
+ }, () => {
96
+ this.setFileInfo(feId, { status: FileStatus.WaitingForProcessing });
97
+ if (this.config.manualProcessTriggering)
98
+ this.processAssetManually(feId);
99
+ }, error => {
100
+ this.setFileInfo(feId, {
101
+ messageStatus: __stringify(error),
102
+ status: FileStatus.Error
103
+ });
104
+ });
105
+ });
106
+ };
107
+ uploadFile = async (response) => {
108
+ const feId = response.asset.feId;
109
+ this.setFileInfo(feId, {
110
+ status: FileStatus.UploadingFile,
111
+ asset: response.asset
112
+ });
113
+ const fileInfo = this.files[feId];
114
+ if (!fileInfo)
115
+ throw new BadImplementationException(`Missing file with id ${feId} and name: ${response.asset.name}`);
116
+ const request = this.createRequest(ApiDef_UploadFile)
117
+ .setUrl(response.signedUrl)
118
+ .setHeader(HeaderKey_ContentType, response.asset.mimeType)
119
+ .setTimeout(20 * Minute)
120
+ .setBody(fileInfo.file)
121
+ .setOnProgressListener((ev) => {
122
+ this.setFileInfo(feId, { progress: ev.loaded / ev.total });
123
+ });
124
+ fileInfo.request = request;
125
+ await request.executeSync();
126
+ // const request = this.vv1.uploadFile(fileInfo.file, undefined as never)
127
+ // .setUrl(response.signedUrl);
128
+ // const request = this
129
+ // .httpModule
130
+ // .createRequest(HttpMethod.PUT, RequestKey_UploadFile, feId)
131
+ };
132
+ processAssetManually = (feId) => {
133
+ const request = this.vv1.processAssetManually({ feId });
134
+ // const request = this
135
+ // .httpModule
136
+ // .createRequest<Api_ProcessAssetManually>(HttpMethod.GET, RequestKey_ProcessAssetManually, feId)
137
+ // .setRelativeUrl('v1/upload/process-asset-manually');
138
+ if (feId)
139
+ request.setUrlParam('feId', feId);
140
+ request.execute();
141
+ };
142
+ }
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@nu-art/file-upload-shared",
3
+ "version": "0.400.7",
4
+ "description": "File Uploader - Express & Typescript based backend framework Shared",
5
+ "keywords": [
6
+ "TacB0sS",
7
+ "infra",
8
+ "nu-art",
9
+ "storm",
10
+ "thunderstorm",
11
+ "typescript"
12
+ ],
13
+ "homepage": "https://github.com/nu-art-js/file-upload",
14
+ "bugs": {
15
+ "url": "https://github.com/nu-art-js/file-upload/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+ssh://git@github.com:nu-art-js/file-upload.git"
20
+ },
21
+ "publishConfig": {
22
+ "directory": "dist",
23
+ "linkDirectory": true
24
+ },
25
+ "license": "Apache-2.0",
26
+ "author": "TacB0sS",
27
+ "files": [
28
+ "**/*"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsc"
32
+ },
33
+ "dependencies": {
34
+ "@nu-art/firebase-shared": "0.400.7",
35
+ "@nu-art/ts-styles": "0.400.7",
36
+ "@nu-art/push-pub-sub-shared": "0.400.7",
37
+ "@nu-art/permissions-shared": "0.400.7",
38
+ "@nu-art/user-account-shared": "0.400.7",
39
+ "@nu-art/thunderstorm-shared": "0.400.7",
40
+ "@nu-art/ts-common": "0.400.7",
41
+ "@google-cloud/common": "^5.0.2",
42
+ "@google-cloud/storage": "^7.15.0",
43
+ "@google-cloud/firestore": "^7.11.0",
44
+ "react": "^18.0.0",
45
+ "jszip": "^3.2.2",
46
+ "express": "^4.18.2",
47
+ "firebase": "^11.9.0",
48
+ "firebase-admin": "13.4.0",
49
+ "firebase-functions": "6.3.2",
50
+ "google-auth-library": "^10.0.0",
51
+ "file-type": "^21.0.0"
52
+ },
53
+ "devDependencies": {
54
+ "@types/react": "^18.0.0",
55
+ "@types/compression": "^1.0.1",
56
+ "@types/express": "^4.17.17"
57
+ },
58
+ "unitConfig": {
59
+ "type": "typescript-lib"
60
+ },
61
+ "type": "module",
62
+ "exports": {
63
+ ".": {
64
+ "types": "./index.d.ts",
65
+ "import": "./index.js"
66
+ },
67
+ "./*": {
68
+ "types": "./*.d.ts",
69
+ "import": "./*.js"
70
+ }
71
+ }
72
+ }
package/types.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export declare const PushKey_FileUploaded = "file-uploaded";
2
+ export declare enum FileStatus {
3
+ Idle = "Idle",
4
+ ObtainingUrl = "ObtainingUrl",
5
+ UrlObtained = "UrlObtained",
6
+ UploadingFile = "UploadingFile",
7
+ WaitingForProcessing = "WaitingForProcessing",
8
+ Processing = "Processing",
9
+ PostProcessing = "PostProcessing",
10
+ Completed = "Completed",
11
+ ErrorWhileProcessing = "ErrorWhileProcessing",
12
+ ErrorMakingPublic = "ErrorMakingPublic",
13
+ ErrorNoValidator = "ErrorNoValidator",
14
+ ErrorNoConfig = "ErrorNoConfig",
15
+ ErrorRetrievingMetadata = "ErrorRetrievingMetadata",
16
+ Error = "Error"
17
+ }
18
+ export interface OnFileStatusChanged {
19
+ __onFileStatusChanged: (id: string) => void;
20
+ }
package/types.js ADDED
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Permissions management system, define access level for each of
3
+ * your server apis, and restrict users by giving them access levels
4
+ *
5
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
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
+ */
19
+ export const PushKey_FileUploaded = 'file-uploaded';
20
+ export var FileStatus;
21
+ (function (FileStatus) {
22
+ FileStatus["Idle"] = "Idle";
23
+ FileStatus["ObtainingUrl"] = "ObtainingUrl";
24
+ FileStatus["UrlObtained"] = "UrlObtained";
25
+ FileStatus["UploadingFile"] = "UploadingFile";
26
+ FileStatus["WaitingForProcessing"] = "WaitingForProcessing";
27
+ FileStatus["Processing"] = "Processing";
28
+ FileStatus["PostProcessing"] = "PostProcessing";
29
+ FileStatus["Completed"] = "Completed";
30
+ FileStatus["ErrorWhileProcessing"] = "ErrorWhileProcessing";
31
+ FileStatus["ErrorMakingPublic"] = "ErrorMakingPublic";
32
+ FileStatus["ErrorNoValidator"] = "ErrorNoValidator";
33
+ FileStatus["ErrorNoConfig"] = "ErrorNoConfig";
34
+ FileStatus["ErrorRetrievingMetadata"] = "ErrorRetrievingMetadata";
35
+ FileStatus["Error"] = "Error";
36
+ })(FileStatus || (FileStatus = {}));