@wirebench/engine 2.1.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.
- package/LICENSE +201 -0
- package/README.md +3 -0
- package/dist/assert/contract.d.ts +3 -0
- package/dist/assert/contract.js +17 -0
- package/dist/assert/index.d.ts +4 -0
- package/dist/assert/index.js +27 -0
- package/dist/assert/match.d.ts +3 -0
- package/dist/assert/match.js +58 -0
- package/dist/assert/model.d.ts +73 -0
- package/dist/assert/model.js +8 -0
- package/dist/assert/schema.d.ts +34 -0
- package/dist/assert/schema.js +46 -0
- package/dist/assert/sla.d.ts +3 -0
- package/dist/assert/sla.js +8 -0
- package/dist/assert/soap-fault.d.ts +3 -0
- package/dist/assert/soap-fault.js +20 -0
- package/dist/assert/status.d.ts +3 -0
- package/dist/assert/status.js +14 -0
- package/dist/errors.d.ts +77 -0
- package/dist/errors.js +121 -0
- package/dist/fs.d.ts +35 -0
- package/dist/fs.js +64 -0
- package/dist/generate.d.ts +12 -0
- package/dist/generate.js +14 -0
- package/dist/grpc/browser.d.ts +11 -0
- package/dist/grpc/browser.js +9 -0
- package/dist/grpc/cache.d.ts +113 -0
- package/dist/grpc/cache.js +244 -0
- package/dist/grpc/call.d.ts +64 -0
- package/dist/grpc/call.js +72 -0
- package/dist/grpc/codec.d.ts +29 -0
- package/dist/grpc/codec.js +416 -0
- package/dist/grpc/command.d.ts +23 -0
- package/dist/grpc/command.js +91 -0
- package/dist/grpc/expand.d.ts +25 -0
- package/dist/grpc/expand.js +52 -0
- package/dist/grpc/framing.d.ts +28 -0
- package/dist/grpc/framing.js +61 -0
- package/dist/grpc/import.d.ts +47 -0
- package/dist/grpc/import.js +88 -0
- package/dist/grpc/model.d.ts +179 -0
- package/dist/grpc/model.js +91 -0
- package/dist/grpc/proto/describe.d.ts +92 -0
- package/dist/grpc/proto/describe.js +205 -0
- package/dist/grpc/proto/load.d.ts +35 -0
- package/dist/grpc/proto/load.js +112 -0
- package/dist/grpc/proto/sample.d.ts +21 -0
- package/dist/grpc/proto/sample.js +79 -0
- package/dist/grpc/proto/well-known.d.ts +42 -0
- package/dist/grpc/proto/well-known.js +143 -0
- package/dist/grpc/reconcile.d.ts +42 -0
- package/dist/grpc/reconcile.js +153 -0
- package/dist/grpc/reflection/client.d.ts +70 -0
- package/dist/grpc/reflection/client.js +197 -0
- package/dist/grpc/reflection/descriptors.d.ts +69 -0
- package/dist/grpc/reflection/descriptors.js +140 -0
- package/dist/grpc/reflection/proto.d.ts +33 -0
- package/dist/grpc/reflection/proto.js +144 -0
- package/dist/grpc/send.d.ts +132 -0
- package/dist/grpc/send.js +435 -0
- package/dist/grpc/shape.d.ts +29 -0
- package/dist/grpc/shape.js +36 -0
- package/dist/grpc/status.d.ts +21 -0
- package/dist/grpc/status.js +62 -0
- package/dist/grpc/target.d.ts +21 -0
- package/dist/grpc/target.js +66 -0
- package/dist/http/auth/apply.d.ts +37 -0
- package/dist/http/auth/apply.js +74 -0
- package/dist/http/auth/basic.d.ts +36 -0
- package/dist/http/auth/basic.js +69 -0
- package/dist/http/auth/md4.d.ts +13 -0
- package/dist/http/auth/md4.js +81 -0
- package/dist/http/auth/ntlm-transport.d.ts +61 -0
- package/dist/http/auth/ntlm-transport.js +97 -0
- package/dist/http/auth/ntlm.d.ts +190 -0
- package/dist/http/auth/ntlm.js +377 -0
- package/dist/http/client.d.ts +73 -0
- package/dist/http/client.js +403 -0
- package/dist/http/curl-flags.d.ts +15 -0
- package/dist/http/curl-flags.js +95 -0
- package/dist/http/curl.d.ts +94 -0
- package/dist/http/curl.js +245 -0
- package/dist/http/decompress.d.ts +7 -0
- package/dist/http/decompress.js +22 -0
- package/dist/http/errors.d.ts +22 -0
- package/dist/http/errors.js +144 -0
- package/dist/http/failed-request.d.ts +27 -0
- package/dist/http/failed-request.js +48 -0
- package/dist/http/headers.d.ts +15 -0
- package/dist/http/headers.js +50 -0
- package/dist/http/heredoc.d.ts +25 -0
- package/dist/http/heredoc.js +74 -0
- package/dist/http/proxy.d.ts +103 -0
- package/dist/http/proxy.js +168 -0
- package/dist/http/raw-capture.d.ts +23 -0
- package/dist/http/raw-capture.js +57 -0
- package/dist/http/timings.d.ts +79 -0
- package/dist/http/timings.js +212 -0
- package/dist/http/tls.d.ts +111 -0
- package/dist/http/tls.js +167 -0
- package/dist/http/types.d.ts +125 -0
- package/dist/http/types.js +6 -0
- package/dist/import-detect.d.ts +26 -0
- package/dist/import-detect.js +169 -0
- package/dist/import.d.ts +20 -0
- package/dist/import.js +163 -0
- package/dist/index.d.ts +272 -0
- package/dist/index.js +157 -0
- package/dist/json/cursor.d.ts +43 -0
- package/dist/json/cursor.js +168 -0
- package/dist/operations.d.ts +12 -0
- package/dist/operations.js +52 -0
- package/dist/project/attachments-cache.d.ts +80 -0
- package/dist/project/attachments-cache.js +186 -0
- package/dist/project/endpoints.d.ts +23 -0
- package/dist/project/endpoints.js +47 -0
- package/dist/project/environments.d.ts +68 -0
- package/dist/project/environments.js +124 -0
- package/dist/project/fs.d.ts +45 -0
- package/dist/project/fs.js +78 -0
- package/dist/project/history.d.ts +171 -0
- package/dist/project/history.js +179 -0
- package/dist/project/keystores.d.ts +24 -0
- package/dist/project/keystores.js +66 -0
- package/dist/project/load.d.ts +44 -0
- package/dist/project/load.js +634 -0
- package/dist/project/migrate.d.ts +27 -0
- package/dist/project/migrate.js +46 -0
- package/dist/project/model.d.ts +401 -0
- package/dist/project/model.js +126 -0
- package/dist/project/paths.d.ts +134 -0
- package/dist/project/paths.js +259 -0
- package/dist/project/preferences.d.ts +318 -0
- package/dist/project/preferences.js +239 -0
- package/dist/project/properties.d.ts +97 -0
- package/dist/project/properties.js +356 -0
- package/dist/project/save.d.ts +65 -0
- package/dist/project/save.js +295 -0
- package/dist/project/schema.d.ts +1329 -0
- package/dist/project/schema.js +737 -0
- package/dist/project/serialize.d.ts +42 -0
- package/dist/project/serialize.js +385 -0
- package/dist/project/wss-configs.d.ts +40 -0
- package/dist/project/wss-configs.js +142 -0
- package/dist/project/yaml.d.ts +17 -0
- package/dist/project/yaml.js +39 -0
- package/dist/redact/index.d.ts +77 -0
- package/dist/redact/index.js +328 -0
- package/dist/redact/literal.d.ts +12 -0
- package/dist/redact/literal.js +68 -0
- package/dist/rest/auth.d.ts +53 -0
- package/dist/rest/auth.js +80 -0
- package/dist/rest/body.d.ts +61 -0
- package/dist/rest/body.js +184 -0
- package/dist/rest/browser.d.ts +12 -0
- package/dist/rest/browser.js +11 -0
- package/dist/rest/cookies.d.ts +41 -0
- package/dist/rest/cookies.js +102 -0
- package/dist/rest/curl.d.ts +75 -0
- package/dist/rest/curl.js +417 -0
- package/dist/rest/expand.d.ts +35 -0
- package/dist/rest/expand.js +104 -0
- package/dist/rest/model.d.ts +247 -0
- package/dist/rest/model.js +118 -0
- package/dist/rest/oauth2.d.ts +118 -0
- package/dist/rest/oauth2.js +212 -0
- package/dist/rest/openapi/cache.d.ts +54 -0
- package/dist/rest/openapi/cache.js +128 -0
- package/dist/rest/openapi/import.d.ts +67 -0
- package/dist/rest/openapi/import.js +91 -0
- package/dist/rest/openapi/map.d.ts +102 -0
- package/dist/rest/openapi/map.js +477 -0
- package/dist/rest/openapi/model.d.ts +203 -0
- package/dist/rest/openapi/model.js +37 -0
- package/dist/rest/openapi/parse.d.ts +44 -0
- package/dist/rest/openapi/parse.js +1530 -0
- package/dist/rest/openapi/refs.d.ts +63 -0
- package/dist/rest/openapi/refs.js +258 -0
- package/dist/rest/openapi/sample.d.ts +68 -0
- package/dist/rest/openapi/sample.js +336 -0
- package/dist/rest/postman/import.d.ts +21 -0
- package/dist/rest/postman/import.js +47 -0
- package/dist/rest/postman/index.d.ts +7 -0
- package/dist/rest/postman/index.js +7 -0
- package/dist/rest/postman/map.d.ts +28 -0
- package/dist/rest/postman/map.js +427 -0
- package/dist/rest/postman/model.d.ts +118 -0
- package/dist/rest/postman/model.js +7 -0
- package/dist/rest/postman/parse.d.ts +29 -0
- package/dist/rest/postman/parse.js +518 -0
- package/dist/rest/response.d.ts +72 -0
- package/dist/rest/response.js +221 -0
- package/dist/rest/send.d.ts +102 -0
- package/dist/rest/send.js +148 -0
- package/dist/rest/url.d.ts +92 -0
- package/dist/rest/url.js +213 -0
- package/dist/run/effective-auth.d.ts +10 -0
- package/dist/run/effective-auth.js +19 -0
- package/dist/run/index.d.ts +8 -0
- package/dist/run/index.js +4 -0
- package/dist/run/prepare.d.ts +43 -0
- package/dist/run/prepare.js +280 -0
- package/dist/run/run.d.ts +53 -0
- package/dist/run/run.js +223 -0
- package/dist/run/secret-needs.d.ts +13 -0
- package/dist/run/secret-needs.js +125 -0
- package/dist/run/select.d.ts +34 -0
- package/dist/run/select.js +76 -0
- package/dist/secrets/env-names.d.ts +27 -0
- package/dist/secrets/env-names.js +40 -0
- package/dist/secrets/resolve.d.ts +58 -0
- package/dist/secrets/resolve.js +136 -0
- package/dist/send-options.d.ts +141 -0
- package/dist/send-options.js +228 -0
- package/dist/send.d.ts +53 -0
- package/dist/send.js +210 -0
- package/dist/soap/body-builder.d.ts +38 -0
- package/dist/soap/body-builder.js +250 -0
- package/dist/soap/build-problems.d.ts +12 -0
- package/dist/soap/build-problems.js +2 -0
- package/dist/soap/charset.d.ts +23 -0
- package/dist/soap/charset.js +47 -0
- package/dist/soap/envelope.d.ts +44 -0
- package/dist/soap/envelope.js +76 -0
- package/dist/soap/fault.d.ts +46 -0
- package/dist/soap/fault.js +129 -0
- package/dist/soap/form-request.d.ts +34 -0
- package/dist/soap/form-request.js +251 -0
- package/dist/soap/legacy-project/definition-fetcher.d.ts +21 -0
- package/dist/soap/legacy-project/definition-fetcher.js +43 -0
- package/dist/soap/legacy-project/format.d.ts +18 -0
- package/dist/soap/legacy-project/format.js +24 -0
- package/dist/soap/legacy-project/import.d.ts +21 -0
- package/dist/soap/legacy-project/import.js +46 -0
- package/dist/soap/legacy-project/index.d.ts +9 -0
- package/dist/soap/legacy-project/index.js +5 -0
- package/dist/soap/legacy-project/map.d.ts +91 -0
- package/dist/soap/legacy-project/map.js +290 -0
- package/dist/soap/legacy-project/model.d.ts +98 -0
- package/dist/soap/legacy-project/model.js +5 -0
- package/dist/soap/legacy-project/parse.d.ts +16 -0
- package/dist/soap/legacy-project/parse.js +325 -0
- package/dist/soap/mime/cid-scan.d.ts +36 -0
- package/dist/soap/mime/cid-scan.js +52 -0
- package/dist/soap/mime/inline-files.d.ts +39 -0
- package/dist/soap/mime/inline-files.js +71 -0
- package/dist/soap/mime/mtom.d.ts +74 -0
- package/dist/soap/mime/mtom.js +134 -0
- package/dist/soap/mime/multipart.d.ts +66 -0
- package/dist/soap/mime/multipart.js +329 -0
- package/dist/soap/mime/send-pipeline.d.ts +61 -0
- package/dist/soap/mime/send-pipeline.js +145 -0
- package/dist/soap/mime/swa.d.ts +45 -0
- package/dist/soap/mime/swa.js +62 -0
- package/dist/soap/mime/types.d.ts +69 -0
- package/dist/soap/mime/types.js +10 -0
- package/dist/soap/namespace-scope.d.ts +32 -0
- package/dist/soap/namespace-scope.js +85 -0
- package/dist/soap/prefixes.d.ts +24 -0
- package/dist/soap/prefixes.js +70 -0
- package/dist/soap/recreate.d.ts +28 -0
- package/dist/soap/recreate.js +168 -0
- package/dist/soap/request-builder.d.ts +63 -0
- package/dist/soap/request-builder.js +161 -0
- package/dist/soap/response-parser.d.ts +29 -0
- package/dist/soap/response-parser.js +71 -0
- package/dist/soap/soap-action.d.ts +31 -0
- package/dist/soap/soap-action.js +28 -0
- package/dist/soap/transforms.d.ts +52 -0
- package/dist/soap/transforms.js +164 -0
- package/dist/types.d.ts +307 -0
- package/dist/types.js +6 -0
- package/dist/validate/index.d.ts +61 -0
- package/dist/validate/index.js +72 -0
- package/dist/validate/schema-file-set.d.ts +51 -0
- package/dist/validate/schema-file-set.js +288 -0
- package/dist/validate/schema-validator.d.ts +53 -0
- package/dist/validate/schema-validator.js +251 -0
- package/dist/validate/soap-structure.d.ts +34 -0
- package/dist/validate/soap-structure.js +255 -0
- package/dist/validate/types.d.ts +47 -0
- package/dist/validate/types.js +8 -0
- package/dist/validate/wsi/assertions/helpers.d.ts +145 -0
- package/dist/validate/wsi/assertions/helpers.js +387 -0
- package/dist/validate/wsi/assertions/index.d.ts +44 -0
- package/dist/validate/wsi/assertions/index.js +77 -0
- package/dist/validate/wsi/assertions/message/helpers.d.ts +63 -0
- package/dist/validate/wsi/assertions/message/helpers.js +168 -0
- package/dist/validate/wsi/assertions/message/index.d.ts +39 -0
- package/dist/validate/wsi/assertions/message/index.js +62 -0
- package/dist/validate/wsi/assertions/message/r1001.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1001.js +38 -0
- package/dist/validate/wsi/assertions/message/r1003.d.ts +14 -0
- package/dist/validate/wsi/assertions/message/r1003.js +45 -0
- package/dist/validate/wsi/assertions/message/r1005.d.ts +12 -0
- package/dist/validate/wsi/assertions/message/r1005.js +37 -0
- package/dist/validate/wsi/assertions/message/r1006.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1006.js +49 -0
- package/dist/validate/wsi/assertions/message/r1007.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1007.js +30 -0
- package/dist/validate/wsi/assertions/message/r1011.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1011.js +33 -0
- package/dist/validate/wsi/assertions/message/r1012.d.ts +13 -0
- package/dist/validate/wsi/assertions/message/r1012.js +37 -0
- package/dist/validate/wsi/assertions/message/r1013.d.ts +9 -0
- package/dist/validate/wsi/assertions/message/r1013.js +42 -0
- package/dist/validate/wsi/assertions/message/r1014.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1014.js +30 -0
- package/dist/validate/wsi/assertions/message/r1015.d.ts +12 -0
- package/dist/validate/wsi/assertions/message/r1015.js +36 -0
- package/dist/validate/wsi/assertions/message/r1017.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1017.js +30 -0
- package/dist/validate/wsi/assertions/message/r1100.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1100.js +39 -0
- package/dist/validate/wsi/assertions/message/r1101.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1101.js +37 -0
- package/dist/validate/wsi/assertions/message/r1102.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1102.js +41 -0
- package/dist/validate/wsi/assertions/message/r1103.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1103.js +28 -0
- package/dist/validate/wsi/assertions/message/r1107.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1107.js +38 -0
- package/dist/validate/wsi/assertions/message/r1109.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1109.js +32 -0
- package/dist/validate/wsi/assertions/message/r1124.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1124.js +31 -0
- package/dist/validate/wsi/assertions/message/r1132.d.ts +9 -0
- package/dist/validate/wsi/assertions/message/r1132.js +23 -0
- package/dist/validate/wsi/assertions/message/r1140.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1140.js +42 -0
- package/dist/validate/wsi/assertions/message/r1141.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1141.js +32 -0
- package/dist/validate/wsi/assertions/message/r2113.d.ts +11 -0
- package/dist/validate/wsi/assertions/message/r2113.js +33 -0
- package/dist/validate/wsi/assertions/message/r2211.d.ts +7 -0
- package/dist/validate/wsi/assertions/message/r2211.js +42 -0
- package/dist/validate/wsi/assertions/r2001.d.ts +15 -0
- package/dist/validate/wsi/assertions/r2001.js +47 -0
- package/dist/validate/wsi/assertions/r2002.d.ts +11 -0
- package/dist/validate/wsi/assertions/r2002.js +38 -0
- package/dist/validate/wsi/assertions/r2003.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2003.js +32 -0
- package/dist/validate/wsi/assertions/r2005.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2005.js +40 -0
- package/dist/validate/wsi/assertions/r2101.d.ts +14 -0
- package/dist/validate/wsi/assertions/r2101.js +65 -0
- package/dist/validate/wsi/assertions/r2102.d.ts +10 -0
- package/dist/validate/wsi/assertions/r2102.js +41 -0
- package/dist/validate/wsi/assertions/r2105.d.ts +8 -0
- package/dist/validate/wsi/assertions/r2105.js +39 -0
- package/dist/validate/wsi/assertions/r2110.d.ts +8 -0
- package/dist/validate/wsi/assertions/r2110.js +38 -0
- package/dist/validate/wsi/assertions/r2111.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2111.js +30 -0
- package/dist/validate/wsi/assertions/r2112.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2112.js +35 -0
- package/dist/validate/wsi/assertions/r2201.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2201.js +28 -0
- package/dist/validate/wsi/assertions/r2203.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2203.js +30 -0
- package/dist/validate/wsi/assertions/r2204.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2204.js +29 -0
- package/dist/validate/wsi/assertions/r2205.d.ts +8 -0
- package/dist/validate/wsi/assertions/r2205.js +46 -0
- package/dist/validate/wsi/assertions/r2206.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2206.js +36 -0
- package/dist/validate/wsi/assertions/r2209.d.ts +12 -0
- package/dist/validate/wsi/assertions/r2209.js +37 -0
- package/dist/validate/wsi/assertions/r2210.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2210.js +30 -0
- package/dist/validate/wsi/assertions/r2303.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2303.js +44 -0
- package/dist/validate/wsi/assertions/r2304.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2304.js +32 -0
- package/dist/validate/wsi/assertions/r2401.d.ts +12 -0
- package/dist/validate/wsi/assertions/r2401.js +31 -0
- package/dist/validate/wsi/assertions/r2701.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2701.js +28 -0
- package/dist/validate/wsi/assertions/r2702.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2702.js +26 -0
- package/dist/validate/wsi/assertions/r2705.d.ts +11 -0
- package/dist/validate/wsi/assertions/r2705.js +31 -0
- package/dist/validate/wsi/assertions/r2706.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2706.js +29 -0
- package/dist/validate/wsi/assertions/r2710.d.ts +13 -0
- package/dist/validate/wsi/assertions/r2710.js +37 -0
- package/dist/validate/wsi/assertions/r2716.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2716.js +29 -0
- package/dist/validate/wsi/assertions/r2717.d.ts +9 -0
- package/dist/validate/wsi/assertions/r2717.js +31 -0
- package/dist/validate/wsi/assertions/r2718.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2718.js +41 -0
- package/dist/validate/wsi/assertions/r2720.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2720.js +29 -0
- package/dist/validate/wsi/assertions/r2721.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2721.js +27 -0
- package/dist/validate/wsi/assertions/r2722.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2722.js +29 -0
- package/dist/validate/wsi/assertions/r2801.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2801.js +39 -0
- package/dist/validate/wsi/assertions/r2803.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2803.js +29 -0
- package/dist/validate/wsi/docs.d.ts +29 -0
- package/dist/validate/wsi/docs.js +167 -0
- package/dist/validate/wsi/index.d.ts +16 -0
- package/dist/validate/wsi/index.js +11 -0
- package/dist/validate/wsi/report-html.d.ts +36 -0
- package/dist/validate/wsi/report-html.js +135 -0
- package/dist/validate/wsi/run-message.d.ts +50 -0
- package/dist/validate/wsi/run-message.js +190 -0
- package/dist/validate/wsi/run-wsdl.d.ts +48 -0
- package/dist/validate/wsi/run-wsdl.js +99 -0
- package/dist/validate/wsi/types.d.ts +173 -0
- package/dist/validate/wsi/types.js +17 -0
- package/dist/workspace/commit-message.d.ts +47 -0
- package/dist/workspace/commit-message.js +195 -0
- package/dist/workspace/environments.d.ts +79 -0
- package/dist/workspace/environments.js +115 -0
- package/dist/workspace/index.d.ts +28 -0
- package/dist/workspace/index.js +19 -0
- package/dist/workspace/load.d.ts +45 -0
- package/dist/workspace/load.js +155 -0
- package/dist/workspace/local-state.d.ts +37 -0
- package/dist/workspace/local-state.js +59 -0
- package/dist/workspace/migrate.d.ts +38 -0
- package/dist/workspace/migrate.js +50 -0
- package/dist/workspace/model.d.ts +86 -0
- package/dist/workspace/model.js +54 -0
- package/dist/workspace/paths.d.ts +64 -0
- package/dist/workspace/paths.js +97 -0
- package/dist/workspace/reidentify.d.ts +22 -0
- package/dist/workspace/reidentify.js +122 -0
- package/dist/workspace/save.d.ts +31 -0
- package/dist/workspace/save.js +84 -0
- package/dist/workspace/schema.d.ts +93 -0
- package/dist/workspace/schema.js +115 -0
- package/dist/workspace/serialize.d.ts +24 -0
- package/dist/workspace/serialize.js +60 -0
- package/dist/workspace/share.d.ts +52 -0
- package/dist/workspace/share.js +89 -0
- package/dist/ws/browser.d.ts +13 -0
- package/dist/ws/browser.js +11 -0
- package/dist/ws/call.d.ts +53 -0
- package/dist/ws/call.js +106 -0
- package/dist/ws/command.d.ts +19 -0
- package/dist/ws/command.js +28 -0
- package/dist/ws/expand.d.ts +38 -0
- package/dist/ws/expand.js +76 -0
- package/dist/ws/model.d.ts +191 -0
- package/dist/ws/model.js +83 -0
- package/dist/ws/pretty.d.ts +12 -0
- package/dist/ws/pretty.js +25 -0
- package/dist/ws/session.d.ts +50 -0
- package/dist/ws/session.js +333 -0
- package/dist/ws/shape.d.ts +18 -0
- package/dist/ws/shape.js +28 -0
- package/dist/ws/transcript.d.ts +14 -0
- package/dist/ws/transcript.js +29 -0
- package/dist/ws/url.d.ts +3 -0
- package/dist/ws/url.js +44 -0
- package/dist/wsa/headers.d.ts +78 -0
- package/dist/wsa/headers.js +244 -0
- package/dist/wsa/model.d.ts +66 -0
- package/dist/wsa/model.js +52 -0
- package/dist/wsa/policy-detect.d.ts +81 -0
- package/dist/wsa/policy-detect.js +245 -0
- package/dist/wsdl/cache-naming.d.ts +39 -0
- package/dist/wsdl/cache-naming.js +90 -0
- package/dist/wsdl/cache.d.ts +48 -0
- package/dist/wsdl/cache.js +141 -0
- package/dist/wsdl/docs-generator.d.ts +47 -0
- package/dist/wsdl/docs-generator.js +439 -0
- package/dist/wsdl/dom-utils.d.ts +15 -0
- package/dist/wsdl/dom-utils.js +50 -0
- package/dist/wsdl/export-definition.d.ts +38 -0
- package/dist/wsdl/export-definition.js +100 -0
- package/dist/wsdl/fetch.d.ts +13 -0
- package/dist/wsdl/fetch.js +60 -0
- package/dist/wsdl/merge.d.ts +17 -0
- package/dist/wsdl/merge.js +57 -0
- package/dist/wsdl/model.d.ts +176 -0
- package/dist/wsdl/model.js +17 -0
- package/dist/wsdl/parse-binding.d.ts +6 -0
- package/dist/wsdl/parse-binding.js +150 -0
- package/dist/wsdl/parse-wsdl.d.ts +47 -0
- package/dist/wsdl/parse-wsdl.js +161 -0
- package/dist/wsdl/qname.d.ts +28 -0
- package/dist/wsdl/qname.js +41 -0
- package/dist/wsdl/ref-policy.d.ts +54 -0
- package/dist/wsdl/ref-policy.js +87 -0
- package/dist/wsdl/resolver.d.ts +81 -0
- package/dist/wsdl/resolver.js +276 -0
- package/dist/wsdl/update-definition.d.ts +106 -0
- package/dist/wsdl/update-definition.js +314 -0
- package/dist/wss/apply.d.ts +40 -0
- package/dist/wss/apply.js +212 -0
- package/dist/wss/c14n-prefixes.d.ts +27 -0
- package/dist/wss/c14n-prefixes.js +95 -0
- package/dist/wss/incoming/decrypt.d.ts +35 -0
- package/dist/wss/incoming/decrypt.js +57 -0
- package/dist/wss/incoming/index.d.ts +56 -0
- package/dist/wss/incoming/index.js +189 -0
- package/dist/wss/incoming/verify.d.ts +74 -0
- package/dist/wss/incoming/verify.js +440 -0
- package/dist/wss/key-identifiers.d.ts +76 -0
- package/dist/wss/key-identifiers.js +139 -0
- package/dist/wss/keystore/certificate.d.ts +45 -0
- package/dist/wss/keystore/certificate.js +134 -0
- package/dist/wss/keystore/index.d.ts +50 -0
- package/dist/wss/keystore/index.js +80 -0
- package/dist/wss/keystore/model.d.ts +83 -0
- package/dist/wss/keystore/model.js +27 -0
- package/dist/wss/keystore/pem.d.ts +21 -0
- package/dist/wss/keystore/pem.js +140 -0
- package/dist/wss/keystore/pkcs12.d.ts +21 -0
- package/dist/wss/keystore/pkcs12.js +125 -0
- package/dist/wss/model.d.ts +160 -0
- package/dist/wss/model.js +37 -0
- package/dist/wss/outgoing/encryption.d.ts +76 -0
- package/dist/wss/outgoing/encryption.js +618 -0
- package/dist/wss/outgoing/signature.d.ts +73 -0
- package/dist/wss/outgoing/signature.js +239 -0
- package/dist/wss/outgoing/timestamp.d.ts +29 -0
- package/dist/wss/outgoing/timestamp.js +39 -0
- package/dist/wss/outgoing/username-token.d.ts +36 -0
- package/dist/wss/outgoing/username-token.js +68 -0
- package/dist/wss/security-header.d.ts +31 -0
- package/dist/wss/security-header.js +83 -0
- package/dist/xml/index.d.ts +7 -0
- package/dist/xml/index.js +7 -0
- package/dist/xml/namespaces.d.ts +36 -0
- package/dist/xml/namespaces.js +60 -0
- package/dist/xml/parse.d.ts +79 -0
- package/dist/xml/parse.js +109 -0
- package/dist/xml/positions.d.ts +26 -0
- package/dist/xml/positions.js +71 -0
- package/dist/xml/pretty.d.ts +37 -0
- package/dist/xml/pretty.js +137 -0
- package/dist/xml/serialize.d.ts +6 -0
- package/dist/xml/serialize.js +8 -0
- package/dist/xml/tolerant-tree.d.ts +56 -0
- package/dist/xml/tolerant-tree.js +134 -0
- package/dist/xpath/evaluate-async.d.ts +31 -0
- package/dist/xpath/evaluate-async.js +81 -0
- package/dist/xpath/evaluate.d.ts +98 -0
- package/dist/xpath/evaluate.js +340 -0
- package/dist/xpath/jsonpath.d.ts +40 -0
- package/dist/xpath/jsonpath.js +109 -0
- package/dist/xpath/namespaces.d.ts +29 -0
- package/dist/xpath/namespaces.js +101 -0
- package/dist/xpath/worker.d.ts +7 -0
- package/dist/xpath/worker.js +26 -0
- package/dist/xsd/builtins.d.ts +36 -0
- package/dist/xsd/builtins.js +108 -0
- package/dist/xsd/check-references.d.ts +25 -0
- package/dist/xsd/check-references.js +145 -0
- package/dist/xsd/form-edits.d.ts +57 -0
- package/dist/xsd/form-edits.js +153 -0
- package/dist/xsd/form-model.d.ts +153 -0
- package/dist/xsd/form-model.js +691 -0
- package/dist/xsd/locate.d.ts +42 -0
- package/dist/xsd/locate.js +249 -0
- package/dist/xsd/model.d.ts +249 -0
- package/dist/xsd/model.js +1 -0
- package/dist/xsd/parse-particles.d.ts +48 -0
- package/dist/xsd/parse-particles.js +320 -0
- package/dist/xsd/parse-schema.d.ts +21 -0
- package/dist/xsd/parse-schema.js +143 -0
- package/dist/xsd/resolve-content.d.ts +18 -0
- package/dist/xsd/resolve-content.js +242 -0
- package/dist/xsd/sample-generator.d.ts +51 -0
- package/dist/xsd/sample-generator.js +291 -0
- package/dist/xsd/sample-types.d.ts +21 -0
- package/dist/xsd/sample-types.js +69 -0
- package/dist/xsd/sample-values.d.ts +54 -0
- package/dist/xsd/sample-values.js +267 -0
- package/dist/xsd/schema-set.d.ts +51 -0
- package/dist/xsd/schema-set.js +203 -0
- package/dist/xsd/xml-scan.d.ts +64 -0
- package/dist/xsd/xml-scan.js +286 -0
- package/dist/xsd/xml-writer.d.ts +56 -0
- package/dist/xsd/xml-writer.js +103 -0
- package/package.json +69 -0
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Generate Documentation": renders an imported definition as a
|
|
3
|
+
* single self-contained document — HTML (inline CSS, no scripts, everything
|
|
4
|
+
* escaped) or Markdown (with a table of contents).
|
|
5
|
+
*
|
|
6
|
+
* Pure and deterministic: the same {@link ImportResult} always produces
|
|
7
|
+
* byte-identical output, so the golden tests are meaningful and a regenerated
|
|
8
|
+
* document is a clean diff. Nothing is fetched; every byte comes from the
|
|
9
|
+
* bundle the import already resolved.
|
|
10
|
+
*/
|
|
11
|
+
import { findBinding, findMessage, findPortType } from './model.js';
|
|
12
|
+
import { qnameToString } from './qname.js';
|
|
13
|
+
const EMPTY = '—';
|
|
14
|
+
function escapeHtml(value) {
|
|
15
|
+
return value
|
|
16
|
+
.replace(/&/g, '&')
|
|
17
|
+
.replace(/</g, '<')
|
|
18
|
+
.replace(/>/g, '>')
|
|
19
|
+
.replace(/"/g, '"')
|
|
20
|
+
.replace(/'/g, ''');
|
|
21
|
+
}
|
|
22
|
+
/** Escapes the Markdown characters that would break a one-line table cell. */
|
|
23
|
+
function escapeMarkdownCell(value) {
|
|
24
|
+
return value.replace(/\|/g, '\\|').replace(/\r?\n/g, ' ');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Escapes free text — `wsdl:documentation` and the document title — before it goes into the
|
|
28
|
+
* Markdown output verbatim. Both can come straight from the WSDL author, so they are HTML-escaped
|
|
29
|
+
* (many Markdown renderers pass raw HTML through) and any line-leading `#`, `>` or `-` is
|
|
30
|
+
* neutralised so the text can't inject a heading, blockquote or list item into the document's
|
|
31
|
+
* own structure.
|
|
32
|
+
*/
|
|
33
|
+
function escapeMarkdownText(value) {
|
|
34
|
+
return escapeHtml(value)
|
|
35
|
+
.split(/\r?\n/)
|
|
36
|
+
.map((line) => line.replace(/^(\s*)([#>-])/, '$1\\$2'))
|
|
37
|
+
.join('\n');
|
|
38
|
+
}
|
|
39
|
+
/** A stable, URL-safe anchor for a heading, deduplicated by the caller's `taken` set. */
|
|
40
|
+
function anchorOf(heading, taken) {
|
|
41
|
+
const base = heading
|
|
42
|
+
.toLowerCase()
|
|
43
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
44
|
+
.replace(/^-+|-+$/g, '') || 'section';
|
|
45
|
+
let anchor = base;
|
|
46
|
+
let n = 2;
|
|
47
|
+
while (taken.has(anchor)) {
|
|
48
|
+
anchor = `${base}-${String(n)}`;
|
|
49
|
+
n += 1;
|
|
50
|
+
}
|
|
51
|
+
taken.add(anchor);
|
|
52
|
+
return anchor;
|
|
53
|
+
}
|
|
54
|
+
/** `{ns}local` for a QName, or the empty marker when there is none. */
|
|
55
|
+
function clark(name) {
|
|
56
|
+
return name === undefined ? EMPTY : qnameToString(name);
|
|
57
|
+
}
|
|
58
|
+
/** How one `wsdl:part` binds to the schema: an element reference, a type reference, or neither. */
|
|
59
|
+
function partTarget(part) {
|
|
60
|
+
if (part.element !== undefined) {
|
|
61
|
+
return `element ${qnameToString(part.element)}`;
|
|
62
|
+
}
|
|
63
|
+
if (part.type !== undefined) {
|
|
64
|
+
return `type ${qnameToString(part.type)}`;
|
|
65
|
+
}
|
|
66
|
+
return EMPTY;
|
|
67
|
+
}
|
|
68
|
+
/** The `wsdl:message` a message reference points at, when the merged definition has it. */
|
|
69
|
+
function messageParts(definition, name) {
|
|
70
|
+
if (name === undefined) {
|
|
71
|
+
return EMPTY;
|
|
72
|
+
}
|
|
73
|
+
const message = findMessage(definition, name);
|
|
74
|
+
if (message === undefined || message.parts.length === 0) {
|
|
75
|
+
return qnameToString(name);
|
|
76
|
+
}
|
|
77
|
+
return `${qnameToString(name)} (${message.parts.map((part) => `${part.name}: ${partTarget(part)}`).join(', ')})`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The XML source of the element that starts on `line` (1-based) of `text`, capped at
|
|
81
|
+
* `maxLines`. Textual rather than DOM-based on purpose: the point is to show the author's own
|
|
82
|
+
* markup, comments and formatting, not a re-serialisation of it. An attribute value containing
|
|
83
|
+
* a literal `>` would end the snippet early — vanishingly rare in a schema, and worth the
|
|
84
|
+
* simplicity of not carrying a second parser here.
|
|
85
|
+
*
|
|
86
|
+
* @param text the whole document the declaration lives in
|
|
87
|
+
* @param line the 1-based line the declaration's start tag opens on
|
|
88
|
+
* @param maxLines how many lines to keep before cutting the snippet with an ellipsis
|
|
89
|
+
* @returns the declaration's source, dedented, or `''` when `line` is out of range
|
|
90
|
+
*
|
|
91
|
+
* Deliberately duplicated, not shared, with `apps/desktop/src/renderer/features/interface-editor/source-snippet.ts`
|
|
92
|
+
* (used by the Schema tab): that one must stay dependency-free JS the sandboxed renderer can run without pulling
|
|
93
|
+
* in `@wirebench/engine`'s main entry, which drags in Node built-ins (`node:crypto`, `node:fs`, …) the renderer
|
|
94
|
+
* cannot load. Keep the two in sync using `packages/engine/test/helpers/source-snippet-cases.ts`, a fixture both
|
|
95
|
+
* test suites run against.
|
|
96
|
+
*/
|
|
97
|
+
export function sourceSnippet(text, line, maxLines = 30) {
|
|
98
|
+
const lines = text.split(/\r?\n/);
|
|
99
|
+
if (line < 1 || line > lines.length) {
|
|
100
|
+
return '';
|
|
101
|
+
}
|
|
102
|
+
// Work on the split lines rather than a character offset into `text`: the document may use
|
|
103
|
+
// CRLF, and a byte offset computed from LF-joined lines would drift by one per preceding line.
|
|
104
|
+
const rest = lines.slice(line - 1).join('\n');
|
|
105
|
+
const open = /<\s*([^\s/>!?]+)/.exec(rest);
|
|
106
|
+
if (open?.[1] === undefined) {
|
|
107
|
+
return dedent([lines[line - 1] ?? '']);
|
|
108
|
+
}
|
|
109
|
+
const tag = open[1];
|
|
110
|
+
const pattern = new RegExp(`<(/?)${escapeRegExp(tag)}(\\s[^>]*?)?(/?)>`, 'g');
|
|
111
|
+
let depth = 0;
|
|
112
|
+
let end = -1;
|
|
113
|
+
for (const match of rest.matchAll(pattern)) {
|
|
114
|
+
const closing = match[1] === '/';
|
|
115
|
+
const selfClosing = match[3] === '/';
|
|
116
|
+
if (closing) {
|
|
117
|
+
depth -= 1;
|
|
118
|
+
}
|
|
119
|
+
else if (!selfClosing) {
|
|
120
|
+
depth += 1;
|
|
121
|
+
}
|
|
122
|
+
if (depth <= 0) {
|
|
123
|
+
end = match.index + match[0].length;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const source = end === -1 ? rest : rest.slice(0, end);
|
|
128
|
+
const collected = source.split(/\r?\n/);
|
|
129
|
+
const capped = collected.slice(0, maxLines);
|
|
130
|
+
const truncated = capped.length < collected.length || end === -1;
|
|
131
|
+
return truncated ? `${dedent(capped)}\n…` : dedent(capped);
|
|
132
|
+
}
|
|
133
|
+
/** Strips the first line's leading whitespace from every line that starts with it. */
|
|
134
|
+
function dedent(lines) {
|
|
135
|
+
const indent = /^\s*/.exec(lines[0] ?? '')?.[0] ?? '';
|
|
136
|
+
if (indent === '') {
|
|
137
|
+
return lines.join('\n');
|
|
138
|
+
}
|
|
139
|
+
return lines.map((line) => (line.startsWith(indent) ? line.slice(indent.length) : line.trimStart())).join('\n');
|
|
140
|
+
}
|
|
141
|
+
function escapeRegExp(value) {
|
|
142
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
143
|
+
}
|
|
144
|
+
/** The bundle's document texts, keyed by canonical location. */
|
|
145
|
+
function textsOf(result) {
|
|
146
|
+
return new Map(result.bundle.documents.map((document) => [document.location, document.text]));
|
|
147
|
+
}
|
|
148
|
+
/** The overview block: where the definition came from, and what it is made of. */
|
|
149
|
+
function overviewBlock(result, title) {
|
|
150
|
+
const { definition, bundle, schemaSet } = result;
|
|
151
|
+
return {
|
|
152
|
+
heading: 'Overview',
|
|
153
|
+
fields: [
|
|
154
|
+
{ label: 'Title', value: title },
|
|
155
|
+
{ label: 'Definition', value: bundle.root.location },
|
|
156
|
+
{ label: 'Target namespace', value: definition.targetNamespace || EMPTY },
|
|
157
|
+
{ label: 'Documents', value: String(bundle.documents.length) },
|
|
158
|
+
{ label: 'Operations', value: String(result.operations.length) },
|
|
159
|
+
{ label: 'Schema namespaces', value: schemaSet.namespaces.length > 0 ? schemaSet.namespaces.join(', ') : EMPTY },
|
|
160
|
+
],
|
|
161
|
+
...(definition.documentation !== undefined ? { paragraphs: [definition.documentation] } : {}),
|
|
162
|
+
table: {
|
|
163
|
+
columns: ['Document', 'Kind', 'Namespace'],
|
|
164
|
+
rows: bundle.documents.map((document) => [document.location, document.kind, document.namespace ?? EMPTY]),
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function servicesBlock(definition) {
|
|
169
|
+
const rows = [];
|
|
170
|
+
for (const service of definition.services) {
|
|
171
|
+
for (const port of service.ports) {
|
|
172
|
+
const binding = findBinding(definition, port.binding);
|
|
173
|
+
rows.push([
|
|
174
|
+
service.name.localName,
|
|
175
|
+
port.name,
|
|
176
|
+
clark(port.binding),
|
|
177
|
+
binding?.soapVersion ?? EMPTY,
|
|
178
|
+
port.address ?? EMPTY,
|
|
179
|
+
]);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
heading: 'Services and ports',
|
|
184
|
+
table: { columns: ['Service', 'Port', 'Binding', 'SOAP', 'Address'], rows },
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function bindingsBlock(definition) {
|
|
188
|
+
return {
|
|
189
|
+
heading: 'Bindings',
|
|
190
|
+
table: {
|
|
191
|
+
columns: ['Binding', 'Port type', 'SOAP', 'Style', 'Transport', 'Operations'],
|
|
192
|
+
rows: definition.bindings.map((binding) => [
|
|
193
|
+
clark(binding.name),
|
|
194
|
+
clark(binding.type),
|
|
195
|
+
binding.soapVersion,
|
|
196
|
+
binding.style,
|
|
197
|
+
binding.transport ?? EMPTY,
|
|
198
|
+
binding.operations.map((operation) => operation.name).join(', ') || EMPTY,
|
|
199
|
+
]),
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/** One operation's own sub-block: transport metadata, documentation and its messages. */
|
|
204
|
+
function operationBlock(definition, binding, bindingOperation) {
|
|
205
|
+
const portType = findPortType(definition, binding.type);
|
|
206
|
+
const abstract = portType?.operations.find((candidate) => candidate.name === bindingOperation.name);
|
|
207
|
+
const rows = [
|
|
208
|
+
['Input', messageParts(definition, abstract?.input?.message)],
|
|
209
|
+
['Output', messageParts(definition, abstract?.output?.message)],
|
|
210
|
+
];
|
|
211
|
+
for (const fault of abstract?.faults ?? []) {
|
|
212
|
+
rows.push([`Fault "${fault.name}"`, messageParts(definition, fault.message)]);
|
|
213
|
+
}
|
|
214
|
+
const headers = [...(bindingOperation.input?.headers ?? []), ...(bindingOperation.output?.headers ?? [])];
|
|
215
|
+
for (const header of headers) {
|
|
216
|
+
rows.push(['SOAP header', `${qnameToString(header.message)} part ${header.part} (${header.use})`]);
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
heading: `${binding.name.localName}.${bindingOperation.name}`,
|
|
220
|
+
fields: [
|
|
221
|
+
{ label: 'SOAPAction', value: bindingOperation.soapAction ?? EMPTY },
|
|
222
|
+
{ label: 'Style', value: bindingOperation.style ?? binding.style },
|
|
223
|
+
{ label: 'Use', value: bindingOperation.input?.body.use ?? EMPTY },
|
|
224
|
+
{ label: 'SOAP version', value: binding.soapVersion },
|
|
225
|
+
],
|
|
226
|
+
...(abstract?.documentation !== undefined ? { paragraphs: [abstract.documentation] } : {}),
|
|
227
|
+
table: { columns: ['Message', 'Details'], rows },
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function operationsBlock(definition) {
|
|
231
|
+
const children = [];
|
|
232
|
+
for (const binding of definition.bindings) {
|
|
233
|
+
for (const operation of binding.operations) {
|
|
234
|
+
children.push(operationBlock(definition, binding, operation));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return { heading: 'Operations', children };
|
|
238
|
+
}
|
|
239
|
+
function messagesBlock(definition) {
|
|
240
|
+
const rows = [];
|
|
241
|
+
for (const message of definition.messages) {
|
|
242
|
+
if (message.parts.length === 0) {
|
|
243
|
+
rows.push([clark(message.name), EMPTY, EMPTY]);
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
for (const part of message.parts) {
|
|
247
|
+
rows.push([clark(message.name), part.name, partTarget(part)]);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return { heading: 'Messages', table: { columns: ['Message', 'Part', 'Binds to'], rows } };
|
|
251
|
+
}
|
|
252
|
+
/** One schema component's sub-block: its kind, its type reference and the XML that declares it. */
|
|
253
|
+
function componentBlock(kind, name, typeName, source, texts) {
|
|
254
|
+
const text = texts.get(source.location);
|
|
255
|
+
const snippet = text !== undefined && source.line !== undefined ? sourceSnippet(text, source.line) : '';
|
|
256
|
+
return {
|
|
257
|
+
heading: `${kind} ${name}`,
|
|
258
|
+
fields: [
|
|
259
|
+
{ label: 'Type', value: clark(typeName) },
|
|
260
|
+
{
|
|
261
|
+
label: 'Declared in',
|
|
262
|
+
value: `${source.location}${source.line !== undefined ? `:${String(source.line)}` : ''}`,
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
...(snippet !== '' ? { code: snippet } : {}),
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function schemaBlock(schemaSet, texts) {
|
|
269
|
+
const children = [];
|
|
270
|
+
for (const uri of [...schemaSet.namespaces].sort((a, b) => a.localeCompare(b))) {
|
|
271
|
+
const components = [];
|
|
272
|
+
for (const element of [...schemaSet.elementsInNamespace(uri)].sort((a, b) => a.name.localName.localeCompare(b.name.localName))) {
|
|
273
|
+
components.push(componentBlock('element', element.name.localName, element.type, element.source, texts));
|
|
274
|
+
}
|
|
275
|
+
for (const type of [...schemaSet.typesInNamespace(uri)].sort((a, b) => (a.name?.localName ?? '').localeCompare(b.name?.localName ?? ''))) {
|
|
276
|
+
if (type.name === undefined) {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
components.push(componentBlock(type.kind, type.name.localName, undefined, type.source, texts));
|
|
280
|
+
}
|
|
281
|
+
children.push({ heading: `Namespace ${uri === '' ? '(no namespace)' : uri}`, children: components });
|
|
282
|
+
}
|
|
283
|
+
return { heading: 'Schema components', children };
|
|
284
|
+
}
|
|
285
|
+
/** The document's title: the caller's, then the first service's name, then the root file name. */
|
|
286
|
+
function titleOf(result, options) {
|
|
287
|
+
if (options.title !== undefined && options.title.trim() !== '') {
|
|
288
|
+
return options.title.trim();
|
|
289
|
+
}
|
|
290
|
+
const service = result.definition.services[0];
|
|
291
|
+
if (service !== undefined) {
|
|
292
|
+
return service.name.localName;
|
|
293
|
+
}
|
|
294
|
+
return result.bundle.root.location.split('/').pop() ?? 'Definition';
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Assigns every block (recursively, document order) a deduplicated anchor into `anchors`,
|
|
298
|
+
* sharing one `taken` set across the whole tree. Called once, up front, so the table of
|
|
299
|
+
* contents and the body headings are guaranteed to agree — see {@link renderHtml}.
|
|
300
|
+
*/
|
|
301
|
+
function collectAnchors(blocks, taken, anchors) {
|
|
302
|
+
for (const block of blocks) {
|
|
303
|
+
anchors.set(block, anchorOf(block.heading, taken));
|
|
304
|
+
if (block.children !== undefined) {
|
|
305
|
+
collectAnchors(block.children, taken, anchors);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function renderHtmlBlock(block, level, anchors) {
|
|
310
|
+
const tag = `h${String(Math.min(level, 6))}`;
|
|
311
|
+
const anchor = anchors.get(block) ?? '';
|
|
312
|
+
const parts = [`<${tag} id="${escapeHtml(anchor)}">${escapeHtml(block.heading)}</${tag}>`];
|
|
313
|
+
if (block.fields !== undefined && block.fields.length > 0) {
|
|
314
|
+
parts.push(`<dl>${block.fields
|
|
315
|
+
.map((field) => `<dt>${escapeHtml(field.label)}</dt><dd>${escapeHtml(field.value)}</dd>`)
|
|
316
|
+
.join('')}</dl>`);
|
|
317
|
+
}
|
|
318
|
+
for (const paragraph of block.paragraphs ?? []) {
|
|
319
|
+
parts.push(`<p>${escapeHtml(paragraph)}</p>`);
|
|
320
|
+
}
|
|
321
|
+
if (block.table !== undefined && block.table.rows.length > 0) {
|
|
322
|
+
const head = block.table.columns.map((column) => `<th>${escapeHtml(column)}</th>`).join('');
|
|
323
|
+
const body = block.table.rows
|
|
324
|
+
.map((row) => `<tr>${row.map((cell) => `<td>${escapeHtml(cell)}</td>`).join('')}</tr>`)
|
|
325
|
+
.join('');
|
|
326
|
+
parts.push(`<table><thead><tr>${head}</tr></thead><tbody>${body}</tbody></table>`);
|
|
327
|
+
}
|
|
328
|
+
if (block.code !== undefined) {
|
|
329
|
+
parts.push(`<pre><code>${escapeHtml(block.code)}</code></pre>`);
|
|
330
|
+
}
|
|
331
|
+
for (const child of block.children ?? []) {
|
|
332
|
+
parts.push(renderHtmlBlock(child, level + 1, anchors));
|
|
333
|
+
}
|
|
334
|
+
return parts.join('\n');
|
|
335
|
+
}
|
|
336
|
+
/** Inline stylesheet of the HTML document; no external resources, no scripts. */
|
|
337
|
+
const HTML_STYLE = `
|
|
338
|
+
:root { color-scheme: light dark; }
|
|
339
|
+
body { font: 15px/1.55 -apple-system, "Segoe UI", system-ui, sans-serif; margin: 0 auto; max-width: 60rem; padding: 2rem 1.5rem; }
|
|
340
|
+
h1 { font-size: 1.9rem; margin-bottom: 0.25rem; }
|
|
341
|
+
h2 { border-bottom: 1px solid currentColor; margin-top: 2.5rem; padding-bottom: 0.2rem; }
|
|
342
|
+
h3, h4 { margin-top: 1.75rem; }
|
|
343
|
+
dl { display: grid; gap: 0.15rem 1rem; grid-template-columns: max-content 1fr; margin: 0.5rem 0; }
|
|
344
|
+
dt { font-weight: 600; }
|
|
345
|
+
dd { margin: 0; overflow-wrap: anywhere; }
|
|
346
|
+
table { border-collapse: collapse; display: block; margin: 0.75rem 0; overflow-x: auto; width: 100%; }
|
|
347
|
+
th, td { border: 1px solid rgba(128,128,128,0.45); padding: 0.3rem 0.55rem; text-align: left; vertical-align: top; }
|
|
348
|
+
th { background: rgba(128,128,128,0.14); }
|
|
349
|
+
pre { background: rgba(128,128,128,0.12); border-radius: 4px; overflow-x: auto; padding: 0.6rem 0.8rem; }
|
|
350
|
+
code { font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
351
|
+
nav ol { padding-left: 1.2rem; }
|
|
352
|
+
footer { color: rgba(128,128,128,1); font-size: 0.85rem; margin-top: 3rem; }
|
|
353
|
+
`.trim();
|
|
354
|
+
function renderHtml(title, blocks) {
|
|
355
|
+
// One shared pre-pass over the whole tree: the TOC and the body headings then look up the
|
|
356
|
+
// very same anchors instead of each computing (and potentially deduplicating) their own.
|
|
357
|
+
const anchors = new Map();
|
|
358
|
+
collectAnchors(blocks, new Set(), anchors);
|
|
359
|
+
const toc = blocks.map((block) => ({ heading: block.heading, anchor: anchors.get(block) ?? '' }));
|
|
360
|
+
const body = blocks.map((block) => renderHtmlBlock(block, 2, anchors)).join('\n');
|
|
361
|
+
return [
|
|
362
|
+
'<!DOCTYPE html>',
|
|
363
|
+
'<html lang="en">',
|
|
364
|
+
'<head>',
|
|
365
|
+
'<meta charset="utf-8">',
|
|
366
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1">',
|
|
367
|
+
`<title>${escapeHtml(title)}</title>`,
|
|
368
|
+
`<style>\n${HTML_STYLE}\n</style>`,
|
|
369
|
+
'</head>',
|
|
370
|
+
'<body>',
|
|
371
|
+
`<h1>${escapeHtml(title)}</h1>`,
|
|
372
|
+
`<nav><ol>${toc
|
|
373
|
+
.map((entry) => `<li><a href="#${escapeHtml(entry.anchor)}">${escapeHtml(entry.heading)}</a></li>`)
|
|
374
|
+
.join('')}</ol></nav>`,
|
|
375
|
+
body,
|
|
376
|
+
'<footer>Generated by Wirebench.</footer>',
|
|
377
|
+
'</body>',
|
|
378
|
+
'</html>',
|
|
379
|
+
'',
|
|
380
|
+
].join('\n');
|
|
381
|
+
}
|
|
382
|
+
function renderMarkdownBlock(block, level) {
|
|
383
|
+
const parts = [`${'#'.repeat(Math.min(level, 6))} ${block.heading}`];
|
|
384
|
+
if (block.fields !== undefined && block.fields.length > 0) {
|
|
385
|
+
parts.push(block.fields.map((field) => `- **${field.label}:** ${escapeMarkdownCell(field.value)}`).join('\n'));
|
|
386
|
+
}
|
|
387
|
+
for (const paragraph of block.paragraphs ?? []) {
|
|
388
|
+
parts.push(escapeMarkdownText(paragraph));
|
|
389
|
+
}
|
|
390
|
+
if (block.table !== undefined && block.table.rows.length > 0) {
|
|
391
|
+
const head = `| ${block.table.columns.join(' | ')} |`;
|
|
392
|
+
const rule = `| ${block.table.columns.map(() => '---').join(' | ')} |`;
|
|
393
|
+
const rows = block.table.rows.map((row) => `| ${row.map(escapeMarkdownCell).join(' | ')} |`);
|
|
394
|
+
parts.push([head, rule, ...rows].join('\n'));
|
|
395
|
+
}
|
|
396
|
+
if (block.code !== undefined) {
|
|
397
|
+
parts.push(['```xml', block.code, '```'].join('\n'));
|
|
398
|
+
}
|
|
399
|
+
for (const child of block.children ?? []) {
|
|
400
|
+
parts.push(renderMarkdownBlock(child, level + 1));
|
|
401
|
+
}
|
|
402
|
+
return parts.join('\n\n');
|
|
403
|
+
}
|
|
404
|
+
function renderMarkdown(title, blocks) {
|
|
405
|
+
const taken = new Set();
|
|
406
|
+
const toc = blocks.map((block) => `- [${block.heading}](#${anchorOf(block.heading, taken)})`);
|
|
407
|
+
return [
|
|
408
|
+
`# ${escapeMarkdownText(title)}`,
|
|
409
|
+
'## Contents',
|
|
410
|
+
toc.join('\n'),
|
|
411
|
+
...blocks.map((block) => renderMarkdownBlock(block, 2)),
|
|
412
|
+
'---',
|
|
413
|
+
'Generated by Wirebench.',
|
|
414
|
+
'',
|
|
415
|
+
].join('\n\n');
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Renders `result` as a complete, self-contained document — a single HTML page
|
|
419
|
+
* or a single Markdown file — covering the definition's services and ports,
|
|
420
|
+
* bindings, operations (with their messages and SOAP headers), messages and
|
|
421
|
+
* global schema components with the XML that declares them.
|
|
422
|
+
*
|
|
423
|
+
* @param result the imported definition to document
|
|
424
|
+
* @param options output format and an optional title
|
|
425
|
+
* @returns the whole document as a string; the caller decides where it lands
|
|
426
|
+
*/
|
|
427
|
+
export function generateDocs(result, options) {
|
|
428
|
+
const title = titleOf(result, options);
|
|
429
|
+
const texts = textsOf(result);
|
|
430
|
+
const blocks = [
|
|
431
|
+
overviewBlock(result, title),
|
|
432
|
+
servicesBlock(result.definition),
|
|
433
|
+
bindingsBlock(result.definition),
|
|
434
|
+
operationsBlock(result.definition),
|
|
435
|
+
messagesBlock(result.definition),
|
|
436
|
+
schemaBlock(result.schemaSet, texts),
|
|
437
|
+
];
|
|
438
|
+
return options.format === 'html' ? renderHtml(title, blocks) : renderMarkdown(title, blocks);
|
|
439
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Document, Element } from '@xmldom/xmldom';
|
|
2
|
+
/** Returns the direct child elements of `parent` matching `namespaceUri`/`localName`. */
|
|
3
|
+
export declare function childElements(parent: Element | Document, namespaceUri: string, localName: string): Element[];
|
|
4
|
+
/** Returns the first direct child element of `parent` matching `namespaceUri`/`localName`, if any. */
|
|
5
|
+
export declare function firstChildElement(parent: Element | Document, namespaceUri: string, localName: string): Element | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Reads a `wsdl:documentation` child of `element` (any namespace's `documentation`
|
|
8
|
+
* local-name is not sufficient; callers pass the WSDL namespace), trims its text,
|
|
9
|
+
* and returns `undefined` for a missing or empty element.
|
|
10
|
+
*/
|
|
11
|
+
export declare function readDocumentation(element: Element, wsdlNamespaceUri: string): string | undefined;
|
|
12
|
+
/** Reads a required attribute, throwing `WsdlParseError('wsdl-invalid')` with position details if absent. */
|
|
13
|
+
export declare function requireAttribute(element: Element, name: string, location: string): string;
|
|
14
|
+
/** Reads an optional attribute, returning `undefined` when absent (rather than xmldom's `null`). */
|
|
15
|
+
export declare function optionalAttribute(element: Element, name: string): string | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { WsdlParseError } from '../errors.js';
|
|
2
|
+
import { getPosition } from '../xml/parse.js';
|
|
3
|
+
/** Returns the direct child elements of `parent` matching `namespaceUri`/`localName`. */
|
|
4
|
+
export function childElements(parent, namespaceUri, localName) {
|
|
5
|
+
const result = [];
|
|
6
|
+
let child = parent.firstChild;
|
|
7
|
+
while (child !== null) {
|
|
8
|
+
if (child.nodeType === 1) {
|
|
9
|
+
const el = child;
|
|
10
|
+
if (el.namespaceURI === namespaceUri && el.localName === localName) {
|
|
11
|
+
result.push(el);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
child = child.nextSibling;
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
/** Returns the first direct child element of `parent` matching `namespaceUri`/`localName`, if any. */
|
|
19
|
+
export function firstChildElement(parent, namespaceUri, localName) {
|
|
20
|
+
return childElements(parent, namespaceUri, localName)[0];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Reads a `wsdl:documentation` child of `element` (any namespace's `documentation`
|
|
24
|
+
* local-name is not sufficient; callers pass the WSDL namespace), trims its text,
|
|
25
|
+
* and returns `undefined` for a missing or empty element.
|
|
26
|
+
*/
|
|
27
|
+
export function readDocumentation(element, wsdlNamespaceUri) {
|
|
28
|
+
const docEl = firstChildElement(element, wsdlNamespaceUri, 'documentation');
|
|
29
|
+
if (docEl === undefined) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const text = (docEl.textContent ?? '').trim();
|
|
33
|
+
return text.length > 0 ? text : undefined;
|
|
34
|
+
}
|
|
35
|
+
/** Reads a required attribute, throwing `WsdlParseError('wsdl-invalid')` with position details if absent. */
|
|
36
|
+
export function requireAttribute(element, name, location) {
|
|
37
|
+
const value = element.getAttribute(name);
|
|
38
|
+
if (value === null || value === '') {
|
|
39
|
+
const pos = getPosition(element);
|
|
40
|
+
throw new WsdlParseError('wsdl-invalid', `Element <${element.tagName}> is missing required attribute "${name}"`, {
|
|
41
|
+
details: { location, element: element.tagName, attribute: name, ...pos },
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
/** Reads an optional attribute, returning `undefined` when absent (rather than xmldom's `null`). */
|
|
47
|
+
export function optionalAttribute(element, name) {
|
|
48
|
+
const value = element.getAttribute(name);
|
|
49
|
+
return value === null || value === '' ? undefined : value;
|
|
50
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes an entire resolved definition (the root WSDL and every document it
|
|
3
|
+
* imports/includes) to a plain folder — "Export Definition": the
|
|
4
|
+
* folder is self-contained and portable, with every cross-document reference
|
|
5
|
+
* rewritten to a relative file name so the exported set opens standalone.
|
|
6
|
+
*
|
|
7
|
+
* Unlike `wsdl/cache.ts`, documents ARE re-serialised here (the rewritten
|
|
8
|
+
* reference has to land somewhere), and no manifest is written.
|
|
9
|
+
*/
|
|
10
|
+
import type { FsLike } from '../project/fs.js';
|
|
11
|
+
import type { DefinitionBundle } from './resolver.js';
|
|
12
|
+
/** Options accepted by {@link exportDefinition}. */
|
|
13
|
+
export interface ExportDefinitionOptions {
|
|
14
|
+
/** Overrides the file system, e.g. for tests. Defaults to `nodeFs`. */
|
|
15
|
+
readonly fs?: FsLike;
|
|
16
|
+
}
|
|
17
|
+
/** One document written by {@link exportDefinition}. */
|
|
18
|
+
export interface ExportedFile {
|
|
19
|
+
/** File name written inside the target directory. */
|
|
20
|
+
readonly file: string;
|
|
21
|
+
/** The document's canonical location in the original bundle. */
|
|
22
|
+
readonly location: string;
|
|
23
|
+
}
|
|
24
|
+
/** The result of {@link exportDefinition}. */
|
|
25
|
+
export interface ExportResult {
|
|
26
|
+
readonly files: readonly ExportedFile[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Writes every document of `bundle` to `targetDir` (created if needed), with
|
|
30
|
+
* every `wsdl:import/@location`, `xs:import/@schemaLocation`,
|
|
31
|
+
* `xs:include/@schemaLocation` and `xs:redefine/@schemaLocation` rewritten to
|
|
32
|
+
* the relative file name of the referenced document, so the folder is
|
|
33
|
+
* self-contained and can be re-imported standalone.
|
|
34
|
+
*
|
|
35
|
+
* @param bundle the resolved definition to export
|
|
36
|
+
* @param targetDir absolute path of the destination folder
|
|
37
|
+
*/
|
|
38
|
+
export declare function exportDefinition(bundle: DefinitionBundle, targetDir: string, options?: ExportDefinitionOptions): Promise<ExportResult>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes an entire resolved definition (the root WSDL and every document it
|
|
3
|
+
* imports/includes) to a plain folder — "Export Definition": the
|
|
4
|
+
* folder is self-contained and portable, with every cross-document reference
|
|
5
|
+
* rewritten to a relative file name so the exported set opens standalone.
|
|
6
|
+
*
|
|
7
|
+
* Unlike `wsdl/cache.ts`, documents ARE re-serialised here (the rewritten
|
|
8
|
+
* reference has to land somewhere), and no manifest is written.
|
|
9
|
+
*/
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { nodeFs } from '../project/fs.js';
|
|
12
|
+
import { writeFileAtomic } from '../project/fs.js';
|
|
13
|
+
import { NS } from '../xml/namespaces.js';
|
|
14
|
+
import { parseXml } from '../xml/parse.js';
|
|
15
|
+
import { serializeXml } from '../xml/serialize.js';
|
|
16
|
+
import { assignFileNames } from './cache-naming.js';
|
|
17
|
+
import { childElements, firstChildElement, optionalAttribute } from './dom-utils.js';
|
|
18
|
+
/** Resolves `ref` (an import/include/redefine location) against `base` using the WHATWG `URL` class. */
|
|
19
|
+
function resolveUrl(ref, base) {
|
|
20
|
+
return new URL(ref, base).toString();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Rewrites one `location`/`schemaLocation` attribute on `element` to the
|
|
24
|
+
* exported file name of the document it points to, when that document is
|
|
25
|
+
* part of the bundle. References to a document the bundle never resolved
|
|
26
|
+
* (a namespace-only import, or one that failed to fetch) are left as-is.
|
|
27
|
+
*/
|
|
28
|
+
function rewriteReference(element, attrName, ownerLocation, fileByLocation) {
|
|
29
|
+
const ref = optionalAttribute(element, attrName);
|
|
30
|
+
if (ref === undefined) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const absolute = resolveUrl(ref, ownerLocation);
|
|
34
|
+
const file = fileByLocation.get(absolute);
|
|
35
|
+
if (file !== undefined) {
|
|
36
|
+
element.setAttribute(attrName, file);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Rewrites the `xs:import`/`xs:include`/`xs:redefine` children of one `xs:schema` element. */
|
|
40
|
+
function rewriteSchemaReferences(schemaEl, ownerLocation, fileByLocation) {
|
|
41
|
+
for (const el of childElements(schemaEl, NS.XSD, 'import')) {
|
|
42
|
+
rewriteReference(el, 'schemaLocation', ownerLocation, fileByLocation);
|
|
43
|
+
}
|
|
44
|
+
for (const el of childElements(schemaEl, NS.XSD, 'include')) {
|
|
45
|
+
rewriteReference(el, 'schemaLocation', ownerLocation, fileByLocation);
|
|
46
|
+
}
|
|
47
|
+
for (const el of childElements(schemaEl, NS.XSD, 'redefine')) {
|
|
48
|
+
rewriteReference(el, 'schemaLocation', ownerLocation, fileByLocation);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Rewrites every cross-document reference inside `root` (the document
|
|
53
|
+
* element of a freshly re-parsed copy of `doc` — never the DOM node owned by
|
|
54
|
+
* the original bundle, which callers may still hold onto), in place.
|
|
55
|
+
*/
|
|
56
|
+
function rewriteDocumentReferences(root, doc, fileByLocation) {
|
|
57
|
+
if (doc.kind === 'wsdl') {
|
|
58
|
+
for (const el of childElements(root, NS.WSDL, 'import')) {
|
|
59
|
+
rewriteReference(el, 'location', doc.location, fileByLocation);
|
|
60
|
+
}
|
|
61
|
+
const typesEl = firstChildElement(root, NS.WSDL, 'types');
|
|
62
|
+
if (typesEl !== undefined) {
|
|
63
|
+
for (const schemaEl of childElements(typesEl, NS.XSD, 'schema')) {
|
|
64
|
+
rewriteSchemaReferences(schemaEl, doc.location, fileByLocation);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
rewriteSchemaReferences(root, doc.location, fileByLocation);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Writes every document of `bundle` to `targetDir` (created if needed), with
|
|
74
|
+
* every `wsdl:import/@location`, `xs:import/@schemaLocation`,
|
|
75
|
+
* `xs:include/@schemaLocation` and `xs:redefine/@schemaLocation` rewritten to
|
|
76
|
+
* the relative file name of the referenced document, so the folder is
|
|
77
|
+
* self-contained and can be re-imported standalone.
|
|
78
|
+
*
|
|
79
|
+
* @param bundle the resolved definition to export
|
|
80
|
+
* @param targetDir absolute path of the destination folder
|
|
81
|
+
*/
|
|
82
|
+
export async function exportDefinition(bundle, targetDir, options) {
|
|
83
|
+
const fs = options?.fs ?? nodeFs;
|
|
84
|
+
const named = assignFileNames(bundle.documents);
|
|
85
|
+
const fileByLocation = new Map(named.map(({ document, file }) => [document.location, file]));
|
|
86
|
+
const files = [];
|
|
87
|
+
for (const { document, file } of named) {
|
|
88
|
+
// Re-parse rather than mutate `document.document` in place: that DOM node is owned by
|
|
89
|
+
// the caller's bundle, which may still be in use (e.g. for the schema set) after export.
|
|
90
|
+
const working = parseXml(document.text, { location: document.location });
|
|
91
|
+
const root = working.documentElement;
|
|
92
|
+
if (root !== null) {
|
|
93
|
+
rewriteDocumentReferences(root, document, fileByLocation);
|
|
94
|
+
}
|
|
95
|
+
const xml = serializeXml(working);
|
|
96
|
+
await writeFileAtomic(fs, join(targetDir, file), xml);
|
|
97
|
+
files.push({ file, location: document.location });
|
|
98
|
+
}
|
|
99
|
+
return { files };
|
|
100
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FetchDocument } from './resolver.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates the default {@link FetchDocument} implementation: `file:` URLs are
|
|
4
|
+
* read from disk via `node:fs/promises`, and `http(s):` URLs are fetched via
|
|
5
|
+
* the global `fetch` (following redirects, with a 20s timeout combined with
|
|
6
|
+
* the caller's `AbortSignal`, and a `wirebench/0.1` User-Agent).
|
|
7
|
+
*
|
|
8
|
+
* Text is decoded as UTF-8 by default, honouring an `iso-8859-1` `encoding`
|
|
9
|
+
* in the document's XML declaration when present (see {@link decodeXmlBytes}
|
|
10
|
+
* for why `utf-16` isn't sniffed the same way). Other declared encodings
|
|
11
|
+
* fall back to UTF-8.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createDefaultFetchDocument(): FetchDocument;
|