imodel 0.1.0 → 0.3.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/migrate.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * imodel v0.1.0
2
+ * imodel v0.3.0
3
3
  * (c) 2019-2025 undefined
4
4
  * @license undefined
5
5
  */
6
6
 
7
- import { TransactionFn, Connection, IndexOptions, ColumnOptions, Column, Index, TableDefine } from 'imodel';
7
+ import { TransactionFn, Connection, IndexOptions, FieldType, ColumnOptions, Column, Index, TableDefine } from 'imodel';
8
8
 
9
9
  /**
10
10
  *
@@ -185,7 +185,7 @@ declare class MigrationType implements Migrator$4 {
185
185
  }
186
186
  type Migrator$4 = Migrator;
187
187
 
188
- /** @import { IndexOptions, ColumnOptions } from 'imodel' */
188
+ /** @import { IndexOptions, ColumnOptions, FieldType } from 'imodel' */
189
189
  /**
190
190
  * @abstract
191
191
  */
@@ -200,11 +200,11 @@ declare class TableAdder {
200
200
  /**
201
201
  * @abstract
202
202
  * @param {string} name
203
- * @param {string} type
203
+ * @param {keyof FieldType} type
204
204
  * @param {ColumnOptions<any>} [options]
205
205
  * @returns {this}
206
206
  */
207
- field(name: string, type: string, options?: ColumnOptions<any>): this;
207
+ field(name: string, type: keyof FieldType, options?: ColumnOptions<any>): this;
208
208
  /**
209
209
  * @param {string} name
210
210
  * @param {ColumnOptions<string>} [options]
@@ -223,12 +223,6 @@ declare class TableAdder {
223
223
  * @returns {this}
224
224
  */
225
225
  text(name: string, options?: ColumnOptions<string>): this;
226
- /**
227
- * @param {string} name
228
- * @param {ColumnOptions<never>} [options]
229
- * @returns {this}
230
- */
231
- id(name: string, options?: ColumnOptions<never>): this;
232
226
  /**
233
227
  * @param {string} name
234
228
  * @param {ColumnOptions<number | bigint>} [options]
@@ -241,42 +235,12 @@ declare class TableAdder {
241
235
  * @returns {this}
242
236
  */
243
237
  i32(name: string, options?: ColumnOptions<number | bigint>): this;
244
- /**
245
- * @param {string} name
246
- * @param {ColumnOptions<number | bigint>} [options]
247
- * @returns {this}
248
- */
249
- i52(name: string, options?: ColumnOptions<number | bigint>): this;
250
238
  /**
251
239
  * @param {string} name
252
240
  * @param {ColumnOptions<number | bigint>} [options]
253
241
  * @returns {this}
254
242
  */
255
243
  i64(name: string, options?: ColumnOptions<number | bigint>): this;
256
- /**
257
- * @param {string} name
258
- * @param {ColumnOptions<number | bigint>} [options]
259
- * @returns {this}
260
- */
261
- u16(name: string, options?: ColumnOptions<number | bigint>): this;
262
- /**
263
- * @param {string} name
264
- * @param {ColumnOptions<number | bigint>} [options]
265
- * @returns {this}
266
- */
267
- u32(name: string, options?: ColumnOptions<number | bigint>): this;
268
- /**
269
- * @param {string} name
270
- * @param {ColumnOptions<number | bigint>} [options]
271
- * @returns {this}
272
- */
273
- u52(name: string, options?: ColumnOptions<number | bigint>): this;
274
- /**
275
- * @param {string} name
276
- * @param {ColumnOptions<number | bigint>} [options]
277
- * @returns {this}
278
- */
279
- u64(name: string, options?: ColumnOptions<number | bigint>): this;
280
244
  /**
281
245
  * @param {string} name
282
246
  * @param {ColumnOptions<number | bigint>} [options]
@@ -307,12 +271,6 @@ declare class TableAdder {
307
271
  * @returns {this}
308
272
  */
309
273
  money(name: string, options?: ColumnOptions<number | bigint>): this;
310
- /**
311
- * @param {string} name
312
- * @param {ColumnOptions<number | bigint>} [options]
313
- * @returns {this}
314
- */
315
- bin(name: string, options?: ColumnOptions<number | bigint>): this;
316
274
  /**
317
275
  * @param {string} name
318
276
  * @param {ColumnOptions<never>} [options]
@@ -385,6 +343,12 @@ declare class TableAdder {
385
343
  * @returns {this}
386
344
  */
387
345
  object(name: string, options?: ColumnOptions<object>): this;
346
+ /**
347
+ * @param {string} name
348
+ * @param {ColumnOptions<object>} [options]
349
+ * @returns {this}
350
+ */
351
+ json(name: string, options?: ColumnOptions<object>): this;
388
352
  /**
389
353
  * @returns {this}
390
354
  */
@@ -651,13 +615,6 @@ declare function sqlite3(...list: (Migrator | Migrator[])[]): MigrationType;
651
615
  * @returns
652
616
  */
653
617
  declare function table(table: string | TableDefine): TableCreator;
654
- /**
655
- *
656
- * @param {string} ta
657
- * @param {string} tb
658
- * @returns
659
- */
660
- declare function joinTable(ta: string, tb: string): TableCreator;
661
618
 
662
619
  type Migrator = {
663
620
  tables: (revert?: boolean | undefined) => Iterable<string>;
@@ -665,4 +622,4 @@ type Migrator = {
665
622
  down: (connection: Connection, echoDescription: Echo) => PromiseLike<void> | void;
666
623
  };
667
624
 
668
- export { Echo, type MigrationDef, type MigrationDefine, type MigrationPromise, type MigrationValue, type Migrator, _default as auto, _default$1 as createEcho, customize, down, create as exec, joinTable, mysql, postgres, revert, sqlite, sqlite3, table, type, up };
625
+ export { Echo, type MigrationDef, type MigrationDefine, type MigrationPromise, type MigrationValue, type Migrator, _default as auto, _default$1 as createEcho, customize, down, create as exec, mysql, postgres, revert, sqlite, sqlite3, table, type, up };
package/migrate.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * imodel v0.1.0
2
+ * imodel v0.3.0
3
3
  * (c) 2019-2025 undefined
4
4
  * @license undefined
5
5
  */
6
6
 
7
- import { Query, define } from 'imodel';
7
+ import { now, Query, define } from 'imodel';
8
8
 
9
9
  /** @import { Connection } from 'imodel' */
10
10
  /** @typedef {import('./index.mjs').Migrator} Migrator */
@@ -55,7 +55,7 @@ class Reverter {
55
55
  }
56
56
  }
57
57
 
58
- /** @import { IndexOptions, ColumnOptions } from 'imodel' */
58
+ /** @import { IndexOptions, ColumnOptions, FieldType } from 'imodel' */
59
59
  /**
60
60
  * @abstract
61
61
  */
@@ -72,7 +72,7 @@ class TableAdder {
72
72
  /**
73
73
  * @abstract
74
74
  * @param {string} name
75
- * @param {string} type
75
+ * @param {keyof FieldType} type
76
76
  * @param {ColumnOptions<any>} [options]
77
77
  * @returns {this}
78
78
  */
@@ -103,14 +103,6 @@ class TableAdder {
103
103
  text(name, options) {
104
104
  return this.field(name, 'text', options);
105
105
  }
106
- /**
107
- * @param {string} name
108
- * @param {ColumnOptions<never>} [options]
109
- * @returns {this}
110
- */
111
- id(name, options) {
112
- return this.field(name, 'id', options);
113
- }
114
106
  /**
115
107
  * @param {string} name
116
108
  * @param {ColumnOptions<number | bigint>} [options]
@@ -127,14 +119,6 @@ class TableAdder {
127
119
  i32(name, options) {
128
120
  return this.field(name, 'i32', options);
129
121
  }
130
- /**
131
- * @param {string} name
132
- * @param {ColumnOptions<number | bigint>} [options]
133
- * @returns {this}
134
- */
135
- i52(name, options) {
136
- return this.field(name, 'i52', options);
137
- }
138
122
  /**
139
123
  * @param {string} name
140
124
  * @param {ColumnOptions<number | bigint>} [options]
@@ -143,38 +127,6 @@ class TableAdder {
143
127
  i64(name, options) {
144
128
  return this.field(name, 'i64', options);
145
129
  }
146
- /**
147
- * @param {string} name
148
- * @param {ColumnOptions<number | bigint>} [options]
149
- * @returns {this}
150
- */
151
- u16(name, options) {
152
- return this.field(name, 'u16', options);
153
- }
154
- /**
155
- * @param {string} name
156
- * @param {ColumnOptions<number | bigint>} [options]
157
- * @returns {this}
158
- */
159
- u32(name, options) {
160
- return this.field(name, 'u32', options);
161
- }
162
- /**
163
- * @param {string} name
164
- * @param {ColumnOptions<number | bigint>} [options]
165
- * @returns {this}
166
- */
167
- u52(name, options) {
168
- return this.field(name, 'u52', options);
169
- }
170
- /**
171
- * @param {string} name
172
- * @param {ColumnOptions<number | bigint>} [options]
173
- * @returns {this}
174
- */
175
- u64(name, options) {
176
- return this.field(name, 'u64', options);
177
- }
178
130
  /**
179
131
  * @param {string} name
180
132
  * @param {ColumnOptions<number | bigint>} [options]
@@ -215,14 +167,6 @@ class TableAdder {
215
167
  money(name, options) {
216
168
  return this.field(name, 'money', options);
217
169
  }
218
- /**
219
- * @param {string} name
220
- * @param {ColumnOptions<number | bigint>} [options]
221
- * @returns {this}
222
- */
223
- bin(name, options) {
224
- return this.field(name, 'bin', options);
225
- }
226
170
  /**
227
171
  * @param {string} name
228
172
  * @param {ColumnOptions<never>} [options]
@@ -319,7 +263,7 @@ class TableAdder {
319
263
  * @returns {this}
320
264
  */
321
265
  uuid(name, options) {
322
- return this.field(name, 'bool', options);
266
+ return this.field(name, 'uuid', options);
323
267
  }
324
268
  /**
325
269
  * @param {string} name
@@ -327,7 +271,15 @@ class TableAdder {
327
271
  * @returns {this}
328
272
  */
329
273
  object(name, options) {
330
- return this.field(name, 'bool', options);
274
+ return this.field(name, 'object', options);
275
+ }
276
+ /**
277
+ * @param {string} name
278
+ * @param {ColumnOptions<object>} [options]
279
+ * @returns {this}
280
+ */
281
+ json(name, options) {
282
+ return this.field(name, 'json', options);
331
283
  }
332
284
  /**
333
285
  * @returns {this}
@@ -335,7 +287,7 @@ class TableAdder {
335
287
  createTime() {
336
288
  return this.field('createOn', 'timestamp', {
337
289
  nullable: true,
338
- timestampCreating: true
290
+ creating: now
339
291
  });
340
292
  }
341
293
  /**
@@ -344,7 +296,7 @@ class TableAdder {
344
296
  updateTime() {
345
297
  return this.field('updateOn', 'timestamp', {
346
298
  nullable: true,
347
- timestampUpdating: true
299
+ updating: now
348
300
  });
349
301
  }
350
302
  /**
@@ -352,7 +304,8 @@ class TableAdder {
352
304
  */
353
305
  deleteTime() {
354
306
  return this.field('deleteOn', 'timestamp', {
355
- nullable: true
307
+ nullable: true,
308
+ deleting: now
356
309
  });
357
310
  }
358
311
  }
@@ -903,7 +856,7 @@ class TableCreator extends TableAdder {
903
856
  if (!type.table) {
904
857
  this.field(name, 'object', {
905
858
  ...field,
906
- primary: false
859
+ primary: 0
907
860
  });
908
861
  continue;
909
862
  }
@@ -1219,13 +1172,13 @@ async function create(connection, migrations, log, revert) {
1219
1172
  /** @typedef {MigrationDef | PromiseLike<MigrationDef>} MigrationPromise */
1220
1173
  /** @typedef {MigrationPromise | (() => MigrationPromise)} MigrationDefine */
1221
1174
  const TableMigration = Query.table('__table_migrations', {
1222
- no: define('i64', {
1175
+ group: define('string', {
1223
1176
  nullable: false,
1224
- primary: true
1177
+ primary: 1
1225
1178
  }),
1226
- group: define('string', {
1179
+ no: define('i64', {
1227
1180
  nullable: false,
1228
- primary: true
1181
+ primary: 2
1229
1182
  })
1230
1183
  });
1231
1184
  const tableMigrationsMigrator = new TableCreator(TableMigration);
@@ -1530,14 +1483,5 @@ function sqlite3(...list) {
1530
1483
  function table(table) {
1531
1484
  return new TableCreator(table);
1532
1485
  }
1533
- /**
1534
- *
1535
- * @param {string} ta
1536
- * @param {string} tb
1537
- * @returns
1538
- */
1539
- function joinTable(ta, tb) {
1540
- return new TableCreator(`${ta}_${tb}`).id(`${ta}_id`).id(`${tb}_id`);
1541
- }
1542
1486
 
1543
- export { auto, createEcho, customize, down, create as exec, joinTable, mysql, postgres, revert, sqlite, sqlite3, table, type, up };
1487
+ export { auto, createEcho, customize, down, create as exec, mysql, postgres, revert, sqlite, sqlite3, table, type, up };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imodel",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "main": "index.mjs",
5
5
  "type": "module",
6
6
  "repository": {