velocious 1.0.106 → 1.0.107
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 +3 -1
- package/peak_flow.yml +1 -0
- package/spec/cli/commands/db/migrate-spec.js +7 -2
- package/spec/cli/commands/test/test-files-finder-spec.js +2 -0
- package/spec/database/connection/drivers/mysql/query-parser-spec.js +3 -1
- package/spec/database/drivers/mysql/connection-spec.js +1 -1
- package/spec/database/record/find-or-create-spec.js +3 -3
- package/spec/database/record/find-spec.js +1 -1
- package/spec/database/record/instance-relationships/belongs-to-relationship-spec.js +1 -1
- package/spec/database/record/instance-relationships/has-many-relationship-spec.js +3 -3
- package/spec/database/record/instance-relationships/has-one-relationship-spec.js +1 -1
- package/spec/database/record/last-spec.js +2 -2
- package/spec/database/record/preloader/belongs-to-spec.js +1 -1
- package/spec/database/record/preloader/has-many-spec.js +4 -4
- package/spec/database/record/preloader/has-one-spec.js +1 -1
- package/spec/database/record/query-spec.js +8 -6
- package/spec/database/record/translation-fallbacks-spec.js +1 -1
- package/spec/dummy/src/config/configuration.example.js +1 -0
- package/spec/dummy/src/model-bases/account.js +2 -2
- package/spec/dummy/src/model-bases/authentication-token.js +3 -3
- package/spec/dummy/src/model-bases/project-detail.js +3 -3
- package/spec/dummy/src/model-bases/project-translation.js +3 -3
- package/spec/dummy/src/model-bases/project.js +12 -12
- package/spec/dummy/src/model-bases/task.js +3 -3
- package/spec/dummy/src/model-bases/user.js +9 -9
- package/spec/dummy/src/routes/projects/controller.js +1 -1
- package/spec/dummy/src/routes/tasks/controller.js +1 -3
- package/spec/http-server/client-spec.js +1 -1
- package/spec/http-server/get-spec.js +1 -1
- package/spec/http-server/post-spec.js +9 -9
- package/spec/http-server/root-get-spec.js +2 -1
- package/src/application.js +1 -0
- package/src/cli/base-command.js +1 -1
- package/src/cli/commands/db/create.js +1 -1
- package/src/cli/use-browser-cli.js +2 -0
- package/src/configuration-types.js +11 -6
- package/src/controller.js +1 -2
- package/src/database/drivers/base.js +9 -9
- package/src/database/drivers/mssql/index.js +11 -11
- package/src/database/drivers/mssql/options.js +10 -6
- package/src/database/drivers/mysql/index.js +8 -8
- package/src/database/drivers/mysql/options.js +10 -6
- package/src/database/drivers/pgsql/index.js +10 -10
- package/src/database/drivers/pgsql/options.js +9 -6
- package/src/database/drivers/sqlite/base.js +10 -10
- package/src/database/drivers/sqlite/connection-sql-js.js +2 -0
- package/src/database/drivers/sqlite/index.js +8 -2
- package/src/database/drivers/sqlite/index.native.js +5 -1
- package/src/database/drivers/sqlite/index.web.js +2 -1
- package/src/database/drivers/sqlite/options.js +10 -7
- package/src/database/drivers/sqlite/sql/alter-table.js +3 -3
- package/src/database/migration/index.js +16 -5
- package/src/database/migrator.js +5 -1
- package/src/database/pool/base-methods-forward.js +0 -4
- package/src/database/query/alter-table-base.js +2 -2
- package/src/database/query/base.js +2 -2
- package/src/database/query/create-index-base.js +2 -2
- package/src/database/query/create-table-base.js +4 -4
- package/src/database/query/drop-table-base.js +2 -2
- package/src/database/query/index.js +2 -2
- package/src/database/record/index.js +11 -44
- package/src/database/record/instance-relationships/base.js +2 -2
- package/src/database/record/instance-relationships/has-many.js +1 -1
- package/src/database/use-database.js +1 -0
- package/src/environment-handlers/base.js +2 -2
- package/src/environment-handlers/browser.js +40 -18
- package/src/environment-handlers/node/cli/commands/destroy/migration.js +5 -1
- package/src/environment-handlers/node/cli/commands/generate/base-models.js +20 -9
- package/src/environment-handlers/node/cli/commands/generate/migration.js +5 -1
- package/src/environment-handlers/node/cli/commands/generate/model.js +5 -1
- package/src/environment-handlers/node/cli/commands/init.js +5 -1
- package/src/environment-handlers/node.js +1 -1
- package/src/http-server/client/index.js +2 -1
- package/src/http-server/client/params-to-object.js +0 -8
- package/src/http-server/client/request-buffer/index.js +1 -0
- package/src/routes/basic-route.js +1 -1
- package/src/testing/test-files-finder.js +1 -1
- package/src/testing/test-runner.js +3 -0
- package/src/testing/test.js +0 -2
- package/src/utils/with-tracked-stack-async-hooks.js +0 -2
- package/src/utils/with-tracked-stack.js +0 -2
- package/tsconfig.json +15 -0
package/package.json
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
"velocious": "bin/velocious.js"
|
|
4
4
|
},
|
|
5
5
|
"name": "velocious",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.107",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"lint": "eslint",
|
|
10
10
|
"test": "VELOCIOUS_TEST_DIR=../ cd spec/dummy && npx velocious test",
|
|
11
|
+
"typecheck": "tsc --noEmit",
|
|
11
12
|
"velocious": "asd"
|
|
12
13
|
},
|
|
13
14
|
"type": "module",
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
"sqlite": "^5.1.1",
|
|
55
56
|
"sqlite3": "^5.1.7",
|
|
56
57
|
"tedious": "^19.1.3",
|
|
58
|
+
"typescript": "^5.9.3",
|
|
57
59
|
"uniqunize": "^1.0.1"
|
|
58
60
|
}
|
|
59
61
|
}
|
package/peak_flow.yml
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
import Cli from "../../../../src/cli/index.js"
|
|
2
4
|
import dummyConfiguration from "../../../dummy/src/config/configuration.js"
|
|
3
5
|
import dummyDirectory from "../../../dummy/dummy-directory.js"
|
|
@@ -15,9 +17,12 @@ describe("Cli - Commands - db:migrate", () => {
|
|
|
15
17
|
testing: true
|
|
16
18
|
})
|
|
17
19
|
|
|
18
|
-
let defaultDatabaseType, defaultSchemaMigrations = [],
|
|
20
|
+
let defaultDatabaseType, defaultSchemaMigrations = [], tablesResult = []
|
|
21
|
+
|
|
22
|
+
/** @type {import("../../../../src/database/drivers/base-foreign-key.js").default} */
|
|
23
|
+
let projectForeignKey = undefined
|
|
19
24
|
|
|
20
|
-
await cli.
|
|
25
|
+
await cli.getConfiguration().ensureConnections(async (dbs) => {
|
|
21
26
|
defaultDatabaseType = dbs.default.getType()
|
|
22
27
|
|
|
23
28
|
const tableNames = ["accounts", "authentication_tokens", "tasks", "project_details", "project_translations", "projects", "schema_migrations", "users"]
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import configuration from "../../../../dummy/src/config/configuration.js"
|
|
1
2
|
import DatabaseHandler from "../../../../../src/database/handler.js"
|
|
2
3
|
import DatabaseQuery from "../../../../../src/database/query/index.js"
|
|
3
4
|
import MysqlQueryParser from "../../../../../src/database/drivers/mysql/query-parser.js"
|
|
@@ -7,7 +8,8 @@ import SelectTableAndColumn from "../../../../../src/database/query/select-table
|
|
|
7
8
|
|
|
8
9
|
import MysqlDriverClass from "../../../../../src/database/drivers/mysql/index.js"
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
+
const mysqlConfig = configuration.database.test.default
|
|
12
|
+
const mysqlDriver = new MysqlDriverClass(mysqlConfig, configuration)
|
|
11
13
|
|
|
12
14
|
describe("database - connection - drivers - mysql - query parser", () => {
|
|
13
15
|
it("generates sql with selects, joins and orders", () => {
|
|
@@ -7,7 +7,7 @@ const mysqlConfig = digg(configuration, "database", "test", "default")
|
|
|
7
7
|
describe("Database - Drivers - Mysql - Connection", () => {
|
|
8
8
|
it("connects", async () => {
|
|
9
9
|
if (configuration.getDatabaseType() != "sqlite" && configuration.getDatabaseType() != "mssql" && configuration.getDatabaseType() != "pgsql") {
|
|
10
|
-
const mysql = new DatabaseDriversMysql(mysqlConfig)
|
|
10
|
+
const mysql = new DatabaseDriversMysql(mysqlConfig, configuration)
|
|
11
11
|
|
|
12
12
|
await mysql.connect()
|
|
13
13
|
|
|
@@ -4,11 +4,11 @@ import Task from "../../dummy/src/models/task.js"
|
|
|
4
4
|
describe("Record - find or create", () => {
|
|
5
5
|
it("doesnt find but then creates a record", async () => {
|
|
6
6
|
await Dummy.run(async () => {
|
|
7
|
-
const task = await Task.findOrCreateBy({name: "Test task"}, (newTask) => {
|
|
7
|
+
const task = /** @type {Task} */ (await Task.findOrCreateBy({name: "Test task"}, (newTask) => {
|
|
8
8
|
const project = newTask.buildProject({nameEn: "Test project", nameDe: "Test projekt"})
|
|
9
9
|
|
|
10
10
|
project.buildProjectDetail({note: "Test note"})
|
|
11
|
-
})
|
|
11
|
+
}))
|
|
12
12
|
|
|
13
13
|
const project = task.project()
|
|
14
14
|
|
|
@@ -51,7 +51,7 @@ describe("Record - find or create", () => {
|
|
|
51
51
|
|
|
52
52
|
expect(tasksRelationship.getPreloaded()).toBeTrue()
|
|
53
53
|
|
|
54
|
-
const projectTasksIDs = project.
|
|
54
|
+
const projectTasksIDs = project.tasksLoaded().map((task) => task.id())
|
|
55
55
|
|
|
56
56
|
expect(projectTasksIDs).toEqual([task.id()])
|
|
57
57
|
})
|
|
@@ -10,7 +10,7 @@ describe("Record - find", () => {
|
|
|
10
10
|
|
|
11
11
|
await task.save()
|
|
12
12
|
|
|
13
|
-
const foundTask = await Task.find(task.id())
|
|
13
|
+
const foundTask = /** @type {Task} */ (await Task.find(task.id()))
|
|
14
14
|
|
|
15
15
|
expect(foundTask.readAttribute("name")).toEqual("Test task")
|
|
16
16
|
expect(foundTask.readColumn("name")).toEqual("Test task")
|
|
@@ -7,7 +7,7 @@ describe("Record - instance relationships - belongs to relationship", () => {
|
|
|
7
7
|
await Dummy.run(async () => {
|
|
8
8
|
const project = await Project.create()
|
|
9
9
|
const task = await Task.create({name: "Test task", project})
|
|
10
|
-
const foundTask = await Task.find(task.id())
|
|
10
|
+
const foundTask = /** @type {Task} */ (await Task.find(task.id()))
|
|
11
11
|
const projectInstanceRelationship = foundTask.getRelationshipByName("project")
|
|
12
12
|
|
|
13
13
|
expect(projectInstanceRelationship.isLoaded()).toBeFalse()
|
|
@@ -5,9 +5,9 @@ import Task from "../../../dummy/src/models/task.js"
|
|
|
5
5
|
describe("Record - instance relationships - has many relationship", () => {
|
|
6
6
|
it("loads a relationship", async () => {
|
|
7
7
|
await Dummy.run(async () => {
|
|
8
|
-
const project = await Project.create()
|
|
8
|
+
const project = /** @type {Project} */ (await Project.create())
|
|
9
9
|
const task = await Task.create({name: "Test task", project})
|
|
10
|
-
const foundProject = await Project.find(project.id())
|
|
10
|
+
const foundProject = /** @type {Project} */ (await Project.find(project.id()))
|
|
11
11
|
const tasksInstanceRelationship = foundProject.getRelationshipByName("tasks")
|
|
12
12
|
|
|
13
13
|
expect(tasksInstanceRelationship.isLoaded()).toBeFalse()
|
|
@@ -16,7 +16,7 @@ describe("Record - instance relationships - has many relationship", () => {
|
|
|
16
16
|
|
|
17
17
|
expect(tasksInstanceRelationship.isLoaded()).toBeTrue()
|
|
18
18
|
|
|
19
|
-
const taskIDs = foundProject.
|
|
19
|
+
const taskIDs = foundProject.tasksLoaded().map((task) => task.id())
|
|
20
20
|
|
|
21
21
|
expect(taskIDs).toEqual([task.id()])
|
|
22
22
|
})
|
|
@@ -7,7 +7,7 @@ describe("Record - instance relationships - has one relationship", () => {
|
|
|
7
7
|
await Dummy.run(async () => {
|
|
8
8
|
const project = await Project.create()
|
|
9
9
|
const projectDetail = await ProjectDetail.create({note: "Test project", project})
|
|
10
|
-
const foundProject = await Project.find(project.id())
|
|
10
|
+
const foundProject = /** @type {Project} */ (await Project.find(project.id()))
|
|
11
11
|
const projectDetailInstanceRelationship = foundProject.getRelationshipByName("projectDetail")
|
|
12
12
|
|
|
13
13
|
expect(projectDetailInstanceRelationship.isLoaded()).toBeFalse()
|
|
@@ -17,11 +17,11 @@ describe("Record - last", () => {
|
|
|
17
17
|
await Task.create({name: "Test task 5", project: project2})
|
|
18
18
|
await Task.create({name: "Test task 6", project: project2})
|
|
19
19
|
|
|
20
|
-
const foundTask = await Task.last()
|
|
20
|
+
const foundTask = /** @type {Task} */ (await Task.last())
|
|
21
21
|
|
|
22
22
|
expect(foundTask.name()).toEqual("Test task 6")
|
|
23
23
|
|
|
24
|
-
const foundTaskWithFilter = await Task.where({project_id: project1.id()}).last()
|
|
24
|
+
const foundTaskWithFilter = /** @type {Task} */ (await Task.where({project_id: project1.id()}).last())
|
|
25
25
|
|
|
26
26
|
expect(foundTaskWithFilter.name()).toEqual("Test task 3")
|
|
27
27
|
})
|
|
@@ -7,7 +7,7 @@ describe("Record - preloader - belongs to", () => {
|
|
|
7
7
|
await Dummy.run(async () => {
|
|
8
8
|
const project = await Project.create({creating_user_reference: "User-65"})
|
|
9
9
|
const user = await User.create({email: "user@example.com", encrypted_password: "password", reference: "User-65"})
|
|
10
|
-
const foundProject = await Project.preload({creatingUser: true}).find(project.id())
|
|
10
|
+
const foundProject = /** @type {Project} */ (await Project.preload({creatingUser: true}).find(project.id()))
|
|
11
11
|
|
|
12
12
|
expect(foundProject.creatingUser().id()).toEqual(user.id())
|
|
13
13
|
})
|
|
@@ -7,8 +7,8 @@ describe("Record - preloader - has many", () => {
|
|
|
7
7
|
await Dummy.run(async () => {
|
|
8
8
|
const project = await Project.create({creating_user_reference: "User-65"})
|
|
9
9
|
const user = await User.create({email: "user@example.com", encrypted_password: "password", reference: "User-65"})
|
|
10
|
-
const foundUser = await User.preload({createdProjects: true}).find(user.id())
|
|
11
|
-
const createdProjectsIDs = foundUser.
|
|
10
|
+
const foundUser = /** @type {User} */ (await User.preload({createdProjects: true}).find(user.id()))
|
|
11
|
+
const createdProjectsIDs = foundUser.createdProjectsLoaded().map((createdProject) => createdProject.id())
|
|
12
12
|
|
|
13
13
|
expect(createdProjectsIDs).toEqual([project.id()])
|
|
14
14
|
})
|
|
@@ -20,8 +20,8 @@ describe("Record - preloader - has many", () => {
|
|
|
20
20
|
await Project.create({creating_user_reference: "User-69"})
|
|
21
21
|
|
|
22
22
|
const user = await User.create({email: "user@example.com", encrypted_password: "password", reference: "User-65"})
|
|
23
|
-
const foundUser = await User.preload({createdProjects: true}).find(user.id())
|
|
24
|
-
const createdProjectsIDs = foundUser.
|
|
23
|
+
const foundUser = /** @type {User} */ (await User.preload({createdProjects: true}).find(user.id()))
|
|
24
|
+
const createdProjectsIDs = foundUser.createdProjectsLoaded().map((createdProject) => createdProject.id())
|
|
25
25
|
|
|
26
26
|
expect(createdProjectsIDs).toEqual([])
|
|
27
27
|
})
|
|
@@ -7,7 +7,7 @@ describe("Record - preloader - has one", () => {
|
|
|
7
7
|
await Dummy.run(async () => {
|
|
8
8
|
const project = await Project.create({creating_user_reference: "User-65"})
|
|
9
9
|
const user = await User.create({email: "user@example.com", encrypted_password: "password", reference: "User-65"})
|
|
10
|
-
const foundUser = await User.preload({createdProject: true}).find(user.id())
|
|
10
|
+
const foundUser = /** @type {User} */ (await User.preload({createdProject: true}).find(user.id()))
|
|
11
11
|
|
|
12
12
|
expect(foundUser.createdProject().id()).toEqual([project.id()])
|
|
13
13
|
})
|
|
@@ -22,7 +22,7 @@ describe("Record - query", () => {
|
|
|
22
22
|
expect(project.nameDe()).toEqual("Test projekt")
|
|
23
23
|
expect(project.nameEn()).toEqual("Test project")
|
|
24
24
|
|
|
25
|
-
const tasks = await Task.preload({project: {projectDetail: true, translations: true}}).toArray()
|
|
25
|
+
const tasks = /** @type {Task[]} */ (await Task.preload({project: {projectDetail: true, translations: true}}).toArray())
|
|
26
26
|
const newTask = tasks[0]
|
|
27
27
|
const newProject = newTask.project()
|
|
28
28
|
const newProjectDetail = newProject.projectDetail()
|
|
@@ -85,11 +85,13 @@ describe("Record - query", () => {
|
|
|
85
85
|
await Task.create({name: `Task 2-${i}`, project: project2})
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const tasks =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
const tasks = /** @type {Task[]} */ (
|
|
89
|
+
await Task
|
|
90
|
+
.joins({project: {translations: true}})
|
|
91
|
+
.where({tasks: {name: "Task 2-2"}, project_translations: {name: "Test project 2"}})
|
|
92
|
+
.preload({project: {translations: true}})
|
|
93
|
+
.toArray()
|
|
94
|
+
)
|
|
93
95
|
|
|
94
96
|
const task = tasks[0]
|
|
95
97
|
|
|
@@ -13,7 +13,7 @@ describe("Record - translation fallbacks", () => {
|
|
|
13
13
|
|
|
14
14
|
await task.save()
|
|
15
15
|
|
|
16
|
-
const sameTask = await Task.preload({project: {translations: true}}).find(task.id())
|
|
16
|
+
const sameTask = /** @type {Task} */ (await Task.preload({project: {translations: true}}).find(task.id()))
|
|
17
17
|
const sameProject = sameTask.project()
|
|
18
18
|
|
|
19
19
|
expect(sameProject.name()).toEqual("Test projekt")
|
|
@@ -49,6 +49,7 @@ export default new Configuration({
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
directory: dummyDirectory(),
|
|
52
|
+
environment: "development",
|
|
52
53
|
environmentHandler: new NodeEnvironmentHandler(),
|
|
53
54
|
initializeModels: async ({configuration}) => {
|
|
54
55
|
const modelsPath = await fs.realpath(`${path.dirname(import.meta.dirname)}/../src/models`)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseRecord from "../../../../src/database/record/index.js"
|
|
2
2
|
|
|
3
|
-
export default class AccountBase extends
|
|
3
|
+
export default class AccountBase extends DatabaseRecord {
|
|
4
4
|
/**
|
|
5
5
|
* @returns {number}
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseRecord from "../../../../src/database/record/index.js"
|
|
2
2
|
|
|
3
|
-
export default class AuthenticationTokenBase extends
|
|
3
|
+
export default class AuthenticationTokenBase extends DatabaseRecord {
|
|
4
4
|
/**
|
|
5
5
|
* @returns {number}
|
|
6
6
|
*/
|
|
@@ -84,7 +84,7 @@ export default class AuthenticationTokenBase extends Record {
|
|
|
84
84
|
/**
|
|
85
85
|
* @returns {import("../models/user.js").default}
|
|
86
86
|
*/
|
|
87
|
-
user() { return this.getRelationshipByName("user").loaded() }
|
|
87
|
+
user() { return /** @type {import("../models/user.js").default} */ (this.getRelationshipByName("user").loaded()) }
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* @abstract
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseRecord from "../../../../src/database/record/index.js"
|
|
2
2
|
|
|
3
|
-
export default class ProjectDetailBase extends
|
|
3
|
+
export default class ProjectDetailBase extends DatabaseRecord {
|
|
4
4
|
/**
|
|
5
5
|
* @returns {number}
|
|
6
6
|
*/
|
|
@@ -77,7 +77,7 @@ export default class ProjectDetailBase extends Record {
|
|
|
77
77
|
/**
|
|
78
78
|
* @returns {import("../models/project.js").default}
|
|
79
79
|
*/
|
|
80
|
-
project() { return this.getRelationshipByName("project").loaded() }
|
|
80
|
+
project() { return /** @type {import("../models/project.js").default} */ (this.getRelationshipByName("project").loaded()) }
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* @abstract
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseRecord from "../../../../src/database/record/index.js"
|
|
2
2
|
|
|
3
|
-
export default class ProjectTranslationBase extends
|
|
3
|
+
export default class ProjectTranslationBase extends DatabaseRecord {
|
|
4
4
|
/**
|
|
5
5
|
* @returns {number}
|
|
6
6
|
*/
|
|
@@ -100,7 +100,7 @@ export default class ProjectTranslationBase extends Record {
|
|
|
100
100
|
/**
|
|
101
101
|
* @returns {import("../models/project.js").default}
|
|
102
102
|
*/
|
|
103
|
-
project() { return this.getRelationshipByName("project").loaded() }
|
|
103
|
+
project() { return /** @type {import("../models/project.js").default} */ (this.getRelationshipByName("project").loaded()) }
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* @abstract
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseRecord from "../../../../src/database/record/index.js"
|
|
2
2
|
|
|
3
|
-
export default class ProjectBase extends
|
|
3
|
+
export default class ProjectBase extends DatabaseRecord {
|
|
4
4
|
/**
|
|
5
5
|
* @returns {number}
|
|
6
6
|
*/
|
|
@@ -101,7 +101,7 @@ export default class ProjectBase extends Record {
|
|
|
101
101
|
/**
|
|
102
102
|
* @returns {import("../models/user.js").default}
|
|
103
103
|
*/
|
|
104
|
-
creatingUser() { return this.getRelationshipByName("creatingUser").loaded() }
|
|
104
|
+
creatingUser() { return /** @type {import("../models/user.js").default} */ (this.getRelationshipByName("creatingUser").loaded()) }
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* @abstract
|
|
@@ -124,14 +124,14 @@ export default class ProjectBase extends Record {
|
|
|
124
124
|
setCreatingUser(newModel) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
* @returns {import("
|
|
127
|
+
* @returns {import("../../../../src/database/record/instance-relationships/has-many.js").default}
|
|
128
128
|
*/
|
|
129
|
-
tasks() { return this.getRelationshipByName("tasks") }
|
|
129
|
+
tasks() { return /** @type {import("../../../../src/database/record/instance-relationships/has-many.js").default} */ (this.getRelationshipByName("tasks")) }
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* @returns {Array<import("../models/task.js").default>}
|
|
133
133
|
*/
|
|
134
|
-
tasksLoaded() { return this.getRelationshipByName("tasks").loaded() }
|
|
134
|
+
tasksLoaded() { return /** @type {Array<import("../models/task.js").default>} */ (this.getRelationshipByName("tasks").loaded()) }
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* @abstract
|
|
@@ -149,7 +149,7 @@ export default class ProjectBase extends Record {
|
|
|
149
149
|
/**
|
|
150
150
|
* @returns {import("../models/project-detail.js").default}
|
|
151
151
|
*/
|
|
152
|
-
projectDetail() { return this.getRelationshipByName("projectDetail").loaded() }
|
|
152
|
+
projectDetail() { return /** @type {import("../models/project-detail.js").default} */ (this.getRelationshipByName("projectDetail").loaded()) }
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* @abstract
|
|
@@ -172,14 +172,14 @@ export default class ProjectBase extends Record {
|
|
|
172
172
|
setProjectDetail(newModel) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
|
-
* @returns {import("
|
|
175
|
+
* @returns {import("../../../../src/database/record/instance-relationships/has-many.js").default}
|
|
176
176
|
*/
|
|
177
|
-
translations() { return this.getRelationshipByName("translations") }
|
|
177
|
+
translations() { return /** @type {import("../../../../src/database/record/instance-relationships/has-many.js").default} */ (this.getRelationshipByName("translations")) }
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
|
-
* @returns {Array<import("
|
|
180
|
+
* @returns {Array<import("../model-bases/project-translation.js").default>}
|
|
181
181
|
*/
|
|
182
|
-
translationsLoaded() { return this.getRelationshipByName("translations").loaded() }
|
|
182
|
+
translationsLoaded() { return /** @type {Array<import("../model-bases/project-translation.js").default>} */ (this.getRelationshipByName("translations").loaded()) }
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
185
|
* @abstract
|
|
@@ -189,7 +189,7 @@ export default class ProjectBase extends Record {
|
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
191
|
* @abstract
|
|
192
|
-
* @param {Array<import("
|
|
192
|
+
* @param {Array<import("../model-bases/project-translation.js").default>} newModels
|
|
193
193
|
* @returns {void}
|
|
194
194
|
*/
|
|
195
195
|
setTranslations(newModels) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseRecord from "../../../../src/database/record/index.js"
|
|
2
2
|
|
|
3
|
-
export default class TaskBase extends
|
|
3
|
+
export default class TaskBase extends DatabaseRecord {
|
|
4
4
|
/**
|
|
5
5
|
* @returns {number}
|
|
6
6
|
*/
|
|
@@ -93,7 +93,7 @@ export default class TaskBase extends Record {
|
|
|
93
93
|
/**
|
|
94
94
|
* @returns {import("../models/project.js").default}
|
|
95
95
|
*/
|
|
96
|
-
project() { return this.getRelationshipByName("project").loaded() }
|
|
96
|
+
project() { return /** @type {import("../models/project.js").default} */ (this.getRelationshipByName("project").loaded()) }
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* @abstract
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseRecord from "../../../../src/database/record/index.js"
|
|
2
2
|
|
|
3
|
-
export default class UserBase extends
|
|
3
|
+
export default class UserBase extends DatabaseRecord {
|
|
4
4
|
/**
|
|
5
5
|
* @returns {number}
|
|
6
6
|
*/
|
|
@@ -100,7 +100,7 @@ export default class UserBase extends Record {
|
|
|
100
100
|
/**
|
|
101
101
|
* @returns {import("../models/project.js").default}
|
|
102
102
|
*/
|
|
103
|
-
createdProject() { return this.getRelationshipByName("createdProject").loaded() }
|
|
103
|
+
createdProject() { return /** @type {import("../models/project.js").default} */ (this.getRelationshipByName("createdProject").loaded()) }
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* @abstract
|
|
@@ -123,14 +123,14 @@ export default class UserBase extends Record {
|
|
|
123
123
|
setCreatedProject(newModel) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
|
-
* @returns {import("
|
|
126
|
+
* @returns {import("../../../../src/database/record/instance-relationships/has-many.js").default}
|
|
127
127
|
*/
|
|
128
|
-
authenticationTokens() { return this.getRelationshipByName("authenticationTokens") }
|
|
128
|
+
authenticationTokens() { return /** @type {import("../../../../src/database/record/instance-relationships/has-many.js").default} */ (this.getRelationshipByName("authenticationTokens")) }
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* @returns {Array<import("../models/authentication-token.js").default>}
|
|
132
132
|
*/
|
|
133
|
-
authenticationTokensLoaded() { return this.getRelationshipByName("authenticationTokens").loaded() }
|
|
133
|
+
authenticationTokensLoaded() { return /** @type {Array<import("../models/authentication-token.js").default>} */ (this.getRelationshipByName("authenticationTokens").loaded()) }
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
136
|
* @abstract
|
|
@@ -146,14 +146,14 @@ export default class UserBase extends Record {
|
|
|
146
146
|
setAuthenticationTokens(newModels) { throw new Error("Not implemented") } // eslint-disable-line no-unused-vars
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
|
-
* @returns {import("
|
|
149
|
+
* @returns {import("../../../../src/database/record/instance-relationships/has-many.js").default}
|
|
150
150
|
*/
|
|
151
|
-
createdProjects() { return this.getRelationshipByName("createdProjects") }
|
|
151
|
+
createdProjects() { return /** @type {import("../../../../src/database/record/instance-relationships/has-many.js").default} */ (this.getRelationshipByName("createdProjects")) }
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
154
|
* @returns {Array<import("../models/project.js").default>}
|
|
155
155
|
*/
|
|
156
|
-
createdProjectsLoaded() { return this.getRelationshipByName("createdProjects").loaded() }
|
|
156
|
+
createdProjectsLoaded() { return /** @type {Array<import("../models/project.js").default>} */ (this.getRelationshipByName("createdProjects").loaded()) }
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* @abstract
|
|
@@ -10,7 +10,7 @@ export default class ProjectsController extends Controller {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async show() {
|
|
13
|
-
const projectId = digg(params, "id")
|
|
13
|
+
const projectId = digg(this.params(), "id")
|
|
14
14
|
const project = await Project.find(projectId)
|
|
15
15
|
|
|
16
16
|
this.viewParams.project = project
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {digg} from "diggerize"
|
|
2
|
-
|
|
3
1
|
import Controller from "../../../../../src/controller.js"
|
|
4
2
|
import Task from "../../models/task.js"
|
|
5
3
|
|
|
@@ -10,7 +8,7 @@ export default class TasksController extends Controller {
|
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
async show() {
|
|
13
|
-
const taskId =
|
|
11
|
+
const taskId = this.params().id
|
|
14
12
|
const task = await Task.find(taskId)
|
|
15
13
|
|
|
16
14
|
this.viewParams.task = task
|
|
@@ -3,7 +3,7 @@ import Client from "../../src/http-server/client/index.js"
|
|
|
3
3
|
import {digg} from "diggerize"
|
|
4
4
|
import dummyConfiguration from "../dummy/src/config/configuration.js"
|
|
5
5
|
|
|
6
|
-
describe("http server - client", {databaseCleaning: {transaction: false, truncate: true}}, () => {
|
|
6
|
+
describe("http server - client", {databaseCleaning: {transaction: false, truncate: true}}, async () => {
|
|
7
7
|
it("spawns a request for each that it is fed", async () => {
|
|
8
8
|
await dummyConfiguration.initialize()
|
|
9
9
|
|
|
@@ -4,7 +4,7 @@ import Header from "../../src/http-client/header.js"
|
|
|
4
4
|
import HttpClient from "../../src/http-client/index.js"
|
|
5
5
|
import {wait, waitFor} from "awaitery"
|
|
6
6
|
|
|
7
|
-
describe("HttpServer - get", {databaseCleaning: {transaction: false, truncate: true}}, () => {
|
|
7
|
+
describe("HttpServer - get", {databaseCleaning: {transaction: false, truncate: true}}, async () => {
|
|
8
8
|
it("handles get requests", async () => {
|
|
9
9
|
await Dummy.run(async () => {
|
|
10
10
|
for (let i = 0; i <= 5; i++) {
|
|
@@ -6,7 +6,7 @@ import wait from "awaitery/src/wait.js"
|
|
|
6
6
|
import Dummy from "../dummy/index.js"
|
|
7
7
|
import Project from "../dummy/src/models/project.js"
|
|
8
8
|
|
|
9
|
-
describe("HttpServer - post", {databaseCleaning: {transaction: false, truncate: true}}, () => {
|
|
9
|
+
describe("HttpServer - post", {databaseCleaning: {transaction: false, truncate: true}}, async () => {
|
|
10
10
|
it("handles post requests", async () => {
|
|
11
11
|
await Dummy.run(async () => {
|
|
12
12
|
for (let i = 0; i <= 5; i++) {
|
|
@@ -17,7 +17,7 @@ describe("HttpServer - post", {databaseCleaning: {transaction: false, truncate:
|
|
|
17
17
|
body: postData,
|
|
18
18
|
headers: {
|
|
19
19
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
20
|
-
"Content-Length": Buffer.byteLength(postData)
|
|
20
|
+
"Content-Length": Buffer.byteLength(postData).toString()
|
|
21
21
|
},
|
|
22
22
|
method: "POST"
|
|
23
23
|
}
|
|
@@ -27,7 +27,7 @@ describe("HttpServer - post", {databaseCleaning: {transaction: false, truncate:
|
|
|
27
27
|
|
|
28
28
|
await wait(100) // Wait a bit to ensure the database connections are in sync
|
|
29
29
|
|
|
30
|
-
const createdProject = await Project.preload({translations: true}).find(projectID)
|
|
30
|
+
const createdProject = /** @type {Project} */ (await Project.preload({translations: true}).find(projectID))
|
|
31
31
|
|
|
32
32
|
expect(createdProject.name()).toEqual("Test create project")
|
|
33
33
|
}
|
|
@@ -44,18 +44,18 @@ describe("HttpServer - post", {databaseCleaning: {transaction: false, truncate:
|
|
|
44
44
|
body: postData,
|
|
45
45
|
headers: {
|
|
46
46
|
"Content-Type": "application/json",
|
|
47
|
-
"Content-Length": Buffer.byteLength(postData)
|
|
47
|
+
"Content-Length": Buffer.byteLength(postData).toString()
|
|
48
48
|
},
|
|
49
49
|
method: "POST"
|
|
50
50
|
}
|
|
51
51
|
)
|
|
52
|
-
const data = await response.json()
|
|
52
|
+
const data = /** @type {Record<string, any>} */ (await response.json())
|
|
53
53
|
|
|
54
54
|
expect(data.status).toEqual("success")
|
|
55
55
|
|
|
56
56
|
await wait(100) // Wait a bit to ensure the database connections are in sync
|
|
57
57
|
|
|
58
|
-
const createdProject = await Project.preload({translations: true}).last()
|
|
58
|
+
const createdProject = /** @type {Project} */ (await Project.preload({translations: true}).last())
|
|
59
59
|
|
|
60
60
|
expect(createdProject.name()).toEqual("Test create project")
|
|
61
61
|
}
|
|
@@ -67,7 +67,7 @@ describe("HttpServer - post", {databaseCleaning: {transaction: false, truncate:
|
|
|
67
67
|
for (let i = 0; i <= 5; i++) {
|
|
68
68
|
const body = new FormData()
|
|
69
69
|
|
|
70
|
-
body.append("project[creating_user_reference]", 150123)
|
|
70
|
+
body.append("project[creating_user_reference]", "150123")
|
|
71
71
|
body.append("project[name]", "Test create project")
|
|
72
72
|
|
|
73
73
|
const response = await fetch(
|
|
@@ -77,13 +77,13 @@ describe("HttpServer - post", {databaseCleaning: {transaction: false, truncate:
|
|
|
77
77
|
method: "POST"
|
|
78
78
|
}
|
|
79
79
|
)
|
|
80
|
-
const data = await response.json()
|
|
80
|
+
const data = /** @type {Record<string, any>} */ (await response.json())
|
|
81
81
|
|
|
82
82
|
expect(data.status).toEqual("success")
|
|
83
83
|
|
|
84
84
|
await wait(100) // Wait a bit to ensure the database connections are in sync
|
|
85
85
|
|
|
86
|
-
const createdProject = await Project.preload({translations: true}).last()
|
|
86
|
+
const createdProject = /** @type {Project} */ (await Project.preload({translations: true}).last())
|
|
87
87
|
|
|
88
88
|
expect(createdProject.creatingUserReference()).toEqual("150123")
|
|
89
89
|
expect(createdProject.name()).toEqual("Test create project")
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import {describe, it} from "../../src/testing/test.js"
|
|
1
2
|
import fetch from "node-fetch"
|
|
2
3
|
import Dummy from "../dummy/index.js"
|
|
3
4
|
|
|
4
|
-
describe("HttpServer - root get", {databaseCleaning: {transaction: false, truncate: true}}, () => {
|
|
5
|
+
describe("HttpServer - root get", {databaseCleaning: {transaction: false, truncate: true}}, async () => {
|
|
5
6
|
it("handles root get requests", async () => {
|
|
6
7
|
await Dummy.run(async () => {
|
|
7
8
|
for (let i = 0; i <= 5; i++) {
|
package/src/application.js
CHANGED