@scalar/oas-utils 0.1.17 → 0.2.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 (158) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/entities/index.d.ts +2 -0
  3. package/dist/entities/index.d.ts.map +1 -0
  4. package/dist/entities/index.js +1 -0
  5. package/dist/entities/workspace/collection/collection.d.ts +314 -0
  6. package/dist/entities/workspace/collection/collection.d.ts.map +1 -0
  7. package/dist/entities/workspace/collection/collection.js +112 -0
  8. package/dist/entities/workspace/collection/index.d.ts +2 -0
  9. package/dist/entities/workspace/collection/index.d.ts.map +1 -0
  10. package/dist/entities/workspace/collection/index.js +1 -0
  11. package/dist/entities/workspace/cookie/cookie.d.ts +84 -0
  12. package/dist/entities/workspace/cookie/cookie.d.ts.map +1 -0
  13. package/dist/entities/workspace/cookie/cookie.js +44 -0
  14. package/dist/entities/workspace/cookie/index.d.ts +2 -0
  15. package/dist/entities/workspace/cookie/index.d.ts.map +1 -0
  16. package/dist/entities/workspace/cookie/index.js +1 -0
  17. package/dist/entities/workspace/environment/environment.d.ts +55 -0
  18. package/dist/entities/workspace/environment/environment.d.ts.map +1 -0
  19. package/dist/entities/workspace/environment/environment.js +23 -0
  20. package/dist/entities/workspace/environment/index.d.ts +2 -0
  21. package/dist/entities/workspace/environment/index.d.ts.map +1 -0
  22. package/dist/entities/workspace/environment/index.js +1 -0
  23. package/dist/entities/workspace/folder/folder.d.ts +36 -0
  24. package/dist/entities/workspace/folder/folder.d.ts.map +1 -0
  25. package/dist/entities/workspace/folder/folder.js +21 -0
  26. package/dist/entities/workspace/folder/index.d.ts +2 -0
  27. package/dist/entities/workspace/folder/index.d.ts.map +1 -0
  28. package/dist/entities/workspace/folder/index.js +1 -0
  29. package/dist/entities/workspace/index.d.ts +2 -0
  30. package/dist/entities/workspace/index.d.ts.map +1 -0
  31. package/dist/entities/workspace/index.js +1 -0
  32. package/dist/entities/workspace/security-schemes/index.d.ts +2 -0
  33. package/dist/entities/workspace/security-schemes/index.d.ts.map +1 -0
  34. package/dist/entities/workspace/security-schemes/index.js +1 -0
  35. package/dist/entities/workspace/security-schemes/security-schemes.d.ts +19 -0
  36. package/dist/entities/workspace/security-schemes/security-schemes.d.ts.map +1 -0
  37. package/dist/entities/workspace/security-schemes/security-schemes.js +15 -0
  38. package/dist/entities/workspace/server/index.d.ts +2 -0
  39. package/dist/entities/workspace/server/index.d.ts.map +1 -0
  40. package/dist/entities/workspace/server/index.js +1 -0
  41. package/dist/entities/workspace/server/server.d.ts +84 -0
  42. package/dist/entities/workspace/server/server.d.ts.map +1 -0
  43. package/dist/entities/workspace/server/server.js +46 -0
  44. package/dist/entities/workspace/shared/index.d.ts +2 -0
  45. package/dist/entities/workspace/shared/index.d.ts.map +1 -0
  46. package/dist/entities/workspace/shared/index.js +1 -0
  47. package/dist/entities/workspace/shared/utility.d.ts +6 -0
  48. package/dist/entities/workspace/shared/utility.d.ts.map +1 -0
  49. package/dist/entities/workspace/shared/utility.js +11 -0
  50. package/dist/entities/workspace/spec/components.d.ts +3 -0
  51. package/dist/entities/workspace/spec/components.d.ts.map +1 -0
  52. package/dist/entities/workspace/spec/index.d.ts +5 -0
  53. package/dist/entities/workspace/spec/index.d.ts.map +1 -0
  54. package/dist/entities/workspace/spec/index.js +2 -0
  55. package/dist/entities/workspace/spec/parameters.d.ts +16 -0
  56. package/dist/entities/workspace/spec/parameters.d.ts.map +1 -0
  57. package/dist/entities/workspace/spec/refs.d.ts +30 -0
  58. package/dist/entities/workspace/spec/refs.d.ts.map +1 -0
  59. package/dist/entities/workspace/spec/refs.js +9 -0
  60. package/dist/entities/workspace/spec/request-examples.d.ts +479 -0
  61. package/dist/entities/workspace/spec/request-examples.d.ts.map +1 -0
  62. package/dist/entities/workspace/spec/request-examples.js +68 -0
  63. package/dist/entities/workspace/spec/requests.d.ts +149 -0
  64. package/dist/entities/workspace/spec/requests.d.ts.map +1 -0
  65. package/dist/entities/workspace/spec/requests.js +52 -0
  66. package/dist/entities/workspace/spec/spec.d.ts +18 -0
  67. package/dist/entities/workspace/spec/spec.d.ts.map +1 -0
  68. package/dist/entities/workspace/spec/spec.js +8 -0
  69. package/dist/entities/workspace/workspace.d.ts +45 -0
  70. package/dist/entities/workspace/workspace.d.ts.map +1 -0
  71. package/dist/entities/workspace/workspace.js +20 -0
  72. package/dist/helpers/createHash.d.ts.map +1 -0
  73. package/dist/helpers/createHash.js +20 -0
  74. package/dist/helpers/deepMerge.d.ts +7 -0
  75. package/dist/helpers/deepMerge.d.ts.map +1 -0
  76. package/dist/helpers/deepMerge.js +28 -0
  77. package/dist/helpers/fetchSpecFromUrl.d.ts.map +1 -0
  78. package/dist/helpers/fetchSpecFromUrl.js +31 -0
  79. package/dist/helpers/httpMethods.d.ts +93 -0
  80. package/dist/helpers/httpMethods.d.ts.map +1 -0
  81. package/dist/helpers/httpMethods.js +64 -0
  82. package/dist/helpers/httpStatusCodes.d.ts.map +1 -0
  83. package/dist/helpers/httpStatusCodes.js +252 -0
  84. package/dist/helpers/index.d.ts +14 -0
  85. package/dist/helpers/index.d.ts.map +1 -0
  86. package/dist/helpers/index.js +13 -0
  87. package/dist/helpers/iterateTitle.d.ts +5 -0
  88. package/dist/helpers/iterateTitle.d.ts.map +1 -0
  89. package/dist/helpers/iterateTitle.js +15 -0
  90. package/dist/helpers/json2xml.d.ts.map +1 -0
  91. package/dist/helpers/json2xml.js +51 -0
  92. package/dist/{normalizeMimeType.d.ts → helpers/normalizeMimeType.d.ts} +1 -1
  93. package/dist/helpers/normalizeMimeType.d.ts.map +1 -0
  94. package/dist/helpers/normalizeMimeType.js +20 -0
  95. package/dist/{normalizeMimeTypeObject.d.ts → helpers/normalizeMimeTypeObject.d.ts} +1 -1
  96. package/dist/helpers/normalizeMimeTypeObject.d.ts.map +1 -0
  97. package/dist/helpers/normalizeMimeTypeObject.js +34 -0
  98. package/dist/helpers/objectMerge.d.ts +5 -0
  99. package/dist/helpers/objectMerge.d.ts.map +1 -0
  100. package/dist/helpers/objectMerge.js +16 -0
  101. package/dist/{parse.d.ts → helpers/parse.d.ts} +1 -1
  102. package/dist/helpers/parse.d.ts.map +1 -0
  103. package/dist/helpers/parse.js +89 -0
  104. package/dist/helpers/prettyPrintJson.d.ts.map +1 -0
  105. package/dist/helpers/prettyPrintJson.js +19 -0
  106. package/dist/helpers/schema-model.d.ts +5 -0
  107. package/dist/helpers/schema-model.d.ts.map +1 -0
  108. package/dist/helpers/schema-model.js +21 -0
  109. package/dist/{ssrState.d.ts → helpers/ssrState.d.ts} +1 -1
  110. package/dist/helpers/ssrState.d.ts.map +1 -0
  111. package/dist/helpers/ssrState.js +9 -0
  112. package/dist/index.d.ts +0 -15
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +0 -914
  115. package/dist/spec-getters/getExampleFromSchema.d.ts.map +1 -0
  116. package/dist/spec-getters/getExampleFromSchema.js +246 -0
  117. package/dist/{getParametersFromOperation.d.ts → spec-getters/getParametersFromOperation.d.ts} +1 -1
  118. package/dist/spec-getters/getParametersFromOperation.d.ts.map +1 -0
  119. package/dist/spec-getters/getParametersFromOperation.js +44 -0
  120. package/dist/{getRequestBodyFromOperation.d.ts → spec-getters/getRequestBodyFromOperation.d.ts} +1 -1
  121. package/dist/spec-getters/getRequestBodyFromOperation.d.ts.map +1 -0
  122. package/dist/spec-getters/getRequestBodyFromOperation.js +199 -0
  123. package/dist/{getRequestFromOperation.d.ts → spec-getters/getRequestFromOperation.d.ts} +5 -1
  124. package/dist/spec-getters/getRequestFromOperation.d.ts.map +1 -0
  125. package/dist/spec-getters/getRequestFromOperation.js +49 -0
  126. package/dist/spec-getters/index.d.ts +5 -0
  127. package/dist/spec-getters/index.d.ts.map +1 -0
  128. package/dist/spec-getters/index.js +4 -0
  129. package/dist/transforms/import-spec.d.ts +67 -0
  130. package/dist/transforms/import-spec.d.ts.map +1 -0
  131. package/dist/transforms/import-spec.js +133 -0
  132. package/dist/transforms/index.d.ts +2 -0
  133. package/dist/transforms/index.d.ts.map +1 -0
  134. package/dist/transforms/index.js +1 -0
  135. package/dist/types.d.ts +43 -2
  136. package/dist/types.d.ts.map +1 -1
  137. package/package.json +62 -13
  138. package/dist/createHash.d.ts.map +0 -1
  139. package/dist/fetchSpecFromUrl.d.ts.map +0 -1
  140. package/dist/getExampleFromSchema.d.ts.map +0 -1
  141. package/dist/getHarRequest.d.ts +0 -4
  142. package/dist/getHarRequest.d.ts.map +0 -1
  143. package/dist/getParametersFromOperation.d.ts.map +0 -1
  144. package/dist/getRequestBodyFromOperation.d.ts.map +0 -1
  145. package/dist/getRequestFromOperation.d.ts.map +0 -1
  146. package/dist/httpStatusCodes.d.ts.map +0 -1
  147. package/dist/json2xml.d.ts.map +0 -1
  148. package/dist/normalizeMimeType.d.ts.map +0 -1
  149. package/dist/normalizeMimeTypeObject.d.ts.map +0 -1
  150. package/dist/parse.d.ts.map +0 -1
  151. package/dist/prettyPrintJson.d.ts.map +0 -1
  152. package/dist/ssrState.d.ts.map +0 -1
  153. /package/dist/{createHash.d.ts → helpers/createHash.d.ts} +0 -0
  154. /package/dist/{fetchSpecFromUrl.d.ts → helpers/fetchSpecFromUrl.d.ts} +0 -0
  155. /package/dist/{httpStatusCodes.d.ts → helpers/httpStatusCodes.d.ts} +0 -0
  156. /package/dist/{json2xml.d.ts → helpers/json2xml.d.ts} +0 -0
  157. /package/dist/{prettyPrintJson.d.ts → helpers/prettyPrintJson.d.ts} +0 -0
  158. /package/dist/{getExampleFromSchema.d.ts → spec-getters/getExampleFromSchema.d.ts} +0 -0
@@ -0,0 +1,252 @@
1
+ const httpStatusCodes = {
2
+ 100: {
3
+ name: 'Continue',
4
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100',
5
+ },
6
+ 101: {
7
+ name: 'Switching Protocols',
8
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/101',
9
+ },
10
+ 102: {
11
+ name: 'Processing',
12
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/102',
13
+ },
14
+ 103: {
15
+ name: 'Early Hints',
16
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103',
17
+ },
18
+ 200: {
19
+ name: 'OK',
20
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200',
21
+ },
22
+ 201: {
23
+ name: 'Created',
24
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201',
25
+ },
26
+ 202: {
27
+ name: 'Accepted',
28
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202',
29
+ },
30
+ 203: {
31
+ name: 'Non-Authoritative Information',
32
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/203',
33
+ },
34
+ 204: {
35
+ name: 'No Content',
36
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204',
37
+ },
38
+ 205: {
39
+ name: 'Reset Content',
40
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/205',
41
+ },
42
+ 206: {
43
+ name: 'Partial Content',
44
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206',
45
+ },
46
+ 207: {
47
+ name: 'Multi-Status',
48
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/207',
49
+ },
50
+ 208: {
51
+ name: 'Already Reported',
52
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/208',
53
+ },
54
+ 226: {
55
+ name: 'IM Used',
56
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/226',
57
+ },
58
+ 300: {
59
+ name: 'Multiple Choices',
60
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/300',
61
+ },
62
+ 301: {
63
+ name: 'Moved Permanently',
64
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301',
65
+ },
66
+ 302: {
67
+ name: 'Found',
68
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302',
69
+ },
70
+ 303: {
71
+ name: 'See Other',
72
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303',
73
+ },
74
+ 304: {
75
+ name: 'Not Modified',
76
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304',
77
+ },
78
+ 305: {
79
+ name: 'Use Proxy',
80
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/305',
81
+ },
82
+ 306: {
83
+ name: '(Unused)',
84
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/306',
85
+ },
86
+ 307: {
87
+ name: 'Temporary Redirect',
88
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307',
89
+ },
90
+ 308: {
91
+ name: 'Permanent Redirect',
92
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308',
93
+ },
94
+ 400: {
95
+ name: 'Bad Request',
96
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400',
97
+ },
98
+ 401: {
99
+ name: 'Unauthorized',
100
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401',
101
+ },
102
+ 402: {
103
+ name: 'Payment Required',
104
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402',
105
+ },
106
+ 403: {
107
+ name: 'Forbidden',
108
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403',
109
+ },
110
+ 404: {
111
+ name: 'Not Found',
112
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404',
113
+ },
114
+ 405: {
115
+ name: 'Method Not Allowed',
116
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405',
117
+ },
118
+ 406: {
119
+ name: 'Not Acceptable',
120
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406',
121
+ },
122
+ 407: {
123
+ name: 'Proxy Authentication Required',
124
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407',
125
+ },
126
+ 408: {
127
+ name: 'Request Timeout',
128
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408',
129
+ },
130
+ 409: {
131
+ name: 'Conflict',
132
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409',
133
+ },
134
+ 410: {
135
+ name: 'Gone',
136
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/410',
137
+ },
138
+ 411: {
139
+ name: 'Length Required',
140
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/411',
141
+ },
142
+ 412: {
143
+ name: 'Precondition Failed',
144
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412',
145
+ },
146
+ 413: {
147
+ name: 'Content Too Large',
148
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413',
149
+ },
150
+ 414: {
151
+ name: 'URI Too Long',
152
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414',
153
+ },
154
+ 415: {
155
+ name: 'Unsupported Media Type',
156
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415',
157
+ },
158
+ 416: {
159
+ name: 'Range Not Satisfiable',
160
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416',
161
+ },
162
+ 417: {
163
+ name: 'Expectation Failed',
164
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/417',
165
+ },
166
+ 421: {
167
+ name: 'Misdirected Request',
168
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/421',
169
+ },
170
+ 422: {
171
+ name: 'Unprocessable Content',
172
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422',
173
+ },
174
+ 423: {
175
+ name: 'Locked',
176
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/423',
177
+ },
178
+ 424: {
179
+ name: 'Failed Dependency',
180
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/424',
181
+ },
182
+ 425: {
183
+ name: 'Too Early',
184
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/425',
185
+ },
186
+ 426: {
187
+ name: 'Upgrade Required',
188
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/426',
189
+ },
190
+ 428: {
191
+ name: 'Precondition Required',
192
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/428',
193
+ },
194
+ 429: {
195
+ name: 'Too Many Requests',
196
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429',
197
+ },
198
+ 431: {
199
+ name: 'Request Header Fields Too Large',
200
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/431',
201
+ },
202
+ 451: {
203
+ name: 'Unavailable For Legal Reasons',
204
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451',
205
+ },
206
+ 500: {
207
+ name: 'Internal Server Error',
208
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500',
209
+ },
210
+ 501: {
211
+ name: 'Not Implemented',
212
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501',
213
+ },
214
+ 502: {
215
+ name: 'Bad Gateway',
216
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502',
217
+ },
218
+ 503: {
219
+ name: 'Service Unavailable',
220
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503',
221
+ },
222
+ 504: {
223
+ name: 'Gateway Timeout',
224
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504',
225
+ },
226
+ 505: {
227
+ name: 'HTTP Version Not Supported',
228
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/505',
229
+ },
230
+ 506: {
231
+ name: 'Variant Also Negotiates',
232
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/506',
233
+ },
234
+ 507: {
235
+ name: 'Insufficient Storage',
236
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507',
237
+ },
238
+ 508: {
239
+ name: 'Loop Detected',
240
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/508',
241
+ },
242
+ 510: {
243
+ name: 'Not Extended',
244
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/510',
245
+ },
246
+ 511: {
247
+ name: 'Network Authentication Required',
248
+ url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511',
249
+ },
250
+ };
251
+
252
+ export { httpStatusCodes };
@@ -0,0 +1,14 @@
1
+ export * from './createHash.js';
2
+ export * from './deepMerge.js';
3
+ export * from './fetchSpecFromUrl.js';
4
+ export * from './httpMethods.js';
5
+ export * from './httpStatusCodes.js';
6
+ export * from './iterateTitle.js';
7
+ export * from './normalizeMimeType.js';
8
+ export * from './normalizeMimeTypeObject.js';
9
+ export * from './objectMerge.js';
10
+ export * from './parse.js';
11
+ export * from './prettyPrintJson.js';
12
+ export * from './schema-model.js';
13
+ export * from './ssrState.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,2BAA2B,CAAA;AACzC,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,13 @@
1
+ export { createHash } from './createHash.js';
2
+ export { deepMerge } from './deepMerge.js';
3
+ export { fetchSpecFromUrl } from './fetchSpecFromUrl.js';
4
+ export { REQUEST_METHODS, getRequest } from './httpMethods.js';
5
+ export { httpStatusCodes } from './httpStatusCodes.js';
6
+ export { iterateTitle } from './iterateTitle.js';
7
+ export { normalizeMimeType } from './normalizeMimeType.js';
8
+ export { normalizeMimeTypeObject } from './normalizeMimeTypeObject.js';
9
+ export { objectMerge } from './objectMerge.js';
10
+ export { formatJsonOrYamlString, isJsonString, json, parseJsonOrYaml, transformToJson, yaml } from './parse.js';
11
+ export { prettyPrintJson } from './prettyPrintJson.js';
12
+ export { schemaModel } from './schema-model.js';
13
+ export { defaultStateFactory, ssrState } from './ssrState.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Check for duplicate titles, and iterate title
3
+ */
4
+ export declare const iterateTitle: (title: string, checkDuplicates: (title: string) => boolean, separator?: string) => string;
5
+ //# sourceMappingURL=iterateTitle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterateTitle.d.ts","sourceRoot":"","sources":["../../src/helpers/iterateTitle.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY,UAChB,MAAM,2BACY,MAAM,KAAK,OAAO,yBAE1C,MAWF,CAAA"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Check for duplicate titles, and iterate title
3
+ */
4
+ const iterateTitle = (title, checkDuplicates, separator = ' #') => {
5
+ // If the title is not a duplicate return
6
+ if (!checkDuplicates(title))
7
+ return title;
8
+ const split = title.split(separator);
9
+ const newTitle = split.length > 1
10
+ ? `${split.slice(0, -1).join()}${separator}${Number(split.at(-1)) + 1}`
11
+ : `${split.join()}${separator}2`;
12
+ return iterateTitle(newTitle, checkDuplicates, separator);
13
+ };
14
+
15
+ export { iterateTitle };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json2xml.d.ts","sourceRoot":"","sources":["../../src/helpers/json2xml.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,UA+C/D"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * This function converts an object to XML.
3
+ */
4
+ function json2xml(data, tab) {
5
+ const toXml = function (value, key, indentation) {
6
+ let xml = '';
7
+ if (value instanceof Array) {
8
+ for (let i = 0, n = value.length; i < n; i++) {
9
+ xml += indentation + toXml(value[i], key, indentation + '\t') + '\n';
10
+ }
11
+ }
12
+ else if (typeof value == 'object') {
13
+ let hasChild = false;
14
+ xml += indentation + '<' + key;
15
+ for (const m in value) {
16
+ if (m.charAt(0) == '@')
17
+ xml += ' ' + m.substr(1) + '="' + value[m].toString() + '"';
18
+ else
19
+ hasChild = true;
20
+ }
21
+ xml += hasChild ? '>' : '/>';
22
+ if (hasChild) {
23
+ for (const m in value) {
24
+ if (m == '#text')
25
+ xml += value[m];
26
+ else if (m == '#cdata')
27
+ xml += '<![CDATA[' + value[m] + ']]>';
28
+ else if (m.charAt(0) != '@')
29
+ xml += toXml(value[m], m, indentation + '\t');
30
+ }
31
+ xml +=
32
+ (xml.charAt(xml.length - 1) == '\n' ? indentation : '') +
33
+ '</' +
34
+ key +
35
+ '>';
36
+ }
37
+ }
38
+ else {
39
+ xml += indentation + '<' + key + '>' + value.toString() + '</' + key + '>';
40
+ }
41
+ return xml;
42
+ };
43
+ let xml = '';
44
+ // eslint-disable-next-line guard-for-in
45
+ for (const key in data) {
46
+ xml += toXml(data[key], key, '');
47
+ }
48
+ return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, '');
49
+ }
50
+
51
+ export { json2xml };
@@ -1,4 +1,4 @@
1
- import type { ContentType } from './types';
1
+ import type { ContentType } from '../types';
2
2
  /**
3
3
  * Normalizes a MIME type to a standard format.
4
4
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeMimeType.d.ts","sourceRoot":"","sources":["../../src/helpers/normalizeMimeType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,CAAC,EAAE,MAAM,2BAcrD"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Normalizes a MIME type to a standard format.
3
+ *
4
+ * Input: application/problem+json; charset=utf-8
5
+ * Output: application/json
6
+ */
7
+ function normalizeMimeType(contentType) {
8
+ if (typeof contentType !== 'string') {
9
+ return undefined;
10
+ }
11
+ return contentType
12
+ // Remove '; charset=utf-8'
13
+ .replace(/;.*$/, '')
14
+ // Remove 'problem+'
15
+ .replace(/\/.+\+/, '/')
16
+ // Remove whitespace
17
+ .trim();
18
+ }
19
+
20
+ export { normalizeMimeType };
@@ -1,4 +1,4 @@
1
- import type { ContentType } from './types';
1
+ import type { ContentType } from '../types';
2
2
  /**
3
3
  * Remove charset from content types
4
4
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeMimeTypeObject.d.ts","sourceRoot":"","sources":["../../src/helpers/normalizeMimeTypeObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAG3C;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC;;;;;;;;cA8BzE"}
@@ -0,0 +1,34 @@
1
+ import { normalizeMimeType } from './normalizeMimeType.js';
2
+
3
+ /**
4
+ * Remove charset from content types
5
+ *
6
+ * Example: `application/json; charset=utf-8` -> `application/json`
7
+ */
8
+ function normalizeMimeTypeObject(content) {
9
+ if (!content) {
10
+ return content;
11
+ }
12
+ // Clone the object
13
+ const newContent = {
14
+ ...content,
15
+ };
16
+ Object.keys(newContent).forEach((key) => {
17
+ // Input: 'application/problem+json; charset=utf-8'
18
+ // Output: 'application/json'
19
+ const newKey = normalizeMimeType(key);
20
+ // We need a new key to replace the old one
21
+ if (newKey === undefined) {
22
+ return;
23
+ }
24
+ // Move the content
25
+ newContent[newKey] = newContent[key];
26
+ // Remove the old key
27
+ if (key !== newKey) {
28
+ delete newContent[key];
29
+ }
30
+ });
31
+ return newContent;
32
+ }
33
+
34
+ export { normalizeMimeTypeObject };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Overwrite a target object a new replacement object handling removed keys
3
+ **/
4
+ export declare function objectMerge<A extends object, B extends object>(target: A, replacement: B): B;
5
+ //# sourceMappingURL=objectMerge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objectMerge.d.ts","sourceRoot":"","sources":["../../src/helpers/objectMerge.ts"],"names":[],"mappings":"AACA;;IAEI;AACJ,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC5D,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,CAAC,KAYf"}
@@ -0,0 +1,16 @@
1
+ // TODO: This is a copy of packages/core-interface/src/database/utility.ts
2
+ /**
3
+ * Overwrite a target object a new replacement object handling removed keys
4
+ **/
5
+ function objectMerge(target, replacement) {
6
+ // Clear any keys that have been removed in the replacement
7
+ Object.keys(target).forEach((key) => {
8
+ if (!Object.hasOwn(replacement, key)) {
9
+ delete target[key];
10
+ }
11
+ });
12
+ Object.assign(target, replacement);
13
+ return target;
14
+ }
15
+
16
+ export { objectMerge };
@@ -1,5 +1,5 @@
1
1
  import { stringify } from 'yaml';
2
- import type { AnyObject } from './types';
2
+ import type { AnyObject } from '../types';
3
3
  type PrimitiveOrObject = object | string | null | number | boolean | undefined;
4
4
  /** Yaml handling with optional safeparse */
5
5
  export declare const yaml: {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/helpers/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,SAAS,EAAE,MAAM,MAAM,CAAA;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,KAAK,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;AAE9E,4CAA4C;AAC5C,eAAO,MAAM,IAAI;IACf,2DAA2D;iBAC9C,MAAM;IAKnB,6CAA6C;gDAEtC,MAAM,uBACU,GAAG,KAAK,CAAC,IAC7B,SAAS,GAAG,CAAC;;CAQjB,CAAA;AAED,4CAA4C;AAC5C,eAAO,MAAM,IAAI;IACf,2DAA2D;iBAC9C,MAAM,KAAG,SAAS;IAK/B,6CAA6C;gDAEtC,MAAM,uBACU,GAAG,KAAK,CAAC,IAC7B,SAAS,GAAG,CAAC;qBAOC,MAAM;CACxB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,WAAY,GAAG,YAIvC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,WAG5C,CAAA;AAED,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,UAYnD;AAED,wCAAwC;AACxC,eAAO,MAAM,eAAe,UAAW,MAAM,GAAG,SAAS,KAAG,SAc3D,CAAA"}
@@ -0,0 +1,89 @@
1
+ import { parse, stringify } from 'yaml';
2
+
3
+ /** Yaml handling with optional safeparse */
4
+ const yaml = {
5
+ /** Parse and throw if the return value is not an object */
6
+ parse: (val) => {
7
+ const yamlObject = parse(val);
8
+ if (typeof yamlObject !== 'object')
9
+ throw Error('Invalid YAML object');
10
+ return yamlObject;
11
+ },
12
+ /** Parse and return a fallback on failure */
13
+ parseSafe(val, fallback) {
14
+ try {
15
+ return yaml.parse(val);
16
+ }
17
+ catch (err) {
18
+ return typeof fallback === 'function' ? fallback(err) : fallback;
19
+ }
20
+ },
21
+ stringify,
22
+ };
23
+ /** JSON handling with optional safeparse */
24
+ const json = {
25
+ /** Parse and throw if the return value is not an object */
26
+ parse: (val) => {
27
+ const jsonObject = JSON.parse(val);
28
+ if (typeof jsonObject !== 'object')
29
+ throw Error('Invalid JSON object');
30
+ return jsonObject;
31
+ },
32
+ /** Parse and return a fallback on failure */
33
+ parseSafe(val, fallback) {
34
+ try {
35
+ return json.parse(val);
36
+ }
37
+ catch (err) {
38
+ return typeof fallback === 'function' ? fallback(err) : fallback;
39
+ }
40
+ },
41
+ stringify: (val) => JSON.stringify(val),
42
+ };
43
+ /**
44
+ * Check if value is a valid JSON string
45
+ */
46
+ const isJsonString = (value) => {
47
+ if (typeof value !== 'string')
48
+ return false;
49
+ return !!json.parseSafe(value, false);
50
+ };
51
+ /**
52
+ * This helper is used to transform the content of the swagger file to JSON, even it was YAML.
53
+ */
54
+ const transformToJson = (value) => {
55
+ // Try json, then fallback to yaml, then fallback to string
56
+ return JSON.stringify(json.parseSafe(value, yaml.parseSafe(value, value)));
57
+ };
58
+ /** Validates a JSON string if provided. Otherwise returns the raw YAML */
59
+ function formatJsonOrYamlString(value) {
60
+ // If we don't start with a bracket assume yaml
61
+ const trimmed = value.trim();
62
+ if (trimmed[0] !== '{')
63
+ return value;
64
+ try {
65
+ // JSON
66
+ return JSON.stringify(JSON.parse(value), null, 2);
67
+ }
68
+ catch {
69
+ // YAML
70
+ return value;
71
+ }
72
+ }
73
+ /** Parse JSON or YAML into an object */
74
+ const parseJsonOrYaml = (value) => {
75
+ if (typeof value !== 'string')
76
+ return value;
77
+ const jsonObject = json.parseSafe(value, null);
78
+ if (jsonObject)
79
+ return jsonObject;
80
+ // Value is probably supposed to be JSON. Throw
81
+ if (value.length > 0 && ['{', '['].includes(value[0])) {
82
+ throw Error('Invalid JSON or YAML');
83
+ }
84
+ return yaml.parseSafe(value, (err) => {
85
+ throw Error(err);
86
+ });
87
+ };
88
+
89
+ export { formatJsonOrYamlString, isJsonString, json, parseJsonOrYaml, transformToJson, yaml };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettyPrintJson.d.ts","sourceRoot":"","sources":["../../src/helpers/prettyPrintJson.ts"],"names":[],"mappings":"AAAA;;IAEI;AACJ,eAAO,MAAM,eAAe,UAAW,GAAG,QAYzC,CAAA"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Takes JSON and formats it.
3
+ **/
4
+ const prettyPrintJson = (value) => {
5
+ try {
6
+ if (typeof value === 'string') {
7
+ return JSON.stringify(JSON.parse(value), null, 2);
8
+ }
9
+ else {
10
+ return JSON.stringify(value, null, 2);
11
+ }
12
+ }
13
+ catch {
14
+ console.log('[prettyPrintJson] Error parsing JSON', value);
15
+ return value;
16
+ }
17
+ };
18
+
19
+ export { prettyPrintJson };
@@ -0,0 +1,5 @@
1
+ import type { ZodSchema, ZodTypeDef } from 'zod';
2
+ /** Parse an value from a given schema with optional error or null return */
3
+ export declare function schemaModel<T, I = any>(data: I, schema: ZodSchema<T, ZodTypeDef, any>, throwError?: true): T;
4
+ export declare function schemaModel<T, I = any>(data: I, schema: ZodSchema<T, ZodTypeDef, any>, throwError?: false): T | null;
5
+ //# sourceMappingURL=schema-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-model.d.ts","sourceRoot":"","sources":["../../src/helpers/schema-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAEhD,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EACpC,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EACrC,UAAU,CAAC,EAAE,IAAI,GAChB,CAAC,CAAA;AACJ,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EACpC,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EACrC,UAAU,CAAC,EAAE,KAAK,GACjB,CAAC,GAAG,IAAI,CAAA"}
@@ -0,0 +1,21 @@
1
+ function schemaModel(data, schema, throwError = true) {
2
+ if (throwError) {
3
+ const result = schema.safeParse(data);
4
+ if (!result.success) {
5
+ console.error('Zod Schema Error');
6
+ console.group();
7
+ result.error.issues.forEach((issue) => {
8
+ console.log(`Path: ${issue.path.join(', ')} \nError: ${issue.message}`);
9
+ });
10
+ console.groupEnd();
11
+ throw new Error('Zod validation failure');
12
+ }
13
+ return result.data;
14
+ }
15
+ else {
16
+ const res = schema.safeParse(data);
17
+ return res.success ? res.data : null;
18
+ }
19
+ }
20
+
21
+ export { schemaModel };
@@ -1,4 +1,4 @@
1
- import type { ScalarState } from './types';
1
+ import type { ScalarState } from '../types';
2
2
  declare global {
3
3
  interface Window {
4
4
  __SCALAR__: ScalarState;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssrState.d.ts","sourceRoot":"","sources":["../../src/helpers/ssrState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE,WAAW,CAAA;KACxB;CACF;AAED,eAAO,MAAM,mBAAmB,QAAO,WAAmB,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,WAGI,CAAA"}
@@ -0,0 +1,9 @@
1
+ const defaultStateFactory = () => ({});
2
+ /**
3
+ * This allows us to access the server state in the front-end
4
+ */
5
+ const ssrState = typeof window !== 'undefined'
6
+ ? window.__SCALAR__ ?? defaultStateFactory()
7
+ : defaultStateFactory();
8
+
9
+ export { defaultStateFactory, ssrState };