@naturalcycles/backend-lib 4.23.1 → 4.23.3
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/cfg/tsconfig.json +2 -2
- package/dist/db/httpDB.d.ts +2 -1
- package/dist/db/httpDB.js +10 -0
- package/dist/deploy/backend.cfg.util.js +1 -3
- package/dist/deploy/deployPrepare.js +2 -2
- package/package.json +2 -4
- package/src/db/httpDB.ts +14 -1
- package/src/db/httpDBRequestHandler.ts +1 -1
- package/src/deploy/backend.cfg.util.ts +2 -3
- package/src/deploy/deployPrepare.ts +3 -3
package/cfg/tsconfig.json
CHANGED
package/dist/db/httpDB.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseCommonDB, CommonDB, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, DBQuery, RunQueryResult } from '@naturalcycles/db-lib';
|
|
1
|
+
import { BaseCommonDB, CommonDB, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, CommonDBSupport, DBQuery, RunQueryResult } from '@naturalcycles/db-lib';
|
|
2
2
|
import { FetcherOptions, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib';
|
|
3
3
|
import { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
4
4
|
export interface HttpDBCfg extends FetcherOptions {
|
|
@@ -9,6 +9,7 @@ export interface HttpDBCfg extends FetcherOptions {
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class HttpDB extends BaseCommonDB implements CommonDB {
|
|
11
11
|
cfg: HttpDBCfg;
|
|
12
|
+
support: CommonDBSupport;
|
|
12
13
|
constructor(cfg: HttpDBCfg);
|
|
13
14
|
setCfg(cfg: HttpDBCfg): void;
|
|
14
15
|
private fetcher;
|
package/dist/db/httpDB.js
CHANGED
|
@@ -11,6 +11,16 @@ class HttpDB extends db_lib_1.BaseCommonDB {
|
|
|
11
11
|
constructor(cfg) {
|
|
12
12
|
super();
|
|
13
13
|
this.cfg = cfg;
|
|
14
|
+
this.support = {
|
|
15
|
+
...db_lib_1.commonDBFullSupport,
|
|
16
|
+
streaming: false,
|
|
17
|
+
createTable: false,
|
|
18
|
+
bufferValues: false,
|
|
19
|
+
updateSaveMethod: false,
|
|
20
|
+
insertSaveMethod: false,
|
|
21
|
+
transactions: false,
|
|
22
|
+
updateByQuery: false,
|
|
23
|
+
};
|
|
14
24
|
this.setCfg(cfg);
|
|
15
25
|
}
|
|
16
26
|
setCfg(cfg) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBackendCfg = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
|
-
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
7
5
|
const paths_cnst_1 = require("../paths.cnst");
|
|
8
6
|
const backendCfgSchema = nodejs_lib_1.AjvSchema.readJsonSync(`${paths_cnst_1.resourcesDir}/backendCfg.schema.json`, {
|
|
9
7
|
objectName: 'backend.cfg.yaml',
|
|
@@ -13,7 +11,7 @@ function getBackendCfg(projectDir = '.') {
|
|
|
13
11
|
(0, nodejs_lib_1.requireFileToExist)(backendCfgYamlPath);
|
|
14
12
|
const backendCfg = {
|
|
15
13
|
serviceWithBranchName: true,
|
|
16
|
-
...
|
|
14
|
+
...nodejs_lib_1.fs2.readYaml(backendCfgYamlPath),
|
|
17
15
|
};
|
|
18
16
|
backendCfgSchema.validate(backendCfg);
|
|
19
17
|
return backendCfg;
|
|
@@ -58,7 +58,7 @@ async function deployPrepare(opt = {}) {
|
|
|
58
58
|
const appYamlPassEnv = opt.appYamlPassEnv || backendCfg.appYamlPassEnv;
|
|
59
59
|
console.log(`1. Copy files to ${(0, nodejs_lib_1.dimGrey)(targetDir)}`);
|
|
60
60
|
// Clean targetDir
|
|
61
|
-
|
|
61
|
+
nodejs_lib_1.fs2.emptyDir(targetDir);
|
|
62
62
|
(0, nodejs_lib_1.kpySync)({
|
|
63
63
|
baseDir: defaultFilesDir,
|
|
64
64
|
outputDir: targetDir,
|
|
@@ -74,7 +74,7 @@ async function deployPrepare(opt = {}) {
|
|
|
74
74
|
if (NPM_TOKEN && createNpmrc) {
|
|
75
75
|
const npmrcPath = `${targetDir}/.npmrc`;
|
|
76
76
|
const npmrc = `//registry.npmjs.org/:_authToken=${NPM_TOKEN}`;
|
|
77
|
-
|
|
77
|
+
nodejs_lib_1.fs2.writeFile(npmrcPath, npmrc);
|
|
78
78
|
}
|
|
79
79
|
console.log(`2. Generate ${(0, nodejs_lib_1.dimGrey)('deployInfo.json')} and ${(0, nodejs_lib_1.dimGrey)('app.yaml')} in targetDir`);
|
|
80
80
|
const deployInfo = await (0, deploy_util_1.createAndSaveDeployInfo)(backendCfg, targetDir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/backend-lib",
|
|
3
|
-
"version": "4.23.
|
|
3
|
+
"version": "4.23.3",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"serve": "APP_ENV=dev nodemon",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@sentry/node": "^7.0.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@naturalcycles/db-lib": "^
|
|
19
|
+
"@naturalcycles/db-lib": "^9.1.0",
|
|
20
20
|
"@naturalcycles/js-lib": "^14.27.0",
|
|
21
21
|
"@naturalcycles/nodejs-lib": "^13.1.0",
|
|
22
22
|
"@types/cookie-parser": "^1.4.1",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"express-promise-router": "^4.0.0",
|
|
32
32
|
"firebase-admin": "^12.0.0",
|
|
33
33
|
"helmet": "^7.0.0",
|
|
34
|
-
"js-yaml": "^4.0.0",
|
|
35
34
|
"on-finished": "^2.3.0",
|
|
36
35
|
"simple-git": "^3.0.3",
|
|
37
36
|
"yargs": "^17.0.0"
|
|
@@ -41,7 +40,6 @@
|
|
|
41
40
|
"@naturalcycles/dev-lib": "^13.0.0",
|
|
42
41
|
"@sentry/node": "^7.0.0",
|
|
43
42
|
"@types/ejs": "^3.0.0",
|
|
44
|
-
"@types/js-yaml": "^4.0.0",
|
|
45
43
|
"@types/node": "^20.1.0",
|
|
46
44
|
"@types/yargs": "^16.0.0",
|
|
47
45
|
"fastify": "^4.0.0",
|
package/src/db/httpDB.ts
CHANGED
|
@@ -2,9 +2,11 @@ import { Readable } from 'node:stream'
|
|
|
2
2
|
import {
|
|
3
3
|
BaseCommonDB,
|
|
4
4
|
CommonDB,
|
|
5
|
+
commonDBFullSupport,
|
|
5
6
|
CommonDBOptions,
|
|
6
7
|
CommonDBSaveOptions,
|
|
7
8
|
CommonDBStreamOptions,
|
|
9
|
+
CommonDBSupport,
|
|
8
10
|
DBQuery,
|
|
9
11
|
RunQueryResult,
|
|
10
12
|
} from '@naturalcycles/db-lib'
|
|
@@ -25,6 +27,17 @@ export interface HttpDBCfg extends FetcherOptions {
|
|
|
25
27
|
* Implementation of CommonDB that proxies all requests via HTTP to "httpDBRequestHandler".
|
|
26
28
|
*/
|
|
27
29
|
export class HttpDB extends BaseCommonDB implements CommonDB {
|
|
30
|
+
override support: CommonDBSupport = {
|
|
31
|
+
...commonDBFullSupport,
|
|
32
|
+
streaming: false,
|
|
33
|
+
createTable: false,
|
|
34
|
+
bufferValues: false,
|
|
35
|
+
updateSaveMethod: false,
|
|
36
|
+
insertSaveMethod: false,
|
|
37
|
+
transactions: false,
|
|
38
|
+
updateByQuery: false,
|
|
39
|
+
}
|
|
40
|
+
|
|
28
41
|
constructor(public cfg: HttpDBCfg) {
|
|
29
42
|
super()
|
|
30
43
|
this.setCfg(cfg)
|
|
@@ -106,7 +119,7 @@ export class HttpDB extends BaseCommonDB implements CommonDB {
|
|
|
106
119
|
})
|
|
107
120
|
}
|
|
108
121
|
|
|
109
|
-
async deleteByIds(table: string, ids: string[], opt?: CommonDBOptions): Promise<number> {
|
|
122
|
+
override async deleteByIds(table: string, ids: string[], opt?: CommonDBOptions): Promise<number> {
|
|
110
123
|
return await this.fetcher.put(`deleteByIds`, {
|
|
111
124
|
json: {
|
|
112
125
|
table,
|
|
@@ -75,7 +75,7 @@ export function httpDBRequestHandler(db: CommonDB): BackendRouter {
|
|
|
75
75
|
|
|
76
76
|
// getTableSchema
|
|
77
77
|
router.get('/:table/schema', async (req, res) => {
|
|
78
|
-
res.json(await db.getTableSchema(req.params['table']
|
|
78
|
+
res.json(await db.getTableSchema(req.params['table']))
|
|
79
79
|
})
|
|
80
80
|
|
|
81
81
|
// todo: createTable
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { StringMap } from '@naturalcycles/js-lib'
|
|
2
|
-
import {
|
|
3
|
-
import yaml from 'js-yaml'
|
|
2
|
+
import { AjvSchema, fs2, requireFileToExist } from '@naturalcycles/nodejs-lib'
|
|
4
3
|
import { resourcesDir } from '../paths.cnst'
|
|
5
4
|
|
|
6
5
|
export interface BackendCfg {
|
|
@@ -63,7 +62,7 @@ export function getBackendCfg(projectDir: string = '.'): BackendCfg {
|
|
|
63
62
|
|
|
64
63
|
const backendCfg: BackendCfg = {
|
|
65
64
|
serviceWithBranchName: true,
|
|
66
|
-
...
|
|
65
|
+
...fs2.readYaml(backendCfgYamlPath),
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
backendCfgSchema.validate(backendCfg)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dimGrey, fs2, kpySync } from '@naturalcycles/nodejs-lib'
|
|
2
2
|
import { srcDir } from '../paths.cnst'
|
|
3
3
|
import { getBackendCfg } from './backend.cfg.util'
|
|
4
4
|
import { DeployInfo } from './deploy.model'
|
|
@@ -75,7 +75,7 @@ export async function deployPrepare(opt: DeployPrepareOptions = {}): Promise<Dep
|
|
|
75
75
|
console.log(`1. Copy files to ${dimGrey(targetDir)}`)
|
|
76
76
|
|
|
77
77
|
// Clean targetDir
|
|
78
|
-
|
|
78
|
+
fs2.emptyDir(targetDir)
|
|
79
79
|
|
|
80
80
|
kpySync({
|
|
81
81
|
baseDir: defaultFilesDir,
|
|
@@ -94,7 +94,7 @@ export async function deployPrepare(opt: DeployPrepareOptions = {}): Promise<Dep
|
|
|
94
94
|
if (NPM_TOKEN && createNpmrc) {
|
|
95
95
|
const npmrcPath = `${targetDir}/.npmrc`
|
|
96
96
|
const npmrc = `//registry.npmjs.org/:_authToken=${NPM_TOKEN}`
|
|
97
|
-
|
|
97
|
+
fs2.writeFile(npmrcPath, npmrc)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
console.log(`2. Generate ${dimGrey('deployInfo.json')} and ${dimGrey('app.yaml')} in targetDir`)
|