@openpkg-ts/spec 0.4.0 → 0.5.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/dist/index.d.ts +43 -8
- package/dist/index.js +861 -27
- package/package.json +1 -1
- package/schemas/v0.2.0/openpkg.schema.json +10 -1
- package/schemas/v0.3.0/openpkg.schema.json +487 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
declare const SCHEMA_VERSION = "0.2.0";
|
|
2
|
-
declare const SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.2.0/openpkg.schema.json";
|
|
3
|
-
declare const JSON_SCHEMA_DRAFT = "https://json-schema.org/draft/2020-12/schema";
|
|
4
1
|
type SpecTag = {
|
|
5
2
|
name: string;
|
|
6
3
|
text: string;
|
|
4
|
+
paramName?: string;
|
|
5
|
+
typeAnnotation?: string;
|
|
6
|
+
reference?: string;
|
|
7
|
+
language?: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
reason?: string;
|
|
7
10
|
};
|
|
8
11
|
type SpecSource = {
|
|
9
12
|
file?: string;
|
|
@@ -36,6 +39,8 @@ type SpecSignatureParameter = {
|
|
|
36
39
|
required?: boolean;
|
|
37
40
|
description?: string;
|
|
38
41
|
schema: SpecSchema;
|
|
42
|
+
default?: unknown;
|
|
43
|
+
rest?: boolean;
|
|
39
44
|
};
|
|
40
45
|
type SpecSignatureReturn = {
|
|
41
46
|
schema: SpecSchema;
|
|
@@ -47,6 +52,8 @@ type SpecSignature = {
|
|
|
47
52
|
returns?: SpecSignatureReturn;
|
|
48
53
|
description?: string;
|
|
49
54
|
typeParameters?: SpecTypeParameter[];
|
|
55
|
+
overloadIndex?: number;
|
|
56
|
+
isImplementation?: boolean;
|
|
50
57
|
};
|
|
51
58
|
type SpecMember = {
|
|
52
59
|
id?: string;
|
|
@@ -112,9 +119,11 @@ type OpenPkgMeta = {
|
|
|
112
119
|
repository?: string;
|
|
113
120
|
ecosystem?: string;
|
|
114
121
|
};
|
|
122
|
+
/** Supported OpenPkg spec versions */
|
|
123
|
+
type OpenPkgVersion = "0.2.0" | "0.3.0";
|
|
115
124
|
type OpenPkg = {
|
|
116
125
|
$schema?: string;
|
|
117
|
-
openpkg:
|
|
126
|
+
openpkg: OpenPkgVersion;
|
|
118
127
|
meta: OpenPkgMeta;
|
|
119
128
|
exports: SpecExport[];
|
|
120
129
|
types?: SpecType[];
|
|
@@ -122,6 +131,9 @@ type OpenPkg = {
|
|
|
122
131
|
docs?: SpecDocsMetadata;
|
|
123
132
|
extensions?: SpecExtension;
|
|
124
133
|
};
|
|
134
|
+
declare const SCHEMA_VERSION: OpenPkgVersion;
|
|
135
|
+
declare const SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.3.0/openpkg.schema.json";
|
|
136
|
+
declare const JSON_SCHEMA_DRAFT = "https://json-schema.org/draft/2020-12/schema";
|
|
125
137
|
declare function dereference(spec: OpenPkg): OpenPkg;
|
|
126
138
|
type BreakingSeverity = "high" | "medium" | "low";
|
|
127
139
|
interface CategorizedBreaking {
|
|
@@ -163,17 +175,40 @@ declare function diffSpec(oldSpec: OpenPkg, newSpec: OpenPkg): SpecDiff;
|
|
|
163
175
|
*/
|
|
164
176
|
declare function categorizeBreakingChanges(breaking: string[], oldSpec: OpenPkg, newSpec: OpenPkg, memberChanges?: MemberChangeInfo[]): CategorizedBreaking[];
|
|
165
177
|
declare function normalize(spec: OpenPkg): OpenPkg;
|
|
178
|
+
/** Supported schema versions */
|
|
179
|
+
type SchemaVersion = "0.1.0" | "0.2.0" | "0.3.0" | "latest";
|
|
166
180
|
type SpecError = {
|
|
167
181
|
instancePath: string;
|
|
168
182
|
message: string;
|
|
169
183
|
keyword: string;
|
|
170
184
|
};
|
|
171
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Validate a spec against a specific schema version.
|
|
187
|
+
*
|
|
188
|
+
* @param spec - The spec object to validate
|
|
189
|
+
* @param version - Schema version to validate against (default: 'latest')
|
|
190
|
+
* @returns Validation result
|
|
191
|
+
*/
|
|
192
|
+
declare function validateSpec(spec: unknown, version?: SchemaVersion): {
|
|
172
193
|
ok: true;
|
|
173
194
|
} | {
|
|
174
195
|
ok: false;
|
|
175
196
|
errors: SpecError[];
|
|
176
197
|
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Assert that a value is a valid OpenPkg spec.
|
|
200
|
+
* Throws an error with details if validation fails.
|
|
201
|
+
*
|
|
202
|
+
* @param spec - The value to validate
|
|
203
|
+
* @param version - Schema version to validate against (default: 'latest')
|
|
204
|
+
*/
|
|
205
|
+
declare function assertSpec(spec: unknown, version?: SchemaVersion): asserts spec is OpenPkg;
|
|
206
|
+
/**
|
|
207
|
+
* Get validation errors for a spec.
|
|
208
|
+
*
|
|
209
|
+
* @param spec - The spec to validate
|
|
210
|
+
* @param version - Schema version to validate against (default: 'latest')
|
|
211
|
+
* @returns Array of validation errors (empty if valid)
|
|
212
|
+
*/
|
|
213
|
+
declare function getValidationErrors(spec: unknown, version?: SchemaVersion): SpecError[];
|
|
214
|
+
export { validateSpec, normalize, getValidationErrors, diffSpec, dereference, categorizeBreakingChanges, assertSpec, SpecVisibility, SpecTypeParameter, SpecTypeKind, SpecType, SpecTag, SpecSource, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchema, SpecMember, SpecExtension, SpecExportKind, SpecExport, SpecExample, SpecDocsMetadata, SpecDocSignal, SpecDocDrift, SpecDiff, SCHEMA_VERSION, SCHEMA_URL, OpenPkgVersion, OpenPkgMeta, OpenPkg, MemberChangeInfo, JSON_SCHEMA_DRAFT, CategorizedBreaking, BreakingSeverity };
|