@contember/client-content-generator 2.0.0-alpha.32 → 2.0.0-alpha.36

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 (26) 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.map +1 -1
  4. package/dist/development/src/ContemberClientGenerator.js.map +1 -1
  5. package/dist/development/src/EntityTypeSchemaGenerator.cjs.map +1 -1
  6. package/dist/development/src/EntityTypeSchemaGenerator.js.map +1 -1
  7. package/dist/development/src/EnumTypeSchemaGenerator.cjs.map +1 -1
  8. package/dist/development/src/EnumTypeSchemaGenerator.js.map +1 -1
  9. package/dist/development/src/NameSchemaGenerator.cjs.map +1 -1
  10. package/dist/development/src/NameSchemaGenerator.js.map +1 -1
  11. package/dist/production/generate.cjs.map +1 -1
  12. package/dist/production/generate.js.map +1 -1
  13. package/dist/production/src/ContemberClientGenerator.cjs.map +1 -1
  14. package/dist/production/src/ContemberClientGenerator.js.map +1 -1
  15. package/dist/production/src/EntityTypeSchemaGenerator.cjs.map +1 -1
  16. package/dist/production/src/EntityTypeSchemaGenerator.js.map +1 -1
  17. package/dist/production/src/EnumTypeSchemaGenerator.cjs.map +1 -1
  18. package/dist/production/src/EnumTypeSchemaGenerator.js.map +1 -1
  19. package/dist/production/src/NameSchemaGenerator.cjs.map +1 -1
  20. package/dist/production/src/NameSchemaGenerator.js.map +1 -1
  21. package/dist/types/tsconfig.tsbuildinfo +1 -1
  22. package/package.json +6 -6
  23. package/tests/__snapshots__/generateEnittyTypes.test.ts.snap +278 -0
  24. package/tests/__snapshots__/generateEnumTypes.test.ts.snap +17 -0
  25. package/tests/generateEnittyTypes.test.ts +7 -272
  26. package/tests/generateEnumTypes.test.ts +2 -16
@@ -1,4 +1,4 @@
1
- import { describe, expect, test } from 'vitest'
1
+ import { describe, expect, test } from 'bun:test'
2
2
  import { EntityTypeSchemaGenerator } from '../src'
3
3
  import { schemas } from './schemas'
4
4
 
@@ -8,296 +8,31 @@ describe('generate entities', () => {
8
8
  const entityGenerator = new EntityTypeSchemaGenerator()
9
9
  test('generate for scalars', () => {
10
10
 
11
- expect(entityGenerator.generate(schemas.scalarsSchema.model)).toMatchInlineSnapshot(`
12
- "
13
- export type JSONPrimitive = string | number | boolean | null
14
- export type JSONValue = JSONPrimitive | JSONObject | JSONArray
15
- export type JSONObject = { readonly [K in string]?: JSONValue }
16
- export type JSONArray = readonly JSONValue[]
17
-
18
- export type Foo <OverRelation extends string | never = never> = {
19
- name: 'Foo'
20
- unique:
21
- | Omit<{ id: string}, OverRelation>
22
- columns: {
23
- id: string
24
- stringCol: string | null
25
- intCol: number | null
26
- doubleCol: number | null
27
- dateCol: string | null
28
- datetimeCol: string | null
29
- booleanCol: boolean | null
30
- jsonCol: JSONValue | null
31
- uuidCol: string | null
32
- }
33
- hasOne: {
34
- }
35
- hasMany: {
36
- }
37
- hasManyBy: {
38
- }
39
- }
40
-
41
- export type ContemberClientEntities = {
42
- Foo: Foo
43
- }
44
-
45
- export type ContemberClientSchema = {
46
- entities: ContemberClientEntities
47
- }
48
- "
49
- `)
11
+ expect(entityGenerator.generate(schemas.scalarsSchema.model)).toMatchSnapshot()
50
12
  })
51
13
 
52
14
  test('generate for has enum', () => {
53
15
 
54
- expect(entityGenerator.generate(schemas.enumSchema.model)).toMatchInlineSnapshot(`
55
- "import type { FooEnumCol } from './enums'
56
-
57
- export type JSONPrimitive = string | number | boolean | null
58
- export type JSONValue = JSONPrimitive | JSONObject | JSONArray
59
- export type JSONObject = { readonly [K in string]?: JSONValue }
60
- export type JSONArray = readonly JSONValue[]
61
-
62
- export type Foo <OverRelation extends string | never = never> = {
63
- name: 'Foo'
64
- unique:
65
- | Omit<{ id: string}, OverRelation>
66
- columns: {
67
- id: string
68
- enumCol: FooEnumCol | null
69
- }
70
- hasOne: {
71
- }
72
- hasMany: {
73
- }
74
- hasManyBy: {
75
- }
76
- }
77
-
78
- export type ContemberClientEntities = {
79
- Foo: Foo
80
- }
81
-
82
- export type ContemberClientSchema = {
83
- entities: ContemberClientEntities
84
- }
85
- "
86
- `)
16
+ expect(entityGenerator.generate(schemas.enumSchema.model)).toMatchSnapshot()
87
17
  })
88
18
  test('generate one has one', () => {
89
19
 
90
- expect(entityGenerator.generate(schemas.oneHasOneSchema.model)).toMatchInlineSnapshot(`
91
- "
92
- export type JSONPrimitive = string | number | boolean | null
93
- export type JSONValue = JSONPrimitive | JSONObject | JSONArray
94
- export type JSONObject = { readonly [K in string]?: JSONValue }
95
- export type JSONArray = readonly JSONValue[]
96
-
97
- export type Foo <OverRelation extends string | never = never> = {
98
- name: 'Foo'
99
- unique:
100
- | Omit<{ id: string}, OverRelation>
101
- | Omit<{ oneHasOneInverseRel: Bar['unique']}, OverRelation>
102
- columns: {
103
- id: string
104
- }
105
- hasOne: {
106
- oneHasOneInverseRel: Bar
107
- }
108
- hasMany: {
109
- }
110
- hasManyBy: {
111
- }
112
- }
113
- export type Bar <OverRelation extends string | never = never> = {
114
- name: 'Bar'
115
- unique:
116
- | Omit<{ id: string}, OverRelation>
117
- | Omit<{ oneHasOneOwningRel: Foo['unique']}, OverRelation>
118
- columns: {
119
- id: string
120
- }
121
- hasOne: {
122
- oneHasOneOwningRel: Foo
123
- }
124
- hasMany: {
125
- }
126
- hasManyBy: {
127
- }
128
- }
129
-
130
- export type ContemberClientEntities = {
131
- Foo: Foo
132
- Bar: Bar
133
- }
134
-
135
- export type ContemberClientSchema = {
136
- entities: ContemberClientEntities
137
- }
138
- "
139
- `)
20
+ expect(entityGenerator.generate(schemas.oneHasOneSchema.model)).toMatchSnapshot()
140
21
  })
141
22
 
142
23
  test('generate one has many', () => {
143
24
 
144
- expect(entityGenerator.generate(schemas.oneHasManySchema.model)).toMatchInlineSnapshot(`
145
- "
146
- export type JSONPrimitive = string | number | boolean | null
147
- export type JSONValue = JSONPrimitive | JSONObject | JSONArray
148
- export type JSONObject = { readonly [K in string]?: JSONValue }
149
- export type JSONArray = readonly JSONValue[]
150
-
151
- export type Foo <OverRelation extends string | never = never> = {
152
- name: 'Foo'
153
- unique:
154
- | Omit<{ id: string}, OverRelation>
155
- | Omit<{ oneHasManyRel: Bar['unique']}, OverRelation>
156
- columns: {
157
- id: string
158
- }
159
- hasOne: {
160
- }
161
- hasMany: {
162
- oneHasManyRel: Bar<'manyHasOneRel'>
163
- }
164
- hasManyBy: {
165
- }
166
- }
167
- export type Bar <OverRelation extends string | never = never> = {
168
- name: 'Bar'
169
- unique:
170
- | Omit<{ id: string}, OverRelation>
171
- columns: {
172
- id: string
173
- }
174
- hasOne: {
175
- manyHasOneRel: Foo
176
- }
177
- hasMany: {
178
- }
179
- hasManyBy: {
180
- }
181
- }
182
-
183
- export type ContemberClientEntities = {
184
- Foo: Foo
185
- Bar: Bar
186
- }
187
-
188
- export type ContemberClientSchema = {
189
- entities: ContemberClientEntities
190
- }
191
- "
192
- `)
25
+ expect(entityGenerator.generate(schemas.oneHasManySchema.model)).toMatchSnapshot()
193
26
  })
194
27
 
195
28
  test('generate many has many', () => {
196
29
 
197
- expect(entityGenerator.generate(schemas.manyHasManySchema.model)).toMatchInlineSnapshot(`
198
- "
199
- export type JSONPrimitive = string | number | boolean | null
200
- export type JSONValue = JSONPrimitive | JSONObject | JSONArray
201
- export type JSONObject = { readonly [K in string]?: JSONValue }
202
- export type JSONArray = readonly JSONValue[]
203
-
204
- export type Foo <OverRelation extends string | never = never> = {
205
- name: 'Foo'
206
- unique:
207
- | Omit<{ id: string}, OverRelation>
208
- columns: {
209
- id: string
210
- }
211
- hasOne: {
212
- }
213
- hasMany: {
214
- manyHasManyRel: Bar
215
- }
216
- hasManyBy: {
217
- }
218
- }
219
- export type Bar <OverRelation extends string | never = never> = {
220
- name: 'Bar'
221
- unique:
222
- | Omit<{ id: string}, OverRelation>
223
- columns: {
224
- id: string
225
- }
226
- hasOne: {
227
- }
228
- hasMany: {
229
- manyHasManyInverseRel: Foo
230
- }
231
- hasManyBy: {
232
- }
233
- }
234
-
235
- export type ContemberClientEntities = {
236
- Foo: Foo
237
- Bar: Bar
238
- }
239
-
240
- export type ContemberClientSchema = {
241
- entities: ContemberClientEntities
242
- }
243
- "
244
- `)
30
+ expect(entityGenerator.generate(schemas.manyHasManySchema.model)).toMatchSnapshot()
245
31
  })
246
32
 
247
33
  test('generate reduced has by', () => {
248
34
 
249
- expect(entityGenerator.generate(schemas.reducedHasManySchema.model)).toMatchInlineSnapshot(`
250
- "
251
- export type JSONPrimitive = string | number | boolean | null
252
- export type JSONValue = JSONPrimitive | JSONObject | JSONArray
253
- export type JSONObject = { readonly [K in string]?: JSONValue }
254
- export type JSONArray = readonly JSONValue[]
255
-
256
- export type Foo <OverRelation extends string | never = never> = {
257
- name: 'Foo'
258
- unique:
259
- | Omit<{ id: string}, OverRelation>
260
- | Omit<{ locales: FooLocale['unique']}, OverRelation>
261
- columns: {
262
- id: string
263
- }
264
- hasOne: {
265
- }
266
- hasMany: {
267
- locales: FooLocale<'foo'>
268
- }
269
- hasManyBy: {
270
- localesByLocale: { entity: FooLocale; by: {locale: string} }
271
- }
272
- }
273
- export type FooLocale <OverRelation extends string | never = never> = {
274
- name: 'FooLocale'
275
- unique:
276
- | Omit<{ id: string}, OverRelation>
277
- | Omit<{ locale: string, foo: Foo['unique']}, OverRelation>
278
- columns: {
279
- id: string
280
- locale: string
281
- }
282
- hasOne: {
283
- foo: Foo
284
- }
285
- hasMany: {
286
- }
287
- hasManyBy: {
288
- }
289
- }
290
-
291
- export type ContemberClientEntities = {
292
- Foo: Foo
293
- FooLocale: FooLocale
294
- }
295
-
296
- export type ContemberClientSchema = {
297
- entities: ContemberClientEntities
298
- }
299
- "
300
- `)
35
+ expect(entityGenerator.generate(schemas.reducedHasManySchema.model)).toMatchSnapshot()
301
36
  })
302
37
 
303
38
  })
@@ -1,4 +1,4 @@
1
- import { describe, expect, test } from 'vitest'
1
+ import { describe, expect, test } from 'bun:test'
2
2
  import { EnumTypeSchemaGenerator } from '../src'
3
3
 
4
4
 
@@ -10,19 +10,5 @@ test('generate enums', () => {
10
10
  OrderStatus: ['new', 'paid', 'cancelled'],
11
11
  orderType: ['normal', 'express'],
12
12
  },
13
- })).toMatchInlineSnapshot(`
14
- "export type OrderStatus =
15
- | "new"
16
- | "paid"
17
- | "cancelled"
18
- export type OrderType =
19
- | "normal"
20
- | "express"
21
- export type ContemberClientEnums = {
22
- OrderStatus: OrderStatus
23
- orderType: OrderType
24
- }
25
-
26
- "
27
- `)
13
+ })).toMatchSnapshot()
28
14
  })