@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
package/dist/errors.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for every error the engine throws. Every Wirebench error carries
|
|
3
|
+
* a stable, machine-readable `code` in addition to a human-readable message,
|
|
4
|
+
* so callers (CLI, IPC, UI) can branch on `code` without parsing text.
|
|
5
|
+
*/
|
|
6
|
+
export class WirebenchError extends Error {
|
|
7
|
+
/** Stable, machine-readable identifier for this error condition. */
|
|
8
|
+
code;
|
|
9
|
+
/** Structured context for the error, if any. */
|
|
10
|
+
details;
|
|
11
|
+
constructor(code, message, options) {
|
|
12
|
+
super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);
|
|
13
|
+
this.name = 'WirebenchError';
|
|
14
|
+
this.code = code;
|
|
15
|
+
if (options?.details !== undefined) {
|
|
16
|
+
this.details = options.details;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Thrown when a WSDL document cannot be parsed or is structurally invalid. */
|
|
21
|
+
export class WsdlParseError extends WirebenchError {
|
|
22
|
+
constructor(code, message, options) {
|
|
23
|
+
super(code, message, options);
|
|
24
|
+
this.name = 'WsdlParseError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Thrown for XML Schema (XSD) validation or resolution failures. */
|
|
28
|
+
export class SchemaError extends WirebenchError {
|
|
29
|
+
constructor(code, message, options) {
|
|
30
|
+
super(code, message, options);
|
|
31
|
+
this.name = 'SchemaError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Thrown for HTTP transport failures (network, status, timeout). */
|
|
35
|
+
export class HttpError extends WirebenchError {
|
|
36
|
+
constructor(code, message, options) {
|
|
37
|
+
super(code, message, options);
|
|
38
|
+
this.name = 'HttpError';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Thrown for WS-Security signing/encryption/verification failures. */
|
|
42
|
+
export class WssError extends WirebenchError {
|
|
43
|
+
constructor(code, message, options) {
|
|
44
|
+
super(code, message, options);
|
|
45
|
+
this.name = 'WssError';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Thrown for WS-Addressing header construction failures. */
|
|
49
|
+
export class WsaError extends WirebenchError {
|
|
50
|
+
constructor(code, message, options) {
|
|
51
|
+
super(code, message, options);
|
|
52
|
+
this.name = 'WsaError';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Thrown for project file (load/save/migration) failures. */
|
|
56
|
+
export class ProjectError extends WirebenchError {
|
|
57
|
+
constructor(code, message, options) {
|
|
58
|
+
super(code, message, options);
|
|
59
|
+
this.name = 'ProjectError';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Thrown for workspace file (load/save/migration) failures. */
|
|
63
|
+
export class WorkspaceError extends WirebenchError {
|
|
64
|
+
constructor(code, message, options) {
|
|
65
|
+
super(code, message, options);
|
|
66
|
+
this.name = 'WorkspaceError';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** Thrown when an OpenAPI document cannot be read, or describes something this client cannot import. */
|
|
70
|
+
export class OpenApiError extends WirebenchError {
|
|
71
|
+
constructor(code, message, options) {
|
|
72
|
+
super(code, message, options);
|
|
73
|
+
this.name = 'OpenApiError';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Thrown when a Postman collection cannot be read, or is structurally invalid. */
|
|
77
|
+
export class PostmanError extends WirebenchError {
|
|
78
|
+
constructor(code, message, options) {
|
|
79
|
+
super(code, message, options);
|
|
80
|
+
this.name = 'PostmanError';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Thrown when a legacy single-XML SOAP project file cannot be read, or is not one. */
|
|
84
|
+
export class LegacyProjectError extends WirebenchError {
|
|
85
|
+
constructor(code, message, options) {
|
|
86
|
+
super(code, message, options);
|
|
87
|
+
this.name = 'LegacyProjectError';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Thrown when a `.proto` set cannot be parsed, an import cannot be found, or a name does not resolve. */
|
|
91
|
+
export class ProtoError extends WirebenchError {
|
|
92
|
+
constructor(code, message, options) {
|
|
93
|
+
super(code, message, options);
|
|
94
|
+
this.name = 'ProtoError';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Thrown for gRPC transport failures: the connection, the HTTP/2 stream, or a malformed frame. */
|
|
98
|
+
export class GrpcError extends WirebenchError {
|
|
99
|
+
constructor(code, message, options) {
|
|
100
|
+
super(code, message, options);
|
|
101
|
+
this.name = 'GrpcError';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** Thrown for WebSocket transport failures: the handshake, the connection, or a malformed frame. */
|
|
105
|
+
export class WsError extends WirebenchError {
|
|
106
|
+
constructor(code, message, options) {
|
|
107
|
+
super(code, message, options);
|
|
108
|
+
this.name = 'WsError';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Thrown when a value fails validation against a schema or business rule. */
|
|
112
|
+
export class ValidationError extends WirebenchError {
|
|
113
|
+
constructor(code, message, options) {
|
|
114
|
+
super(code, message, options);
|
|
115
|
+
this.name = 'ValidationError';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** Type guard identifying any {@link WirebenchError} (base class or subclass). */
|
|
119
|
+
export function isWirebenchError(e) {
|
|
120
|
+
return e instanceof WirebenchError;
|
|
121
|
+
}
|
package/dist/fs.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Does this path stay inside that folder?", answered against the real file system.
|
|
3
|
+
*
|
|
4
|
+
* The engine needs the same answer the desktop app's `main/path-containment.ts` gives, for a
|
|
5
|
+
* different reason: a WSDL fetched from anywhere may reference further documents by `file:`
|
|
6
|
+
* URL, and those references must not be able to walk out of the root document's own folder.
|
|
7
|
+
* Main's copy stays where it is — it guards renderer-named paths and is reachable from
|
|
8
|
+
* Electron-only code — but the rule itself is identical, so a fix here should be mirrored
|
|
9
|
+
* there (and vice versa).
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* `path`, with `realpath` resolved through whatever prefix of it already exists on disk, the
|
|
13
|
+
* still-missing tail joined back on. Nothing is created; this only computes the path a later
|
|
14
|
+
* read would actually land at, so a symlink anywhere in the existing prefix cannot be used to
|
|
15
|
+
* escape a containment check.
|
|
16
|
+
*
|
|
17
|
+
* @param path the absolute path to resolve
|
|
18
|
+
* @returns the real path of the existing prefix joined with the unresolved tail
|
|
19
|
+
*/
|
|
20
|
+
export declare function realpathOfPrefix(path: string): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* True when `candidate` is `root` itself or sits below it. Both must already be real paths.
|
|
23
|
+
*
|
|
24
|
+
* @param root the containing folder, as a real path
|
|
25
|
+
* @param candidate the path to test, as a real path
|
|
26
|
+
*/
|
|
27
|
+
export declare function isInsideReal(root: string, candidate: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* True when `candidate` resolves inside `root`, comparing real paths so a symlink cannot be
|
|
30
|
+
* used to point out of it.
|
|
31
|
+
*
|
|
32
|
+
* @param root the containing folder
|
|
33
|
+
* @param candidate the path to test
|
|
34
|
+
*/
|
|
35
|
+
export declare function isInsideRealDir(root: string, candidate: string): Promise<boolean>;
|
package/dist/fs.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Does this path stay inside that folder?", answered against the real file system.
|
|
3
|
+
*
|
|
4
|
+
* The engine needs the same answer the desktop app's `main/path-containment.ts` gives, for a
|
|
5
|
+
* different reason: a WSDL fetched from anywhere may reference further documents by `file:`
|
|
6
|
+
* URL, and those references must not be able to walk out of the root document's own folder.
|
|
7
|
+
* Main's copy stays where it is — it guards renderer-named paths and is reachable from
|
|
8
|
+
* Electron-only code — but the rule itself is identical, so a fix here should be mirrored
|
|
9
|
+
* there (and vice versa).
|
|
10
|
+
*/
|
|
11
|
+
import { basename, dirname, isAbsolute, join, relative, sep } from 'node:path';
|
|
12
|
+
import { existsSync } from 'node:fs';
|
|
13
|
+
import { realpath } from 'node:fs/promises';
|
|
14
|
+
/**
|
|
15
|
+
* `path`, with `realpath` resolved through whatever prefix of it already exists on disk, the
|
|
16
|
+
* still-missing tail joined back on. Nothing is created; this only computes the path a later
|
|
17
|
+
* read would actually land at, so a symlink anywhere in the existing prefix cannot be used to
|
|
18
|
+
* escape a containment check.
|
|
19
|
+
*
|
|
20
|
+
* @param path the absolute path to resolve
|
|
21
|
+
* @returns the real path of the existing prefix joined with the unresolved tail
|
|
22
|
+
*/
|
|
23
|
+
export async function realpathOfPrefix(path) {
|
|
24
|
+
const tail = [];
|
|
25
|
+
let current = path;
|
|
26
|
+
while (!existsSync(current)) {
|
|
27
|
+
const parent = dirname(current);
|
|
28
|
+
if (parent === current) {
|
|
29
|
+
// Hit the filesystem root without finding anything that exists; nothing to resolve.
|
|
30
|
+
return path;
|
|
31
|
+
}
|
|
32
|
+
tail.unshift(basename(current));
|
|
33
|
+
current = parent;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const real = await realpath(current);
|
|
37
|
+
return tail.length === 0 ? real : join(real, ...tail);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
/* v8 ignore next 2 -- realpath of an existsSync-confirmed path only fails on a race */
|
|
41
|
+
return path;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* True when `candidate` is `root` itself or sits below it. Both must already be real paths.
|
|
46
|
+
*
|
|
47
|
+
* @param root the containing folder, as a real path
|
|
48
|
+
* @param candidate the path to test, as a real path
|
|
49
|
+
*/
|
|
50
|
+
export function isInsideReal(root, candidate) {
|
|
51
|
+
const rel = relative(root, candidate);
|
|
52
|
+
return rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* True when `candidate` resolves inside `root`, comparing real paths so a symlink cannot be
|
|
56
|
+
* used to point out of it.
|
|
57
|
+
*
|
|
58
|
+
* @param root the containing folder
|
|
59
|
+
* @param candidate the path to test
|
|
60
|
+
*/
|
|
61
|
+
export async function isInsideRealDir(root, candidate) {
|
|
62
|
+
const [rootReal, candidateReal] = await Promise.all([realpathOfPrefix(root), realpathOfPrefix(candidate)]);
|
|
63
|
+
return isInsideReal(rootReal, candidateReal);
|
|
64
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience wrappers around `buildSampleRequest`/`buildEmptyRequest` that
|
|
3
|
+
* take an {@link ImportResult} directly, so callers don't have to thread
|
|
4
|
+
* `definition`/`schemaSet` through by hand.
|
|
5
|
+
*/
|
|
6
|
+
import type { GeneratedRequest, OperationRef, RequestBuildOptions } from './soap/request-builder.js';
|
|
7
|
+
import type { GenerateOptions } from './xsd/sample-generator.js';
|
|
8
|
+
import type { ImportResult } from './types.js';
|
|
9
|
+
/** Builds the sample SOAP request for one operation of an imported definition. */
|
|
10
|
+
export declare function generateRequest(result: ImportResult, op: OperationRef, genOptions?: Partial<GenerateOptions>, options?: RequestBuildOptions): GeneratedRequest;
|
|
11
|
+
/** Builds an empty SOAP request (empty `Header`/`Body`) for one operation of an imported definition. */
|
|
12
|
+
export declare function generateEmptyRequest(result: ImportResult, op: OperationRef, options?: RequestBuildOptions): GeneratedRequest;
|
package/dist/generate.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience wrappers around `buildSampleRequest`/`buildEmptyRequest` that
|
|
3
|
+
* take an {@link ImportResult} directly, so callers don't have to thread
|
|
4
|
+
* `definition`/`schemaSet` through by hand.
|
|
5
|
+
*/
|
|
6
|
+
import { buildEmptyRequest, buildSampleRequest } from './soap/request-builder.js';
|
|
7
|
+
/** Builds the sample SOAP request for one operation of an imported definition. */
|
|
8
|
+
export function generateRequest(result, op, genOptions, options) {
|
|
9
|
+
return buildSampleRequest({ definition: result.definition, schemaSet: result.schemaSet }, op, genOptions, options);
|
|
10
|
+
}
|
|
11
|
+
/** Builds an empty SOAP request (empty `Header`/`Body`) for one operation of an imported definition. */
|
|
12
|
+
export function generateEmptyRequest(result, op, options) {
|
|
13
|
+
return buildEmptyRequest({ definition: result.definition, schemaSet: result.schemaSet }, op, options);
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser-safe face of `grpc/`: pure helpers with no Node dependency, reachable from the
|
|
3
|
+
* renderer as `@wirebench/engine/grpc` (ESLint allows this subpath and no other). Kept to what an
|
|
4
|
+
* editor needs to display — the effective target, the method path, the status names — so the
|
|
5
|
+
* renderer never reimplements a rule the transport enforces.
|
|
6
|
+
*/
|
|
7
|
+
export { clientStreams, defaultTlsFor, GRPC_REFLECTION_VERSIONS, grpcMethodPath, serverStreams } from './shape.js';
|
|
8
|
+
export type { GrpcMethodKind, GrpcReflectionVersion } from './shape.js';
|
|
9
|
+
export { GRPC_STATUS_NAMES, grpcStatusName } from './status.js';
|
|
10
|
+
export { parseGrpcTarget } from './target.js';
|
|
11
|
+
export type { GrpcTarget } from './target.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser-safe face of `grpc/`: pure helpers with no Node dependency, reachable from the
|
|
3
|
+
* renderer as `@wirebench/engine/grpc` (ESLint allows this subpath and no other). Kept to what an
|
|
4
|
+
* editor needs to display — the effective target, the method path, the status names — so the
|
|
5
|
+
* renderer never reimplements a rule the transport enforces.
|
|
6
|
+
*/
|
|
7
|
+
export { clientStreams, defaultTlsFor, GRPC_REFLECTION_VERSIONS, grpcMethodPath, serverStreams } from './shape.js';
|
|
8
|
+
export { GRPC_STATUS_NAMES, grpcStatusName } from './status.js';
|
|
9
|
+
export { parseGrpcTarget } from './target.js';
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persisting a gRPC API's schema under `apis/<slug>/definition/`, in either of the two forms it can
|
|
3
|
+
* arrive in.
|
|
4
|
+
*
|
|
5
|
+
* An **import** keeps the `.proto` files byte-exact, on the same contract the WSDL and OpenAPI caches
|
|
6
|
+
* keep: nothing is re-serialised, a `manifest.yaml` records each file's size and SHA-256 so
|
|
7
|
+
* corruption is noticed rather than parsed, and an export is byte-identical to what was imported.
|
|
8
|
+
* What differs is the layout: a `.proto` reaches its imports by path, so each file is stored under
|
|
9
|
+
* `protos/` *at its import path* — the set loads again from the cache exactly as it loaded from the
|
|
10
|
+
* user's folder, with no renaming to undo.
|
|
11
|
+
*
|
|
12
|
+
* **Server reflection** has no `.proto` text to keep: a server describes itself in the compiler's own
|
|
13
|
+
* output, so what is cached is the `FileDescriptorSet` it sent, as one binary file beside a manifest
|
|
14
|
+
* that says `kind: descriptors`. The two forms are siblings rather than variations of one: a manifest
|
|
15
|
+
* declares which it is, and {@link readGrpcDefinitionCache} hands the caller whichever it found.
|
|
16
|
+
*/
|
|
17
|
+
import type { FsLike } from '../project/fs.js';
|
|
18
|
+
import type { DescriptorDefinitionCacheManifest, ProtoDefinitionCacheManifest } from '../project/schema.js';
|
|
19
|
+
import type { ProtoSources } from './proto/load.js';
|
|
20
|
+
/** The directory under `definition/` the `.proto` files live in, at their import paths. */
|
|
21
|
+
export declare const PROTOS_DIR = "protos";
|
|
22
|
+
/** The file under `definition/` a discovered schema's `FileDescriptorSet` is stored in. */
|
|
23
|
+
export declare const DESCRIPTORS_FILE = "descriptors.binpb";
|
|
24
|
+
/** Options accepted by the read and write halves. */
|
|
25
|
+
export interface ProtoDefinitionCacheOptions {
|
|
26
|
+
/** Overrides the file system, e.g. for tests. Defaults to `nodeFs`. */
|
|
27
|
+
readonly fs?: FsLike;
|
|
28
|
+
}
|
|
29
|
+
/** Options accepted by {@link writeProtoDefinitionCache}. */
|
|
30
|
+
export interface WriteProtoDefinitionCacheOptions extends ProtoDefinitionCacheOptions {
|
|
31
|
+
/** Where the files came from, as the user gave it. */
|
|
32
|
+
readonly source: string;
|
|
33
|
+
/** The import paths the load started from. */
|
|
34
|
+
readonly roots: readonly string[];
|
|
35
|
+
/** Overrides the clock used for `fetchedAt`. */
|
|
36
|
+
readonly now?: () => string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Splits an import path into segments, each checked as a path segment (ADR-0005), so a file that
|
|
40
|
+
* calls itself `../../etc/passwd.proto` never leaves the cache directory.
|
|
41
|
+
*
|
|
42
|
+
* @throws ProjectError `project-path-invalid`
|
|
43
|
+
*/
|
|
44
|
+
export declare function protoPathSegments(path: string): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Writes every source byte-exact under `dir/protos/` alongside a `manifest.yaml`, and returns the
|
|
47
|
+
* manifest. The previous contents are REPLACED: a file the new manifest does not list is deleted.
|
|
48
|
+
*
|
|
49
|
+
* @param sources the `.proto` files, keyed by import path
|
|
50
|
+
* @param dir absolute path of the API's `definition/` directory
|
|
51
|
+
* @throws ProjectError `definition-cache-corrupt` for an empty set, `project-path-invalid` for an unsafe path
|
|
52
|
+
*/
|
|
53
|
+
export declare function writeProtoDefinitionCache(sources: ProtoSources, dir: string, options: WriteProtoDefinitionCacheOptions): Promise<ProtoDefinitionCacheManifest>;
|
|
54
|
+
/** A cached `.proto` set: its manifest and every file it lists. */
|
|
55
|
+
export interface CachedProtoDefinition {
|
|
56
|
+
readonly manifest: ProtoDefinitionCacheManifest;
|
|
57
|
+
readonly sources: Map<string, string>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Reads a cache previously written by {@link writeProtoDefinitionCache}, verifying every file's
|
|
61
|
+
* bytes against its recorded SHA-256.
|
|
62
|
+
*
|
|
63
|
+
* @throws ProjectError `definition-cache-missing` when `dir` has no `manifest.yaml` or it is not a
|
|
64
|
+
* proto manifest, `definition-cache-corrupt` when a file is gone or its bytes no longer match
|
|
65
|
+
*/
|
|
66
|
+
export declare function readProtoDefinitionCache(dir: string, options?: ProtoDefinitionCacheOptions): Promise<CachedProtoDefinition>;
|
|
67
|
+
/** Options accepted by {@link writeDescriptorDefinitionCache}. */
|
|
68
|
+
export interface WriteDescriptorDefinitionCacheOptions extends ProtoDefinitionCacheOptions {
|
|
69
|
+
/** The target the server was asked at, as the user gave it. */
|
|
70
|
+
readonly source: string;
|
|
71
|
+
/** The descriptor files declaring the services. */
|
|
72
|
+
readonly roots: readonly string[];
|
|
73
|
+
/** The reflection protocol version that answered. */
|
|
74
|
+
readonly reflectionVersion?: 'v1' | 'v1alpha';
|
|
75
|
+
/** Overrides the clock used for `fetchedAt`. */
|
|
76
|
+
readonly now?: () => string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Writes a discovered schema's `FileDescriptorSet` byte-exact beside a `manifest.yaml`, and returns
|
|
80
|
+
* the manifest. Any `.proto` cache the directory held is removed: an API has one definition.
|
|
81
|
+
*
|
|
82
|
+
* @param descriptors the encoded `FileDescriptorSet`
|
|
83
|
+
* @param dir absolute path of the API's `definition/` directory
|
|
84
|
+
* @throws ProjectError `definition-cache-corrupt` when there are no bytes to write
|
|
85
|
+
*/
|
|
86
|
+
export declare function writeDescriptorDefinitionCache(descriptors: Uint8Array, dir: string, options: WriteDescriptorDefinitionCacheOptions): Promise<DescriptorDefinitionCacheManifest>;
|
|
87
|
+
/** A cached descriptor set: its manifest and the `FileDescriptorSet` bytes. */
|
|
88
|
+
export interface CachedDescriptorDefinition {
|
|
89
|
+
readonly manifest: DescriptorDefinitionCacheManifest;
|
|
90
|
+
readonly descriptors: Uint8Array;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Reads a cache previously written by {@link writeDescriptorDefinitionCache}, verifying the bytes
|
|
94
|
+
* against the recorded SHA-256.
|
|
95
|
+
*
|
|
96
|
+
* @throws ProjectError `definition-cache-missing` when `dir` has no `manifest.yaml` or it is not a
|
|
97
|
+
* descriptor manifest, `definition-cache-corrupt` when the set is gone or no longer matches
|
|
98
|
+
*/
|
|
99
|
+
export declare function readDescriptorDefinitionCache(dir: string, options?: ProtoDefinitionCacheOptions): Promise<CachedDescriptorDefinition>;
|
|
100
|
+
/** Whichever of the two gRPC definition caches a directory holds. */
|
|
101
|
+
export type CachedGrpcDefinition = ({
|
|
102
|
+
readonly kind: 'proto';
|
|
103
|
+
} & CachedProtoDefinition) | ({
|
|
104
|
+
readonly kind: 'descriptors';
|
|
105
|
+
} & CachedDescriptorDefinition);
|
|
106
|
+
/**
|
|
107
|
+
* Reads a gRPC API's definition cache whichever form it is in, so a caller that only wants a loaded
|
|
108
|
+
* schema does not have to know which one was written.
|
|
109
|
+
*
|
|
110
|
+
* @throws ProjectError `definition-cache-missing` when there is no manifest or it declares a kind
|
|
111
|
+
* this build does not know, and whatever the matching reader throws
|
|
112
|
+
*/
|
|
113
|
+
export declare function readGrpcDefinitionCache(dir: string, options?: ProtoDefinitionCacheOptions): Promise<CachedGrpcDefinition>;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persisting a gRPC API's schema under `apis/<slug>/definition/`, in either of the two forms it can
|
|
3
|
+
* arrive in.
|
|
4
|
+
*
|
|
5
|
+
* An **import** keeps the `.proto` files byte-exact, on the same contract the WSDL and OpenAPI caches
|
|
6
|
+
* keep: nothing is re-serialised, a `manifest.yaml` records each file's size and SHA-256 so
|
|
7
|
+
* corruption is noticed rather than parsed, and an export is byte-identical to what was imported.
|
|
8
|
+
* What differs is the layout: a `.proto` reaches its imports by path, so each file is stored under
|
|
9
|
+
* `protos/` *at its import path* — the set loads again from the cache exactly as it loaded from the
|
|
10
|
+
* user's folder, with no renaming to undo.
|
|
11
|
+
*
|
|
12
|
+
* **Server reflection** has no `.proto` text to keep: a server describes itself in the compiler's own
|
|
13
|
+
* output, so what is cached is the `FileDescriptorSet` it sent, as one binary file beside a manifest
|
|
14
|
+
* that says `kind: descriptors`. The two forms are siblings rather than variations of one: a manifest
|
|
15
|
+
* declares which it is, and {@link readGrpcDefinitionCache} hands the caller whichever it found.
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from 'node:crypto';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { ProjectError } from '../errors.js';
|
|
20
|
+
import { nodeFs, readFileIfExists, readdirIfExists, writeFileAtomic } from '../project/fs.js';
|
|
21
|
+
import { assertPathSegment } from '../project/paths.js';
|
|
22
|
+
import { descriptorDefinitionCacheManifestSchema, parseFile, protoDefinitionCacheManifestSchema, } from '../project/schema.js';
|
|
23
|
+
import { parseYaml, stringifyYaml } from '../project/yaml.js';
|
|
24
|
+
const MANIFEST_FILE = 'manifest.yaml';
|
|
25
|
+
/** The directory under `definition/` the `.proto` files live in, at their import paths. */
|
|
26
|
+
export const PROTOS_DIR = 'protos';
|
|
27
|
+
/** The file under `definition/` a discovered schema's `FileDescriptorSet` is stored in. */
|
|
28
|
+
export const DESCRIPTORS_FILE = 'descriptors.binpb';
|
|
29
|
+
function sha256Hex(bytes) {
|
|
30
|
+
return createHash('sha256').update(bytes).digest('hex');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Splits an import path into segments, each checked as a path segment (ADR-0005), so a file that
|
|
34
|
+
* calls itself `../../etc/passwd.proto` never leaves the cache directory.
|
|
35
|
+
*
|
|
36
|
+
* @throws ProjectError `project-path-invalid`
|
|
37
|
+
*/
|
|
38
|
+
export function protoPathSegments(path) {
|
|
39
|
+
const segments = path.split('/');
|
|
40
|
+
if (segments.length === 0 || segments.some((segment) => segment === '')) {
|
|
41
|
+
throw new ProjectError('project-path-invalid', `"${path}" is not a usable .proto import path`, {
|
|
42
|
+
details: { path },
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
for (const segment of segments) {
|
|
46
|
+
assertPathSegment(segment);
|
|
47
|
+
}
|
|
48
|
+
return segments;
|
|
49
|
+
}
|
|
50
|
+
/** Every file under `dir`, recursively, as `/`-separated paths relative to it. */
|
|
51
|
+
async function listFiles(fs, dir, prefix = '') {
|
|
52
|
+
const out = [];
|
|
53
|
+
for (const entry of await readdirIfExists(fs, dir)) {
|
|
54
|
+
if (entry.isDirectory) {
|
|
55
|
+
out.push(...(await listFiles(fs, join(dir, entry.name), `${prefix}${entry.name}/`)));
|
|
56
|
+
}
|
|
57
|
+
else if (entry.isFile) {
|
|
58
|
+
out.push(`${prefix}${entry.name}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Writes every source byte-exact under `dir/protos/` alongside a `manifest.yaml`, and returns the
|
|
65
|
+
* manifest. The previous contents are REPLACED: a file the new manifest does not list is deleted.
|
|
66
|
+
*
|
|
67
|
+
* @param sources the `.proto` files, keyed by import path
|
|
68
|
+
* @param dir absolute path of the API's `definition/` directory
|
|
69
|
+
* @throws ProjectError `definition-cache-corrupt` for an empty set, `project-path-invalid` for an unsafe path
|
|
70
|
+
*/
|
|
71
|
+
export async function writeProtoDefinitionCache(sources, dir, options) {
|
|
72
|
+
const fs = options.fs ?? nodeFs;
|
|
73
|
+
if (sources.size === 0) {
|
|
74
|
+
throw new ProjectError('definition-cache-corrupt', 'A proto definition cache needs at least one file', {
|
|
75
|
+
details: { dir },
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const protosDir = join(dir, PROTOS_DIR);
|
|
79
|
+
const existing = await listFiles(fs, protosDir);
|
|
80
|
+
const files = [...sources.entries()]
|
|
81
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
82
|
+
.map(([path, text]) => {
|
|
83
|
+
protoPathSegments(path);
|
|
84
|
+
const bytes = Buffer.from(text, 'utf8');
|
|
85
|
+
return { path, sha256: sha256Hex(bytes), bytes: bytes.byteLength, content: bytes };
|
|
86
|
+
});
|
|
87
|
+
const manifest = {
|
|
88
|
+
formatVersion: 1,
|
|
89
|
+
kind: 'proto',
|
|
90
|
+
source: options.source,
|
|
91
|
+
fetchedAt: (options.now ?? (() => new Date().toISOString()))(),
|
|
92
|
+
roots: [...options.roots],
|
|
93
|
+
files: files.map(({ path, sha256, bytes }) => ({ path, sha256, bytes })),
|
|
94
|
+
};
|
|
95
|
+
for (const file of files) {
|
|
96
|
+
await writeFileAtomic(fs, join(protosDir, ...protoPathSegments(file.path)), file.content);
|
|
97
|
+
}
|
|
98
|
+
await writeFileAtomic(fs, join(dir, MANIFEST_FILE), stringifyYaml(manifest));
|
|
99
|
+
const keep = new Set(files.map((file) => file.path));
|
|
100
|
+
for (const stale of existing) {
|
|
101
|
+
if (!keep.has(stale)) {
|
|
102
|
+
await fs.rm(join(protosDir, ...stale.split('/')), { force: true });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// An API re-imported from files after having been discovered leaves no descriptor set behind.
|
|
106
|
+
await fs.rm(join(dir, DESCRIPTORS_FILE), { force: true });
|
|
107
|
+
return manifest;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Reads and parses `definition/manifest.yaml` as an untyped document.
|
|
111
|
+
*
|
|
112
|
+
* @throws ProjectError `definition-cache-missing` when there is none
|
|
113
|
+
*/
|
|
114
|
+
async function readManifestDocument(fs, dir) {
|
|
115
|
+
const path = join(dir, MANIFEST_FILE);
|
|
116
|
+
const raw = await readFileIfExists(fs, path);
|
|
117
|
+
if (raw === undefined) {
|
|
118
|
+
throw new ProjectError('definition-cache-missing', `No definition cache manifest at ${path}`, {
|
|
119
|
+
details: { dir },
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return { path, document: parseYaml(raw.toString('utf8'), path) };
|
|
123
|
+
}
|
|
124
|
+
/** The `kind` a manifest document declares, or `undefined` when it declares none. */
|
|
125
|
+
function manifestKind(document) {
|
|
126
|
+
if (typeof document !== 'object' || document === null || Array.isArray(document)) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
const kind = document.kind;
|
|
130
|
+
return typeof kind === 'string' ? kind : undefined;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Reads a cache previously written by {@link writeProtoDefinitionCache}, verifying every file's
|
|
134
|
+
* bytes against its recorded SHA-256.
|
|
135
|
+
*
|
|
136
|
+
* @throws ProjectError `definition-cache-missing` when `dir` has no `manifest.yaml` or it is not a
|
|
137
|
+
* proto manifest, `definition-cache-corrupt` when a file is gone or its bytes no longer match
|
|
138
|
+
*/
|
|
139
|
+
export async function readProtoDefinitionCache(dir, options) {
|
|
140
|
+
const fs = options?.fs ?? nodeFs;
|
|
141
|
+
const { path: manifestPath, document } = await readManifestDocument(fs, dir);
|
|
142
|
+
if (manifestKind(document) !== 'proto') {
|
|
143
|
+
throw new ProjectError('definition-cache-missing', `${manifestPath} is not a .proto definition cache`, {
|
|
144
|
+
details: { dir },
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const manifest = parseFile(protoDefinitionCacheManifestSchema, document, manifestPath);
|
|
148
|
+
const sources = new Map();
|
|
149
|
+
for (const file of manifest.files) {
|
|
150
|
+
const bytes = await readFileIfExists(fs, join(dir, PROTOS_DIR, ...protoPathSegments(file.path)));
|
|
151
|
+
if (bytes === undefined) {
|
|
152
|
+
throw new ProjectError('definition-cache-corrupt', `${file.path} is listed in the manifest but missing from the cache`, {
|
|
153
|
+
details: { dir, path: file.path },
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (sha256Hex(bytes) !== file.sha256) {
|
|
157
|
+
throw new ProjectError('definition-cache-corrupt', `${file.path} no longer matches the hash the manifest recorded`, {
|
|
158
|
+
details: { dir, path: file.path },
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
sources.set(file.path, bytes.toString('utf8'));
|
|
162
|
+
}
|
|
163
|
+
return { manifest, sources };
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Writes a discovered schema's `FileDescriptorSet` byte-exact beside a `manifest.yaml`, and returns
|
|
167
|
+
* the manifest. Any `.proto` cache the directory held is removed: an API has one definition.
|
|
168
|
+
*
|
|
169
|
+
* @param descriptors the encoded `FileDescriptorSet`
|
|
170
|
+
* @param dir absolute path of the API's `definition/` directory
|
|
171
|
+
* @throws ProjectError `definition-cache-corrupt` when there are no bytes to write
|
|
172
|
+
*/
|
|
173
|
+
export async function writeDescriptorDefinitionCache(descriptors, dir, options) {
|
|
174
|
+
const fs = options.fs ?? nodeFs;
|
|
175
|
+
if (descriptors.byteLength === 0) {
|
|
176
|
+
throw new ProjectError('definition-cache-corrupt', 'A descriptor definition cache needs a descriptor set', {
|
|
177
|
+
details: { dir },
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const content = Buffer.from(descriptors);
|
|
181
|
+
const manifest = {
|
|
182
|
+
formatVersion: 1,
|
|
183
|
+
kind: 'descriptors',
|
|
184
|
+
source: options.source,
|
|
185
|
+
fetchedAt: (options.now ?? (() => new Date().toISOString()))(),
|
|
186
|
+
roots: [...options.roots],
|
|
187
|
+
...(options.reflectionVersion !== undefined ? { reflectionVersion: options.reflectionVersion } : {}),
|
|
188
|
+
file: { path: DESCRIPTORS_FILE, sha256: sha256Hex(content), bytes: content.byteLength },
|
|
189
|
+
};
|
|
190
|
+
await writeFileAtomic(fs, join(dir, DESCRIPTORS_FILE), content);
|
|
191
|
+
await writeFileAtomic(fs, join(dir, MANIFEST_FILE), stringifyYaml(manifest));
|
|
192
|
+
// An API rediscovered by reflection after having been imported keeps no .proto files behind.
|
|
193
|
+
const protosDir = join(dir, PROTOS_DIR);
|
|
194
|
+
for (const stale of await listFiles(fs, protosDir)) {
|
|
195
|
+
await fs.rm(join(protosDir, ...stale.split('/')), { force: true });
|
|
196
|
+
}
|
|
197
|
+
return manifest;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Reads a cache previously written by {@link writeDescriptorDefinitionCache}, verifying the bytes
|
|
201
|
+
* against the recorded SHA-256.
|
|
202
|
+
*
|
|
203
|
+
* @throws ProjectError `definition-cache-missing` when `dir` has no `manifest.yaml` or it is not a
|
|
204
|
+
* descriptor manifest, `definition-cache-corrupt` when the set is gone or no longer matches
|
|
205
|
+
*/
|
|
206
|
+
export async function readDescriptorDefinitionCache(dir, options) {
|
|
207
|
+
const fs = options?.fs ?? nodeFs;
|
|
208
|
+
const { path: manifestPath, document } = await readManifestDocument(fs, dir);
|
|
209
|
+
if (manifestKind(document) !== 'descriptors') {
|
|
210
|
+
throw new ProjectError('definition-cache-missing', `${manifestPath} is not a descriptor definition cache`, {
|
|
211
|
+
details: { dir },
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
const manifest = parseFile(descriptorDefinitionCacheManifestSchema, document, manifestPath);
|
|
215
|
+
const bytes = await readFileIfExists(fs, join(dir, ...protoPathSegments(manifest.file.path)));
|
|
216
|
+
if (bytes === undefined) {
|
|
217
|
+
throw new ProjectError('definition-cache-corrupt', `${manifest.file.path} is listed in the manifest but missing from the cache`, { details: { dir, path: manifest.file.path } });
|
|
218
|
+
}
|
|
219
|
+
if (sha256Hex(bytes) !== manifest.file.sha256) {
|
|
220
|
+
throw new ProjectError('definition-cache-corrupt', `${manifest.file.path} no longer matches the hash the manifest recorded`, { details: { dir, path: manifest.file.path } });
|
|
221
|
+
}
|
|
222
|
+
return { manifest, descriptors: new Uint8Array(bytes) };
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Reads a gRPC API's definition cache whichever form it is in, so a caller that only wants a loaded
|
|
226
|
+
* schema does not have to know which one was written.
|
|
227
|
+
*
|
|
228
|
+
* @throws ProjectError `definition-cache-missing` when there is no manifest or it declares a kind
|
|
229
|
+
* this build does not know, and whatever the matching reader throws
|
|
230
|
+
*/
|
|
231
|
+
export async function readGrpcDefinitionCache(dir, options) {
|
|
232
|
+
const fs = options?.fs ?? nodeFs;
|
|
233
|
+
const { path: manifestPath, document } = await readManifestDocument(fs, dir);
|
|
234
|
+
switch (manifestKind(document)) {
|
|
235
|
+
case 'proto':
|
|
236
|
+
return { kind: 'proto', ...(await readProtoDefinitionCache(dir, options)) };
|
|
237
|
+
case 'descriptors':
|
|
238
|
+
return { kind: 'descriptors', ...(await readDescriptorDefinitionCache(dir, options)) };
|
|
239
|
+
default:
|
|
240
|
+
throw new ProjectError('definition-cache-missing', `${manifestPath} is not a gRPC definition cache`, {
|
|
241
|
+
details: { dir, kind: manifestKind(document) },
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|