@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,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One gRPC call end to end: the request message text is encoded against the method's request type,
|
|
3
|
+
* sent, and every response message decoded against its response type. This is the function the
|
|
4
|
+
* desktop app calls; `send.ts` beneath it is bytes only, and `codec.ts` beside it is schema only.
|
|
5
|
+
*/
|
|
6
|
+
import type { GrpcMethodKind } from './model.js';
|
|
7
|
+
import type { ProtoSet } from './proto/load.js';
|
|
8
|
+
import type { GrpcExchange, GrpcSendInput } from './send.js';
|
|
9
|
+
/** Everything {@link callGrpc} needs: the schema, the method, the message text, and the transport input. */
|
|
10
|
+
export interface GrpcCallInput extends Omit<GrpcSendInput, 'messages' | 'onMessage' | 'onOpen'> {
|
|
11
|
+
readonly set: ProtoSet;
|
|
12
|
+
/** The request message(s) as JSON text: one object, or an array for a client stream. */
|
|
13
|
+
readonly messageText: string;
|
|
14
|
+
/**
|
|
15
|
+
* Called for each response message as it arrives, already decoded — the transport's
|
|
16
|
+
* {@link GrpcSendInput.onMessage} with the schema applied, so a caller showing a live stream
|
|
17
|
+
* never sees raw bytes. The same messages still come back in the result.
|
|
18
|
+
*/
|
|
19
|
+
readonly onMessage?: (message: GrpcResponseMessage, index: number) => void;
|
|
20
|
+
/** Opts into an interactive call: the request side stays open and the handle drives it. */
|
|
21
|
+
readonly onOpen?: (handle: GrpcCallStreamHandle) => void;
|
|
22
|
+
}
|
|
23
|
+
/** The client's side of an interactive call, in message text rather than bytes. */
|
|
24
|
+
export interface GrpcCallStreamHandle {
|
|
25
|
+
/**
|
|
26
|
+
* Encodes one more request message from its JSON text and writes it, returning the message as it
|
|
27
|
+
* went — the canonical JSON, which is what the caller shows as sent.
|
|
28
|
+
*
|
|
29
|
+
* @throws ProtoError when the text does not parse or encode against the request type; GrpcError
|
|
30
|
+
* `grpc-stream-closed` once the request side is closed
|
|
31
|
+
*/
|
|
32
|
+
readonly send: (messageText: string) => unknown;
|
|
33
|
+
/** Half-closes the request side. Idempotent. */
|
|
34
|
+
readonly end: () => void;
|
|
35
|
+
readonly isOpen: () => boolean;
|
|
36
|
+
}
|
|
37
|
+
/** One response message, decoded when it could be. */
|
|
38
|
+
export interface GrpcResponseMessage {
|
|
39
|
+
/** The message as canonical JSON, or `undefined` when it did not decode. */
|
|
40
|
+
readonly json?: unknown;
|
|
41
|
+
/** The message bytes as base64, kept so a message that did not decode is still visible. */
|
|
42
|
+
readonly base64: string;
|
|
43
|
+
readonly bytes: number;
|
|
44
|
+
readonly problem?: string;
|
|
45
|
+
}
|
|
46
|
+
/** The outcome of {@link callGrpc}. */
|
|
47
|
+
export interface GrpcCallResult {
|
|
48
|
+
readonly exchange: GrpcExchange;
|
|
49
|
+
readonly methodKind: GrpcMethodKind;
|
|
50
|
+
readonly requestType: string;
|
|
51
|
+
readonly responseType: string;
|
|
52
|
+
/** The request messages as they were sent, in canonical JSON. */
|
|
53
|
+
readonly requestMessages: readonly unknown[];
|
|
54
|
+
readonly responseMessages: readonly GrpcResponseMessage[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Encodes, sends and decodes one call.
|
|
58
|
+
*
|
|
59
|
+
* @throws ProtoError for a method or type the schema does not define, or a message that does not
|
|
60
|
+
* encode; whatever {@link sendGrpc} throws for a failure to get an answer
|
|
61
|
+
*/
|
|
62
|
+
export declare function callGrpc(input: GrpcCallInput): Promise<GrpcCallResult>;
|
|
63
|
+
/** Decodes one response message, reporting rather than throwing when it does not decode. */
|
|
64
|
+
export declare function decodeResponseMessage(set: ProtoSet, responseType: string, bytes: Uint8Array): GrpcResponseMessage;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One gRPC call end to end: the request message text is encoded against the method's request type,
|
|
3
|
+
* sent, and every response message decoded against its response type. This is the function the
|
|
4
|
+
* desktop app calls; `send.ts` beneath it is bytes only, and `codec.ts` beside it is schema only.
|
|
5
|
+
*/
|
|
6
|
+
import { decodeMessage, encodeMessage, parseMessageText } from './codec.js';
|
|
7
|
+
import { clientStreams } from './model.js';
|
|
8
|
+
import { describeMethod } from './proto/describe.js';
|
|
9
|
+
import { sendGrpc } from './send.js';
|
|
10
|
+
/**
|
|
11
|
+
* Encodes, sends and decodes one call.
|
|
12
|
+
*
|
|
13
|
+
* @throws ProtoError for a method or type the schema does not define, or a message that does not
|
|
14
|
+
* encode; whatever {@link sendGrpc} throws for a failure to get an answer
|
|
15
|
+
*/
|
|
16
|
+
export async function callGrpc(input) {
|
|
17
|
+
const method = describeMethod(input.set, input.service, input.method);
|
|
18
|
+
const parsed = parseMessageText(input.messageText, clientStreams(method.kind));
|
|
19
|
+
const messages = parsed.map((message) => encodeMessage(input.set, method.requestType, message));
|
|
20
|
+
const { set, messageText, onMessage, onOpen, ...send } = input;
|
|
21
|
+
void messageText;
|
|
22
|
+
// Every request message in canonical JSON: the ones the text held, then whatever an interactive
|
|
23
|
+
// call pushed afterwards, so the result records the whole conversation rather than its opening.
|
|
24
|
+
const requestMessages = messages.map((bytes) => decodeMessage(set, method.requestType, bytes));
|
|
25
|
+
const exchange = await sendGrpc({
|
|
26
|
+
...send,
|
|
27
|
+
messages,
|
|
28
|
+
...(onMessage !== undefined
|
|
29
|
+
? {
|
|
30
|
+
onMessage: (bytes, index) => {
|
|
31
|
+
onMessage(decodeResponseMessage(set, method.responseType, bytes), index);
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
: {}),
|
|
35
|
+
...(onOpen !== undefined
|
|
36
|
+
? {
|
|
37
|
+
onOpen: (handle) => {
|
|
38
|
+
onOpen({
|
|
39
|
+
send: (text) => {
|
|
40
|
+
const [message] = parseMessageText(text, false);
|
|
41
|
+
const bytes = encodeMessage(set, method.requestType, message);
|
|
42
|
+
handle.write(bytes);
|
|
43
|
+
const json = decodeMessage(set, method.requestType, bytes);
|
|
44
|
+
requestMessages.push(json);
|
|
45
|
+
return json;
|
|
46
|
+
},
|
|
47
|
+
end: handle.end,
|
|
48
|
+
isOpen: handle.isOpen,
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
: {}),
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
exchange,
|
|
56
|
+
methodKind: method.kind,
|
|
57
|
+
requestType: method.requestType,
|
|
58
|
+
responseType: method.responseType,
|
|
59
|
+
requestMessages,
|
|
60
|
+
responseMessages: exchange.messages.map((bytes) => decodeResponseMessage(set, method.responseType, bytes)),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Decodes one response message, reporting rather than throwing when it does not decode. */
|
|
64
|
+
export function decodeResponseMessage(set, responseType, bytes) {
|
|
65
|
+
const base64 = Buffer.from(bytes).toString('base64');
|
|
66
|
+
try {
|
|
67
|
+
return { json: decodeMessage(set, responseType, bytes), base64, bytes: bytes.byteLength };
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
return { base64, bytes: bytes.byteLength, problem: error instanceof Error ? error.message : String(error) };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON ⇄ protobuf bytes for one message type. The user edits a message as JSON in the canonical
|
|
3
|
+
* mapping the protobuf specification defines; the wire wants the binary encoding. This module is
|
|
4
|
+
* where the two meet, and it is deliberately strict on the way in — an unknown field, a value of the
|
|
5
|
+
* wrong shape or a malformed well-known type is an error naming the field, never a silently dropped
|
|
6
|
+
* key — and lenient on the way out, because whatever the server sent is what the user needs to see.
|
|
7
|
+
*/
|
|
8
|
+
import type { ProtoSet } from './proto/load.js';
|
|
9
|
+
/**
|
|
10
|
+
* Encodes `json` as the binary form of the message type `typeName`.
|
|
11
|
+
*
|
|
12
|
+
* @throws ProtoError `grpc-message-invalid` naming the offending field, `proto-type-unknown`
|
|
13
|
+
*/
|
|
14
|
+
export declare function encodeMessage(set: ProtoSet, typeName: string, json: unknown): Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Decodes `bytes` as the message type `typeName` into canonical JSON: 64-bit integers as strings,
|
|
17
|
+
* enums by name, bytes as base64, well-known types in their string or bare forms, and fields at
|
|
18
|
+
* their default value omitted.
|
|
19
|
+
*
|
|
20
|
+
* @throws ProtoError `grpc-message-malformed` when the bytes do not decode, `proto-type-unknown`
|
|
21
|
+
*/
|
|
22
|
+
export declare function decodeMessage(set: ProtoSet, typeName: string, bytes: Uint8Array): unknown;
|
|
23
|
+
/**
|
|
24
|
+
* Parses the JSON text of a request body into the messages to send: one object, or — for a
|
|
25
|
+
* client-streaming method — an array of objects.
|
|
26
|
+
*
|
|
27
|
+
* @throws ProtoError `grpc-message-invalid` when the text is not JSON or has the wrong shape
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseMessageText(text: string, streaming: boolean): unknown[];
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON ⇄ protobuf bytes for one message type. The user edits a message as JSON in the canonical
|
|
3
|
+
* mapping the protobuf specification defines; the wire wants the binary encoding. This module is
|
|
4
|
+
* where the two meet, and it is deliberately strict on the way in — an unknown field, a value of the
|
|
5
|
+
* wrong shape or a malformed well-known type is an error naming the field, never a silently dropped
|
|
6
|
+
* key — and lenient on the way out, because whatever the server sent is what the user needs to see.
|
|
7
|
+
*/
|
|
8
|
+
import protobuf from 'protobufjs';
|
|
9
|
+
import { ProtoError } from '../errors.js';
|
|
10
|
+
import { lookupMessageType, qualifiedName } from './proto/describe.js';
|
|
11
|
+
import { durationFromJson, durationToJson, fieldMaskFromJson, fieldMaskToJson, isWrapperType, timestampFromJson, timestampToJson, } from './proto/well-known.js';
|
|
12
|
+
const TO_OBJECT_OPTIONS = {
|
|
13
|
+
longs: String,
|
|
14
|
+
enums: String,
|
|
15
|
+
bytes: String,
|
|
16
|
+
defaults: false,
|
|
17
|
+
arrays: false,
|
|
18
|
+
objects: false,
|
|
19
|
+
oneofs: false,
|
|
20
|
+
};
|
|
21
|
+
function isRecord(value) {
|
|
22
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
23
|
+
}
|
|
24
|
+
function invalid(path, reason) {
|
|
25
|
+
return new ProtoError('grpc-message-invalid', `${path}: ${reason}`, { details: { path, reason } });
|
|
26
|
+
}
|
|
27
|
+
/** `snake_case` → `lowerCamelCase`, the JSON name the specification derives from a field name. */
|
|
28
|
+
function jsonName(name) {
|
|
29
|
+
return name.replace(/_([a-z0-9])/g, (_, char) => char.toUpperCase());
|
|
30
|
+
}
|
|
31
|
+
/** Finds a field by its declared name or its JSON name, both of which the JSON mapping accepts. */
|
|
32
|
+
function fieldNamed(type, key) {
|
|
33
|
+
const direct = type.fields[key];
|
|
34
|
+
if (direct !== undefined) {
|
|
35
|
+
return direct;
|
|
36
|
+
}
|
|
37
|
+
return type.fieldsArray.find((field) => jsonName(field.name) === key);
|
|
38
|
+
}
|
|
39
|
+
/** Message-level conversions for well-known types, JSON form → parser form. `undefined` means "ordinary message". */
|
|
40
|
+
function wellKnownFromJson(type, value, path, set) {
|
|
41
|
+
const name = qualifiedName(type);
|
|
42
|
+
const field = (id) => type.fieldsById[id]?.name ?? String(id);
|
|
43
|
+
switch (name) {
|
|
44
|
+
case 'google.protobuf.Timestamp': {
|
|
45
|
+
if (isRecord(value))
|
|
46
|
+
return value;
|
|
47
|
+
const { seconds, nanos } = timestampFromJson(value);
|
|
48
|
+
return { [field(1)]: seconds, [field(2)]: nanos };
|
|
49
|
+
}
|
|
50
|
+
case 'google.protobuf.Duration': {
|
|
51
|
+
if (isRecord(value))
|
|
52
|
+
return value;
|
|
53
|
+
const { seconds, nanos } = durationFromJson(value);
|
|
54
|
+
return { [field(1)]: seconds, [field(2)]: nanos };
|
|
55
|
+
}
|
|
56
|
+
case 'google.protobuf.FieldMask':
|
|
57
|
+
return isRecord(value) ? value : { [field(1)]: fieldMaskFromJson(value).paths };
|
|
58
|
+
case 'google.protobuf.Struct':
|
|
59
|
+
if (!isRecord(value))
|
|
60
|
+
throw invalid(path, 'a Struct must be a JSON object');
|
|
61
|
+
return {
|
|
62
|
+
[field(1)]: Object.fromEntries(Object.entries(value).map(([k, v]) => [k, valueFromJson(type.root, v)])),
|
|
63
|
+
};
|
|
64
|
+
case 'google.protobuf.Value':
|
|
65
|
+
return valueFromJson(type.root, value);
|
|
66
|
+
case 'google.protobuf.ListValue':
|
|
67
|
+
if (!Array.isArray(value))
|
|
68
|
+
throw invalid(path, 'a ListValue must be a JSON array');
|
|
69
|
+
return { [field(1)]: value.map((item) => valueFromJson(type.root, item)) };
|
|
70
|
+
case 'google.protobuf.Empty':
|
|
71
|
+
return {};
|
|
72
|
+
case 'google.protobuf.Any':
|
|
73
|
+
return anyFromJson(type, value, path, set);
|
|
74
|
+
default:
|
|
75
|
+
if (isWrapperType(name)) {
|
|
76
|
+
return isRecord(value) && 'value' in value ? value : { [field(1)]: value };
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function valueFromJson(root, value) {
|
|
82
|
+
const type = root.lookupType('google.protobuf.Value');
|
|
83
|
+
const field = (id) => type.fieldsById[id]?.name ?? String(id);
|
|
84
|
+
if (value === null || value === undefined)
|
|
85
|
+
return { [field(1)]: 0 };
|
|
86
|
+
if (typeof value === 'number')
|
|
87
|
+
return { [field(2)]: value };
|
|
88
|
+
if (typeof value === 'string')
|
|
89
|
+
return { [field(3)]: value };
|
|
90
|
+
if (typeof value === 'boolean')
|
|
91
|
+
return { [field(4)]: value };
|
|
92
|
+
if (Array.isArray(value)) {
|
|
93
|
+
const list = root.lookupType('google.protobuf.ListValue');
|
|
94
|
+
return { [field(6)]: { [list.fieldsById[1]?.name ?? 'values']: value.map((item) => valueFromJson(root, item)) } };
|
|
95
|
+
}
|
|
96
|
+
const struct = root.lookupType('google.protobuf.Struct');
|
|
97
|
+
return {
|
|
98
|
+
[field(5)]: {
|
|
99
|
+
[struct.fieldsById[1]?.name ?? 'fields']: Object.fromEntries(Object.entries(value).map(([k, v]) => [k, valueFromJson(root, v)])),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function anyFromJson(type, value, path, set) {
|
|
104
|
+
if (!isRecord(value))
|
|
105
|
+
throw invalid(path, 'an Any must be a JSON object with an "@type"');
|
|
106
|
+
const { '@type': typeUrl, ...rest } = value;
|
|
107
|
+
if (typeof typeUrl !== 'string' || typeUrl === '') {
|
|
108
|
+
if ('type_url' in value || 'typeUrl' in value)
|
|
109
|
+
return value;
|
|
110
|
+
throw invalid(path, 'an Any needs an "@type" such as "type.googleapis.com/pkg.Message"');
|
|
111
|
+
}
|
|
112
|
+
const innerName = typeUrl.slice(typeUrl.lastIndexOf('/') + 1);
|
|
113
|
+
const inner = lookupMessageType(set, innerName);
|
|
114
|
+
const innerJson = wellKnownFromJson(inner, rest['value'], `${path}.value`, set) !== undefined && 'value' in rest
|
|
115
|
+
? rest['value']
|
|
116
|
+
: rest;
|
|
117
|
+
const bytes = encodeMessage(set, innerName, innerJson);
|
|
118
|
+
return { [type.fieldsById[1]?.name ?? 'type_url']: typeUrl, [type.fieldsById[2]?.name ?? 'value']: bytes };
|
|
119
|
+
}
|
|
120
|
+
const INT64_TYPES = new Set(['int64', 'uint64', 'sint64', 'fixed64', 'sfixed64']);
|
|
121
|
+
const INT32_TYPES = new Set(['int32', 'uint32', 'sint32', 'fixed32', 'sfixed32']);
|
|
122
|
+
const FLOAT_TYPES = new Set(['float', 'double']);
|
|
123
|
+
/**
|
|
124
|
+
* Checks a scalar or enum value against its declared type, the way the JSON mapping reads it: a
|
|
125
|
+
* 64-bit integer may be a string, a float may be `"NaN"` or `"Infinity"`, an enum may be a name or
|
|
126
|
+
* a number, bytes are base64. The parser's own `verify` wants its internal forms (a `Long`, an enum
|
|
127
|
+
* number), so the checking lives here and `fromObject` does the converting.
|
|
128
|
+
*/
|
|
129
|
+
function checkScalar(field, value, path) {
|
|
130
|
+
const type = field.type;
|
|
131
|
+
const resolved = field.resolvedType;
|
|
132
|
+
if (resolved instanceof protobuf.Enum) {
|
|
133
|
+
if (typeof value === 'string') {
|
|
134
|
+
if (!(value in resolved.values)) {
|
|
135
|
+
throw invalid(path, `"${value}" is not a value of ${qualifiedName(resolved)}`);
|
|
136
|
+
}
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
if (typeof value === 'number' && Number.isInteger(value)) {
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
throw invalid(path, `expected a ${qualifiedName(resolved)} name`);
|
|
143
|
+
}
|
|
144
|
+
if (type === 'string') {
|
|
145
|
+
if (typeof value !== 'string')
|
|
146
|
+
throw invalid(path, 'string expected');
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
if (type === 'bool') {
|
|
150
|
+
if (typeof value !== 'boolean')
|
|
151
|
+
throw invalid(path, 'boolean expected');
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
if (type === 'bytes') {
|
|
155
|
+
if (typeof value !== 'string')
|
|
156
|
+
throw invalid(path, 'base64 string expected');
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
if (INT64_TYPES.has(type)) {
|
|
160
|
+
if (typeof value === 'number' && Number.isInteger(value))
|
|
161
|
+
return value;
|
|
162
|
+
if (typeof value === 'string' && /^-?\d+$/.test(value))
|
|
163
|
+
return value;
|
|
164
|
+
throw invalid(path, 'integer expected (a 64-bit value may be written as a string)');
|
|
165
|
+
}
|
|
166
|
+
if (INT32_TYPES.has(type)) {
|
|
167
|
+
if (typeof value === 'number' && Number.isInteger(value))
|
|
168
|
+
return value;
|
|
169
|
+
if (typeof value === 'string' && /^-?\d+$/.test(value))
|
|
170
|
+
return Number(value);
|
|
171
|
+
throw invalid(path, 'integer expected');
|
|
172
|
+
}
|
|
173
|
+
if (FLOAT_TYPES.has(type)) {
|
|
174
|
+
if (typeof value === 'number')
|
|
175
|
+
return value;
|
|
176
|
+
if (value === 'NaN' || value === 'Infinity' || value === '-Infinity')
|
|
177
|
+
return Number(value);
|
|
178
|
+
if (typeof value === 'string' && value.trim() !== '' && !Number.isNaN(Number(value)))
|
|
179
|
+
return Number(value);
|
|
180
|
+
throw invalid(path, 'number expected');
|
|
181
|
+
}
|
|
182
|
+
return value;
|
|
183
|
+
}
|
|
184
|
+
/** Converts one JSON value into the parser's object form for `type`, checking every field name. */
|
|
185
|
+
function toParserObject(set, type, value, path) {
|
|
186
|
+
const special = wellKnownFromJson(type, value, path, set);
|
|
187
|
+
if (special !== undefined) {
|
|
188
|
+
return special;
|
|
189
|
+
}
|
|
190
|
+
if (!isRecord(value)) {
|
|
191
|
+
throw invalid(path, `expected a JSON object for ${qualifiedName(type)}`);
|
|
192
|
+
}
|
|
193
|
+
const out = {};
|
|
194
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
195
|
+
const field = fieldNamed(type, key);
|
|
196
|
+
if (field === undefined) {
|
|
197
|
+
throw invalid(`${path}.${key}`, `${qualifiedName(type)} has no field "${key}"`);
|
|
198
|
+
}
|
|
199
|
+
if (raw === null || raw === undefined) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
field.resolve();
|
|
203
|
+
const fieldPath = `${path}.${field.name}`;
|
|
204
|
+
if (field instanceof protobuf.MapField) {
|
|
205
|
+
if (!isRecord(raw))
|
|
206
|
+
throw invalid(fieldPath, 'a map field must be a JSON object');
|
|
207
|
+
const valueType = field.resolvedType;
|
|
208
|
+
out[field.name] = Object.fromEntries(Object.entries(raw).map(([k, v]) => [
|
|
209
|
+
k,
|
|
210
|
+
valueType instanceof protobuf.Type
|
|
211
|
+
? toParserObject(set, valueType, v, `${fieldPath}.${k}`)
|
|
212
|
+
: checkScalar(field, v, `${fieldPath}.${k}`),
|
|
213
|
+
]));
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
const convert = (item, itemPath) => field.resolvedType instanceof protobuf.Type
|
|
217
|
+
? toParserObject(set, field.resolvedType, item, itemPath)
|
|
218
|
+
: checkScalar(field, item, itemPath);
|
|
219
|
+
if (field.repeated) {
|
|
220
|
+
if (!Array.isArray(raw))
|
|
221
|
+
throw invalid(fieldPath, 'a repeated field must be a JSON array');
|
|
222
|
+
out[field.name] = raw.map((item, index) => convert(item, `${fieldPath}[${String(index)}]`));
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
out[field.name] = convert(raw, fieldPath);
|
|
226
|
+
}
|
|
227
|
+
return out;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Encodes `json` as the binary form of the message type `typeName`.
|
|
231
|
+
*
|
|
232
|
+
* @throws ProtoError `grpc-message-invalid` naming the offending field, `proto-type-unknown`
|
|
233
|
+
*/
|
|
234
|
+
export function encodeMessage(set, typeName, json) {
|
|
235
|
+
const type = lookupMessageType(set, typeName);
|
|
236
|
+
const object = toParserObject(set, type, json, qualifiedName(type));
|
|
237
|
+
return type.encode(type.fromObject(object)).finish();
|
|
238
|
+
}
|
|
239
|
+
/** Message-level conversions for well-known types, parser form → JSON form. */
|
|
240
|
+
function wellKnownToJson(type, value, set) {
|
|
241
|
+
const name = qualifiedName(type);
|
|
242
|
+
const field = (id) => type.fieldsById[id]?.name ?? String(id);
|
|
243
|
+
const at = (id) => value[field(id)];
|
|
244
|
+
switch (name) {
|
|
245
|
+
case 'google.protobuf.Timestamp':
|
|
246
|
+
return timestampToJson({ seconds: at(1), nanos: at(2) });
|
|
247
|
+
case 'google.protobuf.Duration':
|
|
248
|
+
return durationToJson({ seconds: at(1), nanos: at(2) });
|
|
249
|
+
case 'google.protobuf.FieldMask':
|
|
250
|
+
return fieldMaskToJson({ paths: at(1) });
|
|
251
|
+
case 'google.protobuf.Struct': {
|
|
252
|
+
const fields = at(1);
|
|
253
|
+
return isRecord(fields)
|
|
254
|
+
? Object.fromEntries(Object.entries(fields).map(([k, v]) => [k, valueToJson(type.root, v)]))
|
|
255
|
+
: {};
|
|
256
|
+
}
|
|
257
|
+
case 'google.protobuf.Value':
|
|
258
|
+
return valueToJson(type.root, value);
|
|
259
|
+
case 'google.protobuf.ListValue': {
|
|
260
|
+
const items = at(1);
|
|
261
|
+
return Array.isArray(items) ? items.map((item) => valueToJson(type.root, item)) : [];
|
|
262
|
+
}
|
|
263
|
+
case 'google.protobuf.Empty':
|
|
264
|
+
return {};
|
|
265
|
+
case 'google.protobuf.Any':
|
|
266
|
+
return anyToJson(value, at(1), at(2), set);
|
|
267
|
+
default:
|
|
268
|
+
if (isWrapperType(name)) {
|
|
269
|
+
return at(1) ?? wrapperDefault(name);
|
|
270
|
+
}
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function wrapperDefault(name) {
|
|
275
|
+
switch (name) {
|
|
276
|
+
case 'google.protobuf.BoolValue':
|
|
277
|
+
return false;
|
|
278
|
+
case 'google.protobuf.StringValue':
|
|
279
|
+
case 'google.protobuf.BytesValue':
|
|
280
|
+
return '';
|
|
281
|
+
case 'google.protobuf.Int64Value':
|
|
282
|
+
case 'google.protobuf.UInt64Value':
|
|
283
|
+
return '0';
|
|
284
|
+
default:
|
|
285
|
+
return 0;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function valueToJson(root, value) {
|
|
289
|
+
if (!isRecord(value))
|
|
290
|
+
return null;
|
|
291
|
+
const type = root.lookupType('google.protobuf.Value');
|
|
292
|
+
const field = (id) => type.fieldsById[id]?.name ?? String(id);
|
|
293
|
+
if (field(2) in value)
|
|
294
|
+
return value[field(2)];
|
|
295
|
+
if (field(3) in value)
|
|
296
|
+
return value[field(3)];
|
|
297
|
+
if (field(4) in value)
|
|
298
|
+
return value[field(4)];
|
|
299
|
+
if (field(5) in value) {
|
|
300
|
+
const struct = value[field(5)];
|
|
301
|
+
const fields = isRecord(struct)
|
|
302
|
+
? struct[root.lookupType('google.protobuf.Struct').fieldsById[1]?.name ?? 'fields']
|
|
303
|
+
: undefined;
|
|
304
|
+
return isRecord(fields)
|
|
305
|
+
? Object.fromEntries(Object.entries(fields).map(([k, v]) => [k, valueToJson(root, v)]))
|
|
306
|
+
: {};
|
|
307
|
+
}
|
|
308
|
+
if (field(6) in value) {
|
|
309
|
+
const list = value[field(6)];
|
|
310
|
+
const items = isRecord(list)
|
|
311
|
+
? list[root.lookupType('google.protobuf.ListValue').fieldsById[1]?.name ?? 'values']
|
|
312
|
+
: undefined;
|
|
313
|
+
return Array.isArray(items) ? items.map((item) => valueToJson(root, item)) : [];
|
|
314
|
+
}
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
function anyToJson(value, typeUrl, bytes, set) {
|
|
318
|
+
if (typeof typeUrl !== 'string' || typeUrl === '') {
|
|
319
|
+
return value;
|
|
320
|
+
}
|
|
321
|
+
const innerName = typeUrl.slice(typeUrl.lastIndexOf('/') + 1);
|
|
322
|
+
let inner;
|
|
323
|
+
try {
|
|
324
|
+
inner = lookupMessageType(set, innerName);
|
|
325
|
+
}
|
|
326
|
+
catch {
|
|
327
|
+
return {
|
|
328
|
+
'@type': typeUrl,
|
|
329
|
+
value: typeof bytes === 'string' ? bytes : Buffer.from(bytes).toString('base64'),
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
const raw = typeof bytes === 'string' ? Buffer.from(bytes, 'base64') : bytes;
|
|
333
|
+
const decoded = decodeMessage(set, qualifiedName(inner), raw);
|
|
334
|
+
return isRecord(decoded) && wellKnownToJson(inner, {}, set) === undefined
|
|
335
|
+
? { '@type': typeUrl, ...decoded }
|
|
336
|
+
: { '@type': typeUrl, value: decoded };
|
|
337
|
+
}
|
|
338
|
+
/** Converts the parser's object form of `type` into canonical JSON. Lenient: nothing here throws. */
|
|
339
|
+
function toJson(set, type, value) {
|
|
340
|
+
if (!isRecord(value)) {
|
|
341
|
+
return value;
|
|
342
|
+
}
|
|
343
|
+
const special = wellKnownToJson(type, value, set);
|
|
344
|
+
if (special !== undefined) {
|
|
345
|
+
return special;
|
|
346
|
+
}
|
|
347
|
+
const out = {};
|
|
348
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
349
|
+
const field = type.fields[key];
|
|
350
|
+
if (field === undefined) {
|
|
351
|
+
out[key] = raw;
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
field.resolve();
|
|
355
|
+
const nested = field.resolvedType instanceof protobuf.Type ? field.resolvedType : undefined;
|
|
356
|
+
if (field instanceof protobuf.MapField) {
|
|
357
|
+
out[key] = isRecord(raw)
|
|
358
|
+
? Object.fromEntries(Object.entries(raw).map(([k, v]) => [k, nested === undefined ? v : toJson(set, nested, v)]))
|
|
359
|
+
: raw;
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (field.repeated) {
|
|
363
|
+
out[key] = Array.isArray(raw)
|
|
364
|
+
? raw.map((item) => (nested === undefined ? item : toJson(set, nested, item)))
|
|
365
|
+
: raw;
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
out[key] = nested === undefined ? raw : toJson(set, nested, raw);
|
|
369
|
+
}
|
|
370
|
+
return out;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Decodes `bytes` as the message type `typeName` into canonical JSON: 64-bit integers as strings,
|
|
374
|
+
* enums by name, bytes as base64, well-known types in their string or bare forms, and fields at
|
|
375
|
+
* their default value omitted.
|
|
376
|
+
*
|
|
377
|
+
* @throws ProtoError `grpc-message-malformed` when the bytes do not decode, `proto-type-unknown`
|
|
378
|
+
*/
|
|
379
|
+
export function decodeMessage(set, typeName, bytes) {
|
|
380
|
+
const type = lookupMessageType(set, typeName);
|
|
381
|
+
let message;
|
|
382
|
+
try {
|
|
383
|
+
message = type.decode(bytes);
|
|
384
|
+
}
|
|
385
|
+
catch (error) {
|
|
386
|
+
throw new ProtoError('grpc-message-malformed', `The response could not be decoded as ${qualifiedName(type)}: ${error instanceof Error ? error.message : String(error)}`, { cause: error, details: { type: qualifiedName(type), bytes: bytes.byteLength } });
|
|
387
|
+
}
|
|
388
|
+
return toJson(set, type, type.toObject(message, TO_OBJECT_OPTIONS));
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Parses the JSON text of a request body into the messages to send: one object, or — for a
|
|
392
|
+
* client-streaming method — an array of objects.
|
|
393
|
+
*
|
|
394
|
+
* @throws ProtoError `grpc-message-invalid` when the text is not JSON or has the wrong shape
|
|
395
|
+
*/
|
|
396
|
+
export function parseMessageText(text, streaming) {
|
|
397
|
+
let parsed;
|
|
398
|
+
try {
|
|
399
|
+
parsed = text.trim() === '' ? {} : JSON.parse(text);
|
|
400
|
+
}
|
|
401
|
+
catch (error) {
|
|
402
|
+
throw new ProtoError('grpc-message-invalid', `The message is not valid JSON: ${error instanceof Error ? error.message : String(error)}`, {
|
|
403
|
+
cause: error,
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
if (streaming) {
|
|
407
|
+
if (Array.isArray(parsed)) {
|
|
408
|
+
return parsed;
|
|
409
|
+
}
|
|
410
|
+
return [parsed];
|
|
411
|
+
}
|
|
412
|
+
if (Array.isArray(parsed)) {
|
|
413
|
+
throw new ProtoError('grpc-message-invalid', 'This method takes one message, but the body is a JSON array');
|
|
414
|
+
}
|
|
415
|
+
return [parsed];
|
|
416
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command-line equivalent of a call, for the Code panel: what a person would type at a shell
|
|
3
|
+
* to make the same call with a command-line gRPC client that takes JSON and `.proto` files. The
|
|
4
|
+
* same value the send path uses is what is rendered, so what the panel shows is what would be sent;
|
|
5
|
+
* credentials are replaced with a stand-in unless the caller says otherwise.
|
|
6
|
+
*/
|
|
7
|
+
import type { GrpcSendInput } from './send.js';
|
|
8
|
+
/** Options for {@link grpcToCommand}. */
|
|
9
|
+
export interface GrpcToCommandOptions {
|
|
10
|
+
/** Replace secret values with a stand-in. On by default. */
|
|
11
|
+
readonly redactSecrets?: boolean;
|
|
12
|
+
/** The `.proto` files to name with `-proto`; the import root is passed as `-import-path`. */
|
|
13
|
+
readonly protoFiles?: readonly string[];
|
|
14
|
+
readonly importPath?: string;
|
|
15
|
+
readonly shell?: 'posix' | 'powershell';
|
|
16
|
+
}
|
|
17
|
+
/** The stand-in a redacted secret is rendered as. */
|
|
18
|
+
export declare const GRPC_COMMAND_REDACTED = "<redacted>";
|
|
19
|
+
/**
|
|
20
|
+
* Renders one call as a shell command. `messageText` is the request JSON, one object or an array,
|
|
21
|
+
* passed as the data argument; a client stream is what an array means to such a tool as well.
|
|
22
|
+
*/
|
|
23
|
+
export declare function grpcToCommand(input: Pick<GrpcSendInput, 'target' | 'tls' | 'service' | 'method' | 'metadata' | 'auth' | 'defaultMetadata' | 'timeoutMs'>, messageText: string, options?: GrpcToCommandOptions): string;
|