@distilled.cloud/core 1.0.0-rc.16 → 1.0.0-rc.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_bundle/aws.js +2 -0
- package/lib/_bundle/aws.js.map +1 -0
- package/lib/_bundle/base.js +5 -0
- package/lib/_bundle/base.js.map +1 -0
- package/lib/_bundle/graphql.js +3 -0
- package/lib/_bundle/graphql.js.map +1 -0
- package/lib/_bundle/rest.js +2 -0
- package/lib/_bundle/rest.js.map +1 -0
- package/lib/_bundle/xml.js +4 -0
- package/lib/_bundle/xml.js.map +1 -0
- package/lib/annotations.d.ts +15 -0
- package/lib/annotations.d.ts.map +1 -0
- package/lib/annotations.js +2 -0
- package/lib/annotations.js.map +1 -0
- package/lib/api.d.ts +15 -0
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +1 -796
- package/lib/category.d.ts.map +1 -1
- package/lib/category.js +1 -278
- package/lib/chunks.js +1 -11
- package/lib/config.d.ts +54 -13
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +1 -161
- package/lib/crypto.js +1 -130
- package/lib/debug.d.ts.map +1 -1
- package/lib/debug.js +1 -8
- package/lib/error-category.d.ts.map +1 -1
- package/lib/error-category.js +1 -47
- package/lib/errors.d.ts +2 -13
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -198
- package/lib/graphql.d.ts +14 -0
- package/lib/graphql.d.ts.map +1 -1
- package/lib/graphql.js +1 -1058
- package/lib/graphql.types.js +1 -6
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -15
- package/lib/pagination.d.ts +34 -2
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +1 -271
- package/lib/plain-values.js +1 -39
- package/lib/plain-values.js.map +1 -1
- package/lib/protocol-http.d.ts +30 -6
- package/lib/protocol-http.d.ts.map +1 -1
- package/lib/protocol-http.js +1 -812
- package/lib/protocol-rest.d.ts +53 -39
- package/lib/protocol-rest.d.ts.map +1 -1
- package/lib/protocol-rest.js +1 -375
- package/lib/query.js +1 -27
- package/lib/response-validation-strict.js +1 -284
- package/lib/response-validation.d.ts +4 -3
- package/lib/response-validation.d.ts.map +1 -1
- package/lib/response-validation.js +1 -118
- package/lib/retry-after.js +1 -112
- package/lib/retry.js +1 -197
- package/lib/schema-lite-impl.js +1 -341
- package/lib/schema-lite-typed.js +1 -27
- package/lib/schema-lite.js +1 -31
- package/lib/schema.js +1 -220
- package/lib/telemetry-debug.d.ts +14 -0
- package/lib/telemetry-debug.d.ts.map +1 -0
- package/lib/telemetry-debug.js +2 -0
- package/lib/telemetry-debug.js.map +1 -0
- package/lib/telemetry-hooks.d.ts +32 -0
- package/lib/telemetry-hooks.d.ts.map +1 -0
- package/lib/telemetry-hooks.js +2 -0
- package/lib/telemetry-hooks.js.map +1 -0
- package/lib/telemetry-host-rules.d.ts +23 -0
- package/lib/telemetry-host-rules.d.ts.map +1 -0
- package/lib/telemetry-host-rules.js +2 -0
- package/lib/telemetry-host-rules.js.map +1 -0
- package/lib/telemetry-lambda-context.d.ts +17 -0
- package/lib/telemetry-lambda-context.d.ts.map +1 -0
- package/lib/telemetry-lambda-context.js +2 -0
- package/lib/telemetry-lambda-context.js.map +1 -0
- package/lib/telemetry-message-context.d.ts +52 -0
- package/lib/telemetry-message-context.d.ts.map +1 -0
- package/lib/telemetry-message-context.js +2 -0
- package/lib/telemetry-message-context.js.map +1 -0
- package/lib/telemetry-metrics.d.ts +6 -0
- package/lib/telemetry-metrics.d.ts.map +1 -0
- package/lib/telemetry-metrics.js +2 -0
- package/lib/telemetry-metrics.js.map +1 -0
- package/lib/telemetry-name-template.d.ts +13 -0
- package/lib/telemetry-name-template.d.ts.map +1 -0
- package/lib/telemetry-name-template.js +2 -0
- package/lib/telemetry-name-template.js.map +1 -0
- package/lib/telemetry-stream.d.ts +9 -0
- package/lib/telemetry-stream.d.ts.map +1 -0
- package/lib/telemetry-stream.js +2 -0
- package/lib/telemetry-stream.js.map +1 -0
- package/lib/telemetry-xray.d.ts +28 -0
- package/lib/telemetry-xray.d.ts.map +1 -0
- package/lib/telemetry-xray.js +2 -0
- package/lib/telemetry-xray.js.map +1 -0
- package/lib/telemetry.d.ts +269 -0
- package/lib/telemetry.d.ts.map +1 -0
- package/lib/telemetry.js +3 -0
- package/lib/telemetry.js.map +1 -0
- package/lib/trait.js +1 -131
- package/lib/xml.js +1 -323
- package/package.json +1 -3
- package/src/annotations.ts +37 -0
- package/src/api.ts +130 -30
- package/src/category.ts +21 -22
- package/src/config.ts +58 -29
- package/src/debug.ts +9 -6
- package/src/error-category.ts +12 -14
- package/src/errors.ts +7 -7
- package/src/graphql.ts +123 -18
- package/src/index.ts +3 -2
- package/src/pagination.ts +119 -6
- package/src/protocol-http.ts +63 -43
- package/src/protocol-rest.ts +201 -140
- package/src/response-validation.ts +4 -3
- package/src/telemetry-debug.ts +135 -0
- package/src/telemetry-hooks.ts +33 -0
- package/src/telemetry-host-rules.ts +39 -0
- package/src/telemetry-lambda-context.ts +46 -0
- package/src/telemetry-message-context.ts +170 -0
- package/src/telemetry-metrics.ts +69 -0
- package/src/telemetry-name-template.ts +26 -0
- package/src/telemetry-stream.ts +91 -0
- package/src/telemetry-xray.ts +66 -0
- package/src/telemetry.ts +768 -0
- package/lib/api.js.map +0 -1
- package/lib/category.js.map +0 -1
- package/lib/chunks.js.map +0 -1
- package/lib/codegen/boolean-string-enums.d.ts +0 -36
- package/lib/codegen/boolean-string-enums.d.ts.map +0 -1
- package/lib/codegen/boolean-string-enums.js +0 -147
- package/lib/codegen/boolean-string-enums.js.map +0 -1
- package/lib/codegen/chunk.d.ts +0 -7
- package/lib/codegen/chunk.d.ts.map +0 -1
- package/lib/codegen/chunk.js +0 -139
- package/lib/codegen/chunk.js.map +0 -1
- package/lib/codegen/cli.d.ts +0 -80
- package/lib/codegen/cli.d.ts.map +0 -1
- package/lib/codegen/cli.js +0 -166
- package/lib/codegen/cli.js.map +0 -1
- package/lib/codegen/datafy.d.ts +0 -14
- package/lib/codegen/datafy.d.ts.map +0 -1
- package/lib/codegen/datafy.js +0 -853
- package/lib/codegen/datafy.js.map +0 -1
- package/lib/codegen/dedupe.d.ts +0 -5
- package/lib/codegen/dedupe.d.ts.map +0 -1
- package/lib/codegen/dedupe.js +0 -153
- package/lib/codegen/dedupe.js.map +0 -1
- package/lib/codegen/emit.d.ts +0 -125
- package/lib/codegen/emit.d.ts.map +0 -1
- package/lib/codegen/emit.js +0 -99
- package/lib/codegen/emit.js.map +0 -1
- package/lib/codegen/format.d.ts +0 -11
- package/lib/codegen/format.d.ts.map +0 -1
- package/lib/codegen/format.js +0 -32
- package/lib/codegen/format.js.map +0 -1
- package/lib/codegen/generated-at.d.ts +0 -29
- package/lib/codegen/generated-at.d.ts.map +0 -1
- package/lib/codegen/generated-at.js +0 -78
- package/lib/codegen/generated-at.js.map +0 -1
- package/lib/codegen/generator.d.ts +0 -353
- package/lib/codegen/generator.d.ts.map +0 -1
- package/lib/codegen/generator.js +0 -810
- package/lib/codegen/generator.js.map +0 -1
- package/lib/codegen/graph.d.ts +0 -36
- package/lib/codegen/graph.d.ts.map +0 -1
- package/lib/codegen/graph.js +0 -136
- package/lib/codegen/graph.js.map +0 -1
- package/lib/codegen/graphql-client.d.ts +0 -70
- package/lib/codegen/graphql-client.d.ts.map +0 -1
- package/lib/codegen/graphql-client.js +0 -439
- package/lib/codegen/graphql-client.js.map +0 -1
- package/lib/codegen/graphql.d.ts +0 -207
- package/lib/codegen/graphql.d.ts.map +0 -1
- package/lib/codegen/graphql.js +0 -786
- package/lib/codegen/graphql.js.map +0 -1
- package/lib/codegen/latin1.d.ts +0 -3
- package/lib/codegen/latin1.d.ts.map +0 -1
- package/lib/codegen/latin1.js +0 -126
- package/lib/codegen/latin1.js.map +0 -1
- package/lib/codegen/members.d.ts +0 -32
- package/lib/codegen/members.d.ts.map +0 -1
- package/lib/codegen/members.js +0 -62
- package/lib/codegen/members.js.map +0 -1
- package/lib/codegen/model-diff.d.ts +0 -10
- package/lib/codegen/model-diff.d.ts.map +0 -1
- package/lib/codegen/model-diff.js +0 -67
- package/lib/codegen/model-diff.js.map +0 -1
- package/lib/codegen/naming.d.ts +0 -29
- package/lib/codegen/naming.d.ts.map +0 -1
- package/lib/codegen/naming.js +0 -74
- package/lib/codegen/naming.js.map +0 -1
- package/lib/codegen/openapi-cli.d.ts +0 -52
- package/lib/codegen/openapi-cli.d.ts.map +0 -1
- package/lib/codegen/openapi-cli.js +0 -84
- package/lib/codegen/openapi-cli.js.map +0 -1
- package/lib/codegen/openapi.d.ts +0 -209
- package/lib/codegen/openapi.d.ts.map +0 -1
- package/lib/codegen/openapi.js +0 -1548
- package/lib/codegen/openapi.js.map +0 -1
- package/lib/codegen/operations.d.ts +0 -24
- package/lib/codegen/operations.d.ts.map +0 -1
- package/lib/codegen/operations.js +0 -56
- package/lib/codegen/operations.js.map +0 -1
- package/lib/codegen/pagination.d.ts +0 -39
- package/lib/codegen/pagination.d.ts.map +0 -1
- package/lib/codegen/pagination.js +0 -31
- package/lib/codegen/pagination.js.map +0 -1
- package/lib/codegen/patch-audit.d.ts +0 -84
- package/lib/codegen/patch-audit.d.ts.map +0 -1
- package/lib/codegen/patch-audit.js +0 -366
- package/lib/codegen/patch-audit.js.map +0 -1
- package/lib/codegen/patches.d.ts +0 -129
- package/lib/codegen/patches.d.ts.map +0 -1
- package/lib/codegen/patches.js +0 -472
- package/lib/codegen/patches.js.map +0 -1
- package/lib/codegen/prelude.d.ts +0 -15
- package/lib/codegen/prelude.d.ts.map +0 -1
- package/lib/codegen/prelude.js +0 -60
- package/lib/codegen/prelude.js.map +0 -1
- package/lib/codegen/privatize.d.ts +0 -21
- package/lib/codegen/privatize.d.ts.map +0 -1
- package/lib/codegen/privatize.js +0 -176
- package/lib/codegen/privatize.js.map +0 -1
- package/lib/codegen/proto.d.ts +0 -121
- package/lib/codegen/proto.d.ts.map +0 -1
- package/lib/codegen/proto.js +0 -960
- package/lib/codegen/proto.js.map +0 -1
- package/lib/codegen/pure.d.ts +0 -6
- package/lib/codegen/pure.d.ts.map +0 -1
- package/lib/codegen/pure.js +0 -91
- package/lib/codegen/pure.js.map +0 -1
- package/lib/codegen/rewrite-operation-ids.d.ts +0 -154
- package/lib/codegen/rewrite-operation-ids.d.ts.map +0 -1
- package/lib/codegen/rewrite-operation-ids.js +0 -1117
- package/lib/codegen/rewrite-operation-ids.js.map +0 -1
- package/lib/codegen/spec-path.d.ts +0 -16
- package/lib/codegen/spec-path.d.ts.map +0 -1
- package/lib/codegen/spec-path.js +0 -101
- package/lib/codegen/spec-path.js.map +0 -1
- package/lib/codegen/table.d.ts +0 -5
- package/lib/codegen/table.d.ts.map +0 -1
- package/lib/codegen/table.js +0 -249
- package/lib/codegen/table.js.map +0 -1
- package/lib/config.js.map +0 -1
- package/lib/crypto.js.map +0 -1
- package/lib/debug.js.map +0 -1
- package/lib/error-category.js.map +0 -1
- package/lib/errors.js.map +0 -1
- package/lib/graphql.js.map +0 -1
- package/lib/graphql.types.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/json-patch.d.ts +0 -58
- package/lib/json-patch.d.ts.map +0 -1
- package/lib/json-patch.js +0 -227
- package/lib/json-patch.js.map +0 -1
- package/lib/pagination.js.map +0 -1
- package/lib/protocol-http.js.map +0 -1
- package/lib/protocol-rest.js.map +0 -1
- package/lib/query.js.map +0 -1
- package/lib/response-validation-strict.js.map +0 -1
- package/lib/response-validation.js.map +0 -1
- package/lib/retry-after.js.map +0 -1
- package/lib/retry.js.map +0 -1
- package/lib/schema-lite-impl.js.map +0 -1
- package/lib/schema-lite-typed.js.map +0 -1
- package/lib/schema-lite.js.map +0 -1
- package/lib/schema.js.map +0 -1
- package/lib/testing.d.ts +0 -40
- package/lib/testing.d.ts.map +0 -1
- package/lib/testing.js +0 -42
- package/lib/testing.js.map +0 -1
- package/lib/trait.js.map +0 -1
- package/lib/xml.js.map +0 -1
- package/src/codegen/boolean-string-enums.ts +0 -155
- package/src/codegen/chunk.ts +0 -147
- package/src/codegen/cli.ts +0 -293
- package/src/codegen/datafy.ts +0 -874
- package/src/codegen/dedupe.ts +0 -173
- package/src/codegen/emit.ts +0 -200
- package/src/codegen/format.ts +0 -49
- package/src/codegen/generated-at.ts +0 -88
- package/src/codegen/generator.ts +0 -1229
- package/src/codegen/graph.ts +0 -151
- package/src/codegen/graphql-client.ts +0 -545
- package/src/codegen/graphql.ts +0 -1145
- package/src/codegen/latin1.ts +0 -131
- package/src/codegen/members.ts +0 -79
- package/src/codegen/model-diff.ts +0 -67
- package/src/codegen/naming.ts +0 -85
- package/src/codegen/openapi-cli.ts +0 -141
- package/src/codegen/openapi.ts +0 -1845
- package/src/codegen/operations.ts +0 -73
- package/src/codegen/pagination.ts +0 -64
- package/src/codegen/patch-audit.ts +0 -480
- package/src/codegen/patches.ts +0 -581
- package/src/codegen/prelude.ts +0 -70
- package/src/codegen/privatize.ts +0 -200
- package/src/codegen/proto.ts +0 -1092
- package/src/codegen/pure.ts +0 -94
- package/src/codegen/rewrite-operation-ids.ts +0 -1219
- package/src/codegen/spec-path.ts +0 -112
- package/src/codegen/table.ts +0 -254
- package/src/json-patch.ts +0 -273
- package/src/testing.ts +0 -74
package/lib/xml.js
CHANGED
|
@@ -1,323 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
export class XmlParseError extends /*@__PURE__*/ /*@__PURE__*/ Data.TaggedError("XmlParseError") {
|
|
4
|
-
}
|
|
5
|
-
// XML 1.0 (Fifth Edition) NameStartChar / NameChar, including astral names.
|
|
6
|
-
const namePattern =
|
|
7
|
-
// XML NameChar explicitly includes combining marks as individual code points.
|
|
8
|
-
// eslint-disable-next-line no-misleading-character-class
|
|
9
|
-
/[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}.\-0-9\u00B7\u0300-\u036F\u203F-\u2040]*/uy;
|
|
10
|
-
const invalidCharacter =
|
|
11
|
-
// XML 1.0 forbids these literal controls and unpaired surrogates.
|
|
12
|
-
// eslint-disable-next-line no-control-regex
|
|
13
|
-
/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/u;
|
|
14
|
-
const xmlSpace = /^[\t\n\r ]*$/;
|
|
15
|
-
const declarationPattern = /^xml[\t\n\r ]+version[\t\n\r ]*=[\t\n\r ]*(?:"1\.0"|'1\.0')(?:[\t\n\r ]+encoding[\t\n\r ]*=[\t\n\r ]*(?:"[A-Za-z][A-Za-z0-9._-]*"|'[A-Za-z][A-Za-z0-9._-]*'))?(?:[\t\n\r ]+standalone[\t\n\r ]*=[\t\n\r ]*(?:"(?:yes|no)"|'(?:yes|no)'))?[\t\n\r ]*$/;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const nodeProto = /*@__PURE__*/ Object.create(null);
|
|
23
|
-
|
|
24
|
-
const asciiName = /[A-Za-z_:][\w:.-]*(?![^\0-\x7f])/y;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export function parseXmlSync(xml, options = {}) {
|
|
35
|
-
let pos = xml.charCodeAt(0) === 0xfeff ? 1 : 0;
|
|
36
|
-
const start = pos;
|
|
37
|
-
const maxDepth = options.maxDepth ?? 256;
|
|
38
|
-
const maxLength = options.maxLength ?? 64 * 1024 * 1024;
|
|
39
|
-
const stack = [];
|
|
40
|
-
const document = Object.create(nodeProto);
|
|
41
|
-
let hasRoot = false;
|
|
42
|
-
function fail(message, offset = pos) {
|
|
43
|
-
offset = Math.min(offset, xml.length);
|
|
44
|
-
const lines = xml.slice(0, offset).split(/\r\n|[\r\n]/);
|
|
45
|
-
const line = lines.length;
|
|
46
|
-
const column = lines[line - 1].length + 1;
|
|
47
|
-
throw new XmlParseError({
|
|
48
|
-
message: `${message} at ${line}:${column}`,
|
|
49
|
-
offset,
|
|
50
|
-
line,
|
|
51
|
-
column,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
if (!Number.isSafeInteger(maxDepth) || maxDepth < 1)
|
|
55
|
-
fail("Invalid maxDepth");
|
|
56
|
-
if (!Number.isSafeInteger(maxLength) || maxLength < 0)
|
|
57
|
-
fail("Invalid maxLength");
|
|
58
|
-
if (xml.length > maxLength)
|
|
59
|
-
fail("XML input length limit exceeded", 0);
|
|
60
|
-
const invalid = invalidCharacter.exec(xml);
|
|
61
|
-
if (invalid)
|
|
62
|
-
fail("Invalid XML character", invalid.index);
|
|
63
|
-
if (xmlSpace.test(xml.slice(start)))
|
|
64
|
-
return document;
|
|
65
|
-
function skipSpace() {
|
|
66
|
-
const before = pos;
|
|
67
|
-
while (pos < xml.length) {
|
|
68
|
-
const c = xml.charCodeAt(pos);
|
|
69
|
-
if (c !== 32 && c !== 9 && c !== 10 && c !== 13)
|
|
70
|
-
break;
|
|
71
|
-
pos++;
|
|
72
|
-
}
|
|
73
|
-
return pos !== before;
|
|
74
|
-
}
|
|
75
|
-
function readName() {
|
|
76
|
-
// ASCII names (most documents) match a cheaper, non-Unicode pattern first.
|
|
77
|
-
asciiName.lastIndex = namePattern.lastIndex = pos;
|
|
78
|
-
const match = asciiName.exec(xml) ?? namePattern.exec(xml);
|
|
79
|
-
if (!match)
|
|
80
|
-
fail("Expected XML name");
|
|
81
|
-
pos += match[0].length;
|
|
82
|
-
return match[0];
|
|
83
|
-
}
|
|
84
|
-
function decode(raw, offset, attribute = false) {
|
|
85
|
-
if (raw.indexOf("&") < 0 && !(attribute ? /[\t\r\n]/ : /\r/).test(raw))
|
|
86
|
-
return raw;
|
|
87
|
-
const parts = [];
|
|
88
|
-
let from = 0;
|
|
89
|
-
while (from < raw.length) {
|
|
90
|
-
const amp = raw.indexOf("&", from);
|
|
91
|
-
const end = amp < 0 ? raw.length : amp;
|
|
92
|
-
const literal = raw.slice(from, end);
|
|
93
|
-
parts.push(attribute ? literal.replace(/\r\n|[\t\r\n]/g, " ") : literal.replace(/\r\n?/g, "\n"));
|
|
94
|
-
if (amp < 0)
|
|
95
|
-
break;
|
|
96
|
-
const semi = raw.indexOf(";", amp + 1);
|
|
97
|
-
if (semi < 0)
|
|
98
|
-
fail("Unterminated entity reference", offset + amp);
|
|
99
|
-
const entity = raw.slice(amp + 1, semi);
|
|
100
|
-
switch (entity) {
|
|
101
|
-
case "amp":
|
|
102
|
-
parts.push("&");
|
|
103
|
-
break;
|
|
104
|
-
case "lt":
|
|
105
|
-
parts.push("<");
|
|
106
|
-
break;
|
|
107
|
-
case "gt":
|
|
108
|
-
parts.push(">");
|
|
109
|
-
break;
|
|
110
|
-
case "quot":
|
|
111
|
-
parts.push('"');
|
|
112
|
-
break;
|
|
113
|
-
case "apos":
|
|
114
|
-
parts.push("'");
|
|
115
|
-
break;
|
|
116
|
-
default: {
|
|
117
|
-
if (!/^#(?:[0-9]+|x[0-9a-fA-F]+)$/.test(entity)) {
|
|
118
|
-
fail("Unknown or invalid entity reference", offset + amp);
|
|
119
|
-
}
|
|
120
|
-
const code = entity[1] === "x"
|
|
121
|
-
? Number.parseInt(entity.slice(2), 16)
|
|
122
|
-
: Number.parseInt(entity.slice(1), 10);
|
|
123
|
-
if (!(code === 9 ||
|
|
124
|
-
code === 10 ||
|
|
125
|
-
code === 13 ||
|
|
126
|
-
(code >= 0x20 && code <= 0xd7ff) ||
|
|
127
|
-
(code >= 0xe000 && code <= 0xfffd) ||
|
|
128
|
-
(code >= 0x10000 && code <= 0x10ffff))) {
|
|
129
|
-
fail("Invalid character reference", offset + amp);
|
|
130
|
-
}
|
|
131
|
-
parts.push(String.fromCodePoint(code));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
from = semi + 1;
|
|
135
|
-
}
|
|
136
|
-
return parts.join("");
|
|
137
|
-
}
|
|
138
|
-
function finish(element) {
|
|
139
|
-
const text = element.text;
|
|
140
|
-
let value;
|
|
141
|
-
if (!element.hasChildren && !element.hasAttributes) {
|
|
142
|
-
value = text;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
if (text && (!element.hasChildren || element.hasCdata || !xmlSpace.test(text))) {
|
|
146
|
-
element.object["#text"] = text;
|
|
147
|
-
}
|
|
148
|
-
value = element.object;
|
|
149
|
-
}
|
|
150
|
-
const parent = stack[stack.length - 1];
|
|
151
|
-
const target = parent ? parent.object : document;
|
|
152
|
-
if (parent)
|
|
153
|
-
parent.hasChildren = true;
|
|
154
|
-
if (!Object.hasOwn(target, element.name))
|
|
155
|
-
target[element.name] = value;
|
|
156
|
-
else {
|
|
157
|
-
const previous = target[element.name];
|
|
158
|
-
if (Array.isArray(previous))
|
|
159
|
-
previous.push(value);
|
|
160
|
-
else
|
|
161
|
-
target[element.name] = [previous, value];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
while (pos < xml.length) {
|
|
165
|
-
if (xml[pos] !== "<") {
|
|
166
|
-
const offset = pos;
|
|
167
|
-
const next = xml.indexOf("<", pos);
|
|
168
|
-
pos = next < 0 ? xml.length : next;
|
|
169
|
-
const raw = xml.slice(offset, pos);
|
|
170
|
-
const element = stack[stack.length - 1];
|
|
171
|
-
if (!element) {
|
|
172
|
-
if (!xmlSpace.test(raw))
|
|
173
|
-
fail("Text outside root element", offset);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
const cdataEnd = raw.indexOf("]]>");
|
|
177
|
-
if (cdataEnd >= 0)
|
|
178
|
-
fail("Unexpected CDATA terminator", offset + cdataEnd);
|
|
179
|
-
element.text += decode(raw, offset);
|
|
180
|
-
}
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
if (xml.startsWith("<!--", pos)) {
|
|
184
|
-
const end = xml.indexOf("-->", pos + 4);
|
|
185
|
-
if (end < 0)
|
|
186
|
-
fail("Unterminated comment");
|
|
187
|
-
const comment = xml.slice(pos + 4, end);
|
|
188
|
-
if (comment.includes("--") || comment.endsWith("-"))
|
|
189
|
-
fail("Invalid comment");
|
|
190
|
-
pos = end + 3;
|
|
191
|
-
}
|
|
192
|
-
else if (xml.startsWith("<![CDATA[", pos)) {
|
|
193
|
-
const element = stack[stack.length - 1];
|
|
194
|
-
if (!element)
|
|
195
|
-
fail("CDATA outside root element");
|
|
196
|
-
const end = xml.indexOf("]]>", pos + 9);
|
|
197
|
-
if (end < 0)
|
|
198
|
-
fail("Unterminated CDATA");
|
|
199
|
-
element.text += xml.slice(pos + 9, end).replace(/\r\n?/g, "\n");
|
|
200
|
-
element.hasCdata = true;
|
|
201
|
-
pos = end + 3;
|
|
202
|
-
}
|
|
203
|
-
else if (xml.startsWith("<?", pos)) {
|
|
204
|
-
const offset = pos;
|
|
205
|
-
pos += 2;
|
|
206
|
-
const target = readName();
|
|
207
|
-
if (!xml.startsWith("?>", pos) && !skipSpace())
|
|
208
|
-
fail("Expected PI whitespace");
|
|
209
|
-
const end = xml.indexOf("?>", pos);
|
|
210
|
-
if (end < 0)
|
|
211
|
-
fail("Unterminated processing instruction", offset);
|
|
212
|
-
if (target.toLowerCase() === "xml") {
|
|
213
|
-
if (offset !== start || !declarationPattern.test(xml.slice(offset + 2, end))) {
|
|
214
|
-
fail("Invalid or misplaced XML declaration", offset);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
pos = end + 2;
|
|
218
|
-
}
|
|
219
|
-
else if (xml.startsWith("<!", pos)) {
|
|
220
|
-
fail("DTDs and markup declarations are not supported");
|
|
221
|
-
}
|
|
222
|
-
else if (xml.startsWith("</", pos)) {
|
|
223
|
-
pos += 2;
|
|
224
|
-
const name = readName();
|
|
225
|
-
skipSpace();
|
|
226
|
-
if (xml[pos] !== ">")
|
|
227
|
-
fail("Expected closing tag terminator");
|
|
228
|
-
const element = stack.pop();
|
|
229
|
-
if (!element || element.name !== name)
|
|
230
|
-
fail("Mismatched closing tag");
|
|
231
|
-
pos++;
|
|
232
|
-
finish(element);
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
if (stack.length >= maxDepth)
|
|
236
|
-
fail("XML depth limit exceeded");
|
|
237
|
-
if (stack.length === 0) {
|
|
238
|
-
if (hasRoot)
|
|
239
|
-
fail("Multiple root elements");
|
|
240
|
-
hasRoot = true;
|
|
241
|
-
}
|
|
242
|
-
pos++;
|
|
243
|
-
const element = {
|
|
244
|
-
name: readName(),
|
|
245
|
-
object: Object.create(nodeProto),
|
|
246
|
-
text: "",
|
|
247
|
-
hasChildren: false,
|
|
248
|
-
hasAttributes: false,
|
|
249
|
-
hasCdata: false,
|
|
250
|
-
};
|
|
251
|
-
while (true) {
|
|
252
|
-
const spaced = skipSpace();
|
|
253
|
-
if (xml.startsWith("/>", pos)) {
|
|
254
|
-
pos += 2;
|
|
255
|
-
finish(element);
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
if (xml[pos] === ">") {
|
|
259
|
-
pos++;
|
|
260
|
-
stack.push(element);
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
if (!spaced)
|
|
264
|
-
fail("Expected whitespace or tag terminator");
|
|
265
|
-
const name = readName();
|
|
266
|
-
const key = `@_${name}`;
|
|
267
|
-
if (Object.hasOwn(element.object, key))
|
|
268
|
-
fail("Duplicate attribute");
|
|
269
|
-
skipSpace();
|
|
270
|
-
if (xml[pos++] !== "=")
|
|
271
|
-
fail("Expected attribute equals sign");
|
|
272
|
-
skipSpace();
|
|
273
|
-
const quote = xml[pos++];
|
|
274
|
-
if (quote !== '"' && quote !== "'")
|
|
275
|
-
fail("Expected quoted attribute");
|
|
276
|
-
const end = xml.indexOf(quote, pos);
|
|
277
|
-
if (end < 0)
|
|
278
|
-
fail("Unterminated attribute");
|
|
279
|
-
const raw = xml.slice(pos, end);
|
|
280
|
-
if (raw.includes("<"))
|
|
281
|
-
fail("Unescaped '<' in attribute");
|
|
282
|
-
element.object[key] = decode(raw, pos, true);
|
|
283
|
-
element.hasAttributes = true;
|
|
284
|
-
pos = end + 1;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (stack.length)
|
|
289
|
-
fail("Unclosed element");
|
|
290
|
-
if (!hasRoot)
|
|
291
|
-
fail("Missing root element");
|
|
292
|
-
return document;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
export const parseXml = (xml, options) => Effect.suspend(() => {
|
|
296
|
-
try {
|
|
297
|
-
return Effect.succeed(parseXmlSync(xml, options));
|
|
298
|
-
}
|
|
299
|
-
catch (error) {
|
|
300
|
-
if (error instanceof XmlParseError)
|
|
301
|
-
return Effect.fail(error);
|
|
302
|
-
throw error;
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
const xmlEscapes = {
|
|
306
|
-
"&": "&",
|
|
307
|
-
"<": "<",
|
|
308
|
-
">": ">",
|
|
309
|
-
'"': """,
|
|
310
|
-
"'": "'",
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
export const escapeXml = (s) => s.replace(/[&<>"']/g, (c) => xmlEscapes[c]);
|
|
316
|
-
// =============================================================================
|
|
317
|
-
// XML Tag Helpers
|
|
318
|
-
// =============================================================================
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
export const wrapTag = (tag, content, xmlns) => `<${tag}${xmlns ? ` xmlns="${escapeXml(xmlns)}"` : ""}>${content}</${tag}>`;
|
|
323
|
-
//# sourceMappingURL=xml.js.map
|
|
1
|
+
export { xml$XmlParseError as XmlParseError, xml$escapeXml as escapeXml, xml$parseXml as parseXml, xml$parseXmlSync as parseXmlSync, xml$wrapTag as wrapTag } from "./_bundle/xml.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/core",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.18",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,10 +29,8 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@effect/platform-node": "^4.0.5",
|
|
33
32
|
"@types/node": "26.6.5",
|
|
34
33
|
"effect": "^4.0.5",
|
|
35
|
-
"rolldown": "1.2.13",
|
|
36
34
|
"vitest": "^5.0.4"
|
|
37
35
|
},
|
|
38
36
|
"peerDependencies": {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading schema annotations through the wrappers a generated schema has:
|
|
3
|
+
* Suspend, encodings, and `S.optional` / nullable unions. Shared by the
|
|
4
|
+
* protocols (via `./protocol-http.ts`) and by `./telemetry.ts`, which
|
|
5
|
+
* derives span facts from the same annotations.
|
|
6
|
+
*/
|
|
7
|
+
import type * as AST from "effect/SchemaAST";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Marks a response schema whose entire value is the response body (see
|
|
11
|
+
* `RawResponseRoot` in `./protocol-rest.ts`).
|
|
12
|
+
*/
|
|
13
|
+
export const rawResponseRootSymbol = /*@__PURE__*/ Symbol.for(
|
|
14
|
+
"@distilled.cloud/core/raw-response-root",
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const getProps = (ast: AST.AST): readonly AST.PropertySignature[] => {
|
|
18
|
+
if (ast._tag === "Objects") return ast.propertySignatures;
|
|
19
|
+
if (ast._tag === "Suspend") return getProps(ast.thunk());
|
|
20
|
+
if (ast.encoding && ast.encoding.length > 0) return getProps(ast.encoding[0]!.to);
|
|
21
|
+
return [];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const getAnn = (ast: AST.AST, symbol: symbol): unknown => {
|
|
25
|
+
const direct = (ast.annotations as Record<symbol, unknown> | undefined)?.[symbol];
|
|
26
|
+
if (direct !== undefined) return direct;
|
|
27
|
+
if (ast._tag === "Suspend") return getAnn(ast.thunk(), symbol);
|
|
28
|
+
if (ast.encoding && ast.encoding.length > 0) return getAnn(ast.encoding[0]!.to, symbol);
|
|
29
|
+
// S.optional -> Union[self, Undefined]; descend into the single real member.
|
|
30
|
+
if (ast._tag === "Union") {
|
|
31
|
+
const real = (ast as AST.Union).types.filter(
|
|
32
|
+
(t) => t._tag !== "Undefined" && !(t._tag === "Literal" && (t as any).literal === null),
|
|
33
|
+
);
|
|
34
|
+
if (real.length === 1) return getAnn(real[0]!, symbol);
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
};
|