imodel 0.19.3 → 0.20.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/index.d.mts +268 -107
- package/index.mjs +3324 -2836
- package/migrate.d.mts +5 -4
- package/migrate.mjs +22 -3
- package/package.json +3 -1
package/migrate.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* imodel v0.
|
|
3
|
-
* (c) 2019-2026
|
|
4
|
-
* @license
|
|
2
|
+
* imodel v0.20.0
|
|
3
|
+
* (c) 2019-2026 猛火Fierflame
|
|
4
|
+
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { TransactionFn, Connection, IndexOptions, FieldType, ColumnOptions, Column, Index, TableDefine } from 'imodel';
|
|
@@ -622,4 +622,5 @@ type Migrator = {
|
|
|
622
622
|
down: (connection: Connection, echoDescription: Echo) => PromiseLike<void> | void;
|
|
623
623
|
};
|
|
624
624
|
|
|
625
|
-
export { Echo,
|
|
625
|
+
export { Echo, _default as auto, _default$1 as createEcho, customize, down, create as exec, mysql, postgres, revert, sqlite, sqlite3, table, type, up };
|
|
626
|
+
export type { MigrationDef, MigrationDefine, MigrationPromise, MigrationValue, Migrator };
|
package/migrate.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* imodel v0.
|
|
3
|
-
* (c) 2019-2026
|
|
4
|
-
* @license
|
|
2
|
+
* imodel v0.20.0
|
|
3
|
+
* (c) 2019-2026 猛火Fierflame
|
|
4
|
+
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { now, Query, define } from 'imodel';
|
|
@@ -9,6 +9,7 @@ import { now, Query, define } from 'imodel';
|
|
|
9
9
|
/** @import { Connection } from 'imodel' */
|
|
10
10
|
/** @typedef {import('./index.mjs').Migrator} Migrator */
|
|
11
11
|
/** @import { Echo } from './createEcho.mjs' */
|
|
12
|
+
|
|
12
13
|
/** @implements {Migrator} */
|
|
13
14
|
class Reverter {
|
|
14
15
|
/** @readonly @type {readonly Migrator[]} */
|
|
@@ -56,6 +57,7 @@ class Reverter {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
/** @import { IndexOptions, ColumnOptions, FieldType } from 'imodel' */
|
|
60
|
+
|
|
59
61
|
/**
|
|
60
62
|
* @abstract
|
|
61
63
|
*/
|
|
@@ -143,6 +145,7 @@ class TableAdder {
|
|
|
143
145
|
f64(name, options) {
|
|
144
146
|
return this.field(name, 'f64', options);
|
|
145
147
|
}
|
|
148
|
+
|
|
146
149
|
/**
|
|
147
150
|
* @param {string} name
|
|
148
151
|
* @param {ColumnOptions<number | bigint>} [options]
|
|
@@ -167,6 +170,7 @@ class TableAdder {
|
|
|
167
170
|
money(name, options) {
|
|
168
171
|
return this.field(name, 'money', options);
|
|
169
172
|
}
|
|
173
|
+
|
|
170
174
|
/**
|
|
171
175
|
* @param {string} name
|
|
172
176
|
* @param {ColumnOptions<never>} [options]
|
|
@@ -313,11 +317,13 @@ class TableAdder {
|
|
|
313
317
|
/** @typedef {import('./index.mjs').Migrator} Migrator */
|
|
314
318
|
/** @import { Column, Connection, Index } from 'imodel' */
|
|
315
319
|
/** @import { Echo } from './createEcho.mjs' */
|
|
320
|
+
|
|
316
321
|
/**
|
|
317
322
|
*
|
|
318
323
|
* @param {TableCreator | TableModifier} v
|
|
319
324
|
* @returns {string[]}
|
|
320
325
|
*/
|
|
326
|
+
|
|
321
327
|
function getIndexes(v) {
|
|
322
328
|
if (v instanceof TableCreator) {
|
|
323
329
|
return Object.keys(v.indexes);
|
|
@@ -383,6 +389,7 @@ function get(v) {
|
|
|
383
389
|
}
|
|
384
390
|
return [fields, indexes, _columns, _indexes];
|
|
385
391
|
}
|
|
392
|
+
|
|
386
393
|
/**
|
|
387
394
|
* @implements {Migrator}
|
|
388
395
|
*/
|
|
@@ -410,6 +417,7 @@ class TableDrop {
|
|
|
410
417
|
tables(revert) {
|
|
411
418
|
return revert ? [this.name] : [];
|
|
412
419
|
}
|
|
420
|
+
|
|
413
421
|
/**
|
|
414
422
|
* @param {Connection} connection
|
|
415
423
|
* @param {Echo} echoDescription
|
|
@@ -454,6 +462,7 @@ class TableDrop {
|
|
|
454
462
|
/** @typedef {import('./index.mjs').Migrator} Migrator */
|
|
455
463
|
/** @import { Column, ColumnOptions, Connection, Index, IndexOptions } from 'imodel' */
|
|
456
464
|
/** @import { Echo } from './createEcho.mjs' */
|
|
465
|
+
|
|
457
466
|
/**
|
|
458
467
|
*
|
|
459
468
|
* @param {string} name
|
|
@@ -528,6 +537,7 @@ class TableModifier extends TableAdder {
|
|
|
528
537
|
tables(revert) {
|
|
529
538
|
return revert ? [this.name] : [this.newName || this.name];
|
|
530
539
|
}
|
|
540
|
+
|
|
531
541
|
/**
|
|
532
542
|
* @readonly
|
|
533
543
|
* @type {(['field', string, Column<any>] | ['index', string, Index] | ['changeColumn', string, Column<any>] | ['removeColumn', string] | ['removeIndex', string] | ['renameColumn', string, string])[]}
|
|
@@ -602,6 +612,7 @@ class TableModifier extends TableAdder {
|
|
|
602
612
|
this.name = last.name;
|
|
603
613
|
}
|
|
604
614
|
}
|
|
615
|
+
|
|
605
616
|
/**
|
|
606
617
|
* @param {string} name
|
|
607
618
|
* @returns {this}
|
|
@@ -817,6 +828,7 @@ class TableModifier extends TableAdder {
|
|
|
817
828
|
/** @typedef {import('./index.mjs').Migrator} Migrator */
|
|
818
829
|
/** @import { Column, ColumnOptions, Connection, Index, IndexOptions, TableDefine } from 'imodel' */
|
|
819
830
|
/** @import { Echo } from './createEcho.mjs' */
|
|
831
|
+
|
|
820
832
|
/**
|
|
821
833
|
* @implements {Migrator}
|
|
822
834
|
*/
|
|
@@ -977,6 +989,7 @@ class TableCreator extends TableAdder {
|
|
|
977
989
|
/** @import { Connection } from 'imodel' */
|
|
978
990
|
/** @import { Echo } from './createEcho.mjs' */
|
|
979
991
|
/** @typedef {import('./index.mjs').Migrator} Migrator */
|
|
992
|
+
|
|
980
993
|
/** @implements {Migrator} */
|
|
981
994
|
class MigrationType {
|
|
982
995
|
/** @readonly @type {readonly Migrator[]} */
|
|
@@ -1090,6 +1103,7 @@ class Customize {
|
|
|
1090
1103
|
}
|
|
1091
1104
|
|
|
1092
1105
|
/** @interface Echo */
|
|
1106
|
+
|
|
1093
1107
|
/**
|
|
1094
1108
|
*
|
|
1095
1109
|
* @param {((v: string) => void) | boolean} [log]
|
|
@@ -1174,6 +1188,7 @@ async function create(connection, migrations, log, revert) {
|
|
|
1174
1188
|
/** @typedef {MigrationValue | { default: MigrationValue }} MigrationDef */
|
|
1175
1189
|
/** @typedef {MigrationDef | PromiseLike<MigrationDef>} MigrationPromise */
|
|
1176
1190
|
/** @typedef {MigrationPromise | (() => MigrationPromise)} MigrationDefine */
|
|
1191
|
+
|
|
1177
1192
|
const TableMigration = Query.table('__table_migrations', {
|
|
1178
1193
|
group: define('string', {
|
|
1179
1194
|
nullable: false,
|
|
@@ -1289,6 +1304,7 @@ function getUpList(list, target) {
|
|
|
1289
1304
|
}
|
|
1290
1305
|
return list.filter(m => m.no <= target && m.no);
|
|
1291
1306
|
}
|
|
1307
|
+
|
|
1292
1308
|
/**
|
|
1293
1309
|
*
|
|
1294
1310
|
* @param {Info[]} list
|
|
@@ -1383,12 +1399,14 @@ async function auto (runTransaction, migrations, {
|
|
|
1383
1399
|
|
|
1384
1400
|
/** @export { Echo } from './createEcho.mjs' */
|
|
1385
1401
|
/** @export { MigrationValue, MigrationDef, MigrationPromise, MigrationDefine } from './auto.mjs' */
|
|
1402
|
+
|
|
1386
1403
|
/**
|
|
1387
1404
|
* @typedef {object} Migrator
|
|
1388
1405
|
* @property {(revert?: boolean | undefined) => Iterable<string>} tables
|
|
1389
1406
|
* @property {(connection: Connection, echoDescription: Echo) => PromiseLike<void> | void} up
|
|
1390
1407
|
* @property {(connection: Connection, echoDescription: Echo) => PromiseLike<void> | void} down
|
|
1391
1408
|
*/
|
|
1409
|
+
|
|
1392
1410
|
/**
|
|
1393
1411
|
*
|
|
1394
1412
|
* @param {((connection: Connection) => void | PromiseLike<void>)?} [up]
|
|
@@ -1437,6 +1455,7 @@ function revert(...list) {
|
|
|
1437
1455
|
// export {
|
|
1438
1456
|
// _catch as catch,
|
|
1439
1457
|
// };
|
|
1458
|
+
|
|
1440
1459
|
/**
|
|
1441
1460
|
*
|
|
1442
1461
|
* @param {string} type
|
package/package.json
CHANGED