velocious 1.0.99 → 1.0.101

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 (40) hide show
  1. package/package.json +1 -1
  2. package/spec/database/migration/column-exists-spec.js +28 -0
  3. package/spec/database/record/create-spec.js +14 -7
  4. package/spec/database/transactions-spec.js +8 -1
  5. package/spec/dummy/src/model-bases/account.js +67 -0
  6. package/spec/dummy/src/model-bases/authentication-token.js +108 -0
  7. package/spec/dummy/src/model-bases/project-detail.js +101 -0
  8. package/spec/dummy/src/model-bases/project-translation.js +124 -0
  9. package/spec/dummy/src/model-bases/project.js +178 -0
  10. package/spec/dummy/src/model-bases/task.js +117 -0
  11. package/spec/dummy/src/model-bases/user.js +170 -0
  12. package/spec/dummy/src/models/account.js +2 -2
  13. package/spec/dummy/src/models/authentication-token.js +2 -2
  14. package/spec/dummy/src/models/project-detail.js +2 -2
  15. package/spec/dummy/src/models/project.js +2 -2
  16. package/spec/dummy/src/models/task.js +2 -2
  17. package/spec/dummy/src/models/user.js +2 -2
  18. package/src/cli/base-command.js +1 -1
  19. package/src/configuration.js +6 -2
  20. package/src/database/drivers/base-column.js +8 -7
  21. package/src/database/drivers/base-columns-index.js +1 -1
  22. package/src/database/drivers/base-foreign-key.js +5 -5
  23. package/src/database/drivers/base-table.js +4 -4
  24. package/src/database/drivers/base.js +18 -19
  25. package/src/database/drivers/mysql/column.js +8 -0
  26. package/src/database/migration/index.js +7 -5
  27. package/src/database/pool/base.js +5 -5
  28. package/src/database/query/base.js +1 -1
  29. package/src/database/query/from-base.js +2 -4
  30. package/src/database/query/order-base.js +1 -1
  31. package/src/database/query/select-base.js +1 -1
  32. package/src/database/query/where-base.js +1 -1
  33. package/src/database/record/index.js +5 -2
  34. package/src/database/record/relationships/base.js +2 -2
  35. package/src/database/record/validators/base.js +1 -1
  36. package/src/environment-handlers/base.js +7 -7
  37. package/src/environment-handlers/node/cli/commands/generate/base-models.js +79 -24
  38. package/src/initializer.js +1 -1
  39. package/src/routes/base-route.js +1 -1
  40. package/src/testing/test.js +3 -3
@@ -91,7 +91,7 @@ export default class VelociousDatabaseDriversBase {
91
91
  }
92
92
 
93
93
  /**
94
- * @interface
94
+ * @abstract
95
95
  * @param {import("../table-data/index.js").default} _tableData
96
96
  * @returns {Promise<string[]>}
97
97
  */
@@ -100,7 +100,7 @@ export default class VelociousDatabaseDriversBase {
100
100
  }
101
101
 
102
102
  /**
103
- * @interface
103
+ * @abstract
104
104
  * @returns {Promise<void>}
105
105
  */
106
106
  connect() {
@@ -108,7 +108,7 @@ export default class VelociousDatabaseDriversBase {
108
108
  }
109
109
 
110
110
  /**
111
- * @interface
111
+ * @abstract
112
112
  * @param {CreateIndexSqlArgs} indexData
113
113
  * @returns {string}
114
114
  */
@@ -129,7 +129,7 @@ export default class VelociousDatabaseDriversBase {
129
129
  }
130
130
 
131
131
  /**
132
- * @interface
132
+ * @abstract
133
133
  * @param {import("../table-data/index.js").default} tableData
134
134
  * @returns {string[]}
135
135
  */
@@ -148,7 +148,7 @@ export default class VelociousDatabaseDriversBase {
148
148
  }
149
149
 
150
150
  /**
151
- * @interface
151
+ * @abstract
152
152
  * @param {DeleteSqlArgsType} args
153
153
  * @returns {string}
154
154
  */
@@ -170,7 +170,7 @@ export default class VelociousDatabaseDriversBase {
170
170
  }
171
171
 
172
172
  /**
173
- * @interface
173
+ * @abstract
174
174
  * @param {string} tableName
175
175
  * @param {DropTableSqlArgsType} [args]
176
176
  * @returns {string}
@@ -180,7 +180,7 @@ export default class VelociousDatabaseDriversBase {
180
180
  }
181
181
 
182
182
  /**
183
- * @interface
183
+ * @abstract
184
184
  * @param {any} value
185
185
  * @returns {any}
186
186
  */
@@ -212,7 +212,7 @@ export default class VelociousDatabaseDriversBase {
212
212
  }
213
213
 
214
214
  /**
215
- * @interface
215
+ * @abstract
216
216
  * @returns {Array<import("./base-table.js").default>}
217
217
  */
218
218
  getTables() {
@@ -235,7 +235,7 @@ export default class VelociousDatabaseDriversBase {
235
235
  }
236
236
 
237
237
  /**
238
- * @interface
238
+ * @abstract
239
239
  * @returns {string}
240
240
  */
241
241
  getType() {
@@ -253,7 +253,7 @@ export default class VelociousDatabaseDriversBase {
253
253
  }
254
254
 
255
255
  /**
256
- * @interface
256
+ * @abstract
257
257
  * @param {InsertSqlArgsType} args
258
258
  * @returns {string}
259
259
  */
@@ -262,7 +262,7 @@ export default class VelociousDatabaseDriversBase {
262
262
  }
263
263
 
264
264
  /**
265
- * @interface
265
+ * @abstract
266
266
  * @returns {Promise<number>}
267
267
  */
268
268
  lastInsertID() {
@@ -282,7 +282,7 @@ export default class VelociousDatabaseDriversBase {
282
282
  }
283
283
 
284
284
  /**
285
- * @interface
285
+ * @abstract
286
286
  * @returns {import("../query-parser/options.js").default}
287
287
  */
288
288
  options() {
@@ -361,7 +361,7 @@ export default class VelociousDatabaseDriversBase {
361
361
  }
362
362
 
363
363
  /**
364
- * @interface
364
+ * @abstract
365
365
  * @returns {boolean}
366
366
  */
367
367
  shouldSetAutoIncrementWhenPrimaryKey() {
@@ -498,7 +498,7 @@ export default class VelociousDatabaseDriversBase {
498
498
  }
499
499
 
500
500
  /**
501
- * @interface
501
+ * @abstract
502
502
  * @param {string} sql
503
503
  * @returns {Promise<QueryResultType>}
504
504
  */
@@ -507,14 +507,13 @@ export default class VelociousDatabaseDriversBase {
507
507
  }
508
508
 
509
509
  /**
510
- * @interface
510
+ * @abstract
511
511
  * @param {Query} _query
512
512
  * @returns {string}
513
513
  */
514
514
  queryToSql(_query) { throw new Error("queryToSql not implemented") } // eslint-disable-line no-unused-vars
515
515
 
516
516
  /**
517
- * @interface
518
517
  * @param {Error} _error
519
518
  * @returns {boolean}
520
519
  */
@@ -674,7 +673,7 @@ export default class VelociousDatabaseDriversBase {
674
673
  }
675
674
 
676
675
  /**
677
- * @interface
676
+ * @abstract
678
677
  * @param {UpdateSqlArgsType} args
679
678
  * @returns {string}
680
679
  */
@@ -683,7 +682,7 @@ export default class VelociousDatabaseDriversBase {
683
682
  }
684
683
 
685
684
  /**
686
- * @interface
685
+ * @abstract
687
686
  * @returns {Promise<void>}
688
687
  */
689
688
  disableForeignKeys() {
@@ -691,7 +690,7 @@ export default class VelociousDatabaseDriversBase {
691
690
  }
692
691
 
693
692
  /**
694
- * @interface
693
+ * @abstract
695
694
  * @returns {Promise<void>}
696
695
  */
697
696
  enableForeignKeys() {
@@ -83,7 +83,15 @@ export default class VelociousDatabaseDriversMysqlColumn extends BaseColumn {
83
83
 
84
84
  getType() {
85
85
  const type = digg(this, "data", "Type")
86
+
87
+ if (type.match(/^[a-z]+$/)) {
88
+ return type
89
+ }
90
+
86
91
  const match = type.match(/^(.+)\((\d+)\)$/)
92
+
93
+ if (!match) throw new Error(`Couldn't match column type from: ${type}`)
94
+
87
95
  const columnType = match[1]
88
96
 
89
97
  return columnType
@@ -223,13 +223,15 @@ export default class VelociousDatabaseMigration {
223
223
  async columnExists(tableName, columnName) {
224
224
  const table = await this.getDriver().getTableByName(tableName)
225
225
 
226
- if (!table) throw new Error(`Table ${tableName} does not exist`)
227
-
228
- const column = await table.getColumnByName(columnName)
226
+ if (table) {
227
+ const column = await table.getColumnByName(columnName)
229
228
 
230
- if (!column) throw new Error(`Column ${columnName} does not exist in table ${tableName}`)
229
+ if (column) {
230
+ return true
231
+ }
232
+ }
231
233
 
232
- return Boolean(column)
234
+ return Boolean(false)
233
235
  }
234
236
 
235
237
  /**
@@ -36,7 +36,7 @@ class VelociousDatabasePoolBase {
36
36
  }
37
37
 
38
38
  /**
39
- * @interface
39
+ * @abstract
40
40
  * @param {import("../drivers/base.js").default} _connection
41
41
  */
42
42
  checkin(_connection) { // eslint-disable-line no-unused-vars
@@ -44,7 +44,7 @@ class VelociousDatabasePoolBase {
44
44
  }
45
45
 
46
46
  /**
47
- * @interface
47
+ * @abstract
48
48
  * @returns {Promise<import("../drivers/base.js").default>}
49
49
  */
50
50
  checkout() {
@@ -52,7 +52,7 @@ class VelociousDatabasePoolBase {
52
52
  }
53
53
 
54
54
  /**
55
- * @interface
55
+ * @abstract
56
56
  * @returns {import("../drivers/base.js").default}
57
57
  */
58
58
  getCurrentConnection() {
@@ -67,7 +67,7 @@ class VelociousDatabasePoolBase {
67
67
  }
68
68
 
69
69
  /**
70
- * @interface
70
+ * @abstract
71
71
  * @returns {string}
72
72
  */
73
73
  primaryKeyType() {
@@ -119,7 +119,7 @@ class VelociousDatabasePoolBase {
119
119
  }
120
120
 
121
121
  /**
122
- * @interface
122
+ * @abstract
123
123
  * @param {function(import("../drivers/base.js").default) : void} _callback
124
124
  * @returns {Promise<void>}
125
125
  */
@@ -37,7 +37,7 @@ export default class VelociousDatabaseQueryBase {
37
37
  }
38
38
 
39
39
  /**
40
- * @interface
40
+ * @abstract
41
41
  * @returns {string[]}
42
42
  */
43
43
  toSqls() {
@@ -1,9 +1,7 @@
1
1
  // @ts-check
2
2
 
3
- import Query from "./index.js"
4
-
5
3
  export default class VelociousDatabaseQueryFromBase {
6
- /** @type {Query | null} */
4
+ /** @type {import("./index.js").default | null} */
7
5
  query = null
8
6
 
9
7
  /**
@@ -24,7 +22,7 @@ export default class VelociousDatabaseQueryFromBase {
24
22
  }
25
23
 
26
24
  /**
27
- * @interface
25
+ * @abstract
28
26
  * @returns {string[]}
29
27
  */
30
28
  toSql() {
@@ -16,7 +16,7 @@ export default class VelociousDatabaseQueryOrderBase {
16
16
  }
17
17
 
18
18
  /**
19
- * @interface
19
+ * @abstract
20
20
  * @param {boolean} _reverseOrder
21
21
  * @returns {void}
22
22
  */
@@ -18,7 +18,7 @@ export default class VelociousDatabaseQuerySelectBase {
18
18
  }
19
19
 
20
20
  /**
21
- * @interface
21
+ * @abstract
22
22
  * @returns {string}
23
23
  */
24
24
  toSql() {
@@ -25,7 +25,7 @@ export default class VelociousDatabaseQueryWhereBase {
25
25
  }
26
26
 
27
27
  /**
28
- * @interface
28
+ * @abstract
29
29
  * @returns {string}
30
30
  */
31
31
  toSql() {
@@ -269,7 +269,7 @@ class VelociousDatabaseRecord {
269
269
  }
270
270
 
271
271
  /**
272
- * @param {Record<string, any>} attributes
272
+ * @param {Record<string, any>} [attributes]
273
273
  * @returns {Promise<InstanceType<typeof this>>}
274
274
  */
275
275
  static async create(attributes) {
@@ -511,6 +511,9 @@ class VelociousDatabaseRecord {
511
511
  }
512
512
  }
513
513
 
514
+ /**
515
+ * @returns {import("../drivers/base-column.js").default[]}
516
+ */
514
517
  static getColumns() {
515
518
  if (!this._columns) throw new Error(`${this.name} hasn't been initialized yet`)
516
519
 
@@ -763,7 +766,7 @@ class VelociousDatabaseRecord {
763
766
  }
764
767
 
765
768
  /**
766
- * @returns {VelociousDatabaseRecord}
769
+ * @returns {typeof VelociousDatabaseRecord}
767
770
  */
768
771
  static getTranslationClass() {
769
772
  if (this._translationClass) return this._translationClass
@@ -42,7 +42,7 @@ export default class VelociousDatabaseRecordBaseRelationship {
42
42
  getDependent() { return this._dependent }
43
43
 
44
44
  /**
45
- * @interface
45
+ * @abstract
46
46
  * @returns {string} The name of the foreign key, e.g. "user_id", "post_id" etc.
47
47
  */
48
48
  getForeignKey() {
@@ -50,7 +50,7 @@ export default class VelociousDatabaseRecordBaseRelationship {
50
50
  }
51
51
 
52
52
  /**
53
- * @interface
53
+ * @abstract
54
54
  * @returns {string} The name of the inverse relationship, e.g. "posts", "comments" etc.
55
55
  */
56
56
  getInverseOf() {
@@ -1,6 +1,6 @@
1
1
  export default class VelociousDatabaseRecordValidatorsBase {
2
2
  /**
3
- * @interface
3
+ * @abstract
4
4
  * @template T extends import("../index.js").default
5
5
  * @param {object} args
6
6
  * @param {T} args.model
@@ -72,13 +72,13 @@ export default class VelociousEnvironmentHandlerBase {
72
72
  }
73
73
 
74
74
  /**
75
- * @interface
75
+ * @abstract
76
76
  * @returns {Promise<CommandFileObjectType[]>}
77
77
  */
78
78
  async findCommands() { throw new Error("findCommands not implemented") }
79
79
 
80
80
  /**
81
- * @interface
81
+ * @abstract
82
82
  * @returns {Promise<Array<MigrationObjectType>>}
83
83
  */
84
84
  async findMigrations() { throw new Error("findMigrations not implemneted") }
@@ -97,26 +97,26 @@ export default class VelociousEnvironmentHandlerBase {
97
97
  }
98
98
 
99
99
  /**
100
- * @interface
100
+ * @abstract
101
101
  * @returns {Promise<string>}
102
102
  */
103
103
  getVelociousPath() { throw new Error("getVelociousPath not implemented") }
104
104
 
105
105
  /**
106
- * @interface
106
+ * @abstract
107
107
  * @returns {Promise<import("../routes/index.js").default>}
108
108
  */
109
109
  async importApplicationRoutes() { throw new Error("importApplicationRoutes not implemented") }
110
110
 
111
111
  /**
112
- * @interface
112
+ * @abstract
113
113
  * @param {string[]} _testFiles
114
114
  * @returns {Promise<void>}
115
115
  */
116
116
  importTestFiles(_testFiles) { throw new Error("'importTestFiles' not implemented") } // eslint-disable-line no-unused-vars
117
117
 
118
118
  /**
119
- * @interface
119
+ * @abstract
120
120
  * @returns {Promise<void>}
121
121
  */
122
122
  importTestingConfigPath() { throw new Error(`'importTestingConfigPath' not implemented`) }
@@ -125,7 +125,7 @@ export default class VelociousEnvironmentHandlerBase {
125
125
  * @param {object} args
126
126
  * @param {string[]} args.commandParts
127
127
  * @returns {Promise<import ("../cli/base-command.js").default>}
128
- * @interface
128
+ * @abstract
129
129
  */
130
130
  async requireCommand({commandParts}) { throw new Error("'requireCommand' not implemented") } // eslint-disable-line no-unused-vars
131
131
 
@@ -9,6 +9,11 @@ export default class DbGenerateModel extends BaseCommand {
9
9
 
10
10
  const modelsDir = `${process.cwd()}/src/model-bases`
11
11
  const modelClasses = this.getConfiguration().getModelClasses()
12
+ let devMode = false
13
+
14
+ if (modelsDir.endsWith("velocious/spec/dummy/src/model-bases")) {
15
+ devMode = true
16
+ }
12
17
 
13
18
  if (!await fileExists(modelsDir)) {
14
19
  await fs.mkdir(modelsDir, {recursive: true})
@@ -23,7 +28,13 @@ export default class DbGenerateModel extends BaseCommand {
23
28
 
24
29
  console.log(`create src/model-bases/${modelBaseFileName}`)
25
30
 
26
- let fileContent = `import Record from "velocious/src/database/record/index.js"\n\n`
31
+ let fileContent = ""
32
+
33
+ if (devMode) {
34
+ fileContent += `import Record from "../../../../src/database/record/index.js"\n\n`
35
+ } else {
36
+ fileContent += `import Record from "velocious/src/database/record/index.js"\n\n`
37
+ }
27
38
 
28
39
  fileContent += `export default class ${modelNameCamelized}Base extends Record {\n`
29
40
 
@@ -33,15 +44,7 @@ export default class DbGenerateModel extends BaseCommand {
33
44
  for (const column of columns) {
34
45
  const camelizedColumnName = inflection.camelize(column.getName(), true)
35
46
  const camelizedColumnNameBigFirst = inflection.camelize(column.getName())
36
- let jsdocType
37
-
38
- if (column.getType() == "varchar") {
39
- jsdocType = "string"
40
- } else if (["bigint", "int", "integer", "smallint"].includes(column.getType())) {
41
- jsdocType = "number"
42
- } else if (["date", "datetime"].includes(column.getType())) {
43
- jsdocType = "Date"
44
- }
47
+ const jsdocType = this.jsDocTypeFromColumn(column)
45
48
 
46
49
  if (methodsCount > 0) {
47
50
  fileContent += "\n"
@@ -49,7 +52,7 @@ export default class DbGenerateModel extends BaseCommand {
49
52
 
50
53
  if (jsdocType) {
51
54
  fileContent += " /**\n"
52
- fileContent += ` * @returns {${jsdocType}}\n`
55
+ fileContent += ` * @returns {${jsdocType}${column.getNull() ? " | null" : ""}}\n`
53
56
  fileContent += " */\n"
54
57
  }
55
58
 
@@ -57,7 +60,7 @@ export default class DbGenerateModel extends BaseCommand {
57
60
 
58
61
  if (jsdocType) {
59
62
  fileContent += " /**\n"
60
- fileContent += ` * @param {${jsdocType}} newValue\n`
63
+ fileContent += ` * @param {${jsdocType}${column.getNull() ? " | null" : ""}} newValue\n`
61
64
  fileContent += " * @returns {void}\n"
62
65
  fileContent += " */\n"
63
66
  }
@@ -72,6 +75,46 @@ export default class DbGenerateModel extends BaseCommand {
72
75
  methodsCount++
73
76
  }
74
77
 
78
+ if (modelClass._translations) {
79
+ const TranslationClass = modelClass.getTranslationClass()
80
+ const translationColumns = TranslationClass.getColumns()
81
+
82
+ for (const name in modelClass._translations) {
83
+ const nameUnderscore = inflection.underscore(name)
84
+ const column = translationColumns.find((translationColumn) => translationColumn.getName() === nameUnderscore)
85
+ let translationJsdocType
86
+
87
+ if (column) {
88
+ translationJsdocType = this.jsDocTypeFromColumn(column)
89
+ }
90
+
91
+ if (translationJsdocType) {
92
+ fileContent += `\n`
93
+ fileContent += " /**\n"
94
+ fileContent += ` * @returns {${translationJsdocType}${column.getNull() ? " | null" : ""}}\n`
95
+ fileContent += " */\n"
96
+ }
97
+
98
+ fileContent += ` ${name}() { return this._getTranslatedAttributeWithFallback("${name}", this._getConfiguration().getLocale()) }\n`
99
+ methodsCount++
100
+
101
+ for (const locale of this.getConfiguration().getLocales()) {
102
+ const localeMethodName = `${name}${inflection.camelize(locale)}`
103
+
104
+ if (translationJsdocType) {
105
+ fileContent += `\n`
106
+ fileContent += " /**\n"
107
+ fileContent += ` * @returns {${translationJsdocType}${column.getNull() ? " | null" : ""}}\n`
108
+ fileContent += " */\n"
109
+ }
110
+
111
+ fileContent += ` ${localeMethodName}() { return this._getTranslatedAttributeWithFallback("${name}", "${locale}") }\n`
112
+
113
+ methodsCount++
114
+ }
115
+ }
116
+ }
117
+
75
118
  for (const relationship of modelClass.getRelationships()) {
76
119
  let fileName, fullFilePath
77
120
 
@@ -96,32 +139,32 @@ export default class DbGenerateModel extends BaseCommand {
96
139
  }
97
140
 
98
141
  fileContent += " /**\n"
99
- fileContent += " * @interface\n"
100
142
  fileContent += ` * @returns {import("${modelFilePath}").default}\n`
101
143
  fileContent += " */\n"
102
144
  fileContent += ` ${relationship.getRelationshipName()}() { return this.getRelationshipByName("${relationship.getRelationshipName()}").loaded() }\n`
103
145
 
104
146
  fileContent += "\n"
105
147
  fileContent += " /**\n"
106
- fileContent += " * @interface\n"
148
+ fileContent += " * @abstract\n"
149
+ fileContent += " * @param {Record<string, any>} attributes\n"
107
150
  fileContent += ` * @returns {import("${modelFilePath}").default}\n`
108
151
  fileContent += " */\n"
109
- fileContent += ` build${inflection.camelize(relationship.getRelationshipName())}() { throw new Error("Not implemented") }\n`
152
+ fileContent += ` build${inflection.camelize(relationship.getRelationshipName())}(attributes) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars\n`
110
153
 
111
154
  fileContent += "\n"
112
155
  fileContent += " /**\n"
113
- fileContent += " * @interface\n"
156
+ fileContent += " * @abstract\n"
114
157
  fileContent += " * @returns {Promise<void>}\n"
115
158
  fileContent += " */\n"
116
159
  fileContent += ` load${inflection.camelize(relationship.getRelationshipName())}() { throw new Error("Not implemented") }\n`
117
160
 
118
161
  fileContent += "\n"
119
162
  fileContent += " /**\n"
120
- fileContent += " * @interface\n"
163
+ fileContent += " * @abstract\n"
121
164
  fileContent += ` * @param {import("${modelFilePath}").default} newModel\n`
122
165
  fileContent += ` * @returns {void}\n`
123
166
  fileContent += " */\n"
124
- fileContent += ` set${inflection.camelize(relationship.getRelationshipName())}() { throw new Error("Not implemented") }\n`
167
+ fileContent += ` set${inflection.camelize(relationship.getRelationshipName())}(newModel) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars\n`
125
168
  } else if (relationship.getType() == "hasMany") {
126
169
  let recordImport
127
170
 
@@ -132,32 +175,30 @@ export default class DbGenerateModel extends BaseCommand {
132
175
  }
133
176
 
134
177
  fileContent += " /**\n"
135
- fileContent += " * @interface\n"
136
178
  fileContent += ` * @returns {import("velocious/src/database/query/index.js").default<import("${recordImport}").default>}\n`
137
179
  fileContent += " */\n"
138
180
  fileContent += ` ${relationship.getRelationshipName()}() { return this.getRelationshipByName("${relationship.getRelationshipName()}") }\n`
139
181
 
140
182
  fileContent += "\n"
141
183
  fileContent += " /**\n"
142
- fileContent += " * @interface\n"
143
184
  fileContent += ` * @returns {Array<import("${recordImport}").default>}\n`
144
185
  fileContent += " */\n"
145
186
  fileContent += ` ${relationship.getRelationshipName()}Loaded() { return this.getRelationshipByName("${relationship.getRelationshipName()}").loaded() }\n`
146
187
 
147
188
  fileContent += "\n"
148
189
  fileContent += " /**\n"
149
- fileContent += " * @interface\n"
190
+ fileContent += " * @abstract\n"
150
191
  fileContent += " * @returns {Promise<void>}\n"
151
192
  fileContent += " */\n"
152
193
  fileContent += ` load${inflection.camelize(relationship.getRelationshipName())}() { throw new Error("Not implemented") }\n`
153
194
 
154
195
  fileContent += "\n"
155
196
  fileContent += " /**\n"
156
- fileContent += " * @interface\n"
197
+ fileContent += " * @abstract\n"
157
198
  fileContent += ` * @param {Array<import("${recordImport}").default>} newModels\n`
158
- fileContent += " * @returns {void>}\n"
199
+ fileContent += " * @returns {void}\n"
159
200
  fileContent += " */\n"
160
- fileContent += ` set${inflection.camelize(relationship.getRelationshipName())}() { throw new Error("Not implemented") }\n`
201
+ fileContent += ` set${inflection.camelize(relationship.getRelationshipName())}(newModels) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars\n`
161
202
  } else {
162
203
  throw new Error(`Unknown relationship type: ${relationship.getType()}`)
163
204
  }
@@ -170,4 +211,18 @@ export default class DbGenerateModel extends BaseCommand {
170
211
  await fs.writeFile(modelPath, fileContent)
171
212
  }
172
213
  }
214
+
215
+ /**
216
+ * @param {import("../../../../../database/drivers/base-column.js").default} column
217
+ * @returns {string | undefined}
218
+ */
219
+ jsDocTypeFromColumn(column) {
220
+ if (column.getType() == "varchar") {
221
+ return "string"
222
+ } else if (["bigint", "int", "integer", "smallint"].includes(column.getType())) {
223
+ return "number"
224
+ } else if (["date", "datetime"].includes(column.getType())) {
225
+ return "Date"
226
+ }
227
+ }
173
228
  }
@@ -24,7 +24,7 @@ export default class VelociousInitializer {
24
24
  getType() { return this._type }
25
25
 
26
26
  /**
27
- * @interface
27
+ * @abstract
28
28
  * @returns {Promise<void>}
29
29
  */
30
30
  run() {
@@ -21,7 +21,7 @@ export function initBaseRoute() {
21
21
  }
22
22
 
23
23
  /**
24
- * @interface
24
+ * @abstract
25
25
  * @param {string} _path
26
26
  */
27
27
  matchWithPath(_path) { // eslint-disable-line no-unused-vars
@@ -315,7 +315,7 @@ class Expect {
315
315
  /**
316
316
  * @param {string} description
317
317
  * @param {object|() => Promise<void>} arg1
318
- * @param {undefined|() => Promise<void>} arg2
318
+ * @param {undefined|() => Promise<void>} [arg2]
319
319
  * @returns {void}
320
320
  */
321
321
  async function describe(description, arg1, arg2) {
@@ -361,7 +361,7 @@ function expect(arg) {
361
361
  /**
362
362
  * @param {string} description
363
363
  * @param {object|() => Promise<void>} arg1
364
- * @param {undefined|() => Promise<void>} arg2
364
+ * @param {undefined|() => Promise<void>} [arg2]
365
365
  * @returns {void}
366
366
  */
367
367
  function it(description, arg1, arg2) {
@@ -386,7 +386,7 @@ function it(description, arg1, arg2) {
386
386
  /**
387
387
  * @param {string} description
388
388
  * @param {object|() => Promise<void>} arg1
389
- * @param {undefined|() => Promise<void>} arg2
389
+ * @param {undefined|() => Promise<void>} [arg2]
390
390
  * @returns {void}
391
391
  */
392
392
  function fit(description, arg1, arg2) {