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
@@ -3,9 +3,13 @@ import fileExists from "../../../../../utils/file-exists.js"
3
3
  import fs from "fs/promises"
4
4
  import * as inflection from "inflection"
5
5
 
6
+ /**
7
+ * @typedef {{date: Date, modelContent: string, modelName: string, modelNameCamelized: string, modelPath: string}} DbGenerateModelResult
8
+ */
9
+
6
10
  export default class DbGenerateModel extends BaseCommand {
7
11
  /**
8
- * @returns {Promise<void>}
12
+ * @returns {Promise<void | DbGenerateModelResult>}
9
13
  */
10
14
  async execute() {
11
15
  const modelName = this.processArgs[1]
@@ -2,9 +2,13 @@ import BaseCommand from "../../../../cli/base-command.js"
2
2
  import fileExists from "../../../../utils/file-exists.js"
3
3
  import fs from "fs/promises"
4
4
 
5
+ /**
6
+ * @typedef {{source: string, target: string}} FileMappingType
7
+ */
8
+
5
9
  export default class VelociousCliCommandsInit extends BaseCommand {
6
10
  /**
7
- * @returns {Promise<void>}
11
+ * @returns {Promise<void | {fileMappings: FileMappingType[]}>}
8
12
  */
9
13
  async execute() {
10
14
  const velociousPath = await this.getEnvironmentHandler().getVelociousPath()
@@ -115,7 +115,7 @@ export default class VelociousEnvironmentHandlerNode extends Base{
115
115
  /**
116
116
  * @param {object} args
117
117
  * @param {string[]} args.commandParts
118
- * @returns {Promise<import ("../cli/base-command.js").default>}
118
+ * @returns {Promise<typeof import ("../cli/base-command.js").default>}
119
119
  */
120
120
  async requireCommand({commandParts}) {
121
121
  const commands = await this.findCommands()
@@ -46,7 +46,8 @@ export default class VeoliciousHttpServerClient {
46
46
  }
47
47
 
48
48
  /**
49
- * @param {string} data
49
+ * @param {Buffer} data
50
+ * @returns {void}
50
51
  */
51
52
  onWrite(data) {
52
53
  if (this.state == "initial") {
@@ -36,21 +36,17 @@ export default class ParamsToObject {
36
36
  let newResult
37
37
 
38
38
  if (inputName in result) {
39
- // @ts-expect-error
40
39
  newResult = result[inputName]
41
40
  } else if (rest == "[]") {
42
41
  newResult = []
43
- // @ts-expect-error
44
42
  result[inputName] = newResult
45
43
  } else {
46
44
  newResult = {}
47
- // @ts-expect-error
48
45
  result[inputName] = newResult
49
46
  }
50
47
 
51
48
  this.treatSecond(value, rest, newResult)
52
49
  } else {
53
- // @ts-expect-error
54
50
  result[key] = value
55
51
  }
56
52
  }
@@ -74,19 +70,15 @@ export default class ParamsToObject {
74
70
  if (rest == "[]") {
75
71
  result.push(value)
76
72
  } else if (newRest == "") {
77
- // @ts-expect-error
78
73
  result[key] = value
79
74
  } else {
80
75
  if (typeof result == "object" && key in result) {
81
- // @ts-expect-error
82
76
  newResult = result[key]
83
77
  } else if (newRest == "[]") {
84
78
  newResult = []
85
- // @ts-expect-error
86
79
  result[key] = newResult
87
80
  } else {
88
81
  newResult = {}
89
- // @ts-expect-error
90
82
  result[key] = newResult
91
83
  }
92
84
 
@@ -334,6 +334,7 @@ export default class RequestBuffer {
334
334
 
335
335
  parseQueryStringPostParams() {
336
336
  if (this.postBody) {
337
+ /** @type {Record<string, any>} */
337
338
  const unparsedParams = querystring.parse(this.postBody)
338
339
  const paramsToObject = new ParamsToObject(unparsedParams)
339
340
  const newParams = paramsToObject.toObject()
@@ -57,7 +57,7 @@ export default class VelociousBasicRoute extends BaseRoute {
57
57
 
58
58
  /**
59
59
  * @param {string} name
60
- * @param {function(import("./resource-route.js").default) : void} callback
60
+ * @param {function(import("./resource-route.js").default) : void} [callback]
61
61
  * @returns {void}
62
62
  */
63
63
  resources(name, callback) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import restArgsError from "../utils/rest-args-error.js"
4
4
  import BaseRoute from "./base-route.js"
5
- import BasicRoute from "./base-route.js"
5
+ import BasicRoute from "./basic-route.js"
6
6
  import escapeStringRegexp from "escape-string-regexp"
7
7
 
8
8
  class VelociousRouteNamespaceRoute extends BasicRoute {
@@ -13,7 +13,7 @@ export default class TestFilesFinder {
13
13
  /**
14
14
  * @param {object} args
15
15
  * @param {string} args.directory
16
- * @param {string[]} args.directories
16
+ * @param {string[]} [args.directories]
17
17
  * @param {string[]} args.processArgs
18
18
  */
19
19
  constructor({directory, directories, processArgs, ...restArgs}) {
@@ -11,6 +11,9 @@ import {tests} from "./test.js"
11
11
  * @typedef {object} TestArgs
12
12
  * @property {Application} [application]
13
13
  * @property {RequestClient} [client]
14
+ * @property {object} [databaseCleaning]
15
+ * @property {boolean} [databaseCleaning.transaction]
16
+ * @property {boolean} [databaseCleaning.truncate]
14
17
  * @property {boolean} [focus]
15
18
  * @property {() => Promise<void>} [function]
16
19
  * @property {string} [type]
@@ -412,7 +412,6 @@ function it(description, arg1, arg2) {
412
412
  let testFunction
413
413
 
414
414
  if (typeof arg1 == "function") {
415
- // @ts-expect-error
416
415
  testFunction = arg1
417
416
  testArgs = {}
418
417
  } else if (typeof arg2 == "function") {
@@ -440,7 +439,6 @@ function fit(description, arg1, arg2) {
440
439
  let testFunction
441
440
 
442
441
  if (typeof arg1 == "function") {
443
- // @ts-expect-error
444
442
  testFunction = arg1
445
443
  testArgs = {focus: true}
446
444
  } else if (typeof arg2 == "function") {
@@ -76,11 +76,9 @@ async function withTrackedStack(arg1, arg2) {
76
76
  })
77
77
  }
78
78
 
79
- // @ts-expect-error
80
79
  if (globalThis.withTrackedStack) {
81
80
  console.warn("globalThis.withTrackedStack was already defined")
82
81
  } else {
83
- // @ts-expect-error
84
82
  globalThis.withTrackedStack = {addTrackedStackToError, withTrackedStack}
85
83
  }
86
84
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  /** @param {Error} error */
4
4
  function addTrackedStackToError(error) {
5
- // @ts-expect-error
6
5
  globalThis.withTrackedStack?.addTrackedStackToError(error)
7
6
  }
8
7
 
@@ -11,7 +10,6 @@ function addTrackedStackToError(error) {
11
10
  * @returns {Promise<any>}
12
11
  */
13
12
  async function withTrackedStack(...args) {
14
- // @ts-expect-error
15
13
  const withTrackedStack = globalThis.withTrackedStack?.withTrackedStack
16
14
 
17
15
  let callback
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "checkJs": true,
4
+
5
+ "noEmit": true,
6
+ "target": "ES2024",
7
+
8
+ "moduleResolution": "nodenext",
9
+ "module": "nodenext",
10
+
11
+ "lib": ["dom", "ES2024"],
12
+ "types": ["node"]
13
+ },
14
+ "exclude": ["src/templates/**"]
15
+ }