velocious 1.0.38 → 1.0.40
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/package.json +1 -1
- package/peak_flow.yml +6 -2
- package/spec/database/record/create-spec.js +3 -0
- package/spec/database/record/find-spec.js +1 -0
- package/spec/database/record/validations-spec.js +8 -0
- package/spec/dummy/src/config/configuration.peakflow.mssql.js +0 -10
- package/src/cli/commands/test.js +2 -2
- package/src/database/record/index.js +16 -5
- package/src/database/record/validators/presence.js +1 -1
package/package.json
CHANGED
package/peak_flow.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
before_install:
|
|
2
2
|
- sudo mkdir -p /etc/apt/keyrings
|
|
3
3
|
- curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --no-tty --batch --yes --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
|
4
|
-
- echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/
|
|
4
|
+
- echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
|
|
5
5
|
- sudo apt-get update
|
|
6
6
|
- sudo apt-get install -y nodejs
|
|
7
7
|
before_script:
|
|
@@ -45,8 +45,9 @@ builds:
|
|
|
45
45
|
name: MariaDB
|
|
46
46
|
script:
|
|
47
47
|
- cp spec/dummy/src/config/configuration.peakflow.mariadb.js spec/dummy/src/config/configuration.js
|
|
48
|
-
- wait-for-it mariadb:3306
|
|
49
48
|
- wait-for-it mssql:1433
|
|
49
|
+
- wait-for-it mariadb:3306
|
|
50
|
+
- sleep 5
|
|
50
51
|
- cd spec/dummy && npx velocious db:create
|
|
51
52
|
- npm test
|
|
52
53
|
build_2:
|
|
@@ -54,6 +55,7 @@ builds:
|
|
|
54
55
|
script:
|
|
55
56
|
- cp spec/dummy/src/config/configuration.peakflow.mssql.js spec/dummy/src/config/configuration.js
|
|
56
57
|
- wait-for-it mssql:1433
|
|
58
|
+
- sleep 5
|
|
57
59
|
- cd spec/dummy && npx velocious db:create
|
|
58
60
|
- npm test
|
|
59
61
|
build_3:
|
|
@@ -62,6 +64,7 @@ builds:
|
|
|
62
64
|
- cp spec/dummy/src/config/configuration.peakflow.pgsql.js spec/dummy/src/config/configuration.js
|
|
63
65
|
- wait-for-it mssql:1433
|
|
64
66
|
- wait-for-it postgres:5432
|
|
67
|
+
- sleep 5
|
|
65
68
|
- cd spec/dummy && npx velocious db:create
|
|
66
69
|
- npm test
|
|
67
70
|
build_4:
|
|
@@ -69,5 +72,6 @@ builds:
|
|
|
69
72
|
script:
|
|
70
73
|
- cp spec/dummy/src/config/configuration.peakflow.sqlite.js spec/dummy/src/config/configuration.js
|
|
71
74
|
- wait-for-it mssql:1433
|
|
75
|
+
- sleep 5
|
|
72
76
|
- cd spec/dummy && npx velocious db:create
|
|
73
77
|
- npm test
|
|
@@ -22,6 +22,9 @@ describe("Record - create", () => {
|
|
|
22
22
|
expect(project.nameEn()).toEqual("Test project")
|
|
23
23
|
expect(project.createdAt()).toBeInstanceOf(Date)
|
|
24
24
|
expect(project.updatedAt()).toBeInstanceOf(Date)
|
|
25
|
+
|
|
26
|
+
// 'name' is not a column but rather a column on the translation data model.
|
|
27
|
+
expect(() => project.readColumn("name")).toThrowError("No such attribute or not selected Project#name")
|
|
25
28
|
})
|
|
26
29
|
})
|
|
27
30
|
|
|
@@ -11,6 +11,14 @@ describe("Record - validations", () => {
|
|
|
11
11
|
})
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
+
it("raises validations if trying to create an invalid record with a blank value because of a presence validation", async () => {
|
|
15
|
+
await Dummy.run(async () => {
|
|
16
|
+
const task = new Task({name: null})
|
|
17
|
+
|
|
18
|
+
await expectAsync(task.save()).toBeRejectedWith(new ValidationError("Name can't be blank"))
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
|
|
14
22
|
it("raises validations if trying to create an invalid record because of a uniqueness validation", async () => {
|
|
15
23
|
await Dummy.run(async () => {
|
|
16
24
|
await Task.create({name: "Task 1"})
|
|
@@ -21,11 +21,6 @@ export default new Configuration({
|
|
|
21
21
|
password: "Super-Secret-Password",
|
|
22
22
|
database: "velocious_test",
|
|
23
23
|
server: "mssql",
|
|
24
|
-
pool: {
|
|
25
|
-
max: 10,
|
|
26
|
-
min: 0,
|
|
27
|
-
idleTimeoutMillis: 30000
|
|
28
|
-
},
|
|
29
24
|
options: {
|
|
30
25
|
encrypt: true, // for azure
|
|
31
26
|
trustServerCertificate: true // change to true for local dev / self-signed certs
|
|
@@ -43,11 +38,6 @@ export default new Configuration({
|
|
|
43
38
|
password: "Super-Secret-Password",
|
|
44
39
|
database: "velocious_test",
|
|
45
40
|
server: "mssql",
|
|
46
|
-
pool: {
|
|
47
|
-
max: 10,
|
|
48
|
-
min: 0,
|
|
49
|
-
idleTimeoutMillis: 30000
|
|
50
|
-
},
|
|
51
41
|
options: {
|
|
52
42
|
encrypt: true, // for azure
|
|
53
43
|
trustServerCertificate: true // change to true for local dev / self-signed certs
|
package/src/cli/commands/test.js
CHANGED
|
@@ -12,10 +12,10 @@ export default class VelociousCliCommandsInit extends BaseCommand {
|
|
|
12
12
|
|
|
13
13
|
if (testRunner.isFailed()) {
|
|
14
14
|
console.error(`Test run failed with ${testRunner.failedTests} failed tests and ${testRunner.successfulTests} successfull`)
|
|
15
|
-
process.exit(
|
|
15
|
+
process.exit(1)
|
|
16
16
|
} else {
|
|
17
17
|
console.log(`Test run succeeded with ${testRunner.successfulTests} successful tests`)
|
|
18
|
-
process.exit(
|
|
18
|
+
process.exit(0)
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -330,7 +330,13 @@ class VelociousDatabaseRecord {
|
|
|
330
330
|
return record
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
+
static setPrimaryKey(primaryKey) {
|
|
334
|
+
this._primaryKey = primaryKey
|
|
335
|
+
}
|
|
336
|
+
|
|
333
337
|
static primaryKey() {
|
|
338
|
+
if (this._primaryKey) return this._primaryKey
|
|
339
|
+
|
|
334
340
|
return "id"
|
|
335
341
|
}
|
|
336
342
|
|
|
@@ -762,13 +768,18 @@ class VelociousDatabaseRecord {
|
|
|
762
768
|
|
|
763
769
|
readAttribute(attributeName) {
|
|
764
770
|
const attributeNameUnderscore = inflection.underscore(attributeName)
|
|
765
|
-
|
|
771
|
+
|
|
772
|
+
return this.readColumn(attributeNameUnderscore)
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
readColumn(attributeName) {
|
|
776
|
+
const column = this.constructor.getColumns().find((column) => column.getName() == attributeName)
|
|
766
777
|
let result
|
|
767
778
|
|
|
768
|
-
if (
|
|
769
|
-
result = this._changes[
|
|
770
|
-
} else if (
|
|
771
|
-
result = this._attributes[
|
|
779
|
+
if (attributeName in this._changes) {
|
|
780
|
+
result = this._changes[attributeName]
|
|
781
|
+
} else if (attributeName in this._attributes) {
|
|
782
|
+
result = this._attributes[attributeName]
|
|
772
783
|
} else if (this.isPersisted()) {
|
|
773
784
|
throw new Error(`No such attribute or not selected ${this.constructor.name}#${attributeName}`)
|
|
774
785
|
}
|
|
@@ -2,7 +2,7 @@ import Base from "./base.js"
|
|
|
2
2
|
|
|
3
3
|
export default class VelociousDatabaseRecordValidatorsPresence extends Base {
|
|
4
4
|
validate({model, attributeName}) {
|
|
5
|
-
const attributeValue = model.readAttribute(attributeName)
|
|
5
|
+
const attributeValue = model.readAttribute(attributeName)?.trim()
|
|
6
6
|
|
|
7
7
|
if (!attributeValue) {
|
|
8
8
|
if (!(attributeName in model._validationErrors)) model._validationErrors[attributeName] = []
|