@ditojs/server 2.45.1 → 2.46.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/server",
3
- "version": "2.45.1",
3
+ "version": "2.46.0",
4
4
  "type": "module",
5
5
  "description": "Dito.js Server – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
6
6
  "repository": "https://github.com/ditojs/dito/tree/master/packages/server",
@@ -25,12 +25,12 @@
25
25
  "node >= 18"
26
26
  ],
27
27
  "dependencies": {
28
- "@ditojs/admin": "^2.45.1",
29
- "@ditojs/build": "^2.45.0",
30
- "@ditojs/router": "^2.45.0",
31
- "@ditojs/utils": "^2.45.0",
28
+ "@ditojs/admin": "^2.46.0",
29
+ "@ditojs/build": "^2.46.0",
30
+ "@ditojs/router": "^2.46.0",
31
+ "@ditojs/utils": "^2.46.0",
32
32
  "@koa/cors": "^5.0.0",
33
- "@koa/multer": "^3.0.2",
33
+ "@koa/multer": "^3.1.0",
34
34
  "@originjs/vite-plugin-commonjs": "^1.0.3",
35
35
  "ajv": "^8.17.1",
36
36
  "ajv-formats": "^2.1.1",
@@ -53,11 +53,11 @@
53
53
  "koa-session": "^7.0.2",
54
54
  "koa-static": "^5.0.0",
55
55
  "leather": "^3.0.3",
56
- "mime-types": "^2.1.35",
56
+ "mime-types": "^3.0.1",
57
57
  "multer": "^1.4.5-lts.2",
58
58
  "multer-s3": "https://github.com/ditojs/multer-s3#dito",
59
59
  "nanoid": "^5.1.5",
60
- "parse-duration": "^2.1.3",
60
+ "parse-duration": "^2.1.4",
61
61
  "passport-local": "^1.0.0",
62
62
  "passthrough-counter": "^1.0.0",
63
63
  "picocolors": "^1.1.1",
@@ -84,11 +84,11 @@
84
84
  "@types/koa-session": "^6.4.5",
85
85
  "@types/koa-static": "^4.0.4",
86
86
  "@types/koa__cors": "^5.0.0",
87
- "@types/node": "^22.13.13",
87
+ "@types/node": "^22.13.14",
88
88
  "knex": "^3.1.0",
89
89
  "objection": "^3.1.5",
90
90
  "typescript": "^5.8.2"
91
91
  },
92
92
  "types": "types",
93
- "gitHead": "6de5398fb812c9cbc030761e3ef82cac9a030117"
93
+ "gitHead": "7b8291912cfb1f1de8fe55dd7658ac544c23545a"
94
94
  }
@@ -12,7 +12,8 @@ import {
12
12
  normalizeDataPath,
13
13
  getValueAtDataPath,
14
14
  mapConcurrently,
15
- assignDeeply
15
+ assignDeeply,
16
+ deprecate
16
17
  } from '@ditojs/utils'
17
18
  import { QueryBuilder } from '../query/index.js'
18
19
  import { EventEmitter, KnexHelper } from '../lib/index.js'
@@ -756,7 +757,23 @@ export class Model extends objection.Model {
756
757
  )
757
758
  }
758
759
  // Now check possible scope prefixes and handle them:
759
- switch (modifier[0]) {
760
+
761
+ let prefix = modifier[0]
762
+ const deprecatedPrefixes = { '-': '!', '#': '@' }
763
+ if (deprecatedPrefixes[prefix]) {
764
+ prefix = deprecatedPrefixes[prefix]
765
+ deprecate(
766
+ `The ${
767
+ modifier
768
+ } modifier is deprecated, use the ${
769
+ prefix
770
+ }${
771
+ modifier.slice(1)
772
+ } modifier instead.`
773
+ )
774
+ }
775
+
776
+ switch (prefix) {
760
777
  case '^': // Eager-applied scope:
761
778
  // Always apply eager-scopes, even if the model itself doesn't know
762
779
  // it. The scope may still be known in eager-loaded relations.
@@ -767,14 +784,17 @@ export class Model extends objection.Model {
767
784
  // that are defined on relations to be applied.
768
785
  false
769
786
  )
770
- case '-': // Ignore scope:
787
+ case '!': // Ignore scope:
771
788
  return query.ignoreScope(modifier.slice(1))
772
- case '#': // Select column:
789
+ case '@': // Select column:
773
790
  return query.select(modifier.slice(1))
791
+ case '~': // omit column:
792
+ return query.omit(modifier.slice(1))
774
793
  case '*': // Select all columns:
775
794
  if (modifier === '*') {
776
795
  return query.select('*')
777
796
  }
797
+ break
778
798
  }
779
799
  }
780
800
  super.modifierNotFound(query, modifier)
@@ -5,6 +5,7 @@ import {
5
5
  isBoolean,
6
6
  isObject,
7
7
  isPlainObject,
8
+ asArray,
8
9
  clone,
9
10
  mapKeys,
10
11
  getValueAtDataPath,
@@ -31,6 +32,7 @@ export class QueryBuilder extends objection.QueryBuilder {
31
32
  #appliedScopes = {}
32
33
  #allowFilters = null
33
34
  #executeFirst = null // Part of a work-around for cyclic graphs
35
+ #omits = []
34
36
 
35
37
  // @override
36
38
  clone() {
@@ -45,6 +47,14 @@ export class QueryBuilder extends objection.QueryBuilder {
45
47
 
46
48
  // @override
47
49
  async execute() {
50
+ if (this.#omits.length > 0) {
51
+ this.runAfter(result => {
52
+ for (const model of asArray(result)) {
53
+ model.$omitFromJson(...this.#omits)
54
+ }
55
+ return result
56
+ })
57
+ }
48
58
  this.#applyScopes()
49
59
  // In case of cyclic graphs, run `_executeFirst()` now:
50
60
  await this.#executeFirst?.()
@@ -88,6 +98,10 @@ export class QueryBuilder extends objection.QueryBuilder {
88
98
  return super.toFindQuery().clear('runAfter')
89
99
  }
90
100
 
101
+ omit(...properties) {
102
+ this.#omits.push(...properties)
103
+ }
104
+
91
105
  #withScope(...args) {
92
106
  const { checkAllowedScopes, scopes } = getScopes(args)
93
107
  for (const expr of scopes) {