@postxl/schema 0.0.2
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/LICENSE +50 -0
- package/README.md +320 -0
- package/dist/enum/enum.brands.d.ts +11 -0
- package/dist/enum/enum.brands.js +19 -0
- package/dist/enum/enum.d.ts +49 -0
- package/dist/enum/enum.defaults.d.ts +41 -0
- package/dist/enum/enum.defaults.js +105 -0
- package/dist/enum/enum.js +6 -0
- package/dist/enum/enum.json-decoder.d.ts +61 -0
- package/dist/enum/enum.json-decoder.js +51 -0
- package/dist/enum/enum.transformer.d.ts +12 -0
- package/dist/enum/enum.transformer.js +76 -0
- package/dist/enum/enum.types.d.ts +14 -0
- package/dist/enum/enum.types.js +2 -0
- package/dist/enum/index.d.ts +6 -0
- package/dist/enum/index.js +22 -0
- package/dist/field/defaults.d.ts +12 -0
- package/dist/field/defaults.js +78 -0
- package/dist/field/discriminated-union.d.ts +125 -0
- package/dist/field/discriminated-union.js +207 -0
- package/dist/field/enum.d.ts +65 -0
- package/dist/field/enum.js +111 -0
- package/dist/field/field.d.ts +483 -0
- package/dist/field/field.js +68 -0
- package/dist/field/id.d.ts +152 -0
- package/dist/field/id.js +104 -0
- package/dist/field/index.d.ts +11 -0
- package/dist/field/index.js +27 -0
- package/dist/field/relation.d.ts +88 -0
- package/dist/field/relation.js +138 -0
- package/dist/field/scalar.d.ts +179 -0
- package/dist/field/scalar.js +197 -0
- package/dist/field/shared/brands.d.ts +38 -0
- package/dist/field/shared/brands.js +109 -0
- package/dist/field/shared/decoders.d.ts +17 -0
- package/dist/field/shared/decoders.js +88 -0
- package/dist/field/shared/seed.d.ts +32 -0
- package/dist/field/shared/seed.js +63 -0
- package/dist/field/shared/types.d.ts +73 -0
- package/dist/field/shared/types.js +2 -0
- package/dist/field/shared/utils.d.ts +26 -0
- package/dist/field/shared/utils.js +52 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +25 -0
- package/dist/model/index.d.ts +5 -0
- package/dist/model/index.js +21 -0
- package/dist/model/model.brands.d.ts +7 -0
- package/dist/model/model.brands.js +10 -0
- package/dist/model/model.defaults.d.ts +28 -0
- package/dist/model/model.defaults.js +304 -0
- package/dist/model/model.json-decoder.d.ts +94 -0
- package/dist/model/model.json-decoder.js +107 -0
- package/dist/model/model.transformer.d.ts +93 -0
- package/dist/model/model.transformer.js +183 -0
- package/dist/model/model.types.d.ts +37 -0
- package/dist/model/model.types.js +2 -0
- package/dist/project-schema/project-schema.brands.d.ts +10 -0
- package/dist/project-schema/project-schema.brands.js +17 -0
- package/dist/project-schema/project-schema.defaults.d.ts +16 -0
- package/dist/project-schema/project-schema.defaults.js +53 -0
- package/dist/project-schema/project-schema.json-decoder.d.ts +285 -0
- package/dist/project-schema/project-schema.json-decoder.js +145 -0
- package/dist/project-schema/project-schema.transformer.d.ts +284 -0
- package/dist/project-schema/project-schema.transformer.js +444 -0
- package/dist/project-schema/project-schema.types.d.ts +77 -0
- package/dist/project-schema/project-schema.types.js +2 -0
- package/dist/samples/la.schema.json +2055 -0
- package/dist/samples/mca.schema.json +830 -0
- package/dist/samples/ring.schema.json +879 -0
- package/dist/samples/sample-schemas.d.ts +1896 -0
- package/dist/samples/sample-schemas.js +20 -0
- package/dist/samples/simple.schema.json +250 -0
- package/dist/samples/subex.schema.json +1188 -0
- package/dist/samples/usp-msm.schema.json +2515 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
PostXL Non-Commercial License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 PostXL GmbH
|
|
4
|
+
|
|
5
|
+
NON-COMMERCIAL USE
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to use,
|
|
9
|
+
copy, modify, and distribute the Software for non-commercial purposes only,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
1. The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
2. The Software may not be used for commercial purposes without obtaining a
|
|
16
|
+
commercial license from PostXL GmbH.
|
|
17
|
+
|
|
18
|
+
DEFINITION OF NON-COMMERCIAL USE
|
|
19
|
+
|
|
20
|
+
"Non-commercial use" means personal, educational, research, or evaluation use
|
|
21
|
+
where the primary purpose is not to generate revenue or commercial advantage.
|
|
22
|
+
|
|
23
|
+
Non-commercial use includes:
|
|
24
|
+
|
|
25
|
+
- Personal projects and learning
|
|
26
|
+
- Academic research and education
|
|
27
|
+
- Open source projects that are not commercially monetized
|
|
28
|
+
- Evaluation and testing of the Software
|
|
29
|
+
|
|
30
|
+
COMMERCIAL USE
|
|
31
|
+
|
|
32
|
+
For commercial use of this Software, including but not limited to:
|
|
33
|
+
|
|
34
|
+
- Use in products or services sold or licensed to third parties
|
|
35
|
+
- Use in internal business operations that generate revenue
|
|
36
|
+
- Use by for-profit organizations in production environments
|
|
37
|
+
|
|
38
|
+
You must obtain a commercial license from PostXL GmbH.
|
|
39
|
+
|
|
40
|
+
Contact: licensing@postxl.com
|
|
41
|
+
|
|
42
|
+
DISCLAIMER
|
|
43
|
+
|
|
44
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
45
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
46
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
47
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
48
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
49
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
50
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# PXL Schema
|
|
2
|
+
|
|
3
|
+
A utility package that defines the schema for PXL projects & generators - together with the tooling to read/validate the schema.
|
|
4
|
+
|
|
5
|
+
## Concept
|
|
6
|
+
|
|
7
|
+
A PXL project is defined by a "ProjectSchema" - typically through a JSON file.
|
|
8
|
+
|
|
9
|
+
The project schema contains:
|
|
10
|
+
|
|
11
|
+
- Overall project configuration (e.g. name, description)
|
|
12
|
+
- Definition of database schemas
|
|
13
|
+
- Configuration of generators
|
|
14
|
+
- Definition of models
|
|
15
|
+
- Definition of enums
|
|
16
|
+
|
|
17
|
+
## Fields
|
|
18
|
+
|
|
19
|
+
The project schema currently defines the following field types:
|
|
20
|
+
|
|
21
|
+
- id: the primary key of the model
|
|
22
|
+
- scalar: a scalar value, e.g. string, int, boolean, date
|
|
23
|
+
- discriminated union (see below)
|
|
24
|
+
- relation: a relation to another model
|
|
25
|
+
- enum: an enum value
|
|
26
|
+
|
|
27
|
+
### Discriminated Union
|
|
28
|
+
|
|
29
|
+
A discriminated union represents a a state that can be one of multiple values (differentiated by a discriminator value). E.g in case of a blog post, the author can be either a user or an anonymous user.
|
|
30
|
+
Both types might need an email address - but for the user we want to store the userId and for the anonymous user we want to store the name.
|
|
31
|
+
With this field, we can define the above states as follows:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"name": "AuthorType",
|
|
36
|
+
"type": "DiscriminatedUnion",
|
|
37
|
+
"commonFields": [
|
|
38
|
+
{
|
|
39
|
+
"name": "email",
|
|
40
|
+
"type": "String"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"members": [
|
|
44
|
+
{
|
|
45
|
+
"type": "User",
|
|
46
|
+
"label": "existing user",
|
|
47
|
+
"fields": [
|
|
48
|
+
{
|
|
49
|
+
"name": "userId",
|
|
50
|
+
"type": "User"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"type": "Anonymous",
|
|
56
|
+
"label": "Anonymous user",
|
|
57
|
+
"fields": [
|
|
58
|
+
{
|
|
59
|
+
"name": "name",
|
|
60
|
+
"type": "String"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## API
|
|
69
|
+
|
|
70
|
+
The package exposes the following:
|
|
71
|
+
|
|
72
|
+
- `type ProjectSchema`: The overall project configuration. This includes the models, enums, generators, etc.
|
|
73
|
+
- `type ProjectSchemaJSON`: The JSON format of a `ProjectSchema`
|
|
74
|
+
- `zProjectSchema`: Zod decoder that converts `ProjectSchemaJSON` to a `ProjectSchema`
|
|
75
|
+
|
|
76
|
+
## Under the hood
|
|
77
|
+
|
|
78
|
+
We use (Zod decoders)[https://zod.dev/] and transformers to convert from JSON to the final type and also perform validations.
|
|
79
|
+
|
|
80
|
+
For each element (`Field`, `Model`, `Enum`, `ProjectSchema`), we follow the following steps (and naming conventions):
|
|
81
|
+
|
|
82
|
+
1. Raw JSON decoder
|
|
83
|
+
|
|
84
|
+
- This decoder only performs type checking and provides descriptions for each property.
|
|
85
|
+
- Naming:
|
|
86
|
+
- Decoder: `z<ElementName>JSON`
|
|
87
|
+
- Type: `<ElementName>JSON`
|
|
88
|
+
- File: `<elementName>.json-schema.ts`
|
|
89
|
+
|
|
90
|
+
2. Transform individual elements
|
|
91
|
+
|
|
92
|
+
- This transformation applies default values and branding to strings
|
|
93
|
+
- In case of `FieldJSON`, it also splits it into a discriminated union (Id, Scalar, RelationOrEnum)
|
|
94
|
+
- These transformations only require the decoded element from the previous step and are independent of the other elements.
|
|
95
|
+
\*Importantly, these transformations do not check any consistency with their parent elements.
|
|
96
|
+
- Naming:
|
|
97
|
+
- Type: `<ElementName>Enriched`
|
|
98
|
+
- Transformation: `<elementName>JSONTransformer`
|
|
99
|
+
- File: `<elementName>.transformer.ts`
|
|
100
|
+
|
|
101
|
+
3. Transform entire schema:
|
|
102
|
+
|
|
103
|
+
- Naming:
|
|
104
|
+
- Decoder: `zProjectSchema` (there is only this one decoder which combines all other decoders)
|
|
105
|
+
- Type: `<ElementName>`
|
|
106
|
+
- Transformation: `<elementName>Transformer`, `<elementNames>Transformer`
|
|
107
|
+
- Files: `project-schema.transformer.ts`
|
|
108
|
+
|
|
109
|
+
Additionally, for each element, we provide the following files:
|
|
110
|
+
|
|
111
|
+
- `<elementName>.defaults.ts`: contains the default values for the element. To be used in tests and in the individual transformers
|
|
112
|
+
- `<elementName>.brands.ts`: contains the branded names for the element
|
|
113
|
+
- `<elementName>.test.ts`: contains tests
|
|
114
|
+
|
|
115
|
+
## Example schema
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"name": "PostXL Demo project",
|
|
120
|
+
"slug": "postxl-demo",
|
|
121
|
+
"description": "A demo project for PostXL",
|
|
122
|
+
"version": "0.0.1",
|
|
123
|
+
"generators": {
|
|
124
|
+
"@PXL/core": {},
|
|
125
|
+
"@PXL/Types": {},
|
|
126
|
+
"@PXL/Backend/Data/Prisma": {
|
|
127
|
+
"prisma": {
|
|
128
|
+
"datasource": {
|
|
129
|
+
"name": "db",
|
|
130
|
+
"provider": "postgres",
|
|
131
|
+
"url": "env(\"DATABASE_CONNECTION\")"
|
|
132
|
+
},
|
|
133
|
+
"generator": {
|
|
134
|
+
"name": "client",
|
|
135
|
+
"provider": "prisma-client-js",
|
|
136
|
+
"previewFeatures": ["multiSchema"]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"systemUser": {
|
|
142
|
+
"id": "root",
|
|
143
|
+
"sub": null,
|
|
144
|
+
"email": "admin@postxl.com",
|
|
145
|
+
"name": "Root",
|
|
146
|
+
"profilePictureUrl": "https://postxl.com/images/team/user.png"
|
|
147
|
+
},
|
|
148
|
+
"standardModels": ["File", "Action", "Mutation", "Config"],
|
|
149
|
+
"models": [
|
|
150
|
+
{
|
|
151
|
+
"name": "User",
|
|
152
|
+
"description": "A user of the application.",
|
|
153
|
+
"schema": "PXL",
|
|
154
|
+
"standardFields": ["id", "createdAt", "updatedAt", "name"],
|
|
155
|
+
"fields": [
|
|
156
|
+
{
|
|
157
|
+
"name": "sub",
|
|
158
|
+
"type": "String?",
|
|
159
|
+
"isUnique": true,
|
|
160
|
+
"hasIndex": true,
|
|
161
|
+
"description": "The OpenID Connect provided subject identifier."
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "email",
|
|
165
|
+
"type": "String",
|
|
166
|
+
// validation: [
|
|
167
|
+
// {
|
|
168
|
+
// type: 'email',
|
|
169
|
+
// message: 'The email is not valid.',
|
|
170
|
+
// },
|
|
171
|
+
// ],
|
|
172
|
+
"description": "The email of the user."
|
|
173
|
+
// generation: 'faker("internet.email")',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "profilePictureUrl",
|
|
177
|
+
"type": "String?",
|
|
178
|
+
"description": "The URL of the profile picture of the user."
|
|
179
|
+
// generation: 'faker("internet.avatar")',
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"seed": [
|
|
183
|
+
{
|
|
184
|
+
"id": "System",
|
|
185
|
+
"name": "System",
|
|
186
|
+
"email": "admin@postxl.com",
|
|
187
|
+
"profilePictureUrl": "https://postxl.com/images/team/user.png"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"id": "User 1",
|
|
191
|
+
"name": "John Doe",
|
|
192
|
+
"email": "john.doe@company.com",
|
|
193
|
+
"profilePictureUrl": "https://postxl.com/images/team/user.png"
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"name": "Country",
|
|
199
|
+
"description": "A lookup table, demonstrating the use of a @@IsDefault. See description of `isDefault` field for details.",
|
|
200
|
+
"standardFields": ["id", "createdAt", "updatedAt"],
|
|
201
|
+
"labelField": "name",
|
|
202
|
+
"fields": [
|
|
203
|
+
{
|
|
204
|
+
"name": "countryCode",
|
|
205
|
+
"type": "String",
|
|
206
|
+
"description": "The country's ISO 3166-1 alpha-2 code.",
|
|
207
|
+
"isUnique": true
|
|
208
|
+
// generation: 'faker("address.countryCode")',
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "name",
|
|
212
|
+
"type": "String",
|
|
213
|
+
"description": "The name of the country.",
|
|
214
|
+
"isUnique": true
|
|
215
|
+
// generation: 'faker("address.country")',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"name": "isDefault",
|
|
219
|
+
"type": "Boolean?",
|
|
220
|
+
"description": "Tells that the country is the default country."
|
|
221
|
+
}
|
|
222
|
+
],
|
|
223
|
+
"defaultField": "isDefault",
|
|
224
|
+
"examples": [
|
|
225
|
+
{
|
|
226
|
+
"id": "Global",
|
|
227
|
+
"countryCode": "GLOBAL",
|
|
228
|
+
"name": "Global",
|
|
229
|
+
"isDefault": true
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"id": "US",
|
|
233
|
+
"countryCode": "US",
|
|
234
|
+
"name": "United States"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"id": "DE",
|
|
238
|
+
"countryCode": "DE",
|
|
239
|
+
"name": "Germany"
|
|
240
|
+
}
|
|
241
|
+
]
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"name": "Post",
|
|
245
|
+
"description": "A blog post entry.",
|
|
246
|
+
// fakerSeed: '12345',
|
|
247
|
+
"fields": [
|
|
248
|
+
{
|
|
249
|
+
"name": "body",
|
|
250
|
+
"type": "String",
|
|
251
|
+
"description": "The post that you should see after reading this one."
|
|
252
|
+
// generation: 'faker("lorem.paragraph")',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"name": "authorId",
|
|
256
|
+
"type": "User",
|
|
257
|
+
"description": "The user that authored the post.",
|
|
258
|
+
"prismaRelationFieldName": "author"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"name": "nextPostId",
|
|
262
|
+
"type": "Post?",
|
|
263
|
+
"description": "The next post that you should see after reading this one.",
|
|
264
|
+
"prismaRelationFieldName": "nextPost"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"name": "publicationId",
|
|
268
|
+
"type": "Publication?",
|
|
269
|
+
"description": "Posts are bundled in publications.",
|
|
270
|
+
"prismaRelationFieldName": "posts"
|
|
271
|
+
// cloningStrategy: 'withParent',
|
|
272
|
+
}
|
|
273
|
+
],
|
|
274
|
+
"examples": [
|
|
275
|
+
{
|
|
276
|
+
"id": "Post 1",
|
|
277
|
+
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus.",
|
|
278
|
+
"authorId": "User 1",
|
|
279
|
+
"nextPostId": "Post 2",
|
|
280
|
+
"publicationId": "Publication 1"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"id": "Post 2",
|
|
284
|
+
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
|
|
285
|
+
"authorId": "User 1",
|
|
286
|
+
"publicationId": "Publication 1"
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"name": "Publication",
|
|
292
|
+
"description": "A collection of posts.",
|
|
293
|
+
"fields": [
|
|
294
|
+
{
|
|
295
|
+
"name": "featuredPostId",
|
|
296
|
+
"type": "Post?",
|
|
297
|
+
"description": "The post that is featured in the publication.",
|
|
298
|
+
"prismaRelationFieldName": "featuredPost"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
"name": "mostLikedPostId",
|
|
302
|
+
"type": "Post?",
|
|
303
|
+
"description": "The post that is most liked in the publication.",
|
|
304
|
+
"prismaRelationFieldName": "mostLikedPost"
|
|
305
|
+
}
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Next steps
|
|
313
|
+
|
|
314
|
+
- Extend validations:
|
|
315
|
+
- Validate seed, example and systemUser structure
|
|
316
|
+
- Verify/extend Prisma relations:
|
|
317
|
+
Currently, we only store the `databaseName` (e.g. "nextPostId") and `prismaRelationFieldName` (e.g. ("nextPost")). However, for full schema generation, we probably also need the back reference (e.g. "previousPosts").
|
|
318
|
+
- Extend schema:
|
|
319
|
+
- Add cloning strategy: withParent
|
|
320
|
+
- Generators config
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const zEnumName: z.ZodBranded<z.ZodEffects<z.ZodString, string, string>, "PXL.EnumName">;
|
|
3
|
+
export type EnumName = z.infer<typeof zEnumName>;
|
|
4
|
+
export declare const toEnumName: (input: string) => string & z.BRAND<"PXL.EnumName">;
|
|
5
|
+
declare const zEnumValue: z.ZodBranded<z.ZodString, "PXL.EnumValue">;
|
|
6
|
+
export type EnumValue = z.infer<typeof zEnumValue>;
|
|
7
|
+
export declare const toEnumValue: (input: string) => string & z.BRAND<"PXL.EnumValue">;
|
|
8
|
+
export declare const zDatabaseEnumName: z.ZodBranded<z.ZodString, "PXL.DatabaseEnumName">;
|
|
9
|
+
export type DatabaseEnumName = z.infer<typeof zDatabaseEnumName>;
|
|
10
|
+
export declare const toDatabaseEnumName: (input: string) => string & z.BRAND<"PXL.DatabaseEnumName">;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toDatabaseEnumName = exports.zDatabaseEnumName = exports.toEnumValue = exports.toEnumName = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("@postxl/utils");
|
|
6
|
+
const zEnumName = zod_1.z
|
|
7
|
+
.string()
|
|
8
|
+
.refine((v) => (0, utils_1.isCamelCase)(v) || (0, utils_1.isPascalCase)(v), (v) => ({
|
|
9
|
+
message: `Enum name must be camelCase (${(0, utils_1.toCamelCase)(v)} or PascalCase ${(0, utils_1.toPascalCase)(v)})! Received ${v}.`,
|
|
10
|
+
}))
|
|
11
|
+
.brand('PXL.EnumName');
|
|
12
|
+
const toEnumName = (input) => zEnumName.parse(input);
|
|
13
|
+
exports.toEnumName = toEnumName;
|
|
14
|
+
const zEnumValue = zod_1.z.string().brand('PXL.EnumValue');
|
|
15
|
+
const toEnumValue = (input) => zEnumValue.parse(input);
|
|
16
|
+
exports.toEnumValue = toEnumValue;
|
|
17
|
+
exports.zDatabaseEnumName = zod_1.z.string().brand('PXL.DatabaseEnumName');
|
|
18
|
+
const toDatabaseEnumName = (input) => exports.zDatabaseEnumName.parse(input);
|
|
19
|
+
exports.toDatabaseEnumName = toDatabaseEnumName;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const zEnum: import("zod").ZodEffects<import("zod").ZodObject<{
|
|
2
|
+
name: import("zod").ZodEffects<import("zod").ZodString, string, string>;
|
|
3
|
+
description: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
4
|
+
schema: import("zod").ZodOptional<import("zod").ZodString>;
|
|
5
|
+
databaseName: import("zod").ZodOptional<import("zod").ZodString>;
|
|
6
|
+
members: import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
7
|
+
value: import("zod").ZodString;
|
|
8
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
9
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
10
|
+
value: string;
|
|
11
|
+
description?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
value: string;
|
|
14
|
+
description?: string | undefined;
|
|
15
|
+
}>, import("zod").ZodString]>, "many">;
|
|
16
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
17
|
+
description: string;
|
|
18
|
+
name: string;
|
|
19
|
+
members: (string | {
|
|
20
|
+
value: string;
|
|
21
|
+
description?: string | undefined;
|
|
22
|
+
})[];
|
|
23
|
+
schema?: string | undefined;
|
|
24
|
+
databaseName?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
name: string;
|
|
27
|
+
members: (string | {
|
|
28
|
+
value: string;
|
|
29
|
+
description?: string | undefined;
|
|
30
|
+
})[];
|
|
31
|
+
description?: string | undefined;
|
|
32
|
+
schema?: string | undefined;
|
|
33
|
+
databaseName?: string | undefined;
|
|
34
|
+
}>, {
|
|
35
|
+
name: string & import("zod").BRAND<"PXL.EnumName">;
|
|
36
|
+
description: string;
|
|
37
|
+
members: Map<string & import("zod").BRAND<"PXL.EnumValue">, import("./enum.types").EnumMember>;
|
|
38
|
+
databaseSchema: (string & import("zod").BRAND<"PXL.DatabaseSchemaName">) | undefined;
|
|
39
|
+
databaseName: string & import("zod").BRAND<"PXL.DatabaseEnumName">;
|
|
40
|
+
}, {
|
|
41
|
+
name: string;
|
|
42
|
+
members: (string | {
|
|
43
|
+
value: string;
|
|
44
|
+
description?: string | undefined;
|
|
45
|
+
})[];
|
|
46
|
+
description?: string | undefined;
|
|
47
|
+
schema?: string | undefined;
|
|
48
|
+
databaseName?: string | undefined;
|
|
49
|
+
}>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as Branded from './enum.brands';
|
|
2
|
+
import { EnumJSON } from './enum.json-decoder';
|
|
3
|
+
export declare const defaultEnumName_ActionStatus: string & import("zod").BRAND<"PXL.EnumName">;
|
|
4
|
+
export declare const defaultEnumName_MutationStatus: string & import("zod").BRAND<"PXL.EnumName">;
|
|
5
|
+
export declare const defaultEnumName_MutationKind: string & import("zod").BRAND<"PXL.EnumName">;
|
|
6
|
+
export declare const defaultEnumNames: {
|
|
7
|
+
actionStatus: string & import("zod").BRAND<"PXL.EnumName">;
|
|
8
|
+
mutationStatus: string & import("zod").BRAND<"PXL.EnumName">;
|
|
9
|
+
mutationKind: string & import("zod").BRAND<"PXL.EnumName">;
|
|
10
|
+
};
|
|
11
|
+
export declare const defaultEnumJson_ActionStatus: {
|
|
12
|
+
description: string;
|
|
13
|
+
name: string;
|
|
14
|
+
members: (string | {
|
|
15
|
+
value: string;
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
})[];
|
|
18
|
+
schema?: string | undefined;
|
|
19
|
+
databaseName?: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
export declare const defaultEnumJson_MutationStatus: {
|
|
22
|
+
description: string;
|
|
23
|
+
name: string;
|
|
24
|
+
members: (string | {
|
|
25
|
+
value: string;
|
|
26
|
+
description?: string | undefined;
|
|
27
|
+
})[];
|
|
28
|
+
schema?: string | undefined;
|
|
29
|
+
databaseName?: string | undefined;
|
|
30
|
+
};
|
|
31
|
+
export declare const defaultEnumJson_MutationKind: {
|
|
32
|
+
description: string;
|
|
33
|
+
name: string;
|
|
34
|
+
members: (string | {
|
|
35
|
+
value: string;
|
|
36
|
+
description?: string | undefined;
|
|
37
|
+
})[];
|
|
38
|
+
schema?: string | undefined;
|
|
39
|
+
databaseName?: string | undefined;
|
|
40
|
+
};
|
|
41
|
+
export declare const defaultEnumsJson: Record<Branded.EnumName, EnumJSON>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.defaultEnumsJson = exports.defaultEnumJson_MutationKind = exports.defaultEnumJson_MutationStatus = exports.defaultEnumJson_ActionStatus = exports.defaultEnumNames = exports.defaultEnumName_MutationKind = exports.defaultEnumName_MutationStatus = exports.defaultEnumName_ActionStatus = void 0;
|
|
37
|
+
const project_schema_defaults_1 = require("../project-schema/project-schema.defaults");
|
|
38
|
+
const Branded = __importStar(require("./enum.brands"));
|
|
39
|
+
const enum_json_decoder_1 = require("./enum.json-decoder");
|
|
40
|
+
exports.defaultEnumName_ActionStatus = Branded.toEnumName('ActionStatus');
|
|
41
|
+
exports.defaultEnumName_MutationStatus = Branded.toEnumName('MutationStatus');
|
|
42
|
+
exports.defaultEnumName_MutationKind = Branded.toEnumName('MutationKind');
|
|
43
|
+
exports.defaultEnumNames = {
|
|
44
|
+
actionStatus: exports.defaultEnumName_ActionStatus,
|
|
45
|
+
mutationStatus: exports.defaultEnumName_MutationStatus,
|
|
46
|
+
mutationKind: exports.defaultEnumName_MutationKind,
|
|
47
|
+
};
|
|
48
|
+
exports.defaultEnumJson_ActionStatus = enum_json_decoder_1.zEnumJSON.parse({
|
|
49
|
+
name: exports.defaultEnumName_ActionStatus,
|
|
50
|
+
description: 'The status of an action.',
|
|
51
|
+
schema: project_schema_defaults_1.databaseSchemaNameConfig,
|
|
52
|
+
members: [
|
|
53
|
+
{
|
|
54
|
+
value: 'Started',
|
|
55
|
+
description: 'The action has been started but is not completed yet.',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
value: 'Success',
|
|
59
|
+
description: 'The action has been completed successfully.',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: 'Error',
|
|
63
|
+
description: 'The action has been completed with an error.',
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
});
|
|
67
|
+
exports.defaultEnumJson_MutationStatus = enum_json_decoder_1.zEnumJSON.parse({
|
|
68
|
+
name: exports.defaultEnumName_MutationStatus,
|
|
69
|
+
description: 'The status of a mutation.',
|
|
70
|
+
schema: project_schema_defaults_1.databaseSchemaNameConfig,
|
|
71
|
+
members: [
|
|
72
|
+
{
|
|
73
|
+
value: 'Started',
|
|
74
|
+
description: 'The mutation has been started but is not completed yet.',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
value: 'Success',
|
|
78
|
+
description: 'The mutation has been completed successfully.',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
value: 'Error',
|
|
82
|
+
description: 'The mutation has been completed with an error.',
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
exports.defaultEnumJson_MutationKind = enum_json_decoder_1.zEnumJSON.parse({
|
|
87
|
+
name: exports.defaultEnumName_MutationKind,
|
|
88
|
+
description: 'The kind/type of a mutation.',
|
|
89
|
+
schema: project_schema_defaults_1.databaseSchemaNameConfig,
|
|
90
|
+
members: [
|
|
91
|
+
{ value: 'Create', description: 'Create a new entity.' },
|
|
92
|
+
{ value: 'CreateMany', description: 'Create multiple new entities.' },
|
|
93
|
+
{ value: 'Update', description: 'Update an existing item.' },
|
|
94
|
+
{ value: 'UpdateMany', description: 'Update multiple existing items.' },
|
|
95
|
+
{ value: 'Delete', description: 'Delete an existing item.' },
|
|
96
|
+
{ value: 'DeleteMany', description: 'Delete multiple existing items.' },
|
|
97
|
+
{ value: 'Clone', description: 'Clone an existing item.' },
|
|
98
|
+
{ value: 'CloneMany', description: 'Clone multiple existing items.' },
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
exports.defaultEnumsJson = {
|
|
102
|
+
[exports.defaultEnumName_ActionStatus]: exports.defaultEnumJson_ActionStatus,
|
|
103
|
+
[exports.defaultEnumName_MutationStatus]: exports.defaultEnumJson_MutationStatus,
|
|
104
|
+
[exports.defaultEnumName_MutationKind]: exports.defaultEnumJson_MutationKind,
|
|
105
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zEnum = void 0;
|
|
4
|
+
const enum_json_decoder_1 = require("./enum.json-decoder");
|
|
5
|
+
const enum_transformer_1 = require("./enum.transformer");
|
|
6
|
+
exports.zEnum = enum_json_decoder_1.zEnumJSON.transform(enum_transformer_1.enumTransformer);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const zEnumMemberNameJSON: z.ZodString;
|
|
3
|
+
export declare const zEnumMemberDescriptionJSON: z.ZodOptional<z.ZodString>;
|
|
4
|
+
export declare const zEnumMemberJSONDetailed: z.ZodObject<{
|
|
5
|
+
value: z.ZodString;
|
|
6
|
+
description: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
value: string;
|
|
9
|
+
description?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
value: string;
|
|
12
|
+
description?: string | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const zEnumMemberCompact: z.ZodString;
|
|
15
|
+
export declare const zEnumMemberJSON: z.ZodUnion<[z.ZodObject<{
|
|
16
|
+
value: z.ZodString;
|
|
17
|
+
description: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
value: string;
|
|
20
|
+
description?: string | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
value: string;
|
|
23
|
+
description?: string | undefined;
|
|
24
|
+
}>, z.ZodString]>;
|
|
25
|
+
export type EnumMemberJSON = z.infer<typeof zEnumMemberJSON>;
|
|
26
|
+
export declare const zEnumNameJSON: z.ZodEffects<z.ZodString, string, string>;
|
|
27
|
+
export declare const zEnumJSON: z.ZodObject<{
|
|
28
|
+
name: z.ZodEffects<z.ZodString, string, string>;
|
|
29
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
30
|
+
schema: z.ZodOptional<z.ZodString>;
|
|
31
|
+
databaseName: z.ZodOptional<z.ZodString>;
|
|
32
|
+
members: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
33
|
+
value: z.ZodString;
|
|
34
|
+
description: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
value: string;
|
|
37
|
+
description?: string | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
value: string;
|
|
40
|
+
description?: string | undefined;
|
|
41
|
+
}>, z.ZodString]>, "many">;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
description: string;
|
|
44
|
+
name: string;
|
|
45
|
+
members: (string | {
|
|
46
|
+
value: string;
|
|
47
|
+
description?: string | undefined;
|
|
48
|
+
})[];
|
|
49
|
+
schema?: string | undefined;
|
|
50
|
+
databaseName?: string | undefined;
|
|
51
|
+
}, {
|
|
52
|
+
name: string;
|
|
53
|
+
members: (string | {
|
|
54
|
+
value: string;
|
|
55
|
+
description?: string | undefined;
|
|
56
|
+
})[];
|
|
57
|
+
description?: string | undefined;
|
|
58
|
+
schema?: string | undefined;
|
|
59
|
+
databaseName?: string | undefined;
|
|
60
|
+
}>;
|
|
61
|
+
export type EnumJSON = z.infer<typeof zEnumJSON>;
|