@brydio/manifest 0.1.0-alpha.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.
@@ -0,0 +1,29 @@
1
+ import { appManifestSchema } from "./schema.js";
2
+ export function validateManifest(source) {
3
+ const parsed = appManifestSchema.safeParse(source);
4
+ if (parsed.success)
5
+ return { ok: true, manifest: parsed.data, problems: [] };
6
+ return {
7
+ ok: false,
8
+ problems: parsed.error.issues.map(issue => {
9
+ const params = issue.params;
10
+ const code = typeof params?.code === 'string' ? params.code : 'manifest_invalid';
11
+ const path = issue.path.map(String).join('.');
12
+ return { code, message: issue.message, ...(path ? { path } : {}) };
13
+ }),
14
+ };
15
+ }
16
+ /** Parses the text of `.brydio/app.json` and validates it. */
17
+ export function validateManifestText(text) {
18
+ let json;
19
+ try {
20
+ json = JSON.parse(text);
21
+ }
22
+ catch (error) {
23
+ return {
24
+ ok: false,
25
+ problems: [{ code: 'manifest_not_json', message: `The manifest is not valid JSON: ${error instanceof Error ? error.message : String(error)}` }],
26
+ };
27
+ }
28
+ return validateManifest(json);
29
+ }