@contember/schema 2.1.0-alpha.9 → 2.1.0-beta.1

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 (46) hide show
  1. package/CLAUDE.md +25 -0
  2. package/dist/development/src/ProjectRole.cjs.map +1 -1
  3. package/dist/development/src/ProjectRole.js.map +1 -1
  4. package/dist/development/src/schema/acl.cjs.map +1 -1
  5. package/dist/development/src/schema/acl.js.map +1 -1
  6. package/dist/development/src/schema/input.cjs.map +1 -1
  7. package/dist/development/src/schema/input.js.map +1 -1
  8. package/dist/development/src/schema/model.cjs.map +1 -1
  9. package/dist/development/src/schema/model.js.map +1 -1
  10. package/dist/development/src/schema/result.cjs.map +1 -1
  11. package/dist/development/src/schema/result.js.map +1 -1
  12. package/dist/development/src/schema/validation.cjs.map +1 -1
  13. package/dist/development/src/schema/validation.js.map +1 -1
  14. package/dist/production/src/ProjectRole.cjs.map +1 -1
  15. package/dist/production/src/ProjectRole.js.map +1 -1
  16. package/dist/production/src/schema/acl.cjs.map +1 -1
  17. package/dist/production/src/schema/acl.js.map +1 -1
  18. package/dist/production/src/schema/input.cjs.map +1 -1
  19. package/dist/production/src/schema/input.js.map +1 -1
  20. package/dist/production/src/schema/model.cjs.map +1 -1
  21. package/dist/production/src/schema/model.js.map +1 -1
  22. package/dist/production/src/schema/result.cjs.map +1 -1
  23. package/dist/production/src/schema/result.js.map +1 -1
  24. package/dist/production/src/schema/validation.cjs.map +1 -1
  25. package/dist/production/src/schema/validation.js.map +1 -1
  26. package/dist/types/index.d.ts.map +1 -1
  27. package/dist/types/schema/acl.d.ts +3 -3
  28. package/dist/types/schema/acl.d.ts.map +1 -1
  29. package/dist/types/schema/actions.d.ts +1 -0
  30. package/dist/types/schema/actions.d.ts.map +1 -1
  31. package/dist/types/schema/actionsPayload.d.ts +13 -0
  32. package/dist/types/schema/actionsPayload.d.ts.map +1 -1
  33. package/dist/types/schema/input.d.ts +1 -1
  34. package/dist/types/schema/input.d.ts.map +1 -1
  35. package/dist/types/schema/model.d.ts +5 -2
  36. package/dist/types/schema/model.d.ts.map +1 -1
  37. package/dist/types/schema/validation.d.ts.map +1 -1
  38. package/dist/types/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +7 -2
  40. package/src/index.ts +1 -1
  41. package/src/schema/acl.ts +10 -12
  42. package/src/schema/actions.ts +2 -2
  43. package/src/schema/actionsPayload.ts +14 -1
  44. package/src/schema/input.ts +20 -18
  45. package/src/schema/model.ts +93 -10
  46. package/src/schema/validation.ts +2 -2
@@ -2,13 +2,12 @@ import { Input } from './input'
2
2
  import { JSONValue } from './json'
3
3
 
4
4
  export namespace Model {
5
-
6
- export type Entity = {
5
+ export type Entity<Fields extends string = string> = {
7
6
  readonly name: string
8
7
  readonly primary: string
9
8
  readonly primaryColumn: string
10
9
  readonly tableName: string
11
- readonly fields: { readonly [name: string]: AnyField }
10
+ readonly fields: { readonly [name in Fields]: AnyField }
12
11
  readonly unique: Uniques
13
12
  readonly indexes: Indexes
14
13
  readonly view?: View
@@ -53,7 +52,7 @@ export namespace Model {
53
52
  readonly columnName: string
54
53
  }
55
54
 
56
- export type ColumnTypeDefinition<T extends ColumnType = ColumnType> =
55
+ export type ColumnTypeDefinition<T extends ColumnType = ColumnType> =
57
56
  & Field<T>
58
57
  & {
59
58
  readonly columnType: string
@@ -70,13 +69,95 @@ export namespace Model {
70
69
 
71
70
  export type Collation =
72
71
  // generic
73
- | 'und-x-icu' | 'C' | 'ucs_basic' | 'unicode' | 'POSIX' | 'default'
72
+ | 'und-x-icu'
73
+ | 'C'
74
+ | 'ucs_basic'
75
+ | 'unicode'
76
+ | 'POSIX'
77
+ | 'default'
74
78
  // some languages
75
- | 'cs-x-icu' | 'sk-x-icu' | 'da-x-icu' | 'de-x-icu' | 'en-x-icu' | 'es-x-icu' | 'fr-x-icu' | 'it-x-icu' | 'ja-x-icu' | 'ko-x-icu' | 'nl-x-icu' | 'pl-x-icu' | 'pt-x-icu' | 'ru-x-icu' | 'sv-x-icu' | 'tr-x-icu' | 'zh-x-icu' | 'hu-x-icu' | 'fi-x-icu' | 'el-x-icu' | 'bg-x-icu' | 'hr-x-icu' | 'ro-x-icu' | 'sl-x-icu' | 'sr-x-icu' | 'uk-x-icu' | 'vi-x-icu' | 'th-x-icu' | 'ar-x-icu' | 'he-x-icu' | 'hi-x-icu' | 'id-x-icu' | 'ms-x-icu' | 'fil-x-icu' | 'sw-x-icu' | 'ta-x-icu' | 'te-x-icu' | 'ml-x-icu' | 'bn-x-icu' | 'gu-x-icu' | 'kn-x-icu' | 'mr-x-icu' | 'pa-x-icu' | 'ur-x-icu' | 'or-x-icu' | 'si-x-icu' | 'th-x-icu' | 'lo-x-icu' | 'my-x-icu' | 'ka-x-icu' | 'am-x-icu' | 'ti-x-icu' | 'ne-x-icu' | 'dz-x-icu' | 'kok-x-icu' | 'syr-x-icu' | 'sd-x-icu' | 'bo-x-icu' | 'km-x-icu' | 'mn-x-icu' | 'lo-x-icu' | 'gl-x-icu' | 'eu-x-icu' | 'ca-x-icu' | 'af-x-icu' | 'is-x-icu' | 'mk-x-icu' | 'sq-x-icu' | 'hy-x-icu' | 'mt-x-icu' | 'cy-x-icu' | 'et-x-icu' | 'lv-x-icu' | 'lt-x-icu' | 'tg-x-icu' | 'fa-x-icu' | 'ps-x-icu' | 'ks-x-icu' | 'sd-x'
79
+ | 'cs-x-icu'
80
+ | 'sk-x-icu'
81
+ | 'da-x-icu'
82
+ | 'de-x-icu'
83
+ | 'en-x-icu'
84
+ | 'es-x-icu'
85
+ | 'fr-x-icu'
86
+ | 'it-x-icu'
87
+ | 'ja-x-icu'
88
+ | 'ko-x-icu'
89
+ | 'nl-x-icu'
90
+ | 'pl-x-icu'
91
+ | 'pt-x-icu'
92
+ | 'ru-x-icu'
93
+ | 'sv-x-icu'
94
+ | 'tr-x-icu'
95
+ | 'zh-x-icu'
96
+ | 'hu-x-icu'
97
+ | 'fi-x-icu'
98
+ | 'el-x-icu'
99
+ | 'bg-x-icu'
100
+ | 'hr-x-icu'
101
+ | 'ro-x-icu'
102
+ | 'sl-x-icu'
103
+ | 'sr-x-icu'
104
+ | 'uk-x-icu'
105
+ | 'vi-x-icu'
106
+ | 'th-x-icu'
107
+ | 'ar-x-icu'
108
+ | 'he-x-icu'
109
+ | 'hi-x-icu'
110
+ | 'id-x-icu'
111
+ | 'ms-x-icu'
112
+ | 'fil-x-icu'
113
+ | 'sw-x-icu'
114
+ | 'ta-x-icu'
115
+ | 'te-x-icu'
116
+ | 'ml-x-icu'
117
+ | 'bn-x-icu'
118
+ | 'gu-x-icu'
119
+ | 'kn-x-icu'
120
+ | 'mr-x-icu'
121
+ | 'pa-x-icu'
122
+ | 'ur-x-icu'
123
+ | 'or-x-icu'
124
+ | 'si-x-icu'
125
+ | 'th-x-icu'
126
+ | 'lo-x-icu'
127
+ | 'my-x-icu'
128
+ | 'ka-x-icu'
129
+ | 'am-x-icu'
130
+ | 'ti-x-icu'
131
+ | 'ne-x-icu'
132
+ | 'dz-x-icu'
133
+ | 'kok-x-icu'
134
+ | 'syr-x-icu'
135
+ | 'sd-x-icu'
136
+ | 'bo-x-icu'
137
+ | 'km-x-icu'
138
+ | 'mn-x-icu'
139
+ | 'lo-x-icu'
140
+ | 'gl-x-icu'
141
+ | 'eu-x-icu'
142
+ | 'ca-x-icu'
143
+ | 'af-x-icu'
144
+ | 'is-x-icu'
145
+ | 'mk-x-icu'
146
+ | 'sq-x-icu'
147
+ | 'hy-x-icu'
148
+ | 'mt-x-icu'
149
+ | 'cy-x-icu'
150
+ | 'et-x-icu'
151
+ | 'lv-x-icu'
152
+ | 'lt-x-icu'
153
+ | 'tg-x-icu'
154
+ | 'fa-x-icu'
155
+ | 'ps-x-icu'
156
+ | 'ks-x-icu'
157
+ | 'sd-x'
76
158
  // fallback
77
159
  | string & {}
78
160
 
79
-
80
161
  export enum RelationType {
81
162
  OneHasOne = 'OneHasOne',
82
163
  OneHasMany = 'OneHasMany',
@@ -99,7 +180,7 @@ export namespace Model {
99
180
 
100
181
  export type AnyRelation = AnyInverseRelation | AnyOwningRelation
101
182
 
102
- export type Relation<T extends RelationType = RelationType>=
183
+ export type Relation<T extends RelationType = RelationType> =
103
184
  & Field<T>
104
185
  & {
105
186
  readonly name: string
@@ -230,16 +311,19 @@ export namespace Model {
230
311
  readonly fields: readonly string[]
231
312
  readonly index: true
232
313
  readonly nulls?: NullsDistinctBehaviour // empty means distinct
314
+ readonly method?: IndexMethod
233
315
  }
234
316
 
235
317
  export type Indexes = readonly Index[]
236
318
 
319
+ export type IndexMethod = 'btree' | 'gin' | 'gist' | 'hash' | 'brin' | 'spgist'
320
+
237
321
  export type Index = {
238
322
  readonly fields: readonly string[]
239
323
  readonly name?: string
324
+ readonly method?: IndexMethod
240
325
  }
241
326
 
242
-
243
327
  export interface ColumnContext {
244
328
  entity: Model.Entity
245
329
  column: Model.AnyColumn
@@ -311,7 +395,6 @@ export namespace Model {
311
395
  targetRelation: Model.OneHasOneInverseRelation | null
312
396
  }
313
397
 
314
-
315
398
  export interface ColumnVisitor<T> {
316
399
  visitColumn(context: ColumnContext): T
317
400
  }
@@ -31,8 +31,8 @@ export namespace Validation {
31
31
  readonly range: readonly [LiteralArgument<number | null>, LiteralArgument<number | null>]
32
32
  readonly equals: readonly [LiteralArgument<JSONValue>]
33
33
  readonly not: readonly [ValidatorArgument]
34
- readonly empty: readonly[]
35
- readonly defined: readonly[]
34
+ readonly empty: readonly []
35
+ readonly defined: readonly []
36
36
  readonly inContext: readonly [PathArgument, ValidatorArgument]
37
37
  readonly every: readonly [ValidatorArgument]
38
38
  readonly any: readonly [ValidatorArgument]