@snipl/registry-schema 1.0.0-next.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.
- package/LICENSE +21 -0
- package/dist/src/errors.d.ts +38 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +44 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/manifest.d.ts +99 -0
- package/dist/src/manifest.d.ts.map +1 -0
- package/dist/src/manifest.js +19 -0
- package/dist/src/manifest.js.map +1 -0
- package/dist/src/registry-item.d.ts +262 -0
- package/dist/src/registry-item.d.ts.map +1 -0
- package/dist/src/registry-item.js +74 -0
- package/dist/src/registry-item.js.map +1 -0
- package/dist/src/snippets-config.d.ts +34 -0
- package/dist/src/snippets-config.d.ts.map +1 -0
- package/dist/src/snippets-config.js +15 -0
- package/dist/src/snippets-config.js.map +1 -0
- package/dist/src/spdx.d.ts +3 -0
- package/dist/src/spdx.d.ts.map +1 -0
- package/dist/src/spdx.js +20 -0
- package/dist/src/spdx.js.map +1 -0
- package/dist/src/strings.d.ts +7 -0
- package/dist/src/strings.d.ts.map +1 -0
- package/dist/src/strings.js +19 -0
- package/dist/src/strings.js.map +1 -0
- package/dist/src/validation.d.ts +11 -0
- package/dist/src/validation.d.ts.map +1 -0
- package/dist/src/validation.js +55 -0
- package/dist/src/validation.js.map +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Snippet CLI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const ErrorCode: {
|
|
2
|
+
readonly INVALID_SCHEMA_VERSION: "INVALID_SCHEMA_VERSION";
|
|
3
|
+
readonly INVALID_NAME: "INVALID_NAME";
|
|
4
|
+
readonly INVALID_VERSION: "INVALID_VERSION";
|
|
5
|
+
readonly INVALID_HASH: "INVALID_HASH";
|
|
6
|
+
readonly INVALID_PATH: "INVALID_PATH";
|
|
7
|
+
readonly INVALID_PATH_TRAVERSAL: "INVALID_PATH_TRAVERSAL";
|
|
8
|
+
readonly INVALID_PATH_ABSOLUTE: "INVALID_PATH_ABSOLUTE";
|
|
9
|
+
readonly INVALID_LICENSE: "INVALID_LICENSE";
|
|
10
|
+
readonly INVALID_LICENSE_SOURCE: "INVALID_LICENSE_SOURCE";
|
|
11
|
+
readonly INVALID_ENVIRONMENT: "INVALID_ENVIRONMENT";
|
|
12
|
+
readonly INVALID_LANGUAGE: "INVALID_LANGUAGE";
|
|
13
|
+
readonly INVALID_EXPORT_KIND: "INVALID_EXPORT_KIND";
|
|
14
|
+
readonly INVALID_CONTENT_EMPTY: "INVALID_CONTENT_EMPTY";
|
|
15
|
+
readonly DUPLICATE_FILE_PATH: "DUPLICATE_FILE_PATH";
|
|
16
|
+
readonly DEPENDENCIES_NOT_EMPTY: "DEPENDENCIES_NOT_EMPTY";
|
|
17
|
+
readonly TEMPLATE_VARIABLES_NOT_EMPTY: "TEMPLATE_VARIABLES_NOT_EMPTY";
|
|
18
|
+
readonly MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD";
|
|
19
|
+
readonly MALFORMED_JSON: "MALFORMED_JSON";
|
|
20
|
+
readonly ATTRIBUTION_REQUIRED: "ATTRIBUTION_REQUIRED";
|
|
21
|
+
readonly INVALID_SPDX: "INVALID_SPDX";
|
|
22
|
+
readonly INVALID_REGISTRY_SOURCE: "INVALID_REGISTRY_SOURCE";
|
|
23
|
+
readonly INVALID_DATE: "INVALID_DATE";
|
|
24
|
+
readonly ARRAY_SIZE_EXCEEDED: "ARRAY_SIZE_EXCEEDED";
|
|
25
|
+
readonly INVALID_TAG: "INVALID_TAG";
|
|
26
|
+
};
|
|
27
|
+
export type ErrorCodeType = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
28
|
+
export declare class ValidationError extends Error {
|
|
29
|
+
readonly code: ErrorCodeType;
|
|
30
|
+
readonly path: string;
|
|
31
|
+
constructor(code: ErrorCodeType, message: string, path: string);
|
|
32
|
+
toJSON(): {
|
|
33
|
+
code: ErrorCodeType;
|
|
34
|
+
message: string;
|
|
35
|
+
path: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;CAyBZ,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAEvE,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,IAAI,EAAE,aAAa,CAAC;IACpC,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAO9D,MAAM,IAAI;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAOjE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const ErrorCode = {
|
|
2
|
+
INVALID_SCHEMA_VERSION: 'INVALID_SCHEMA_VERSION',
|
|
3
|
+
INVALID_NAME: 'INVALID_NAME',
|
|
4
|
+
INVALID_VERSION: 'INVALID_VERSION',
|
|
5
|
+
INVALID_HASH: 'INVALID_HASH',
|
|
6
|
+
INVALID_PATH: 'INVALID_PATH',
|
|
7
|
+
INVALID_PATH_TRAVERSAL: 'INVALID_PATH_TRAVERSAL',
|
|
8
|
+
INVALID_PATH_ABSOLUTE: 'INVALID_PATH_ABSOLUTE',
|
|
9
|
+
INVALID_LICENSE: 'INVALID_LICENSE',
|
|
10
|
+
INVALID_LICENSE_SOURCE: 'INVALID_LICENSE_SOURCE',
|
|
11
|
+
INVALID_ENVIRONMENT: 'INVALID_ENVIRONMENT',
|
|
12
|
+
INVALID_LANGUAGE: 'INVALID_LANGUAGE',
|
|
13
|
+
INVALID_EXPORT_KIND: 'INVALID_EXPORT_KIND',
|
|
14
|
+
INVALID_CONTENT_EMPTY: 'INVALID_CONTENT_EMPTY',
|
|
15
|
+
DUPLICATE_FILE_PATH: 'DUPLICATE_FILE_PATH',
|
|
16
|
+
DEPENDENCIES_NOT_EMPTY: 'DEPENDENCIES_NOT_EMPTY',
|
|
17
|
+
TEMPLATE_VARIABLES_NOT_EMPTY: 'TEMPLATE_VARIABLES_NOT_EMPTY',
|
|
18
|
+
MISSING_REQUIRED_FIELD: 'MISSING_REQUIRED_FIELD',
|
|
19
|
+
MALFORMED_JSON: 'MALFORMED_JSON',
|
|
20
|
+
ATTRIBUTION_REQUIRED: 'ATTRIBUTION_REQUIRED',
|
|
21
|
+
INVALID_SPDX: 'INVALID_SPDX',
|
|
22
|
+
INVALID_REGISTRY_SOURCE: 'INVALID_REGISTRY_SOURCE',
|
|
23
|
+
INVALID_DATE: 'INVALID_DATE',
|
|
24
|
+
ARRAY_SIZE_EXCEEDED: 'ARRAY_SIZE_EXCEEDED',
|
|
25
|
+
INVALID_TAG: 'INVALID_TAG',
|
|
26
|
+
};
|
|
27
|
+
export class ValidationError extends Error {
|
|
28
|
+
code;
|
|
29
|
+
path;
|
|
30
|
+
constructor(code, message, path) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = 'ValidationError';
|
|
33
|
+
this.code = code;
|
|
34
|
+
this.path = path;
|
|
35
|
+
}
|
|
36
|
+
toJSON() {
|
|
37
|
+
return {
|
|
38
|
+
code: this.code,
|
|
39
|
+
message: this.message,
|
|
40
|
+
path: this.path,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,sBAAsB,EAAE,wBAAwB;IAChD,YAAY,EAAE,cAAc;IAC5B,eAAe,EAAE,iBAAiB;IAClC,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;IAC5B,sBAAsB,EAAE,wBAAwB;IAChD,qBAAqB,EAAE,uBAAuB;IAC9C,eAAe,EAAE,iBAAiB;IAClC,sBAAsB,EAAE,wBAAwB;IAChD,mBAAmB,EAAE,qBAAqB;IAC1C,gBAAgB,EAAE,kBAAkB;IACpC,mBAAmB,EAAE,qBAAqB;IAC1C,qBAAqB,EAAE,uBAAuB;IAC9C,mBAAmB,EAAE,qBAAqB;IAC1C,sBAAsB,EAAE,wBAAwB;IAChD,4BAA4B,EAAE,8BAA8B;IAC5D,sBAAsB,EAAE,wBAAwB;IAChD,cAAc,EAAE,gBAAgB;IAChC,oBAAoB,EAAE,sBAAsB;IAC5C,YAAY,EAAE,cAAc;IAC5B,uBAAuB,EAAE,yBAAyB;IAClD,YAAY,EAAE,cAAc;IAC5B,mBAAmB,EAAE,qBAAqB;IAC1C,WAAW,EAAE,aAAa;CAClB,CAAC;AAIX,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxB,IAAI,CAAgB;IACpB,IAAI,CAAS;IAE7B,YAAY,IAAmB,EAAE,OAAe,EAAE,IAAY;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { SnippetConfigSchema } from './snippets-config.js';
|
|
2
|
+
export type { SnippetConfig } from './snippets-config.js';
|
|
3
|
+
export { RegistryItemSchema } from './registry-item.js';
|
|
4
|
+
export type { RegistryItem } from './registry-item.js';
|
|
5
|
+
export { ManifestSchema, InstalledItemSchema } from './manifest.js';
|
|
6
|
+
export type { Manifest, InstalledItem } from './manifest.js';
|
|
7
|
+
export { ValidationError, ErrorCode } from './errors.js';
|
|
8
|
+
export type { ErrorCodeType } from './errors.js';
|
|
9
|
+
export { SPDX_ALLOW_LIST } from './spdx.js';
|
|
10
|
+
export type { SpdxId } from './spdx.js';
|
|
11
|
+
export { safeParse } from './validation.js';
|
|
12
|
+
export type { ParseResult } from './validation.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,YAAY,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { SnippetConfigSchema } from './snippets-config.js';
|
|
2
|
+
export { RegistryItemSchema } from './registry-item.js';
|
|
3
|
+
export { ManifestSchema, InstalledItemSchema } from './manifest.js';
|
|
4
|
+
export { ValidationError, ErrorCode } from './errors.js';
|
|
5
|
+
export { SPDX_ALLOW_LIST } from './spdx.js';
|
|
6
|
+
export { safeParse } from './validation.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAG5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const InstalledItemSchema: z.ZodObject<{
|
|
3
|
+
registry: z.ZodString;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
version: z.ZodString;
|
|
6
|
+
installedAt: z.ZodString;
|
|
7
|
+
files: z.ZodArray<z.ZodObject<{
|
|
8
|
+
path: z.ZodString;
|
|
9
|
+
sha256: z.ZodString;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
path: string;
|
|
12
|
+
sha256: string;
|
|
13
|
+
}, {
|
|
14
|
+
path: string;
|
|
15
|
+
sha256: string;
|
|
16
|
+
}>, "many">;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
name: string;
|
|
19
|
+
version: string;
|
|
20
|
+
files: {
|
|
21
|
+
path: string;
|
|
22
|
+
sha256: string;
|
|
23
|
+
}[];
|
|
24
|
+
registry: string;
|
|
25
|
+
installedAt: string;
|
|
26
|
+
}, {
|
|
27
|
+
name: string;
|
|
28
|
+
version: string;
|
|
29
|
+
files: {
|
|
30
|
+
path: string;
|
|
31
|
+
sha256: string;
|
|
32
|
+
}[];
|
|
33
|
+
registry: string;
|
|
34
|
+
installedAt: string;
|
|
35
|
+
}>;
|
|
36
|
+
export type InstalledItem = z.infer<typeof InstalledItemSchema>;
|
|
37
|
+
export declare const ManifestSchema: z.ZodObject<{
|
|
38
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
39
|
+
items: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
40
|
+
registry: z.ZodString;
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
version: z.ZodString;
|
|
43
|
+
installedAt: z.ZodString;
|
|
44
|
+
files: z.ZodArray<z.ZodObject<{
|
|
45
|
+
path: z.ZodString;
|
|
46
|
+
sha256: z.ZodString;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
path: string;
|
|
49
|
+
sha256: string;
|
|
50
|
+
}, {
|
|
51
|
+
path: string;
|
|
52
|
+
sha256: string;
|
|
53
|
+
}>, "many">;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
name: string;
|
|
56
|
+
version: string;
|
|
57
|
+
files: {
|
|
58
|
+
path: string;
|
|
59
|
+
sha256: string;
|
|
60
|
+
}[];
|
|
61
|
+
registry: string;
|
|
62
|
+
installedAt: string;
|
|
63
|
+
}, {
|
|
64
|
+
name: string;
|
|
65
|
+
version: string;
|
|
66
|
+
files: {
|
|
67
|
+
path: string;
|
|
68
|
+
sha256: string;
|
|
69
|
+
}[];
|
|
70
|
+
registry: string;
|
|
71
|
+
installedAt: string;
|
|
72
|
+
}>, "many">>;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
schemaVersion: 1;
|
|
75
|
+
items: {
|
|
76
|
+
name: string;
|
|
77
|
+
version: string;
|
|
78
|
+
files: {
|
|
79
|
+
path: string;
|
|
80
|
+
sha256: string;
|
|
81
|
+
}[];
|
|
82
|
+
registry: string;
|
|
83
|
+
installedAt: string;
|
|
84
|
+
}[];
|
|
85
|
+
}, {
|
|
86
|
+
schemaVersion: 1;
|
|
87
|
+
items?: {
|
|
88
|
+
name: string;
|
|
89
|
+
version: string;
|
|
90
|
+
files: {
|
|
91
|
+
path: string;
|
|
92
|
+
sha256: string;
|
|
93
|
+
}[];
|
|
94
|
+
registry: string;
|
|
95
|
+
installedAt: string;
|
|
96
|
+
}[] | undefined;
|
|
97
|
+
}>;
|
|
98
|
+
export type Manifest = z.infer<typeof ManifestSchema>;
|
|
99
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { kebabCaseString, semverString, sha256Hex, relativePosixPath } from './strings.js';
|
|
3
|
+
const MAX_MANIFEST_ITEMS = 200;
|
|
4
|
+
const installedFileSchema = z.object({
|
|
5
|
+
path: relativePosixPath,
|
|
6
|
+
sha256: sha256Hex,
|
|
7
|
+
});
|
|
8
|
+
export const InstalledItemSchema = z.object({
|
|
9
|
+
registry: kebabCaseString,
|
|
10
|
+
name: kebabCaseString,
|
|
11
|
+
version: semverString,
|
|
12
|
+
installedAt: z.string().datetime(),
|
|
13
|
+
files: z.array(installedFileSchema).min(1),
|
|
14
|
+
});
|
|
15
|
+
export const ManifestSchema = z.object({
|
|
16
|
+
schemaVersion: z.literal(1),
|
|
17
|
+
items: z.array(InstalledItemSchema).max(MAX_MANIFEST_ITEMS).default([]),
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE3F,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,iBAAiB;IACvB,MAAM,EAAE,SAAS;CAClB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,QAAQ,EAAE,eAAe;IACzB,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,YAAY;IACrB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC3C,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CACxE,CAAC,CAAC"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const RegistryItemSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
3
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
version: z.ZodString;
|
|
6
|
+
summary: z.ZodString;
|
|
7
|
+
tags: z.ZodArray<z.ZodString, "many">;
|
|
8
|
+
language: z.ZodEnum<["ts", "js"]>;
|
|
9
|
+
environments: z.ZodArray<z.ZodEnum<["browser", "node", "universal"]>, "many">;
|
|
10
|
+
exports: z.ZodArray<z.ZodObject<{
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
kind: z.ZodEnum<["function", "type", "class"]>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
name: string;
|
|
15
|
+
kind: "function" | "type" | "class";
|
|
16
|
+
}, {
|
|
17
|
+
name: string;
|
|
18
|
+
kind: "function" | "type" | "class";
|
|
19
|
+
}>, "many">;
|
|
20
|
+
files: z.ZodArray<z.ZodObject<{
|
|
21
|
+
path: z.ZodString;
|
|
22
|
+
content: z.ZodString;
|
|
23
|
+
sha256: z.ZodString;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
path: string;
|
|
26
|
+
content: string;
|
|
27
|
+
sha256: string;
|
|
28
|
+
}, {
|
|
29
|
+
path: string;
|
|
30
|
+
content: string;
|
|
31
|
+
sha256: string;
|
|
32
|
+
}>, "many">;
|
|
33
|
+
dependencies: z.ZodTuple<[], null>;
|
|
34
|
+
templateVariables: z.ZodTuple<[], null>;
|
|
35
|
+
license: z.ZodObject<{
|
|
36
|
+
spdx: z.ZodEnum<["MIT", "Apache-2.0", "BSD-2-Clause", "BSD-3-Clause", "ISC", "Unlicense", "CC0-1.0", "MPL-2.0", "LGPL-2.1-only", "LGPL-2.1-or-later", "LGPL-3.0-only", "LGPL-3.0-or-later", "GPL-2.0-only", "GPL-2.0-or-later", "GPL-3.0-only", "GPL-3.0-or-later", "0BSD"]>;
|
|
37
|
+
source: z.ZodEnum<["original", "derived"]>;
|
|
38
|
+
attribution: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
source: "original" | "derived";
|
|
41
|
+
spdx: "MIT" | "Apache-2.0" | "BSD-2-Clause" | "BSD-3-Clause" | "ISC" | "Unlicense" | "CC0-1.0" | "MPL-2.0" | "LGPL-2.1-only" | "LGPL-2.1-or-later" | "LGPL-3.0-only" | "LGPL-3.0-or-later" | "GPL-2.0-only" | "GPL-2.0-or-later" | "GPL-3.0-only" | "GPL-3.0-or-later" | "0BSD";
|
|
42
|
+
attribution?: string | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
source: "original" | "derived";
|
|
45
|
+
spdx: "MIT" | "Apache-2.0" | "BSD-2-Clause" | "BSD-3-Clause" | "ISC" | "Unlicense" | "CC0-1.0" | "MPL-2.0" | "LGPL-2.1-only" | "LGPL-2.1-or-later" | "LGPL-3.0-only" | "LGPL-3.0-or-later" | "GPL-2.0-only" | "GPL-2.0-or-later" | "GPL-3.0-only" | "GPL-3.0-or-later" | "0BSD";
|
|
46
|
+
attribution?: string | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
tests: z.ZodArray<z.ZodObject<{
|
|
49
|
+
path: z.ZodString;
|
|
50
|
+
content: z.ZodString;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
path: string;
|
|
53
|
+
content: string;
|
|
54
|
+
}, {
|
|
55
|
+
path: string;
|
|
56
|
+
content: string;
|
|
57
|
+
}>, "many">;
|
|
58
|
+
docs: z.ZodObject<{
|
|
59
|
+
usage: z.ZodString;
|
|
60
|
+
caveats: z.ZodArray<z.ZodString, "many">;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
usage: string;
|
|
63
|
+
caveats: string[];
|
|
64
|
+
}, {
|
|
65
|
+
usage: string;
|
|
66
|
+
caveats: string[];
|
|
67
|
+
}>;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
name: string;
|
|
70
|
+
language: "ts" | "js";
|
|
71
|
+
schemaVersion: 1;
|
|
72
|
+
version: string;
|
|
73
|
+
summary: string;
|
|
74
|
+
tags: string[];
|
|
75
|
+
environments: ("browser" | "node" | "universal")[];
|
|
76
|
+
exports: {
|
|
77
|
+
name: string;
|
|
78
|
+
kind: "function" | "type" | "class";
|
|
79
|
+
}[];
|
|
80
|
+
files: {
|
|
81
|
+
path: string;
|
|
82
|
+
content: string;
|
|
83
|
+
sha256: string;
|
|
84
|
+
}[];
|
|
85
|
+
dependencies: [];
|
|
86
|
+
templateVariables: [];
|
|
87
|
+
license: {
|
|
88
|
+
source: "original" | "derived";
|
|
89
|
+
spdx: "MIT" | "Apache-2.0" | "BSD-2-Clause" | "BSD-3-Clause" | "ISC" | "Unlicense" | "CC0-1.0" | "MPL-2.0" | "LGPL-2.1-only" | "LGPL-2.1-or-later" | "LGPL-3.0-only" | "LGPL-3.0-or-later" | "GPL-2.0-only" | "GPL-2.0-or-later" | "GPL-3.0-only" | "GPL-3.0-or-later" | "0BSD";
|
|
90
|
+
attribution?: string | undefined;
|
|
91
|
+
};
|
|
92
|
+
tests: {
|
|
93
|
+
path: string;
|
|
94
|
+
content: string;
|
|
95
|
+
}[];
|
|
96
|
+
docs: {
|
|
97
|
+
usage: string;
|
|
98
|
+
caveats: string[];
|
|
99
|
+
};
|
|
100
|
+
}, {
|
|
101
|
+
name: string;
|
|
102
|
+
language: "ts" | "js";
|
|
103
|
+
schemaVersion: 1;
|
|
104
|
+
version: string;
|
|
105
|
+
summary: string;
|
|
106
|
+
tags: string[];
|
|
107
|
+
environments: ("browser" | "node" | "universal")[];
|
|
108
|
+
exports: {
|
|
109
|
+
name: string;
|
|
110
|
+
kind: "function" | "type" | "class";
|
|
111
|
+
}[];
|
|
112
|
+
files: {
|
|
113
|
+
path: string;
|
|
114
|
+
content: string;
|
|
115
|
+
sha256: string;
|
|
116
|
+
}[];
|
|
117
|
+
dependencies: [];
|
|
118
|
+
templateVariables: [];
|
|
119
|
+
license: {
|
|
120
|
+
source: "original" | "derived";
|
|
121
|
+
spdx: "MIT" | "Apache-2.0" | "BSD-2-Clause" | "BSD-3-Clause" | "ISC" | "Unlicense" | "CC0-1.0" | "MPL-2.0" | "LGPL-2.1-only" | "LGPL-2.1-or-later" | "LGPL-3.0-only" | "LGPL-3.0-or-later" | "GPL-2.0-only" | "GPL-2.0-or-later" | "GPL-3.0-only" | "GPL-3.0-or-later" | "0BSD";
|
|
122
|
+
attribution?: string | undefined;
|
|
123
|
+
};
|
|
124
|
+
tests: {
|
|
125
|
+
path: string;
|
|
126
|
+
content: string;
|
|
127
|
+
}[];
|
|
128
|
+
docs: {
|
|
129
|
+
usage: string;
|
|
130
|
+
caveats: string[];
|
|
131
|
+
};
|
|
132
|
+
}>, {
|
|
133
|
+
name: string;
|
|
134
|
+
language: "ts" | "js";
|
|
135
|
+
schemaVersion: 1;
|
|
136
|
+
version: string;
|
|
137
|
+
summary: string;
|
|
138
|
+
tags: string[];
|
|
139
|
+
environments: ("browser" | "node" | "universal")[];
|
|
140
|
+
exports: {
|
|
141
|
+
name: string;
|
|
142
|
+
kind: "function" | "type" | "class";
|
|
143
|
+
}[];
|
|
144
|
+
files: {
|
|
145
|
+
path: string;
|
|
146
|
+
content: string;
|
|
147
|
+
sha256: string;
|
|
148
|
+
}[];
|
|
149
|
+
dependencies: [];
|
|
150
|
+
templateVariables: [];
|
|
151
|
+
license: {
|
|
152
|
+
source: "original" | "derived";
|
|
153
|
+
spdx: "MIT" | "Apache-2.0" | "BSD-2-Clause" | "BSD-3-Clause" | "ISC" | "Unlicense" | "CC0-1.0" | "MPL-2.0" | "LGPL-2.1-only" | "LGPL-2.1-or-later" | "LGPL-3.0-only" | "LGPL-3.0-or-later" | "GPL-2.0-only" | "GPL-2.0-or-later" | "GPL-3.0-only" | "GPL-3.0-or-later" | "0BSD";
|
|
154
|
+
attribution?: string | undefined;
|
|
155
|
+
};
|
|
156
|
+
tests: {
|
|
157
|
+
path: string;
|
|
158
|
+
content: string;
|
|
159
|
+
}[];
|
|
160
|
+
docs: {
|
|
161
|
+
usage: string;
|
|
162
|
+
caveats: string[];
|
|
163
|
+
};
|
|
164
|
+
}, {
|
|
165
|
+
name: string;
|
|
166
|
+
language: "ts" | "js";
|
|
167
|
+
schemaVersion: 1;
|
|
168
|
+
version: string;
|
|
169
|
+
summary: string;
|
|
170
|
+
tags: string[];
|
|
171
|
+
environments: ("browser" | "node" | "universal")[];
|
|
172
|
+
exports: {
|
|
173
|
+
name: string;
|
|
174
|
+
kind: "function" | "type" | "class";
|
|
175
|
+
}[];
|
|
176
|
+
files: {
|
|
177
|
+
path: string;
|
|
178
|
+
content: string;
|
|
179
|
+
sha256: string;
|
|
180
|
+
}[];
|
|
181
|
+
dependencies: [];
|
|
182
|
+
templateVariables: [];
|
|
183
|
+
license: {
|
|
184
|
+
source: "original" | "derived";
|
|
185
|
+
spdx: "MIT" | "Apache-2.0" | "BSD-2-Clause" | "BSD-3-Clause" | "ISC" | "Unlicense" | "CC0-1.0" | "MPL-2.0" | "LGPL-2.1-only" | "LGPL-2.1-or-later" | "LGPL-3.0-only" | "LGPL-3.0-or-later" | "GPL-2.0-only" | "GPL-2.0-or-later" | "GPL-3.0-only" | "GPL-3.0-or-later" | "0BSD";
|
|
186
|
+
attribution?: string | undefined;
|
|
187
|
+
};
|
|
188
|
+
tests: {
|
|
189
|
+
path: string;
|
|
190
|
+
content: string;
|
|
191
|
+
}[];
|
|
192
|
+
docs: {
|
|
193
|
+
usage: string;
|
|
194
|
+
caveats: string[];
|
|
195
|
+
};
|
|
196
|
+
}>, {
|
|
197
|
+
name: string;
|
|
198
|
+
language: "ts" | "js";
|
|
199
|
+
schemaVersion: 1;
|
|
200
|
+
version: string;
|
|
201
|
+
summary: string;
|
|
202
|
+
tags: string[];
|
|
203
|
+
environments: ("browser" | "node" | "universal")[];
|
|
204
|
+
exports: {
|
|
205
|
+
name: string;
|
|
206
|
+
kind: "function" | "type" | "class";
|
|
207
|
+
}[];
|
|
208
|
+
files: {
|
|
209
|
+
path: string;
|
|
210
|
+
content: string;
|
|
211
|
+
sha256: string;
|
|
212
|
+
}[];
|
|
213
|
+
dependencies: [];
|
|
214
|
+
templateVariables: [];
|
|
215
|
+
license: {
|
|
216
|
+
source: "original" | "derived";
|
|
217
|
+
spdx: "MIT" | "Apache-2.0" | "BSD-2-Clause" | "BSD-3-Clause" | "ISC" | "Unlicense" | "CC0-1.0" | "MPL-2.0" | "LGPL-2.1-only" | "LGPL-2.1-or-later" | "LGPL-3.0-only" | "LGPL-3.0-or-later" | "GPL-2.0-only" | "GPL-2.0-or-later" | "GPL-3.0-only" | "GPL-3.0-or-later" | "0BSD";
|
|
218
|
+
attribution?: string | undefined;
|
|
219
|
+
};
|
|
220
|
+
tests: {
|
|
221
|
+
path: string;
|
|
222
|
+
content: string;
|
|
223
|
+
}[];
|
|
224
|
+
docs: {
|
|
225
|
+
usage: string;
|
|
226
|
+
caveats: string[];
|
|
227
|
+
};
|
|
228
|
+
}, {
|
|
229
|
+
name: string;
|
|
230
|
+
language: "ts" | "js";
|
|
231
|
+
schemaVersion: 1;
|
|
232
|
+
version: string;
|
|
233
|
+
summary: string;
|
|
234
|
+
tags: string[];
|
|
235
|
+
environments: ("browser" | "node" | "universal")[];
|
|
236
|
+
exports: {
|
|
237
|
+
name: string;
|
|
238
|
+
kind: "function" | "type" | "class";
|
|
239
|
+
}[];
|
|
240
|
+
files: {
|
|
241
|
+
path: string;
|
|
242
|
+
content: string;
|
|
243
|
+
sha256: string;
|
|
244
|
+
}[];
|
|
245
|
+
dependencies: [];
|
|
246
|
+
templateVariables: [];
|
|
247
|
+
license: {
|
|
248
|
+
source: "original" | "derived";
|
|
249
|
+
spdx: "MIT" | "Apache-2.0" | "BSD-2-Clause" | "BSD-3-Clause" | "ISC" | "Unlicense" | "CC0-1.0" | "MPL-2.0" | "LGPL-2.1-only" | "LGPL-2.1-or-later" | "LGPL-3.0-only" | "LGPL-3.0-or-later" | "GPL-2.0-only" | "GPL-2.0-or-later" | "GPL-3.0-only" | "GPL-3.0-or-later" | "0BSD";
|
|
250
|
+
attribution?: string | undefined;
|
|
251
|
+
};
|
|
252
|
+
tests: {
|
|
253
|
+
path: string;
|
|
254
|
+
content: string;
|
|
255
|
+
}[];
|
|
256
|
+
docs: {
|
|
257
|
+
usage: string;
|
|
258
|
+
caveats: string[];
|
|
259
|
+
};
|
|
260
|
+
}>;
|
|
261
|
+
export type RegistryItem = z.infer<typeof RegistryItemSchema>;
|
|
262
|
+
//# sourceMappingURL=registry-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-item.d.ts","sourceRoot":"","sources":["../../src/registry-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA4CxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyC3B,CAAC;AAEL,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { kebabCaseString, semverString, sha256Hex, relativePosixPath, nonEmptyString, } from './strings.js';
|
|
3
|
+
import { SPDX_ALLOW_LIST } from './spdx.js';
|
|
4
|
+
const MAX_TAGS = 20;
|
|
5
|
+
const MAX_FILES = 50;
|
|
6
|
+
const MAX_TESTS = 20;
|
|
7
|
+
const MAX_CAVEATS = 20;
|
|
8
|
+
const MAX_EXPORTS = 30;
|
|
9
|
+
const MAX_CONTENT_BYTES = 100_000;
|
|
10
|
+
const exportSchema = z.object({
|
|
11
|
+
name: z.string().min(1).max(100),
|
|
12
|
+
kind: z.enum(['function', 'type', 'class']),
|
|
13
|
+
});
|
|
14
|
+
const fileSchema = z.object({
|
|
15
|
+
path: relativePosixPath,
|
|
16
|
+
content: nonEmptyString.max(MAX_CONTENT_BYTES, 'Content exceeds size limit'),
|
|
17
|
+
sha256: sha256Hex,
|
|
18
|
+
});
|
|
19
|
+
const licenseSchema = z.object({
|
|
20
|
+
spdx: z.enum(SPDX_ALLOW_LIST),
|
|
21
|
+
source: z.enum(['original', 'derived']),
|
|
22
|
+
attribution: z.string().min(1).max(500).optional(),
|
|
23
|
+
});
|
|
24
|
+
const testFileSchema = z.object({
|
|
25
|
+
path: relativePosixPath,
|
|
26
|
+
content: nonEmptyString.max(MAX_CONTENT_BYTES),
|
|
27
|
+
});
|
|
28
|
+
const docsSchema = z.object({
|
|
29
|
+
usage: nonEmptyString.max(10_000),
|
|
30
|
+
caveats: z.array(nonEmptyString.max(2000)).max(MAX_CAVEATS),
|
|
31
|
+
});
|
|
32
|
+
export const RegistryItemSchema = z
|
|
33
|
+
.object({
|
|
34
|
+
schemaVersion: z.literal(1),
|
|
35
|
+
name: kebabCaseString,
|
|
36
|
+
version: semverString,
|
|
37
|
+
summary: nonEmptyString.max(200),
|
|
38
|
+
tags: z.array(z.string().min(1).max(50)).max(MAX_TAGS),
|
|
39
|
+
language: z.enum(['ts', 'js']),
|
|
40
|
+
environments: z.array(z.enum(['browser', 'node', 'universal'])).min(1),
|
|
41
|
+
exports: z.array(exportSchema).max(MAX_EXPORTS),
|
|
42
|
+
files: z.array(fileSchema).min(1).max(MAX_FILES),
|
|
43
|
+
dependencies: z.tuple([]).describe('MVP invariant: no dependencies allowed'),
|
|
44
|
+
templateVariables: z.tuple([]).describe('MVP invariant: no template variables'),
|
|
45
|
+
license: licenseSchema,
|
|
46
|
+
tests: z.array(testFileSchema).max(MAX_TESTS),
|
|
47
|
+
docs: docsSchema,
|
|
48
|
+
})
|
|
49
|
+
.superRefine((data, ctx) => {
|
|
50
|
+
const seenPaths = new Set();
|
|
51
|
+
for (let i = 0; i < data.files.length; i++) {
|
|
52
|
+
const file = data.files[i];
|
|
53
|
+
if (file && seenPaths.has(file.path)) {
|
|
54
|
+
ctx.addIssue({
|
|
55
|
+
code: z.ZodIssueCode.custom,
|
|
56
|
+
message: `Duplicate file path: ${file.path}`,
|
|
57
|
+
path: ['files', i, 'path'],
|
|
58
|
+
params: { code: 'DUPLICATE_FILE_PATH' },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
seenPaths.add(file.path);
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
.superRefine((data, ctx) => {
|
|
65
|
+
if (data.license.source === 'derived' && !data.license.attribution) {
|
|
66
|
+
ctx.addIssue({
|
|
67
|
+
code: z.ZodIssueCode.custom,
|
|
68
|
+
message: 'Attribution is required when license source is "derived"',
|
|
69
|
+
path: ['license', 'attribution'],
|
|
70
|
+
params: { code: 'ATTRIBUTION_REQUIRED' },
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=registry-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-item.js","sourceRoot":"","sources":["../../src/registry-item.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SnippetConfigSchema: z.ZodObject<{
|
|
3
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
4
|
+
output: z.ZodDefault<z.ZodString>;
|
|
5
|
+
language: z.ZodDefault<z.ZodEnum<["ts", "js"]>>;
|
|
6
|
+
registries: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
source: z.ZodEnum<["builtin"]>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
name: string;
|
|
11
|
+
source: "builtin";
|
|
12
|
+
}, {
|
|
13
|
+
name: string;
|
|
14
|
+
source: "builtin";
|
|
15
|
+
}>, "many">>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
output: string;
|
|
18
|
+
language: "ts" | "js";
|
|
19
|
+
registries: {
|
|
20
|
+
name: string;
|
|
21
|
+
source: "builtin";
|
|
22
|
+
}[];
|
|
23
|
+
$schema?: string | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
$schema?: string | undefined;
|
|
26
|
+
output?: string | undefined;
|
|
27
|
+
language?: "ts" | "js" | undefined;
|
|
28
|
+
registries?: {
|
|
29
|
+
name: string;
|
|
30
|
+
source: "builtin";
|
|
31
|
+
}[] | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
export type SnippetConfig = z.infer<typeof SnippetConfigSchema>;
|
|
34
|
+
//# sourceMappingURL=snippets-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippets-config.d.ts","sourceRoot":"","sources":["../../src/snippets-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQ9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const registrySourceSchema = z.object({
|
|
3
|
+
name: z.string().min(1).max(50),
|
|
4
|
+
source: z.enum(['builtin']),
|
|
5
|
+
});
|
|
6
|
+
export const SnippetConfigSchema = z.object({
|
|
7
|
+
$schema: z.string().url().optional(),
|
|
8
|
+
output: z.string().min(1).max(500).default('src/snippets'),
|
|
9
|
+
language: z.enum(['ts', 'js']).default('ts'),
|
|
10
|
+
registries: z
|
|
11
|
+
.array(registrySourceSchema)
|
|
12
|
+
.min(1)
|
|
13
|
+
.default([{ name: 'official', source: 'builtin' }]),
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=snippets-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippets-config.js","sourceRoot":"","sources":["../../src/snippets-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IAC/B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC;CAC5B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IAC1D,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IAC5C,UAAU,EAAE,CAAC;SACV,KAAK,CAAC,oBAAoB,CAAC;SAC3B,GAAG,CAAC,CAAC,CAAC;SACN,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;CACtD,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const SPDX_ALLOW_LIST: readonly ["MIT", "Apache-2.0", "BSD-2-Clause", "BSD-3-Clause", "ISC", "Unlicense", "CC0-1.0", "MPL-2.0", "LGPL-2.1-only", "LGPL-2.1-or-later", "LGPL-3.0-only", "LGPL-3.0-or-later", "GPL-2.0-only", "GPL-2.0-or-later", "GPL-3.0-only", "GPL-3.0-or-later", "0BSD"];
|
|
2
|
+
export type SpdxId = (typeof SPDX_ALLOW_LIST)[number];
|
|
3
|
+
//# sourceMappingURL=spdx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spdx.d.ts","sourceRoot":"","sources":["../../src/spdx.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,sQAkBlB,CAAC;AAEX,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/src/spdx.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const SPDX_ALLOW_LIST = [
|
|
2
|
+
'MIT',
|
|
3
|
+
'Apache-2.0',
|
|
4
|
+
'BSD-2-Clause',
|
|
5
|
+
'BSD-3-Clause',
|
|
6
|
+
'ISC',
|
|
7
|
+
'Unlicense',
|
|
8
|
+
'CC0-1.0',
|
|
9
|
+
'MPL-2.0',
|
|
10
|
+
'LGPL-2.1-only',
|
|
11
|
+
'LGPL-2.1-or-later',
|
|
12
|
+
'LGPL-3.0-only',
|
|
13
|
+
'LGPL-3.0-or-later',
|
|
14
|
+
'GPL-2.0-only',
|
|
15
|
+
'GPL-2.0-or-later',
|
|
16
|
+
'GPL-3.0-only',
|
|
17
|
+
'GPL-3.0-or-later',
|
|
18
|
+
'0BSD',
|
|
19
|
+
];
|
|
20
|
+
//# sourceMappingURL=spdx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spdx.js","sourceRoot":"","sources":["../../src/spdx.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,KAAK;IACL,YAAY;IACZ,cAAc;IACd,cAAc;IACd,KAAK;IACL,WAAW;IACX,SAAS;IACT,SAAS;IACT,eAAe;IACf,mBAAmB;IACnB,eAAe;IACf,mBAAmB;IACnB,cAAc;IACd,kBAAkB;IAClB,cAAc;IACd,kBAAkB;IAClB,MAAM;CACE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const kebabCaseString: z.ZodString;
|
|
3
|
+
export declare const semverString: z.ZodString;
|
|
4
|
+
export declare const sha256Hex: z.ZodString;
|
|
5
|
+
export declare const relativePosixPath: z.ZodString;
|
|
6
|
+
export declare const nonEmptyString: z.ZodString;
|
|
7
|
+
//# sourceMappingURL=strings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/strings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,eAAe,aAI4B,CAAC;AAEzD,eAAO,MAAM,YAAY,aAAiE,CAAC;AAE3F,eAAO,MAAM,SAAS,aAA6E,CAAC;AAEpG,eAAO,MAAM,iBAAiB,aAImE,CAAC;AAElG,eAAO,MAAM,cAAc,aAAyC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const kebabCaseRegex = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
3
|
+
const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
4
|
+
const sha256HexRegex = /^[a-f0-9]{64}$/;
|
|
5
|
+
const relativePosixPathRegex = /^(?!\/)(?!.*\/\/)(?!.*\.\.)(?!.*\\)[^\0]+$/;
|
|
6
|
+
export const kebabCaseString = z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.max(100)
|
|
10
|
+
.regex(kebabCaseRegex, 'Must be lowercase kebab-case');
|
|
11
|
+
export const semverString = z.string().regex(semverRegex, 'Must be a valid SemVer string');
|
|
12
|
+
export const sha256Hex = z.string().regex(sha256HexRegex, 'Must be a lowercase SHA-256 hex string');
|
|
13
|
+
export const relativePosixPath = z
|
|
14
|
+
.string()
|
|
15
|
+
.min(1)
|
|
16
|
+
.max(500)
|
|
17
|
+
.regex(relativePosixPathRegex, 'Must be a relative POSIX path without traversal or null bytes');
|
|
18
|
+
export const nonEmptyString = z.string().min(1, 'Must not be empty');
|
|
19
|
+
//# sourceMappingURL=strings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strings.js","sourceRoot":"","sources":["../../src/strings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,cAAc,GAAG,+BAA+B,CAAC;AACvD,MAAM,WAAW,GACf,qLAAqL,CAAC;AACxL,MAAM,cAAc,GAAG,gBAAgB,CAAC;AACxC,MAAM,sBAAsB,GAAG,4CAA4C,CAAC;AAE5E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC;KAC7B,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,KAAK,CAAC,cAAc,EAAE,8BAA8B,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,+BAA+B,CAAC,CAAC;AAE3F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,wCAAwC,CAAC,CAAC;AAEpG,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC/B,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,KAAK,CAAC,sBAAsB,EAAE,+DAA+D,CAAC,CAAC;AAElG,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ValidationError } from './errors.js';
|
|
3
|
+
export type ParseResult<T> = {
|
|
4
|
+
success: true;
|
|
5
|
+
data: T;
|
|
6
|
+
} | {
|
|
7
|
+
success: false;
|
|
8
|
+
errors: ValidationError[];
|
|
9
|
+
};
|
|
10
|
+
export declare function safeParse<T>(schema: z.ZodSchema<T>, data: unknown): ParseResult<T>;
|
|
11
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAa,MAAM,aAAa,CAAC;AAEzD,MAAM,MAAM,WAAW,CAAC,CAAC,IACvB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC;AAwC7E,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CASlF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ValidationError, ErrorCode } from './errors.js';
|
|
3
|
+
function mapZodIssue(issue) {
|
|
4
|
+
const path = issue.path.join('.');
|
|
5
|
+
const code = inferErrorCode(issue);
|
|
6
|
+
return new ValidationError(code, issue.message, path || '$');
|
|
7
|
+
}
|
|
8
|
+
function inferErrorCode(issue) {
|
|
9
|
+
switch (issue.code) {
|
|
10
|
+
case z.ZodIssueCode.invalid_literal:
|
|
11
|
+
return ErrorCode.INVALID_SCHEMA_VERSION;
|
|
12
|
+
case z.ZodIssueCode.invalid_enum_value:
|
|
13
|
+
if (issue.path.includes('spdx'))
|
|
14
|
+
return ErrorCode.INVALID_SPDX;
|
|
15
|
+
if (issue.path.includes('source'))
|
|
16
|
+
return ErrorCode.INVALID_LICENSE_SOURCE;
|
|
17
|
+
if (issue.path.includes('kind'))
|
|
18
|
+
return ErrorCode.INVALID_EXPORT_KIND;
|
|
19
|
+
if (issue.path.includes('environment'))
|
|
20
|
+
return ErrorCode.INVALID_ENVIRONMENT;
|
|
21
|
+
if (issue.path.includes('language'))
|
|
22
|
+
return ErrorCode.INVALID_LANGUAGE;
|
|
23
|
+
return ErrorCode.INVALID_LICENSE;
|
|
24
|
+
case z.ZodIssueCode.too_small:
|
|
25
|
+
if (issue.path.includes('content') && issue.minimum === 1)
|
|
26
|
+
return ErrorCode.INVALID_CONTENT_EMPTY;
|
|
27
|
+
if (issue.path.includes('usage') && issue.minimum === 1)
|
|
28
|
+
return ErrorCode.MISSING_REQUIRED_FIELD;
|
|
29
|
+
return ErrorCode.MISSING_REQUIRED_FIELD;
|
|
30
|
+
case z.ZodIssueCode.invalid_type:
|
|
31
|
+
if (issue.path.includes('dependencies') || issue.path.includes('templateVariables')) {
|
|
32
|
+
if (issue.received === 'array')
|
|
33
|
+
return ErrorCode.INVALID_LICENSE;
|
|
34
|
+
return ErrorCode.INVALID_LICENSE;
|
|
35
|
+
}
|
|
36
|
+
return ErrorCode.MISSING_REQUIRED_FIELD;
|
|
37
|
+
case z.ZodIssueCode.custom:
|
|
38
|
+
if (issue.params?.code)
|
|
39
|
+
return issue.params.code;
|
|
40
|
+
return ErrorCode.MALFORMED_JSON;
|
|
41
|
+
default:
|
|
42
|
+
return ErrorCode.MALFORMED_JSON;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function safeParse(schema, data) {
|
|
46
|
+
const result = schema.safeParse(data);
|
|
47
|
+
if (result.success) {
|
|
48
|
+
return { success: true, data: result.data };
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
success: false,
|
|
52
|
+
errors: result.error.issues.map(mapZodIssue),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@snipl/registry-schema",
|
|
3
|
+
"version": "1.0.0-next.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/ysr-hameed/snipl.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/ysr-hameed/snipl/issues"
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/src/index.js",
|
|
15
|
+
"types": "./dist/src/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/src/index.d.ts",
|
|
19
|
+
"default": "./dist/src/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/src",
|
|
24
|
+
"!dist/src/**/*.tsbuildinfo"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"zod": "^3.24.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"typescript": "^5.7.0",
|
|
31
|
+
"vitest": "^3.0.0"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=22.0.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -b",
|
|
38
|
+
"typecheck": "tsc -b",
|
|
39
|
+
"test": "vitest run"
|
|
40
|
+
}
|
|
41
|
+
}
|