@conloca/content-api 0.2.1 → 0.2.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/dist/asset-metadata-store.d.ts.map +1 -1
- package/dist/asset-operations.d.ts +15 -17
- package/dist/asset-operations.d.ts.map +1 -1
- package/dist/asset-operations.js +216 -78
- package/dist/asset-operations.js.map +1 -1
- package/dist/cf-access.d.ts +4 -2
- package/dist/cf-access.d.ts.map +1 -1
- package/dist/cf-access.js +29 -13
- package/dist/cf-access.js.map +1 -1
- package/dist/component-registry.d.ts +0 -3
- package/dist/component-registry.d.ts.map +1 -1
- package/dist/content-file-id.d.ts +9 -0
- package/dist/content-file-id.d.ts.map +1 -0
- package/dist/content-file-id.js +33 -0
- package/dist/content-file-id.js.map +1 -0
- package/dist/filesystem-content-api.d.ts +0 -15
- package/dist/filesystem-content-api.d.ts.map +1 -1
- package/dist/git-operations.d.ts.map +1 -1
- package/dist/git-operations.js +162 -34
- package/dist/git-operations.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +5 -0
- package/dist/middleware.js.map +1 -1
- package/dist/schemas/index.d.ts +9 -97
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +8 -83
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/normalize.d.ts +101 -0
- package/dist/schemas/normalize.d.ts.map +1 -0
- package/dist/schemas/normalize.js +168 -0
- package/dist/schemas/normalize.js.map +1 -0
- package/dist/schemas/types.d.ts +135 -0
- package/dist/schemas/types.d.ts.map +1 -0
- package/dist/schemas/types.js +17 -0
- package/dist/schemas/types.js.map +1 -0
- package/dist/schemas/validators.d.ts +46 -0
- package/dist/schemas/validators.d.ts.map +1 -0
- package/dist/schemas/validators.js +938 -0
- package/dist/schemas/validators.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -5
- package/src/asset-operations.ts +256 -83
- package/src/cf-access.ts +30 -14
- package/src/content-file-id.ts +31 -0
- package/src/git-operations.ts +188 -41
- package/src/index.ts +17 -1
- package/src/middleware.ts +5 -0
- package/src/schemas/index.ts +34 -108
- package/src/schemas/normalize.ts +194 -0
- package/src/schemas/types.ts +154 -0
- package/src/schemas/validators.ts +176 -0
- package/src/types.ts +7 -0
|
@@ -0,0 +1,938 @@
|
|
|
1
|
+
import * as _accessExpressionAsString_1 from "typia/lib/internal/_accessExpressionAsString";
|
|
2
|
+
const __typia_transform__accessExpressionAsString = _accessExpressionAsString_1._accessExpressionAsString;
|
|
3
|
+
import * as _validateReport_1 from "typia/lib/internal/_validateReport";
|
|
4
|
+
import * as _createStandardSchema_1 from "typia/lib/internal/_createStandardSchema";
|
|
5
|
+
/**
|
|
6
|
+
* Generated validators for the content metadata shapes.
|
|
7
|
+
*
|
|
8
|
+
* Every `typia.createValidate<T>()` below is rewritten into concrete generated
|
|
9
|
+
* validation code by the `ttsc` transform (spec 12 §The build chain) — in
|
|
10
|
+
* tsdown's Rolldown pipeline for the published build, and by the Bun test
|
|
11
|
+
* preload for `bun test`. Nothing here hand-rolls a check.
|
|
12
|
+
*
|
|
13
|
+
* `parse*` is the replacement for the Zod schemas' `safeParse`: normalize first
|
|
14
|
+
* (`./normalize` reproduces what Zod did implicitly: the fresh copy, the
|
|
15
|
+
* unknown-key strip of the strict shapes, the date coercion and the `.url()`
|
|
16
|
+
* check), then validate with `typia.createValidate<T>()`.
|
|
17
|
+
*
|
|
18
|
+
* `canonical` deliberately carries no `tags.Format<'url'>`: Typia's URL regex
|
|
19
|
+
* rejects URLs Zod accepted (`https://example.com?lang=en`, `#top`,
|
|
20
|
+
* `http://localhost:4321/`) and accepts ones it rejected (port 99999), so the
|
|
21
|
+
* page parsers keep Zod's parser-based check in `normalize()` instead.
|
|
22
|
+
*/
|
|
23
|
+
import typia, {} from 'typia';
|
|
24
|
+
import { normalize, PAGE_DATE_KEYS, PAGE_URL_KEYS } from './normalize.js';
|
|
25
|
+
/** Field names `PageMeta` declares — the fields a host page schema may not redeclare. */
|
|
26
|
+
export const PAGE_META_KEYS = [
|
|
27
|
+
"canonical",
|
|
28
|
+
"description",
|
|
29
|
+
"id",
|
|
30
|
+
"locale",
|
|
31
|
+
"pathname",
|
|
32
|
+
"publishAt",
|
|
33
|
+
"robots",
|
|
34
|
+
"title",
|
|
35
|
+
"unpublishAt"
|
|
36
|
+
];
|
|
37
|
+
const validatePageEditable = (() => {
|
|
38
|
+
const _io0 = input => "string" === typeof input.title && (undefined === input.description || "string" === typeof input.description) && "string" === typeof input.pathname && (null === input.publishAt || undefined === input.publishAt || input.publishAt instanceof Date) && (null === input.unpublishAt || undefined === input.unpublishAt || input.unpublishAt instanceof Date) && (undefined === input.robots || "string" === typeof input.robots) && (undefined === input.canonical || "string" === typeof input.canonical);
|
|
39
|
+
const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.title || _report(_exceptionable, {
|
|
40
|
+
path: _path + ".title",
|
|
41
|
+
expected: "string",
|
|
42
|
+
value: input.title
|
|
43
|
+
}), undefined === input.description || "string" === typeof input.description || _report(_exceptionable, {
|
|
44
|
+
path: _path + ".description",
|
|
45
|
+
expected: "(string | undefined)",
|
|
46
|
+
value: input.description
|
|
47
|
+
}), "string" === typeof input.pathname || _report(_exceptionable, {
|
|
48
|
+
path: _path + ".pathname",
|
|
49
|
+
expected: "string",
|
|
50
|
+
value: input.pathname
|
|
51
|
+
}), null === input.publishAt || undefined === input.publishAt || input.publishAt instanceof Date || _report(_exceptionable, {
|
|
52
|
+
path: _path + ".publishAt",
|
|
53
|
+
expected: "(Date | null | undefined)",
|
|
54
|
+
value: input.publishAt
|
|
55
|
+
}), null === input.unpublishAt || undefined === input.unpublishAt || input.unpublishAt instanceof Date || _report(_exceptionable, {
|
|
56
|
+
path: _path + ".unpublishAt",
|
|
57
|
+
expected: "(Date | null | undefined)",
|
|
58
|
+
value: input.unpublishAt
|
|
59
|
+
}), undefined === input.robots || "string" === typeof input.robots || _report(_exceptionable, {
|
|
60
|
+
path: _path + ".robots",
|
|
61
|
+
expected: "(string | undefined)",
|
|
62
|
+
value: input.robots
|
|
63
|
+
}), undefined === input.canonical || "string" === typeof input.canonical || _report(_exceptionable, {
|
|
64
|
+
path: _path + ".canonical",
|
|
65
|
+
expected: "(string | undefined)",
|
|
66
|
+
value: input.canonical
|
|
67
|
+
})].every(flag => flag);
|
|
68
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
69
|
+
let errors;
|
|
70
|
+
let _report;
|
|
71
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
72
|
+
if (false === __is(input)) {
|
|
73
|
+
errors = [];
|
|
74
|
+
_report = _validateReport_1._validateReport(errors);
|
|
75
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
76
|
+
path: _path + "",
|
|
77
|
+
expected: "PageEditable",
|
|
78
|
+
value: input
|
|
79
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
80
|
+
path: _path + "",
|
|
81
|
+
expected: "PageEditable",
|
|
82
|
+
value: input
|
|
83
|
+
}))(input, "$input", true);
|
|
84
|
+
const success = 0 === errors.length;
|
|
85
|
+
return success ? {
|
|
86
|
+
success,
|
|
87
|
+
data: input
|
|
88
|
+
} : {
|
|
89
|
+
success,
|
|
90
|
+
errors,
|
|
91
|
+
data: input
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
success: true,
|
|
96
|
+
data: input
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
})();
|
|
100
|
+
const validatePageMeta = (() => {
|
|
101
|
+
const _io0 = input => _io1(input) && ("string" === typeof input.id && "string" === typeof input.locale);
|
|
102
|
+
const _io1 = input => "string" === typeof input.title && (undefined === input.description || "string" === typeof input.description) && "string" === typeof input.pathname && (null === input.publishAt || undefined === input.publishAt || input.publishAt instanceof Date) && (null === input.unpublishAt || undefined === input.unpublishAt || input.unpublishAt instanceof Date) && (undefined === input.robots || "string" === typeof input.robots) && (undefined === input.canonical || "string" === typeof input.canonical);
|
|
103
|
+
const _vo0 = (input, _path, _exceptionable = true) => _vo1(input, _path, true && _exceptionable) && ["string" === typeof input.id || _report(_exceptionable, {
|
|
104
|
+
path: _path + ".id",
|
|
105
|
+
expected: "string",
|
|
106
|
+
value: input.id
|
|
107
|
+
}), "string" === typeof input.locale || _report(_exceptionable, {
|
|
108
|
+
path: _path + ".locale",
|
|
109
|
+
expected: "string",
|
|
110
|
+
value: input.locale
|
|
111
|
+
})].every(flag => flag);
|
|
112
|
+
const _vo1 = (input, _path, _exceptionable = true) => ["string" === typeof input.title || _report(_exceptionable, {
|
|
113
|
+
path: _path + ".title",
|
|
114
|
+
expected: "string",
|
|
115
|
+
value: input.title
|
|
116
|
+
}), undefined === input.description || "string" === typeof input.description || _report(_exceptionable, {
|
|
117
|
+
path: _path + ".description",
|
|
118
|
+
expected: "(string | undefined)",
|
|
119
|
+
value: input.description
|
|
120
|
+
}), "string" === typeof input.pathname || _report(_exceptionable, {
|
|
121
|
+
path: _path + ".pathname",
|
|
122
|
+
expected: "string",
|
|
123
|
+
value: input.pathname
|
|
124
|
+
}), null === input.publishAt || undefined === input.publishAt || input.publishAt instanceof Date || _report(_exceptionable, {
|
|
125
|
+
path: _path + ".publishAt",
|
|
126
|
+
expected: "(Date | null | undefined)",
|
|
127
|
+
value: input.publishAt
|
|
128
|
+
}), null === input.unpublishAt || undefined === input.unpublishAt || input.unpublishAt instanceof Date || _report(_exceptionable, {
|
|
129
|
+
path: _path + ".unpublishAt",
|
|
130
|
+
expected: "(Date | null | undefined)",
|
|
131
|
+
value: input.unpublishAt
|
|
132
|
+
}), undefined === input.robots || "string" === typeof input.robots || _report(_exceptionable, {
|
|
133
|
+
path: _path + ".robots",
|
|
134
|
+
expected: "(string | undefined)",
|
|
135
|
+
value: input.robots
|
|
136
|
+
}), undefined === input.canonical || "string" === typeof input.canonical || _report(_exceptionable, {
|
|
137
|
+
path: _path + ".canonical",
|
|
138
|
+
expected: "(string | undefined)",
|
|
139
|
+
value: input.canonical
|
|
140
|
+
})].every(flag => flag);
|
|
141
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
142
|
+
let errors;
|
|
143
|
+
let _report;
|
|
144
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
145
|
+
if (false === __is(input)) {
|
|
146
|
+
errors = [];
|
|
147
|
+
_report = _validateReport_1._validateReport(errors);
|
|
148
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
149
|
+
path: _path + "",
|
|
150
|
+
expected: "PageMeta",
|
|
151
|
+
value: input
|
|
152
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
153
|
+
path: _path + "",
|
|
154
|
+
expected: "PageMeta",
|
|
155
|
+
value: input
|
|
156
|
+
}))(input, "$input", true);
|
|
157
|
+
const success = 0 === errors.length;
|
|
158
|
+
return success ? {
|
|
159
|
+
success,
|
|
160
|
+
data: input
|
|
161
|
+
} : {
|
|
162
|
+
success,
|
|
163
|
+
errors,
|
|
164
|
+
data: input
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
success: true,
|
|
169
|
+
data: input
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
})();
|
|
173
|
+
const validateFragmentEditable = (() => {
|
|
174
|
+
const _io0 = input => "string" === typeof input.title && (undefined === input.description || "string" === typeof input.description) && (undefined === input.category || "string" === typeof input.category) && (undefined === input.tags || Array.isArray(input.tags) && input.tags.every(elem => "string" === typeof elem));
|
|
175
|
+
const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.title || _report(_exceptionable, {
|
|
176
|
+
path: _path + ".title",
|
|
177
|
+
expected: "string",
|
|
178
|
+
value: input.title
|
|
179
|
+
}), undefined === input.description || "string" === typeof input.description || _report(_exceptionable, {
|
|
180
|
+
path: _path + ".description",
|
|
181
|
+
expected: "(string | undefined)",
|
|
182
|
+
value: input.description
|
|
183
|
+
}), undefined === input.category || "string" === typeof input.category || _report(_exceptionable, {
|
|
184
|
+
path: _path + ".category",
|
|
185
|
+
expected: "(string | undefined)",
|
|
186
|
+
value: input.category
|
|
187
|
+
}), undefined === input.tags || (Array.isArray(input.tags) || _report(_exceptionable, {
|
|
188
|
+
path: _path + ".tags",
|
|
189
|
+
expected: "(Array<string> | undefined)",
|
|
190
|
+
value: input.tags
|
|
191
|
+
})) && input.tags.map((elem, _index2) => "string" === typeof elem || _report(_exceptionable, {
|
|
192
|
+
path: _path + ".tags[" + _index2 + "]",
|
|
193
|
+
expected: "string",
|
|
194
|
+
value: elem
|
|
195
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
196
|
+
path: _path + ".tags",
|
|
197
|
+
expected: "(Array<string> | undefined)",
|
|
198
|
+
value: input.tags
|
|
199
|
+
})].every(flag => flag);
|
|
200
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
201
|
+
let errors;
|
|
202
|
+
let _report;
|
|
203
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
204
|
+
if (false === __is(input)) {
|
|
205
|
+
errors = [];
|
|
206
|
+
_report = _validateReport_1._validateReport(errors);
|
|
207
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
208
|
+
path: _path + "",
|
|
209
|
+
expected: "FragmentEditable",
|
|
210
|
+
value: input
|
|
211
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
212
|
+
path: _path + "",
|
|
213
|
+
expected: "FragmentEditable",
|
|
214
|
+
value: input
|
|
215
|
+
}))(input, "$input", true);
|
|
216
|
+
const success = 0 === errors.length;
|
|
217
|
+
return success ? {
|
|
218
|
+
success,
|
|
219
|
+
data: input
|
|
220
|
+
} : {
|
|
221
|
+
success,
|
|
222
|
+
errors,
|
|
223
|
+
data: input
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
success: true,
|
|
228
|
+
data: input
|
|
229
|
+
};
|
|
230
|
+
});
|
|
231
|
+
})();
|
|
232
|
+
const validateFragmentMeta = (() => {
|
|
233
|
+
const _io0 = input => _io1(input) && ("string" === typeof input.id && "string" === typeof input.locale && "string" === typeof input.name);
|
|
234
|
+
const _io1 = input => "string" === typeof input.title && (undefined === input.description || "string" === typeof input.description) && (undefined === input.category || "string" === typeof input.category) && (undefined === input.tags || Array.isArray(input.tags) && input.tags.every(elem => "string" === typeof elem));
|
|
235
|
+
const _vo0 = (input, _path, _exceptionable = true) => _vo1(input, _path, true && _exceptionable) && ["string" === typeof input.id || _report(_exceptionable, {
|
|
236
|
+
path: _path + ".id",
|
|
237
|
+
expected: "string",
|
|
238
|
+
value: input.id
|
|
239
|
+
}), "string" === typeof input.locale || _report(_exceptionable, {
|
|
240
|
+
path: _path + ".locale",
|
|
241
|
+
expected: "string",
|
|
242
|
+
value: input.locale
|
|
243
|
+
}), "string" === typeof input.name || _report(_exceptionable, {
|
|
244
|
+
path: _path + ".name",
|
|
245
|
+
expected: "string",
|
|
246
|
+
value: input.name
|
|
247
|
+
})].every(flag => flag);
|
|
248
|
+
const _vo1 = (input, _path, _exceptionable = true) => ["string" === typeof input.title || _report(_exceptionable, {
|
|
249
|
+
path: _path + ".title",
|
|
250
|
+
expected: "string",
|
|
251
|
+
value: input.title
|
|
252
|
+
}), undefined === input.description || "string" === typeof input.description || _report(_exceptionable, {
|
|
253
|
+
path: _path + ".description",
|
|
254
|
+
expected: "(string | undefined)",
|
|
255
|
+
value: input.description
|
|
256
|
+
}), undefined === input.category || "string" === typeof input.category || _report(_exceptionable, {
|
|
257
|
+
path: _path + ".category",
|
|
258
|
+
expected: "(string | undefined)",
|
|
259
|
+
value: input.category
|
|
260
|
+
}), undefined === input.tags || (Array.isArray(input.tags) || _report(_exceptionable, {
|
|
261
|
+
path: _path + ".tags",
|
|
262
|
+
expected: "(Array<string> | undefined)",
|
|
263
|
+
value: input.tags
|
|
264
|
+
})) && input.tags.map((elem, _index2) => "string" === typeof elem || _report(_exceptionable, {
|
|
265
|
+
path: _path + ".tags[" + _index2 + "]",
|
|
266
|
+
expected: "string",
|
|
267
|
+
value: elem
|
|
268
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
269
|
+
path: _path + ".tags",
|
|
270
|
+
expected: "(Array<string> | undefined)",
|
|
271
|
+
value: input.tags
|
|
272
|
+
})].every(flag => flag);
|
|
273
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
274
|
+
let errors;
|
|
275
|
+
let _report;
|
|
276
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
277
|
+
if (false === __is(input)) {
|
|
278
|
+
errors = [];
|
|
279
|
+
_report = _validateReport_1._validateReport(errors);
|
|
280
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
281
|
+
path: _path + "",
|
|
282
|
+
expected: "FragmentMeta",
|
|
283
|
+
value: input
|
|
284
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
285
|
+
path: _path + "",
|
|
286
|
+
expected: "FragmentMeta",
|
|
287
|
+
value: input
|
|
288
|
+
}))(input, "$input", true);
|
|
289
|
+
const success = 0 === errors.length;
|
|
290
|
+
return success ? {
|
|
291
|
+
success,
|
|
292
|
+
data: input
|
|
293
|
+
} : {
|
|
294
|
+
success,
|
|
295
|
+
errors,
|
|
296
|
+
data: input
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
return {
|
|
300
|
+
success: true,
|
|
301
|
+
data: input
|
|
302
|
+
};
|
|
303
|
+
});
|
|
304
|
+
})();
|
|
305
|
+
const validateMdxPageFrontmatter = (() => {
|
|
306
|
+
const _io0 = input => "string" === typeof input.title && (undefined === input.description || "string" === typeof input.description) && (undefined === input.draft || "boolean" === typeof input.draft) && Object.keys(input).every(key => {
|
|
307
|
+
if (["title", "description", "draft"].some(prop => key === prop))
|
|
308
|
+
return true;
|
|
309
|
+
const value = input[key];
|
|
310
|
+
if (undefined === value)
|
|
311
|
+
return true;
|
|
312
|
+
return true;
|
|
313
|
+
});
|
|
314
|
+
const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.title || _report(_exceptionable, {
|
|
315
|
+
path: _path + ".title",
|
|
316
|
+
expected: "string",
|
|
317
|
+
value: input.title
|
|
318
|
+
}), undefined === input.description || "string" === typeof input.description || _report(_exceptionable, {
|
|
319
|
+
path: _path + ".description",
|
|
320
|
+
expected: "(string | undefined)",
|
|
321
|
+
value: input.description
|
|
322
|
+
}), undefined === input.draft || "boolean" === typeof input.draft || _report(_exceptionable, {
|
|
323
|
+
path: _path + ".draft",
|
|
324
|
+
expected: "(boolean | undefined)",
|
|
325
|
+
value: input.draft
|
|
326
|
+
}), false === _exceptionable || Object.keys(input).map(key => {
|
|
327
|
+
if (["title", "description", "draft"].some(prop => key === prop))
|
|
328
|
+
return true;
|
|
329
|
+
const value = input[key];
|
|
330
|
+
if (undefined === value)
|
|
331
|
+
return true;
|
|
332
|
+
return true;
|
|
333
|
+
}).every(flag => flag)].every(flag => flag);
|
|
334
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
335
|
+
let errors;
|
|
336
|
+
let _report;
|
|
337
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
338
|
+
if (false === __is(input)) {
|
|
339
|
+
errors = [];
|
|
340
|
+
_report = _validateReport_1._validateReport(errors);
|
|
341
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
342
|
+
path: _path + "",
|
|
343
|
+
expected: "MdxPageFrontmatter",
|
|
344
|
+
value: input
|
|
345
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
346
|
+
path: _path + "",
|
|
347
|
+
expected: "MdxPageFrontmatter",
|
|
348
|
+
value: input
|
|
349
|
+
}))(input, "$input", true);
|
|
350
|
+
const success = 0 === errors.length;
|
|
351
|
+
return success ? {
|
|
352
|
+
success,
|
|
353
|
+
data: input
|
|
354
|
+
} : {
|
|
355
|
+
success,
|
|
356
|
+
errors,
|
|
357
|
+
data: input
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
success: true,
|
|
362
|
+
data: input
|
|
363
|
+
};
|
|
364
|
+
});
|
|
365
|
+
})();
|
|
366
|
+
const validateDataEditable = (() => {
|
|
367
|
+
const _io0 = input => "string" === typeof input.title && (undefined === input.description || "string" === typeof input.description) && (undefined === input.category || "string" === typeof input.category) && (undefined === input.tags || Array.isArray(input.tags) && input.tags.every(elem => "string" === typeof elem));
|
|
368
|
+
const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.title || _report(_exceptionable, {
|
|
369
|
+
path: _path + ".title",
|
|
370
|
+
expected: "string",
|
|
371
|
+
value: input.title
|
|
372
|
+
}), undefined === input.description || "string" === typeof input.description || _report(_exceptionable, {
|
|
373
|
+
path: _path + ".description",
|
|
374
|
+
expected: "(string | undefined)",
|
|
375
|
+
value: input.description
|
|
376
|
+
}), undefined === input.category || "string" === typeof input.category || _report(_exceptionable, {
|
|
377
|
+
path: _path + ".category",
|
|
378
|
+
expected: "(string | undefined)",
|
|
379
|
+
value: input.category
|
|
380
|
+
}), undefined === input.tags || (Array.isArray(input.tags) || _report(_exceptionable, {
|
|
381
|
+
path: _path + ".tags",
|
|
382
|
+
expected: "(Array<string> | undefined)",
|
|
383
|
+
value: input.tags
|
|
384
|
+
})) && input.tags.map((elem, _index2) => "string" === typeof elem || _report(_exceptionable, {
|
|
385
|
+
path: _path + ".tags[" + _index2 + "]",
|
|
386
|
+
expected: "string",
|
|
387
|
+
value: elem
|
|
388
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
389
|
+
path: _path + ".tags",
|
|
390
|
+
expected: "(Array<string> | undefined)",
|
|
391
|
+
value: input.tags
|
|
392
|
+
})].every(flag => flag);
|
|
393
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
394
|
+
let errors;
|
|
395
|
+
let _report;
|
|
396
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
397
|
+
if (false === __is(input)) {
|
|
398
|
+
errors = [];
|
|
399
|
+
_report = _validateReport_1._validateReport(errors);
|
|
400
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
401
|
+
path: _path + "",
|
|
402
|
+
expected: "DataEditable",
|
|
403
|
+
value: input
|
|
404
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
405
|
+
path: _path + "",
|
|
406
|
+
expected: "DataEditable",
|
|
407
|
+
value: input
|
|
408
|
+
}))(input, "$input", true);
|
|
409
|
+
const success = 0 === errors.length;
|
|
410
|
+
return success ? {
|
|
411
|
+
success,
|
|
412
|
+
data: input
|
|
413
|
+
} : {
|
|
414
|
+
success,
|
|
415
|
+
errors,
|
|
416
|
+
data: input
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
return {
|
|
420
|
+
success: true,
|
|
421
|
+
data: input
|
|
422
|
+
};
|
|
423
|
+
});
|
|
424
|
+
})();
|
|
425
|
+
const validateDataMeta = (() => {
|
|
426
|
+
const _io0 = input => _io1(input) && ("string" === typeof input.id && "string" === typeof input.locale && "string" === typeof input.name && (undefined === input.data || "object" === typeof input.data && null !== input.data && false === Array.isArray(input.data) && _io2(input.data)));
|
|
427
|
+
const _io1 = input => "string" === typeof input.title && (undefined === input.description || "string" === typeof input.description) && (undefined === input.category || "string" === typeof input.category) && (undefined === input.tags || Array.isArray(input.tags) && input.tags.every(elem => "string" === typeof elem));
|
|
428
|
+
const _io2 = input => Object.keys(input).every(key => {
|
|
429
|
+
const value = input[key];
|
|
430
|
+
if (undefined === value)
|
|
431
|
+
return true;
|
|
432
|
+
return true;
|
|
433
|
+
});
|
|
434
|
+
const _vo0 = (input, _path, _exceptionable = true) => _vo1(input, _path, true && _exceptionable) && ["string" === typeof input.id || _report(_exceptionable, {
|
|
435
|
+
path: _path + ".id",
|
|
436
|
+
expected: "string",
|
|
437
|
+
value: input.id
|
|
438
|
+
}), "string" === typeof input.locale || _report(_exceptionable, {
|
|
439
|
+
path: _path + ".locale",
|
|
440
|
+
expected: "string",
|
|
441
|
+
value: input.locale
|
|
442
|
+
}), "string" === typeof input.name || _report(_exceptionable, {
|
|
443
|
+
path: _path + ".name",
|
|
444
|
+
expected: "string",
|
|
445
|
+
value: input.name
|
|
446
|
+
}), undefined === input.data || ("object" === typeof input.data && null !== input.data && false === Array.isArray(input.data) || _report(_exceptionable, {
|
|
447
|
+
path: _path + ".data",
|
|
448
|
+
expected: "(Record<string, unknown> | undefined)",
|
|
449
|
+
value: input.data
|
|
450
|
+
})) && _vo2(input.data, _path + ".data", true && _exceptionable) || _report(_exceptionable, {
|
|
451
|
+
path: _path + ".data",
|
|
452
|
+
expected: "(Record<string, unknown> | undefined)",
|
|
453
|
+
value: input.data
|
|
454
|
+
})].every(flag => flag);
|
|
455
|
+
const _vo1 = (input, _path, _exceptionable = true) => ["string" === typeof input.title || _report(_exceptionable, {
|
|
456
|
+
path: _path + ".title",
|
|
457
|
+
expected: "string",
|
|
458
|
+
value: input.title
|
|
459
|
+
}), undefined === input.description || "string" === typeof input.description || _report(_exceptionable, {
|
|
460
|
+
path: _path + ".description",
|
|
461
|
+
expected: "(string | undefined)",
|
|
462
|
+
value: input.description
|
|
463
|
+
}), undefined === input.category || "string" === typeof input.category || _report(_exceptionable, {
|
|
464
|
+
path: _path + ".category",
|
|
465
|
+
expected: "(string | undefined)",
|
|
466
|
+
value: input.category
|
|
467
|
+
}), undefined === input.tags || (Array.isArray(input.tags) || _report(_exceptionable, {
|
|
468
|
+
path: _path + ".tags",
|
|
469
|
+
expected: "(Array<string> | undefined)",
|
|
470
|
+
value: input.tags
|
|
471
|
+
})) && input.tags.map((elem, _index2) => "string" === typeof elem || _report(_exceptionable, {
|
|
472
|
+
path: _path + ".tags[" + _index2 + "]",
|
|
473
|
+
expected: "string",
|
|
474
|
+
value: elem
|
|
475
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
476
|
+
path: _path + ".tags",
|
|
477
|
+
expected: "(Array<string> | undefined)",
|
|
478
|
+
value: input.tags
|
|
479
|
+
})].every(flag => flag);
|
|
480
|
+
const _vo2 = (input, _path, _exceptionable = true) => [false === _exceptionable || Object.keys(input).map(key => {
|
|
481
|
+
const value = input[key];
|
|
482
|
+
if (undefined === value)
|
|
483
|
+
return true;
|
|
484
|
+
return true;
|
|
485
|
+
}).every(flag => flag)].every(flag => flag);
|
|
486
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
487
|
+
let errors;
|
|
488
|
+
let _report;
|
|
489
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
490
|
+
if (false === __is(input)) {
|
|
491
|
+
errors = [];
|
|
492
|
+
_report = _validateReport_1._validateReport(errors);
|
|
493
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
494
|
+
path: _path + "",
|
|
495
|
+
expected: "DataMeta",
|
|
496
|
+
value: input
|
|
497
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
498
|
+
path: _path + "",
|
|
499
|
+
expected: "DataMeta",
|
|
500
|
+
value: input
|
|
501
|
+
}))(input, "$input", true);
|
|
502
|
+
const success = 0 === errors.length;
|
|
503
|
+
return success ? {
|
|
504
|
+
success,
|
|
505
|
+
data: input
|
|
506
|
+
} : {
|
|
507
|
+
success,
|
|
508
|
+
errors,
|
|
509
|
+
data: input
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
return {
|
|
513
|
+
success: true,
|
|
514
|
+
data: input
|
|
515
|
+
};
|
|
516
|
+
});
|
|
517
|
+
})();
|
|
518
|
+
const validateLoosePageMeta = (() => {
|
|
519
|
+
const _io0 = input => "string" === typeof input.title && (undefined === input.description || "string" === typeof input.description) && "string" === typeof input.pathname && (null === input.publishAt || undefined === input.publishAt || input.publishAt instanceof Date) && (null === input.unpublishAt || undefined === input.unpublishAt || input.unpublishAt instanceof Date) && (undefined === input.robots || "string" === typeof input.robots) && (undefined === input.canonical || "string" === typeof input.canonical) && "string" === typeof input.id && "string" === typeof input.locale && Object.keys(input).every(key => {
|
|
520
|
+
if (["title", "description", "pathname", "publishAt", "unpublishAt", "robots", "canonical", "id", "locale"].some(prop => key === prop))
|
|
521
|
+
return true;
|
|
522
|
+
const value = input[key];
|
|
523
|
+
if (undefined === value)
|
|
524
|
+
return true;
|
|
525
|
+
return true;
|
|
526
|
+
});
|
|
527
|
+
const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.title || _report(_exceptionable, {
|
|
528
|
+
path: _path + ".title",
|
|
529
|
+
expected: "string",
|
|
530
|
+
value: input.title
|
|
531
|
+
}), undefined === input.description || "string" === typeof input.description || _report(_exceptionable, {
|
|
532
|
+
path: _path + ".description",
|
|
533
|
+
expected: "(string | undefined)",
|
|
534
|
+
value: input.description
|
|
535
|
+
}), "string" === typeof input.pathname || _report(_exceptionable, {
|
|
536
|
+
path: _path + ".pathname",
|
|
537
|
+
expected: "string",
|
|
538
|
+
value: input.pathname
|
|
539
|
+
}), null === input.publishAt || undefined === input.publishAt || input.publishAt instanceof Date || _report(_exceptionable, {
|
|
540
|
+
path: _path + ".publishAt",
|
|
541
|
+
expected: "(Date | null | undefined)",
|
|
542
|
+
value: input.publishAt
|
|
543
|
+
}), null === input.unpublishAt || undefined === input.unpublishAt || input.unpublishAt instanceof Date || _report(_exceptionable, {
|
|
544
|
+
path: _path + ".unpublishAt",
|
|
545
|
+
expected: "(Date | null | undefined)",
|
|
546
|
+
value: input.unpublishAt
|
|
547
|
+
}), undefined === input.robots || "string" === typeof input.robots || _report(_exceptionable, {
|
|
548
|
+
path: _path + ".robots",
|
|
549
|
+
expected: "(string | undefined)",
|
|
550
|
+
value: input.robots
|
|
551
|
+
}), undefined === input.canonical || "string" === typeof input.canonical || _report(_exceptionable, {
|
|
552
|
+
path: _path + ".canonical",
|
|
553
|
+
expected: "(string | undefined)",
|
|
554
|
+
value: input.canonical
|
|
555
|
+
}), "string" === typeof input.id || _report(_exceptionable, {
|
|
556
|
+
path: _path + ".id",
|
|
557
|
+
expected: "string",
|
|
558
|
+
value: input.id
|
|
559
|
+
}), "string" === typeof input.locale || _report(_exceptionable, {
|
|
560
|
+
path: _path + ".locale",
|
|
561
|
+
expected: "string",
|
|
562
|
+
value: input.locale
|
|
563
|
+
}), false === _exceptionable || Object.keys(input).map(key => {
|
|
564
|
+
if (["title", "description", "pathname", "publishAt", "unpublishAt", "robots", "canonical", "id", "locale"].some(prop => key === prop))
|
|
565
|
+
return true;
|
|
566
|
+
const value = input[key];
|
|
567
|
+
if (undefined === value)
|
|
568
|
+
return true;
|
|
569
|
+
return true;
|
|
570
|
+
}).every(flag => flag)].every(flag => flag);
|
|
571
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
572
|
+
let errors;
|
|
573
|
+
let _report;
|
|
574
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
575
|
+
if (false === __is(input)) {
|
|
576
|
+
errors = [];
|
|
577
|
+
_report = _validateReport_1._validateReport(errors);
|
|
578
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
579
|
+
path: _path + "",
|
|
580
|
+
expected: "LoosePageMeta",
|
|
581
|
+
value: input
|
|
582
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
583
|
+
path: _path + "",
|
|
584
|
+
expected: "LoosePageMeta",
|
|
585
|
+
value: input
|
|
586
|
+
}))(input, "$input", true);
|
|
587
|
+
const success = 0 === errors.length;
|
|
588
|
+
return success ? {
|
|
589
|
+
success,
|
|
590
|
+
data: input
|
|
591
|
+
} : {
|
|
592
|
+
success,
|
|
593
|
+
errors,
|
|
594
|
+
data: input
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
return {
|
|
598
|
+
success: true,
|
|
599
|
+
data: input
|
|
600
|
+
};
|
|
601
|
+
});
|
|
602
|
+
})();
|
|
603
|
+
const validateLooseFragmentMeta = (() => {
|
|
604
|
+
const _io0 = input => "string" === typeof input.title && (undefined === input.description || "string" === typeof input.description) && (undefined === input.category || "string" === typeof input.category) && (undefined === input.tags || Array.isArray(input.tags) && input.tags.every(elem => "string" === typeof elem)) && "string" === typeof input.id && "string" === typeof input.locale && "string" === typeof input.name && Object.keys(input).every(key => {
|
|
605
|
+
if (["title", "description", "category", "tags", "id", "locale", "name"].some(prop => key === prop))
|
|
606
|
+
return true;
|
|
607
|
+
const value = input[key];
|
|
608
|
+
if (undefined === value)
|
|
609
|
+
return true;
|
|
610
|
+
return true;
|
|
611
|
+
});
|
|
612
|
+
const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.title || _report(_exceptionable, {
|
|
613
|
+
path: _path + ".title",
|
|
614
|
+
expected: "string",
|
|
615
|
+
value: input.title
|
|
616
|
+
}), undefined === input.description || "string" === typeof input.description || _report(_exceptionable, {
|
|
617
|
+
path: _path + ".description",
|
|
618
|
+
expected: "(string | undefined)",
|
|
619
|
+
value: input.description
|
|
620
|
+
}), undefined === input.category || "string" === typeof input.category || _report(_exceptionable, {
|
|
621
|
+
path: _path + ".category",
|
|
622
|
+
expected: "(string | undefined)",
|
|
623
|
+
value: input.category
|
|
624
|
+
}), undefined === input.tags || (Array.isArray(input.tags) || _report(_exceptionable, {
|
|
625
|
+
path: _path + ".tags",
|
|
626
|
+
expected: "(Array<string> | undefined)",
|
|
627
|
+
value: input.tags
|
|
628
|
+
})) && input.tags.map((elem, _index2) => "string" === typeof elem || _report(_exceptionable, {
|
|
629
|
+
path: _path + ".tags[" + _index2 + "]",
|
|
630
|
+
expected: "string",
|
|
631
|
+
value: elem
|
|
632
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
633
|
+
path: _path + ".tags",
|
|
634
|
+
expected: "(Array<string> | undefined)",
|
|
635
|
+
value: input.tags
|
|
636
|
+
}), "string" === typeof input.id || _report(_exceptionable, {
|
|
637
|
+
path: _path + ".id",
|
|
638
|
+
expected: "string",
|
|
639
|
+
value: input.id
|
|
640
|
+
}), "string" === typeof input.locale || _report(_exceptionable, {
|
|
641
|
+
path: _path + ".locale",
|
|
642
|
+
expected: "string",
|
|
643
|
+
value: input.locale
|
|
644
|
+
}), "string" === typeof input.name || _report(_exceptionable, {
|
|
645
|
+
path: _path + ".name",
|
|
646
|
+
expected: "string",
|
|
647
|
+
value: input.name
|
|
648
|
+
}), false === _exceptionable || Object.keys(input).map(key => {
|
|
649
|
+
if (["title", "description", "category", "tags", "id", "locale", "name"].some(prop => key === prop))
|
|
650
|
+
return true;
|
|
651
|
+
const value = input[key];
|
|
652
|
+
if (undefined === value)
|
|
653
|
+
return true;
|
|
654
|
+
return true;
|
|
655
|
+
}).every(flag => flag)].every(flag => flag);
|
|
656
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
657
|
+
let errors;
|
|
658
|
+
let _report;
|
|
659
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
660
|
+
if (false === __is(input)) {
|
|
661
|
+
errors = [];
|
|
662
|
+
_report = _validateReport_1._validateReport(errors);
|
|
663
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
664
|
+
path: _path + "",
|
|
665
|
+
expected: "LooseFragmentMeta",
|
|
666
|
+
value: input
|
|
667
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
668
|
+
path: _path + "",
|
|
669
|
+
expected: "LooseFragmentMeta",
|
|
670
|
+
value: input
|
|
671
|
+
}))(input, "$input", true);
|
|
672
|
+
const success = 0 === errors.length;
|
|
673
|
+
return success ? {
|
|
674
|
+
success,
|
|
675
|
+
data: input
|
|
676
|
+
} : {
|
|
677
|
+
success,
|
|
678
|
+
errors,
|
|
679
|
+
data: input
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
return {
|
|
683
|
+
success: true,
|
|
684
|
+
data: input
|
|
685
|
+
};
|
|
686
|
+
});
|
|
687
|
+
})();
|
|
688
|
+
const validateLooseDataMeta = (() => {
|
|
689
|
+
const _io0 = input => "string" === typeof input.title && (undefined === input.description || "string" === typeof input.description) && (undefined === input.category || "string" === typeof input.category) && (undefined === input.tags || Array.isArray(input.tags) && input.tags.every(elem => "string" === typeof elem)) && "string" === typeof input.id && "string" === typeof input.locale && "string" === typeof input.name && (undefined === input.data || "object" === typeof input.data && null !== input.data && false === Array.isArray(input.data) && _io1(input.data)) && Object.keys(input).every(key => {
|
|
690
|
+
if (["title", "description", "category", "tags", "id", "locale", "name", "data"].some(prop => key === prop))
|
|
691
|
+
return true;
|
|
692
|
+
const value = input[key];
|
|
693
|
+
if (undefined === value)
|
|
694
|
+
return true;
|
|
695
|
+
return true;
|
|
696
|
+
});
|
|
697
|
+
const _io1 = input => Object.keys(input).every(key => {
|
|
698
|
+
const value = input[key];
|
|
699
|
+
if (undefined === value)
|
|
700
|
+
return true;
|
|
701
|
+
return true;
|
|
702
|
+
});
|
|
703
|
+
const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.title || _report(_exceptionable, {
|
|
704
|
+
path: _path + ".title",
|
|
705
|
+
expected: "string",
|
|
706
|
+
value: input.title
|
|
707
|
+
}), undefined === input.description || "string" === typeof input.description || _report(_exceptionable, {
|
|
708
|
+
path: _path + ".description",
|
|
709
|
+
expected: "(string | undefined)",
|
|
710
|
+
value: input.description
|
|
711
|
+
}), undefined === input.category || "string" === typeof input.category || _report(_exceptionable, {
|
|
712
|
+
path: _path + ".category",
|
|
713
|
+
expected: "(string | undefined)",
|
|
714
|
+
value: input.category
|
|
715
|
+
}), undefined === input.tags || (Array.isArray(input.tags) || _report(_exceptionable, {
|
|
716
|
+
path: _path + ".tags",
|
|
717
|
+
expected: "(Array<string> | undefined)",
|
|
718
|
+
value: input.tags
|
|
719
|
+
})) && input.tags.map((elem, _index2) => "string" === typeof elem || _report(_exceptionable, {
|
|
720
|
+
path: _path + ".tags[" + _index2 + "]",
|
|
721
|
+
expected: "string",
|
|
722
|
+
value: elem
|
|
723
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
724
|
+
path: _path + ".tags",
|
|
725
|
+
expected: "(Array<string> | undefined)",
|
|
726
|
+
value: input.tags
|
|
727
|
+
}), "string" === typeof input.id || _report(_exceptionable, {
|
|
728
|
+
path: _path + ".id",
|
|
729
|
+
expected: "string",
|
|
730
|
+
value: input.id
|
|
731
|
+
}), "string" === typeof input.locale || _report(_exceptionable, {
|
|
732
|
+
path: _path + ".locale",
|
|
733
|
+
expected: "string",
|
|
734
|
+
value: input.locale
|
|
735
|
+
}), "string" === typeof input.name || _report(_exceptionable, {
|
|
736
|
+
path: _path + ".name",
|
|
737
|
+
expected: "string",
|
|
738
|
+
value: input.name
|
|
739
|
+
}), undefined === input.data || ("object" === typeof input.data && null !== input.data && false === Array.isArray(input.data) || _report(_exceptionable, {
|
|
740
|
+
path: _path + ".data",
|
|
741
|
+
expected: "(Record<string, unknown> | undefined)",
|
|
742
|
+
value: input.data
|
|
743
|
+
})) && _vo1(input.data, _path + ".data", true && _exceptionable) || _report(_exceptionable, {
|
|
744
|
+
path: _path + ".data",
|
|
745
|
+
expected: "(Record<string, unknown> | undefined)",
|
|
746
|
+
value: input.data
|
|
747
|
+
}), false === _exceptionable || Object.keys(input).map(key => {
|
|
748
|
+
if (["title", "description", "category", "tags", "id", "locale", "name", "data"].some(prop => key === prop))
|
|
749
|
+
return true;
|
|
750
|
+
const value = input[key];
|
|
751
|
+
if (undefined === value)
|
|
752
|
+
return true;
|
|
753
|
+
return true;
|
|
754
|
+
}).every(flag => flag)].every(flag => flag);
|
|
755
|
+
const _vo1 = (input, _path, _exceptionable = true) => [false === _exceptionable || Object.keys(input).map(key => {
|
|
756
|
+
const value = input[key];
|
|
757
|
+
if (undefined === value)
|
|
758
|
+
return true;
|
|
759
|
+
return true;
|
|
760
|
+
}).every(flag => flag)].every(flag => flag);
|
|
761
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
762
|
+
let errors;
|
|
763
|
+
let _report;
|
|
764
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
765
|
+
if (false === __is(input)) {
|
|
766
|
+
errors = [];
|
|
767
|
+
_report = _validateReport_1._validateReport(errors);
|
|
768
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
769
|
+
path: _path + "",
|
|
770
|
+
expected: "LooseDataMeta",
|
|
771
|
+
value: input
|
|
772
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
773
|
+
path: _path + "",
|
|
774
|
+
expected: "LooseDataMeta",
|
|
775
|
+
value: input
|
|
776
|
+
}))(input, "$input", true);
|
|
777
|
+
const success = 0 === errors.length;
|
|
778
|
+
return success ? {
|
|
779
|
+
success,
|
|
780
|
+
data: input
|
|
781
|
+
} : {
|
|
782
|
+
success,
|
|
783
|
+
errors,
|
|
784
|
+
data: input
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
return {
|
|
788
|
+
success: true,
|
|
789
|
+
data: input
|
|
790
|
+
};
|
|
791
|
+
});
|
|
792
|
+
})();
|
|
793
|
+
/** Typia's `IError` already carries path/expected/value; copy it so no Typia type reaches the public API. */
|
|
794
|
+
function toIssues(errors) {
|
|
795
|
+
return errors.map((error) => ({ path: error.path, expected: error.expected, value: error.value }));
|
|
796
|
+
}
|
|
797
|
+
/** Page shapes: the former `z.coerce.date()` and `z.string().url()` fields. */
|
|
798
|
+
const PAGE_EDITABLE_FIELDS = {
|
|
799
|
+
declared: [
|
|
800
|
+
"canonical",
|
|
801
|
+
"description",
|
|
802
|
+
"pathname",
|
|
803
|
+
"publishAt",
|
|
804
|
+
"robots",
|
|
805
|
+
"title",
|
|
806
|
+
"unpublishAt"
|
|
807
|
+
],
|
|
808
|
+
keepsUndeclared: false,
|
|
809
|
+
dates: PAGE_DATE_KEYS,
|
|
810
|
+
urls: PAGE_URL_KEYS,
|
|
811
|
+
};
|
|
812
|
+
const PAGE_META_FIELDS = { ...PAGE_EDITABLE_FIELDS, declared: PAGE_META_KEYS };
|
|
813
|
+
const LOOSE_PAGE_META_FIELDS = { ...PAGE_META_FIELDS, keepsUndeclared: true };
|
|
814
|
+
/** Fragment shapes: the `z.array()` tags. */
|
|
815
|
+
const FRAGMENT_EDITABLE_FIELDS = {
|
|
816
|
+
declared: [
|
|
817
|
+
"category",
|
|
818
|
+
"description",
|
|
819
|
+
"tags",
|
|
820
|
+
"title"
|
|
821
|
+
],
|
|
822
|
+
keepsUndeclared: false,
|
|
823
|
+
arrays: ['tags'],
|
|
824
|
+
};
|
|
825
|
+
const FRAGMENT_META_FIELDS = {
|
|
826
|
+
...FRAGMENT_EDITABLE_FIELDS,
|
|
827
|
+
declared: [
|
|
828
|
+
"category",
|
|
829
|
+
"description",
|
|
830
|
+
"id",
|
|
831
|
+
"locale",
|
|
832
|
+
"name",
|
|
833
|
+
"tags",
|
|
834
|
+
"title"
|
|
835
|
+
],
|
|
836
|
+
};
|
|
837
|
+
const LOOSE_FRAGMENT_META_FIELDS = { ...FRAGMENT_META_FIELDS, keepsUndeclared: true };
|
|
838
|
+
const MDX_PAGE_FRONTMATTER_FIELDS = {
|
|
839
|
+
declared: [
|
|
840
|
+
"description",
|
|
841
|
+
"draft",
|
|
842
|
+
"title"
|
|
843
|
+
],
|
|
844
|
+
keepsUndeclared: true,
|
|
845
|
+
};
|
|
846
|
+
/** Data shapes: the tags, plus the `z.record()` payload on the full one. */
|
|
847
|
+
const DATA_EDITABLE_FIELDS = {
|
|
848
|
+
declared: [
|
|
849
|
+
"category",
|
|
850
|
+
"description",
|
|
851
|
+
"tags",
|
|
852
|
+
"title"
|
|
853
|
+
],
|
|
854
|
+
keepsUndeclared: false,
|
|
855
|
+
arrays: ['tags'],
|
|
856
|
+
};
|
|
857
|
+
const DATA_META_FIELDS = {
|
|
858
|
+
declared: [
|
|
859
|
+
"category",
|
|
860
|
+
"data",
|
|
861
|
+
"description",
|
|
862
|
+
"id",
|
|
863
|
+
"locale",
|
|
864
|
+
"name",
|
|
865
|
+
"tags",
|
|
866
|
+
"title"
|
|
867
|
+
],
|
|
868
|
+
keepsUndeclared: false,
|
|
869
|
+
arrays: ['tags'],
|
|
870
|
+
records: ['data'],
|
|
871
|
+
};
|
|
872
|
+
const LOOSE_DATA_META_FIELDS = { ...DATA_META_FIELDS, keepsUndeclared: true };
|
|
873
|
+
/**
|
|
874
|
+
* Normalize, then validate, folding in the failures a generated validator
|
|
875
|
+
* cannot see: an Invalid Date (`new Date('nonsense')` is a `Date`, so every
|
|
876
|
+
* structural check passes while Zod rejected it as `expected: date`), a URL
|
|
877
|
+
* field the URL parser rejects, and a record field Zod's plain-object check
|
|
878
|
+
* rejected. A field the generated validator already reported is reported once.
|
|
879
|
+
*/
|
|
880
|
+
function parseWith(input, fields, validate) {
|
|
881
|
+
const { value, issues } = normalize(input, fields);
|
|
882
|
+
const result = validate(value);
|
|
883
|
+
if (!result.success) {
|
|
884
|
+
const reported = new Set(result.errors.map((error) => error.path));
|
|
885
|
+
return {
|
|
886
|
+
success: false,
|
|
887
|
+
issues: [...toIssues(result.errors), ...issues.filter((issue) => !reported.has(issue.path))],
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
if (issues.length > 0)
|
|
891
|
+
return { success: false, issues };
|
|
892
|
+
return { success: true, data: result.data };
|
|
893
|
+
}
|
|
894
|
+
/** Editable page fields: unknown keys stripped, `publishAt`/`unpublishAt` coerced to `Date`, `canonical` checked. */
|
|
895
|
+
export function parsePageEditable(input) {
|
|
896
|
+
return parseWith(input, PAGE_EDITABLE_FIELDS, validatePageEditable);
|
|
897
|
+
}
|
|
898
|
+
/** Full page metadata: editable fields plus `id`/`locale`, same strip, date coercion and URL check. */
|
|
899
|
+
export function parsePageMeta(input) {
|
|
900
|
+
return parseWith(input, PAGE_META_FIELDS, validatePageMeta);
|
|
901
|
+
}
|
|
902
|
+
/** Editable fragment fields; unknown keys stripped. */
|
|
903
|
+
export function parseFragmentEditable(input) {
|
|
904
|
+
return parseWith(input, FRAGMENT_EDITABLE_FIELDS, validateFragmentEditable);
|
|
905
|
+
}
|
|
906
|
+
/** Full fragment metadata: editable fields plus `id`/`locale`/`name`. */
|
|
907
|
+
export function parseFragmentMeta(input) {
|
|
908
|
+
return parseWith(input, FRAGMENT_META_FIELDS, validateFragmentMeta);
|
|
909
|
+
}
|
|
910
|
+
/** MDX page frontmatter; undeclared keys are preserved (the former `.passthrough()`). */
|
|
911
|
+
export function parseMdxPageFrontmatter(input) {
|
|
912
|
+
return parseWith(input, MDX_PAGE_FRONTMATTER_FIELDS, validateMdxPageFrontmatter);
|
|
913
|
+
}
|
|
914
|
+
/** Editable data-entry fields; unknown keys stripped. */
|
|
915
|
+
export function parseDataEditable(input) {
|
|
916
|
+
return parseWith(input, DATA_EDITABLE_FIELDS, validateDataEditable);
|
|
917
|
+
}
|
|
918
|
+
/** Full data-entry metadata: editable fields plus `id`/`locale`/`name` and the `data` payload. */
|
|
919
|
+
export function parseDataMeta(input) {
|
|
920
|
+
return parseWith(input, DATA_META_FIELDS, validateDataMeta);
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* A page collection entry: the declared page fields validated, dates coerced and
|
|
924
|
+
* `canonical` URL-checked, every undeclared top-level field kept (the former
|
|
925
|
+
* `pageMetaSchema.loose()`).
|
|
926
|
+
*/
|
|
927
|
+
export function parseLoosePageMeta(input) {
|
|
928
|
+
return parseWith(input, LOOSE_PAGE_META_FIELDS, validateLoosePageMeta);
|
|
929
|
+
}
|
|
930
|
+
/** A fragment collection entry; undeclared top-level fields kept (the former `fragmentMetaSchema.loose()`). */
|
|
931
|
+
export function parseLooseFragmentMeta(input) {
|
|
932
|
+
return parseWith(input, LOOSE_FRAGMENT_META_FIELDS, validateLooseFragmentMeta);
|
|
933
|
+
}
|
|
934
|
+
/** A data collection entry; undeclared top-level fields kept (the former `dataMetaSchema.loose()`). */
|
|
935
|
+
export function parseLooseDataMeta(input) {
|
|
936
|
+
return parseWith(input, LOOSE_DATA_META_FIELDS, validateLooseDataMeta);
|
|
937
|
+
}
|
|
938
|
+
//# sourceMappingURL=validators.js.map
|