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
@@ -0,0 +1,117 @@
1
+ import Record from "../../../../src/database/record/index.js"
2
+
3
+ export default class TaskBase extends Record {
4
+ /**
5
+ * @returns {number}
6
+ */
7
+ id() { return this.readAttribute("id") }
8
+
9
+ /**
10
+ * @param {number} newValue
11
+ * @returns {void}
12
+ */
13
+ setId(newValue) { return this._setColumnAttribute("id", newValue) }
14
+
15
+ /**
16
+ * @returns {boolean}
17
+ */
18
+ hasId() { return this._hasAttribute(this.id()) }
19
+
20
+ /**
21
+ * @returns {number}
22
+ */
23
+ projectId() { return this.readAttribute("projectId") }
24
+
25
+ /**
26
+ * @param {number} newValue
27
+ * @returns {void}
28
+ */
29
+ setProjectId(newValue) { return this._setColumnAttribute("projectId", newValue) }
30
+
31
+ /**
32
+ * @returns {boolean}
33
+ */
34
+ hasProjectId() { return this._hasAttribute(this.projectId()) }
35
+
36
+ /**
37
+ * @returns {string | null}
38
+ */
39
+ name() { return this.readAttribute("name") }
40
+
41
+ /**
42
+ * @param {string | null} newValue
43
+ * @returns {void}
44
+ */
45
+ setName(newValue) { return this._setColumnAttribute("name", newValue) }
46
+
47
+ /**
48
+ * @returns {boolean}
49
+ */
50
+ hasName() { return this._hasAttribute(this.name()) }
51
+
52
+ description() { return this.readAttribute("description") }
53
+
54
+ setDescription(newValue) { return this._setColumnAttribute("description", newValue) }
55
+
56
+ /**
57
+ * @returns {boolean}
58
+ */
59
+ hasDescription() { return this._hasAttribute(this.description()) }
60
+
61
+ /**
62
+ * @returns {Date | null}
63
+ */
64
+ createdAt() { return this.readAttribute("createdAt") }
65
+
66
+ /**
67
+ * @param {Date | null} newValue
68
+ * @returns {void}
69
+ */
70
+ setCreatedAt(newValue) { return this._setColumnAttribute("createdAt", newValue) }
71
+
72
+ /**
73
+ * @returns {boolean}
74
+ */
75
+ hasCreatedAt() { return this._hasAttribute(this.createdAt()) }
76
+
77
+ /**
78
+ * @returns {Date | null}
79
+ */
80
+ updatedAt() { return this.readAttribute("updatedAt") }
81
+
82
+ /**
83
+ * @param {Date | null} newValue
84
+ * @returns {void}
85
+ */
86
+ setUpdatedAt(newValue) { return this._setColumnAttribute("updatedAt", newValue) }
87
+
88
+ /**
89
+ * @returns {boolean}
90
+ */
91
+ hasUpdatedAt() { return this._hasAttribute(this.updatedAt()) }
92
+
93
+ /**
94
+ * @returns {import("../models/project.js").default}
95
+ */
96
+ project() { return this.getRelationshipByName("project").loaded() }
97
+
98
+ /**
99
+ * @abstract
100
+ * @param {Record<string, any>} attributes
101
+ * @returns {import("../models/project.js").default}
102
+ */
103
+ buildProject(attributes) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars
104
+
105
+ /**
106
+ * @abstract
107
+ * @returns {Promise<void>}
108
+ */
109
+ loadProject() { throw new Error("Not implemented") }
110
+
111
+ /**
112
+ * @abstract
113
+ * @param {import("../models/project.js").default} newModel
114
+ * @returns {void}
115
+ */
116
+ setProject(newModel) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars
117
+ }
@@ -0,0 +1,170 @@
1
+ import Record from "../../../../src/database/record/index.js"
2
+
3
+ export default class UserBase extends Record {
4
+ /**
5
+ * @returns {number}
6
+ */
7
+ id() { return this.readAttribute("id") }
8
+
9
+ /**
10
+ * @param {number} newValue
11
+ * @returns {void}
12
+ */
13
+ setId(newValue) { return this._setColumnAttribute("id", newValue) }
14
+
15
+ /**
16
+ * @returns {boolean}
17
+ */
18
+ hasId() { return this._hasAttribute(this.id()) }
19
+
20
+ /**
21
+ * @returns {string}
22
+ */
23
+ email() { return this.readAttribute("email") }
24
+
25
+ /**
26
+ * @param {string} newValue
27
+ * @returns {void}
28
+ */
29
+ setEmail(newValue) { return this._setColumnAttribute("email", newValue) }
30
+
31
+ /**
32
+ * @returns {boolean}
33
+ */
34
+ hasEmail() { return this._hasAttribute(this.email()) }
35
+
36
+ /**
37
+ * @returns {string}
38
+ */
39
+ encryptedPassword() { return this.readAttribute("encryptedPassword") }
40
+
41
+ /**
42
+ * @param {string} newValue
43
+ * @returns {void}
44
+ */
45
+ setEncryptedPassword(newValue) { return this._setColumnAttribute("encryptedPassword", newValue) }
46
+
47
+ /**
48
+ * @returns {boolean}
49
+ */
50
+ hasEncryptedPassword() { return this._hasAttribute(this.encryptedPassword()) }
51
+
52
+ /**
53
+ * @returns {string | null}
54
+ */
55
+ reference() { return this.readAttribute("reference") }
56
+
57
+ /**
58
+ * @param {string | null} newValue
59
+ * @returns {void}
60
+ */
61
+ setReference(newValue) { return this._setColumnAttribute("reference", newValue) }
62
+
63
+ /**
64
+ * @returns {boolean}
65
+ */
66
+ hasReference() { return this._hasAttribute(this.reference()) }
67
+
68
+ /**
69
+ * @returns {Date | null}
70
+ */
71
+ createdAt() { return this.readAttribute("createdAt") }
72
+
73
+ /**
74
+ * @param {Date | null} newValue
75
+ * @returns {void}
76
+ */
77
+ setCreatedAt(newValue) { return this._setColumnAttribute("createdAt", newValue) }
78
+
79
+ /**
80
+ * @returns {boolean}
81
+ */
82
+ hasCreatedAt() { return this._hasAttribute(this.createdAt()) }
83
+
84
+ /**
85
+ * @returns {Date | null}
86
+ */
87
+ updatedAt() { return this.readAttribute("updatedAt") }
88
+
89
+ /**
90
+ * @param {Date | null} newValue
91
+ * @returns {void}
92
+ */
93
+ setUpdatedAt(newValue) { return this._setColumnAttribute("updatedAt", newValue) }
94
+
95
+ /**
96
+ * @returns {boolean}
97
+ */
98
+ hasUpdatedAt() { return this._hasAttribute(this.updatedAt()) }
99
+
100
+ /**
101
+ * @returns {import("../models/project.js").default}
102
+ */
103
+ createdProject() { return this.getRelationshipByName("createdProject").loaded() }
104
+
105
+ /**
106
+ * @abstract
107
+ * @param {Record<string, any>} attributes
108
+ * @returns {import("../models/project.js").default}
109
+ */
110
+ buildCreatedProject(attributes) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars
111
+
112
+ /**
113
+ * @abstract
114
+ * @returns {Promise<void>}
115
+ */
116
+ loadCreatedProject() { throw new Error("Not implemented") }
117
+
118
+ /**
119
+ * @abstract
120
+ * @param {import("../models/project.js").default} newModel
121
+ * @returns {void}
122
+ */
123
+ setCreatedProject(newModel) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars
124
+
125
+ /**
126
+ * @returns {import("velocious/src/database/query/index.js").default<import("../models/authentication-token.js").default>}
127
+ */
128
+ authenticationTokens() { return this.getRelationshipByName("authenticationTokens") }
129
+
130
+ /**
131
+ * @returns {Array<import("../models/authentication-token.js").default>}
132
+ */
133
+ authenticationTokensLoaded() { return this.getRelationshipByName("authenticationTokens").loaded() }
134
+
135
+ /**
136
+ * @abstract
137
+ * @returns {Promise<void>}
138
+ */
139
+ loadAuthenticationTokens() { throw new Error("Not implemented") }
140
+
141
+ /**
142
+ * @abstract
143
+ * @param {Array<import("../models/authentication-token.js").default>} newModels
144
+ * @returns {void}
145
+ */
146
+ setAuthenticationTokens(newModels) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars
147
+
148
+ /**
149
+ * @returns {import("velocious/src/database/query/index.js").default<import("../models/project.js").default>}
150
+ */
151
+ createdProjects() { return this.getRelationshipByName("createdProjects") }
152
+
153
+ /**
154
+ * @returns {Array<import("../models/project.js").default>}
155
+ */
156
+ createdProjectsLoaded() { return this.getRelationshipByName("createdProjects").loaded() }
157
+
158
+ /**
159
+ * @abstract
160
+ * @returns {Promise<void>}
161
+ */
162
+ loadCreatedProjects() { throw new Error("Not implemented") }
163
+
164
+ /**
165
+ * @abstract
166
+ * @param {Array<import("../models/project.js").default>} newModels
167
+ * @returns {void}
168
+ */
169
+ setCreatedProjects(newModels) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars
170
+ }
@@ -1,6 +1,6 @@
1
- import DatabaseRecord from "../../../../src/database/record/index.js"
1
+ import AccountBase from "../model-bases/account.js"
2
2
 
3
- class Account extends DatabaseRecord {
3
+ class Account extends AccountBase {
4
4
  }
5
5
 
6
6
  Account.setDatabaseIdentifier("mssql")
@@ -1,6 +1,6 @@
1
- import Record from "../../../../src/database/record/index.js"
1
+ import AuthenticationTokenBase from "../model-bases/authentication-token.js"
2
2
 
3
- class AuthenticationToken extends Record {
3
+ class AuthenticationToken extends AuthenticationTokenBase {
4
4
  }
5
5
 
6
6
  AuthenticationToken.belongsTo("user")
@@ -1,6 +1,6 @@
1
- import DatabaseRecord from "../../../../src/database/record/index.js"
1
+ import ProjectDetailsBase from "../model-bases/project-detail.js"
2
2
 
3
- class ProjectDetail extends DatabaseRecord {
3
+ class ProjectDetail extends ProjectDetailsBase {
4
4
  }
5
5
 
6
6
  ProjectDetail.belongsTo("project")
@@ -1,6 +1,6 @@
1
- import DatabaseRecord from "../../../../src/database/record/index.js"
1
+ import ProjectBase from "../model-bases/project.js"
2
2
 
3
- class Project extends DatabaseRecord {
3
+ class Project extends ProjectBase {
4
4
  }
5
5
 
6
6
  Project.belongsTo("creatingUser", {className: "User", foreignKey: "creating_user_reference", primaryKey: "reference"})
@@ -1,6 +1,6 @@
1
- import Record from "../../../../src/database/record/index.js"
1
+ import TaskBase from "../model-bases/task.js"
2
2
 
3
- class Task extends Record {
3
+ class Task extends TaskBase {
4
4
  }
5
5
 
6
6
  Task.belongsTo("project")
@@ -1,7 +1,7 @@
1
- import Record from "../../../../src/database/record/index.js"
1
+ import UserBase from "../model-bases/user.js"
2
2
  import UserModule from "../../../../src/database/record/user-module.js"
3
3
 
4
- class User extends Record {
4
+ class User extends UserBase {
5
5
  }
6
6
 
7
7
  User.hasOne("createdProject", {className: "Project", foreignKey: "creating_user_reference", primaryKey: "reference"})
@@ -20,7 +20,7 @@ export default class VelociousCliBaseCommand {
20
20
  directory() { return this.getConfiguration().getDirectory() }
21
21
 
22
22
  /**
23
- * @interface
23
+ * @abstract
24
24
  * @returns {Promise<void>}
25
25
  */
26
26
  execute() {
@@ -1,5 +1,9 @@
1
1
  // @ts-check
2
2
 
3
+ /**
4
+ * @typedef {function(Record<string, import("./database/drivers/base.js").default>) : Promise<void>} WithConnectionsCallbackType
5
+ */
6
+
3
7
  import {digg} from "diggerize"
4
8
  import restArgsError from "./utils/rest-args-error.js"
5
9
  import {withTrackedStack} from "./utils/with-tracked-stack.js"
@@ -320,7 +324,7 @@ export default class VelociousConfiguration {
320
324
  }
321
325
 
322
326
  /**
323
- * @param {Function} callback
327
+ * @param {WithConnectionsCallbackType} callback
324
328
  * @returns {Promise<void>}
325
329
  */
326
330
  async withConnections(callback) {
@@ -376,7 +380,7 @@ export default class VelociousConfiguration {
376
380
  }
377
381
 
378
382
  /**
379
- * @param {Function} callback
383
+ * @param {WithConnectionsCallbackType} callback
380
384
  * @returns {Promise<void>}
381
385
  */
382
386
  async ensureConnections(callback) {
@@ -8,7 +8,7 @@ export default class VelociousDatabaseDriversBaseColumn {
8
8
  table = undefined
9
9
 
10
10
  /**
11
- * @interface
11
+ * @abstract
12
12
  * @returns {boolean}
13
13
  */
14
14
  getAutoIncrement() {
@@ -16,6 +16,7 @@ export default class VelociousDatabaseDriversBaseColumn {
16
16
  }
17
17
 
18
18
  /**
19
+ * @abstract
19
20
  * @returns {any}
20
21
  */
21
22
  getDefault() {
@@ -60,7 +61,7 @@ export default class VelociousDatabaseDriversBaseColumn {
60
61
  }
61
62
 
62
63
  /**
63
- * @interface
64
+ * @abstract
64
65
  * @returns {Promise<Array<import("./base-columns-index.js").default>>}
65
66
  */
66
67
  getIndexes() {
@@ -68,7 +69,7 @@ export default class VelociousDatabaseDriversBaseColumn {
68
69
  }
69
70
 
70
71
  /**
71
- * @interface
72
+ * @abstract
72
73
  * @returns {number}
73
74
  */
74
75
  getMaxLength() {
@@ -76,7 +77,7 @@ export default class VelociousDatabaseDriversBaseColumn {
76
77
  }
77
78
 
78
79
  /**
79
- * @interface
80
+ * @abstract
80
81
  * @returns {string}
81
82
  */
82
83
  getName() {
@@ -84,7 +85,7 @@ export default class VelociousDatabaseDriversBaseColumn {
84
85
  }
85
86
 
86
87
  /**
87
- * @interface
88
+ * @abstract
88
89
  * @returns {boolean}
89
90
  */
90
91
  getNull() {
@@ -99,7 +100,7 @@ export default class VelociousDatabaseDriversBaseColumn {
99
100
  }
100
101
 
101
102
  /**
102
- * @interface
103
+ * @abstract
103
104
  * @returns {boolean}
104
105
  */
105
106
  getPrimaryKey() {
@@ -131,7 +132,7 @@ export default class VelociousDatabaseDriversBaseColumn {
131
132
  }
132
133
 
133
134
  /**
134
- * @interface
135
+ * @abstract
135
136
  * @returns {string}
136
137
  */
137
138
  getType() {
@@ -43,7 +43,7 @@ export default class VelociousDatabaseDriversBaseColumnsIndex {
43
43
  }
44
44
 
45
45
  /**
46
- * @interface
46
+ * @abstract
47
47
  * @returns {import("../table-data/table-index.js").default}
48
48
  */
49
49
  getTableDataIndex() {
@@ -14,7 +14,7 @@ export default class VelociousDatabaseDriversBaseForeignKey {
14
14
  }
15
15
 
16
16
  /**
17
- * @interface
17
+ * @abstract
18
18
  * @returns {string}
19
19
  */
20
20
  getColumnName() {
@@ -29,7 +29,7 @@ export default class VelociousDatabaseDriversBaseForeignKey {
29
29
  }
30
30
 
31
31
  /**
32
- * @interface
32
+ * @abstract
33
33
  * @returns {string}
34
34
  */
35
35
  getName() {
@@ -44,7 +44,7 @@ export default class VelociousDatabaseDriversBaseForeignKey {
44
44
  }
45
45
 
46
46
  /**
47
- * @interface
47
+ * @abstract
48
48
  * @returns {string}
49
49
  */
50
50
  getReferencedColumnName() {
@@ -52,7 +52,7 @@ export default class VelociousDatabaseDriversBaseForeignKey {
52
52
  }
53
53
 
54
54
  /**
55
- * @interface
55
+ * @abstract
56
56
  * @returns {string}
57
57
  */
58
58
  getReferencedTableName() {
@@ -69,7 +69,7 @@ export default class VelociousDatabaseDriversBaseForeignKey {
69
69
  }
70
70
 
71
71
  /**
72
- * @interface
72
+ * @abstract
73
73
  * @returns {string}
74
74
  */
75
75
  getTableName() {
@@ -19,7 +19,7 @@ export default class VelociousDatabaseDriversBaseTable {
19
19
  }
20
20
 
21
21
  /**
22
- * @interface
22
+ * @abstract
23
23
  * @returns {Promise<Array<import("./base-column.js").default>>}
24
24
  */
25
25
  getColumns() {
@@ -36,7 +36,7 @@ export default class VelociousDatabaseDriversBaseTable {
36
36
  }
37
37
 
38
38
  /**
39
- * @interface
39
+ * @abstract
40
40
  * @returns {Promise<import("./base-foreign-key.js").default[]>}
41
41
  */
42
42
  getForeignKeys() {
@@ -44,7 +44,7 @@ export default class VelociousDatabaseDriversBaseTable {
44
44
  }
45
45
 
46
46
  /**
47
- * @interface
47
+ * @abstract
48
48
  * @returns {Promise<import("./base-columns-index.js").default[]>}
49
49
  */
50
50
  getIndexes() {
@@ -52,7 +52,7 @@ export default class VelociousDatabaseDriversBaseTable {
52
52
  }
53
53
 
54
54
  /**
55
- * @interface
55
+ * @abstract
56
56
  * @returns {string}
57
57
  */
58
58
  getName() {