@contember/client-content-generator 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 (38) hide show
  1. package/dist/development/generate.cjs.map +1 -1
  2. package/dist/development/generate.js.map +1 -1
  3. package/dist/development/src/ContemberClientGenerator.cjs +7 -2
  4. package/dist/development/src/ContemberClientGenerator.cjs.map +1 -1
  5. package/dist/development/src/ContemberClientGenerator.js +7 -2
  6. package/dist/development/src/ContemberClientGenerator.js.map +1 -1
  7. package/dist/development/src/EntityTypeSchemaGenerator.cjs.map +1 -1
  8. package/dist/development/src/EntityTypeSchemaGenerator.js.map +1 -1
  9. package/dist/development/src/EnumTypeSchemaGenerator.cjs.map +1 -1
  10. package/dist/development/src/EnumTypeSchemaGenerator.js.map +1 -1
  11. package/dist/development/src/NameSchemaGenerator.cjs.map +1 -1
  12. package/dist/development/src/NameSchemaGenerator.js.map +1 -1
  13. package/dist/production/generate.cjs.map +1 -1
  14. package/dist/production/generate.js.map +1 -1
  15. package/dist/production/src/ContemberClientGenerator.cjs +7 -2
  16. package/dist/production/src/ContemberClientGenerator.cjs.map +1 -1
  17. package/dist/production/src/ContemberClientGenerator.js +7 -2
  18. package/dist/production/src/ContemberClientGenerator.js.map +1 -1
  19. package/dist/production/src/EntityTypeSchemaGenerator.cjs.map +1 -1
  20. package/dist/production/src/EntityTypeSchemaGenerator.js.map +1 -1
  21. package/dist/production/src/EnumTypeSchemaGenerator.cjs.map +1 -1
  22. package/dist/production/src/EnumTypeSchemaGenerator.js.map +1 -1
  23. package/dist/production/src/NameSchemaGenerator.cjs.map +1 -1
  24. package/dist/production/src/NameSchemaGenerator.js.map +1 -1
  25. package/dist/types/ContemberClientGenerator.d.ts.map +1 -1
  26. package/dist/types/EntityTypeSchemaGenerator.d.ts.map +1 -1
  27. package/dist/types/NameSchemaGenerator.d.ts.map +1 -1
  28. package/dist/types/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +7 -7
  30. package/src/ContemberClientGenerator.ts +11 -3
  31. package/src/EntityTypeSchemaGenerator.ts +6 -8
  32. package/src/NameSchemaGenerator.ts +1 -3
  33. package/src/generate.ts +3 -5
  34. package/tests/__snapshots__/generateEnittyTypes.test.ts.snap +161 -161
  35. package/tests/__snapshots__/generateEnumTypes.test.ts.snap +8 -8
  36. package/tests/generateEnittyTypes.test.ts +0 -9
  37. package/tests/generateEnumTypes.test.ts +0 -1
  38. package/tests/schemas.ts +1 -3
@@ -1,4 +1,4 @@
1
- // Bun Snapshot v1, https://goo.gl/fbAQLP
1
+ // Bun Snapshot v1, https://bun.sh/docs/test/snapshots
2
2
 
3
3
  exports[`generate entities generate for scalars 1`] = `
4
4
  "
@@ -8,34 +8,34 @@ export type JSONObject = { readonly [K in string]?: JSONValue }
8
8
  export type JSONArray = readonly JSONValue[]
9
9
 
10
10
  export type Foo <OverRelation extends string | never = never> = {
11
- \tname: 'Foo'
12
- \tunique:
13
- \t\t| Omit<{ id: string}, OverRelation>
14
- \tcolumns: {
15
- \t\tid: string
16
- \t\tstringCol: string | null
17
- \t\tintCol: number | null
18
- \t\tdoubleCol: number | null
19
- \t\tdateCol: string | null
20
- \t\tdatetimeCol: string | null
21
- \t\tbooleanCol: boolean | null
22
- \t\tjsonCol: JSONValue | null
23
- \t\tuuidCol: string | null
24
- \t}
25
- \thasOne: {
26
- \t}
27
- \thasMany: {
28
- \t}
29
- \thasManyBy: {
30
- \t}
11
+ name: 'Foo'
12
+ unique:
13
+ | Omit<{ id: string}, OverRelation>
14
+ columns: {
15
+ id: string
16
+ stringCol: string | null
17
+ intCol: number | null
18
+ doubleCol: number | null
19
+ dateCol: string | null
20
+ datetimeCol: string | null
21
+ booleanCol: boolean | null
22
+ jsonCol: JSONValue | null
23
+ uuidCol: string | null
24
+ }
25
+ hasOne: {
26
+ }
27
+ hasMany: {
28
+ }
29
+ hasManyBy: {
30
+ }
31
31
  }
32
32
 
33
33
  export type ContemberClientEntities = {
34
- \tFoo: Foo
34
+ Foo: Foo
35
35
  }
36
36
 
37
37
  export type ContemberClientSchema = {
38
- \tentities: ContemberClientEntities
38
+ entities: ContemberClientEntities
39
39
  }
40
40
  "
41
41
  `;
@@ -49,27 +49,27 @@ export type JSONObject = { readonly [K in string]?: JSONValue }
49
49
  export type JSONArray = readonly JSONValue[]
50
50
 
51
51
  export type Foo <OverRelation extends string | never = never> = {
52
- \tname: 'Foo'
53
- \tunique:
54
- \t\t| Omit<{ id: string}, OverRelation>
55
- \tcolumns: {
56
- \t\tid: string
57
- \t\tenumCol: FooEnumCol | null
58
- \t}
59
- \thasOne: {
60
- \t}
61
- \thasMany: {
62
- \t}
63
- \thasManyBy: {
64
- \t}
52
+ name: 'Foo'
53
+ unique:
54
+ | Omit<{ id: string}, OverRelation>
55
+ columns: {
56
+ id: string
57
+ enumCol: FooEnumCol | null
58
+ }
59
+ hasOne: {
60
+ }
61
+ hasMany: {
62
+ }
63
+ hasManyBy: {
64
+ }
65
65
  }
66
66
 
67
67
  export type ContemberClientEntities = {
68
- \tFoo: Foo
68
+ Foo: Foo
69
69
  }
70
70
 
71
71
  export type ContemberClientSchema = {
72
- \tentities: ContemberClientEntities
72
+ entities: ContemberClientEntities
73
73
  }
74
74
  "
75
75
  `;
@@ -82,45 +82,45 @@ export type JSONObject = { readonly [K in string]?: JSONValue }
82
82
  export type JSONArray = readonly JSONValue[]
83
83
 
84
84
  export type Foo <OverRelation extends string | never = never> = {
85
- \tname: 'Foo'
86
- \tunique:
87
- \t\t| Omit<{ id: string}, OverRelation>
88
- \t\t| Omit<{ oneHasOneInverseRel: Bar['unique']}, OverRelation>
89
- \tcolumns: {
90
- \t\tid: string
91
- \t}
92
- \thasOne: {
93
- \t\toneHasOneInverseRel: Bar
94
- \t}
95
- \thasMany: {
96
- \t}
97
- \thasManyBy: {
98
- \t}
85
+ name: 'Foo'
86
+ unique:
87
+ | Omit<{ id: string}, OverRelation>
88
+ | Omit<{ oneHasOneInverseRel: Bar['unique']}, OverRelation>
89
+ columns: {
90
+ id: string
91
+ }
92
+ hasOne: {
93
+ oneHasOneInverseRel: Bar
94
+ }
95
+ hasMany: {
96
+ }
97
+ hasManyBy: {
98
+ }
99
99
  }
100
100
  export type Bar <OverRelation extends string | never = never> = {
101
- \tname: 'Bar'
102
- \tunique:
103
- \t\t| Omit<{ id: string}, OverRelation>
104
- \t\t| Omit<{ oneHasOneOwningRel: Foo['unique']}, OverRelation>
105
- \tcolumns: {
106
- \t\tid: string
107
- \t}
108
- \thasOne: {
109
- \t\toneHasOneOwningRel: Foo
110
- \t}
111
- \thasMany: {
112
- \t}
113
- \thasManyBy: {
114
- \t}
101
+ name: 'Bar'
102
+ unique:
103
+ | Omit<{ id: string}, OverRelation>
104
+ | Omit<{ oneHasOneOwningRel: Foo['unique']}, OverRelation>
105
+ columns: {
106
+ id: string
107
+ }
108
+ hasOne: {
109
+ oneHasOneOwningRel: Foo
110
+ }
111
+ hasMany: {
112
+ }
113
+ hasManyBy: {
114
+ }
115
115
  }
116
116
 
117
117
  export type ContemberClientEntities = {
118
- \tFoo: Foo
119
- \tBar: Bar
118
+ Foo: Foo
119
+ Bar: Bar
120
120
  }
121
121
 
122
122
  export type ContemberClientSchema = {
123
- \tentities: ContemberClientEntities
123
+ entities: ContemberClientEntities
124
124
  }
125
125
  "
126
126
  `;
@@ -133,44 +133,44 @@ export type JSONObject = { readonly [K in string]?: JSONValue }
133
133
  export type JSONArray = readonly JSONValue[]
134
134
 
135
135
  export type Foo <OverRelation extends string | never = never> = {
136
- \tname: 'Foo'
137
- \tunique:
138
- \t\t| Omit<{ id: string}, OverRelation>
139
- \t\t| Omit<{ oneHasManyRel: Bar['unique']}, OverRelation>
140
- \tcolumns: {
141
- \t\tid: string
142
- \t}
143
- \thasOne: {
144
- \t}
145
- \thasMany: {
146
- \t\toneHasManyRel: Bar<'manyHasOneRel'>
147
- \t}
148
- \thasManyBy: {
149
- \t}
136
+ name: 'Foo'
137
+ unique:
138
+ | Omit<{ id: string}, OverRelation>
139
+ | Omit<{ oneHasManyRel: Bar['unique']}, OverRelation>
140
+ columns: {
141
+ id: string
142
+ }
143
+ hasOne: {
144
+ }
145
+ hasMany: {
146
+ oneHasManyRel: Bar<'manyHasOneRel'>
147
+ }
148
+ hasManyBy: {
149
+ }
150
150
  }
151
151
  export type Bar <OverRelation extends string | never = never> = {
152
- \tname: 'Bar'
153
- \tunique:
154
- \t\t| Omit<{ id: string}, OverRelation>
155
- \tcolumns: {
156
- \t\tid: string
157
- \t}
158
- \thasOne: {
159
- \t\tmanyHasOneRel: Foo
160
- \t}
161
- \thasMany: {
162
- \t}
163
- \thasManyBy: {
164
- \t}
152
+ name: 'Bar'
153
+ unique:
154
+ | Omit<{ id: string}, OverRelation>
155
+ columns: {
156
+ id: string
157
+ }
158
+ hasOne: {
159
+ manyHasOneRel: Foo
160
+ }
161
+ hasMany: {
162
+ }
163
+ hasManyBy: {
164
+ }
165
165
  }
166
166
 
167
167
  export type ContemberClientEntities = {
168
- \tFoo: Foo
169
- \tBar: Bar
168
+ Foo: Foo
169
+ Bar: Bar
170
170
  }
171
171
 
172
172
  export type ContemberClientSchema = {
173
- \tentities: ContemberClientEntities
173
+ entities: ContemberClientEntities
174
174
  }
175
175
  "
176
176
  `;
@@ -183,43 +183,43 @@ export type JSONObject = { readonly [K in string]?: JSONValue }
183
183
  export type JSONArray = readonly JSONValue[]
184
184
 
185
185
  export type Foo <OverRelation extends string | never = never> = {
186
- \tname: 'Foo'
187
- \tunique:
188
- \t\t| Omit<{ id: string}, OverRelation>
189
- \tcolumns: {
190
- \t\tid: string
191
- \t}
192
- \thasOne: {
193
- \t}
194
- \thasMany: {
195
- \t\tmanyHasManyRel: Bar
196
- \t}
197
- \thasManyBy: {
198
- \t}
186
+ name: 'Foo'
187
+ unique:
188
+ | Omit<{ id: string}, OverRelation>
189
+ columns: {
190
+ id: string
191
+ }
192
+ hasOne: {
193
+ }
194
+ hasMany: {
195
+ manyHasManyRel: Bar
196
+ }
197
+ hasManyBy: {
198
+ }
199
199
  }
200
200
  export type Bar <OverRelation extends string | never = never> = {
201
- \tname: 'Bar'
202
- \tunique:
203
- \t\t| Omit<{ id: string}, OverRelation>
204
- \tcolumns: {
205
- \t\tid: string
206
- \t}
207
- \thasOne: {
208
- \t}
209
- \thasMany: {
210
- \t\tmanyHasManyInverseRel: Foo
211
- \t}
212
- \thasManyBy: {
213
- \t}
201
+ name: 'Bar'
202
+ unique:
203
+ | Omit<{ id: string}, OverRelation>
204
+ columns: {
205
+ id: string
206
+ }
207
+ hasOne: {
208
+ }
209
+ hasMany: {
210
+ manyHasManyInverseRel: Foo
211
+ }
212
+ hasManyBy: {
213
+ }
214
214
  }
215
215
 
216
216
  export type ContemberClientEntities = {
217
- \tFoo: Foo
218
- \tBar: Bar
217
+ Foo: Foo
218
+ Bar: Bar
219
219
  }
220
220
 
221
221
  export type ContemberClientSchema = {
222
- \tentities: ContemberClientEntities
222
+ entities: ContemberClientEntities
223
223
  }
224
224
  "
225
225
  `;
@@ -232,47 +232,47 @@ export type JSONObject = { readonly [K in string]?: JSONValue }
232
232
  export type JSONArray = readonly JSONValue[]
233
233
 
234
234
  export type Foo <OverRelation extends string | never = never> = {
235
- \tname: 'Foo'
236
- \tunique:
237
- \t\t| Omit<{ id: string}, OverRelation>
238
- \t\t| Omit<{ locales: FooLocale['unique']}, OverRelation>
239
- \tcolumns: {
240
- \t\tid: string
241
- \t}
242
- \thasOne: {
243
- \t}
244
- \thasMany: {
245
- \t\tlocales: FooLocale<'foo'>
246
- \t}
247
- \thasManyBy: {
248
- \t\tlocalesByLocale: { entity: FooLocale; by: {locale: string} }
249
- \t}
235
+ name: 'Foo'
236
+ unique:
237
+ | Omit<{ id: string}, OverRelation>
238
+ | Omit<{ locales: FooLocale['unique']}, OverRelation>
239
+ columns: {
240
+ id: string
241
+ }
242
+ hasOne: {
243
+ }
244
+ hasMany: {
245
+ locales: FooLocale<'foo'>
246
+ }
247
+ hasManyBy: {
248
+ localesByLocale: { entity: FooLocale; by: {locale: string} }
249
+ }
250
250
  }
251
251
  export type FooLocale <OverRelation extends string | never = never> = {
252
- \tname: 'FooLocale'
253
- \tunique:
254
- \t\t| Omit<{ id: string}, OverRelation>
255
- \t\t| Omit<{ locale: string, foo: Foo['unique']}, OverRelation>
256
- \tcolumns: {
257
- \t\tid: string
258
- \t\tlocale: string
259
- \t}
260
- \thasOne: {
261
- \t\tfoo: Foo
262
- \t}
263
- \thasMany: {
264
- \t}
265
- \thasManyBy: {
266
- \t}
252
+ name: 'FooLocale'
253
+ unique:
254
+ | Omit<{ id: string}, OverRelation>
255
+ | Omit<{ locale: string, foo: Foo['unique']}, OverRelation>
256
+ columns: {
257
+ id: string
258
+ locale: string
259
+ }
260
+ hasOne: {
261
+ foo: Foo
262
+ }
263
+ hasMany: {
264
+ }
265
+ hasManyBy: {
266
+ }
267
267
  }
268
268
 
269
269
  export type ContemberClientEntities = {
270
- \tFoo: Foo
271
- \tFooLocale: FooLocale
270
+ Foo: Foo
271
+ FooLocale: FooLocale
272
272
  }
273
273
 
274
274
  export type ContemberClientSchema = {
275
- \tentities: ContemberClientEntities
275
+ entities: ContemberClientEntities
276
276
  }
277
277
  "
278
278
  `;
@@ -1,16 +1,16 @@
1
- // Bun Snapshot v1, https://goo.gl/fbAQLP
1
+ // Bun Snapshot v1, https://bun.sh/docs/test/snapshots
2
2
 
3
3
  exports[`generate enums 1`] = `
4
4
  "export type OrderStatus =
5
- \t | "new"
6
- \t | "paid"
7
- \t | "cancelled"
5
+ | "new"
6
+ | "paid"
7
+ | "cancelled"
8
8
  export type OrderType =
9
- \t | "normal"
10
- \t | "express"
9
+ | "normal"
10
+ | "express"
11
11
  export type ContemberClientEnums = {
12
- \tOrderStatus: OrderStatus
13
- \torderType: OrderType
12
+ OrderStatus: OrderStatus
13
+ orderType: OrderType
14
14
  }
15
15
 
16
16
  "
@@ -2,37 +2,28 @@ import { describe, expect, test } from 'bun:test'
2
2
  import { EntityTypeSchemaGenerator } from '../src'
3
3
  import { schemas } from './schemas'
4
4
 
5
-
6
5
  describe('generate entities', () => {
7
-
8
6
  const entityGenerator = new EntityTypeSchemaGenerator()
9
7
  test('generate for scalars', () => {
10
-
11
8
  expect(entityGenerator.generate(schemas.scalarsSchema.model)).toMatchSnapshot()
12
9
  })
13
10
 
14
11
  test('generate for has enum', () => {
15
-
16
12
  expect(entityGenerator.generate(schemas.enumSchema.model)).toMatchSnapshot()
17
13
  })
18
14
  test('generate one has one', () => {
19
-
20
15
  expect(entityGenerator.generate(schemas.oneHasOneSchema.model)).toMatchSnapshot()
21
16
  })
22
17
 
23
18
  test('generate one has many', () => {
24
-
25
19
  expect(entityGenerator.generate(schemas.oneHasManySchema.model)).toMatchSnapshot()
26
20
  })
27
21
 
28
22
  test('generate many has many', () => {
29
-
30
23
  expect(entityGenerator.generate(schemas.manyHasManySchema.model)).toMatchSnapshot()
31
24
  })
32
25
 
33
26
  test('generate reduced has by', () => {
34
-
35
27
  expect(entityGenerator.generate(schemas.reducedHasManySchema.model)).toMatchSnapshot()
36
28
  })
37
-
38
29
  })
@@ -1,7 +1,6 @@
1
1
  import { describe, expect, test } from 'bun:test'
2
2
  import { EnumTypeSchemaGenerator } from '../src'
3
3
 
4
-
5
4
  test('generate enums', () => {
6
5
  const enumGenerator = new EnumTypeSchemaGenerator()
7
6
  expect(enumGenerator.generate({
package/tests/schemas.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SchemaDefinition as def, createSchema } from '@contember/schema-definition'
1
+ import { createSchema, SchemaDefinition as def } from '@contember/schema-definition'
2
2
 
3
3
  namespace ManyScalarsSchema {
4
4
  export class Foo {
@@ -13,7 +13,6 @@ namespace ManyScalarsSchema {
13
13
  }
14
14
  }
15
15
 
16
-
17
16
  namespace EnumSchema {
18
17
  export class Foo {
19
18
  enumCol = def.enumColumn(def.createEnum('foo', 'bar'))
@@ -40,7 +39,6 @@ namespace OneHasManySchema {
40
39
  }
41
40
  }
42
41
 
43
-
44
42
  namespace ManyHasManySchema {
45
43
  export class Foo {
46
44
  manyHasManyRel = def.manyHasMany(Bar, 'manyHasManyInverseRel')