eventmodeler 0.4.7 → 0.6.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 (204) hide show
  1. package/dist/api/client-config.js +10 -0
  2. package/dist/api/generated/client/client.gen.js +235 -0
  3. package/dist/api/generated/client/index.js +6 -0
  4. package/dist/api/generated/client/types.gen.js +2 -0
  5. package/dist/api/generated/client/utils.gen.js +228 -0
  6. package/dist/api/generated/client.gen.js +4 -0
  7. package/dist/api/generated/core/auth.gen.js +14 -0
  8. package/dist/api/generated/core/bodySerializer.gen.js +57 -0
  9. package/dist/api/generated/core/params.gen.js +100 -0
  10. package/dist/api/generated/core/pathSerializer.gen.js +106 -0
  11. package/dist/api/generated/core/queryKeySerializer.gen.js +92 -0
  12. package/dist/api/generated/core/serverSentEvents.gen.js +133 -0
  13. package/dist/api/generated/core/types.gen.js +2 -0
  14. package/dist/api/generated/core/utils.gen.js +87 -0
  15. package/dist/api/generated/index.js +2 -0
  16. package/dist/api/generated/sdk.gen.js +4222 -0
  17. package/dist/api/generated/types.gen.js +2 -0
  18. package/dist/api/generated/zod.gen.js +7217 -0
  19. package/dist/commands/add.js +315 -0
  20. package/dist/commands/auth.js +14 -0
  21. package/dist/commands/create.js +192 -0
  22. package/dist/commands/design.js +108 -0
  23. package/dist/commands/guide.js +15 -0
  24. package/dist/commands/init.js +21 -0
  25. package/dist/commands/list-schemas.js +177 -0
  26. package/dist/commands/list.js +39 -0
  27. package/dist/commands/loop.js +101 -0
  28. package/dist/commands/map.js +40 -0
  29. package/dist/commands/mark.js +27 -0
  30. package/dist/commands/move.js +35 -0
  31. package/dist/commands/remove.js +170 -0
  32. package/dist/commands/rename.js +53 -0
  33. package/dist/commands/resize.js +30 -0
  34. package/dist/commands/search.js +14 -0
  35. package/dist/commands/set.js +199 -0
  36. package/dist/commands/show-schemas.js +259 -0
  37. package/dist/commands/show.js +56 -0
  38. package/dist/commands/summary.js +13 -0
  39. package/dist/commands/update.js +240 -0
  40. package/dist/index.js +46 -2379
  41. package/dist/lib/auth.js +1 -1
  42. package/dist/lib/config.js +0 -15
  43. package/dist/lib/excalidraw-schema.js +66 -0
  44. package/dist/lib/globals.js +8 -0
  45. package/dist/lib/model.js +11 -0
  46. package/dist/lib/project-config.js +20 -0
  47. package/dist/lib/resolve.js +59 -0
  48. package/dist/lib/scenario.js +15 -0
  49. package/dist/slices/add-scenario/index.js +2 -206
  50. package/dist/slices/guide/guides/codegen.js +1 -1
  51. package/dist/slices/guide/guides/connect-slices.js +12 -37
  52. package/dist/slices/guide/guides/create-slices.js +110 -140
  53. package/dist/slices/guide/guides/explore.js +37 -26
  54. package/dist/slices/guide/guides/information-flow.js +70 -82
  55. package/dist/slices/guide/guides/scenarios.js +82 -137
  56. package/dist/slices/guide/index.js +6 -6
  57. package/dist/slices/help/index.js +96 -0
  58. package/dist/slices/help/topics/build-codegen.js +109 -0
  59. package/dist/slices/help/topics/build-slice.js +147 -0
  60. package/dist/slices/help/topics/check-completeness.js +57 -0
  61. package/dist/slices/help/topics/connect-slices.js +99 -0
  62. package/dist/slices/help/topics/explore-model.js +112 -0
  63. package/dist/slices/help/topics/json-reference.js +188 -0
  64. package/dist/slices/help/topics/linked-copies.js +89 -0
  65. package/dist/slices/help/topics/manipulate-canvas.js +150 -0
  66. package/dist/slices/help/topics/write-scenarios.js +162 -0
  67. package/dist/slices/init/index.js +10 -4
  68. package/dist/slices/init/loop.js +60 -0
  69. package/dist/slices/login/index.js +2 -2
  70. package/dist/slices/logout/index.js +2 -2
  71. package/dist/slices/whoami/index.js +11 -36
  72. package/package.json +8 -3
  73. package/dist/api/index.d.ts +0 -285
  74. package/dist/api/index.js +0 -323
  75. package/dist/cloud/slices/index.d.ts +0 -276
  76. package/dist/cloud/slices/index.js +0 -406
  77. package/dist/eventmodeler.js +0 -5646
  78. package/dist/formatters.d.ts +0 -17
  79. package/dist/formatters.js +0 -482
  80. package/dist/index.d.ts +0 -2
  81. package/dist/lib/auth.d.ts +0 -24
  82. package/dist/lib/backend.d.ts +0 -43
  83. package/dist/lib/backend.js +0 -73
  84. package/dist/lib/chapter-utils.d.ts +0 -13
  85. package/dist/lib/chapter-utils.js +0 -71
  86. package/dist/lib/cloud-client.d.ts +0 -69
  87. package/dist/lib/cloud-client.js +0 -364
  88. package/dist/lib/config.d.ts +0 -30
  89. package/dist/lib/diff/merge-rules.d.ts +0 -45
  90. package/dist/lib/diff/merge-rules.js +0 -210
  91. package/dist/lib/diff/model-differ.d.ts +0 -8
  92. package/dist/lib/diff/model-differ.js +0 -568
  93. package/dist/lib/diff/three-way-merge.d.ts +0 -7
  94. package/dist/lib/diff/three-way-merge.js +0 -390
  95. package/dist/lib/diff/types.d.ts +0 -75
  96. package/dist/lib/diff/types.js +0 -1
  97. package/dist/lib/element-lookup.d.ts +0 -58
  98. package/dist/lib/element-lookup.js +0 -126
  99. package/dist/lib/file-loader.d.ts +0 -8
  100. package/dist/lib/file-loader.js +0 -108
  101. package/dist/lib/flow-utils.d.ts +0 -53
  102. package/dist/lib/flow-utils.js +0 -348
  103. package/dist/lib/format.d.ts +0 -10
  104. package/dist/lib/format.js +0 -23
  105. package/dist/lib/project-config.d.ts +0 -27
  106. package/dist/lib/slice-utils.d.ts +0 -59
  107. package/dist/lib/slice-utils.js +0 -140
  108. package/dist/local/slices/index.d.ts +0 -11
  109. package/dist/local/slices/index.js +0 -13
  110. package/dist/projection.d.ts +0 -3
  111. package/dist/projection.js +0 -828
  112. package/dist/slices/add-field/index.d.ts +0 -8
  113. package/dist/slices/add-field/index.js +0 -211
  114. package/dist/slices/add-scenario/index.d.ts +0 -27
  115. package/dist/slices/codegen-chapter-events/index.d.ts +0 -2
  116. package/dist/slices/codegen-chapter-events/index.js +0 -145
  117. package/dist/slices/codegen-slice/index.d.ts +0 -2
  118. package/dist/slices/codegen-slice/index.js +0 -448
  119. package/dist/slices/create-automation-slice/index.d.ts +0 -2
  120. package/dist/slices/create-automation-slice/index.js +0 -304
  121. package/dist/slices/create-flow/index.d.ts +0 -2
  122. package/dist/slices/create-flow/index.js +0 -183
  123. package/dist/slices/create-state-change-slice/index.d.ts +0 -2
  124. package/dist/slices/create-state-change-slice/index.js +0 -263
  125. package/dist/slices/create-state-view-slice/index.d.ts +0 -2
  126. package/dist/slices/create-state-view-slice/index.js +0 -128
  127. package/dist/slices/diff/index.d.ts +0 -11
  128. package/dist/slices/diff/index.js +0 -293
  129. package/dist/slices/export-eventmodel-to-json/index.d.ts +0 -2
  130. package/dist/slices/export-eventmodel-to-json/index.js +0 -355
  131. package/dist/slices/git/index.d.ts +0 -2
  132. package/dist/slices/git/index.js +0 -125
  133. package/dist/slices/guide/guides/codegen.d.ts +0 -5
  134. package/dist/slices/guide/guides/connect-slices.d.ts +0 -5
  135. package/dist/slices/guide/guides/create-slices.d.ts +0 -5
  136. package/dist/slices/guide/guides/explore.d.ts +0 -5
  137. package/dist/slices/guide/guides/information-flow.d.ts +0 -5
  138. package/dist/slices/guide/guides/scenarios.d.ts +0 -5
  139. package/dist/slices/guide/index.d.ts +0 -1
  140. package/dist/slices/import/index.d.ts +0 -8
  141. package/dist/slices/import/index.js +0 -63
  142. package/dist/slices/init/index.d.ts +0 -5
  143. package/dist/slices/list-chapters/index.d.ts +0 -3
  144. package/dist/slices/list-chapters/index.js +0 -21
  145. package/dist/slices/list-commands/index.d.ts +0 -3
  146. package/dist/slices/list-commands/index.js +0 -20
  147. package/dist/slices/list-events/index.d.ts +0 -3
  148. package/dist/slices/list-events/index.js +0 -98
  149. package/dist/slices/list-processors/index.d.ts +0 -3
  150. package/dist/slices/list-processors/index.js +0 -20
  151. package/dist/slices/list-readmodels/index.d.ts +0 -3
  152. package/dist/slices/list-readmodels/index.js +0 -21
  153. package/dist/slices/list-scenarios/index.d.ts +0 -3
  154. package/dist/slices/list-scenarios/index.js +0 -35
  155. package/dist/slices/list-screens/index.d.ts +0 -3
  156. package/dist/slices/list-screens/index.js +0 -47
  157. package/dist/slices/list-slices/index.d.ts +0 -3
  158. package/dist/slices/list-slices/index.js +0 -35
  159. package/dist/slices/login/index.d.ts +0 -1
  160. package/dist/slices/logout/index.d.ts +0 -1
  161. package/dist/slices/map-fields/index.d.ts +0 -2
  162. package/dist/slices/map-fields/index.js +0 -269
  163. package/dist/slices/mark-slice-status/index.d.ts +0 -2
  164. package/dist/slices/mark-slice-status/index.js +0 -31
  165. package/dist/slices/merge/index.d.ts +0 -19
  166. package/dist/slices/merge/index.js +0 -147
  167. package/dist/slices/open-app/index.d.ts +0 -1
  168. package/dist/slices/remove-field/index.d.ts +0 -8
  169. package/dist/slices/remove-field/index.js +0 -167
  170. package/dist/slices/remove-scenario/index.d.ts +0 -2
  171. package/dist/slices/remove-scenario/index.js +0 -77
  172. package/dist/slices/search/index.d.ts +0 -3
  173. package/dist/slices/search/index.js +0 -302
  174. package/dist/slices/show-actor/index.d.ts +0 -4
  175. package/dist/slices/show-actor/index.js +0 -115
  176. package/dist/slices/show-aggregate/index.d.ts +0 -3
  177. package/dist/slices/show-aggregate/index.js +0 -108
  178. package/dist/slices/show-aggregate-completeness/index.d.ts +0 -4
  179. package/dist/slices/show-aggregate-completeness/index.js +0 -181
  180. package/dist/slices/show-chapter/index.d.ts +0 -3
  181. package/dist/slices/show-chapter/index.js +0 -195
  182. package/dist/slices/show-command/index.d.ts +0 -3
  183. package/dist/slices/show-command/index.js +0 -133
  184. package/dist/slices/show-completeness/index.d.ts +0 -4
  185. package/dist/slices/show-completeness/index.js +0 -731
  186. package/dist/slices/show-event/index.d.ts +0 -3
  187. package/dist/slices/show-event/index.js +0 -118
  188. package/dist/slices/show-model-summary/index.d.ts +0 -3
  189. package/dist/slices/show-model-summary/index.js +0 -31
  190. package/dist/slices/show-processor/index.d.ts +0 -3
  191. package/dist/slices/show-processor/index.js +0 -111
  192. package/dist/slices/show-readmodel/index.d.ts +0 -3
  193. package/dist/slices/show-readmodel/index.js +0 -158
  194. package/dist/slices/show-scenario/index.d.ts +0 -3
  195. package/dist/slices/show-scenario/index.js +0 -196
  196. package/dist/slices/show-screen/index.d.ts +0 -3
  197. package/dist/slices/show-screen/index.js +0 -139
  198. package/dist/slices/show-slice/index.d.ts +0 -3
  199. package/dist/slices/show-slice/index.js +0 -696
  200. package/dist/slices/update-field/index.d.ts +0 -15
  201. package/dist/slices/update-field/index.js +0 -208
  202. package/dist/slices/whoami/index.d.ts +0 -2
  203. package/dist/types.d.ts +0 -195
  204. package/dist/types.js +0 -1
@@ -0,0 +1,10 @@
1
+ import { getBackendUrl } from '../lib/config';
2
+ import { getValidAccessToken } from '../lib/auth';
3
+ export const createClientConfig = (config) => ({
4
+ ...config,
5
+ baseUrl: getBackendUrl(),
6
+ auth: async () => {
7
+ const token = await getValidAccessToken();
8
+ return token ?? '';
9
+ },
10
+ });
@@ -0,0 +1,235 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ import { createSseClient } from '../core/serverSentEvents.gen';
3
+ import { getValidRequestBody } from '../core/utils.gen';
4
+ import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, mergeHeaders, setAuthParams, } from './utils.gen';
5
+ export const createClient = (config = {}) => {
6
+ let _config = mergeConfigs(createConfig(), config);
7
+ const getConfig = () => ({ ..._config });
8
+ const setConfig = (config) => {
9
+ _config = mergeConfigs(_config, config);
10
+ return getConfig();
11
+ };
12
+ const interceptors = createInterceptors();
13
+ const beforeRequest = async (options) => {
14
+ const opts = {
15
+ ..._config,
16
+ ...options,
17
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
18
+ headers: mergeHeaders(_config.headers, options.headers),
19
+ serializedBody: undefined,
20
+ };
21
+ if (opts.security) {
22
+ await setAuthParams({
23
+ ...opts,
24
+ security: opts.security,
25
+ });
26
+ }
27
+ if (opts.requestValidator) {
28
+ await opts.requestValidator(opts);
29
+ }
30
+ if (opts.body !== undefined && opts.bodySerializer) {
31
+ opts.serializedBody = opts.bodySerializer(opts.body);
32
+ }
33
+ // remove Content-Type header if body is empty to avoid sending invalid requests
34
+ if (opts.body === undefined || opts.serializedBody === '') {
35
+ opts.headers.delete('Content-Type');
36
+ }
37
+ const url = buildUrl(opts);
38
+ return { opts, url };
39
+ };
40
+ const request = async (options) => {
41
+ // @ts-expect-error
42
+ const { opts, url } = await beforeRequest(options);
43
+ const requestInit = {
44
+ redirect: 'follow',
45
+ ...opts,
46
+ body: getValidRequestBody(opts),
47
+ };
48
+ let request = new Request(url, requestInit);
49
+ for (const fn of interceptors.request.fns) {
50
+ if (fn) {
51
+ request = await fn(request, opts);
52
+ }
53
+ }
54
+ // fetch must be assigned here, otherwise it would throw the error:
55
+ // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
56
+ const _fetch = opts.fetch;
57
+ let response;
58
+ try {
59
+ response = await _fetch(request);
60
+ }
61
+ catch (error) {
62
+ // Handle fetch exceptions (AbortError, network errors, etc.)
63
+ let finalError = error;
64
+ for (const fn of interceptors.error.fns) {
65
+ if (fn) {
66
+ finalError = (await fn(error, undefined, request, opts));
67
+ }
68
+ }
69
+ finalError = finalError || {};
70
+ if (opts.throwOnError) {
71
+ throw finalError;
72
+ }
73
+ // Return error response
74
+ return opts.responseStyle === 'data'
75
+ ? undefined
76
+ : {
77
+ error: finalError,
78
+ request,
79
+ response: undefined,
80
+ };
81
+ }
82
+ for (const fn of interceptors.response.fns) {
83
+ if (fn) {
84
+ response = await fn(response, request, opts);
85
+ }
86
+ }
87
+ const result = {
88
+ request,
89
+ response,
90
+ };
91
+ if (response.ok) {
92
+ const parseAs = (opts.parseAs === 'auto'
93
+ ? getParseAs(response.headers.get('Content-Type'))
94
+ : opts.parseAs) ?? 'json';
95
+ if (response.status === 204 || response.headers.get('Content-Length') === '0') {
96
+ let emptyData;
97
+ switch (parseAs) {
98
+ case 'arrayBuffer':
99
+ case 'blob':
100
+ case 'text':
101
+ emptyData = await response[parseAs]();
102
+ break;
103
+ case 'formData':
104
+ emptyData = new FormData();
105
+ break;
106
+ case 'stream':
107
+ emptyData = response.body;
108
+ break;
109
+ case 'json':
110
+ default:
111
+ emptyData = {};
112
+ break;
113
+ }
114
+ return opts.responseStyle === 'data'
115
+ ? emptyData
116
+ : {
117
+ data: emptyData,
118
+ ...result,
119
+ };
120
+ }
121
+ let data;
122
+ switch (parseAs) {
123
+ case 'arrayBuffer':
124
+ case 'blob':
125
+ case 'formData':
126
+ case 'text':
127
+ data = await response[parseAs]();
128
+ break;
129
+ case 'json': {
130
+ // Some servers return 200 with no Content-Length and empty body.
131
+ // response.json() would throw; read as text and parse if non-empty.
132
+ const text = await response.text();
133
+ data = text ? JSON.parse(text) : {};
134
+ break;
135
+ }
136
+ case 'stream':
137
+ return opts.responseStyle === 'data'
138
+ ? response.body
139
+ : {
140
+ data: response.body,
141
+ ...result,
142
+ };
143
+ }
144
+ if (parseAs === 'json') {
145
+ if (opts.responseValidator) {
146
+ await opts.responseValidator(data);
147
+ }
148
+ if (opts.responseTransformer) {
149
+ data = await opts.responseTransformer(data);
150
+ }
151
+ }
152
+ return opts.responseStyle === 'data'
153
+ ? data
154
+ : {
155
+ data,
156
+ ...result,
157
+ };
158
+ }
159
+ const textError = await response.text();
160
+ let jsonError;
161
+ try {
162
+ jsonError = JSON.parse(textError);
163
+ }
164
+ catch {
165
+ // noop
166
+ }
167
+ const error = jsonError ?? textError;
168
+ let finalError = error;
169
+ for (const fn of interceptors.error.fns) {
170
+ if (fn) {
171
+ finalError = (await fn(error, response, request, opts));
172
+ }
173
+ }
174
+ finalError = finalError || {};
175
+ if (opts.throwOnError) {
176
+ throw finalError;
177
+ }
178
+ // TODO: we probably want to return error and improve types
179
+ return opts.responseStyle === 'data'
180
+ ? undefined
181
+ : {
182
+ error: finalError,
183
+ ...result,
184
+ };
185
+ };
186
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
187
+ const makeSseFn = (method) => async (options) => {
188
+ const { opts, url } = await beforeRequest(options);
189
+ return createSseClient({
190
+ ...opts,
191
+ body: opts.body,
192
+ headers: opts.headers,
193
+ method,
194
+ onRequest: async (url, init) => {
195
+ let request = new Request(url, init);
196
+ for (const fn of interceptors.request.fns) {
197
+ if (fn) {
198
+ request = await fn(request, opts);
199
+ }
200
+ }
201
+ return request;
202
+ },
203
+ serializedBody: getValidRequestBody(opts),
204
+ url,
205
+ });
206
+ };
207
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
208
+ return {
209
+ buildUrl: _buildUrl,
210
+ connect: makeMethodFn('CONNECT'),
211
+ delete: makeMethodFn('DELETE'),
212
+ get: makeMethodFn('GET'),
213
+ getConfig,
214
+ head: makeMethodFn('HEAD'),
215
+ interceptors,
216
+ options: makeMethodFn('OPTIONS'),
217
+ patch: makeMethodFn('PATCH'),
218
+ post: makeMethodFn('POST'),
219
+ put: makeMethodFn('PUT'),
220
+ request,
221
+ setConfig,
222
+ sse: {
223
+ connect: makeSseFn('CONNECT'),
224
+ delete: makeSseFn('DELETE'),
225
+ get: makeSseFn('GET'),
226
+ head: makeSseFn('HEAD'),
227
+ options: makeSseFn('OPTIONS'),
228
+ patch: makeSseFn('PATCH'),
229
+ post: makeSseFn('POST'),
230
+ put: makeSseFn('PUT'),
231
+ trace: makeSseFn('TRACE'),
232
+ },
233
+ trace: makeMethodFn('TRACE'),
234
+ };
235
+ };
@@ -0,0 +1,6 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer.gen';
3
+ export { buildClientParams } from '../core/params.gen';
4
+ export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
5
+ export { createClient } from './client.gen';
6
+ export { createConfig, mergeHeaders } from './utils.gen';
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export {};
@@ -0,0 +1,228 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ import { getAuthToken } from '../core/auth.gen';
3
+ import { jsonBodySerializer } from '../core/bodySerializer.gen';
4
+ import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from '../core/pathSerializer.gen';
5
+ import { getUrl } from '../core/utils.gen';
6
+ export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
7
+ const querySerializer = (queryParams) => {
8
+ const search = [];
9
+ if (queryParams && typeof queryParams === 'object') {
10
+ for (const name in queryParams) {
11
+ const value = queryParams[name];
12
+ if (value === undefined || value === null) {
13
+ continue;
14
+ }
15
+ const options = parameters[name] || args;
16
+ if (Array.isArray(value)) {
17
+ const serializedArray = serializeArrayParam({
18
+ allowReserved: options.allowReserved,
19
+ explode: true,
20
+ name,
21
+ style: 'form',
22
+ value,
23
+ ...options.array,
24
+ });
25
+ if (serializedArray)
26
+ search.push(serializedArray);
27
+ }
28
+ else if (typeof value === 'object') {
29
+ const serializedObject = serializeObjectParam({
30
+ allowReserved: options.allowReserved,
31
+ explode: true,
32
+ name,
33
+ style: 'deepObject',
34
+ value: value,
35
+ ...options.object,
36
+ });
37
+ if (serializedObject)
38
+ search.push(serializedObject);
39
+ }
40
+ else {
41
+ const serializedPrimitive = serializePrimitiveParam({
42
+ allowReserved: options.allowReserved,
43
+ name,
44
+ value: value,
45
+ });
46
+ if (serializedPrimitive)
47
+ search.push(serializedPrimitive);
48
+ }
49
+ }
50
+ }
51
+ return search.join('&');
52
+ };
53
+ return querySerializer;
54
+ };
55
+ /**
56
+ * Infers parseAs value from provided Content-Type header.
57
+ */
58
+ export const getParseAs = (contentType) => {
59
+ if (!contentType) {
60
+ // If no Content-Type header is provided, the best we can do is return the raw response body,
61
+ // which is effectively the same as the 'stream' option.
62
+ return 'stream';
63
+ }
64
+ const cleanContent = contentType.split(';')[0]?.trim();
65
+ if (!cleanContent) {
66
+ return;
67
+ }
68
+ if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) {
69
+ return 'json';
70
+ }
71
+ if (cleanContent === 'multipart/form-data') {
72
+ return 'formData';
73
+ }
74
+ if (['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))) {
75
+ return 'blob';
76
+ }
77
+ if (cleanContent.startsWith('text/')) {
78
+ return 'text';
79
+ }
80
+ return;
81
+ };
82
+ const checkForExistence = (options, name) => {
83
+ if (!name) {
84
+ return false;
85
+ }
86
+ if (options.headers.has(name) ||
87
+ options.query?.[name] ||
88
+ options.headers.get('Cookie')?.includes(`${name}=`)) {
89
+ return true;
90
+ }
91
+ return false;
92
+ };
93
+ export const setAuthParams = async ({ security, ...options }) => {
94
+ for (const auth of security) {
95
+ if (checkForExistence(options, auth.name)) {
96
+ continue;
97
+ }
98
+ const token = await getAuthToken(auth, options.auth);
99
+ if (!token) {
100
+ continue;
101
+ }
102
+ const name = auth.name ?? 'Authorization';
103
+ switch (auth.in) {
104
+ case 'query':
105
+ if (!options.query) {
106
+ options.query = {};
107
+ }
108
+ options.query[name] = token;
109
+ break;
110
+ case 'cookie':
111
+ options.headers.append('Cookie', `${name}=${token}`);
112
+ break;
113
+ case 'header':
114
+ default:
115
+ options.headers.set(name, token);
116
+ break;
117
+ }
118
+ }
119
+ };
120
+ export const buildUrl = (options) => getUrl({
121
+ baseUrl: options.baseUrl,
122
+ path: options.path,
123
+ query: options.query,
124
+ querySerializer: typeof options.querySerializer === 'function'
125
+ ? options.querySerializer
126
+ : createQuerySerializer(options.querySerializer),
127
+ url: options.url,
128
+ });
129
+ export const mergeConfigs = (a, b) => {
130
+ const config = { ...a, ...b };
131
+ if (config.baseUrl?.endsWith('/')) {
132
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
133
+ }
134
+ config.headers = mergeHeaders(a.headers, b.headers);
135
+ return config;
136
+ };
137
+ const headersEntries = (headers) => {
138
+ const entries = [];
139
+ headers.forEach((value, key) => {
140
+ entries.push([key, value]);
141
+ });
142
+ return entries;
143
+ };
144
+ export const mergeHeaders = (...headers) => {
145
+ const mergedHeaders = new Headers();
146
+ for (const header of headers) {
147
+ if (!header) {
148
+ continue;
149
+ }
150
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
151
+ for (const [key, value] of iterator) {
152
+ if (value === null) {
153
+ mergedHeaders.delete(key);
154
+ }
155
+ else if (Array.isArray(value)) {
156
+ for (const v of value) {
157
+ mergedHeaders.append(key, v);
158
+ }
159
+ }
160
+ else if (value !== undefined) {
161
+ // assume object headers are meant to be JSON stringified, i.e., their
162
+ // content value in OpenAPI specification is 'application/json'
163
+ mergedHeaders.set(key, typeof value === 'object' ? JSON.stringify(value) : value);
164
+ }
165
+ }
166
+ }
167
+ return mergedHeaders;
168
+ };
169
+ class Interceptors {
170
+ fns = [];
171
+ clear() {
172
+ this.fns = [];
173
+ }
174
+ eject(id) {
175
+ const index = this.getInterceptorIndex(id);
176
+ if (this.fns[index]) {
177
+ this.fns[index] = null;
178
+ }
179
+ }
180
+ exists(id) {
181
+ const index = this.getInterceptorIndex(id);
182
+ return Boolean(this.fns[index]);
183
+ }
184
+ getInterceptorIndex(id) {
185
+ if (typeof id === 'number') {
186
+ return this.fns[id] ? id : -1;
187
+ }
188
+ return this.fns.indexOf(id);
189
+ }
190
+ update(id, fn) {
191
+ const index = this.getInterceptorIndex(id);
192
+ if (this.fns[index]) {
193
+ this.fns[index] = fn;
194
+ return id;
195
+ }
196
+ return false;
197
+ }
198
+ use(fn) {
199
+ this.fns.push(fn);
200
+ return this.fns.length - 1;
201
+ }
202
+ }
203
+ export const createInterceptors = () => ({
204
+ error: new Interceptors(),
205
+ request: new Interceptors(),
206
+ response: new Interceptors(),
207
+ });
208
+ const defaultQuerySerializer = createQuerySerializer({
209
+ allowReserved: false,
210
+ array: {
211
+ explode: true,
212
+ style: 'form',
213
+ },
214
+ object: {
215
+ explode: true,
216
+ style: 'deepObject',
217
+ },
218
+ });
219
+ const defaultHeaders = {
220
+ 'Content-Type': 'application/json',
221
+ };
222
+ export const createConfig = (override = {}) => ({
223
+ ...jsonBodySerializer,
224
+ headers: defaultHeaders,
225
+ parseAs: 'auto',
226
+ querySerializer: defaultQuerySerializer,
227
+ ...override,
228
+ });
@@ -0,0 +1,4 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ import { createClientConfig } from '../client-config';
3
+ import { createClient, createConfig } from './client';
4
+ export const client = createClient(createClientConfig(createConfig({ baseUrl: 'http://localhost:8080' })));
@@ -0,0 +1,14 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export const getAuthToken = async (auth, callback) => {
3
+ const token = typeof callback === 'function' ? await callback(auth) : callback;
4
+ if (!token) {
5
+ return;
6
+ }
7
+ if (auth.scheme === 'bearer') {
8
+ return `Bearer ${token}`;
9
+ }
10
+ if (auth.scheme === 'basic') {
11
+ return `Basic ${btoa(token)}`;
12
+ }
13
+ return token;
14
+ };
@@ -0,0 +1,57 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ const serializeFormDataPair = (data, key, value) => {
3
+ if (typeof value === 'string' || value instanceof Blob) {
4
+ data.append(key, value);
5
+ }
6
+ else if (value instanceof Date) {
7
+ data.append(key, value.toISOString());
8
+ }
9
+ else {
10
+ data.append(key, JSON.stringify(value));
11
+ }
12
+ };
13
+ const serializeUrlSearchParamsPair = (data, key, value) => {
14
+ if (typeof value === 'string') {
15
+ data.append(key, value);
16
+ }
17
+ else {
18
+ data.append(key, JSON.stringify(value));
19
+ }
20
+ };
21
+ export const formDataBodySerializer = {
22
+ bodySerializer: (body) => {
23
+ const data = new FormData();
24
+ Object.entries(body).forEach(([key, value]) => {
25
+ if (value === undefined || value === null) {
26
+ return;
27
+ }
28
+ if (Array.isArray(value)) {
29
+ value.forEach((v) => serializeFormDataPair(data, key, v));
30
+ }
31
+ else {
32
+ serializeFormDataPair(data, key, value);
33
+ }
34
+ });
35
+ return data;
36
+ },
37
+ };
38
+ export const jsonBodySerializer = {
39
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)),
40
+ };
41
+ export const urlSearchParamsBodySerializer = {
42
+ bodySerializer: (body) => {
43
+ const data = new URLSearchParams();
44
+ Object.entries(body).forEach(([key, value]) => {
45
+ if (value === undefined || value === null) {
46
+ return;
47
+ }
48
+ if (Array.isArray(value)) {
49
+ value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
50
+ }
51
+ else {
52
+ serializeUrlSearchParamsPair(data, key, value);
53
+ }
54
+ });
55
+ return data.toString();
56
+ },
57
+ };
@@ -0,0 +1,100 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ const extraPrefixesMap = {
3
+ $body_: 'body',
4
+ $headers_: 'headers',
5
+ $path_: 'path',
6
+ $query_: 'query',
7
+ };
8
+ const extraPrefixes = Object.entries(extraPrefixesMap);
9
+ const buildKeyMap = (fields, map) => {
10
+ if (!map) {
11
+ map = new Map();
12
+ }
13
+ for (const config of fields) {
14
+ if ('in' in config) {
15
+ if (config.key) {
16
+ map.set(config.key, {
17
+ in: config.in,
18
+ map: config.map,
19
+ });
20
+ }
21
+ }
22
+ else if ('key' in config) {
23
+ map.set(config.key, {
24
+ map: config.map,
25
+ });
26
+ }
27
+ else if (config.args) {
28
+ buildKeyMap(config.args, map);
29
+ }
30
+ }
31
+ return map;
32
+ };
33
+ const stripEmptySlots = (params) => {
34
+ for (const [slot, value] of Object.entries(params)) {
35
+ if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
36
+ delete params[slot];
37
+ }
38
+ }
39
+ };
40
+ export const buildClientParams = (args, fields) => {
41
+ const params = {
42
+ body: {},
43
+ headers: {},
44
+ path: {},
45
+ query: {},
46
+ };
47
+ const map = buildKeyMap(fields);
48
+ let config;
49
+ for (const [index, arg] of args.entries()) {
50
+ if (fields[index]) {
51
+ config = fields[index];
52
+ }
53
+ if (!config) {
54
+ continue;
55
+ }
56
+ if ('in' in config) {
57
+ if (config.key) {
58
+ const field = map.get(config.key);
59
+ const name = field.map || config.key;
60
+ if (field.in) {
61
+ params[field.in][name] = arg;
62
+ }
63
+ }
64
+ else {
65
+ params.body = arg;
66
+ }
67
+ }
68
+ else {
69
+ for (const [key, value] of Object.entries(arg ?? {})) {
70
+ const field = map.get(key);
71
+ if (field) {
72
+ if (field.in) {
73
+ const name = field.map || key;
74
+ params[field.in][name] = value;
75
+ }
76
+ else {
77
+ params[field.map] = value;
78
+ }
79
+ }
80
+ else {
81
+ const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
82
+ if (extra) {
83
+ const [prefix, slot] = extra;
84
+ params[slot][key.slice(prefix.length)] = value;
85
+ }
86
+ else if ('allowExtra' in config && config.allowExtra) {
87
+ for (const [slot, allowed] of Object.entries(config.allowExtra)) {
88
+ if (allowed) {
89
+ params[slot][key] = value;
90
+ break;
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ stripEmptySlots(params);
99
+ return params;
100
+ };