@datatruck/cli 0.30.1 → 0.31.0
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/CHANGELOG.md +8 -0
- package/Command/BackupCommand.d.ts +1 -1
- package/Command/CleanCacheCommand.d.ts +1 -1
- package/Command/CommandAbstract.d.ts +2 -1
- package/Command/CommandAbstract.js +3 -1
- package/Command/CopyCommand.d.ts +1 -1
- package/Command/RestoreCommand.d.ts +1 -1
- package/Command/StartServerCommand.js +30 -8
- package/Config/Config.d.ts +7 -1
- package/Config/Config.js +79 -26
- package/Config/RepositoryConfig.d.ts +1 -0
- package/Config/RepositoryConfig.js +6 -1
- package/Factory/CommandFactory.d.ts +1 -1
- package/Factory/CommandFactory.js +2 -2
- package/JsonSchema/backup-def.d.ts +30 -0
- package/JsonSchema/backup-def.js +18 -0
- package/JsonSchema/copy-def.d.ts +24 -0
- package/JsonSchema/copy-def.js +15 -0
- package/cli.js +1 -1
- package/config.schema.json +189 -39
- package/package.json +2 -1
- package/utils/cli.d.ts +3 -0
- package/utils/cli.js +21 -1
- package/utils/datatruck/client.js +3 -3
- package/utils/datatruck/cron-server.d.ts +23 -0
- package/utils/datatruck/cron-server.js +59 -0
- package/utils/datatruck/{server.d.ts → repository-server.d.ts} +11 -5
- package/utils/datatruck/{server.js → repository-server.js} +43 -26
- package/utils/http.d.ts +8 -2
- package/utils/http.js +12 -14
- package/utils/object.d.ts +1 -1
- package/utils/object.js +6 -6
- package/utils/schema.d.ts +34 -0
- package/utils/schema.js +36 -0
- package/utils/string.d.ts +0 -3
- package/utils/string.js +1 -37
- package/utils/ObjectVault.d.ts +0 -13
- package/utils/ObjectVault.js +0 -29
package/utils/object.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.groupBy = exports.getErrorProperties = exports.
|
|
3
|
+
exports.groupBy = exports.getErrorProperties = exports.omitProp = exports.merge = void 0;
|
|
4
4
|
function merge(target, ...sources) {
|
|
5
5
|
const isObject = (o) => typeof o === "object" && o !== null;
|
|
6
6
|
for (const source of sources)
|
|
@@ -13,12 +13,12 @@ function merge(target, ...sources) {
|
|
|
13
13
|
return target;
|
|
14
14
|
}
|
|
15
15
|
exports.merge = merge;
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
function omitProp(object, name) {
|
|
17
|
+
const result = { ...object };
|
|
18
|
+
delete result[name];
|
|
19
|
+
return result;
|
|
20
20
|
}
|
|
21
|
-
exports.
|
|
21
|
+
exports.omitProp = omitProp;
|
|
22
22
|
function getErrorProperties(error) {
|
|
23
23
|
const alt = {};
|
|
24
24
|
for (const key of Object.getOwnPropertyNames(error)) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { JSONSchema7 } from "json-schema";
|
|
2
|
+
export declare function omitPropertySchema<T extends {
|
|
3
|
+
properties: Record<string, any>;
|
|
4
|
+
}, N extends keyof T["properties"]>(object: T, name: N): Omit<T, "properties"> & {
|
|
5
|
+
properties: Omit<T["properties"], N>;
|
|
6
|
+
};
|
|
7
|
+
type IfSchema<KType extends string, KValue extends string, T extends string, V extends JSONSchema7> = {
|
|
8
|
+
if: {
|
|
9
|
+
type: "object";
|
|
10
|
+
properties: {
|
|
11
|
+
[k in KType]: {
|
|
12
|
+
const: T;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
then: {
|
|
17
|
+
type: "object";
|
|
18
|
+
properties: {
|
|
19
|
+
[k in KValue]: V;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
else: false;
|
|
23
|
+
};
|
|
24
|
+
export declare function createCaseSchema<KType extends string, KValue extends string, V extends {
|
|
25
|
+
[K in KType]: JSONSchema7;
|
|
26
|
+
}>(keys: {
|
|
27
|
+
type: KType;
|
|
28
|
+
value: KValue;
|
|
29
|
+
}, value: V): IfSchema<KType, KValue, string, JSONSchema7>[];
|
|
30
|
+
export declare function createIfSchema<KType extends string, KValue extends string, T extends string, V extends JSONSchema7>(keys: {
|
|
31
|
+
type: KType;
|
|
32
|
+
value: KValue;
|
|
33
|
+
}, type: T, value: V): IfSchema<KType, KValue, T, V>;
|
|
34
|
+
export {};
|
package/utils/schema.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createIfSchema = exports.createCaseSchema = exports.omitPropertySchema = void 0;
|
|
4
|
+
const object_1 = require("./object");
|
|
5
|
+
function omitPropertySchema(object, name) {
|
|
6
|
+
return {
|
|
7
|
+
...object,
|
|
8
|
+
properties: (0, object_1.omitProp)(object.properties, name),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.omitPropertySchema = omitPropertySchema;
|
|
12
|
+
function createCaseSchema(keys, value) {
|
|
13
|
+
return Object.entries(value).reduce((schemas, [type, value]) => {
|
|
14
|
+
schemas.push(createIfSchema(keys, type, value));
|
|
15
|
+
return schemas;
|
|
16
|
+
}, []);
|
|
17
|
+
}
|
|
18
|
+
exports.createCaseSchema = createCaseSchema;
|
|
19
|
+
function createIfSchema(keys, type, value) {
|
|
20
|
+
return {
|
|
21
|
+
if: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
[keys.type]: { const: type },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
then: {
|
|
28
|
+
type: "object",
|
|
29
|
+
properties: {
|
|
30
|
+
[keys.value]: value,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
else: false,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
exports.createIfSchema = createIfSchema;
|
package/utils/string.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare function serialize(message: string, data?: Object): string;
|
|
2
1
|
export declare function snakeCase(value: string, char?: string): string;
|
|
3
2
|
export declare function render(subject: string, vars: Record<string, string | undefined>): string;
|
|
4
3
|
type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
@@ -12,12 +11,10 @@ export type UriType = {
|
|
|
12
11
|
path?: string;
|
|
13
12
|
};
|
|
14
13
|
export declare function formatUri(input: UriType, hidePassword?: boolean): string;
|
|
15
|
-
export declare function formatSeconds(seconds: number): string;
|
|
16
14
|
export declare function makePathPatterns(values: string[] | undefined): string[] | undefined;
|
|
17
15
|
export declare function match(path: string, include?: string[], exclude?: string[]): boolean;
|
|
18
16
|
export declare function endsWith(input: string, patterns: string[]): boolean;
|
|
19
17
|
export declare function createMatchFilter(include?: string[], exclude?: string[]): (input: string) => boolean;
|
|
20
18
|
export declare function checkMatch(subject: string | undefined, patterns: string[]): boolean;
|
|
21
|
-
export declare function formatDateTime(datetime: string): string;
|
|
22
19
|
export declare function undefIfEmpty(input: string): string | undefined;
|
|
23
20
|
export {};
|
package/utils/string.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.undefIfEmpty = exports.
|
|
3
|
+
exports.undefIfEmpty = exports.checkMatch = exports.createMatchFilter = exports.endsWith = exports.match = exports.makePathPatterns = exports.formatUri = exports.parseStringList = exports.render = exports.snakeCase = void 0;
|
|
4
4
|
const AppError_1 = require("../Error/AppError");
|
|
5
5
|
const micromatch_1 = require("micromatch");
|
|
6
|
-
function serialize(message, data) {
|
|
7
|
-
if (data)
|
|
8
|
-
return `${message} (${JSON.stringify(data, null, 2)})`;
|
|
9
|
-
return message;
|
|
10
|
-
}
|
|
11
|
-
exports.serialize = serialize;
|
|
12
6
|
function snakeCase(value, char = "_") {
|
|
13
7
|
return value.replace(/[A-Z]/g, (letter) => `${char}${letter.toLowerCase()}`);
|
|
14
8
|
}
|
|
@@ -61,26 +55,6 @@ function formatUri(input, hidePassword) {
|
|
|
61
55
|
return uri;
|
|
62
56
|
}
|
|
63
57
|
exports.formatUri = formatUri;
|
|
64
|
-
function formatSeconds(seconds) {
|
|
65
|
-
let unit;
|
|
66
|
-
let value;
|
|
67
|
-
if (seconds > 60 * 60) {
|
|
68
|
-
value = seconds / 60 / 60;
|
|
69
|
-
unit = `hour`;
|
|
70
|
-
}
|
|
71
|
-
else if (seconds > 60) {
|
|
72
|
-
value = seconds / 60;
|
|
73
|
-
unit = `minute`;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
value = seconds;
|
|
77
|
-
unit = `second`;
|
|
78
|
-
}
|
|
79
|
-
if (value !== 1)
|
|
80
|
-
unit += `s`;
|
|
81
|
-
return `${value.toFixed(2)} ${unit}`;
|
|
82
|
-
}
|
|
83
|
-
exports.formatSeconds = formatSeconds;
|
|
84
58
|
function makePathPatterns(values) {
|
|
85
59
|
return values?.flatMap((v) => {
|
|
86
60
|
if (v === "*" || v === "**" || v === "<empty>" || v === "!<empty>") {
|
|
@@ -111,16 +85,6 @@ function checkMatch(subject, patterns) {
|
|
|
111
85
|
return (0, micromatch_1.isMatch)(subject, patterns);
|
|
112
86
|
}
|
|
113
87
|
exports.checkMatch = checkMatch;
|
|
114
|
-
function formatDateTime(datetime) {
|
|
115
|
-
const date = new Date(datetime);
|
|
116
|
-
const [result] = new Date(date.getTime() - date.getTimezoneOffset() * 60000)
|
|
117
|
-
.toISOString()
|
|
118
|
-
.replace("Z", "")
|
|
119
|
-
.replace("T", " ")
|
|
120
|
-
.split(".");
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
exports.formatDateTime = formatDateTime;
|
|
124
88
|
function undefIfEmpty(input) {
|
|
125
89
|
return input.length ? input : undefined;
|
|
126
90
|
}
|
package/utils/ObjectVault.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type KeysType = (string | number)[];
|
|
2
|
-
export declare class ObjectVault<TObject> {
|
|
3
|
-
protected counter: number;
|
|
4
|
-
protected readonly ids: Record<string, number>;
|
|
5
|
-
protected readonly objects: Record<number, TObject>;
|
|
6
|
-
static serializeKeys(keys: KeysType): string;
|
|
7
|
-
get(id: number): TObject;
|
|
8
|
-
getId(keys: KeysType): number;
|
|
9
|
-
add(options: {
|
|
10
|
-
keys: KeysType;
|
|
11
|
-
handler: (id: number) => TObject;
|
|
12
|
-
}): TObject;
|
|
13
|
-
}
|
package/utils/ObjectVault.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ObjectVault = void 0;
|
|
4
|
-
class ObjectVault {
|
|
5
|
-
counter = 0;
|
|
6
|
-
ids = {};
|
|
7
|
-
objects = {};
|
|
8
|
-
static serializeKeys(keys) {
|
|
9
|
-
return JSON.stringify(keys);
|
|
10
|
-
}
|
|
11
|
-
get(id) {
|
|
12
|
-
if (!(id in this.objects))
|
|
13
|
-
throw new Error(`Object not found: ${id}`);
|
|
14
|
-
return this.objects[id];
|
|
15
|
-
}
|
|
16
|
-
getId(keys) {
|
|
17
|
-
const key = ObjectVault.serializeKeys(keys);
|
|
18
|
-
const id = this.ids[key];
|
|
19
|
-
if (!id)
|
|
20
|
-
throw new Error(`Id not found: ${JSON.stringify(keys)}`);
|
|
21
|
-
return id;
|
|
22
|
-
}
|
|
23
|
-
add(options) {
|
|
24
|
-
const key = ObjectVault.serializeKeys(options.keys);
|
|
25
|
-
const id = (this.ids[key] = ++this.counter);
|
|
26
|
-
return (this.objects[id] = options.handler(id));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.ObjectVault = ObjectVault;
|