@based/schema 2.5.3 → 2.7.0

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/dist/src/compat/Untitled-1.d.ts +3 -0
  2. package/dist/src/compat/Untitled-1.js +205 -0
  3. package/dist/src/compat/index.d.ts +2 -0
  4. package/dist/src/compat/index.js +3 -0
  5. package/dist/src/compat/newToOld.d.ts +3 -0
  6. package/dist/src/compat/newToOld.js +213 -0
  7. package/dist/src/compat/oldSchemaType.d.ts +69 -0
  8. package/dist/src/compat/oldSchemaType.js +2 -0
  9. package/dist/src/compat/oldToNew.d.ts +3 -0
  10. package/dist/src/compat/oldToNew.js +210 -0
  11. package/dist/src/display/number.d.ts +2 -1
  12. package/dist/src/display/number.js +10 -0
  13. package/dist/src/display/string.d.ts +3 -1
  14. package/dist/src/display/string.js +5 -0
  15. package/dist/src/display/timestamp.d.ts +3 -1
  16. package/dist/src/display/timestamp.js +9 -0
  17. package/dist/src/error.d.ts +3 -1
  18. package/dist/src/error.js +2 -0
  19. package/dist/src/index.d.ts +2 -1
  20. package/dist/src/index.js +2 -1
  21. package/dist/src/types.d.ts +4 -3
  22. package/dist/src/types.js +74 -0
  23. package/dist/src/validateSchema/basedSchemaTypeValidator.d.ts +3 -0
  24. package/dist/src/validateSchema/basedSchemaTypeValidator.js +45 -0
  25. package/dist/src/validateSchema/fieldValidators.d.ts +27 -0
  26. package/dist/src/validateSchema/fieldValidators.js +352 -0
  27. package/dist/src/validateSchema/index.d.ts +17 -0
  28. package/dist/src/validateSchema/index.js +109 -0
  29. package/dist/src/validateSchema/utils.d.ts +21 -0
  30. package/dist/src/validateSchema/utils.js +53 -0
  31. package/dist/test/compat.js +15 -0
  32. package/dist/test/data/newSchemas.d.ts +2 -0
  33. package/dist/test/data/newSchemas.js +254 -0
  34. package/dist/test/data/oldSchemas.d.ts +2 -0
  35. package/dist/test/data/oldSchemas.js +5058 -0
  36. package/dist/test/validateSchema/basic.d.ts +1 -0
  37. package/dist/test/validateSchema/basic.js +94 -0
  38. package/dist/test/validateSchema/fields.d.ts +1 -0
  39. package/dist/test/validateSchema/fields.js +366 -0
  40. package/dist/test/validateSchema/languages.d.ts +1 -0
  41. package/dist/test/validateSchema/languages.js +124 -0
  42. package/package.json +4 -1
  43. package/dist/src/validateSchema.d.ts +0 -4
  44. package/dist/src/validateSchema.js +0 -35
  45. package/dist/test/validateSchema.js +0 -38
  46. /package/dist/test/{validateSchema.d.ts → compat.d.ts} +0 -0
@@ -0,0 +1,254 @@
1
+ export const newSchemas = [
2
+ {
3
+ types: {
4
+ thing: {
5
+ prefix: 'ti',
6
+ fields: {
7
+ priority: { type: 'number' },
8
+ something: { type: 'string', format: 'strongPassword' },
9
+ },
10
+ },
11
+ bla: {
12
+ prefix: 'bl',
13
+ fields: {
14
+ enum: {
15
+ enum: ['tony', 'jim'],
16
+ },
17
+ setOfNumbers: {
18
+ type: 'set',
19
+ items: {
20
+ type: 'number',
21
+ },
22
+ },
23
+ object: {
24
+ type: 'object',
25
+ properties: {
26
+ flap: { type: 'boolean' },
27
+ },
28
+ },
29
+ flap: {
30
+ type: 'boolean',
31
+ },
32
+ x: {
33
+ type: 'object',
34
+ properties: {
35
+ flap: {
36
+ type: 'boolean',
37
+ },
38
+ },
39
+ },
40
+ record: {
41
+ type: 'record',
42
+ values: {
43
+ type: 'object',
44
+ properties: {
45
+ bla: {
46
+ type: 'array',
47
+ values: {
48
+ type: 'object',
49
+ properties: {
50
+ snux: {
51
+ type: 'object',
52
+ properties: {
53
+ x: {
54
+ type: 'number',
55
+ },
56
+ },
57
+ },
58
+ flap: { type: 'number' },
59
+ },
60
+ },
61
+ },
62
+ },
63
+ },
64
+ },
65
+ bla: {
66
+ type: 'set',
67
+ items: { type: 'string', minLength: 3, maxLength: 6 },
68
+ },
69
+ },
70
+ },
71
+ },
72
+ $defs: {},
73
+ language: 'en',
74
+ translations: ['de', 'nl', 'ro', 'za', 'ae'],
75
+ root: {
76
+ fields: {},
77
+ },
78
+ prefixToTypeMapping: {
79
+ bl: 'bla',
80
+ ti: 'thing',
81
+ },
82
+ },
83
+ {
84
+ types: {
85
+ thing: {
86
+ prefix: 'ti',
87
+ fields: {
88
+ dateHuman: { type: 'timestamp', display: 'human' },
89
+ dateTime: { type: 'timestamp', display: 'date-time' },
90
+ dateTimeText: { type: 'timestamp', display: 'date-time-text' },
91
+ time: { type: 'timestamp', display: 'time' },
92
+ timePrecise: { type: 'timestamp', display: 'time-precise' },
93
+ capitalize: {
94
+ type: 'string',
95
+ display: 'capitalize',
96
+ format: 'lowercase',
97
+ },
98
+ upperCase: { type: 'string', display: 'uppercase' },
99
+ lowerCase: { type: 'string', display: 'lowercase' },
100
+ euros: { type: 'number', display: 'euro' },
101
+ dollars: { type: 'number', display: 'dollar' },
102
+ pounds: { type: 'number', display: 'pound' },
103
+ bytes: { type: 'number', display: 'bytes' },
104
+ humanNumber: { type: 'number', display: 'human' },
105
+ ratio: { type: 'number', display: 'ratio' },
106
+ short: { type: 'number', display: 'short' },
107
+ },
108
+ },
109
+ },
110
+ $defs: {},
111
+ language: 'en',
112
+ root: {
113
+ fields: {},
114
+ },
115
+ prefixToTypeMapping: {
116
+ bl: 'bla',
117
+ ti: 'thing',
118
+ },
119
+ },
120
+ {
121
+ language: 'en',
122
+ translations: ['nl'],
123
+ $defs: {},
124
+ prefixToTypeMapping: {},
125
+ root: {
126
+ fields: {},
127
+ },
128
+ types: {
129
+ file: {
130
+ prefix: 'fi',
131
+ fields: {
132
+ usedIn: {
133
+ type: 'references',
134
+ bidirectional: { fromField: 'img' },
135
+ },
136
+ caption: {
137
+ // needs translation?
138
+ type: 'text',
139
+ description: 'Caption for seo',
140
+ title: 'Caption',
141
+ },
142
+ },
143
+ },
144
+ user: {
145
+ prefix: 'us',
146
+ fields: {
147
+ firstName: { type: 'string' },
148
+ lastName: { type: 'string' },
149
+ email: { type: 'string', format: 'email' },
150
+ company: { type: 'reference' },
151
+ newsletter: { type: 'integer' },
152
+ ip: { type: 'string' },
153
+ seen: { type: 'timestamp' },
154
+ charges: {
155
+ type: 'references',
156
+ bidirectional: { fromField: 'user' },
157
+ allowedTypes: ['charge'],
158
+ },
159
+ articles: {
160
+ type: 'references',
161
+ bidirectional: { fromField: 'contributors' },
162
+ allowedTypes: ['article'],
163
+ },
164
+ },
165
+ },
166
+ charge: {
167
+ fields: {
168
+ // does this have a user?
169
+ user: {
170
+ type: 'reference',
171
+ bidirectional: { fromField: 'charges' },
172
+ allowedTypes: ['user'],
173
+ },
174
+ token: { type: 'string' },
175
+ description: { type: 'string' },
176
+ amount: { type: 'number' },
177
+ stripeId: { type: 'string' },
178
+ },
179
+ },
180
+ category: {
181
+ fields: {
182
+ title: { type: 'text' },
183
+ children: {
184
+ type: 'references',
185
+ allowedTypes: ['article'],
186
+ },
187
+ },
188
+ },
189
+ section: {
190
+ fields: {
191
+ title: { type: 'text' },
192
+ membership: { type: 'number' },
193
+ membershipFreeDays: { type: 'number' },
194
+ hidden: { type: 'boolean' },
195
+ metaDescription: { type: 'text' },
196
+ // meta_keywords: { type: 'array', values: { type: 'string' } },
197
+ children: {
198
+ type: 'references',
199
+ allowedTypes: ['article', 'category'],
200
+ },
201
+ },
202
+ },
203
+ article: {
204
+ prefix: 'ar',
205
+ fields: {
206
+ contributors: {
207
+ title: 'Writers',
208
+ description: 'Writers or people involved with the article.',
209
+ type: 'references',
210
+ allowedTypes: ['user'],
211
+ bidirectional: {
212
+ fromField: 'articles',
213
+ },
214
+ },
215
+ contributorsText: {
216
+ title: 'Contributors text',
217
+ description: 'Gets auto generated based on contributors, fill it in to override.',
218
+ examples: ['Peter Teffer, graphics by Kashyap Raibagi (EDJNET)'],
219
+ type: 'text',
220
+ },
221
+ headline: {
222
+ title: 'Headline',
223
+ description: 'Displayed on pages, also used as meta title for seo.',
224
+ type: 'text',
225
+ },
226
+ publishDate: {
227
+ title: 'Publish date',
228
+ description: 'Any time you want the article to show on the website',
229
+ type: 'timestamp',
230
+ },
231
+ archived: {
232
+ title: 'Archived',
233
+ description: 'Archived articles will not show up on the website or be available outside of the cms',
234
+ type: 'boolean',
235
+ },
236
+ img: {
237
+ type: 'reference',
238
+ allowedTypes: ['file'],
239
+ bidirectional: { fromField: 'usedIn' },
240
+ },
241
+ hits: { type: 'number' }, // get a bit more going here maybe? what does this mean
242
+ membership: { enum: ['Need membership', 'Free'] },
243
+ location: { type: 'text' }, // or string its just city name or smth
244
+ bio: { type: 'text', format: 'json' }, //has a href and stuff so aarich text
245
+ tweet: { type: 'string' }, // ask if it needs translation // 'The 2009 allocation of solar subsidies in Solvakia "was rigged," say a US cable. PM Fico denies it.',
246
+ notes: { type: 'string' },
247
+ abstract: { type: 'text' },
248
+ body: { type: 'text', format: 'json' }, // will add rich text
249
+ },
250
+ },
251
+ },
252
+ },
253
+ ];
254
+ //# sourceMappingURL=newSchemas.js.map
@@ -0,0 +1,2 @@
1
+ import { BasedOldSchema } from '../../src/compat/oldSchemaType.js';
2
+ export declare const oldSchemas: BasedOldSchema[];