velocious 1.0.114 → 1.0.116
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/dist/src/database/record/index.d.ts +85 -41
- package/dist/src/database/record/index.d.ts.map +1 -1
- package/dist/src/database/record/index.js +68 -24
- package/dist/src/environment-handlers/node/cli/commands/generate/base-models.d.ts.map +1 -1
- package/dist/src/environment-handlers/node/cli/commands/generate/base-models.js +18 -1
- package/package.json +2 -2
|
@@ -82,10 +82,12 @@ declare class VelociousDatabaseRecord {
|
|
|
82
82
|
*/
|
|
83
83
|
static connection(): import("../drivers/base.js").default;
|
|
84
84
|
/**
|
|
85
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
86
|
+
* @this {MC}
|
|
85
87
|
* @param {Record<string, any>} [attributes]
|
|
86
|
-
* @returns {Promise<InstanceType<
|
|
88
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
87
89
|
*/
|
|
88
|
-
static create(attributes?: Record<string, any>): Promise<InstanceType<
|
|
90
|
+
static create<MC extends typeof VelociousDatabaseRecord>(this: MC, attributes?: Record<string, any>): Promise<InstanceType<MC>>;
|
|
89
91
|
/**
|
|
90
92
|
* @returns {import("../../configuration.js").default}
|
|
91
93
|
*/
|
|
@@ -203,88 +205,127 @@ declare class VelociousDatabaseRecord {
|
|
|
203
205
|
* @param {Record<string, boolean | Record<string, any>>} validators The validators to add. Key is the validator name, value is the validator arguments.
|
|
204
206
|
*/
|
|
205
207
|
static validates(attributeName: string, validators: Record<string, boolean | Record<string, any>>): Promise<void>;
|
|
206
|
-
/**
|
|
207
|
-
|
|
208
|
+
/**
|
|
209
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
210
|
+
* @this {MC}
|
|
211
|
+
* @returns {ModelClassQuery<MC>}
|
|
212
|
+
*/
|
|
213
|
+
static _newQuery<MC extends typeof VelociousDatabaseRecord>(this: MC): ModelClassQuery<MC>;
|
|
208
214
|
/** @returns {string} */
|
|
209
215
|
static orderableColumn(): string;
|
|
210
|
-
/**
|
|
211
|
-
|
|
216
|
+
/**
|
|
217
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
218
|
+
* @this {MC}
|
|
219
|
+
* @returns {ModelClassQuery<MC>}
|
|
220
|
+
*/
|
|
221
|
+
static all<MC extends typeof VelociousDatabaseRecord>(this: MC): ModelClassQuery<MC>;
|
|
212
222
|
/** @returns {Promise<number>} */
|
|
213
223
|
static count(): Promise<number>;
|
|
214
224
|
static destroyAll(): Promise<void>;
|
|
215
225
|
/**
|
|
226
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
227
|
+
* @this {MC}
|
|
216
228
|
* @param {number|string} recordId
|
|
217
|
-
* @returns {Promise<InstanceType<
|
|
229
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
218
230
|
*/
|
|
219
|
-
static find(recordId: number | string): Promise<InstanceType<
|
|
231
|
+
static find<MC extends typeof VelociousDatabaseRecord>(this: MC, recordId: number | string): Promise<InstanceType<MC>>;
|
|
220
232
|
/**
|
|
233
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
234
|
+
* @this {MC}
|
|
221
235
|
* @param {{[key: string]: any}} conditions
|
|
222
|
-
* @returns {Promise<InstanceType<
|
|
236
|
+
* @returns {Promise<InstanceType<MC> | null>}
|
|
223
237
|
*/
|
|
224
|
-
static findBy(conditions: {
|
|
238
|
+
static findBy<MC extends typeof VelociousDatabaseRecord>(this: MC, conditions: {
|
|
225
239
|
[key: string]: any;
|
|
226
|
-
}): Promise<InstanceType<
|
|
240
|
+
}): Promise<InstanceType<MC> | null>;
|
|
227
241
|
/**
|
|
242
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
243
|
+
* @this {MC}
|
|
228
244
|
* @param {{[key: string]: any}} conditions
|
|
229
|
-
* @returns {Promise<InstanceType<
|
|
245
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
230
246
|
*/
|
|
231
|
-
static findByOrFail(conditions: {
|
|
247
|
+
static findByOrFail<MC extends typeof VelociousDatabaseRecord>(this: MC, conditions: {
|
|
232
248
|
[key: string]: any;
|
|
233
|
-
}): Promise<InstanceType<
|
|
249
|
+
}): Promise<InstanceType<MC>>;
|
|
234
250
|
/**
|
|
251
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
252
|
+
* @this {MC}
|
|
235
253
|
* @param {{[key: string]: any}} conditions
|
|
236
254
|
* @param {function() : void} [callback]
|
|
237
|
-
* @returns {Promise<InstanceType<
|
|
255
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
238
256
|
*/
|
|
239
|
-
static findOrCreateBy(conditions: {
|
|
257
|
+
static findOrCreateBy<MC extends typeof VelociousDatabaseRecord>(this: MC, conditions: {
|
|
240
258
|
[key: string]: any;
|
|
241
|
-
}, callback?: () => void): Promise<InstanceType<
|
|
259
|
+
}, callback?: () => void): Promise<InstanceType<MC>>;
|
|
242
260
|
/**
|
|
243
|
-
* @
|
|
244
|
-
* @
|
|
245
|
-
* @
|
|
261
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
262
|
+
* @this {MC}
|
|
263
|
+
* @param {Record<string, any>} conditions
|
|
264
|
+
* @param {function(InstanceType<MC>) : void} [callback]
|
|
265
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
266
|
+
*/
|
|
267
|
+
static findOrInitializeBy<MC extends typeof VelociousDatabaseRecord>(this: MC, conditions: Record<string, any>, callback?: (arg0: InstanceType<MC>) => void): Promise<InstanceType<MC>>;
|
|
268
|
+
/**
|
|
269
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
270
|
+
* @this {MC}
|
|
271
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
246
272
|
*/
|
|
247
|
-
static
|
|
248
|
-
/** @returns {Promise<InstanceType<typeof this>>} */
|
|
249
|
-
static first(): Promise<InstanceType<typeof this>>;
|
|
273
|
+
static first<MC extends typeof VelociousDatabaseRecord>(this: MC): Promise<InstanceType<MC>>;
|
|
250
274
|
/**
|
|
275
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
276
|
+
* @this {MC}
|
|
251
277
|
* @param {string|{[key: string]: any}} join
|
|
252
|
-
* @returns {ModelClassQuery<
|
|
278
|
+
* @returns {ModelClassQuery<MC>}
|
|
253
279
|
*/
|
|
254
|
-
static joins(join: string | {
|
|
280
|
+
static joins<MC extends typeof VelociousDatabaseRecord>(this: MC, join: string | {
|
|
255
281
|
[key: string]: any;
|
|
256
|
-
}): ModelClassQuery<
|
|
257
|
-
/**
|
|
258
|
-
|
|
282
|
+
}): ModelClassQuery<MC>;
|
|
283
|
+
/**
|
|
284
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
285
|
+
* @this {MC}
|
|
286
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
287
|
+
*/
|
|
288
|
+
static last<MC extends typeof VelociousDatabaseRecord>(this: MC): Promise<InstanceType<MC>>;
|
|
259
289
|
/**
|
|
290
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
291
|
+
* @this {MC}
|
|
260
292
|
* @param {number} value
|
|
261
|
-
* @returns {ModelClassQuery<
|
|
293
|
+
* @returns {ModelClassQuery<MC>}
|
|
262
294
|
*/
|
|
263
|
-
static limit(value: number): ModelClassQuery<
|
|
295
|
+
static limit<MC extends typeof VelociousDatabaseRecord>(this: MC, value: number): ModelClassQuery<MC>;
|
|
264
296
|
/**
|
|
297
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
298
|
+
* @this {MC}
|
|
265
299
|
* @param {string | number} order
|
|
266
|
-
* @returns {ModelClassQuery<
|
|
300
|
+
* @returns {ModelClassQuery<MC>}
|
|
267
301
|
*/
|
|
268
|
-
static order(order: string | number): ModelClassQuery<
|
|
302
|
+
static order<MC extends typeof VelociousDatabaseRecord>(this: MC, order: string | number): ModelClassQuery<MC>;
|
|
269
303
|
/**
|
|
304
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
305
|
+
* @this {MC}
|
|
270
306
|
* @param {import("../query/index.js").NestedPreloadRecord} preload
|
|
271
|
-
* @returns {ModelClassQuery<typeof this>}
|
|
272
307
|
*/
|
|
273
|
-
static preload(preload: import("../query/index.js").NestedPreloadRecord): ModelClassQuery<
|
|
308
|
+
static preload<MC extends typeof VelociousDatabaseRecord>(this: MC, preload: import("../query/index.js").NestedPreloadRecord): ModelClassQuery<MC>;
|
|
274
309
|
/**
|
|
310
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
311
|
+
* @this {MC}
|
|
275
312
|
* @param {import("../query/index.js").SelectArgumentType} select
|
|
276
|
-
* @returns {ModelClassQuery<
|
|
313
|
+
* @returns {ModelClassQuery<MC>}
|
|
277
314
|
*/
|
|
278
|
-
static select(select: import("../query/index.js").SelectArgumentType): ModelClassQuery<
|
|
315
|
+
static select<MC extends typeof VelociousDatabaseRecord>(this: MC, select: import("../query/index.js").SelectArgumentType): ModelClassQuery<MC>;
|
|
279
316
|
/**
|
|
280
|
-
* @
|
|
317
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
318
|
+
* @this {MC}
|
|
319
|
+
* @returns {Promise<InstanceType<MC>[]>}
|
|
281
320
|
*/
|
|
282
|
-
static toArray(): Promise<InstanceType<
|
|
321
|
+
static toArray<MC extends typeof VelociousDatabaseRecord>(this: MC): Promise<InstanceType<MC>[]>;
|
|
283
322
|
/**
|
|
323
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
324
|
+
* @this {MC}
|
|
284
325
|
* @param {import("../query/index.js").WhereArgumentType} where
|
|
285
|
-
* @returns {ModelClassQuery<
|
|
326
|
+
* @returns {ModelClassQuery<MC>}
|
|
286
327
|
*/
|
|
287
|
-
static where(where: import("../query/index.js").WhereArgumentType): ModelClassQuery<
|
|
328
|
+
static where<MC extends typeof VelociousDatabaseRecord>(this: MC, where: import("../query/index.js").WhereArgumentType): ModelClassQuery<MC>;
|
|
288
329
|
/**
|
|
289
330
|
* @param {Record<string, any>} changes
|
|
290
331
|
*/
|
|
@@ -322,7 +363,10 @@ declare class VelociousDatabaseRecord {
|
|
|
322
363
|
* @returns {*}
|
|
323
364
|
*/
|
|
324
365
|
getAttribute(name: string): any;
|
|
325
|
-
/**
|
|
366
|
+
/**
|
|
367
|
+
* @abstract
|
|
368
|
+
* @returns {typeof VelociousDatabaseRecord}
|
|
369
|
+
*/
|
|
326
370
|
getModelClass(): typeof VelociousDatabaseRecord;
|
|
327
371
|
/**
|
|
328
372
|
* @param {string} name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/database/record/index.js"],"names":[],"mappings":";wCAGa;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC;AAkB5C;IACE;;OAEG;IACH,YAFa,uBAAuB,CAMnC;IAED;;;OAGG;IACH,gBAHW,uBAAuB,GACrB,IAAI,CAIhB;IADC,gCAAmB;IAGrB,6DAA6D;IAC7D,uBADc,MAAM,CAAC,MAAM,EAAE,yBAAyB,EAAE,CAAC,CAKxD;IAED,4EAA4E;IAC5E,sCADY,MAAM,CAAC,MAAM,EAAE,yBAAyB,EAAE,CAAC,QAGtD;IADC,+DAAyC;CAE5C;AAED;IACE,iEAOC;IAED,iEAOC;IAED,iDAOC;IAED,oFAOC;IAED,6FAOC;IAuBD,uFAEC;IAED;;;OAGG;IACH,mCAHW,MAAM,kBACN,cAAc,sBAAsB,EAAE,OAAO,QAIvD;IAED;;;OAGG;IACH,uCAHW,MAAM,GACJ,cAAc,sBAAsB,EAAE,OAAO,CAMzD;IAED;;;OAGG;IACH,6CAHW,MAAM,GACJ,OAAO,CAQnB;IAED;;;;;OAKG;IACH;;;OAGG;IACH,6CAHW,MAAM;oBALH,MAAM;gBACN,OAAO,uBAAuB;eAC9B,MAAM;aA8GnB;IAED;;;OAGG;IACH,+CAHW,MAAM,GACJ,OAAO,yBAAyB,EAAE,OAAO,CAQrD;IAED;;OAEG;IACH,2BAFa,KAAK,CAAC,OAAO,yBAAyB,EAAE,OAAO,CAAC,CAI5D;IAED,wFAOC;IAED;;OAEG;IACH,+BAFa,KAAK,CAAC,MAAM,CAAC,CAIzB;IA4BD;;;;OAIG;IACH,mCAHW,MAAM,YACN,MAAM,QAIhB;IAED;;OAEG;IACH,qBAFa,OAAO,oBAAoB,EAAE,OAAO,CAShD;IAED
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/database/record/index.js"],"names":[],"mappings":";wCAGa;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC;AAkB5C;IACE;;OAEG;IACH,YAFa,uBAAuB,CAMnC;IAED;;;OAGG;IACH,gBAHW,uBAAuB,GACrB,IAAI,CAIhB;IADC,gCAAmB;IAGrB,6DAA6D;IAC7D,uBADc,MAAM,CAAC,MAAM,EAAE,yBAAyB,EAAE,CAAC,CAKxD;IAED,4EAA4E;IAC5E,sCADY,MAAM,CAAC,MAAM,EAAE,yBAAyB,EAAE,CAAC,QAGtD;IADC,+DAAyC;CAE5C;AAED;IACE,iEAOC;IAED,iEAOC;IAED,iDAOC;IAED,oFAOC;IAED,6FAOC;IAuBD,uFAEC;IAED;;;OAGG;IACH,mCAHW,MAAM,kBACN,cAAc,sBAAsB,EAAE,OAAO,QAIvD;IAED;;;OAGG;IACH,uCAHW,MAAM,GACJ,cAAc,sBAAsB,EAAE,OAAO,CAMzD;IAED;;;OAGG;IACH,6CAHW,MAAM,GACJ,OAAO,CAQnB;IAED;;;;;OAKG;IACH;;;OAGG;IACH,6CAHW,MAAM;oBALH,MAAM;gBACN,OAAO,uBAAuB;eAC9B,MAAM;aA8GnB;IAED;;;OAGG;IACH,+CAHW,MAAM,GACJ,OAAO,yBAAyB,EAAE,OAAO,CAQrD;IAED;;OAEG;IACH,2BAFa,KAAK,CAAC,OAAO,yBAAyB,EAAE,OAAO,CAAC,CAI5D;IAED,wFAOC;IAED;;OAEG;IACH,+BAFa,KAAK,CAAC,MAAM,CAAC,CAIzB;IA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AO,CACsB;IAE3C,yBAAyB;IACzB,eADc,OAAO,CACqB;IAE1C;;;OAGG;IACH,+BAHW,OAAO,GACL,IAAI,CAIhB;IAED;;;;OAIG;IACH,cAJ8C,EAAE,SAAnC,OAAQ,uBAAwB,MAClC,MAAM,GAAG,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAiBzB;IAED;;OAEG;IACH,UAFa,OAAO,CAAC,IAAI,CAAC,CAIzB;IAED,iCAwBC;IAED,0BAA0B;IAC1B,qBADc,MAAM,EAAE,CAgBrB;IAED;;;OAGG;IACH,2BAFW,MAAM,iBAMhB;CACF;AAED;IACE;;;OAGG;IACH,UAFa,MAAM,CAIlB;CACF;4BAjpD2B,+BAA+B"}
|
|
@@ -290,11 +290,13 @@ class VelociousDatabaseRecord {
|
|
|
290
290
|
return connection;
|
|
291
291
|
}
|
|
292
292
|
/**
|
|
293
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
294
|
+
* @this {MC}
|
|
293
295
|
* @param {Record<string, any>} [attributes]
|
|
294
|
-
* @returns {Promise<InstanceType<
|
|
296
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
295
297
|
*/
|
|
296
298
|
static async create(attributes) {
|
|
297
|
-
const record = new this(attributes);
|
|
299
|
+
const record = /** @type {InstanceType<MC>} */ (new this(attributes));
|
|
298
300
|
await record.save();
|
|
299
301
|
return record;
|
|
300
302
|
}
|
|
@@ -485,7 +487,10 @@ class VelociousDatabaseRecord {
|
|
|
485
487
|
}
|
|
486
488
|
return this._attributes[columnName];
|
|
487
489
|
}
|
|
488
|
-
/**
|
|
490
|
+
/**
|
|
491
|
+
* @abstract
|
|
492
|
+
* @returns {typeof VelociousDatabaseRecord}
|
|
493
|
+
*/
|
|
489
494
|
getModelClass() {
|
|
490
495
|
const modelClass = /** @type {typeof VelociousDatabaseRecord} */ (this.constructor);
|
|
491
496
|
return modelClass;
|
|
@@ -899,7 +904,11 @@ class VelociousDatabaseRecord {
|
|
|
899
904
|
assignments[name] = newValue;
|
|
900
905
|
translation.assign(assignments);
|
|
901
906
|
}
|
|
902
|
-
/**
|
|
907
|
+
/**
|
|
908
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
909
|
+
* @this {MC}
|
|
910
|
+
* @returns {ModelClassQuery<MC>}
|
|
911
|
+
*/
|
|
903
912
|
static _newQuery() {
|
|
904
913
|
const handler = new Handler();
|
|
905
914
|
const query = new ModelClassQuery({
|
|
@@ -914,7 +923,11 @@ class VelociousDatabaseRecord {
|
|
|
914
923
|
// FIXME: Allow to change to 'created_at' if using UUID?
|
|
915
924
|
return this.primaryKey();
|
|
916
925
|
}
|
|
917
|
-
/**
|
|
926
|
+
/**
|
|
927
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
928
|
+
* @this {MC}
|
|
929
|
+
* @returns {ModelClassQuery<MC>}
|
|
930
|
+
*/
|
|
918
931
|
static all() {
|
|
919
932
|
return this._newQuery();
|
|
920
933
|
}
|
|
@@ -926,95 +939,126 @@ class VelociousDatabaseRecord {
|
|
|
926
939
|
return await this._newQuery().destroyAll();
|
|
927
940
|
}
|
|
928
941
|
/**
|
|
942
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
943
|
+
* @this {MC}
|
|
929
944
|
* @param {number|string} recordId
|
|
930
|
-
* @returns {Promise<InstanceType<
|
|
945
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
931
946
|
*/
|
|
932
947
|
static async find(recordId) {
|
|
933
948
|
return await this._newQuery().find(recordId);
|
|
934
949
|
}
|
|
935
950
|
/**
|
|
951
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
952
|
+
* @this {MC}
|
|
936
953
|
* @param {{[key: string]: any}} conditions
|
|
937
|
-
* @returns {Promise<InstanceType<
|
|
954
|
+
* @returns {Promise<InstanceType<MC> | null>}
|
|
938
955
|
*/
|
|
939
956
|
static async findBy(conditions) {
|
|
940
957
|
return await this._newQuery().findBy(conditions);
|
|
941
958
|
}
|
|
942
959
|
/**
|
|
960
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
961
|
+
* @this {MC}
|
|
943
962
|
* @param {{[key: string]: any}} conditions
|
|
944
|
-
* @returns {Promise<InstanceType<
|
|
963
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
945
964
|
*/
|
|
946
965
|
static async findByOrFail(conditions) {
|
|
947
966
|
return await this._newQuery().findByOrFail(conditions);
|
|
948
967
|
}
|
|
949
968
|
/**
|
|
969
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
970
|
+
* @this {MC}
|
|
950
971
|
* @param {{[key: string]: any}} conditions
|
|
951
972
|
* @param {function() : void} [callback]
|
|
952
|
-
* @returns {Promise<InstanceType<
|
|
973
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
953
974
|
*/
|
|
954
975
|
static async findOrCreateBy(conditions, callback) {
|
|
955
976
|
return await this._newQuery().findOrCreateBy(conditions, callback);
|
|
956
977
|
}
|
|
957
978
|
/**
|
|
958
|
-
* @
|
|
959
|
-
* @
|
|
960
|
-
* @
|
|
979
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
980
|
+
* @this {MC}
|
|
981
|
+
* @param {Record<string, any>} conditions
|
|
982
|
+
* @param {function(InstanceType<MC>) : void} [callback]
|
|
983
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
961
984
|
*/
|
|
962
985
|
static async findOrInitializeBy(conditions, callback) {
|
|
963
986
|
return await this._newQuery().findOrInitializeBy(conditions, callback);
|
|
964
987
|
}
|
|
965
|
-
/**
|
|
988
|
+
/**
|
|
989
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
990
|
+
* @this {MC}
|
|
991
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
992
|
+
*/
|
|
966
993
|
static async first() {
|
|
967
994
|
return await this._newQuery().first();
|
|
968
995
|
}
|
|
969
996
|
/**
|
|
997
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
998
|
+
* @this {MC}
|
|
970
999
|
* @param {string|{[key: string]: any}} join
|
|
971
|
-
* @returns {ModelClassQuery<
|
|
1000
|
+
* @returns {ModelClassQuery<MC>}
|
|
972
1001
|
*/
|
|
973
1002
|
static joins(join) {
|
|
974
1003
|
return this._newQuery().joins(join);
|
|
975
1004
|
}
|
|
976
|
-
/**
|
|
1005
|
+
/**
|
|
1006
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
1007
|
+
* @this {MC}
|
|
1008
|
+
* @returns {Promise<InstanceType<MC>>}
|
|
1009
|
+
*/
|
|
977
1010
|
static async last() {
|
|
978
1011
|
return await this._newQuery().last();
|
|
979
1012
|
}
|
|
980
1013
|
/**
|
|
1014
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
1015
|
+
* @this {MC}
|
|
981
1016
|
* @param {number} value
|
|
982
|
-
* @returns {ModelClassQuery<
|
|
1017
|
+
* @returns {ModelClassQuery<MC>}
|
|
983
1018
|
*/
|
|
984
1019
|
static limit(value) {
|
|
985
1020
|
return this._newQuery().limit(value);
|
|
986
1021
|
}
|
|
987
1022
|
/**
|
|
1023
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
1024
|
+
* @this {MC}
|
|
988
1025
|
* @param {string | number} order
|
|
989
|
-
* @returns {ModelClassQuery<
|
|
1026
|
+
* @returns {ModelClassQuery<MC>}
|
|
990
1027
|
*/
|
|
991
1028
|
static order(order) {
|
|
992
1029
|
return this._newQuery().order(order);
|
|
993
1030
|
}
|
|
994
1031
|
/**
|
|
1032
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
1033
|
+
* @this {MC}
|
|
995
1034
|
* @param {import("../query/index.js").NestedPreloadRecord} preload
|
|
996
|
-
* @returns {ModelClassQuery<typeof this>}
|
|
997
1035
|
*/
|
|
998
1036
|
static preload(preload) {
|
|
999
|
-
|
|
1037
|
+
const query = /** @type {ModelClassQuery<MC>} */ (this._newQuery().preload(preload));
|
|
1038
|
+
return query;
|
|
1000
1039
|
}
|
|
1001
1040
|
/**
|
|
1041
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
1042
|
+
* @this {MC}
|
|
1002
1043
|
* @param {import("../query/index.js").SelectArgumentType} select
|
|
1003
|
-
* @returns {ModelClassQuery<
|
|
1044
|
+
* @returns {ModelClassQuery<MC>}
|
|
1004
1045
|
*/
|
|
1005
1046
|
static select(select) {
|
|
1006
1047
|
return this._newQuery().select(select);
|
|
1007
1048
|
}
|
|
1008
1049
|
/**
|
|
1009
|
-
* @
|
|
1050
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
1051
|
+
* @this {MC}
|
|
1052
|
+
* @returns {Promise<InstanceType<MC>[]>}
|
|
1010
1053
|
*/
|
|
1011
1054
|
static async toArray() {
|
|
1012
|
-
|
|
1013
|
-
return await modelClassQuery.toArray();
|
|
1055
|
+
return await this._newQuery().toArray();
|
|
1014
1056
|
}
|
|
1015
1057
|
/**
|
|
1058
|
+
* @template {typeof VelociousDatabaseRecord} MC
|
|
1059
|
+
* @this {MC}
|
|
1016
1060
|
* @param {import("../query/index.js").WhereArgumentType} where
|
|
1017
|
-
* @returns {ModelClassQuery<
|
|
1061
|
+
* @returns {ModelClassQuery<MC>}
|
|
1018
1062
|
*/
|
|
1019
1063
|
static where(where) {
|
|
1020
1064
|
return this._newQuery().where(where);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-models.d.ts","sourceRoot":"","sources":["../../../../../../../src/environment-handlers/node/cli/commands/generate/base-models.js"],"names":[],"mappings":"AAKA;IACE,
|
|
1
|
+
{"version":3,"file":"base-models.d.ts","sourceRoot":"","sources":["../../../../../../../src/environment-handlers/node/cli/commands/generate/base-models.js"],"names":[],"mappings":"AAKA;IACE,yBAuQC;IAED;;;OAGG;IACH,4BAHW,OAAO,gDAAgD,EAAE,OAAO,GAC9D,MAAM,GAAG,SAAS,CAkB9B;CACF;wBApSuB,oCAAoC"}
|
|
@@ -41,6 +41,23 @@ export default class DbGenerateModel extends BaseCommand {
|
|
|
41
41
|
fileContent += `import DatabaseRecord from "${velociousPath}/database/record/index.js"\n\n`;
|
|
42
42
|
const hasManyRelationFilePath = `${velociousPath}/database/record/instance-relationships/has-many.js`;
|
|
43
43
|
fileContent += `export default class ${modelNameCamelized}Base extends DatabaseRecord {\n`;
|
|
44
|
+
// --- getModelClass() override (fixes polymorphic typing in JS/JSDoc) ---
|
|
45
|
+
if (await fileExists(sourceModelFullFilePath)) {
|
|
46
|
+
// Model file exists (e.g. src/models/ticket.js) → return typeof Ticket
|
|
47
|
+
fileContent += " /**\n";
|
|
48
|
+
fileContent += ` * @returns {typeof import("${sourceModelFilePath}").default}\n`;
|
|
49
|
+
fileContent += " */\n";
|
|
50
|
+
fileContent += " // @ts-ignore - override narrows return type for better IntelliSense in generated model bases\n";
|
|
51
|
+
fileContent += ` getModelClass() { return /** @type {typeof import("${sourceModelFilePath}").default} */ (this.constructor) }\n\n`;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// No model file yet → fall back to typeof TicketBase
|
|
55
|
+
fileContent += " /**\n";
|
|
56
|
+
fileContent += ` * @returns {typeof ${modelNameCamelized}Base}\n`;
|
|
57
|
+
fileContent += " */\n";
|
|
58
|
+
fileContent += " // @ts-ignore - override narrows return type for better IntelliSense in generated model bases\n";
|
|
59
|
+
fileContent += ` getModelClass() { return /** @type {typeof ${modelNameCamelized}Base} */ (this.constructor) }\n\n`;
|
|
60
|
+
}
|
|
44
61
|
const columns = await modelClass._getTable().getColumns();
|
|
45
62
|
let methodsCount = 0;
|
|
46
63
|
for (const column of columns) {
|
|
@@ -180,7 +197,7 @@ export default class DbGenerateModel extends BaseCommand {
|
|
|
180
197
|
fileContent += " /**\n";
|
|
181
198
|
fileContent += ` * @returns {import("${hasManyRelationFilePath}").default<typeof import("${sourceModelFilePath}").default, typeof import("${recordImport}").default>}\n`;
|
|
182
199
|
fileContent += " */\n";
|
|
183
|
-
fileContent += ` ${relationship.getRelationshipName()}() { return /** @type {import("${hasManyRelationFilePath}").default} */ (this.getRelationshipByName("${relationship.getRelationshipName()}")) }\n`;
|
|
200
|
+
fileContent += ` ${relationship.getRelationshipName()}() { return /** @type {import("${hasManyRelationFilePath}").default<typeof import("${sourceModelFilePath}").default, typeof import("${recordImport}").default>} */ (this.getRelationshipByName("${relationship.getRelationshipName()}")) }\n`;
|
|
184
201
|
fileContent += "\n";
|
|
185
202
|
fileContent += " /**\n";
|
|
186
203
|
fileContent += ` * @returns {Array<import("${recordImport}").default>}\n`;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"velocious": "dist/bin/velocious.js"
|
|
4
4
|
},
|
|
5
5
|
"name": "velocious",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.116",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"files": ["dist/**"],
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"build": "rm -rf dist && tsc -p tsconfig.build.json && chmod +x dist/bin/velocious.js",
|
|
12
12
|
"lint": "eslint",
|
|
13
13
|
"test": "VELOCIOUS_TEST_DIR=../ cd spec/dummy && npx velocious test",
|
|
14
|
-
"prepublishOnly": "npm run build",
|
|
14
|
+
"prepublishOnly": "npm run build && chmod +x dist/bin/velocious.js",
|
|
15
15
|
"typecheck": "tsc --noEmit",
|
|
16
16
|
"velocious": "asd",
|
|
17
17
|
"watch": "tsc -p tsconfig.build.json -w"
|