@nu-art/thunderstorm-backend 0.400.5
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/_entity/app-config/ModuleBE_AppConfigAPI.d.ts +9 -0
- package/_entity/app-config/ModuleBE_AppConfigAPI.js +20 -0
- package/_entity/app-config/ModuleBE_AppConfigDB.d.ts +27 -0
- package/_entity/app-config/ModuleBE_AppConfigDB.js +91 -0
- package/_entity/app-config/index.d.ts +2 -0
- package/_entity/app-config/index.js +2 -0
- package/_entity/app-config/module-pack.d.ts +2 -0
- package/_entity/app-config/module-pack.js +3 -0
- package/_entity/backup-doc/ModuleBE_BackupDocDB.d.ts +52 -0
- package/_entity/backup-doc/ModuleBE_BackupDocDB.js +350 -0
- package/_entity/backup-doc/ModuleBE_BackupScheduler.d.ts +7 -0
- package/_entity/backup-doc/ModuleBE_BackupScheduler.js +14 -0
- package/_entity/backup-doc/index.d.ts +3 -0
- package/_entity/backup-doc/index.js +3 -0
- package/_entity/backup-doc/module-pack.d.ts +2 -0
- package/_entity/backup-doc/module-pack.js +3 -0
- package/_entity/editable-test/ModuleBE_EditableTestDB.d.ts +8 -0
- package/_entity/editable-test/ModuleBE_EditableTestDB.js +8 -0
- package/_entity/editable-test/index.d.ts +1 -0
- package/_entity/editable-test/index.js +1 -0
- package/_entity/editable-test/module-pack.d.ts +1 -0
- package/_entity/editable-test/module-pack.js +3 -0
- package/_entity.d.ts +3 -0
- package/_entity.js +3 -0
- package/core/BaseStorm.d.ts +17 -0
- package/core/BaseStorm.js +77 -0
- package/core/Storm.d.ts +15 -0
- package/core/Storm.js +93 -0
- package/core/db-def.d.ts +10 -0
- package/core/db-def.js +11 -0
- package/core/default-storm.d.ts +3 -0
- package/core/default-storm.js +30 -0
- package/core/storm-modulepack.d.ts +3 -0
- package/core/storm-modulepack.js +20 -0
- package/core/typed-api.d.ts +7 -0
- package/core/typed-api.js +46 -0
- package/exceptions.d.ts +1 -0
- package/exceptions.js +21 -0
- package/index.d.ts +27 -0
- package/index.js +48 -0
- package/modules/CleanupScheduler.d.ts +14 -0
- package/modules/CleanupScheduler.js +50 -0
- package/modules/ModuleBE_APIs.d.ts +11 -0
- package/modules/ModuleBE_APIs.js +19 -0
- package/modules/ModuleBE_CSVParser.d.ts +9 -0
- package/modules/ModuleBE_CSVParser.js +50 -0
- package/modules/ModuleBE_ForceUpgrade.d.ts +21 -0
- package/modules/ModuleBE_ForceUpgrade.js +70 -0
- package/modules/ModuleBE_ServerInfo.d.ts +20 -0
- package/modules/ModuleBE_ServerInfo.js +76 -0
- package/modules/_imports.d.ts +6 -0
- package/modules/_imports.js +26 -0
- package/modules/_tdb/service-accounts.d.ts +19 -0
- package/modules/_tdb/service-accounts.js +2 -0
- package/modules/action-processor/Action_SetupProject.d.ts +9 -0
- package/modules/action-processor/Action_SetupProject.js +23 -0
- package/modules/action-processor/ModuleBE_ActionProcessor.d.ts +11 -0
- package/modules/action-processor/ModuleBE_ActionProcessor.js +67 -0
- package/modules/action-processor/types.d.ts +10 -0
- package/modules/action-processor/types.js +1 -0
- package/modules/archiving/ModuleBE_Archiving.d.ts +119 -0
- package/modules/archiving/ModuleBE_Archiving.js +236 -0
- package/modules/collection-actions/ModuleBE_CollectionActions.d.ts +12 -0
- package/modules/collection-actions/ModuleBE_CollectionActions.js +69 -0
- package/modules/collection-actions/dispatcher.d.ts +7 -0
- package/modules/collection-actions/dispatcher.js +2 -0
- package/modules/db-api-gen/ModuleBE_BaseApi.d.ts +16 -0
- package/modules/db-api-gen/ModuleBE_BaseApi.js +74 -0
- package/modules/db-api-gen/ModuleBE_BaseDB.d.ts +78 -0
- package/modules/db-api-gen/ModuleBE_BaseDB.js +298 -0
- package/modules/http/AxiosHttpModule.d.ts +25 -0
- package/modules/http/AxiosHttpModule.js +132 -0
- package/modules/http/types.d.ts +6 -0
- package/modules/http/types.js +1 -0
- package/modules/proxy/ModuleBE_RemoteProxy.d.ts +35 -0
- package/modules/proxy/ModuleBE_RemoteProxy.js +86 -0
- package/modules/proxy/RemoteProxyCaller.d.ts +19 -0
- package/modules/proxy/RemoteProxyCaller.js +82 -0
- package/modules/proxy/assert-secret-middleware.d.ts +2 -0
- package/modules/proxy/assert-secret-middleware.js +24 -0
- package/modules/server/HeaderKey.d.ts +8 -0
- package/modules/server/HeaderKey.js +41 -0
- package/modules/server/HttpServer.d.ts +41 -0
- package/modules/server/HttpServer.js +223 -0
- package/modules/server/consts.d.ts +13 -0
- package/modules/server/consts.js +9 -0
- package/modules/server/route-resolvers/RouteResolver_Dummy.d.ts +7 -0
- package/modules/server/route-resolvers/RouteResolver_Dummy.js +34 -0
- package/modules/server/route-resolvers/RouteResolver_ModulePath.d.ts +22 -0
- package/modules/server/route-resolvers/RouteResolver_ModulePath.js +84 -0
- package/modules/server/route-resolvers/index.d.ts +7 -0
- package/modules/server/route-resolvers/index.js +21 -0
- package/modules/server/server-api.d.ts +85 -0
- package/modules/server/server-api.js +362 -0
- package/modules/server/server-errors.d.ts +4 -0
- package/modules/server/server-errors.js +79 -0
- package/modules/sync-env/ModuleBE_SyncEnv.d.ts +36 -0
- package/modules/sync-env/ModuleBE_SyncEnv.js +212 -0
- package/modules/sync-manager/ModuleBE_SyncManager.d.ts +63 -0
- package/modules/sync-manager/ModuleBE_SyncManager.js +254 -0
- package/package.json +104 -0
- package/shared.d.ts +1 -0
- package/shared.js +21 -0
- package/test/StormTest.d.ts +23 -0
- package/test/StormTest.js +49 -0
- package/utils/file.d.ts +2 -0
- package/utils/file.js +29 -0
- package/utils/promisify-request.d.ts +3 -0
- package/utils/promisify-request.js +33 -0
- package/utils/types.d.ts +11 -0
- package/utils/types.js +21 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AsyncVoidFunction, Module, RecursiveObjectOfPrimitives } from '@nu-art/ts-common';
|
|
2
|
+
import { TestModel } from '@nu-art/ts-common/testing/types';
|
|
3
|
+
type StormTestConfig = {
|
|
4
|
+
databaseName?: string;
|
|
5
|
+
modules: Module[];
|
|
6
|
+
config: RecursiveObjectOfPrimitives;
|
|
7
|
+
};
|
|
8
|
+
export type StormTestInput = {
|
|
9
|
+
modules: Module[];
|
|
10
|
+
config?: RecursiveObjectOfPrimitives;
|
|
11
|
+
cleanup?: AsyncVoidFunction;
|
|
12
|
+
before?: AsyncVoidFunction;
|
|
13
|
+
after?: AsyncVoidFunction;
|
|
14
|
+
};
|
|
15
|
+
export declare class StormTest {
|
|
16
|
+
private firebaseConfig;
|
|
17
|
+
private testConfig;
|
|
18
|
+
constructor(config: StormTestConfig);
|
|
19
|
+
init(): Promise<this>;
|
|
20
|
+
cleanup(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare const stormTester: <TestCase extends TestModel<any, any>>(stormTestInput: StormTestInput, testCaseRunner: () => Promise<void>) => Promise<void>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { generateHex, ModuleManager } from '@nu-art/ts-common';
|
|
2
|
+
import { FIREBASE_DEFAULT_PROJECT_ID } from '@nu-art/firebase-backend';
|
|
3
|
+
import { RouteResolver_Dummy } from '../modules/server/route-resolvers/RouteResolver_Dummy.js';
|
|
4
|
+
import { Storm } from '../core/Storm.js';
|
|
5
|
+
import { ModuleBE_Auth } from '@nu-art/google-services-backend';
|
|
6
|
+
import { dispatcher_resetTests } from '@nu-art/ts-common/testing/consts';
|
|
7
|
+
export class StormTest {
|
|
8
|
+
firebaseConfig;
|
|
9
|
+
testConfig;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.testConfig = config;
|
|
12
|
+
const database = config.databaseName ?? `demo-test`;
|
|
13
|
+
this.firebaseConfig = {
|
|
14
|
+
project_id: generateHex(4),
|
|
15
|
+
databaseURL: `http://localhost:8102/?ns=${database}`,
|
|
16
|
+
isEmulator: true
|
|
17
|
+
};
|
|
18
|
+
process.env.FUNCTIONS_EMULATOR = 'true';
|
|
19
|
+
process.env.GCLOUD_PROJECT = database;
|
|
20
|
+
ModuleBE_Auth.setDefaultConfig({ auth: { [FIREBASE_DEFAULT_PROJECT_ID]: this.firebaseConfig } });
|
|
21
|
+
}
|
|
22
|
+
async init() {
|
|
23
|
+
new Storm({ envKey: 'local', pathToDefaultConfig: '_config/default', pathToEnvOverrideConfig: '_config/test' })
|
|
24
|
+
.addModulePack(this.testConfig.modules)
|
|
25
|
+
.setConfig({ ...this.testConfig.config, isDebug: true, })
|
|
26
|
+
.setInitialRouteResolver(new RouteResolver_Dummy())
|
|
27
|
+
.init();
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
async cleanup() {
|
|
31
|
+
await dispatcher_resetTests.dispatchModuleAsync();
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
ModuleManager.__resetForTests();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export const stormTester = async (stormTestInput, testCaseRunner) => {
|
|
37
|
+
const stormTest = new StormTest({ modules: stormTestInput.modules, config: stormTestInput.config ?? {} });
|
|
38
|
+
await stormTest.init();
|
|
39
|
+
try {
|
|
40
|
+
await stormTestInput.before?.();
|
|
41
|
+
await testCaseRunner();
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
// first we do all the applicative test cleanups, for example, delete firestore collections
|
|
45
|
+
await stormTestInput.after?.();
|
|
46
|
+
// only then we clean infra stuff, like firebase apps
|
|
47
|
+
await stormTest.cleanup();
|
|
48
|
+
}
|
|
49
|
+
};
|
package/utils/file.d.ts
ADDED
package/utils/file.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Thunderstorm is a full web app framework!
|
|
3
|
+
*
|
|
4
|
+
* Typescript & Express backend infrastructure that natively runs on firebase function
|
|
5
|
+
* Typescript & React frontend infrastructure
|
|
6
|
+
*
|
|
7
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
import * as fs from 'fs';
|
|
22
|
+
export async function fileToBase64(file) {
|
|
23
|
+
const buffer = await fs.readFileSync(file);
|
|
24
|
+
return buffer.toString('base64');
|
|
25
|
+
}
|
|
26
|
+
export async function base64ToFile(contentAsBase64, file) {
|
|
27
|
+
const bitmap = Buffer.from(contentAsBase64, 'base64');
|
|
28
|
+
await fs.writeFileSync(file, bitmap);
|
|
29
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Thunderstorm is a full web app framework!
|
|
3
|
+
*
|
|
4
|
+
* Typescript & Express backend infrastructure that natively runs on firebase function
|
|
5
|
+
* Typescript & React frontend infrastructure
|
|
6
|
+
*
|
|
7
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
import request from 'request';
|
|
22
|
+
import { __stringify, ApiException } from '@nu-art/ts-common';
|
|
23
|
+
export async function promisifyRequest(_request, throwException = true) {
|
|
24
|
+
return new Promise((resolve, rejected) => {
|
|
25
|
+
request(_request, (error, response) => {
|
|
26
|
+
if (error)
|
|
27
|
+
return rejected(new ApiException(503, `Error: ${error}\n Request: ${__stringify(_request, true)}`));
|
|
28
|
+
if (throwException && response.statusCode !== 200)
|
|
29
|
+
return rejected(new ApiException(response.statusCode, `Redirect proxy message, ${__stringify(response.body)} \n${__stringify(request, true)}`));
|
|
30
|
+
resolve(response);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
package/utils/types.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as express from 'express';
|
|
2
|
+
import { CoreOptions, UriOptions } from 'request';
|
|
3
|
+
import { ApiException } from '@nu-art/ts-common';
|
|
4
|
+
export type Express = express.Express;
|
|
5
|
+
export type ExpressRouter = express.Router;
|
|
6
|
+
export type ExpressRequest = express.Request<any>;
|
|
7
|
+
export type ExpressResponse = express.Response;
|
|
8
|
+
export type ExpressRequestHandler = express.RequestHandler;
|
|
9
|
+
export type RequestOptions = CoreOptions & UriOptions;
|
|
10
|
+
export type ServerApi_Middleware = () => Promise<any>;
|
|
11
|
+
export type HttpErrorHandler = (error: ApiException) => Promise<string>;
|
package/utils/types.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Thunderstorm is a full web app framework!
|
|
3
|
+
*
|
|
4
|
+
* Typescript & Express backend infrastructure that natively runs on firebase function
|
|
5
|
+
* Typescript & React frontend infrastructure
|
|
6
|
+
*
|
|
7
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
export {};
|