@openpkg-ts/spec 0.45.0 → 0.47.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 CHANGED
@@ -294,6 +294,7 @@ type SpecType = {
294
294
  description?: string;
295
295
  schema?: SpecSchema;
296
296
  type?: string | SpecSchema;
297
+ typeParameters?: SpecTypeParameter[];
297
298
  members?: SpecMember[];
298
299
  source?: SpecSource;
299
300
  tags?: SpecTag[];
@@ -598,6 +599,8 @@ declare function getSchemaType(schema: SpecSchema): string;
598
599
  type ConcreteSchemaVersion = "0.1.0" | "0.2.0" | "0.3.0" | "0.4.0";
599
600
  /** Supported schema versions */
600
601
  type SchemaVersion = ConcreteSchemaVersion | "latest";
602
+ /** Current/latest schema version */
603
+ declare const LATEST_VERSION: ConcreteSchemaVersion;
601
604
  type SpecError = {
602
605
  instancePath: string;
603
606
  message: string;
@@ -636,4 +639,4 @@ declare function assertSpec(spec: unknown, version?: SchemaVersion): asserts spe
636
639
  * @returns Array of validation errors (empty if valid)
637
640
  */
638
641
  declare function getValidationErrors(spec: unknown, version?: SchemaVersion): SpecError[];
639
- export { validateSpec, resolveRef, recommendSemverBump, normalize, isVoidSchema, isTupleSchema, isStringSchema, isRefSchema, isOneOfSchema, isObjectSchema, isNumberSchema, isNullSchema, isNeverSchema, isIntegerSchema, isFunctionSchema, isBooleanSchema, isArraySchema, isAnySchema, isAnyOfSchema, isAllOfSchema, getValidationErrors, getSchemaType, getAvailableVersions, flattenAnyOf, diffSpec, dereference, categorizeBreakingChanges, calculateNextVersion, assertSpec, SpecVisibility, SpecTypePredicate, SpecTypeParameter, SpecTypeKind, SpecTypeAliasKind, SpecType, SpecThrows, SpecTagParam, SpecTag, SpecSource, SpecSkippedExport, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchemaRef, SpecSchemaPrimitive, SpecSchemaGeneric, SpecSchemaFallback, SpecSchemaComposite, SpecSchemaCombinator, SpecSchema, SpecPresentationMeta, SpecMember, SpecMappedType, SpecInheritedMember, SpecGenerationMeta, SpecGenerationInfo, SpecExtractionMode, SpecExtractionLimitation, SpecExtensions, SpecExtension, SpecExportKind, SpecExport, SpecExampleLanguage, SpecExample, SpecDiff, SpecDecorator, SpecConditionalType, SemverRecommendation, SemverBump, SCHEMA_VERSION, SCHEMA_URL_MIRROR, SCHEMA_URL, OpenPkgVersion, OpenPkgMeta, OpenPkg, MemberChangeInfo, KIND_SLUGS, KIND_LABELS, JSON_SCHEMA_DRAFT, JSONSchemaExtensions, GenerationIssueSeverity, GenerationIssue, EntryPointDetectionMethod, DisplayKind, DiffOptions, DISPLAY_KIND_ORDER, CategorizedBreaking, BreakingSeverity };
642
+ export { validateSpec, resolveRef, recommendSemverBump, normalize, isVoidSchema, isTupleSchema, isStringSchema, isRefSchema, isOneOfSchema, isObjectSchema, isNumberSchema, isNullSchema, isNeverSchema, isIntegerSchema, isFunctionSchema, isBooleanSchema, isArraySchema, isAnySchema, isAnyOfSchema, isAllOfSchema, getValidationErrors, getSchemaType, getAvailableVersions, flattenAnyOf, diffSpec, dereference, categorizeBreakingChanges, calculateNextVersion, assertSpec, SpecVisibility, SpecTypePredicate, SpecTypeParameter, SpecTypeKind, SpecTypeAliasKind, SpecType, SpecThrows, SpecTagParam, SpecTag, SpecSource, SpecSkippedExport, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchemaRef, SpecSchemaPrimitive, SpecSchemaGeneric, SpecSchemaFallback, SpecSchemaComposite, SpecSchemaCombinator, SpecSchema, SpecPresentationMeta, SpecMember, SpecMappedType, SpecInheritedMember, SpecGenerationMeta, SpecGenerationInfo, SpecExtractionMode, SpecExtractionLimitation, SpecExtensions, SpecExtension, SpecExportKind, SpecExport, SpecExampleLanguage, SpecExample, SpecError, SpecDiff, SpecDecorator, SpecConditionalType, SemverRecommendation, SemverBump, SchemaVersion, SCHEMA_VERSION, SCHEMA_URL_MIRROR, SCHEMA_URL, OpenPkgVersion, OpenPkgMeta, OpenPkg, MemberChangeInfo, LATEST_VERSION, KIND_SLUGS, KIND_LABELS, JSON_SCHEMA_DRAFT, JSONSchemaExtensions, GenerationIssueSeverity, GenerationIssue, EntryPointDetectionMethod, DisplayKind, DiffOptions, DISPLAY_KIND_ORDER, CategorizedBreaking, BreakingSeverity };
package/dist/index.js CHANGED
@@ -47,7 +47,17 @@ function dereference(spec) {
47
47
  const record = value;
48
48
  const ref = readTypeRef(record);
49
49
  if (ref) {
50
- return resolveTypeRef(ref, typeLookup, seen);
50
+ const resolved = resolveTypeRef(ref, typeLookup, seen);
51
+ const siblings = {};
52
+ for (const [key, nested] of Object.entries(record)) {
53
+ if (key === "$ref")
54
+ continue;
55
+ siblings[key] = visit(nested, seen);
56
+ }
57
+ if (Object.keys(siblings).length === 0) {
58
+ return resolved;
59
+ }
60
+ return { ...siblings, ...resolved };
51
61
  }
52
62
  const next = {};
53
63
  for (const [key, nested] of Object.entries(record)) {
@@ -1961,7 +1971,7 @@ var openpkg_schema_default3 = {
1961
1971
  enum: { type: "array" },
1962
1972
  const: { description: "Constant value" },
1963
1973
  items: { $ref: "#/$defs/schema" },
1964
- prefixedItems: {
1974
+ prefixItems: {
1965
1975
  type: "array",
1966
1976
  items: { $ref: "#/$defs/schema" },
1967
1977
  description: "Tuple element schemas (draft-2020-12)"
@@ -2293,7 +2303,21 @@ var openpkg_schema_default4 = {
2293
2303
  type: "object",
2294
2304
  properties: {
2295
2305
  generator: { type: "string" },
2296
- timestamp: { type: "string", format: "date-time" }
2306
+ timestamp: { type: "string", format: "date-time" },
2307
+ mode: { type: "string", enum: ["source", "declaration-only"] },
2308
+ schemaExtraction: { type: "string", enum: ["hybrid"] },
2309
+ limitations: { type: "array", items: { type: "string" } },
2310
+ skipped: {
2311
+ type: "array",
2312
+ items: {
2313
+ type: "object",
2314
+ required: ["name", "reason"],
2315
+ properties: {
2316
+ name: { type: "string" },
2317
+ reason: { type: "string" }
2318
+ }
2319
+ }
2320
+ }
2297
2321
  }
2298
2322
  },
2299
2323
  presentationMeta: {
@@ -2398,7 +2422,12 @@ var openpkg_schema_default4 = {
2398
2422
  rawComments: { type: "string" },
2399
2423
  typeAliasKind: { $ref: "#/$defs/typeAliasKind" },
2400
2424
  conditionalType: { $ref: "#/$defs/conditionalType" },
2401
- mappedType: { $ref: "#/$defs/mappedType" }
2425
+ mappedType: { $ref: "#/$defs/mappedType" },
2426
+ external: { type: "boolean" },
2427
+ typeParameters: {
2428
+ type: "array",
2429
+ items: { $ref: "#/$defs/typeParameter" }
2430
+ }
2402
2431
  }
2403
2432
  },
2404
2433
  tag: {
@@ -2484,20 +2513,32 @@ var openpkg_schema_default4 = {
2484
2513
  description: { type: "string" }
2485
2514
  }
2486
2515
  },
2516
+ jsonSchemaType: {
2517
+ enum: ["string", "number", "integer", "boolean", "object", "array", "null"]
2518
+ },
2487
2519
  schema: {
2488
2520
  oneOf: [
2489
- { type: "string" },
2490
2521
  { type: "boolean" },
2491
2522
  {
2492
2523
  type: "object",
2493
2524
  properties: {
2494
2525
  $schema: { type: "string" },
2495
- type: { type: "string" },
2526
+ type: {
2527
+ oneOf: [
2528
+ { $ref: "#/$defs/jsonSchemaType" },
2529
+ {
2530
+ type: "array",
2531
+ items: { $ref: "#/$defs/jsonSchemaType" },
2532
+ minItems: 1,
2533
+ uniqueItems: true
2534
+ }
2535
+ ]
2536
+ },
2496
2537
  format: { type: "string" },
2497
2538
  enum: { type: "array" },
2498
2539
  const: {},
2499
2540
  items: { $ref: "#/$defs/schema" },
2500
- prefixedItems: {
2541
+ prefixItems: {
2501
2542
  type: "array",
2502
2543
  items: { $ref: "#/$defs/schema" }
2503
2544
  },
@@ -2507,31 +2548,65 @@ var openpkg_schema_default4 = {
2507
2548
  },
2508
2549
  required: { type: "array", items: { type: "string" } },
2509
2550
  additionalProperties: {
2510
- oneOf: [{ type: "boolean" }, { type: "object" }]
2551
+ oneOf: [{ type: "boolean" }, { $ref: "#/$defs/schema" }]
2552
+ },
2553
+ patternProperties: {
2554
+ type: "object",
2555
+ additionalProperties: { $ref: "#/$defs/schema" }
2556
+ },
2557
+ propertyNames: { $ref: "#/$defs/schema" },
2558
+ $defs: {
2559
+ type: "object",
2560
+ additionalProperties: { $ref: "#/$defs/schema" }
2511
2561
  },
2512
2562
  anyOf: { type: "array", items: { $ref: "#/$defs/schema" } },
2513
2563
  allOf: { type: "array", items: { $ref: "#/$defs/schema" } },
2514
2564
  oneOf: { type: "array", items: { $ref: "#/$defs/schema" } },
2565
+ not: { $ref: "#/$defs/schema" },
2515
2566
  $ref: { type: "string" },
2516
2567
  discriminator: {
2517
2568
  type: "object",
2518
2569
  properties: { propertyName: { type: "string" } }
2519
2570
  },
2571
+ title: { type: "string" },
2520
2572
  description: { type: "string" },
2521
2573
  deprecated: { type: "boolean" },
2522
- "x-deprecated-reason": { type: "string" },
2574
+ readOnly: { type: "boolean" },
2523
2575
  default: {},
2576
+ examples: { type: "array" },
2524
2577
  minimum: { type: "number" },
2525
2578
  maximum: { type: "number" },
2526
2579
  exclusiveMinimum: { type: "number" },
2527
2580
  exclusiveMaximum: { type: "number" },
2581
+ multipleOf: { type: "number" },
2528
2582
  minLength: { type: "integer" },
2529
2583
  maxLength: { type: "integer" },
2530
2584
  pattern: { type: "string" },
2531
2585
  minItems: { type: "integer" },
2532
2586
  maxItems: { type: "integer" },
2533
2587
  uniqueItems: { type: "boolean" },
2534
- signatures: { type: "array", items: { $ref: "#/$defs/signature" } }
2588
+ contains: { $ref: "#/$defs/schema" },
2589
+ minProperties: { type: "integer" },
2590
+ maxProperties: { type: "integer" },
2591
+ "x-ts-type": { type: "string" },
2592
+ "x-ts-function": { type: "boolean" },
2593
+ "x-ts-method": { type: "boolean" },
2594
+ "x-ts-signatures": { type: "array", items: { $ref: "#/$defs/signature" } },
2595
+ "x-ts-type-arguments": { type: "array", items: { $ref: "#/$defs/schema" } },
2596
+ "x-ts-type-predicate": {
2597
+ type: "object",
2598
+ required: ["parameterName", "type"],
2599
+ properties: {
2600
+ parameterName: { type: "string" },
2601
+ type: { $ref: "#/$defs/schema" }
2602
+ }
2603
+ },
2604
+ "x-ts-package": { type: "string" },
2605
+ "x-ts-default": { type: "string" },
2606
+ "x-ts-index-key": { type: "string", enum: ["number"] },
2607
+ "x-ts-accessor": { type: "string", enum: ["getter", "setter"] },
2608
+ "x-enum-members": { type: "array" },
2609
+ "x-deprecated-reason": { type: "string" }
2535
2610
  }
2536
2611
  }
2537
2612
  ]
@@ -2730,6 +2805,7 @@ export {
2730
2805
  SCHEMA_VERSION,
2731
2806
  SCHEMA_URL_MIRROR,
2732
2807
  SCHEMA_URL,
2808
+ LATEST_VERSION,
2733
2809
  KIND_SLUGS,
2734
2810
  KIND_LABELS,
2735
2811
  JSON_SCHEMA_DRAFT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/spec",
3
- "version": "0.45.0",
3
+ "version": "0.47.0",
4
4
  "description": "Shared schema, validation, and diff utilities for OpenPkg specs",
5
5
  "keywords": [
6
6
  "openpkg",
@@ -723,7 +723,7 @@
723
723
  "enum": { "type": "array" },
724
724
  "const": { "description": "Constant value" },
725
725
  "items": { "$ref": "#/$defs/schema" },
726
- "prefixedItems": {
726
+ "prefixItems": {
727
727
  "type": "array",
728
728
  "items": { "$ref": "#/$defs/schema" },
729
729
  "description": "Tuple element schemas (draft-2020-12)"
@@ -58,7 +58,21 @@
58
58
  "type": "object",
59
59
  "properties": {
60
60
  "generator": { "type": "string" },
61
- "timestamp": { "type": "string", "format": "date-time" }
61
+ "timestamp": { "type": "string", "format": "date-time" },
62
+ "mode": { "type": "string", "enum": ["source", "declaration-only"] },
63
+ "schemaExtraction": { "type": "string", "enum": ["hybrid"] },
64
+ "limitations": { "type": "array", "items": { "type": "string" } },
65
+ "skipped": {
66
+ "type": "array",
67
+ "items": {
68
+ "type": "object",
69
+ "required": ["name", "reason"],
70
+ "properties": {
71
+ "name": { "type": "string" },
72
+ "reason": { "type": "string" }
73
+ }
74
+ }
75
+ }
62
76
  }
63
77
  },
64
78
  "presentationMeta": {
@@ -163,7 +177,12 @@
163
177
  "rawComments": { "type": "string" },
164
178
  "typeAliasKind": { "$ref": "#/$defs/typeAliasKind" },
165
179
  "conditionalType": { "$ref": "#/$defs/conditionalType" },
166
- "mappedType": { "$ref": "#/$defs/mappedType" }
180
+ "mappedType": { "$ref": "#/$defs/mappedType" },
181
+ "external": { "type": "boolean" },
182
+ "typeParameters": {
183
+ "type": "array",
184
+ "items": { "$ref": "#/$defs/typeParameter" }
185
+ }
167
186
  }
168
187
  },
169
188
  "tag": {
@@ -249,20 +268,32 @@
249
268
  "description": { "type": "string" }
250
269
  }
251
270
  },
271
+ "jsonSchemaType": {
272
+ "enum": ["string", "number", "integer", "boolean", "object", "array", "null"]
273
+ },
252
274
  "schema": {
253
275
  "oneOf": [
254
- { "type": "string" },
255
276
  { "type": "boolean" },
256
277
  {
257
278
  "type": "object",
258
279
  "properties": {
259
280
  "$schema": { "type": "string" },
260
- "type": { "type": "string" },
281
+ "type": {
282
+ "oneOf": [
283
+ { "$ref": "#/$defs/jsonSchemaType" },
284
+ {
285
+ "type": "array",
286
+ "items": { "$ref": "#/$defs/jsonSchemaType" },
287
+ "minItems": 1,
288
+ "uniqueItems": true
289
+ }
290
+ ]
291
+ },
261
292
  "format": { "type": "string" },
262
293
  "enum": { "type": "array" },
263
294
  "const": {},
264
295
  "items": { "$ref": "#/$defs/schema" },
265
- "prefixedItems": {
296
+ "prefixItems": {
266
297
  "type": "array",
267
298
  "items": { "$ref": "#/$defs/schema" }
268
299
  },
@@ -272,31 +303,65 @@
272
303
  },
273
304
  "required": { "type": "array", "items": { "type": "string" } },
274
305
  "additionalProperties": {
275
- "oneOf": [{ "type": "boolean" }, { "type": "object" }]
306
+ "oneOf": [{ "type": "boolean" }, { "$ref": "#/$defs/schema" }]
307
+ },
308
+ "patternProperties": {
309
+ "type": "object",
310
+ "additionalProperties": { "$ref": "#/$defs/schema" }
311
+ },
312
+ "propertyNames": { "$ref": "#/$defs/schema" },
313
+ "$defs": {
314
+ "type": "object",
315
+ "additionalProperties": { "$ref": "#/$defs/schema" }
276
316
  },
277
317
  "anyOf": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
278
318
  "allOf": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
279
319
  "oneOf": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
320
+ "not": { "$ref": "#/$defs/schema" },
280
321
  "$ref": { "type": "string" },
281
322
  "discriminator": {
282
323
  "type": "object",
283
324
  "properties": { "propertyName": { "type": "string" } }
284
325
  },
326
+ "title": { "type": "string" },
285
327
  "description": { "type": "string" },
286
328
  "deprecated": { "type": "boolean" },
287
- "x-deprecated-reason": { "type": "string" },
329
+ "readOnly": { "type": "boolean" },
288
330
  "default": {},
331
+ "examples": { "type": "array" },
289
332
  "minimum": { "type": "number" },
290
333
  "maximum": { "type": "number" },
291
334
  "exclusiveMinimum": { "type": "number" },
292
335
  "exclusiveMaximum": { "type": "number" },
336
+ "multipleOf": { "type": "number" },
293
337
  "minLength": { "type": "integer" },
294
338
  "maxLength": { "type": "integer" },
295
339
  "pattern": { "type": "string" },
296
340
  "minItems": { "type": "integer" },
297
341
  "maxItems": { "type": "integer" },
298
342
  "uniqueItems": { "type": "boolean" },
299
- "signatures": { "type": "array", "items": { "$ref": "#/$defs/signature" } }
343
+ "contains": { "$ref": "#/$defs/schema" },
344
+ "minProperties": { "type": "integer" },
345
+ "maxProperties": { "type": "integer" },
346
+ "x-ts-type": { "type": "string" },
347
+ "x-ts-function": { "type": "boolean" },
348
+ "x-ts-method": { "type": "boolean" },
349
+ "x-ts-signatures": { "type": "array", "items": { "$ref": "#/$defs/signature" } },
350
+ "x-ts-type-arguments": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
351
+ "x-ts-type-predicate": {
352
+ "type": "object",
353
+ "required": ["parameterName", "type"],
354
+ "properties": {
355
+ "parameterName": { "type": "string" },
356
+ "type": { "$ref": "#/$defs/schema" }
357
+ }
358
+ },
359
+ "x-ts-package": { "type": "string" },
360
+ "x-ts-default": { "type": "string" },
361
+ "x-ts-index-key": { "type": "string", "enum": ["number"] },
362
+ "x-ts-accessor": { "type": "string", "enum": ["getter", "setter"] },
363
+ "x-enum-members": { "type": "array" },
364
+ "x-deprecated-reason": { "type": "string" }
300
365
  }
301
366
  }
302
367
  ]