@goast/core 0.4.1-springwebclient1 → 0.4.2

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 (48) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +67 -67
  3. package/package.json +1 -1
  4. package/src/_dnt.shims.ts +69 -0
  5. package/src/mod.ts +33 -0
  6. package/src/src/ast/node.ts +46 -0
  7. package/src/src/codegen/config.ts +28 -0
  8. package/src/src/codegen/endpoints-generator.ts +72 -0
  9. package/src/src/codegen/generator.ts +181 -0
  10. package/src/src/codegen/internal-utils.ts +6 -0
  11. package/src/src/codegen/schemas-generator.ts +87 -0
  12. package/src/src/codegen/services-generator.ts +77 -0
  13. package/src/src/codegen/types.ts +37 -0
  14. package/src/src/collect/collector.ts +142 -0
  15. package/src/src/collect/helpers.ts +36 -0
  16. package/src/src/collect/types.ts +21 -0
  17. package/src/src/internal-utils.ts +5 -0
  18. package/src/src/parse/deref-proxy.ts +64 -0
  19. package/src/src/parse/openapi-types.ts +949 -0
  20. package/src/src/parse/parser.ts +220 -0
  21. package/src/src/parse/types.ts +27 -0
  22. package/src/src/transform/api-types.ts +243 -0
  23. package/src/src/transform/helpers.ts +216 -0
  24. package/src/src/transform/transform-document.ts +35 -0
  25. package/src/src/transform/transform-endpoint.ts +331 -0
  26. package/src/src/transform/transform-schema.ts +217 -0
  27. package/src/src/transform/transformer.ts +52 -0
  28. package/src/src/transform/types.ts +52 -0
  29. package/src/src/utils/action-provider.ts +58 -0
  30. package/src/src/utils/array.utils.ts +7 -0
  31. package/src/src/utils/asset-manager.ts +51 -0
  32. package/src/src/utils/class.utils.ts +40 -0
  33. package/src/src/utils/common.utils.ts +86 -0
  34. package/src/src/utils/condition.ts +7 -0
  35. package/src/src/utils/endpoint.utils.ts +10 -0
  36. package/src/src/utils/error.utils.ts +3 -0
  37. package/src/src/utils/factory.ts +42 -0
  38. package/src/src/utils/file-system.utils.ts +48 -0
  39. package/src/src/utils/generator.utils.ts +6 -0
  40. package/src/src/utils/object.utils.ts +32 -0
  41. package/src/src/utils/schema.utils.ts +142 -0
  42. package/src/src/utils/source-builder.ts +597 -0
  43. package/src/src/utils/string-builder/options.ts +19 -0
  44. package/src/src/utils/string-builder/string-builder.ts +165 -0
  45. package/src/src/utils/string-builder/utils.ts +69 -0
  46. package/src/src/utils/string.utils.ts +369 -0
  47. package/src/src/utils/string.utils.types.ts +179 -0
  48. package/src/src/utils/type.utils.ts +93 -0
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Represents a casing for a word.
3
+ * @example
4
+ * toCasing('fooBar', 'unchanged') // => 'fooBar'
5
+ * toCasing('fooBar', 'all-lower') // => 'foobar'
6
+ * toCasing('fooBar', 'all-upper') // => 'FOOBAR'
7
+ * toCasing('fooBar', 'first-upper') // => 'FooBar'
8
+ * toCasing('FooBar', 'first-lower') // => 'fooBar'
9
+ * toCasing('fooBar', 'first-upper-then-lower') // => 'Foobar'
10
+ * toCasing('FooBar', 'first-lower-then-upper') // => 'fOOBAR'
11
+ * toCasing('fooBar', 'first-upper-alternating') // => 'FoObAr'
12
+ * toCasing('FooBar', 'first-lower-alternating') // => 'fOoBaR'
13
+ */
14
+ export type WordCasing =
15
+ | 'unchanged'
16
+ | 'all-lower'
17
+ | 'all-upper'
18
+ | 'first-upper'
19
+ | 'first-lower'
20
+ | 'first-upper-then-lower'
21
+ | 'first-lower-then-upper'
22
+ | 'first-upper-alternating'
23
+ | 'first-lower-alternating';
24
+
25
+ /**
26
+ * Represents a casing for a string.
27
+ * @example
28
+ * toCase('fooBar', 'unchanged') // => 'fooBar'
29
+ * toCase('fooBar', 'all-lower') // => 'foobar'
30
+ * toCase('fooBar', 'all-upper') // => 'FOOBAR'
31
+ * toCase('fooBar', 'first-upper') // => 'FooBar'
32
+ * toCase('FooBar', 'first-lower') // => 'fooBar'
33
+ * toCase('fooBar', 'first-upper-then-lower') // => 'Foobar'
34
+ * toCase('FooBar', 'first-lower-then-upper') // => 'fOOBAR'
35
+ * toCase('fooBar', 'first-upper-alternating') // => 'FoObAr'
36
+ * toCase('FooBar', 'first-lower-alternating') // => 'fOoBaR'
37
+ * toCase('fooBar', 'camel') // => 'fooBar'
38
+ * toCase('fooBar', 'pascal') // => 'FooBar'
39
+ * toCase('fooBar', 'kebab') // => 'foo-bar'
40
+ * toCase('fooBar', 'snake') // => 'foo_bar'
41
+ */
42
+ export type StringCasing = WordCasing | 'camel' | 'pascal' | 'kebab' | 'snake' | 'custom';
43
+
44
+ export type StringCasingWithOptions<T extends StringCasing = StringCasing> = {
45
+ casing: T;
46
+ } & CaseOptions<T>;
47
+
48
+ export type ExtendedStringCasing = StringCasing | StringCasingWithOptions;
49
+
50
+ export type CaseOptions<T extends StringCasing> = T extends 'camel' ? Partial<CamelCaseOptions>
51
+ : T extends 'pascal' ? Partial<PascalCaseOptions>
52
+ : T extends 'kebab' ? Partial<KebabCaseOptions>
53
+ : T extends 'snake' ? Partial<SnakeCaseOptions>
54
+ : T extends 'custom' ? CustomCaseOptions
55
+ : never;
56
+
57
+ export type BaseCaseOptions = {
58
+ /**
59
+ * Specifies a prefix to add to the string.
60
+ * @default undefined
61
+ * @example
62
+ * toCase('foo', { prefix: 'bar' }) // => 'barfoo'
63
+ */
64
+ prefix?: string;
65
+ /**
66
+ * Specifies a suffix to add to the string.
67
+ * @default undefined
68
+ * @example
69
+ * toCase('foo', { suffix: 'bar' }) // => 'foobar'
70
+ */
71
+ suffix?: string;
72
+ };
73
+
74
+ export type CamelCaseOptions = BaseCaseOptions & {
75
+ /**
76
+ * Controls the casing of all characters except the first one for each word.
77
+ *
78
+ * If true, all characters except the first one will remain unchanged; otherwise, all characters except the first one will be converted to lowercase.
79
+ *
80
+ * @default false
81
+ * @example
82
+ * toCamelCase('fooBAR') // => 'fooBar'
83
+ * toCamelCase('fooBAR', { keepOriginalCase: false }) // => 'fooBar'
84
+ * toCamelCase('fooBAR', { keepOriginalCase: true }) // => 'fooBAR'
85
+ */
86
+ keepOriginalCase: boolean;
87
+ };
88
+
89
+ export type PascalCaseOptions = BaseCaseOptions & {
90
+ /**
91
+ * Controls the casing of all characters except the first one for each word.
92
+ *
93
+ * If true, all characters except the first one will remain unchanged; otherwise, all characters except the first one will be converted to lowercase.
94
+ *
95
+ * @default false
96
+ * @example
97
+ * toCamelCase('FooBAR') // => 'FooBar'
98
+ * toCamelCase('FooBAR', { keepOriginalCase: false }) // => 'FooBar'
99
+ * toCamelCase('FooBAR', { keepOriginalCase: true }) // => 'FooBAR'
100
+ */
101
+ keepOriginalCase: boolean;
102
+ };
103
+
104
+ export type KebabCaseOptions = BaseCaseOptions & {
105
+ /**
106
+ * Specifies the casing of words.
107
+ * @default 'all-lower'
108
+ * @example
109
+ * toKebabCase('Foo bAR') // => 'foo-bar'
110
+ * toKebabCase('Foo bAR', { wordCasing: 'all-upper' }) // => 'FOO-BAR'
111
+ */
112
+ wordCasing: WordCasing;
113
+ /**
114
+ * Specifies the casing of the first word. If undefined uses the casing option.
115
+ * @default undefined
116
+ * @example
117
+ * toKebabCase('Foo bAR') // => 'foo-bar'
118
+ * toKebabCase('Foo bAR', { firstWordCasing: 'all-upper' }) // => 'FOO-bar'
119
+ * toKebabCase('Foo bAR', { wordCasing: 'all-upper', firstWordCasing: 'all-lower' }) // => 'foo-BAR'
120
+ */
121
+ firstWordCasing?: WordCasing;
122
+ };
123
+
124
+ export type SnakeCaseOptions = BaseCaseOptions & {
125
+ /**
126
+ * Specifies the casing of words.
127
+ * @default 'all-upper'
128
+ * @example
129
+ * toSnakeCase('Foo bAR') // => 'FOO_BAR'
130
+ * toSnakeCase('Foo bAR', { wordCasing: 'all-lower' }) // => 'foo_bar'
131
+ */
132
+ wordCasing: WordCasing;
133
+ /**
134
+ * Specifies the casing of the first word. If undefined uses the casing option.
135
+ * @default undefined
136
+ * @example
137
+ * toSnakeCase('Foo bAR') // => 'FOO_BAR'
138
+ * toSnakeCase('Foo bAR', { firstWordCasing: 'all-lower' }) // => 'foo_BAR'
139
+ * toSnakeCase('Foo bAR', { wordCasing: 'all-lower', firstWordCasing: 'all-upper' }) // => 'FOO_bar'
140
+ */
141
+ firstWordCasing?: WordCasing;
142
+ };
143
+
144
+ export type CustomCaseOptions =
145
+ & BaseCaseOptions
146
+ & {
147
+ /**
148
+ * Specifies the separator between words.
149
+ * @default undefined
150
+ * @example
151
+ * toCustomCase('Foo bAR', { wordCasing: 'first-upper-then-lower', wordSeparator: '~' }) // => 'Foo~Bar'
152
+ */
153
+ wordSeparator?: string;
154
+ }
155
+ & (
156
+ | {
157
+ /**
158
+ * Specifies the casing of words.
159
+ * @example
160
+ * toCustomCase('Foo bAR', { wordCasing: 'first-upper-then-lower' }) // => 'FooBar'
161
+ */
162
+ wordCasing: WordCasing;
163
+ /**
164
+ * Specifies the casing of the first word. If undefined uses the casing option.
165
+ * @default undefined
166
+ * @example
167
+ * toCustomCase('Foo bAR', { wordCasing: 'first-upper-then-lower', firstWordCasing: 'all-upper' }) // => 'FOOBar'
168
+ */
169
+ firstWordCasing?: WordCasing;
170
+ }
171
+ | {
172
+ /**
173
+ * Specifies the casing of words.
174
+ * @example
175
+ * toCustomCase('Foo bAR baz', { wordCasing: (wordIndex) => (wordIndex % 2 === 0 ? 'all-upper' : 'all-lower') }) // => 'FOObarBAZ'
176
+ */
177
+ wordCasing: (wordIndex: number) => WordCasing;
178
+ }
179
+ );
@@ -0,0 +1,93 @@
1
+ // deno-lint-ignore-file no-explicit-any ban-types
2
+ export type Merge<U extends unknown[]> = U extends [infer A, ...infer R] ? A & Merge<R> : {};
3
+
4
+ export type OptionalProperties<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
5
+ export type RequiredProperties<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
6
+
7
+ export type ArrayItem<T> = T extends (infer U)[] ? U : never;
8
+ export type SingleOrMultiple<T> = T | T[];
9
+ export type Single<T> = T extends (infer U)[] ? U : T;
10
+ export type Multiple<T> = T extends (infer U)[] ? U[] : T[];
11
+
12
+ export type Nullable<T> = T | null | undefined;
13
+
14
+ export interface Constructor<T, TArgs extends any[] = any[]> extends Function {
15
+ new (...args: TArgs): T;
16
+ }
17
+
18
+ export type EmptyConstructor<T> = Constructor<T, []>;
19
+
20
+ export type FunctionNames<T> = {
21
+ [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
22
+ }[keyof T];
23
+
24
+ export type Prettify<T> =
25
+ & {
26
+ [K in keyof T]: T[K];
27
+ }
28
+ & {};
29
+
30
+ export type ValueOf<T> = T[keyof T];
31
+
32
+ export type NonEmptyArray<T> = [T, ...T[]];
33
+
34
+ type MustInclude<T, U extends T[]> = [T] extends [ValueOf<U>] ? U : never;
35
+ export function stringUnionToArray<T>(): <U extends NonEmptyArray<T>>(
36
+ ...elements: MustInclude<T, U>
37
+ ) => MustInclude<T, U> {
38
+ return (...elements) => elements;
39
+ }
40
+
41
+ export type StringSuggestions<T extends string> = T | Omit<string, T>;
42
+ export function suggestionsAsString<T>(
43
+ value: T,
44
+ ): T extends StringSuggestions<infer U> ? Exclude<T, StringSuggestions<U>> | string : T {
45
+ return value as any;
46
+ }
47
+
48
+ export type ParametersWithOverloads<T extends (...args: any[]) => any> = T extends {
49
+ (...args: infer A1): any;
50
+ (...args: infer A2): any;
51
+ (...args: infer A3): any;
52
+ (...args: infer A4): any;
53
+ (...args: infer A5): any;
54
+ (...args: infer A6): any;
55
+ } ? A1 | A2 | A3 | A4 | A5 | A6
56
+ : T extends {
57
+ (...args: infer A1): any;
58
+ (...args: infer A2): any;
59
+ (...args: infer A3): any;
60
+ (...args: infer A4): any;
61
+ (...args: infer A5): any;
62
+ } ? A1 | A2 | A3 | A4 | A5
63
+ : T extends {
64
+ (...args: infer A1): any;
65
+ (...args: infer A2): any;
66
+ (...args: infer A3): any;
67
+ (...args: infer A4): any;
68
+ } ? A1 | A2 | A3 | A4
69
+ : T extends {
70
+ (...args: infer A1): any;
71
+ (...args: infer A2): any;
72
+ (...args: infer A3): any;
73
+ } ? A1 | A2 | A3
74
+ : T extends {
75
+ (...args: infer A1): any;
76
+ (...args: infer A2): any;
77
+ } ? A1 | A2
78
+ : T extends {
79
+ (...args: infer A1): any;
80
+ } ? A1
81
+ : never;
82
+
83
+ type _TupleOf<T, N extends number, R extends unknown[]> = R['length'] extends N ? R : _TupleOf<T, N, [T, ...R]>;
84
+ export type TupleWithCount<T, N extends number | number[]> = N extends number ? number extends N ? T[]
85
+ : _TupleOf<T, N, []>
86
+ : N extends [infer A, ...infer R]
87
+ ? A extends number ? R extends number[] ? TupleWithCount<T, A> | TupleWithCount<T, R>
88
+ : never
89
+ : never
90
+ : N extends [] ? never
91
+ : T[];
92
+
93
+ export type MaybePromise<T> = T | Promise<T>;