@kubb/ast 5.0.0-beta.59 → 5.0.0-beta.60

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/utils.cjs CHANGED
@@ -1,133 +1,34 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_utils = require("./utils-BCtRXfhI.cjs");
3
- Object.defineProperty(exports, "buildGroupParam", {
4
- enumerable: true,
5
- get: function() {
6
- return require_utils.buildGroupParam;
7
- }
8
- });
9
- Object.defineProperty(exports, "buildJSDoc", {
10
- enumerable: true,
11
- get: function() {
12
- return require_utils.buildJSDoc;
13
- }
14
- });
15
- Object.defineProperty(exports, "buildList", {
16
- enumerable: true,
17
- get: function() {
18
- return require_utils.buildList;
19
- }
20
- });
21
- Object.defineProperty(exports, "buildObject", {
22
- enumerable: true,
23
- get: function() {
24
- return require_utils.buildObject;
25
- }
26
- });
27
- Object.defineProperty(exports, "buildTypeLiteral", {
28
- enumerable: true,
29
- get: function() {
30
- return require_utils.buildTypeLiteral;
31
- }
32
- });
33
- Object.defineProperty(exports, "caseParams", {
34
- enumerable: true,
35
- get: function() {
36
- return require_utils.caseParams;
37
- }
38
- });
2
+ const require_response = require("./response-DS5S3IG4.cjs");
3
+ const require_utils = require("./utils-D83JA6Xx.cjs");
4
+ exports.buildGroupParam = require_utils.buildGroupParam;
5
+ exports.buildJSDoc = require_utils.buildJSDoc;
6
+ exports.buildList = require_utils.buildList;
7
+ exports.buildObject = require_utils.buildObject;
8
+ exports.buildTypeLiteral = require_utils.buildTypeLiteral;
9
+ exports.caseParams = require_utils.caseParams;
39
10
  exports.childName = require_utils.childName;
40
- Object.defineProperty(exports, "collectUsedSchemaNames", {
41
- enumerable: true,
42
- get: function() {
43
- return require_utils.collectUsedSchemaNames;
44
- }
45
- });
46
- Object.defineProperty(exports, "containsCircularRef", {
47
- enumerable: true,
48
- get: function() {
49
- return require_utils.containsCircularRef;
50
- }
51
- });
52
- Object.defineProperty(exports, "createOperationParams", {
53
- enumerable: true,
54
- get: function() {
55
- return require_utils.createOperationParams;
56
- }
57
- });
11
+ exports.collectUsedSchemaNames = require_utils.collectUsedSchemaNames;
12
+ exports.containsCircularRef = require_utils.containsCircularRef;
13
+ exports.createOperationParams = require_utils.createOperationParams;
58
14
  exports.enumPropName = require_utils.enumPropName;
59
15
  exports.extractRefName = require_utils.extractRefName;
60
- Object.defineProperty(exports, "extractStringsFromNodes", {
61
- enumerable: true,
62
- get: function() {
63
- return require_utils.extractStringsFromNodes;
64
- }
65
- });
66
- Object.defineProperty(exports, "findCircularSchemas", {
67
- enumerable: true,
68
- get: function() {
69
- return require_utils.findCircularSchemas;
70
- }
71
- });
72
- Object.defineProperty(exports, "getNestedAccessor", {
73
- enumerable: true,
74
- get: function() {
75
- return require_utils.getNestedAccessor;
76
- }
77
- });
16
+ exports.extractStringsFromNodes = require_response.extractStringsFromNodes;
17
+ exports.findCircularSchemas = require_utils.findCircularSchemas;
18
+ exports.getNestedAccessor = require_utils.getNestedAccessor;
78
19
  exports.isStringType = require_utils.isStringType;
79
- Object.defineProperty(exports, "isValidVarName", {
80
- enumerable: true,
81
- get: function() {
82
- return require_utils.isValidVarName;
83
- }
84
- });
85
- Object.defineProperty(exports, "jsStringEscape", {
86
- enumerable: true,
87
- get: function() {
88
- return require_utils.jsStringEscape;
89
- }
90
- });
91
- Object.defineProperty(exports, "objectKey", {
92
- enumerable: true,
93
- get: function() {
94
- return require_utils.objectKey;
95
- }
96
- });
20
+ exports.isValidVarName = require_utils.isValidVarName;
21
+ exports.jsStringEscape = require_utils.jsStringEscape;
22
+ exports.lazyGetter = require_utils.lazyGetter;
23
+ exports.mapSchemaItems = require_utils.mapSchemaItems;
24
+ exports.mapSchemaMembers = require_utils.mapSchemaMembers;
25
+ exports.mapSchemaProperties = require_utils.mapSchemaProperties;
26
+ exports.objectKey = require_utils.objectKey;
97
27
  exports.resolveGroupType = require_utils.resolveGroupType;
98
- Object.defineProperty(exports, "resolveParamType", {
99
- enumerable: true,
100
- get: function() {
101
- return require_utils.resolveParamType;
102
- }
103
- });
104
- Object.defineProperty(exports, "stringify", {
105
- enumerable: true,
106
- get: function() {
107
- return require_utils.stringify;
108
- }
109
- });
110
- Object.defineProperty(exports, "stringifyObject", {
111
- enumerable: true,
112
- get: function() {
113
- return require_utils.stringifyObject;
114
- }
115
- });
116
- Object.defineProperty(exports, "syncSchemaRef", {
117
- enumerable: true,
118
- get: function() {
119
- return require_utils.syncSchemaRef;
120
- }
121
- });
122
- Object.defineProperty(exports, "toRegExpString", {
123
- enumerable: true,
124
- get: function() {
125
- return require_utils.toRegExpString;
126
- }
127
- });
128
- Object.defineProperty(exports, "trimQuotes", {
129
- enumerable: true,
130
- get: function() {
131
- return require_utils.trimQuotes;
132
- }
133
- });
28
+ exports.resolveParamType = require_utils.resolveParamType;
29
+ exports.resolveRefName = require_utils.resolveRefName;
30
+ exports.stringify = require_utils.stringify;
31
+ exports.stringifyObject = require_utils.stringifyObject;
32
+ exports.syncSchemaRef = require_utils.syncSchemaRef;
33
+ exports.toRegExpString = require_utils.toRegExpString;
34
+ exports.trimQuotes = require_utils.trimQuotes;
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as __name } from "./chunk-CNktS9qV.js";
2
- import { _t as SchemaNode, f as OperationNode, w as ParameterNode } from "./index-BzjwdK2M.js";
2
+ import { Et as PropertyNode, St as UnionSchemaNode, _t as SchemaNode, f as OperationNode, ft as ObjectSchemaNode, ot as ArraySchemaNode, ut as IntersectionSchemaNode, w as ParameterNode } from "./index-BzjwdK2M.js";
3
3
  import { a as buildTypeLiteral, c as resolveParamType, i as buildGroupParam, n as OperationParamsResolver, o as caseParams, r as ParamGroupType, s as createOperationParams, t as BuildGroupArgs } from "./operationParams-BZ07xDm0.js";
4
4
  import { o as syncSchemaRef, t as extractStringsFromNodes } from "./extractStringsFromNodes-WMYJ8nQL.js";
5
5
 
@@ -92,6 +92,18 @@ declare function buildList(items: Array<string>, brackets?: [open: string, close
92
92
  * ```
93
93
  */
94
94
  declare function extractRefName(ref: string): string;
95
+ /**
96
+ * Resolves the schema name of a ref node, falling back through `ref` → `name` → nested `schema.name`.
97
+ *
98
+ * Returns `null` for non-ref nodes or when no name resolves.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' })
103
+ * // => 'Pet'
104
+ * ```
105
+ */
106
+ declare function resolveRefName(node: SchemaNode | undefined): string | null;
95
107
  /**
96
108
  * Builds a PascalCase child schema name by joining a parent name and property name.
97
109
  * Returns `null` when there is no parent to nest under.
@@ -239,5 +251,82 @@ declare function containsCircularRef(node: SchemaNode | undefined, {
239
251
  excludeName?: string;
240
252
  }): boolean;
241
253
  //#endregion
242
- export { type BuildGroupArgs, type ParamGroupType, buildGroupParam, buildJSDoc, buildList, buildObject, buildTypeLiteral, caseParams, childName, collectUsedSchemaNames, containsCircularRef, createOperationParams, enumPropName, extractRefName, extractStringsFromNodes, findCircularSchemas, getNestedAccessor, isStringType, isValidVarName, jsStringEscape, objectKey, resolveGroupType, resolveParamType, stringify, stringifyObject, syncSchemaRef, toRegExpString, trimQuotes };
254
+ //#region src/utils/schemaTraversal.d.ts
255
+ /**
256
+ * Converts a child schema to printer output. Plugins instantiate it with their own output type:
257
+ * `string` for the zod and faker printers, `ts.TypeNode` for the TypeScript printer. A printer's
258
+ * `this.transform` fits directly, so its `null` for an empty result carries through to `output`.
259
+ */
260
+ type SchemaTransform<TOutput> = (schema: SchemaNode) => TOutput;
261
+ /**
262
+ * A union or intersection member, or an array or tuple item, paired with its transformed output.
263
+ */
264
+ type MappedSchema<TOutput> = {
265
+ /**
266
+ * The original child schema, kept so the printer can read its metadata for leaf formatting.
267
+ */
268
+ schema: SchemaNode;
269
+ /**
270
+ * The child schema after being run through the transform.
271
+ */
272
+ output: TOutput;
273
+ };
274
+ /**
275
+ * An object property paired with its transformed output.
276
+ */
277
+ type MappedProperty<TOutput> = {
278
+ /**
279
+ * The property name as written on the schema, before any identifier quoting.
280
+ */
281
+ name: string;
282
+ /**
283
+ * The original property node, kept so the printer can read `required`, `schema`, and metadata.
284
+ */
285
+ property: PropertyNode;
286
+ /**
287
+ * The property schema after being run through the transform.
288
+ */
289
+ output: TOutput;
290
+ };
291
+ /**
292
+ * Maps each property of an object schema to its transformed output. Pairs every result with the
293
+ * original property so the printer keeps full control over modifiers, getters, and key syntax.
294
+ *
295
+ * @example
296
+ * ```ts
297
+ * const entries = mapSchemaProperties(node, (schema) => this.transform(schema))
298
+ * // entries: [{ name: 'id', property, output: 'z.number()' }, ...]
299
+ * ```
300
+ */
301
+ declare function mapSchemaProperties<TOutput>(node: ObjectSchemaNode, transform: SchemaTransform<TOutput>): Array<MappedProperty<TOutput>>;
302
+ /**
303
+ * Maps each member of a union or intersection schema to its transformed output, pairing every
304
+ * result with the original member.
305
+ */
306
+ declare function mapSchemaMembers<TOutput>(node: UnionSchemaNode | IntersectionSchemaNode, transform: SchemaTransform<TOutput>): Array<MappedSchema<TOutput>>;
307
+ /**
308
+ * Maps each item of an array or tuple schema to its transformed output, pairing every result with
309
+ * the original item.
310
+ */
311
+ declare function mapSchemaItems<TOutput>(node: ArraySchemaNode, transform: SchemaTransform<TOutput>): Array<MappedSchema<TOutput>>;
312
+ /**
313
+ * Emits a lazy getter for a circular-ref property position, `get name() { return body }`. The key
314
+ * is quoted only when it is not a valid identifier. Used by the string printers to defer evaluation
315
+ * of a recursive schema until first access.
316
+ *
317
+ * @example
318
+ * ```ts
319
+ * lazyGetter({ name: 'parent', body: 'z.lazy(() => Pet)' })
320
+ * // "get parent() { return z.lazy(() => Pet) }"
321
+ * ```
322
+ */
323
+ declare function lazyGetter({
324
+ name,
325
+ body
326
+ }: {
327
+ name: string;
328
+ body: string;
329
+ }): string;
330
+ //#endregion
331
+ export { type BuildGroupArgs, type MappedProperty, type MappedSchema, type ParamGroupType, type SchemaTransform, buildGroupParam, buildJSDoc, buildList, buildObject, buildTypeLiteral, caseParams, childName, collectUsedSchemaNames, containsCircularRef, createOperationParams, enumPropName, extractRefName, extractStringsFromNodes, findCircularSchemas, getNestedAccessor, isStringType, isValidVarName, jsStringEscape, lazyGetter, mapSchemaItems, mapSchemaMembers, mapSchemaProperties, objectKey, resolveGroupType, resolveParamType, resolveRefName, stringify, stringifyObject, syncSchemaRef, toRegExpString, trimQuotes };
243
332
  //# sourceMappingURL=utils.d.ts.map
package/dist/utils.js CHANGED
@@ -1,3 +1,3 @@
1
- import { D as extractRefName, E as enumPropName, F as objectKey, I as isValidVarName, M as buildJSDoc, N as buildList, O as isStringType, P as buildObject, T as childName, _ as stringifyObject, a as resolveParamType, c as findCircularSchemas, g as stringify, h as jsStringEscape, i as createOperationParams, k as resolveGroupType, m as getNestedAccessor, n as buildTypeLiteral, o as collectUsedSchemaNames, r as caseParams, s as containsCircularRef, t as buildGroupParam, v as toRegExpString, w as syncSchemaRef, y as trimQuotes } from "./utils-SdZU0F3H.js";
1
+ import { A as enumPropName, B as objectKey, C as trimQuotes, L as buildJSDoc, M as isStringType, N as resolveGroupType, O as syncSchemaRef, P as resolveRefName, R as buildList, S as toRegExpString, V as isValidVarName, a as resolveParamType, b as stringify, c as mapSchemaMembers, d as containsCircularRef, f as findCircularSchemas, i as createOperationParams, j as extractRefName, k as childName, l as mapSchemaProperties, n as buildTypeLiteral, o as lazyGetter, r as caseParams, s as mapSchemaItems, t as buildGroupParam, u as collectUsedSchemaNames, v as getNestedAccessor, x as stringifyObject, y as jsStringEscape, z as buildObject } from "./utils-Dj_KoXMv.js";
2
2
  import { J as extractStringsFromNodes } from "./response-DKxTr522.js";
3
- export { buildGroupParam, buildJSDoc, buildList, buildObject, buildTypeLiteral, caseParams, childName, collectUsedSchemaNames, containsCircularRef, createOperationParams, enumPropName, extractRefName, extractStringsFromNodes, findCircularSchemas, getNestedAccessor, isStringType, isValidVarName, jsStringEscape, objectKey, resolveGroupType, resolveParamType, stringify, stringifyObject, syncSchemaRef, toRegExpString, trimQuotes };
3
+ export { buildGroupParam, buildJSDoc, buildList, buildObject, buildTypeLiteral, caseParams, childName, collectUsedSchemaNames, containsCircularRef, createOperationParams, enumPropName, extractRefName, extractStringsFromNodes, findCircularSchemas, getNestedAccessor, isStringType, isValidVarName, jsStringEscape, lazyGetter, mapSchemaItems, mapSchemaMembers, mapSchemaProperties, objectKey, resolveGroupType, resolveParamType, resolveRefName, stringify, stringifyObject, syncSchemaRef, toRegExpString, trimQuotes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/ast",
3
- "version": "5.0.0-beta.59",
3
+ "version": "5.0.0-beta.60",
4
4
  "description": "Spec-agnostic AST layer for Kubb. Defines the node tree, visitor pattern, factory functions, and type guards used across all code generation plugins.",
5
5
  "keywords": [
6
6
  "ast",
@@ -23,7 +23,6 @@
23
23
  "!/**/__snapshots__/**"
24
24
  ],
25
25
  "type": "module",
26
- "sideEffects": false,
27
26
  "main": "./dist/index.cjs",
28
27
  "module": "./dist/index.js",
29
28
  "types": "./dist/index.d.ts",
@@ -1,9 +1,11 @@
1
1
  export { isValidVarName } from '@internals/utils'
2
2
  export { buildJSDoc, buildList, buildObject, objectKey } from './codegen.ts'
3
3
  export { extractStringsFromNodes } from './extractStringsFromNodes.ts'
4
- export { childName, enumPropName, extractRefName, isStringType, resolveGroupType } from './refs.ts'
4
+ export { childName, enumPropName, extractRefName, isStringType, resolveGroupType, resolveRefName } from './refs.ts'
5
5
  export { syncSchemaRef } from '../transformers.ts'
6
6
  export { getNestedAccessor, jsStringEscape, stringify, stringifyObject, toRegExpString, trimQuotes } from './strings.ts'
7
7
  export { collectUsedSchemaNames, containsCircularRef, findCircularSchemas } from './schemaGraph.ts'
8
+ export { lazyGetter, mapSchemaItems, mapSchemaMembers, mapSchemaProperties } from './schemaTraversal.ts'
9
+ export type { MappedProperty, MappedSchema, SchemaTransform } from './schemaTraversal.ts'
8
10
  export { buildGroupParam, buildTypeLiteral, caseParams, createOperationParams, resolveParamType } from './operationParams.ts'
9
11
  export type { BuildGroupArgs, ParamGroupType } from './operationParams.ts'
@@ -0,0 +1,86 @@
1
+ import type { ArraySchemaNode, IntersectionSchemaNode, ObjectSchemaNode, PropertyNode, SchemaNode, UnionSchemaNode } from '../nodes/index.ts'
2
+ import { objectKey } from './codegen.ts'
3
+
4
+ /**
5
+ * Converts a child schema to printer output. Plugins instantiate it with their own output type:
6
+ * `string` for the zod and faker printers, `ts.TypeNode` for the TypeScript printer. A printer's
7
+ * `this.transform` fits directly, so its `null` for an empty result carries through to `output`.
8
+ */
9
+ export type SchemaTransform<TOutput> = (schema: SchemaNode) => TOutput
10
+
11
+ /**
12
+ * A union or intersection member, or an array or tuple item, paired with its transformed output.
13
+ */
14
+ export type MappedSchema<TOutput> = {
15
+ /**
16
+ * The original child schema, kept so the printer can read its metadata for leaf formatting.
17
+ */
18
+ schema: SchemaNode
19
+ /**
20
+ * The child schema after being run through the transform.
21
+ */
22
+ output: TOutput
23
+ }
24
+
25
+ /**
26
+ * An object property paired with its transformed output.
27
+ */
28
+ export type MappedProperty<TOutput> = {
29
+ /**
30
+ * The property name as written on the schema, before any identifier quoting.
31
+ */
32
+ name: string
33
+ /**
34
+ * The original property node, kept so the printer can read `required`, `schema`, and metadata.
35
+ */
36
+ property: PropertyNode
37
+ /**
38
+ * The property schema after being run through the transform.
39
+ */
40
+ output: TOutput
41
+ }
42
+
43
+ /**
44
+ * Maps each property of an object schema to its transformed output. Pairs every result with the
45
+ * original property so the printer keeps full control over modifiers, getters, and key syntax.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const entries = mapSchemaProperties(node, (schema) => this.transform(schema))
50
+ * // entries: [{ name: 'id', property, output: 'z.number()' }, ...]
51
+ * ```
52
+ */
53
+ export function mapSchemaProperties<TOutput>(node: ObjectSchemaNode, transform: SchemaTransform<TOutput>): Array<MappedProperty<TOutput>> {
54
+ return node.properties.map((property) => ({ name: property.name, property, output: transform(property.schema) }))
55
+ }
56
+
57
+ /**
58
+ * Maps each member of a union or intersection schema to its transformed output, pairing every
59
+ * result with the original member.
60
+ */
61
+ export function mapSchemaMembers<TOutput>(node: UnionSchemaNode | IntersectionSchemaNode, transform: SchemaTransform<TOutput>): Array<MappedSchema<TOutput>> {
62
+ return (node.members ?? []).map((schema) => ({ schema, output: transform(schema) }))
63
+ }
64
+
65
+ /**
66
+ * Maps each item of an array or tuple schema to its transformed output, pairing every result with
67
+ * the original item.
68
+ */
69
+ export function mapSchemaItems<TOutput>(node: ArraySchemaNode, transform: SchemaTransform<TOutput>): Array<MappedSchema<TOutput>> {
70
+ return (node.items ?? []).map((schema) => ({ schema, output: transform(schema) }))
71
+ }
72
+
73
+ /**
74
+ * Emits a lazy getter for a circular-ref property position, `get name() { return body }`. The key
75
+ * is quoted only when it is not a valid identifier. Used by the string printers to defer evaluation
76
+ * of a recursive schema until first access.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * lazyGetter({ name: 'parent', body: 'z.lazy(() => Pet)' })
81
+ * // "get parent() { return z.lazy(() => Pet) }"
82
+ * ```
83
+ */
84
+ export function lazyGetter({ name, body }: { name: string; body: string }): string {
85
+ return `get ${objectKey(name)}() { return ${body} }`
86
+ }
@@ -1,88 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", {
5
- value,
6
- configurable: true
7
- });
8
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
- var __getOwnPropNames = Object.getOwnPropertyNames;
10
- var __getProtoOf = Object.getPrototypeOf;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __exportAll = (all, no_symbols) => {
13
- let target = {};
14
- for (var name in all) __defProp(target, name, {
15
- get: all[name],
16
- enumerable: true
17
- });
18
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
- return target;
20
- };
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
23
- key = keys[i];
24
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
25
- get: ((k) => from[k]).bind(null, key),
26
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
- });
28
- }
29
- return to;
30
- };
31
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
32
- value: mod,
33
- enumerable: true
34
- }) : target, mod));
35
- //#endregion
36
- //#region ../../internals/utils/src/casing.ts
37
- /**
38
- * Shared implementation for camelCase and PascalCase conversion.
39
- * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
40
- * and capitalizes each word according to `pascal`.
41
- *
42
- * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
43
- */
44
- function toCamelOrPascal(text, pascal) {
45
- return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
46
- if (word.length > 1 && word === word.toUpperCase()) return word;
47
- return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
48
- }).join("").replace(/[^a-zA-Z0-9]/g, "");
49
- }
50
- /**
51
- * Converts `text` to PascalCase.
52
- *
53
- * @example Word boundaries
54
- * `pascalCase('hello-world') // 'HelloWorld'`
55
- *
56
- * @example With a suffix
57
- * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
58
- */
59
- function pascalCase(text, { prefix = "", suffix = "" } = {}) {
60
- return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
61
- }
62
- //#endregion
63
- Object.defineProperty(exports, "__exportAll", {
64
- enumerable: true,
65
- get: function() {
66
- return __exportAll;
67
- }
68
- });
69
- Object.defineProperty(exports, "__name", {
70
- enumerable: true,
71
- get: function() {
72
- return __name;
73
- }
74
- });
75
- Object.defineProperty(exports, "__toESM", {
76
- enumerable: true,
77
- get: function() {
78
- return __toESM;
79
- }
80
- });
81
- Object.defineProperty(exports, "pascalCase", {
82
- enumerable: true,
83
- get: function() {
84
- return pascalCase;
85
- }
86
- });
87
-
88
- //# sourceMappingURL=casing-BE2R1RXg.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"casing-BE2R1RXg.cjs","names":[],"sources":["../../../internals/utils/src/casing.ts"],"sourcesContent":["type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,OAAO,KACJ,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,gBAAgB,OAAO,CAAC,CAChC,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAChC;;;;;;;;;;AAwBA,SAAgB,WAAW,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CAC3F,OAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,IAAI;AAC5D"}