nesoi 3.0.0 → 3.0.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/README.md +10 -0
- package/lib/adapters/postgres/src/migrator/bucket.d.ts +20 -0
- package/lib/adapters/postgres/src/migrator/bucket.js +184 -0
- package/lib/adapters/postgres/src/migrator/csv.d.ts +7 -0
- package/lib/adapters/postgres/src/migrator/csv.js +72 -0
- package/lib/adapters/postgres/src/migrator/migration.d.ts +2 -18
- package/lib/adapters/postgres/src/migrator/migration.js +10 -158
- package/lib/adapters/postgres/src/migrator/migrator.js +8 -5
- package/lib/adapters/postgres/src/migrator/runner.d.ts +16 -6
- package/lib/adapters/postgres/src/migrator/runner.js +103 -34
- package/lib/adapters/postgres/src/postgres.bucket_adapter.d.ts +19 -22
- package/lib/adapters/postgres/src/postgres.bucket_adapter.js +116 -100
- package/lib/adapters/postgres/src/postgres.cli.d.ts +23 -3
- package/lib/adapters/postgres/src/postgres.cli.js +70 -10
- package/lib/adapters/postgres/src/postgres.config.d.ts +5 -0
- package/lib/adapters/postgres/src/postgres.config.js +2 -0
- package/lib/adapters/postgres/src/postgres.nql.d.ts +7 -3
- package/lib/adapters/postgres/src/postgres.nql.js +86 -32
- package/lib/adapters/postgres/src/postgres.provider.d.ts +18 -0
- package/lib/adapters/postgres/src/postgres.provider.js +77 -0
- package/lib/adapters/postgres/test/postgres.bucket_adapter.test.js +76 -39
- package/lib/compiler/apps/monolyth/monolyth_compiler.d.ts +3 -0
- package/lib/compiler/apps/monolyth/monolyth_compiler.js +24 -0
- package/lib/compiler/apps/monolyth/stages/2_build_typescript_stage.js +2 -1
- package/lib/compiler/apps/monolyth/stages/5_dump_cli_stage.js +1 -1
- package/lib/compiler/elements/bucket.element.js +26 -11
- package/lib/compiler/elements/constants.element.js +1 -1
- package/lib/compiler/elements/element.d.ts +2 -0
- package/lib/compiler/elements/message.element.js +4 -4
- package/lib/compiler/helpers/dump_helpers.js +5 -2
- package/lib/compiler/stages/7_dump_stage.js +2 -0
- package/lib/compiler/treeshake.js +9 -37
- package/lib/compiler/typescript/bridge/extract.js +12 -0
- package/lib/compiler/typescript/bridge/inject.js +3 -0
- package/lib/compiler/typescript/bridge/organize.js +3 -3
- package/lib/elements/blocks/block.builder.js +4 -2
- package/lib/elements/blocks/job/internal/resource_job.builder.d.ts +22 -20
- package/lib/elements/blocks/job/internal/resource_job.d.ts +2 -1
- package/lib/elements/blocks/job/internal/resource_job.js +17 -4
- package/lib/elements/blocks/job/job.js +3 -0
- package/lib/elements/blocks/job/job.types.d.ts +7 -0
- package/lib/elements/blocks/job/job.types.js +2 -0
- package/lib/elements/blocks/machine/machine.js +3 -2
- package/lib/elements/blocks/resource/resource.builder.js +2 -4
- package/lib/elements/blocks/resource/resource.d.ts +5 -3
- package/lib/elements/blocks/resource/resource.js +26 -17
- package/lib/elements/edge/controller/adapters/controller_adapter.d.ts +2 -1
- package/lib/elements/edge/controller/adapters/controller_adapter.js +11 -2
- package/lib/elements/edge/controller/controller.builder.d.ts +4 -5
- package/lib/elements/edge/controller/controller.builder.js +7 -7
- package/lib/elements/edge/controller/controller.d.ts +2 -1
- package/lib/elements/edge/controller/controller.js +8 -6
- package/lib/elements/entities/bucket/adapters/bucket_adapter.d.ts +61 -23
- package/lib/elements/entities/bucket/adapters/bucket_adapter.js +22 -13
- package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.d.ts +21 -22
- package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.js +68 -2
- package/lib/elements/entities/bucket/adapters/memory.nql.d.ts +10 -6
- package/lib/elements/entities/bucket/adapters/memory.nql.js +38 -3
- package/lib/elements/entities/bucket/adapters/slow_memory.bucket_adapter.d.ts +0 -20
- package/lib/elements/entities/bucket/adapters/slow_memory.bucket_adapter.js +46 -30
- package/lib/elements/entities/bucket/bucket.builder.d.ts +8 -2
- package/lib/elements/entities/bucket/bucket.builder.js +13 -19
- package/lib/elements/entities/bucket/bucket.config.d.ts +5 -1
- package/lib/elements/entities/bucket/bucket.d.ts +180 -19
- package/lib/elements/entities/bucket/bucket.js +658 -48
- package/lib/elements/entities/bucket/bucket.schema.d.ts +7 -1
- package/lib/elements/entities/bucket/bucket.schema.js +2 -1
- package/lib/elements/entities/bucket/bucket.types.d.ts +2 -7
- package/lib/elements/entities/bucket/cache/bucket_cache.d.ts +6 -2
- package/lib/elements/entities/bucket/cache/bucket_cache.js +12 -12
- package/lib/elements/entities/bucket/graph/bucket_graph.d.ts +32 -5
- package/lib/elements/entities/bucket/graph/bucket_graph.js +80 -111
- package/lib/elements/entities/bucket/graph/bucket_graph.schema.d.ts +3 -6
- package/lib/elements/entities/bucket/graph/bucket_graph.schema.js +1 -4
- package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.d.ts +3 -7
- package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.js +6 -2
- package/lib/elements/entities/bucket/model/bucket_model.builder.js +1 -1
- package/lib/elements/entities/bucket/model/bucket_model.convert.js +3 -3
- package/lib/elements/entities/bucket/model/bucket_model.schema.d.ts +37 -8
- package/lib/elements/entities/bucket/model/bucket_model.schema.js +25 -4
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.d.ts +33 -14
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.js +56 -13
- package/lib/elements/entities/bucket/query/nql.schema.d.ts +1 -0
- package/lib/elements/entities/bucket/query/nql_compiler.js +13 -2
- package/lib/elements/entities/bucket/query/nql_engine.d.ts +11 -4
- package/lib/elements/entities/bucket/query/nql_engine.js +20 -11
- package/lib/elements/entities/bucket/view/bucket_view.js +63 -35
- package/lib/elements/entities/bucket/view/bucket_view.schema.d.ts +5 -2
- package/lib/elements/entities/bucket/view/bucket_view_field.builder.d.ts +6 -2
- package/lib/elements/entities/bucket/view/bucket_view_field.builder.js +21 -15
- package/lib/elements/entities/constants/constants.schema.d.ts +1 -1
- package/lib/elements/entities/drive/drive_adapter.d.ts +36 -0
- package/lib/elements/entities/drive/drive_adapter.js +10 -0
- package/lib/elements/entities/drive/local.drive_adapter.d.ts +8 -0
- package/lib/elements/entities/drive/local.drive_adapter.js +28 -0
- package/lib/elements/entities/message/message.schema.d.ts +1 -0
- package/lib/elements/entities/message/message.schema.js +33 -0
- package/lib/elements/entities/message/message_parser.d.ts +5 -1
- package/lib/elements/entities/message/message_parser.js +56 -35
- package/lib/elements/entities/message/template/message_template.schema.d.ts +10 -8
- package/lib/elements/entities/message/template/message_template_field.builder.d.ts +16 -6
- package/lib/elements/entities/message/template/message_template_field.builder.js +25 -0
- package/lib/elements/entities/message/template/message_template_parser.js +2 -1
- package/lib/engine/apps/app.config.d.ts +32 -11
- package/lib/engine/apps/app.config.js +12 -0
- package/lib/engine/apps/app.d.ts +2 -0
- package/lib/engine/apps/app.js +3 -0
- package/lib/engine/apps/inline.app.d.ts +5 -3
- package/lib/engine/apps/inline.app.js +27 -12
- package/lib/engine/apps/monolyth/monolyth.app.d.ts +4 -2
- package/lib/engine/apps/monolyth/monolyth.app.js +22 -10
- package/lib/engine/auth/authn.d.ts +5 -1
- package/lib/engine/auth/zero.authn_provider.d.ts +4 -2
- package/lib/engine/auth/zero.authn_provider.js +2 -2
- package/lib/engine/cli/cli.d.ts +3 -1
- package/lib/engine/cli/cli.js +22 -3
- package/lib/engine/cli/cli_adapter.d.ts +2 -1
- package/lib/engine/cli/cli_adapter.js +2 -1
- package/lib/engine/cli/cli_input.d.ts +19 -0
- package/lib/engine/cli/cli_input.js +207 -0
- package/lib/engine/cli/ui.d.ts +1 -1
- package/lib/engine/cli/ui.js +2 -2
- package/lib/engine/daemon.d.ts +3 -2
- package/lib/engine/daemon.js +14 -2
- package/lib/engine/data/date.js +2 -2
- package/lib/engine/data/datetime.d.ts +40 -4
- package/lib/engine/data/datetime.js +70 -11
- package/lib/engine/data/decimal.d.ts +1 -1
- package/lib/engine/data/decimal.js +3 -3
- package/lib/engine/data/error.d.ts +21 -4
- package/lib/engine/data/error.js +23 -7
- package/lib/engine/data/file.d.ts +23 -0
- package/lib/engine/data/file.js +53 -0
- package/lib/engine/data/json.d.ts +6 -0
- package/lib/engine/data/json.js +26 -0
- package/lib/engine/data/obj.d.ts +1 -1
- package/lib/engine/data/trash.d.ts +14 -0
- package/lib/engine/data/trash.js +2 -0
- package/lib/engine/data/tree.d.ts +7 -12
- package/lib/engine/data/tree.js +101 -49
- package/lib/engine/module.d.ts +2 -1
- package/lib/engine/module.js +2 -5
- package/lib/engine/space.d.ts +1 -0
- package/lib/engine/space.js +6 -0
- package/lib/engine/transaction/nodes/bucket.trx_node.d.ts +156 -24
- package/lib/engine/transaction/nodes/bucket.trx_node.js +297 -467
- package/lib/engine/transaction/nodes/bucket_query.trx_node.d.ts +4 -2
- package/lib/engine/transaction/nodes/bucket_query.trx_node.js +27 -15
- package/lib/engine/transaction/nodes/job.trx_node.d.ts +2 -1
- package/lib/engine/transaction/nodes/job.trx_node.js +6 -0
- package/lib/engine/transaction/trx.d.ts +5 -2
- package/lib/engine/transaction/trx.js +2 -2
- package/lib/engine/transaction/trx_engine.config.d.ts +1 -3
- package/lib/engine/transaction/trx_engine.d.ts +2 -2
- package/lib/engine/transaction/trx_engine.js +14 -11
- package/lib/engine/transaction/trx_node.d.ts +14 -4
- package/lib/engine/transaction/trx_node.js +50 -8
- package/lib/engine/tree.d.ts +1 -1
- package/lib/engine/util/crypto.d.ts +50 -0
- package/lib/engine/util/crypto.js +89 -0
- package/lib/engine/util/deep.d.ts +5 -0
- package/lib/engine/util/deep.js +46 -0
- package/lib/engine/util/dotenv.d.ts +2 -8
- package/lib/engine/util/dotenv.js +14 -36
- package/lib/engine/util/hash.d.ts +3 -0
- package/lib/engine/util/hash.js +23 -0
- package/lib/engine/util/log.js +1 -1
- package/lib/engine/util/mime.d.ts +10 -0
- package/lib/engine/util/mime.js +389 -0
- package/lib/engine/util/parse.d.ts +6 -5
- package/lib/engine/util/parse.js +16 -15
- package/lib/engine/util/path.d.ts +3 -0
- package/lib/engine/util/path.js +92 -0
- package/lib/engine/util/rules.d.ts +4 -0
- package/lib/engine/util/rules.js +12 -0
- package/package.json +1 -1
- package/tools/compile.js +2 -2
- package/tools/dotenv.d.ts +1 -0
- package/tools/dotenv.js +4 -0
- package/tools/joaquin/job.d.ts +5 -5
- package/tools/joaquin/mock.d.ts +23 -2
- package/tools/joaquin/mock.js +127 -21
- package/tsconfig.build.tsbuildinfo +1 -1
- package/lib/adapters/postgres/test/postgres.bucket_query.test.d.ts +0 -0
- package/lib/adapters/postgres/test/postgres.bucket_query.test.js +0 -136
package/lib/engine/daemon.js
CHANGED
|
@@ -20,9 +20,9 @@ class Daemon {
|
|
|
20
20
|
}
|
|
21
21
|
return new DaemonTrx(trxEngine);
|
|
22
22
|
}
|
|
23
|
-
async cli() {
|
|
23
|
+
async cli(cmd) {
|
|
24
24
|
this._cli = new cli_1.CLI(this, this.app?.cli);
|
|
25
|
-
await this._cli.run();
|
|
25
|
+
await this._cli.run(cmd);
|
|
26
26
|
}
|
|
27
27
|
bindControllers() {
|
|
28
28
|
log_1.Log.info('daemon', this.name, 'Binding controllers');
|
|
@@ -34,10 +34,22 @@ class Daemon {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
static async destroy(daemon) {
|
|
38
|
+
log_1.Log.info('daemon', this.name, 'Stop');
|
|
39
|
+
for (const key in daemon.providers) {
|
|
40
|
+
const provider = daemon.providers[key];
|
|
41
|
+
await provider.__down(provider);
|
|
42
|
+
delete daemon.providers[key];
|
|
43
|
+
}
|
|
44
|
+
for (const key in daemon.trxEngines) {
|
|
45
|
+
delete daemon.trxEngines[key];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
37
48
|
static reload(daemon, trxEngines, providers) {
|
|
38
49
|
log_1.Log.info('daemon', this.name, 'Reloaded');
|
|
39
50
|
daemon.trxEngines = trxEngines;
|
|
40
51
|
daemon.providers = providers;
|
|
52
|
+
daemon.bindControllers();
|
|
41
53
|
}
|
|
42
54
|
static get(daemon, key) {
|
|
43
55
|
return daemon?.[key];
|
package/lib/engine/data/date.js
CHANGED
|
@@ -9,8 +9,8 @@ class NesoiDate {
|
|
|
9
9
|
this.year = year;
|
|
10
10
|
}
|
|
11
11
|
static fromISO(iso) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const match = iso.match(/(\d{4})-(\d{2})-(\d{2})/);
|
|
13
|
+
// TODO: Check invalid date
|
|
14
14
|
if (!match) {
|
|
15
15
|
throw error_1.NesoiError.Data.InvalidISOString({ value: iso });
|
|
16
16
|
}
|
|
@@ -1,12 +1,48 @@
|
|
|
1
1
|
export declare class NesoiDatetime {
|
|
2
|
+
static tz: {
|
|
3
|
+
'-12:00': string;
|
|
4
|
+
'-11:00': string;
|
|
5
|
+
'-10:00': string;
|
|
6
|
+
'-07:00': string;
|
|
7
|
+
'-06:00': string;
|
|
8
|
+
'-05:00': string;
|
|
9
|
+
'-04:00': string;
|
|
10
|
+
'-03:00': string;
|
|
11
|
+
'-02:00': string;
|
|
12
|
+
'-01:00': string;
|
|
13
|
+
Z: string;
|
|
14
|
+
'+01:00': string;
|
|
15
|
+
'+02:00': string;
|
|
16
|
+
'+03:00': string;
|
|
17
|
+
'+04:00': string;
|
|
18
|
+
'+05:00': string;
|
|
19
|
+
'+06:00': string;
|
|
20
|
+
'+07:00': string;
|
|
21
|
+
'+08:00': string;
|
|
22
|
+
'+09:00': string;
|
|
23
|
+
'+10:00': string;
|
|
24
|
+
'+11:00': string;
|
|
25
|
+
'+12:00': string;
|
|
26
|
+
'+13:00': string;
|
|
27
|
+
};
|
|
2
28
|
/**
|
|
3
|
-
* Time in milliseconds since 1970-01-
|
|
29
|
+
* Time in milliseconds since 1970-01-01T00:00:00.000Z
|
|
4
30
|
*/
|
|
5
31
|
epoch: number;
|
|
6
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Timezone represented as string (Z, -03, +05, ...)
|
|
34
|
+
*/
|
|
35
|
+
tz: keyof typeof NesoiDatetime.tz;
|
|
36
|
+
constructor(epoch?: number, tz?: keyof typeof NesoiDatetime.tz);
|
|
37
|
+
toISO(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Parse a timestamp from ISO 8601 format.
|
|
40
|
+
*
|
|
41
|
+
* Example: `2025-04-16T23:04:42.000-03:00`
|
|
42
|
+
*/
|
|
7
43
|
static fromISO(iso: string): NesoiDatetime;
|
|
8
44
|
static now(): NesoiDatetime;
|
|
9
45
|
static isoNow(): string;
|
|
10
|
-
static
|
|
11
|
-
|
|
46
|
+
static shortIsoNow(): string;
|
|
47
|
+
plus(period: `${number} ${'second' | 'minute' | 'hour' | 'day' | 'week' | 'month'}${'s' | ''}`): this;
|
|
12
48
|
}
|
|
@@ -3,29 +3,88 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NesoiDatetime = void 0;
|
|
4
4
|
const error_1 = require("./error");
|
|
5
5
|
class NesoiDatetime {
|
|
6
|
-
constructor(
|
|
7
|
-
this.epoch =
|
|
6
|
+
constructor(epoch, tz = 'Z') {
|
|
7
|
+
this.epoch = epoch || new Date().getTime();
|
|
8
|
+
this.tz = tz;
|
|
8
9
|
}
|
|
10
|
+
// Dump
|
|
11
|
+
toISO() {
|
|
12
|
+
return new Date(this.epoch).toLocaleString('sv-SE', {
|
|
13
|
+
timeZone: NesoiDatetime.tz[this.tz],
|
|
14
|
+
year: 'numeric',
|
|
15
|
+
month: 'numeric',
|
|
16
|
+
day: 'numeric',
|
|
17
|
+
hour: 'numeric',
|
|
18
|
+
minute: 'numeric',
|
|
19
|
+
second: 'numeric',
|
|
20
|
+
fractionalSecondDigits: 3
|
|
21
|
+
})
|
|
22
|
+
.replace(' ', 'T')
|
|
23
|
+
.replace(',', '.')
|
|
24
|
+
+ this.tz;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parse a timestamp from ISO 8601 format.
|
|
28
|
+
*
|
|
29
|
+
* Example: `2025-04-16T23:04:42.000-03:00`
|
|
30
|
+
*/
|
|
9
31
|
static fromISO(iso) {
|
|
10
|
-
|
|
11
|
-
|
|
32
|
+
const match = iso.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(([-+]\d{2})|Z)?(:00)?$/);
|
|
33
|
+
// TODO: Check invalid datetimes
|
|
12
34
|
if (!match) {
|
|
13
35
|
throw error_1.NesoiError.Data.InvalidISOString({ value: iso });
|
|
14
36
|
}
|
|
15
|
-
|
|
16
|
-
|
|
37
|
+
let tz = match[8];
|
|
38
|
+
if (!tz) {
|
|
39
|
+
iso += 'Z';
|
|
40
|
+
tz = 'Z';
|
|
41
|
+
}
|
|
42
|
+
if (tz !== 'Z') {
|
|
43
|
+
if (!match[10]) {
|
|
44
|
+
iso += ':00';
|
|
45
|
+
}
|
|
46
|
+
tz += ':00';
|
|
47
|
+
}
|
|
48
|
+
const jsDate = Date.parse(iso);
|
|
49
|
+
return new NesoiDatetime(jsDate, tz);
|
|
17
50
|
}
|
|
18
51
|
static now() {
|
|
19
52
|
return new NesoiDatetime();
|
|
20
53
|
}
|
|
21
54
|
static isoNow() {
|
|
22
|
-
return new
|
|
55
|
+
return new NesoiDatetime().toISO();
|
|
23
56
|
}
|
|
24
|
-
static
|
|
25
|
-
return new
|
|
57
|
+
static shortIsoNow() {
|
|
58
|
+
return new NesoiDatetime().toISO().slice(5, 19);
|
|
26
59
|
}
|
|
27
|
-
|
|
28
|
-
return
|
|
60
|
+
plus(period) {
|
|
61
|
+
return this;
|
|
29
62
|
}
|
|
30
63
|
}
|
|
31
64
|
exports.NesoiDatetime = NesoiDatetime;
|
|
65
|
+
NesoiDatetime.tz = {
|
|
66
|
+
'-12:00': 'Etc/GMT+12',
|
|
67
|
+
'-11:00': 'Etc/GMT+11',
|
|
68
|
+
'-10:00': 'Etc/GMT+10',
|
|
69
|
+
'-07:00': 'Etc/GMT+7',
|
|
70
|
+
'-06:00': 'Etc/GMT+6',
|
|
71
|
+
'-05:00': 'Etc/GMT+5',
|
|
72
|
+
'-04:00': 'Etc/GMT+4',
|
|
73
|
+
'-03:00': 'Etc/GMT+3',
|
|
74
|
+
'-02:00': 'Etc/GMT+2',
|
|
75
|
+
'-01:00': 'Etc/GMT+1',
|
|
76
|
+
'Z': 'Etc/GMT',
|
|
77
|
+
'+01:00': 'Etc/GMT-1',
|
|
78
|
+
'+02:00': 'Etc/GMT-2',
|
|
79
|
+
'+03:00': 'Etc/GMT-3',
|
|
80
|
+
'+04:00': 'Etc/GMT-4',
|
|
81
|
+
'+05:00': 'Etc/GMT-5',
|
|
82
|
+
'+06:00': 'Etc/GMT-6',
|
|
83
|
+
'+07:00': 'Etc/GMT-7',
|
|
84
|
+
'+08:00': 'Etc/GMT-8',
|
|
85
|
+
'+09:00': 'Etc/GMT-9',
|
|
86
|
+
'+10:00': 'Etc/GMT-10',
|
|
87
|
+
'+11:00': 'Etc/GMT-11',
|
|
88
|
+
'+12:00': 'Etc/GMT-12',
|
|
89
|
+
'+13:00': 'Etc/GMT-13',
|
|
90
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.NesoiDecimal = void 0;
|
|
4
4
|
const error_1 = require("./error");
|
|
5
|
-
class
|
|
5
|
+
class NesoiDecimal {
|
|
6
6
|
constructor(value, pLeft = 12, pRight = 12) {
|
|
7
7
|
this.neg = false;
|
|
8
8
|
let payload = value.trim();
|
|
@@ -67,4 +67,4 @@ class Decimal {
|
|
|
67
67
|
return (this.neg ? -1 : 1) * (this.left + this.right * this.r_exp);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
exports.
|
|
70
|
+
exports.NesoiDecimal = NesoiDecimal;
|
|
@@ -22,7 +22,10 @@ export declare namespace NesoiError {
|
|
|
22
22
|
function UnknownGraphLink(name: string): BaseError;
|
|
23
23
|
function UnknownViewName(name: string): BaseError;
|
|
24
24
|
function NoChildrenOnViewGroup(name: string): BaseError;
|
|
25
|
-
function
|
|
25
|
+
function CompositionThroughPivotNotAllowed($: {
|
|
26
|
+
bucket: string;
|
|
27
|
+
link: string;
|
|
28
|
+
}): BaseError;
|
|
26
29
|
}
|
|
27
30
|
namespace Message {
|
|
28
31
|
function UnknownTemplateFieldType(type: string): BaseError;
|
|
@@ -55,6 +58,7 @@ export declare namespace NesoiError {
|
|
|
55
58
|
namespace Trx {
|
|
56
59
|
function ModuleNotFound(module: string): BaseError;
|
|
57
60
|
function NodeNotFound(node: string, trx: string): BaseError;
|
|
61
|
+
function NotAuthenticated($: {}): BaseError;
|
|
58
62
|
}
|
|
59
63
|
namespace Bucket {
|
|
60
64
|
function InvalidId($: {
|
|
@@ -84,6 +88,10 @@ export declare namespace NesoiError {
|
|
|
84
88
|
bucket: string;
|
|
85
89
|
link: string;
|
|
86
90
|
}): BaseError;
|
|
91
|
+
function FieldNotFound($: {
|
|
92
|
+
path: string;
|
|
93
|
+
bucket: string;
|
|
94
|
+
}): BaseError;
|
|
87
95
|
namespace Graph {
|
|
88
96
|
function LinkNotFound($: {
|
|
89
97
|
bucket: string;
|
|
@@ -93,7 +101,11 @@ export declare namespace NesoiError {
|
|
|
93
101
|
function LinkManyRefOffSelfWithArrayValue(link: string): BaseError;
|
|
94
102
|
function LinkOneWithArrayValue(link: string): BaseError;
|
|
95
103
|
function PivotValueIsUndefined(link: string): BaseError;
|
|
96
|
-
function RequiredLinkNotFound(
|
|
104
|
+
function RequiredLinkNotFound($: {
|
|
105
|
+
bucket: string;
|
|
106
|
+
link: string;
|
|
107
|
+
id: number | string;
|
|
108
|
+
}): BaseError;
|
|
97
109
|
}
|
|
98
110
|
namespace Query {
|
|
99
111
|
function NoResults($: {
|
|
@@ -112,6 +124,11 @@ export declare namespace NesoiError {
|
|
|
112
124
|
index: (string | number)[];
|
|
113
125
|
}): BaseError;
|
|
114
126
|
}
|
|
127
|
+
namespace Drive {
|
|
128
|
+
function NoAdapter($: {
|
|
129
|
+
bucket: string;
|
|
130
|
+
}): BaseError;
|
|
131
|
+
}
|
|
115
132
|
}
|
|
116
133
|
namespace Data {
|
|
117
134
|
function InvalidISOString($: {
|
|
@@ -167,11 +184,11 @@ export declare namespace NesoiError {
|
|
|
167
184
|
path: string;
|
|
168
185
|
value: any;
|
|
169
186
|
}): BaseError;
|
|
170
|
-
function RuleFailed(rule: $MessageTemplateRule
|
|
187
|
+
function RuleFailed(rule: $MessageTemplateRule, error: string): BaseError;
|
|
171
188
|
function FileTooBig(prop: {
|
|
172
189
|
name: string;
|
|
173
190
|
alias?: string;
|
|
174
|
-
},
|
|
191
|
+
}, maxsize: number): BaseError;
|
|
175
192
|
function FileExtNotAllowed(prop: {
|
|
176
193
|
name: string;
|
|
177
194
|
alias?: string;
|
package/lib/engine/data/error.js
CHANGED
|
@@ -20,6 +20,7 @@ var NesoiError;
|
|
|
20
20
|
Status[Status["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
21
21
|
Status[Status["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
22
22
|
Status[Status["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
23
|
+
Status[Status["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
23
24
|
Status[Status["INTERNAL_ERROR"] = 500] = "INTERNAL_ERROR";
|
|
24
25
|
})(Status || (Status = {}));
|
|
25
26
|
let Builder;
|
|
@@ -49,10 +50,10 @@ var NesoiError;
|
|
|
49
50
|
return new BaseError('Builder.Bucket.NoChildrenOnViewGroup', `Bucket view group ${name} has no children`, Status.NOT_FOUND);
|
|
50
51
|
}
|
|
51
52
|
Bucket.NoChildrenOnViewGroup = NoChildrenOnViewGroup;
|
|
52
|
-
function
|
|
53
|
-
return new BaseError('Builder.Bucket.
|
|
53
|
+
function CompositionThroughPivotNotAllowed($) {
|
|
54
|
+
return new BaseError('Builder.Bucket.CompositionThroughPivotNotAllowed', `Link '${$.link}' on bucket '${$.bucket}' passes through pivot, so it cannot be a composition`, Status.INTERNAL_ERROR);
|
|
54
55
|
}
|
|
55
|
-
Bucket.
|
|
56
|
+
Bucket.CompositionThroughPivotNotAllowed = CompositionThroughPivotNotAllowed;
|
|
56
57
|
})(Bucket = Builder.Bucket || (Builder.Bucket = {}));
|
|
57
58
|
let Message;
|
|
58
59
|
(function (Message) {
|
|
@@ -148,6 +149,10 @@ var NesoiError;
|
|
|
148
149
|
return new BaseError('Trx.NodeNotFoundOnTrx', `Node ${node} not found on transaction ${trx}`, Status.NOT_FOUND);
|
|
149
150
|
}
|
|
150
151
|
Trx.NodeNotFound = NodeNotFound;
|
|
152
|
+
function NotAuthenticated($) {
|
|
153
|
+
return new BaseError('Trx.NotAuthenticated', 'Unauthorized', Status.UNAUTHORIZED, $);
|
|
154
|
+
}
|
|
155
|
+
Trx.NotAuthenticated = NotAuthenticated;
|
|
151
156
|
})(Trx = NesoiError.Trx || (NesoiError.Trx = {}));
|
|
152
157
|
/*
|
|
153
158
|
Elements / Entities
|
|
@@ -178,6 +183,10 @@ var NesoiError;
|
|
|
178
183
|
return new BaseError('Bucket.CompositionValueShouldBeArray', `Request to ${$.method} bucket '${$.bucket}' failed, composition for link ${$.link} should be an array`, Status.BAD_REQUEST, $);
|
|
179
184
|
}
|
|
180
185
|
Bucket.CompositionValueShouldBeArray = CompositionValueShouldBeArray;
|
|
186
|
+
function FieldNotFound($) {
|
|
187
|
+
return new BaseError('Bucket.FieldNotFound', `Field '${$.path}' not found on bucket '${$.bucket}'`, Status.NOT_FOUND, $);
|
|
188
|
+
}
|
|
189
|
+
Bucket.FieldNotFound = FieldNotFound;
|
|
181
190
|
let Graph;
|
|
182
191
|
(function (Graph) {
|
|
183
192
|
function LinkNotFound($) {
|
|
@@ -200,8 +209,8 @@ var NesoiError;
|
|
|
200
209
|
return new BaseError('Bucket.Graph.PivotValueIsUndefined', `Link ${link} has a pivot value with undefined/null on the other id`, Status.NOT_FOUND);
|
|
201
210
|
}
|
|
202
211
|
Graph.PivotValueIsUndefined = PivotValueIsUndefined;
|
|
203
|
-
function RequiredLinkNotFound(
|
|
204
|
-
return new BaseError('Bucket.Graph.RequiredLinkNotFound', `Link ${link}
|
|
212
|
+
function RequiredLinkNotFound($) {
|
|
213
|
+
return new BaseError('Bucket.Graph.RequiredLinkNotFound', `Link '${$.link}' of '${$.bucket}' not found for object with id ${$.id}`, Status.PRECONDITION_FAILED, $);
|
|
205
214
|
}
|
|
206
215
|
Graph.RequiredLinkNotFound = RequiredLinkNotFound;
|
|
207
216
|
})(Graph = Bucket.Graph || (Bucket.Graph = {}));
|
|
@@ -239,6 +248,13 @@ var NesoiError;
|
|
|
239
248
|
}
|
|
240
249
|
Fieldpath.InvalidIndexLength = InvalidIndexLength;
|
|
241
250
|
})(Fieldpath = Bucket.Fieldpath || (Bucket.Fieldpath = {}));
|
|
251
|
+
let Drive;
|
|
252
|
+
(function (Drive) {
|
|
253
|
+
function NoAdapter($) {
|
|
254
|
+
return new BaseError('Bucket.Drive.NoAdapter', `Bucket '${$.bucket}' needs a DriveAdapter configured to handle files.`, Status.BAD_REQUEST, $);
|
|
255
|
+
}
|
|
256
|
+
Drive.NoAdapter = NoAdapter;
|
|
257
|
+
})(Drive = Bucket.Drive || (Bucket.Drive = {}));
|
|
242
258
|
})(Bucket = NesoiError.Bucket || (NesoiError.Bucket = {}));
|
|
243
259
|
let Data;
|
|
244
260
|
(function (Data) {
|
|
@@ -301,8 +317,8 @@ var NesoiError;
|
|
|
301
317
|
return new BaseError('Message.RuleFailed', error);
|
|
302
318
|
}
|
|
303
319
|
Message.RuleFailed = RuleFailed;
|
|
304
|
-
function FileTooBig(prop,
|
|
305
|
-
return new BaseError('Message.FileTooBig', `${prop.alias || prop.name} size exceeds max (${
|
|
320
|
+
function FileTooBig(prop, maxsize) {
|
|
321
|
+
return new BaseError('Message.FileTooBig', `${prop.alias || prop.name} size exceeds max (${maxsize})`);
|
|
306
322
|
}
|
|
307
323
|
Message.FileTooBig = FileTooBig;
|
|
308
324
|
function FileExtNotAllowed(prop, options) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare class NesoiFile {
|
|
2
|
+
__nesoi_file: boolean;
|
|
3
|
+
filepath: string;
|
|
4
|
+
filename: string;
|
|
5
|
+
extname: string;
|
|
6
|
+
mimetype: string | null;
|
|
7
|
+
size: number;
|
|
8
|
+
originalFilename: string | null;
|
|
9
|
+
newFilename: string;
|
|
10
|
+
mtime: Date | null;
|
|
11
|
+
hashAlgorithm: false | 'sha1' | 'md5' | 'sha256';
|
|
12
|
+
private _hash;
|
|
13
|
+
constructor(filepath: string, extra?: {
|
|
14
|
+
originalFilename?: string | null;
|
|
15
|
+
newFilename?: string | null;
|
|
16
|
+
});
|
|
17
|
+
hash(hashAlgorithm: 'sha1' | 'md5' | 'sha256'): Promise<{
|
|
18
|
+
algorithm: "sha1" | "sha256" | "md5";
|
|
19
|
+
hash: string | object;
|
|
20
|
+
}>;
|
|
21
|
+
delete(): void;
|
|
22
|
+
move(to: string): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NesoiFile = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const hash_1 = require("../util/hash");
|
|
10
|
+
const mime_1 = require("../util/mime");
|
|
11
|
+
// Based on [formidable](https://github.com/node-formidable/formidable)
|
|
12
|
+
class NesoiFile {
|
|
13
|
+
constructor(filepath, extra) {
|
|
14
|
+
this.__nesoi_file = true;
|
|
15
|
+
this.hashAlgorithm = false;
|
|
16
|
+
// Only available after `.hash` is called
|
|
17
|
+
this._hash = null;
|
|
18
|
+
this.filepath = filepath;
|
|
19
|
+
this.filename = path_1.default.basename(filepath);
|
|
20
|
+
const mime = mime_1.Mime.ofFilepath(filepath);
|
|
21
|
+
this.extname = extra?.originalFilename
|
|
22
|
+
? path_1.default.extname(extra.originalFilename).slice(1)
|
|
23
|
+
: mime.extname;
|
|
24
|
+
this.mimetype = mime.mimetype;
|
|
25
|
+
const stat = fs_1.default.statSync(filepath);
|
|
26
|
+
this.size = stat.size;
|
|
27
|
+
this.originalFilename = extra?.originalFilename || null;
|
|
28
|
+
this.newFilename = extra?.newFilename || this.filename;
|
|
29
|
+
this.mtime = stat.mtime;
|
|
30
|
+
}
|
|
31
|
+
async hash(hashAlgorithm) {
|
|
32
|
+
if (!this._hash) {
|
|
33
|
+
this.hashAlgorithm = hashAlgorithm;
|
|
34
|
+
this._hash = hash_1.Hash.file(this.filepath, this.hashAlgorithm).then(hash => {
|
|
35
|
+
this._hash = hash;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
algorithm: hashAlgorithm,
|
|
40
|
+
hash: this._hash
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
delete() {
|
|
44
|
+
if (fs_1.default.existsSync(this.filepath))
|
|
45
|
+
fs_1.default.rmSync(this.filepath);
|
|
46
|
+
}
|
|
47
|
+
move(to) {
|
|
48
|
+
if (fs_1.default.existsSync(this.filepath))
|
|
49
|
+
fs_1.default.renameSync(this.filepath, to);
|
|
50
|
+
this.filepath = to;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.NesoiFile = NesoiFile;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NesoiJSON = void 0;
|
|
4
|
+
const date_1 = require("./date");
|
|
5
|
+
const datetime_1 = require("./datetime");
|
|
6
|
+
const decimal_1 = require("./decimal");
|
|
7
|
+
class NesoiJSON {
|
|
8
|
+
/**
|
|
9
|
+
* Dumps an object to
|
|
10
|
+
*/
|
|
11
|
+
static dump(obj) {
|
|
12
|
+
return JSON.stringify(obj, (key, value) => {
|
|
13
|
+
if (value instanceof date_1.NesoiDate) {
|
|
14
|
+
return value.toISO();
|
|
15
|
+
}
|
|
16
|
+
if (value instanceof datetime_1.NesoiDatetime) {
|
|
17
|
+
return value.toISO();
|
|
18
|
+
}
|
|
19
|
+
if (value instanceof decimal_1.NesoiDecimal) {
|
|
20
|
+
return value.toString();
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.NesoiJSON = NesoiJSON;
|
package/lib/engine/data/obj.d.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NesoiDatetime } from './datetime';
|
|
2
|
+
export type TrashObj = {
|
|
3
|
+
id: number;
|
|
4
|
+
bucket: string;
|
|
5
|
+
original_id: number | string;
|
|
6
|
+
data: Record<string, any>;
|
|
7
|
+
adapter: {
|
|
8
|
+
name: string;
|
|
9
|
+
[x: string]: any;
|
|
10
|
+
};
|
|
11
|
+
trx: Record<string, any>;
|
|
12
|
+
deleted_by?: number | string;
|
|
13
|
+
deleted_at: NesoiDatetime;
|
|
14
|
+
};
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
type TreeNode<T> = {
|
|
2
|
-
path: string;
|
|
3
|
-
key: string;
|
|
4
|
-
value: T;
|
|
5
|
-
};
|
|
6
1
|
export declare class Tree {
|
|
7
2
|
/**
|
|
8
|
-
*
|
|
9
|
-
* - If the `index` parameter is null, returns nested lists
|
|
10
|
-
* - If the `index` parameter is a list of indices, returns the target object
|
|
3
|
+
* Read one or more values from the object, from a _fieldpath_.
|
|
11
4
|
*
|
|
5
|
+
* The `index` argument is only relevant if the fieldpath contains a spread (`.#`):
|
|
6
|
+
* - `*`: Return all values of the matched array or dict
|
|
7
|
+
* - `0`: Return the first value of an array or dict (dict ordering is unstable)
|
|
8
|
+
* - `(number|string)[]`: Sequence of values to replace the `#`s on the fieldpath
|
|
12
9
|
*/
|
|
13
|
-
static get(obj: Record<string, any>, fieldpath: string, index?:
|
|
14
|
-
static
|
|
15
|
-
static findAll<P>(obj: Record<string, P>, fn: (path: string, value: P) => boolean, _prefix?: string): TreeNode<P>[];
|
|
10
|
+
static get(obj: Record<string, any>, fieldpath: string, index?: '*' | 0 | (number | string)[]): any;
|
|
11
|
+
static set(obj: Record<string, any>, fieldpath: string, replacer: (v: any, i: (number | string)[]) => any, __index?: (number | string)[]): void;
|
|
16
12
|
}
|
|
17
|
-
export {};
|