@zuplo/cli 6.71.27 → 6.72.1

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 (135) hide show
  1. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/dependabot.yml +42 -2
  2. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/README.md +5 -5
  3. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/index.js +4 -7
  4. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/package.json +3 -3
  5. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/additionalProperties.test.js +47 -0
  6. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/const.test.js +20 -0
  7. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/patternProperties.test.js +24 -0
  8. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/.gitattributes +2 -0
  9. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/.github/dependabot.yml +53 -0
  10. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/.github/workflows/ci.yml +154 -0
  11. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/.github/workflows/lock-threads.yml +19 -0
  12. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/LICENSE +30 -0
  13. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/README.md +152 -0
  14. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/benchmark.mjs +159 -0
  15. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/encoder.mjs +54 -0
  16. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/equal.mjs +51 -0
  17. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/non-simple-domain.mjs +22 -0
  18. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/package.json +17 -0
  19. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/string-array-to-hex-stripped.mjs +24 -0
  20. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/ws-is-secure.mjs +65 -0
  21. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/eslint.config.js +6 -0
  22. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/index.js +405 -0
  23. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/lib/schemes.js +267 -0
  24. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/lib/utils.js +585 -0
  25. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/package.json +68 -0
  26. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/ajv.test.js +43 -0
  27. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/equal.test.js +168 -0
  28. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/fixtures/uri-js-parse.json +501 -0
  29. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/fixtures/uri-js-serialize.json +120 -0
  30. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/parse.test.js +325 -0
  31. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
  32. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/resolve.test.js +87 -0
  33. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/rfc-3986.test.js +90 -0
  34. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/scheme-normalization.test.js +16 -0
  35. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/security-normalization.test.js +39 -0
  36. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/security-utf8-encoding.test.js +0 -0
  37. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/security.test.js +161 -0
  38. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/serialize.test.js +151 -0
  39. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/uri-js-compatibility.test.js +33 -0
  40. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/uri-js.test.js +912 -0
  41. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/util.test.js +47 -0
  42. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/tsconfig.json +10 -0
  43. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/types/index.d.ts +51 -0
  44. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/types/index.tst.ts +15 -0
  45. package/node_modules/@posthog/core/dist/index.d.ts +3 -0
  46. package/node_modules/@posthog/core/dist/index.d.ts.map +1 -1
  47. package/node_modules/@posthog/core/dist/index.js +133 -93
  48. package/node_modules/@posthog/core/dist/index.mjs +2 -1
  49. package/node_modules/@posthog/core/dist/metrics/index.d.ts +61 -0
  50. package/node_modules/@posthog/core/dist/metrics/index.d.ts.map +1 -0
  51. package/node_modules/@posthog/core/dist/metrics/index.js +326 -0
  52. package/node_modules/@posthog/core/dist/metrics/index.mjs +283 -0
  53. package/node_modules/@posthog/core/dist/metrics/metrics-utils.d.ts +41 -0
  54. package/node_modules/@posthog/core/dist/metrics/metrics-utils.d.ts.map +1 -0
  55. package/node_modules/@posthog/core/dist/metrics/metrics-utils.js +117 -0
  56. package/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs +68 -0
  57. package/node_modules/@posthog/core/dist/metrics/types.d.ts +69 -0
  58. package/node_modules/@posthog/core/dist/metrics/types.d.ts.map +1 -0
  59. package/node_modules/@posthog/core/dist/metrics/types.js +18 -0
  60. package/node_modules/@posthog/core/dist/metrics/types.mjs +0 -0
  61. package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts +2 -0
  62. package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts.map +1 -1
  63. package/node_modules/@posthog/core/dist/posthog-core-stateless.js +16 -1
  64. package/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +16 -1
  65. package/node_modules/@posthog/core/package.json +2 -2
  66. package/node_modules/@posthog/core/src/index.ts +20 -0
  67. package/node_modules/@posthog/core/src/metrics/index.spec.ts +459 -0
  68. package/node_modules/@posthog/core/src/metrics/index.ts +414 -0
  69. package/node_modules/@posthog/core/src/metrics/metrics-utils.ts +100 -0
  70. package/node_modules/@posthog/core/src/metrics/types.ts +89 -0
  71. package/node_modules/@posthog/core/src/posthog-core-stateless.ts +26 -0
  72. package/node_modules/@posthog/types/dist/capture-metric.d.ts +122 -0
  73. package/node_modules/@posthog/types/dist/capture-metric.d.ts.map +1 -0
  74. package/node_modules/@posthog/types/dist/capture-metric.js +36 -0
  75. package/node_modules/@posthog/types/dist/capture-metric.mjs +2 -0
  76. package/node_modules/@posthog/types/dist/index.d.ts +3 -1
  77. package/node_modules/@posthog/types/dist/index.d.ts.map +1 -1
  78. package/node_modules/@posthog/types/dist/index.js +19 -1
  79. package/node_modules/@posthog/types/dist/index.mjs +2 -0
  80. package/node_modules/@posthog/types/dist/posthog-config.d.ts +60 -0
  81. package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
  82. package/node_modules/@posthog/types/package.json +1 -1
  83. package/node_modules/@posthog/types/src/capture-metric.ts +133 -0
  84. package/node_modules/@posthog/types/src/index.ts +17 -0
  85. package/node_modules/@posthog/types/src/posthog-config.ts +62 -0
  86. package/node_modules/@types/node/README.md +1 -1
  87. package/node_modules/@types/node/fs/promises.d.ts +16 -6
  88. package/node_modules/@types/node/package.json +2 -2
  89. package/node_modules/@zuplo/core/package.json +1 -1
  90. package/node_modules/@zuplo/graphql/package.json +1 -1
  91. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  92. package/node_modules/@zuplo/otel/package.json +1 -1
  93. package/node_modules/@zuplo/runtime/out/esm/{chunk-D3O7C43P.js → chunk-IC7XGD5C.js} +93 -93
  94. package/node_modules/@zuplo/runtime/out/esm/chunk-IC7XGD5C.js.map +1 -0
  95. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  96. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  97. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +9 -9
  98. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
  99. package/node_modules/@zuplo/runtime/out/types/index.d.ts +830 -6
  100. package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +30 -0
  101. package/node_modules/@zuplo/runtime/package.json +1 -1
  102. package/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -1
  103. package/node_modules/lru-cache/dist/commonjs/browser/index.js +11 -4
  104. package/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -1
  105. package/node_modules/lru-cache/dist/commonjs/browser/index.min.js +1 -1
  106. package/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +3 -3
  107. package/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
  108. package/node_modules/lru-cache/dist/commonjs/index.js +11 -4
  109. package/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
  110. package/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  111. package/node_modules/lru-cache/dist/commonjs/index.min.js.map +3 -3
  112. package/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -1
  113. package/node_modules/lru-cache/dist/commonjs/node/index.js +11 -4
  114. package/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -1
  115. package/node_modules/lru-cache/dist/commonjs/node/index.min.js +1 -1
  116. package/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +3 -3
  117. package/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
  118. package/node_modules/lru-cache/dist/esm/browser/index.js +11 -4
  119. package/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
  120. package/node_modules/lru-cache/dist/esm/browser/index.min.js +1 -1
  121. package/node_modules/lru-cache/dist/esm/browser/index.min.js.map +3 -3
  122. package/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
  123. package/node_modules/lru-cache/dist/esm/index.js +11 -4
  124. package/node_modules/lru-cache/dist/esm/index.js.map +1 -1
  125. package/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  126. package/node_modules/lru-cache/dist/esm/index.min.js.map +3 -3
  127. package/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
  128. package/node_modules/lru-cache/dist/esm/node/index.js +11 -4
  129. package/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
  130. package/node_modules/lru-cache/dist/esm/node/index.min.js +1 -1
  131. package/node_modules/lru-cache/dist/esm/node/index.min.js.map +3 -3
  132. package/node_modules/lru-cache/package.json +1 -1
  133. package/package.json +6 -6
  134. package/node_modules/@zuplo/runtime/out/esm/chunk-D3O7C43P.js.map +0 -1
  135. /package/node_modules/@zuplo/runtime/out/esm/{chunk-D3O7C43P.js.LEGAL.txt → chunk-IC7XGD5C.js.LEGAL.txt} +0 -0
@@ -0,0 +1,405 @@
1
+ 'use strict'
2
+
3
+ const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, normalizeQueryFragmentEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require('./lib/utils')
4
+ const { SCHEMES, getSchemeHandler } = require('./lib/schemes')
5
+
6
+ /**
7
+ * @template {import('./types/index').URIComponent|string} T
8
+ * @param {T} uri
9
+ * @param {import('./types/index').Options} [options]
10
+ * @returns {T}
11
+ */
12
+ function normalize (uri, options) {
13
+ if (typeof uri === 'string') {
14
+ uri = /** @type {T} */ (normalizeString(uri, options))
15
+ } else if (typeof uri === 'object') {
16
+ uri = /** @type {T} */ (parse(serialize(uri, options), options))
17
+ }
18
+ return uri
19
+ }
20
+
21
+ /**
22
+ * @param {string} baseURI
23
+ * @param {string} relativeURI
24
+ * @param {import('./types/index').Options} [options]
25
+ * @returns {string}
26
+ */
27
+ function resolve (baseURI, relativeURI, options) {
28
+ const schemelessOptions = options ? Object.assign({ scheme: 'null' }, options) : { scheme: 'null' }
29
+ const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true)
30
+ schemelessOptions.skipEscape = true
31
+ return serialize(resolved, schemelessOptions)
32
+ }
33
+
34
+ /**
35
+ * @param {import ('./types/index').URIComponent} base
36
+ * @param {import ('./types/index').URIComponent} relative
37
+ * @param {import('./types/index').Options} [options]
38
+ * @param {boolean} [skipNormalization=false]
39
+ * @returns {import ('./types/index').URIComponent}
40
+ */
41
+ function resolveComponent (base, relative, options, skipNormalization) {
42
+ /** @type {import('./types/index').URIComponent} */
43
+ const target = {}
44
+ if (!skipNormalization) {
45
+ base = parse(serialize(base, options), options) // normalize base component
46
+ relative = parse(serialize(relative, options), options) // normalize relative component
47
+ }
48
+ options = options || {}
49
+
50
+ if (!options.tolerant && relative.scheme) {
51
+ target.scheme = relative.scheme
52
+ // target.authority = relative.authority;
53
+ target.userinfo = relative.userinfo
54
+ target.host = relative.host
55
+ target.port = relative.port
56
+ target.path = removeDotSegments(relative.path || '')
57
+ target.query = relative.query
58
+ } else {
59
+ if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
60
+ // target.authority = relative.authority;
61
+ target.userinfo = relative.userinfo
62
+ target.host = relative.host
63
+ target.port = relative.port
64
+ target.path = removeDotSegments(relative.path || '')
65
+ target.query = relative.query
66
+ } else {
67
+ if (!relative.path) {
68
+ target.path = base.path
69
+ if (relative.query !== undefined) {
70
+ target.query = relative.query
71
+ } else {
72
+ target.query = base.query
73
+ }
74
+ } else {
75
+ if (relative.path[0] === '/') {
76
+ target.path = removeDotSegments(relative.path)
77
+ } else {
78
+ if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
79
+ target.path = '/' + relative.path
80
+ } else if (!base.path) {
81
+ target.path = relative.path
82
+ } else {
83
+ target.path = base.path.slice(0, base.path.lastIndexOf('/') + 1) + relative.path
84
+ }
85
+ target.path = removeDotSegments(target.path)
86
+ }
87
+ target.query = relative.query
88
+ }
89
+ // target.authority = base.authority;
90
+ target.userinfo = base.userinfo
91
+ target.host = base.host
92
+ target.port = base.port
93
+ }
94
+ target.scheme = base.scheme
95
+ }
96
+
97
+ target.fragment = relative.fragment
98
+
99
+ return target
100
+ }
101
+
102
+ /**
103
+ * @param {import ('./types/index').URIComponent|string} uriA
104
+ * @param {import ('./types/index').URIComponent|string} uriB
105
+ * @param {import ('./types/index').Options} options
106
+ * @returns {boolean}
107
+ */
108
+ function equal (uriA, uriB, options) {
109
+ const normalizedA = normalizeComparableURI(uriA, options)
110
+ const normalizedB = normalizeComparableURI(uriB, options)
111
+
112
+ return normalizedA !== undefined && normalizedB !== undefined && normalizedA.toLowerCase() === normalizedB.toLowerCase()
113
+ }
114
+
115
+ /**
116
+ * @param {Readonly<import('./types/index').URIComponent>} cmpts
117
+ * @param {import('./types/index').Options} [opts]
118
+ * @returns {string}
119
+ */
120
+ function serialize (cmpts, opts) {
121
+ const component = {
122
+ host: cmpts.host,
123
+ scheme: cmpts.scheme,
124
+ userinfo: cmpts.userinfo,
125
+ port: cmpts.port,
126
+ path: cmpts.path,
127
+ query: cmpts.query,
128
+ nid: cmpts.nid,
129
+ nss: cmpts.nss,
130
+ uuid: cmpts.uuid,
131
+ fragment: cmpts.fragment,
132
+ reference: cmpts.reference,
133
+ resourceName: cmpts.resourceName,
134
+ secure: cmpts.secure,
135
+ error: ''
136
+ }
137
+ const options = Object.assign({}, opts)
138
+ const uriTokens = []
139
+
140
+ // find scheme handler
141
+ const schemeHandler = getSchemeHandler(options.scheme || component.scheme)
142
+
143
+ // perform scheme specific serialization
144
+ if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options)
145
+
146
+ if (component.path !== undefined) {
147
+ if (!options.skipEscape) {
148
+ component.path = escapePreservingEscapes(component.path)
149
+
150
+ if (component.scheme !== undefined) {
151
+ component.path = component.path.split('%3A').join(':')
152
+ }
153
+ } else {
154
+ component.path = normalizePercentEncoding(component.path)
155
+ }
156
+ }
157
+
158
+ if (options.reference !== 'suffix' && component.scheme) {
159
+ uriTokens.push(component.scheme, ':')
160
+ }
161
+
162
+ const authority = recomposeAuthority(component)
163
+ if (authority !== undefined) {
164
+ if (options.reference !== 'suffix') {
165
+ uriTokens.push('//')
166
+ }
167
+
168
+ uriTokens.push(authority)
169
+
170
+ if (component.path && component.path[0] !== '/') {
171
+ uriTokens.push('/')
172
+ }
173
+ }
174
+ if (component.path !== undefined) {
175
+ let s = component.path
176
+
177
+ if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
178
+ s = removeDotSegments(s)
179
+ }
180
+
181
+ if (
182
+ authority === undefined &&
183
+ s[0] === '/' &&
184
+ s[1] === '/'
185
+ ) {
186
+ // don't allow the path to start with "//"
187
+ s = '/%2F' + s.slice(2)
188
+ }
189
+
190
+ uriTokens.push(s)
191
+ }
192
+
193
+ if (component.query !== undefined) {
194
+ uriTokens.push('?', component.query)
195
+ }
196
+
197
+ if (component.fragment !== undefined) {
198
+ uriTokens.push('#', component.fragment)
199
+ }
200
+ return uriTokens.join('')
201
+ }
202
+
203
+ const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u
204
+
205
+ /**
206
+ * @param {import('./types/index').URIComponent} parsed
207
+ * @param {RegExpMatchArray} matches
208
+ * @returns {string|undefined}
209
+ */
210
+ function getParseError (parsed, matches) {
211
+ if (matches[2] !== undefined && parsed.path && parsed.path[0] !== '/') {
212
+ return 'URI path must start with "/" when authority is present.'
213
+ }
214
+
215
+ if (typeof parsed.port === 'number' && (parsed.port < 0 || parsed.port > 65535)) {
216
+ return 'URI port is malformed.'
217
+ }
218
+
219
+ return undefined
220
+ }
221
+
222
+ /**
223
+ * @param {string} uri
224
+ * @param {import('./types/index').Options} [opts]
225
+ * @returns {{ parsed: import('./types/index').URIComponent, malformedAuthorityOrPort: boolean }}
226
+ */
227
+ function parseWithStatus (uri, opts) {
228
+ const options = Object.assign({}, opts)
229
+ /** @type {import('./types/index').URIComponent} */
230
+ const parsed = {
231
+ scheme: undefined,
232
+ userinfo: undefined,
233
+ host: '',
234
+ port: undefined,
235
+ path: '',
236
+ query: undefined,
237
+ fragment: undefined
238
+ }
239
+
240
+ let malformedAuthorityOrPort = false
241
+
242
+ let isIP = false
243
+ if (options.reference === 'suffix') {
244
+ if (options.scheme) {
245
+ uri = options.scheme + ':' + uri
246
+ } else {
247
+ uri = '//' + uri
248
+ }
249
+ }
250
+
251
+ const matches = uri.match(URI_PARSE)
252
+
253
+ if (matches) {
254
+ // store each component
255
+ parsed.scheme = matches[1] === undefined ? undefined : matches[1].toLowerCase()
256
+ parsed.userinfo = matches[3]
257
+ parsed.host = matches[4]
258
+ parsed.port = parseInt(matches[5], 10)
259
+ parsed.path = matches[6] || ''
260
+ parsed.query = matches[7]
261
+ parsed.fragment = matches[8]
262
+
263
+ // fix port number
264
+ if (isNaN(parsed.port)) {
265
+ parsed.port = matches[5]
266
+ }
267
+
268
+ const parseError = getParseError(parsed, matches)
269
+ if (parseError !== undefined) {
270
+ parsed.error = parsed.error || parseError
271
+ malformedAuthorityOrPort = true
272
+ }
273
+
274
+ if (parsed.host) {
275
+ const ipv4result = isIPv4(parsed.host)
276
+ if (ipv4result === false) {
277
+ const ipv6result = normalizeIPv6(parsed.host)
278
+ parsed.host = ipv6result.host.toLowerCase()
279
+ isIP = ipv6result.isIPV6
280
+ } else {
281
+ isIP = true
282
+ }
283
+ }
284
+ if (parsed.scheme === undefined && parsed.userinfo === undefined && parsed.host === undefined && parsed.port === undefined && parsed.query === undefined && !parsed.path) {
285
+ parsed.reference = 'same-document'
286
+ } else if (parsed.scheme === undefined) {
287
+ parsed.reference = 'relative'
288
+ } else if (parsed.fragment === undefined) {
289
+ parsed.reference = 'absolute'
290
+ } else {
291
+ parsed.reference = 'uri'
292
+ }
293
+
294
+ // check for reference errors
295
+ if (options.reference && options.reference !== 'suffix' && options.reference !== parsed.reference) {
296
+ parsed.error = parsed.error || 'URI is not a ' + options.reference + ' reference.'
297
+ }
298
+
299
+ // find scheme handler
300
+ const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme)
301
+
302
+ // check if scheme can't handle IRIs
303
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
304
+ // if host component is a domain name
305
+ if (parsed.host && (options.domainHost || (schemeHandler && schemeHandler.domainHost)) && isIP === false && nonSimpleDomain(parsed.host)) {
306
+ // convert Unicode IDN -> ASCII IDN
307
+ try {
308
+ parsed.host = new URL('http://' + parsed.host).hostname
309
+ } catch (e) {
310
+ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e
311
+ }
312
+ }
313
+ // convert IRI -> URI
314
+ }
315
+
316
+ if (!schemeHandler || (schemeHandler && !schemeHandler.skipNormalize)) {
317
+ if (uri.indexOf('%') !== -1) {
318
+ if (parsed.scheme !== undefined) {
319
+ parsed.scheme = unescape(parsed.scheme)
320
+ }
321
+ if (parsed.host !== undefined) {
322
+ parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP)
323
+ }
324
+ }
325
+ if (parsed.path) {
326
+ parsed.path = normalizePathEncoding(parsed.path)
327
+ }
328
+ if (parsed.query) {
329
+ parsed.query = normalizeQueryFragmentEncoding(parsed.query)
330
+ }
331
+ if (parsed.fragment) {
332
+ parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment)
333
+ }
334
+ }
335
+
336
+ // perform scheme specific parsing
337
+ if (schemeHandler && schemeHandler.parse) {
338
+ schemeHandler.parse(parsed, options)
339
+ }
340
+ } else {
341
+ parsed.error = parsed.error || 'URI can not be parsed.'
342
+ }
343
+ return { parsed, malformedAuthorityOrPort }
344
+ }
345
+
346
+ /**
347
+ * @param {string} uri
348
+ * @param {import('./types/index').Options} [opts]
349
+ * @returns
350
+ */
351
+ function parse (uri, opts) {
352
+ return parseWithStatus(uri, opts).parsed
353
+ }
354
+
355
+ /**
356
+ * @param {string} uri
357
+ * @param {import('./types/index').Options} [opts]
358
+ * @returns {string}
359
+ */
360
+ function normalizeString (uri, opts) {
361
+ return normalizeStringWithStatus(uri, opts).normalized
362
+ }
363
+
364
+ /**
365
+ * @param {string} uri
366
+ * @param {import('./types/index').Options} [opts]
367
+ * @returns {{ normalized: string, malformedAuthorityOrPort: boolean }}
368
+ */
369
+ function normalizeStringWithStatus (uri, opts) {
370
+ const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts)
371
+ return {
372
+ normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
373
+ malformedAuthorityOrPort
374
+ }
375
+ }
376
+
377
+ /**
378
+ * @param {import ('./types/index').URIComponent|string} uri
379
+ * @param {import('./types/index').Options} [opts]
380
+ * @returns {string|undefined}
381
+ */
382
+ function normalizeComparableURI (uri, opts) {
383
+ if (typeof uri === 'string') {
384
+ const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts)
385
+ return malformedAuthorityOrPort ? undefined : normalized
386
+ }
387
+
388
+ if (typeof uri === 'object') {
389
+ return serialize(uri, opts)
390
+ }
391
+ }
392
+
393
+ const fastUri = {
394
+ SCHEMES,
395
+ normalize,
396
+ resolve,
397
+ resolveComponent,
398
+ equal,
399
+ serialize,
400
+ parse
401
+ }
402
+
403
+ module.exports = fastUri
404
+ module.exports.default = fastUri
405
+ module.exports.fastUri = fastUri
@@ -0,0 +1,267 @@
1
+ 'use strict'
2
+
3
+ const { isUUID } = require('./utils')
4
+ const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu
5
+
6
+ const supportedSchemeNames = /** @type {const} */ (['http', 'https', 'ws',
7
+ 'wss', 'urn', 'urn:uuid'])
8
+
9
+ /** @typedef {supportedSchemeNames[number]} SchemeName */
10
+
11
+ /**
12
+ * @param {string} name
13
+ * @returns {name is SchemeName}
14
+ */
15
+ function isValidSchemeName (name) {
16
+ return supportedSchemeNames.indexOf(/** @type {*} */ (name)) !== -1
17
+ }
18
+
19
+ /**
20
+ * @callback SchemeFn
21
+ * @param {import('../types/index').URIComponent} component
22
+ * @param {import('../types/index').Options} options
23
+ * @returns {import('../types/index').URIComponent}
24
+ */
25
+
26
+ /**
27
+ * @typedef {Object} SchemeHandler
28
+ * @property {SchemeName} scheme - The scheme name.
29
+ * @property {boolean} [domainHost] - Indicates if the scheme supports domain hosts.
30
+ * @property {SchemeFn} parse - Function to parse the URI component for this scheme.
31
+ * @property {SchemeFn} serialize - Function to serialize the URI component for this scheme.
32
+ * @property {boolean} [skipNormalize] - Indicates if normalization should be skipped for this scheme.
33
+ * @property {boolean} [absolutePath] - Indicates if the scheme uses absolute paths.
34
+ * @property {boolean} [unicodeSupport] - Indicates if the scheme supports Unicode.
35
+ */
36
+
37
+ /**
38
+ * @param {import('../types/index').URIComponent} wsComponent
39
+ * @returns {boolean}
40
+ */
41
+ function wsIsSecure (wsComponent) {
42
+ if (wsComponent.secure === true) {
43
+ return true
44
+ } else if (wsComponent.secure === false) {
45
+ return false
46
+ } else if (wsComponent.scheme) {
47
+ return (
48
+ wsComponent.scheme.length === 3 &&
49
+ (wsComponent.scheme[0] === 'w' || wsComponent.scheme[0] === 'W') &&
50
+ (wsComponent.scheme[1] === 's' || wsComponent.scheme[1] === 'S') &&
51
+ (wsComponent.scheme[2] === 's' || wsComponent.scheme[2] === 'S')
52
+ )
53
+ } else {
54
+ return false
55
+ }
56
+ }
57
+
58
+ /** @type {SchemeFn} */
59
+ function httpParse (component) {
60
+ if (!component.host) {
61
+ component.error = component.error || 'HTTP URIs must have a host.'
62
+ }
63
+
64
+ return component
65
+ }
66
+
67
+ /** @type {SchemeFn} */
68
+ function httpSerialize (component) {
69
+ const secure = String(component.scheme).toLowerCase() === 'https'
70
+
71
+ // normalize the default port
72
+ if (component.port === (secure ? 443 : 80) || component.port === '') {
73
+ component.port = undefined
74
+ }
75
+
76
+ // normalize the empty path
77
+ if (!component.path) {
78
+ component.path = '/'
79
+ }
80
+
81
+ // NOTE: We do not parse query strings for HTTP URIs
82
+ // as WWW Form Url Encoded query strings are part of the HTML4+ spec,
83
+ // and not the HTTP spec.
84
+
85
+ return component
86
+ }
87
+
88
+ /** @type {SchemeFn} */
89
+ function wsParse (wsComponent) {
90
+ // indicate if the secure flag is set
91
+ wsComponent.secure = wsIsSecure(wsComponent)
92
+
93
+ // construct resouce name
94
+ wsComponent.resourceName = (wsComponent.path || '/') + (wsComponent.query ? '?' + wsComponent.query : '')
95
+ wsComponent.path = undefined
96
+ wsComponent.query = undefined
97
+
98
+ return wsComponent
99
+ }
100
+
101
+ /** @type {SchemeFn} */
102
+ function wsSerialize (wsComponent) {
103
+ // normalize the default port
104
+ if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === '') {
105
+ wsComponent.port = undefined
106
+ }
107
+
108
+ // ensure scheme matches secure flag
109
+ if (typeof wsComponent.secure === 'boolean') {
110
+ wsComponent.scheme = (wsComponent.secure ? 'wss' : 'ws')
111
+ wsComponent.secure = undefined
112
+ }
113
+
114
+ // reconstruct path from resource name
115
+ if (wsComponent.resourceName) {
116
+ const [path, query] = wsComponent.resourceName.split('?')
117
+ wsComponent.path = (path && path !== '/' ? path : undefined)
118
+ wsComponent.query = query
119
+ wsComponent.resourceName = undefined
120
+ }
121
+
122
+ // forbid fragment component
123
+ wsComponent.fragment = undefined
124
+
125
+ return wsComponent
126
+ }
127
+
128
+ /** @type {SchemeFn} */
129
+ function urnParse (urnComponent, options) {
130
+ if (!urnComponent.path) {
131
+ urnComponent.error = 'URN can not be parsed'
132
+ return urnComponent
133
+ }
134
+ const matches = urnComponent.path.match(URN_REG)
135
+ if (matches) {
136
+ const scheme = options.scheme || urnComponent.scheme || 'urn'
137
+ urnComponent.nid = matches[1].toLowerCase()
138
+ urnComponent.nss = matches[2]
139
+ const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`
140
+ const schemeHandler = getSchemeHandler(urnScheme)
141
+ urnComponent.path = undefined
142
+
143
+ if (schemeHandler) {
144
+ urnComponent = schemeHandler.parse(urnComponent, options)
145
+ }
146
+ } else {
147
+ urnComponent.error = urnComponent.error || 'URN can not be parsed.'
148
+ }
149
+
150
+ return urnComponent
151
+ }
152
+
153
+ /** @type {SchemeFn} */
154
+ function urnSerialize (urnComponent, options) {
155
+ if (urnComponent.nid === undefined) {
156
+ throw new Error('URN without nid cannot be serialized')
157
+ }
158
+ const scheme = options.scheme || urnComponent.scheme || 'urn'
159
+ const nid = urnComponent.nid.toLowerCase()
160
+ const urnScheme = `${scheme}:${options.nid || nid}`
161
+ const schemeHandler = getSchemeHandler(urnScheme)
162
+
163
+ if (schemeHandler) {
164
+ urnComponent = schemeHandler.serialize(urnComponent, options)
165
+ }
166
+
167
+ const uriComponent = urnComponent
168
+ const nss = urnComponent.nss
169
+ uriComponent.path = `${nid || options.nid}:${nss}`
170
+
171
+ options.skipEscape = true
172
+ return uriComponent
173
+ }
174
+
175
+ /** @type {SchemeFn} */
176
+ function urnuuidParse (urnComponent, options) {
177
+ const uuidComponent = urnComponent
178
+ uuidComponent.uuid = uuidComponent.nss
179
+ uuidComponent.nss = undefined
180
+
181
+ if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) {
182
+ uuidComponent.error = uuidComponent.error || 'UUID is not valid.'
183
+ }
184
+
185
+ return uuidComponent
186
+ }
187
+
188
+ /** @type {SchemeFn} */
189
+ function urnuuidSerialize (uuidComponent) {
190
+ const urnComponent = uuidComponent
191
+ // normalize UUID
192
+ urnComponent.nss = (uuidComponent.uuid || '').toLowerCase()
193
+ return urnComponent
194
+ }
195
+
196
+ const http = /** @type {SchemeHandler} */ ({
197
+ scheme: 'http',
198
+ domainHost: true,
199
+ parse: httpParse,
200
+ serialize: httpSerialize
201
+ })
202
+
203
+ const https = /** @type {SchemeHandler} */ ({
204
+ scheme: 'https',
205
+ domainHost: http.domainHost,
206
+ parse: httpParse,
207
+ serialize: httpSerialize
208
+ })
209
+
210
+ const ws = /** @type {SchemeHandler} */ ({
211
+ scheme: 'ws',
212
+ domainHost: true,
213
+ parse: wsParse,
214
+ serialize: wsSerialize
215
+ })
216
+
217
+ const wss = /** @type {SchemeHandler} */ ({
218
+ scheme: 'wss',
219
+ domainHost: ws.domainHost,
220
+ parse: ws.parse,
221
+ serialize: ws.serialize
222
+ })
223
+
224
+ const urn = /** @type {SchemeHandler} */ ({
225
+ scheme: 'urn',
226
+ parse: urnParse,
227
+ serialize: urnSerialize,
228
+ skipNormalize: true
229
+ })
230
+
231
+ const urnuuid = /** @type {SchemeHandler} */ ({
232
+ scheme: 'urn:uuid',
233
+ parse: urnuuidParse,
234
+ serialize: urnuuidSerialize,
235
+ skipNormalize: true
236
+ })
237
+
238
+ const SCHEMES = /** @type {Record<SchemeName, SchemeHandler>} */ ({
239
+ http,
240
+ https,
241
+ ws,
242
+ wss,
243
+ urn,
244
+ 'urn:uuid': urnuuid
245
+ })
246
+
247
+ Object.setPrototypeOf(SCHEMES, null)
248
+
249
+ /**
250
+ * @param {string|undefined} scheme
251
+ * @returns {SchemeHandler|undefined}
252
+ */
253
+ function getSchemeHandler (scheme) {
254
+ return (
255
+ scheme && (
256
+ SCHEMES[/** @type {SchemeName} */ (scheme)] ||
257
+ SCHEMES[/** @type {SchemeName} */(scheme.toLowerCase())])
258
+ ) ||
259
+ undefined
260
+ }
261
+
262
+ module.exports = {
263
+ wsIsSecure,
264
+ SCHEMES,
265
+ isValidSchemeName,
266
+ getSchemeHandler,
267
+ }