@amritk/helpers 0.7.1 → 0.9.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.
Files changed (83) hide show
  1. package/dist/build-dynamic-ref-map.d.ts +0 -1
  2. package/dist/derive-root-type-name.d.ts +0 -1
  3. package/dist/escape-regex-pattern.d.ts +16 -0
  4. package/dist/escape-regex-pattern.js +20 -0
  5. package/dist/extract-dynamic-anchor-defs.d.ts +0 -1
  6. package/dist/extract-refs.d.ts +0 -1
  7. package/dist/generate-index-barrel.d.ts +0 -1
  8. package/dist/generate-type-definition.d.ts +0 -1
  9. package/dist/has-ref.d.ts +0 -1
  10. package/dist/is-object.d.ts +0 -1
  11. package/dist/mjst-extension.d.ts +0 -1
  12. package/dist/parse-documentation.d.ts +0 -1
  13. package/dist/ref-to-filename.d.ts +0 -1
  14. package/dist/ref-to-name.d.ts +0 -1
  15. package/dist/resolve-dynamic-refs.d.ts +4 -4
  16. package/dist/resolve-dynamic-refs.js +10 -4
  17. package/dist/resolve-ref.d.ts +0 -1
  18. package/dist/safe-accessor.d.ts +0 -1
  19. package/dist/schema-guards.d.ts +16 -1
  20. package/dist/schema-guards.js +29 -0
  21. package/dist/upgrade-draft07-schema.d.ts +0 -1
  22. package/dist/validate-array.d.ts +0 -1
  23. package/dist/validate-record.d.ts +0 -1
  24. package/dist/walk-ref-graph.d.ts +0 -1
  25. package/package.json +2 -4
  26. package/dist/build-dynamic-ref-map.d.ts.map +0 -1
  27. package/dist/derive-root-type-name.d.ts.map +0 -1
  28. package/dist/extract-dynamic-anchor-defs.d.ts.map +0 -1
  29. package/dist/extract-refs.d.ts.map +0 -1
  30. package/dist/generate-index-barrel.d.ts.map +0 -1
  31. package/dist/generate-type-definition.d.ts.map +0 -1
  32. package/dist/has-ref.d.ts.map +0 -1
  33. package/dist/is-object.d.ts.map +0 -1
  34. package/dist/mjst-extension.d.ts.map +0 -1
  35. package/dist/parse-documentation.d.ts.map +0 -1
  36. package/dist/ref-to-filename.d.ts.map +0 -1
  37. package/dist/ref-to-name.d.ts.map +0 -1
  38. package/dist/resolve-dynamic-refs.d.ts.map +0 -1
  39. package/dist/resolve-ref.d.ts.map +0 -1
  40. package/dist/safe-accessor.d.ts.map +0 -1
  41. package/dist/schema-guards.d.ts.map +0 -1
  42. package/dist/upgrade-draft07-schema.d.ts.map +0 -1
  43. package/dist/validate-array.d.ts.map +0 -1
  44. package/dist/validate-record.d.ts.map +0 -1
  45. package/dist/walk-ref-graph.d.ts.map +0 -1
  46. package/src/build-dynamic-ref-map.test.ts +0 -65
  47. package/src/build-dynamic-ref-map.ts +0 -42
  48. package/src/derive-root-type-name.test.ts +0 -42
  49. package/src/derive-root-type-name.ts +0 -42
  50. package/src/extract-dynamic-anchor-defs.test.ts +0 -29
  51. package/src/extract-dynamic-anchor-defs.ts +0 -33
  52. package/src/extract-refs.test.ts +0 -183
  53. package/src/extract-refs.ts +0 -73
  54. package/src/generate-index-barrel.test.ts +0 -41
  55. package/src/generate-index-barrel.ts +0 -62
  56. package/src/generate-type-definition.test.ts +0 -1386
  57. package/src/generate-type-definition.ts +0 -580
  58. package/src/has-ref.ts +0 -10
  59. package/src/is-object.test.ts +0 -65
  60. package/src/is-object.ts +0 -15
  61. package/src/mjst-extension.test.ts +0 -59
  62. package/src/mjst-extension.ts +0 -81
  63. package/src/parse-documentation.test.ts +0 -313
  64. package/src/parse-documentation.ts +0 -173
  65. package/src/ref-to-filename.test.ts +0 -64
  66. package/src/ref-to-filename.ts +0 -116
  67. package/src/ref-to-name.test.ts +0 -57
  68. package/src/ref-to-name.ts +0 -42
  69. package/src/resolve-dynamic-refs.test.ts +0 -94
  70. package/src/resolve-dynamic-refs.ts +0 -48
  71. package/src/resolve-ref.test.ts +0 -186
  72. package/src/resolve-ref.ts +0 -82
  73. package/src/safe-accessor.test.ts +0 -41
  74. package/src/safe-accessor.ts +0 -48
  75. package/src/schema-guards.test.ts +0 -406
  76. package/src/schema-guards.ts +0 -160
  77. package/src/upgrade-draft07-schema.ts +0 -179
  78. package/src/validate-array.test.ts +0 -52
  79. package/src/validate-array.ts +0 -15
  80. package/src/validate-record.test.ts +0 -56
  81. package/src/validate-record.ts +0 -19
  82. package/src/walk-ref-graph.test.ts +0 -118
  83. package/src/walk-ref-graph.ts +0 -184
@@ -15,4 +15,3 @@ import type { JSONSchema } from 'json-schema-typed/draft-2020-12';
15
15
  * // Returns: { "#meta": "#/$defs/schema" }
16
16
  */
17
17
  export declare const buildDynamicRefMap: (rootSchema: JSONSchema) => Record<string, string>;
18
- //# sourceMappingURL=build-dynamic-ref-map.d.ts.map
@@ -18,4 +18,3 @@
18
18
  * ```
19
19
  */
20
20
  export declare const deriveRootTypeName: (schema: unknown) => string;
21
- //# sourceMappingURL=derive-root-type-name.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Escapes a JSON Schema `pattern` so it can be embedded between the slashes of
3
+ * a generated regex literal (`/…/`).
4
+ *
5
+ * A `pattern` is an ECMA-262 regex *body*, and the generated text goes into a
6
+ * regex literal — not a string literal — so backslashes are regex syntax and
7
+ * must be left exactly as-is (doubling `\d` to `\\d` would change it from "a
8
+ * digit" to "a literal backslash followed by d"). The only character that would
9
+ * corrupt the surrounding literal is an *unescaped* `/`, which would close it
10
+ * early. So we escape bare slashes to `\/` while leaving every existing escape
11
+ * sequence (including an already-escaped `\/`) untouched.
12
+ *
13
+ * @example
14
+ * escapeRegexPattern('\\d{4}/\\d{2}') // → '\\d{4}\\/\\d{2}' (i.e. \d{4}\/\d{2})
15
+ */
16
+ export declare const escapeRegexPattern: (pattern: string) => string;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Escapes a JSON Schema `pattern` so it can be embedded between the slashes of
3
+ * a generated regex literal (`/…/`).
4
+ *
5
+ * A `pattern` is an ECMA-262 regex *body*, and the generated text goes into a
6
+ * regex literal — not a string literal — so backslashes are regex syntax and
7
+ * must be left exactly as-is (doubling `\d` to `\\d` would change it from "a
8
+ * digit" to "a literal backslash followed by d"). The only character that would
9
+ * corrupt the surrounding literal is an *unescaped* `/`, which would close it
10
+ * early. So we escape bare slashes to `\/` while leaving every existing escape
11
+ * sequence (including an already-escaped `\/`) untouched.
12
+ *
13
+ * @example
14
+ * escapeRegexPattern('\\d{4}/\\d{2}') // → '\\d{4}\\/\\d{2}' (i.e. \d{4}\/\d{2})
15
+ */
16
+ export const escapeRegexPattern = (pattern) =>
17
+ // Match either an escape sequence (`\` + any char, kept verbatim) or a bare
18
+ // `/` (escaped). Consuming escape pairs first means the slash in `\/` is never
19
+ // seen as bare, so it is not double-escaped.
20
+ pattern.replace(/\\[\s\S]|\//g, (match) => (match === '/' ? '\\/' : match));
@@ -17,4 +17,3 @@ import type { JSONSchema } from 'json-schema-typed/draft-2020-12';
17
17
  * ```
18
18
  */
19
19
  export declare const extractDynamicAnchorDefs: (schema: JSONSchema) => string[];
20
- //# sourceMappingURL=extract-dynamic-anchor-defs.d.ts.map
@@ -21,4 +21,3 @@ import type { JSONSchema } from 'json-schema-typed/draft-2020-12';
21
21
  * ```
22
22
  */
23
23
  export declare const extractRefs: (schema: JSONSchema) => Set<string>;
24
- //# sourceMappingURL=extract-refs.d.ts.map
@@ -26,4 +26,3 @@ export type GenerateIndexBarrelOptions = {
26
26
  * @returns The `index.ts` file content.
27
27
  */
28
28
  export declare const generateIndexBarrel: (files: IndexBarrelFile[], options?: GenerateIndexBarrelOptions) => string;
29
- //# sourceMappingURL=generate-index-barrel.d.ts.map
@@ -15,4 +15,3 @@ export type TypeOptions = {
15
15
  * Uses $comment as inline JSDoc description when present.
16
16
  */
17
17
  export declare const generateTypeDefinition: (schema: JSONSchema, typeName: string, options?: TypeOptions) => string;
18
- //# sourceMappingURL=generate-type-definition.d.ts.map
package/dist/has-ref.d.ts CHANGED
@@ -2,4 +2,3 @@
2
2
  export declare const hasRef: (value: unknown) => value is {
3
3
  $ref: string;
4
4
  } & Record<string, unknown>;
5
- //# sourceMappingURL=has-ref.d.ts.map
@@ -12,4 +12,3 @@
12
12
  * isObject('string') // false
13
13
  */
14
14
  export declare const isObject: (value: unknown) => value is Record<string, unknown>;
15
- //# sourceMappingURL=is-object.d.ts.map
@@ -41,4 +41,3 @@ export declare const getMjstPrimitive: (schema: JSONSchema) => string | undefine
41
41
  * present and safe to embed in generated output. Returns undefined otherwise.
42
42
  */
43
43
  export declare const getMjstBrand: (schema: JSONSchema) => string | undefined;
44
- //# sourceMappingURL=mjst-extension.d.ts.map
@@ -15,4 +15,3 @@ export type ObjectDocumentation = {
15
15
  */
16
16
  export declare const parseDocumentation: (markdownDocumentation: string, commentUrl: string, fallbackCommentUrl?: string) => ObjectDocumentation | null;
17
17
  export {};
18
- //# sourceMappingURL=parse-documentation.d.ts.map
@@ -34,4 +34,3 @@ export declare const toKebabCase: (value: string) => string;
34
34
  * ```
35
35
  */
36
36
  export declare const refToFilename: (ref: string) => string;
37
- //# sourceMappingURL=ref-to-filename.d.ts.map
@@ -19,4 +19,3 @@
19
19
  * ```
20
20
  */
21
21
  export declare const refToName: (ref: string, suffix?: string) => string;
22
- //# sourceMappingURL=ref-to-name.d.ts.map
@@ -6,9 +6,9 @@ import type { JSONSchema } from 'json-schema-typed/draft-2020-12';
6
6
  * the clone and converts any { $dynamicRef: "#meta" } to { $ref: "#/$defs/schema" }
7
7
  * (or whatever the dynamicRefMap dictates).
8
8
  *
9
- * Only the direct properties and their nested schemas are walked — this does not need
10
- * to be infinitely deep because the build system generates separate files for each $def,
11
- * so each schema is relatively shallow.
9
+ * Walks both object properties and array elements, so a `$dynamicRef` nested
10
+ * inside a keyword whose value is an array of subschemas (`allOf`, `anyOf`,
11
+ * `oneOf`, `prefixItems`, …) is rewritten too. The build system generates a
12
+ * separate file per `$def`, so each schema walked here is relatively shallow.
12
13
  */
13
14
  export declare const resolveDynamicRefs: (schema: JSONSchema, dynamicRefMap: Record<string, string>) => JSONSchema;
14
- //# sourceMappingURL=resolve-dynamic-refs.d.ts.map
@@ -5,9 +5,10 @@
5
5
  * the clone and converts any { $dynamicRef: "#meta" } to { $ref: "#/$defs/schema" }
6
6
  * (or whatever the dynamicRefMap dictates).
7
7
  *
8
- * Only the direct properties and their nested schemas are walked — this does not need
9
- * to be infinitely deep because the build system generates separate files for each $def,
10
- * so each schema is relatively shallow.
8
+ * Walks both object properties and array elements, so a `$dynamicRef` nested
9
+ * inside a keyword whose value is an array of subschemas (`allOf`, `anyOf`,
10
+ * `oneOf`, `prefixItems`, …) is rewritten too. The build system generates a
11
+ * separate file per `$def`, so each schema walked here is relatively shallow.
11
12
  */
12
13
  export const resolveDynamicRefs = (schema, dynamicRefMap) => {
13
14
  if (typeof schema !== 'object' || schema === null) {
@@ -19,7 +20,12 @@ export const resolveDynamicRefs = (schema, dynamicRefMap) => {
19
20
  }
20
21
  const clone = JSON.parse(JSON.stringify(schema));
21
22
  const walk = (obj) => {
22
- if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
23
+ if (typeof obj !== 'object' || obj === null) {
24
+ return;
25
+ }
26
+ if (Array.isArray(obj)) {
27
+ for (const item of obj)
28
+ walk(item);
23
29
  return;
24
30
  }
25
31
  const record = obj;
@@ -24,4 +24,3 @@
24
24
  * ```
25
25
  */
26
26
  export declare const resolveRef: (ref: string, rootSchema: Record<string, unknown>) => Record<string, unknown> | undefined;
27
- //# sourceMappingURL=resolve-ref.d.ts.map
@@ -22,4 +22,3 @@ export declare const safeAccessor: (variable: string, key: string) => string;
22
22
  * safeKey("x-linkedin") // "'x-linkedin'"
23
23
  */
24
24
  export declare const safeKey: (key: string) => string;
25
- //# sourceMappingURL=safe-accessor.d.ts.map
@@ -84,6 +84,14 @@ export declare const hasExclusiveMinimum: (schema: JSONSchema) => schema is Sche
84
84
  export declare const hasExclusiveMaximum: (schema: JSONSchema) => schema is SchemaObject & {
85
85
  exclusiveMaximum: number;
86
86
  };
87
+ /**
88
+ * Draft-04 expressed a strict lower bound as a boolean `exclusiveMinimum: true`
89
+ * paired with `minimum`, where draft-06+ uses a standalone numeric keyword. True
90
+ * only for that legacy boolean form, so callers can tighten the `minimum` compare.
91
+ */
92
+ export declare const hasStrictExclusiveMinimum: (schema: JSONSchema) => boolean;
93
+ /** Draft-04 boolean `exclusiveMaximum: true` paired with `maximum`. See {@link hasStrictExclusiveMinimum}. */
94
+ export declare const hasStrictExclusiveMaximum: (schema: JSONSchema) => boolean;
87
95
  /** Type guard to check if schema has multipleOf */
88
96
  export declare const hasMultipleOf: (schema: JSONSchema) => schema is SchemaObject & {
89
97
  multipleOf: number;
@@ -108,5 +116,12 @@ export declare const hasMinProperties: (schema: JSONSchema) => schema is SchemaO
108
116
  export declare const hasMaxProperties: (schema: JSONSchema) => schema is SchemaObject & {
109
117
  maxProperties: number;
110
118
  };
119
+ /** Type guard to check if schema has dependentRequired (2020-12). */
120
+ export declare const hasDependentRequired: (schema: JSONSchema) => schema is SchemaObject & {
121
+ dependentRequired: Record<string, readonly string[]>;
122
+ };
123
+ /** Type guard to check if schema has a propertyNames subschema. */
124
+ export declare const hasPropertyNames: (schema: JSONSchema) => schema is SchemaObject & {
125
+ propertyNames: JSONSchema;
126
+ };
111
127
  export { hasRef } from './has-ref.js';
112
- //# sourceMappingURL=schema-guards.d.ts.map
@@ -93,6 +93,24 @@ export const hasExclusiveMinimum = (schema) => {
93
93
  export const hasExclusiveMaximum = (schema) => {
94
94
  return isSchemaObject(schema) && 'exclusiveMaximum' in schema && typeof schema.exclusiveMaximum === 'number';
95
95
  };
96
+ /**
97
+ * Draft-04 expressed a strict lower bound as a boolean `exclusiveMinimum: true`
98
+ * paired with `minimum`, where draft-06+ uses a standalone numeric keyword. True
99
+ * only for that legacy boolean form, so callers can tighten the `minimum` compare.
100
+ */
101
+ export const hasStrictExclusiveMinimum = (schema) => {
102
+ if (!isSchemaObject(schema))
103
+ return false;
104
+ const flag = schema.exclusiveMinimum;
105
+ return flag === true;
106
+ };
107
+ /** Draft-04 boolean `exclusiveMaximum: true` paired with `maximum`. See {@link hasStrictExclusiveMinimum}. */
108
+ export const hasStrictExclusiveMaximum = (schema) => {
109
+ if (!isSchemaObject(schema))
110
+ return false;
111
+ const flag = schema.exclusiveMaximum;
112
+ return flag === true;
113
+ };
96
114
  /** Type guard to check if schema has multipleOf */
97
115
  export const hasMultipleOf = (schema) => {
98
116
  return isSchemaObject(schema) && 'multipleOf' in schema && typeof schema.multipleOf === 'number';
@@ -117,4 +135,15 @@ export const hasMinProperties = (schema) => {
117
135
  export const hasMaxProperties = (schema) => {
118
136
  return isSchemaObject(schema) && 'maxProperties' in schema && typeof schema.maxProperties === 'number';
119
137
  };
138
+ /** Type guard to check if schema has dependentRequired (2020-12). */
139
+ export const hasDependentRequired = (schema) => {
140
+ return (isSchemaObject(schema) &&
141
+ 'dependentRequired' in schema &&
142
+ typeof schema.dependentRequired === 'object' &&
143
+ schema.dependentRequired !== null);
144
+ };
145
+ /** Type guard to check if schema has a propertyNames subschema. */
146
+ export const hasPropertyNames = (schema) => {
147
+ return isSchemaObject(schema) && 'propertyNames' in schema;
148
+ };
120
149
  export { hasRef } from './has-ref.js';
@@ -31,4 +31,3 @@ export declare const isDraft07Schema: (schema: Record<string, unknown>) => boole
31
31
  * nested defs hoisted to the root, and internal refs rewritten
32
32
  */
33
33
  export declare const upgradeDraft07Schema: (schema: Record<string, unknown>) => Record<string, unknown>;
34
- //# sourceMappingURL=upgrade-draft07-schema.d.ts.map
@@ -1,3 +1,2 @@
1
1
  /** Parses the items of an array with a parser function */
2
2
  export declare const validateArray: (input: unknown, parser: (input: unknown) => unknown) => any[];
3
- //# sourceMappingURL=validate-array.d.ts.map
@@ -3,4 +3,3 @@
3
3
  * Uses for...in instead of Object.entries() to avoid allocating an intermediate array.
4
4
  */
5
5
  export declare const validateRecord: (input: unknown, parser: (input: unknown) => unknown) => Record<string, unknown>;
6
- //# sourceMappingURL=validate-record.d.ts.map
@@ -51,4 +51,3 @@ export type WalkRefGraphOptions = {
51
51
  * @param visit - Called once per output file with a fully prepared {@link RefNode}.
52
52
  */
53
53
  export declare const walkRefGraph: (rootSchema: JSONSchema, rootTypeName: string, options: WalkRefGraphOptions, visit: (node: RefNode) => void) => void;
54
- //# sourceMappingURL=walk-ref-graph.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amritk/helpers",
3
- "version": "0.7.1",
3
+ "version": "0.9.0",
4
4
  "description": "Shared utilities for the mjst code generation ecosystem.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -20,8 +20,7 @@
20
20
  "url": "https://github.com/amritk/mjst/issues"
21
21
  },
22
22
  "files": [
23
- "dist",
24
- "src"
23
+ "dist"
25
24
  ],
26
25
  "publishConfig": {
27
26
  "access": "public"
@@ -37,7 +36,6 @@
37
36
  "exports": {
38
37
  "./package.json": "./package.json",
39
38
  "./*": {
40
- "development": "./src/*.ts",
41
39
  "import": "./dist/*.js",
42
40
  "types": "./dist/*.d.ts",
43
41
  "default": "./dist/*.js"
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-dynamic-ref-map.d.ts","sourceRoot":"","sources":["../src/build-dynamic-ref-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAIjE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,eAAgB,UAAU,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAsBhF,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"derive-root-type-name.d.ts","sourceRoot":"","sources":["../src/derive-root-type-name.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB,WAAY,OAAO,KAAG,MAOpD,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"extract-dynamic-anchor-defs.d.ts","sourceRoot":"","sources":["../src/extract-dynamic-anchor-defs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAEjE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,WAAY,UAAU,KAAG,MAAM,EAanE,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"extract-refs.d.ts","sourceRoot":"","sources":["../src/extract-refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAsBjE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW,WAAY,UAAU,KAAG,GAAG,CAAC,MAAM,CA6B1D,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-index-barrel.d.ts","sourceRoot":"","sources":["../src/generate-index-barrel.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,iEAAiE;AACjE,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAOD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,UAAW,eAAe,EAAE,YAAW,0BAA0B,KAAQ,MA2BxG,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-type-definition.d.ts","sourceRoot":"","sources":["../src/generate-type-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAYjE,iDAAiD;AACjD,MAAM,MAAM,WAAW,GAAG;IACxB,kGAAkG;IAClG,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B,CAAA;AAmZD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,WAAY,UAAU,YAAY,MAAM,YAAW,WAAW,KAAQ,MAsJxG,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"has-ref.d.ts","sourceRoot":"","sources":["../src/has-ref.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,eAAO,MAAM,MAAM,UAAW,OAAO,KAAG,KAAK,IAAI;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAQzF,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-object.d.ts","sourceRoot":"","sources":["../src/is-object.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,UAAW,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACV,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mjst-extension.d.ts","sourceRoot":"","sources":["../src/mjst-extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAIjE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,WAAW,CAAA;AAE1C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAwBD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,WAAY,UAAU,KAAG,MAAM,GAAG,SAG/D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,WAAY,UAAU,KAAG,MAAM,GAAG,SAG9D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,WAAY,UAAU,KAAG,MAAM,GAAG,SAG1D,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-documentation.d.ts","sourceRoot":"","sources":["../src/parse-documentation.ts"],"names":[],"mappings":"AAAA,KAAK,qBAAqB,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;CAClD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,0BACN,MAAM,cACjB,MAAM,uBACG,MAAM,KAC1B,mBAAmB,GAAG,IAuJxB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ref-to-filename.d.ts","sourceRoot":"","sources":["../src/ref-to-filename.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,MAM1B,CAAA;AA0DlB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,MAiB3C,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ref-to-name.d.ts","sourceRoot":"","sources":["../src/ref-to-name.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,SAAS,QAAS,MAAM,sBAAgB,MAAmD,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-dynamic-refs.d.ts","sourceRoot":"","sources":["../src/resolve-dynamic-refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,WAAY,UAAU,iBAAiB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,UAkC9F,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-ref.d.ts","sourceRoot":"","sources":["../src/resolve-ref.ts"],"names":[],"mappings":"AA0BA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,cAAc,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SA8BvG,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"safe-accessor.d.ts","sourceRoot":"","sources":["../src/safe-accessor.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,aAAc,MAAM,OAAO,MAAM,KAAG,MAW5D,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,QAAS,MAAM,KAAG,MAKrC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-guards.d.ts","sourceRoot":"","sources":["../src/schema-guards.ts"],"names":[],"mappings":"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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"upgrade-draft07-schema.d.ts","sourceRoot":"","sources":["../src/upgrade-draft07-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH;;GAEG;AACH,eAAO,MAAM,eAAe,WAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OACe,CAAA;AAqFjF;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,WAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAiC5F,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate-array.d.ts","sourceRoot":"","sources":["../src/validate-array.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,eAAO,MAAM,aAAa,UAAW,OAAO,UAAU,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,UAahF,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate-record.d.ts","sourceRoot":"","sources":["../src/validate-record.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,cAAc,UAAW,OAAO,UAAU,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,4BAYjF,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"walk-ref-graph.d.ts","sourceRoot":"","sources":["../src/walk-ref-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAWjE;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,2FAA2F;IAC3F,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IACvB,2FAA2F;IAC3F,QAAQ,EAAE,MAAM,CAAA;IAChB,sGAAsG;IACtG,QAAQ,EAAE,MAAM,CAAA;IAChB,qFAAqF;IACrF,MAAM,EAAE,UAAU,CAAA;IAClB,+EAA+E;IAC/E,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,oEAAoE;IACpE,MAAM,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,iEAAiE;AACjE,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B,CAAA;AA2DD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,YAAY,eACX,UAAU,gBACR,MAAM,WACX,mBAAmB,SACrB,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,KAC7B,IAyDF,CAAA"}
@@ -1,65 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
-
3
- import { buildDynamicRefMap } from './build-dynamic-ref-map'
4
-
5
- describe('build-dynamic-ref-map', () => {
6
- it('maps $dynamicAnchor values to $ref paths', () => {
7
- const schema = {
8
- type: 'object' as const,
9
- $defs: {
10
- schema: {
11
- $dynamicAnchor: 'meta',
12
- type: 'object',
13
- },
14
- },
15
- }
16
-
17
- const result = buildDynamicRefMap(schema)
18
- expect(result).toEqual({ '#meta': '#/$defs/schema' })
19
- })
20
-
21
- it('returns empty map when no $dynamicAnchor exists', () => {
22
- const schema = {
23
- type: 'object' as const,
24
- $defs: {
25
- info: { type: 'object' },
26
- },
27
- }
28
-
29
- const result = buildDynamicRefMap(schema)
30
- expect(result).toEqual({})
31
- })
32
-
33
- it('returns empty map for non-object schema', () => {
34
- const result = buildDynamicRefMap(true)
35
- expect(result).toEqual({})
36
- })
37
-
38
- it('returns empty map when no $defs exist', () => {
39
- const schema = { type: 'object' as const }
40
- const result = buildDynamicRefMap(schema)
41
- expect(result).toEqual({})
42
- })
43
-
44
- it('handles multiple $dynamicAnchor definitions', () => {
45
- const schema = {
46
- type: 'object' as const,
47
- $defs: {
48
- schema: {
49
- $dynamicAnchor: 'meta',
50
- type: 'object',
51
- },
52
- other: {
53
- $dynamicAnchor: 'other-anchor',
54
- type: 'string',
55
- },
56
- },
57
- }
58
-
59
- const result = buildDynamicRefMap(schema)
60
- expect(result).toEqual({
61
- '#meta': '#/$defs/schema',
62
- '#other-anchor': '#/$defs/other',
63
- })
64
- })
65
- })
@@ -1,42 +0,0 @@
1
- import type { JSONSchema } from 'json-schema-typed/draft-2020-12'
2
-
3
- import { isSchemaObject } from './schema-guards'
4
-
5
- /**
6
- * Builds a map of $dynamicRef anchor values to their corresponding $ref paths.
7
- *
8
- * JSON Schema 2020-12 uses $dynamicAnchor and $dynamicRef for late-binding references.
9
- * In the OpenAPI spec, $dynamicAnchor: "meta" on the schema definition allows properties
10
- * like media-type.schema to reference it via $dynamicRef: "#meta".
11
- *
12
- * This function scans all $defs for entries with $dynamicAnchor and builds a lookup
13
- * so we can convert $dynamicRef values to concrete $ref paths.
14
- *
15
- * @example
16
- * // Given a schema with $defs.schema having $dynamicAnchor: "meta"
17
- * buildDynamicRefMap(rootSchema)
18
- * // Returns: { "#meta": "#/$defs/schema" }
19
- */
20
- export const buildDynamicRefMap = (rootSchema: JSONSchema): Record<string, string> => {
21
- const map: Record<string, string> = {}
22
-
23
- if (!isSchemaObject(rootSchema) || !('$defs' in rootSchema)) {
24
- return map
25
- }
26
-
27
- const defs = rootSchema.$defs as Record<string, unknown>
28
-
29
- for (const [key, value] of Object.entries(defs)) {
30
- if (
31
- typeof value === 'object' &&
32
- value !== null &&
33
- '$dynamicAnchor' in value &&
34
- typeof (value as Record<string, unknown>)['$dynamicAnchor'] === 'string'
35
- ) {
36
- const anchor = (value as Record<string, unknown>)['$dynamicAnchor'] as string
37
- map[`#${anchor}`] = `#/$defs/${key}`
38
- }
39
- }
40
-
41
- return map
42
- }
@@ -1,42 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
-
3
- import { deriveRootTypeName } from './derive-root-type-name'
4
-
5
- describe('derive-root-type-name', () => {
6
- it('derives a PascalCase name from a single-word title', () => {
7
- expect(deriveRootTypeName({ title: 'Document' })).toBe('Document')
8
- })
9
-
10
- it('joins multi-word titles into PascalCase', () => {
11
- expect(deriveRootTypeName({ title: 'OpenAPI Document' })).toBe('OpenAPIDocument')
12
- })
13
-
14
- it('preserves acronyms intact', () => {
15
- expect(deriveRootTypeName({ title: 'JSON Schema' })).toBe('JSONSchema')
16
- })
17
-
18
- it('splits on non-alphanumeric separators', () => {
19
- expect(deriveRootTypeName({ title: 'my-config_file.spec' })).toBe('MyConfigFileSpec')
20
- })
21
-
22
- it('drops leading digits so the name is a valid identifier', () => {
23
- expect(deriveRootTypeName({ title: '3 amigos' })).toBe('Amigos')
24
- })
25
-
26
- it('falls back to Document when the title is missing', () => {
27
- expect(deriveRootTypeName({ type: 'object' })).toBe('Document')
28
- })
29
-
30
- it('falls back to Document when the title is not a string', () => {
31
- expect(deriveRootTypeName({ title: 42 })).toBe('Document')
32
- })
33
-
34
- it('falls back to Document for a title with no usable characters', () => {
35
- expect(deriveRootTypeName({ title: ' --- ' })).toBe('Document')
36
- })
37
-
38
- it('falls back to Document for boolean schemas', () => {
39
- expect(deriveRootTypeName(true)).toBe('Document')
40
- expect(deriveRootTypeName(false)).toBe('Document')
41
- })
42
- })
@@ -1,42 +0,0 @@
1
- import { isObject } from './is-object'
2
-
3
- /**
4
- * Converts an arbitrary title string into a PascalCase TypeScript identifier.
5
- * Splits on any run of non-alphanumeric characters, capitalizes the first
6
- * letter of each word while preserving the rest (so acronyms like "API" or
7
- * "JSON" survive intact), and drops leading digits since an identifier may not
8
- * start with a number.
9
- */
10
- const titleToPascalCase = (title: string): string => {
11
- const words = title.split(/[^a-zA-Z0-9]+/).filter(Boolean)
12
- const pascal = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join('')
13
- return pascal.replace(/^\d+/, '')
14
- }
15
-
16
- /**
17
- * Derives the root type name for a generated schema from its `title` keyword.
18
- *
19
- * We name the root after the schema itself instead of a generic "Document" so
20
- * the generated types and parsers read naturally (e.g. an OpenAPI schema yields
21
- * `OpenApi` / `parseOpenApi`). When the schema has no usable `title`, we fall
22
- * back to "Document" to keep output deterministic.
23
- *
24
- * @param schema - The root JSON Schema. A boolean schema or one without a
25
- * string `title` falls back to the default.
26
- * @returns A PascalCase type name derived from the title, or "Document".
27
- *
28
- * @example
29
- * ```ts
30
- * deriveRootTypeName({ title: 'OpenAPI Document' }) // 'OpenAPIDocument'
31
- * deriveRootTypeName({ title: 'my-config' }) // 'MyConfig'
32
- * deriveRootTypeName({ type: 'object' }) // 'Document'
33
- * ```
34
- */
35
- export const deriveRootTypeName = (schema: unknown): string => {
36
- if (!isObject(schema) || typeof schema['title'] !== 'string') {
37
- return 'Document'
38
- }
39
-
40
- const name = titleToPascalCase(schema['title'])
41
- return name || 'Document'
42
- }
@@ -1,29 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
-
3
- import { extractDynamicAnchorDefs } from './extract-dynamic-anchor-defs'
4
-
5
- describe('extract-dynamic-anchor-defs', () => {
6
- it('collects refs for every $defs entry with a $dynamicAnchor', () => {
7
- const schema = {
8
- $defs: {
9
- schema: { $dynamicAnchor: 'meta', type: 'object' },
10
- contact: { type: 'object' },
11
- node: { $dynamicAnchor: 'node', type: 'string' },
12
- },
13
- }
14
-
15
- expect(extractDynamicAnchorDefs(schema)).toEqual(['#/$defs/schema', '#/$defs/node'])
16
- })
17
-
18
- it('returns an empty array when no $defs are present', () => {
19
- expect(extractDynamicAnchorDefs({ type: 'object' })).toEqual([])
20
- })
21
-
22
- it('returns an empty array when no definition has a $dynamicAnchor', () => {
23
- expect(extractDynamicAnchorDefs({ $defs: { a: { type: 'string' } } })).toEqual([])
24
- })
25
-
26
- it('ignores a non-object schema', () => {
27
- expect(extractDynamicAnchorDefs(true)).toEqual([])
28
- })
29
- })