@scopewatch/manifest 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ import type { ValidationError } from './schema.js';
2
+ /**
3
+ * Format validation errors as readable, actionable messages.
4
+ * Each error includes context, the problem, and a recovery suggestion.
5
+ */
6
+ export declare function formatValidationErrors(errors: ValidationError[]): string;
7
+ /**
8
+ * Render a validation error suitable for the CLI.
9
+ */
10
+ export declare function renderValidationError(errors: ValidationError[]): string;
11
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAyBxE;AAiFD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CASvE"}
package/dist/errors.js ADDED
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Format validation errors as readable, actionable messages.
3
+ * Each error includes context, the problem, and a recovery suggestion.
4
+ */
5
+ export function formatValidationErrors(errors) {
6
+ const lines = [];
7
+ for (const error of errors) {
8
+ const path = formatPath(error.path);
9
+ const context = path ? `at ${path}` : 'at root';
10
+ lines.push('');
11
+ lines.push(`❌ Manifest validation failed ${context}:`);
12
+ lines.push('');
13
+ lines.push(` ${error.message}`);
14
+ // Provide context-specific recovery suggestions
15
+ const suggestion = getRecoverySuggestion(error);
16
+ if (suggestion) {
17
+ lines.push('');
18
+ lines.push(suggestion);
19
+ }
20
+ }
21
+ if (lines.length === 0) {
22
+ return 'Manifest is valid.';
23
+ }
24
+ return lines.join('\n');
25
+ }
26
+ /**
27
+ * Convert path array to dot-notation string.
28
+ * E.g., ['capabilities', 0, 'tool_id'] → 'capabilities[0].tool_id'
29
+ */
30
+ function formatPath(path) {
31
+ if (path.length === 0)
32
+ return '';
33
+ return path.reduce((acc, segment, i) => {
34
+ if (typeof segment === 'number') {
35
+ return `${acc}[${segment}]`;
36
+ }
37
+ return i === 0 ? String(segment) : `${acc}.${segment}`;
38
+ }, '');
39
+ }
40
+ /**
41
+ * Provide contextual recovery suggestions based on error type.
42
+ */
43
+ function getRecoverySuggestion(error) {
44
+ const path = error.path.map(p => String(p)).join('.');
45
+ const code = error.code;
46
+ // Schema version mismatch
47
+ if (path === 'schemaVersion' && code === 'invalid_literal') {
48
+ return (` Fix: This tool only supports schemaVersion: 1.\n` +
49
+ ` If you have an older manifest, it must be migrated first.`);
50
+ }
51
+ // Version format
52
+ if (path === 'version' && code === 'invalid_string') {
53
+ return (` Fix: version must be semantic versioning (e.g., "1.2.0")\n` +
54
+ ` Current format is invalid.`);
55
+ }
56
+ // Missing required fields
57
+ if (code === 'invalid_union' || error.message.includes('Required')) {
58
+ const lastSegment = error.path[error.path.length - 1];
59
+ const field = typeof lastSegment === 'string' ? lastSegment : null;
60
+ if (field === 'tool_id') {
61
+ return (` Fix: Every capability must declare which tool provides it.\n` +
62
+ ` Add "tool_id": "my_tool_id" to this capability entry.`);
63
+ }
64
+ if (field === 'verb') {
65
+ return (` Fix: Every capability must declare a verb: one of\n` +
66
+ ` read | fetch | send | write | delete | execute`);
67
+ }
68
+ }
69
+ // Array minimum length
70
+ if (code === 'too_small') {
71
+ if (path === 'tools') {
72
+ return ` Fix: At least one tool must be declared.`;
73
+ }
74
+ if (path.includes('secrets') || path.includes('used_by')) {
75
+ return ` Fix: This array must not be empty.`;
76
+ }
77
+ }
78
+ // Invalid URL
79
+ if (code === 'invalid_string' && error.message.includes('URL')) {
80
+ return (` Fix: homepage must be a valid URL (e.g., "https://example.com")\n` +
81
+ ` Remove it if not applicable, or format it as a full URL.`);
82
+ }
83
+ return null;
84
+ }
85
+ /**
86
+ * Render a validation error suitable for the CLI.
87
+ */
88
+ export function renderValidationError(errors) {
89
+ if (errors.length === 0) {
90
+ return '✓ Manifest is valid.';
91
+ }
92
+ const header = errors.length === 1 ? 'Validation error:' : `${errors.length} validation errors:`;
93
+ const formatted = formatValidationErrors(errors);
94
+ return `${header}\n${formatted}`;
95
+ }
96
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAyB;IAC9D,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAEhD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,gCAAgC,OAAO,GAAG,CAAC,CAAC;QACvD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAEjC,gDAAgD;QAChD,MAAM,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAChD,IAAI,UAAU,EAAE,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CAAC,IAAy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ceSchema, CapabilityEntrySchema, SecretDeclarationSchema, ToolDeclarationSchema, SourceSchema, MetadataSchema, ServerManifestSchema, parseManifest, validateManifest, isServerManifest, type Verb, type Provenance, type CapabilityEntry, type SecretDeclaration, type ToolDeclaration, type Source, type Metadata, type ServerManifest, type ValidationResult, type ValidationError, } from './schema.js';
2
+ export { formatValidationErrors, renderValidationError } from './errors.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { VerbSchema, ProvenanceSchema, CapabilityEntrySchema, SecretDeclarationSchema, ToolDeclarationSchema, SourceSchema, MetadataSchema, ServerManifestSchema, parseManifest, validateManifest, isServerManifest, } from './schema.js';
2
+ export { formatValidationErrors, renderValidationError } from './errors.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GAWjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,246 @@
1
+ import { z } from 'zod';
2
+ export declare const VerbSchema: z.ZodEnum<["read", "fetch", "send", "write", "delete", "execute"]>;
3
+ export type Verb = z.infer<typeof VerbSchema>;
4
+ export declare const ProvenanceSchema: z.ZodEnum<["declared", "inferred"]>;
5
+ export type Provenance = z.infer<typeof ProvenanceSchema>;
6
+ export declare const CapabilityEntrySchema: z.ZodObject<{
7
+ tool_id: z.ZodString;
8
+ verb: z.ZodEnum<["read", "fetch", "send", "write", "delete", "execute"]>;
9
+ resource: z.ZodOptional<z.ZodString>;
10
+ provenance: z.ZodEnum<["declared", "inferred"]>;
11
+ description: z.ZodOptional<z.ZodString>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ tool_id: string;
14
+ verb: "read" | "fetch" | "send" | "write" | "delete" | "execute";
15
+ provenance: "declared" | "inferred";
16
+ resource?: string | undefined;
17
+ description?: string | undefined;
18
+ }, {
19
+ tool_id: string;
20
+ verb: "read" | "fetch" | "send" | "write" | "delete" | "execute";
21
+ provenance: "declared" | "inferred";
22
+ resource?: string | undefined;
23
+ description?: string | undefined;
24
+ }>;
25
+ export type CapabilityEntry = z.infer<typeof CapabilityEntrySchema>;
26
+ export declare const SecretDeclarationSchema: z.ZodObject<{
27
+ id: z.ZodString;
28
+ description: z.ZodString;
29
+ required: z.ZodBoolean;
30
+ used_by: z.ZodArray<z.ZodString, "many">;
31
+ }, "strip", z.ZodTypeAny, {
32
+ description: string;
33
+ id: string;
34
+ required: boolean;
35
+ used_by: string[];
36
+ }, {
37
+ description: string;
38
+ id: string;
39
+ required: boolean;
40
+ used_by: string[];
41
+ }>;
42
+ export type SecretDeclaration = z.infer<typeof SecretDeclarationSchema>;
43
+ export declare const ToolDeclarationSchema: z.ZodObject<{
44
+ id: z.ZodString;
45
+ name: z.ZodString;
46
+ description: z.ZodString;
47
+ }, "strip", z.ZodTypeAny, {
48
+ description: string;
49
+ id: string;
50
+ name: string;
51
+ }, {
52
+ description: string;
53
+ id: string;
54
+ name: string;
55
+ }>;
56
+ export type ToolDeclaration = z.infer<typeof ToolDeclarationSchema>;
57
+ export declare const SourceSchema: z.ZodObject<{
58
+ type: z.ZodEnum<["npm", "git", "local"]>;
59
+ location: z.ZodString;
60
+ }, "strip", z.ZodTypeAny, {
61
+ type: "npm" | "git" | "local";
62
+ location: string;
63
+ }, {
64
+ type: "npm" | "git" | "local";
65
+ location: string;
66
+ }>;
67
+ export type Source = z.infer<typeof SourceSchema>;
68
+ export declare const MetadataSchema: z.ZodOptional<z.ZodObject<{
69
+ author: z.ZodOptional<z.ZodString>;
70
+ license: z.ZodOptional<z.ZodString>;
71
+ homepage: z.ZodOptional<z.ZodString>;
72
+ }, "strip", z.ZodTypeAny, {
73
+ author?: string | undefined;
74
+ license?: string | undefined;
75
+ homepage?: string | undefined;
76
+ }, {
77
+ author?: string | undefined;
78
+ license?: string | undefined;
79
+ homepage?: string | undefined;
80
+ }>>;
81
+ export type Metadata = z.infer<typeof MetadataSchema>;
82
+ export declare const ServerManifestSchema: z.ZodObject<{
83
+ schemaVersion: z.ZodLiteral<1>;
84
+ version: z.ZodString;
85
+ source: z.ZodObject<{
86
+ type: z.ZodEnum<["npm", "git", "local"]>;
87
+ location: z.ZodString;
88
+ }, "strip", z.ZodTypeAny, {
89
+ type: "npm" | "git" | "local";
90
+ location: string;
91
+ }, {
92
+ type: "npm" | "git" | "local";
93
+ location: string;
94
+ }>;
95
+ checksum: z.ZodString;
96
+ tools: z.ZodArray<z.ZodObject<{
97
+ id: z.ZodString;
98
+ name: z.ZodString;
99
+ description: z.ZodString;
100
+ }, "strip", z.ZodTypeAny, {
101
+ description: string;
102
+ id: string;
103
+ name: string;
104
+ }, {
105
+ description: string;
106
+ id: string;
107
+ name: string;
108
+ }>, "many">;
109
+ capabilities: z.ZodArray<z.ZodObject<{
110
+ tool_id: z.ZodString;
111
+ verb: z.ZodEnum<["read", "fetch", "send", "write", "delete", "execute"]>;
112
+ resource: z.ZodOptional<z.ZodString>;
113
+ provenance: z.ZodEnum<["declared", "inferred"]>;
114
+ description: z.ZodOptional<z.ZodString>;
115
+ }, "strip", z.ZodTypeAny, {
116
+ tool_id: string;
117
+ verb: "read" | "fetch" | "send" | "write" | "delete" | "execute";
118
+ provenance: "declared" | "inferred";
119
+ resource?: string | undefined;
120
+ description?: string | undefined;
121
+ }, {
122
+ tool_id: string;
123
+ verb: "read" | "fetch" | "send" | "write" | "delete" | "execute";
124
+ provenance: "declared" | "inferred";
125
+ resource?: string | undefined;
126
+ description?: string | undefined;
127
+ }>, "many">;
128
+ secrets: z.ZodArray<z.ZodObject<{
129
+ id: z.ZodString;
130
+ description: z.ZodString;
131
+ required: z.ZodBoolean;
132
+ used_by: z.ZodArray<z.ZodString, "many">;
133
+ }, "strip", z.ZodTypeAny, {
134
+ description: string;
135
+ id: string;
136
+ required: boolean;
137
+ used_by: string[];
138
+ }, {
139
+ description: string;
140
+ id: string;
141
+ required: boolean;
142
+ used_by: string[];
143
+ }>, "many">;
144
+ metadata: z.ZodOptional<z.ZodObject<{
145
+ author: z.ZodOptional<z.ZodString>;
146
+ license: z.ZodOptional<z.ZodString>;
147
+ homepage: z.ZodOptional<z.ZodString>;
148
+ }, "strip", z.ZodTypeAny, {
149
+ author?: string | undefined;
150
+ license?: string | undefined;
151
+ homepage?: string | undefined;
152
+ }, {
153
+ author?: string | undefined;
154
+ license?: string | undefined;
155
+ homepage?: string | undefined;
156
+ }>>;
157
+ }, "strip", z.ZodTypeAny, {
158
+ schemaVersion: 1;
159
+ version: string;
160
+ source: {
161
+ type: "npm" | "git" | "local";
162
+ location: string;
163
+ };
164
+ checksum: string;
165
+ tools: {
166
+ description: string;
167
+ id: string;
168
+ name: string;
169
+ }[];
170
+ capabilities: {
171
+ tool_id: string;
172
+ verb: "read" | "fetch" | "send" | "write" | "delete" | "execute";
173
+ provenance: "declared" | "inferred";
174
+ resource?: string | undefined;
175
+ description?: string | undefined;
176
+ }[];
177
+ secrets: {
178
+ description: string;
179
+ id: string;
180
+ required: boolean;
181
+ used_by: string[];
182
+ }[];
183
+ metadata?: {
184
+ author?: string | undefined;
185
+ license?: string | undefined;
186
+ homepage?: string | undefined;
187
+ } | undefined;
188
+ }, {
189
+ schemaVersion: 1;
190
+ version: string;
191
+ source: {
192
+ type: "npm" | "git" | "local";
193
+ location: string;
194
+ };
195
+ checksum: string;
196
+ tools: {
197
+ description: string;
198
+ id: string;
199
+ name: string;
200
+ }[];
201
+ capabilities: {
202
+ tool_id: string;
203
+ verb: "read" | "fetch" | "send" | "write" | "delete" | "execute";
204
+ provenance: "declared" | "inferred";
205
+ resource?: string | undefined;
206
+ description?: string | undefined;
207
+ }[];
208
+ secrets: {
209
+ description: string;
210
+ id: string;
211
+ required: boolean;
212
+ used_by: string[];
213
+ }[];
214
+ metadata?: {
215
+ author?: string | undefined;
216
+ license?: string | undefined;
217
+ homepage?: string | undefined;
218
+ } | undefined;
219
+ }>;
220
+ export type ServerManifest = z.infer<typeof ServerManifestSchema>;
221
+ export type ValidationResult<T> = {
222
+ ok: true;
223
+ value: T;
224
+ } | {
225
+ ok: false;
226
+ errors: ValidationError[];
227
+ };
228
+ export interface ValidationError {
229
+ path: (string | number)[];
230
+ message: string;
231
+ code: string;
232
+ }
233
+ /**
234
+ * Parse and validate a server manifest from JSON.
235
+ * Returns detailed, human-readable errors on failure.
236
+ */
237
+ export declare function parseManifest(input: unknown): ValidationResult<ServerManifest>;
238
+ /**
239
+ * Validate a manifest instance. Useful after round-trip deserialization.
240
+ */
241
+ export declare function validateManifest(manifest: unknown): ValidationResult<ServerManifest>;
242
+ /**
243
+ * Type guard: is this a valid ServerManifest?
244
+ */
245
+ export declare function isServerManifest(value: unknown): value is ServerManifest;
246
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceR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CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAGlE,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAC1B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACtB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC;AAE7C,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAc9E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAEpF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAGxE"}
package/dist/schema.js ADDED
@@ -0,0 +1,85 @@
1
+ import { z } from 'zod';
2
+ // Verb vocabulary: each maps to a distinct threat model
3
+ export const VerbSchema = z.enum([
4
+ 'read', // read access to data
5
+ 'fetch', // reach out and pull something back (SSRF/prompt-injection risk)
6
+ 'send', // push data externally (exfiltration risk)
7
+ 'write', // write access to data
8
+ 'delete', // delete data
9
+ 'execute', // execute commands/code
10
+ ]);
11
+ // Provenance: was this verb declared explicitly or inferred from tool analysis?
12
+ export const ProvenanceSchema = z.enum(['declared', 'inferred']);
13
+ // A single capability granted by a tool
14
+ export const CapabilityEntrySchema = z.object({
15
+ tool_id: z.string().min(1, 'tool_id must not be empty'),
16
+ verb: VerbSchema,
17
+ resource: z.string().optional().describe('Resource identifier (e.g., "repo:owner/name", "filesystem:/*")'),
18
+ provenance: ProvenanceSchema,
19
+ description: z.string().optional().describe('Explanation for inferred verbs'),
20
+ });
21
+ // A secret required by one or more tools
22
+ export const SecretDeclarationSchema = z.object({
23
+ id: z.string().min(1, 'Secret id must not be empty').regex(/^[A-Z_][A-Z0-9_]*$/, 'Secret id must be uppercase with underscores'),
24
+ description: z.string().min(1, 'description must not be empty'),
25
+ required: z.boolean(),
26
+ used_by: z.array(z.string().min(1)).describe('tool_ids that reference this secret'),
27
+ });
28
+ // Minimal tool metadata (capabilities are hoisted to manifest root)
29
+ export const ToolDeclarationSchema = z.object({
30
+ id: z.string().min(1, 'tool id must not be empty'),
31
+ name: z.string().min(1, 'name must not be empty'),
32
+ description: z.string().min(1, 'description must not be empty'),
33
+ });
34
+ // Source location for the server
35
+ export const SourceSchema = z.object({
36
+ type: z.enum(['npm', 'git', 'local']).describe('Source type'),
37
+ location: z.string().min(1, 'location must not be empty').describe('Package name, git URL, or local path'),
38
+ });
39
+ // Optional metadata about the server
40
+ export const MetadataSchema = z.object({
41
+ author: z.string().optional(),
42
+ license: z.string().optional(),
43
+ homepage: z.string().url('homepage must be a valid URL').optional(),
44
+ }).optional();
45
+ // The canonical server manifest
46
+ export const ServerManifestSchema = z.object({
47
+ schemaVersion: z.literal(1).describe('Manifest schema version'),
48
+ version: z.string().regex(/^\d+\.\d+\.\d+$/, 'version must be semver (e.g., "1.2.0")'),
49
+ source: SourceSchema,
50
+ checksum: z.string().min(1, 'checksum must not be empty').describe('sha256 hash of server artifact'),
51
+ tools: z.array(ToolDeclarationSchema).min(1, 'at least one tool must be declared'),
52
+ capabilities: z.array(CapabilityEntrySchema).min(0).describe('Hoisted to root for diff clarity'),
53
+ secrets: z.array(SecretDeclarationSchema).min(0).describe('Secrets with usage tracking'),
54
+ metadata: MetadataSchema,
55
+ });
56
+ /**
57
+ * Parse and validate a server manifest from JSON.
58
+ * Returns detailed, human-readable errors on failure.
59
+ */
60
+ export function parseManifest(input) {
61
+ const result = ServerManifestSchema.safeParse(input);
62
+ if (result.success) {
63
+ return { ok: true, value: result.data };
64
+ }
65
+ const errors = result.error.issues.map(issue => ({
66
+ path: issue.path,
67
+ message: issue.message,
68
+ code: issue.code,
69
+ }));
70
+ return { ok: false, errors };
71
+ }
72
+ /**
73
+ * Validate a manifest instance. Useful after round-trip deserialization.
74
+ */
75
+ export function validateManifest(manifest) {
76
+ return parseManifest(manifest);
77
+ }
78
+ /**
79
+ * Type guard: is this a valid ServerManifest?
80
+ */
81
+ export function isServerManifest(value) {
82
+ const result = ServerManifestSchema.safeParse(value);
83
+ return result.success;
84
+ }
85
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wDAAwD;AACxD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC;IAC/B,MAAM,EAAK,sBAAsB;IACjC,OAAO,EAAI,iEAAiE;IAC5E,MAAM,EAAK,2CAA2C;IACtD,OAAO,EAAI,uBAAuB;IAClC,QAAQ,EAAG,cAAc;IACzB,SAAS,EAAE,wBAAwB;CACpC,CAAC,CAAC;AAIH,gFAAgF;AAChF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AAGjE,wCAAwC;AACxC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,2BAA2B,CAAC;IACvD,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gEAAgE,CAAC;IAC1G,UAAU,EAAE,gBAAgB;IAC5B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAA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C,CAAC;IAErD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC1C,CAAC;IAED,MAAM,MAAM,GAAsB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAClE,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC,CAAC;IAEJ,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAiB;IAChD,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,MAAM,MAAM,GAAG,oBAAoB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@scopewatch/manifest",
3
+ "version": "0.0.1",
4
+ "description": "Manifest schema, parsing, validation, and migrations",
5
+ "license": "MIT",
6
+ "author": "Sathvik Putta <puttasathvik16@gmail.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/PuttaSathvik16/scopewatch.git",
10
+ "directory": "packages/manifest"
11
+ },
12
+ "type": "module",
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "import": "./dist/index.js",
18
+ "types": "./dist/index.d.ts"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "scripts": {
25
+ "build": "tsc",
26
+ "test": "node --test --loader tsx 'test/**/*.test.ts'",
27
+ "clean": "rm -rf dist"
28
+ },
29
+ "dependencies": {
30
+ "zod": "^3.24.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^22.0.0",
34
+ "typescript": "^5.7.0",
35
+ "tsx": "^4.19.0"
36
+ }
37
+ }