@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.
- package/dist/development/generate.cjs.map +1 -1
- package/dist/development/generate.js.map +1 -1
- package/dist/development/src/ContemberClientGenerator.cjs +7 -2
- package/dist/development/src/ContemberClientGenerator.cjs.map +1 -1
- package/dist/development/src/ContemberClientGenerator.js +7 -2
- package/dist/development/src/ContemberClientGenerator.js.map +1 -1
- package/dist/development/src/EntityTypeSchemaGenerator.cjs.map +1 -1
- package/dist/development/src/EntityTypeSchemaGenerator.js.map +1 -1
- package/dist/development/src/EnumTypeSchemaGenerator.cjs.map +1 -1
- package/dist/development/src/EnumTypeSchemaGenerator.js.map +1 -1
- package/dist/development/src/NameSchemaGenerator.cjs.map +1 -1
- package/dist/development/src/NameSchemaGenerator.js.map +1 -1
- package/dist/production/generate.cjs.map +1 -1
- package/dist/production/generate.js.map +1 -1
- package/dist/production/src/ContemberClientGenerator.cjs +7 -2
- package/dist/production/src/ContemberClientGenerator.cjs.map +1 -1
- package/dist/production/src/ContemberClientGenerator.js +7 -2
- package/dist/production/src/ContemberClientGenerator.js.map +1 -1
- package/dist/production/src/EntityTypeSchemaGenerator.cjs.map +1 -1
- package/dist/production/src/EntityTypeSchemaGenerator.js.map +1 -1
- package/dist/production/src/EnumTypeSchemaGenerator.cjs.map +1 -1
- package/dist/production/src/EnumTypeSchemaGenerator.js.map +1 -1
- package/dist/production/src/NameSchemaGenerator.cjs.map +1 -1
- package/dist/production/src/NameSchemaGenerator.js.map +1 -1
- package/dist/types/ContemberClientGenerator.d.ts.map +1 -1
- package/dist/types/EntityTypeSchemaGenerator.d.ts.map +1 -1
- package/dist/types/NameSchemaGenerator.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/ContemberClientGenerator.ts +11 -3
- package/src/EntityTypeSchemaGenerator.ts +6 -8
- package/src/NameSchemaGenerator.ts +1 -3
- package/src/generate.ts +3 -5
- package/tests/__snapshots__/generateEnittyTypes.test.ts.snap +161 -161
- package/tests/__snapshots__/generateEnumTypes.test.ts.snap +8 -8
- package/tests/generateEnittyTypes.test.ts +0 -9
- package/tests/generateEnumTypes.test.ts +0 -1
- package/tests/schemas.ts +1 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Bun Snapshot v1, https://
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
34
|
+
Foo: Foo
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export type ContemberClientSchema = {
|
|
38
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
68
|
+
Foo: Foo
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export type ContemberClientSchema = {
|
|
72
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
119
|
-
|
|
118
|
+
Foo: Foo
|
|
119
|
+
Bar: Bar
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
export type ContemberClientSchema = {
|
|
123
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
169
|
-
|
|
168
|
+
Foo: Foo
|
|
169
|
+
Bar: Bar
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
export type ContemberClientSchema = {
|
|
173
|
-
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
218
|
-
|
|
217
|
+
Foo: Foo
|
|
218
|
+
Bar: Bar
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
export type ContemberClientSchema = {
|
|
222
|
-
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
271
|
-
|
|
270
|
+
Foo: Foo
|
|
271
|
+
FooLocale: FooLocale
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
export type ContemberClientSchema = {
|
|
275
|
-
|
|
275
|
+
entities: ContemberClientEntities
|
|
276
276
|
}
|
|
277
277
|
"
|
|
278
278
|
`;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// Bun Snapshot v1, https://
|
|
1
|
+
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
2
|
|
|
3
3
|
exports[`generate enums 1`] = `
|
|
4
4
|
"export type OrderStatus =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
| "new"
|
|
6
|
+
| "paid"
|
|
7
|
+
| "cancelled"
|
|
8
8
|
export type OrderType =
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
| "normal"
|
|
10
|
+
| "express"
|
|
11
11
|
export type ContemberClientEnums = {
|
|
12
|
-
|
|
13
|
-
|
|
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
|
})
|
package/tests/schemas.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SchemaDefinition as def
|
|
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')
|