velocious 1.0.106 → 1.0.108

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 (86) hide show
  1. package/package.json +3 -1
  2. package/peak_flow.yml +1 -0
  3. package/spec/cli/commands/db/migrate-spec.js +7 -2
  4. package/spec/cli/commands/test/test-files-finder-spec.js +2 -0
  5. package/spec/database/connection/drivers/mysql/query-parser-spec.js +3 -1
  6. package/spec/database/drivers/mysql/connection-spec.js +1 -1
  7. package/spec/database/record/find-or-create-spec.js +3 -3
  8. package/spec/database/record/find-spec.js +1 -1
  9. package/spec/database/record/instance-relationships/belongs-to-relationship-spec.js +1 -1
  10. package/spec/database/record/instance-relationships/has-many-relationship-spec.js +3 -3
  11. package/spec/database/record/instance-relationships/has-one-relationship-spec.js +1 -1
  12. package/spec/database/record/last-spec.js +2 -2
  13. package/spec/database/record/preloader/belongs-to-spec.js +1 -1
  14. package/spec/database/record/preloader/has-many-spec.js +4 -4
  15. package/spec/database/record/preloader/has-one-spec.js +1 -1
  16. package/spec/database/record/query-spec.js +8 -6
  17. package/spec/database/record/translation-fallbacks-spec.js +1 -1
  18. package/spec/dummy/src/config/configuration.example.js +1 -0
  19. package/spec/dummy/src/config/routes.js +4 -0
  20. package/spec/dummy/src/model-bases/account.js +2 -2
  21. package/spec/dummy/src/model-bases/authentication-token.js +3 -3
  22. package/spec/dummy/src/model-bases/project-detail.js +3 -3
  23. package/spec/dummy/src/model-bases/project-translation.js +3 -3
  24. package/spec/dummy/src/model-bases/project.js +12 -12
  25. package/spec/dummy/src/model-bases/task.js +3 -3
  26. package/spec/dummy/src/model-bases/user.js +9 -9
  27. package/spec/dummy/src/routes/api/controller.js +9 -0
  28. package/spec/dummy/src/routes/projects/controller.js +1 -1
  29. package/spec/dummy/src/routes/tasks/controller.js +1 -3
  30. package/spec/http-server/client-spec.js +1 -1
  31. package/spec/http-server/get-spec.js +1 -1
  32. package/spec/http-server/namespace-spec.js +17 -0
  33. package/spec/http-server/post-spec.js +9 -9
  34. package/spec/http-server/root-get-spec.js +2 -1
  35. package/src/application.js +1 -0
  36. package/src/cli/base-command.js +1 -1
  37. package/src/cli/commands/db/create.js +1 -1
  38. package/src/cli/use-browser-cli.js +2 -0
  39. package/src/configuration-types.js +11 -6
  40. package/src/controller.js +1 -2
  41. package/src/database/drivers/base.js +9 -9
  42. package/src/database/drivers/mssql/index.js +11 -11
  43. package/src/database/drivers/mssql/options.js +10 -6
  44. package/src/database/drivers/mysql/index.js +8 -8
  45. package/src/database/drivers/mysql/options.js +10 -6
  46. package/src/database/drivers/pgsql/index.js +10 -10
  47. package/src/database/drivers/pgsql/options.js +9 -6
  48. package/src/database/drivers/sqlite/base.js +10 -10
  49. package/src/database/drivers/sqlite/connection-sql-js.js +2 -0
  50. package/src/database/drivers/sqlite/index.js +8 -2
  51. package/src/database/drivers/sqlite/index.native.js +5 -1
  52. package/src/database/drivers/sqlite/index.web.js +2 -1
  53. package/src/database/drivers/sqlite/options.js +10 -7
  54. package/src/database/drivers/sqlite/sql/alter-table.js +3 -3
  55. package/src/database/migration/index.js +16 -5
  56. package/src/database/migrator.js +5 -1
  57. package/src/database/pool/base-methods-forward.js +0 -4
  58. package/src/database/query/alter-table-base.js +2 -2
  59. package/src/database/query/base.js +2 -2
  60. package/src/database/query/create-index-base.js +2 -2
  61. package/src/database/query/create-table-base.js +4 -4
  62. package/src/database/query/drop-table-base.js +2 -2
  63. package/src/database/query/index.js +2 -2
  64. package/src/database/record/index.js +11 -44
  65. package/src/database/record/instance-relationships/base.js +2 -2
  66. package/src/database/record/instance-relationships/has-many.js +1 -1
  67. package/src/database/use-database.js +1 -0
  68. package/src/environment-handlers/base.js +2 -2
  69. package/src/environment-handlers/browser.js +40 -18
  70. package/src/environment-handlers/node/cli/commands/destroy/migration.js +5 -1
  71. package/src/environment-handlers/node/cli/commands/generate/base-models.js +20 -9
  72. package/src/environment-handlers/node/cli/commands/generate/migration.js +5 -1
  73. package/src/environment-handlers/node/cli/commands/generate/model.js +5 -1
  74. package/src/environment-handlers/node/cli/commands/init.js +5 -1
  75. package/src/environment-handlers/node.js +1 -1
  76. package/src/http-server/client/index.js +2 -1
  77. package/src/http-server/client/params-to-object.js +0 -8
  78. package/src/http-server/client/request-buffer/index.js +1 -0
  79. package/src/routes/basic-route.js +1 -1
  80. package/src/routes/namespace-route.js +1 -1
  81. package/src/testing/test-files-finder.js +1 -1
  82. package/src/testing/test-runner.js +3 -0
  83. package/src/testing/test.js +0 -2
  84. package/src/utils/with-tracked-stack-async-hooks.js +0 -2
  85. package/src/utils/with-tracked-stack.js +0 -2
  86. 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.106",
6
+ "version": "1.0.108",
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
@@ -86,3 +86,4 @@ builds:
86
86
  - cp spec/dummy/src/config/configuration.peakflow.sqlite.js spec/dummy/src/config/configuration.js
87
87
  - sleep 5
88
88
  - npm run lint
89
+ - npm run typecheck
@@ -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 = [], projectForeignKey = [], tablesResult = []
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.configuration.ensureConnections(async (dbs) => {
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,5 @@
1
+ // @ts-check
2
+
1
3
  import fs from "fs/promises"
2
4
  import TestFilesFinder from "../../../../src/testing/test-files-finder.js"
3
5
 
@@ -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 mysqlDriver = new MysqlDriverClass()
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.tasks().loaded().map((task) => task.id())
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.tasks().loaded().map((task) => task.id())
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.createdProjects().loaded().map((createdProject) => createdProject.id())
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.createdProjects().loaded().map((createdProject) => createdProject.id())
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 = await Task
89
- .joins({project: {translations: true}})
90
- .where({tasks: {name: "Task 2-2"}, project_translations: {name: "Test project 2"}})
91
- .preload({project: {translations: true}})
92
- .toArray()
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`)
@@ -3,6 +3,10 @@ import Routes from "../../../../src/routes/index.js"
3
3
  const routes = new Routes()
4
4
 
5
5
  routes.draw((route) => {
6
+ route.namespace("api", (route) => {
7
+ route.post("version")
8
+ })
9
+
6
10
  route.resources("projects")
7
11
 
8
12
  route.resources("tasks", (route) => {
@@ -1,6 +1,6 @@
1
- import Record from "../../../../src/database/record/index.js"
1
+ import DatabaseRecord from "../../../../src/database/record/index.js"
2
2
 
3
- export default class AccountBase extends Record {
3
+ export default class AccountBase extends DatabaseRecord {
4
4
  /**
5
5
  * @returns {number}
6
6
  */
@@ -1,6 +1,6 @@
1
- import Record from "../../../../src/database/record/index.js"
1
+ import DatabaseRecord from "../../../../src/database/record/index.js"
2
2
 
3
- export default class AuthenticationTokenBase extends Record {
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 Record from "../../../../src/database/record/index.js"
1
+ import DatabaseRecord from "../../../../src/database/record/index.js"
2
2
 
3
- export default class ProjectDetailBase extends Record {
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 Record from "../../../../src/database/record/index.js"
1
+ import DatabaseRecord from "../../../../src/database/record/index.js"
2
2
 
3
- export default class ProjectTranslationBase extends Record {
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 Record from "../../../../src/database/record/index.js"
1
+ import DatabaseRecord from "../../../../src/database/record/index.js"
2
2
 
3
- export default class ProjectBase extends Record {
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("velocious/src/database/query/index.js").default<import("../models/task.js").default>}
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("velocious/src/database/query/index.js").default<import("velocious/src/database/record/index.js").default>}
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("velocious/src/database/record/index.js").default>}
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("velocious/src/database/record/index.js").default>} newModels
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 Record from "../../../../src/database/record/index.js"
1
+ import DatabaseRecord from "../../../../src/database/record/index.js"
2
2
 
3
- export default class TaskBase extends Record {
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 Record from "../../../../src/database/record/index.js"
1
+ import DatabaseRecord from "../../../../src/database/record/index.js"
2
2
 
3
- export default class UserBase extends Record {
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("velocious/src/database/query/index.js").default<import("../models/authentication-token.js").default>}
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("velocious/src/database/query/index.js").default<import("../models/project.js").default>}
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
@@ -0,0 +1,9 @@
1
+ import Controller from "../../../../../src/controller.js"
2
+
3
+ export default class ApiController extends Controller {
4
+ version() {
5
+ this.renderJsonArg({
6
+ version: "2.1"
7
+ })
8
+ }
9
+ }
@@ -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 = digg(params, "id")
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++) {
@@ -0,0 +1,17 @@
1
+ import fetch from "node-fetch"
2
+
3
+ import Dummy from "../dummy/index.js"
4
+
5
+ describe("HttpServer - namespace", {databaseCleaning: {transaction: false, truncate: true}}, async () => {
6
+ it("handles post requests", async () => {
7
+ await Dummy.run(async () => {
8
+ const response = await fetch(
9
+ "http://localhost:3006/api/version",
10
+ {method: "POST"}
11
+ )
12
+ const data = /** @type {Record<string, any>} */ (await response.json())
13
+
14
+ expect(data.version).toEqual("2.1")
15
+ })
16
+ })
17
+ })