nesoi 3.0.9 → 3.0.10

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.
Files changed (83) hide show
  1. package/lib/compiler/apps/monolyth/monolyth_compiler.d.ts +1 -1
  2. package/lib/compiler/apps/monolyth/monolyth_compiler.js +7 -7
  3. package/lib/elements/blocks/machine/machine.builder.js +12 -1
  4. package/lib/elements/blocks/machine/machine.schema.d.ts +2 -1
  5. package/lib/elements/blocks/machine/machine.schema.js +2 -1
  6. package/lib/elements/edge/controller/adapters/controller_adapter.d.ts +3 -1
  7. package/lib/elements/edge/controller/adapters/controller_adapter.js +2 -1
  8. package/lib/elements/edge/controller/controller.config.d.ts +3 -2
  9. package/lib/elements/edge/controller/controller.d.ts +3 -3
  10. package/lib/elements/edge/controller/controller.js +3 -3
  11. package/lib/elements/entities/bucket/adapters/bucket_adapter.d.ts +2 -1
  12. package/lib/elements/entities/bucket/bucket.config.d.ts +3 -3
  13. package/lib/elements/entities/bucket/bucket.d.ts +3 -2
  14. package/lib/elements/entities/bucket/bucket.js +4 -4
  15. package/lib/engine/apps/app.config.d.ts +12 -11
  16. package/lib/engine/apps/app.d.ts +11 -22
  17. package/lib/engine/apps/app.js +9 -9
  18. package/lib/engine/apps/inline.app.d.ts +9 -8
  19. package/lib/engine/apps/inline.app.js +24 -24
  20. package/lib/engine/apps/monolyth/monolyth.app.d.ts +5 -5
  21. package/lib/engine/apps/monolyth/monolyth.app.js +6 -6
  22. package/lib/engine/apps/service.d.ts +30 -0
  23. package/lib/engine/apps/service.js +15 -0
  24. package/lib/engine/auth/authn.d.ts +10 -1
  25. package/lib/engine/auth/zero.authn_provider.d.ts +7 -3
  26. package/lib/engine/auth/zero.authn_provider.js +9 -2
  27. package/lib/engine/cli/cli.d.ts +2 -2
  28. package/lib/engine/cli/cli.js +1 -1
  29. package/lib/engine/cli/ui.js +1 -1
  30. package/lib/engine/daemon.d.ts +11 -11
  31. package/lib/engine/daemon.js +18 -18
  32. package/lib/engine/dependency.d.ts +2 -1
  33. package/lib/engine/dependency.js +18 -0
  34. package/lib/engine/module.d.ts +6 -4
  35. package/lib/engine/module.js +25 -10
  36. package/lib/engine/transaction/nodes/bucket.trx_node.js +1 -2
  37. package/lib/engine/transaction/nodes/bucket_query.trx_node.js +5 -10
  38. package/lib/engine/transaction/nodes/job.trx_node.js +2 -4
  39. package/lib/engine/transaction/nodes/machine.trx_node.js +2 -4
  40. package/lib/engine/transaction/nodes/queue.trx_node.js +1 -2
  41. package/lib/engine/transaction/nodes/resource.trx_node.js +2 -4
  42. package/lib/engine/transaction/trx.d.ts +6 -4
  43. package/lib/engine/transaction/trx.js +2 -1
  44. package/lib/engine/transaction/trx_engine.config.d.ts +2 -2
  45. package/lib/engine/transaction/trx_engine.d.ts +4 -3
  46. package/lib/engine/transaction/trx_engine.js +20 -17
  47. package/lib/engine/transaction/trx_node.d.ts +4 -2
  48. package/lib/engine/transaction/trx_node.js +13 -1
  49. package/lib/engine/tree.js +6 -17
  50. package/lib/schema.d.ts +1 -1
  51. package/package.json +2 -3
  52. package/tools/joaquin/job.js +2 -2
  53. package/tools/joaquin/message.js +2 -2
  54. package/tools/joaquin/mock.d.ts +6 -6
  55. package/tsconfig.build.tsbuildinfo +1 -1
  56. package/lib/adapters/postgres/src/migrator/csv.d.ts +0 -7
  57. package/lib/adapters/postgres/src/migrator/csv.js +0 -72
  58. package/lib/adapters/postgres/src/migrator/database.d.ts +0 -34
  59. package/lib/adapters/postgres/src/migrator/database.js +0 -88
  60. package/lib/adapters/postgres/src/migrator/generator/generator.d.ts +0 -22
  61. package/lib/adapters/postgres/src/migrator/generator/generator.js +0 -326
  62. package/lib/adapters/postgres/src/migrator/generator/migration.d.ts +0 -66
  63. package/lib/adapters/postgres/src/migrator/generator/migration.js +0 -249
  64. package/lib/adapters/postgres/src/migrator/generator/provider.d.ts +0 -19
  65. package/lib/adapters/postgres/src/migrator/generator/provider.js +0 -74
  66. package/lib/adapters/postgres/src/migrator/index.d.ts +0 -47
  67. package/lib/adapters/postgres/src/migrator/index.js +0 -22
  68. package/lib/adapters/postgres/src/migrator/runner/runner.d.ts +0 -17
  69. package/lib/adapters/postgres/src/migrator/runner/runner.js +0 -249
  70. package/lib/adapters/postgres/src/migrator/runner/status.d.ts +0 -17
  71. package/lib/adapters/postgres/src/migrator/runner/status.js +0 -55
  72. package/lib/adapters/postgres/src/postgres.bucket_adapter.d.ts +0 -42
  73. package/lib/adapters/postgres/src/postgres.bucket_adapter.js +0 -294
  74. package/lib/adapters/postgres/src/postgres.cli.d.ts +0 -76
  75. package/lib/adapters/postgres/src/postgres.cli.js +0 -207
  76. package/lib/adapters/postgres/src/postgres.config.d.ts +0 -5
  77. package/lib/adapters/postgres/src/postgres.config.js +0 -2
  78. package/lib/adapters/postgres/src/postgres.nql.d.ts +0 -16
  79. package/lib/adapters/postgres/src/postgres.nql.js +0 -123
  80. package/lib/adapters/postgres/src/postgres.provider.d.ts +0 -18
  81. package/lib/adapters/postgres/src/postgres.provider.js +0 -77
  82. package/lib/adapters/postgres/test/postgres.bucket_adapter.test.d.ts +0 -1
  83. package/lib/adapters/postgres/test/postgres.bucket_adapter.test.js +0 -210
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MigrationProvider = void 0;
4
- const log_1 = require("../../../../../engine/util/log");
5
- const runner_1 = require("../runner/runner");
6
- const daemon_1 = require("../../../../../engine/daemon");
7
- const postgres_bucket_adapter_1 = require("../../postgres.bucket_adapter");
8
- const string_1 = require("../../../../../engine/util/string");
9
- const generator_1 = require("./generator");
10
- class MigrationProvider {
11
- constructor(daemon, sql, dirpath = './migrations') {
12
- this.daemon = daemon;
13
- this.sql = sql;
14
- this.dirpath = dirpath;
15
- }
16
- static async create(daemon, sql) {
17
- const provider = new MigrationProvider(daemon, sql);
18
- const oldTable = await provider.sql `
19
- SELECT * FROM pg_catalog.pg_tables WHERE tablename = ${runner_1.MigrationRunner.MIGRATION_TABLE_NAME};
20
- `;
21
- if (!oldTable.length) {
22
- await provider.sql `CREATE TABLE ${provider.sql(runner_1.MigrationRunner.MIGRATION_TABLE_NAME)} (
23
- id SERIAL PRIMARY KEY,
24
- module VARCHAR NOT NULL,
25
- name VARCHAR NOT NULL,
26
- description VARCHAR,
27
- batch INT4 NOT NULL,
28
- timestamp TIMESTAMP NOT NULL,
29
- hash VARCHAR
30
- )`;
31
- }
32
- provider.status = await runner_1.MigrationRunner.status(daemon, provider.sql, provider.dirpath);
33
- return provider;
34
- }
35
- async generate() {
36
- const modules = daemon_1.Daemon.getModules(this.daemon);
37
- const migrations = [];
38
- for (const module of modules) {
39
- const buckets = daemon_1.Daemon.getModule(this.daemon, module.name).buckets;
40
- for (const bucket in buckets) {
41
- const schema = buckets[bucket].schema;
42
- // Avoid external buckets
43
- if (schema.module !== module.name)
44
- continue;
45
- // Avoid non-postgres buckets
46
- const adapter = buckets[bucket].adapter;
47
- if (!(adapter instanceof postgres_bucket_adapter_1.PostgresBucketAdapter))
48
- continue;
49
- const migration = await this.generateForBucket(module.name, bucket, adapter.tableName);
50
- if (migration) {
51
- migrations.push(migration);
52
- }
53
- }
54
- }
55
- return migrations;
56
- }
57
- async generateForBucket(module, bucket, tableName) {
58
- const generator = new generator_1.MigrationGenerator(this.daemon, this.sql, module, bucket, tableName);
59
- const migration = await generator.generate();
60
- const tag = (0, string_1.colored)(`${module}::bucket:${bucket}`, 'lightcyan');
61
- if (!migration) {
62
- log_1.Log.info('migrator', 'bucket', `No migrations for ${tag}.`);
63
- return undefined;
64
- }
65
- const hash = migration.hash();
66
- const alreadyExists = this.status.items.find(item => item.hash === hash);
67
- if (alreadyExists && alreadyExists?.state === 'pending') {
68
- log_1.Log.warn('migrator', 'bucket', `A similar migration for ${tag} was found pending, ignoring this one.`);
69
- return undefined;
70
- }
71
- return migration;
72
- }
73
- }
74
- exports.MigrationProvider = MigrationProvider;
@@ -1,47 +0,0 @@
1
- import postgres from 'postgres';
2
- import { AnyTrxNode } from "../../../../engine/transaction/trx_node";
3
- type MigrationFn = ($: {
4
- sql: postgres.Sql<any>;
5
- trx: AnyTrxNode;
6
- }) => Promise<void>;
7
- /**
8
- * An entry on a bucket adapter describing one migration.
9
- */
10
- export type MigrationRow = {
11
- id: number;
12
- module: string;
13
- name: string;
14
- description?: string;
15
- batch: number;
16
- timestamp: string;
17
- hash: string;
18
- };
19
- /**
20
- * A file on disk describing one migration.
21
- */
22
- export type MigrationFile = {
23
- module: string;
24
- name: string;
25
- path: string;
26
- routine: MigrationRoutine;
27
- };
28
- /**
29
- * A migration routine, composed of up and down methods.
30
- */
31
- export declare class MigrationRoutine {
32
- hash?: string;
33
- description?: string;
34
- up: MigrationFn;
35
- down: MigrationFn;
36
- constructor($: {
37
- hash?: string;
38
- description?: string;
39
- up: MigrationFn;
40
- down: MigrationFn;
41
- });
42
- }
43
- /**
44
- * Function used on migration files to declare a routine
45
- */
46
- export declare function migration(...$: ConstructorParameters<typeof MigrationRoutine>): MigrationRoutine;
47
- export {};
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MigrationRoutine = void 0;
4
- exports.migration = migration;
5
- /**
6
- * A migration routine, composed of up and down methods.
7
- */
8
- class MigrationRoutine {
9
- constructor($) {
10
- this.hash = $.hash;
11
- this.description = $.description;
12
- this.up = $.up;
13
- this.down = $.down;
14
- }
15
- }
16
- exports.MigrationRoutine = MigrationRoutine;
17
- /**
18
- * Function used on migration files to declare a routine
19
- */
20
- function migration(...$) {
21
- return new MigrationRoutine(...$);
22
- }
@@ -1,17 +0,0 @@
1
- import postgres from 'postgres';
2
- import { AnyDaemon } from "../../../../../engine/daemon";
3
- import { MigrationRunnerStatus } from './status';
4
- import { $Migration } from '../generator/migration';
5
- export declare class MigrationRunner {
6
- static MIGRATION_TABLE_NAME: string;
7
- private static scanFiles;
8
- private static scanRows;
9
- static status(daemon: AnyDaemon, sql: postgres.Sql<any>, migrations_dir: string): Promise<MigrationRunnerStatus>;
10
- static up(daemon: AnyDaemon, sql: postgres.Sql<any>, mode?: 'one' | 'batch', dirpath?: string): Promise<void>;
11
- static down(daemon: AnyDaemon, sql: postgres.Sql<any>, mode?: 'one' | 'batch', dirpath?: string): Promise<void>;
12
- static fromSchema: {
13
- up: (daemon: AnyDaemon, sql: postgres.Sql<any>, migration: $Migration, dirpath?: string) => Promise<void>;
14
- };
15
- private static migrateUp;
16
- private static migrateDown;
17
- }
@@ -1,249 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- var _a;
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.MigrationRunner = void 0;
41
- const fs = __importStar(require("fs"));
42
- const path = __importStar(require("path"));
43
- const string_1 = require("../../../../../engine/util/string");
44
- const log_1 = require("../../../../../engine/util/log");
45
- const datetime_1 = require("../../../../../engine/data/datetime");
46
- const daemon_1 = require("../../../../../engine/daemon");
47
- const trx_1 = require("../../../../../engine/transaction/trx");
48
- const status_1 = require("./status");
49
- const __1 = require("..");
50
- const ui_1 = __importDefault(require("../../../../../engine/cli/ui"));
51
- class MigrationRunner {
52
- // Scan (to generate status)
53
- static async scanFiles(daemon, migrations_dir) {
54
- const modules = daemon_1.Daemon.getModules(daemon);
55
- // Read migration files of each module
56
- const files = [];
57
- for (const module of modules) {
58
- const modulepath = path.join('modules', module.name, migrations_dir);
59
- if (!fs.existsSync(modulepath))
60
- continue;
61
- fs.readdirSync(modulepath, { withFileTypes: true })
62
- .forEach(node => {
63
- const nodePath = path.resolve(modulepath, node.name);
64
- if (nodePath.endsWith('.d.ts')) {
65
- return;
66
- }
67
- files.push({
68
- module: module.name,
69
- name: node.name,
70
- path: nodePath
71
- });
72
- });
73
- }
74
- // Extract migration routine of each file
75
- const migrationFiles = [];
76
- for (const file of files) {
77
- const { default: routine } = await Promise.resolve(`${file.path}`).then(s => __importStar(require(s)));
78
- if (routine instanceof __1.MigrationRoutine) {
79
- const name = file.name.replace(/'.[t|j]s'/, '');
80
- migrationFiles.push({
81
- ...file,
82
- name,
83
- routine
84
- });
85
- }
86
- else {
87
- log_1.Log.warn('migrator', 'scan', `File at ${file.path} doesn't appear to be a migration. Skipping it.`);
88
- }
89
- }
90
- return migrationFiles;
91
- }
92
- static async scanRows(sql) {
93
- const db = await sql `
94
- SELECT * FROM ${sql(_a.MIGRATION_TABLE_NAME)}
95
- ORDER BY id
96
- `;
97
- return db;
98
- }
99
- static async status(daemon, sql, migrations_dir) {
100
- const migrationFiles = await _a.scanFiles(daemon, migrations_dir);
101
- const migrationRows = await _a.scanRows(sql);
102
- return new status_1.MigrationRunnerStatus(migrationFiles, migrationRows);
103
- }
104
- // Public Up / Down
105
- static async up(daemon, sql, mode = 'one', dirpath = 'migrations') {
106
- let status = await _a.status(daemon, sql, dirpath);
107
- console.log(status.describe());
108
- const pending = status.items.filter(item => item.state === 'pending');
109
- if (!pending.length) {
110
- log_1.Log.info('migrator', 'up', 'No migrations to run.');
111
- return;
112
- }
113
- const n = (mode === 'one' ? 1 : pending.length).toString();
114
- const confirm = await ui_1.default.yesOrNo(`Run ${(0, string_1.colored)(n, 'green')} migration(s) ${(0, string_1.colored)('▲ UP', 'lightgreen')}?`);
115
- if (!confirm) {
116
- return;
117
- }
118
- await sql.begin(async (sql) => {
119
- if (mode === 'one') {
120
- const migration = pending[0];
121
- await this.migrateUp(daemon, sql, migration, status.batch + 1);
122
- }
123
- else {
124
- for (const migration of pending) {
125
- await this.migrateUp(daemon, sql, migration, status.batch + 1);
126
- }
127
- }
128
- });
129
- status = await _a.status(daemon, sql, dirpath);
130
- console.log(status.describe());
131
- }
132
- static async down(daemon, sql, mode = 'one', dirpath = 'migrations') {
133
- let status = await _a.status(daemon, sql, dirpath);
134
- console.log(status.describe());
135
- const lastBatch = status.items.filter(item => item.batch === status.batch);
136
- if (!lastBatch.length) {
137
- log_1.Log.info('migrator', 'down', 'No migrations to rollback.');
138
- return;
139
- }
140
- const n = mode === 'one' ? 'one' : 'last batch of';
141
- const confirm = await ui_1.default.yesOrNo(`Rollback ${(0, string_1.colored)(n, 'green')} migration(s) ${(0, string_1.colored)('▼ DOWN', 'red')}?`);
142
- if (!confirm) {
143
- return;
144
- }
145
- await sql.begin(async (sql) => {
146
- if (mode === 'one') {
147
- const migration = lastBatch.at(-1);
148
- await this.migrateDown(daemon, sql, migration);
149
- }
150
- else {
151
- for (const migration of lastBatch) {
152
- await this.migrateDown(daemon, sql, migration);
153
- }
154
- }
155
- });
156
- status = await _a.status(daemon, sql, dirpath);
157
- console.log(status.describe());
158
- }
159
- // Implementation Up/Down
160
- static async migrateUp(daemon, sql, migration, batch) {
161
- log_1.Log.info('migrator', 'up', `Running migration ${(0, string_1.colored)('▲ UP', 'lightgreen')} ${(0, string_1.colored)(migration.name, 'lightblue')}`);
162
- const status = await daemon.trx(migration.module)
163
- .run(async (trx) => {
164
- trx_1.Trx.set(trx, 'sql', sql);
165
- await migration.routine.up({
166
- sql,
167
- trx
168
- });
169
- });
170
- if (status.state !== 'ok') {
171
- throw new Error('Migration failed. Rolling back all batch changes.');
172
- }
173
- const row = {
174
- module: migration.module,
175
- name: migration.name,
176
- description: migration.routine.description,
177
- batch,
178
- timestamp: datetime_1.NesoiDatetime.now(),
179
- hash: migration.hash || null
180
- };
181
- if (migration.description) {
182
- row.description = migration.description;
183
- }
184
- await sql `
185
- INSERT INTO ${sql(_a.MIGRATION_TABLE_NAME)}
186
- ${sql(row)}
187
- `;
188
- }
189
- static async migrateDown(daemon, sql, migration) {
190
- const name = (0, string_1.colored)(migration.name, 'lightblue');
191
- log_1.Log.info('migrator', 'up', `Running migration ${(0, string_1.colored)('▼ DOWN', 'yellow')} ${name}`);
192
- if (migration.state === 'lost') {
193
- const del = await ui_1.default.yesOrNo(`The migration ${name} is ${(0, string_1.colored)('lost', 'red')}, skip and delete it? ${(0, string_1.colored)('Warning: this might cause inconsistencies', 'red')}.`);
194
- if (!del) {
195
- throw new Error(`Migration ${migration.name} was lost, unable to migrate down.`);
196
- }
197
- }
198
- else {
199
- const status = await daemon.trx(migration.module)
200
- .run(async (trx) => {
201
- trx_1.Trx.set(trx, 'sql', sql);
202
- await migration.routine.down({
203
- sql,
204
- trx
205
- });
206
- });
207
- if (status.state !== 'ok') {
208
- throw new Error('Migration failed. Rolling back all batch changes.');
209
- }
210
- }
211
- await sql `
212
- DELETE FROM ${sql(_a.MIGRATION_TABLE_NAME)}
213
- WHERE id = ${migration.id}
214
- `;
215
- }
216
- }
217
- exports.MigrationRunner = MigrationRunner;
218
- _a = MigrationRunner;
219
- MigrationRunner.MIGRATION_TABLE_NAME = '__nesoi_migrations';
220
- MigrationRunner.fromSchema = {
221
- up: async (daemon, sql, migration, dirpath = 'migrations') => {
222
- let status = await _a.status(daemon, sql, dirpath);
223
- console.log(status.describe());
224
- const routine = new __1.MigrationRoutine({
225
- description: migration.description,
226
- up: async ($) => {
227
- for (const sql of migration.sqlUp()) {
228
- await $.sql.unsafe(sql);
229
- }
230
- },
231
- down: async ($) => {
232
- for (const sql of migration.sqlDown()) {
233
- await $.sql.unsafe(sql);
234
- }
235
- }
236
- });
237
- const mig = {
238
- ...migration,
239
- state: 'pending',
240
- hash: routine.hash,
241
- routine
242
- };
243
- await sql.begin(async (sql) => {
244
- await _a.migrateUp(daemon, sql, mig, status.batch + 1);
245
- });
246
- status = await _a.status(daemon, sql, dirpath);
247
- console.log(status.describe());
248
- }
249
- };
@@ -1,17 +0,0 @@
1
- import { MigrationFile, MigrationRoutine, MigrationRow } from '..';
2
- export declare class MigrationRunnerStatus {
3
- items: {
4
- state: 'done' | 'pending' | 'lost' | 'modified';
5
- id?: number;
6
- module: string;
7
- name: string;
8
- description?: string;
9
- batch?: number;
10
- timestamp?: string;
11
- hash?: string;
12
- routine?: MigrationRoutine;
13
- }[];
14
- batch: number;
15
- constructor(migrationFiles: MigrationFile[], migrationRows: MigrationRow[]);
16
- describe(): string;
17
- }
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MigrationRunnerStatus = void 0;
4
- const string_1 = require("../../../../../engine/util/string");
5
- class MigrationRunnerStatus {
6
- constructor(migrationFiles, migrationRows) {
7
- this.items = migrationRows.map(migration => ({
8
- ...migration,
9
- state: 'lost'
10
- }));
11
- migrationFiles.forEach(migration => {
12
- const hash = migration.routine.hash;
13
- const old = this.items.find(item => item.name === migration.name);
14
- if (old) {
15
- if (!old.hash || old.hash === hash) {
16
- old.state = 'done';
17
- }
18
- else {
19
- old.state = 'modified';
20
- }
21
- old.routine = migration.routine;
22
- }
23
- else {
24
- this.items.push({
25
- id: undefined,
26
- module: migration.module,
27
- name: migration.name,
28
- description: migration.routine.description,
29
- batch: undefined,
30
- hash,
31
- state: 'pending',
32
- routine: migration.routine
33
- });
34
- }
35
- });
36
- const lastBatch = Math.max(...this.items.map(item => item.batch || 0), 0);
37
- this.batch = lastBatch;
38
- }
39
- describe() {
40
- let str = '';
41
- str += `◆ ${(0, string_1.colored)('Migration Status', 'lightblue')}\n`;
42
- this.items.forEach(item => {
43
- const state = {
44
- 'done': () => (0, string_1.colored)('done', 'green'),
45
- 'pending': () => (0, string_1.colored)('pending', 'yellow'),
46
- 'lost': () => (0, string_1.colored)('lost', 'red'),
47
- 'modified': () => (0, string_1.colored)('modified', 'brown'),
48
- }[item.state]();
49
- const module = (0, string_1.colored)(item.module, 'lightcyan');
50
- str += `└ ${item.id || '*'}\t${state}\t${module} ${item.name} @ ${item.batch || '...'}\n`;
51
- });
52
- return str;
53
- }
54
- }
55
- exports.MigrationRunnerStatus = MigrationRunnerStatus;
@@ -1,42 +0,0 @@
1
- import { $Bucket } from "../../../elements";
2
- import { BucketAdapter } from "../../../elements/entities/bucket/adapters/bucket_adapter";
3
- import { AnyTrxNode } from "../../../engine/transaction/trx_node";
4
- import { NQL_QueryMeta } from "../../../elements/entities/bucket/query/nql.schema";
5
- import { PostgresProvider } from './postgres.provider';
6
- export declare class PostgresBucketAdapter<$ extends $Bucket, Obj extends $['#data']> extends BucketAdapter<$['#data']> {
7
- schema: $;
8
- provider: PostgresProvider;
9
- tableName: string;
10
- constructor(schema: $, provider: PostgresProvider, tableName: string);
11
- private guard;
12
- getQueryMeta(): {
13
- scope: string;
14
- avgTime: number;
15
- };
16
- protected deleteEverything(trx: AnyTrxNode): Promise<void>;
17
- index(trx: AnyTrxNode): Promise<Obj[]>;
18
- get(trx: AnyTrxNode, id: Obj['id']): Promise<Obj>;
19
- private precleanup;
20
- create(trx: AnyTrxNode, obj: Record<string, any>): Promise<Obj>;
21
- createMany(trx: AnyTrxNode, objs: Record<string, any>[]): Promise<Obj[]>;
22
- patch(trx: AnyTrxNode, obj: Record<string, any>): Promise<Obj>;
23
- patchMany(trx: AnyTrxNode, objs: Record<string, any>[]): Promise<$["#data"][]>;
24
- replace(trx: AnyTrxNode, obj: Record<string, any>): Promise<Obj>;
25
- replaceMany(trx: AnyTrxNode, objs: Record<string, any>[]): Promise<$["#data"][]>;
26
- put(trx: AnyTrxNode, obj: Record<string, any>): Promise<Obj>;
27
- putMany(trx: AnyTrxNode, objs: Record<string, any>[]): Promise<$["#data"][]>;
28
- delete(trx: AnyTrxNode, id: Obj['id']): Promise<void>;
29
- deleteMany(trx: AnyTrxNode, ids: Obj['id'][]): Promise<void>;
30
- syncOne(trx: AnyTrxNode, id: Obj['id'], lastObjUpdateEpoch: number): Promise<any>;
31
- syncOneAndPast(trx: AnyTrxNode, id: Obj['id'], lastUpdateEpoch: number): Promise<any>;
32
- syncAll(trx: AnyTrxNode, lastHash?: string, lastUpdateEpoch?: number): Promise<any>;
33
- static getTableMeta(trx: AnyTrxNode, meta: NQL_QueryMeta): {
34
- tableName: string;
35
- meta: {
36
- created_at: string;
37
- created_by: string;
38
- updated_at: string;
39
- updated_by: string;
40
- };
41
- };
42
- }