@api-client/core 0.18.11 → 0.18.13
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/build/src/browser.d.ts +0 -3
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +0 -3
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +2 -5
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +2 -5
- package/build/src/index.js.map +1 -1
- package/build/src/lib/logging/DefaultLogger.d.ts +14 -0
- package/build/src/lib/logging/DefaultLogger.d.ts.map +1 -1
- package/build/src/lib/logging/DefaultLogger.js +27 -0
- package/build/src/lib/logging/DefaultLogger.js.map +1 -1
- package/build/src/lib/logging/index.d.ts +4 -0
- package/build/src/lib/logging/index.d.ts.map +1 -0
- package/build/src/lib/logging/index.js +10 -0
- package/build/src/lib/logging/index.js.map +1 -0
- package/build/src/modeling/DomainModel.d.ts.map +1 -1
- package/build/src/modeling/DomainModel.js +11 -4
- package/build/src/modeling/DomainModel.js.map +1 -1
- package/build/src/models/ClientCertificate.d.ts +1 -1
- package/build/src/models/ClientCertificate.js.map +1 -1
- package/build/src/models/RequestConfig.d.ts +1 -1
- package/build/src/models/RequestConfig.js.map +1 -1
- package/build/src/models/SerializableError.d.ts +1 -1
- package/build/src/models/SerializableError.d.ts.map +1 -1
- package/build/src/models/SerializableError.js.map +1 -1
- package/build/src/proxy/RequestProxy.d.ts.map +1 -1
- package/build/src/proxy/RequestProxy.js +2 -2
- package/build/src/proxy/RequestProxy.js.map +1 -1
- package/build/src/runtime/http-engine/CoreEngine.d.ts +218 -139
- package/build/src/runtime/http-engine/CoreEngine.d.ts.map +1 -1
- package/build/src/runtime/http-engine/CoreEngine.js +716 -870
- package/build/src/runtime/http-engine/CoreEngine.js.map +1 -1
- package/build/src/runtime/http-engine/PayloadSupport.d.ts.map +1 -1
- package/build/src/runtime/http-engine/PayloadSupport.js +2 -1
- package/build/src/runtime/http-engine/PayloadSupport.js.map +1 -1
- package/build/src/runtime/http-engine/auth/AuthManager.d.ts +73 -0
- package/build/src/runtime/http-engine/auth/AuthManager.d.ts.map +1 -0
- package/build/src/runtime/http-engine/auth/AuthManager.js +186 -0
- package/build/src/runtime/http-engine/auth/AuthManager.js.map +1 -0
- package/build/src/runtime/http-engine/auth/index.d.ts +2 -0
- package/build/src/runtime/http-engine/auth/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/auth/index.js +2 -0
- package/build/src/runtime/http-engine/auth/index.js.map +1 -0
- package/build/src/runtime/http-engine/certificates/CertificateManager.d.ts +11 -0
- package/build/src/runtime/http-engine/certificates/CertificateManager.d.ts.map +1 -0
- package/build/src/runtime/http-engine/certificates/CertificateManager.js +76 -0
- package/build/src/runtime/http-engine/certificates/CertificateManager.js.map +1 -0
- package/build/src/runtime/http-engine/certificates/index.d.ts +2 -0
- package/build/src/runtime/http-engine/certificates/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/certificates/index.js +2 -0
- package/build/src/runtime/http-engine/certificates/index.js.map +1 -0
- package/build/src/runtime/http-engine/compression/CompressionManager.d.ts +25 -0
- package/build/src/runtime/http-engine/compression/CompressionManager.d.ts.map +1 -0
- package/build/src/runtime/http-engine/compression/CompressionManager.js +89 -0
- package/build/src/runtime/http-engine/compression/CompressionManager.js.map +1 -0
- package/build/src/runtime/http-engine/compression/index.d.ts +2 -0
- package/build/src/runtime/http-engine/compression/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/compression/index.js +2 -0
- package/build/src/runtime/http-engine/compression/index.js.map +1 -0
- package/build/src/runtime/http-engine/connections/ConnectionManager.d.ts +57 -0
- package/build/src/runtime/http-engine/connections/ConnectionManager.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/ConnectionManager.js +78 -0
- package/build/src/runtime/http-engine/connections/ConnectionManager.js.map +1 -0
- package/build/src/runtime/http-engine/connections/DigestAuthHandler.d.ts +70 -0
- package/build/src/runtime/http-engine/connections/DigestAuthHandler.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/DigestAuthHandler.js +184 -0
- package/build/src/runtime/http-engine/connections/DigestAuthHandler.js.map +1 -0
- package/build/src/runtime/http-engine/connections/DirectConnection.d.ts +22 -0
- package/build/src/runtime/http-engine/connections/DirectConnection.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/DirectConnection.js +105 -0
- package/build/src/runtime/http-engine/connections/DirectConnection.js.map +1 -0
- package/build/src/runtime/http-engine/connections/ProxyAuthHandler.d.ts +60 -0
- package/build/src/runtime/http-engine/connections/ProxyAuthHandler.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/ProxyAuthHandler.js +138 -0
- package/build/src/runtime/http-engine/connections/ProxyAuthHandler.js.map +1 -0
- package/build/src/runtime/http-engine/connections/ProxyConnection.d.ts +14 -0
- package/build/src/runtime/http-engine/connections/ProxyConnection.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/ProxyConnection.js +47 -0
- package/build/src/runtime/http-engine/connections/ProxyConnection.js.map +1 -0
- package/build/src/runtime/http-engine/connections/TunnelConnection.d.ts +13 -0
- package/build/src/runtime/http-engine/connections/TunnelConnection.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/TunnelConnection.js +175 -0
- package/build/src/runtime/http-engine/connections/TunnelConnection.js.map +1 -0
- package/build/src/runtime/http-engine/connections/index.d.ts +7 -0
- package/build/src/runtime/http-engine/connections/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/index.js +7 -0
- package/build/src/runtime/http-engine/connections/index.js.map +1 -0
- package/build/src/runtime/http-engine/constants.d.ts +69 -0
- package/build/src/runtime/http-engine/constants.d.ts.map +1 -0
- package/build/src/runtime/http-engine/constants.js +90 -0
- package/build/src/runtime/http-engine/constants.js.map +1 -0
- package/build/src/runtime/http-engine/cookies/CookieProcessor.d.ts +5 -0
- package/build/src/runtime/http-engine/cookies/CookieProcessor.d.ts.map +1 -0
- package/build/src/runtime/http-engine/cookies/CookieProcessor.js +20 -0
- package/build/src/runtime/http-engine/cookies/CookieProcessor.js.map +1 -0
- package/build/src/runtime/http-engine/cookies/index.d.ts +2 -0
- package/build/src/runtime/http-engine/cookies/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/cookies/index.js +2 -0
- package/build/src/runtime/http-engine/cookies/index.js.map +1 -0
- package/build/src/runtime/http-engine/errors/HttpEngineErrors.d.ts +156 -0
- package/build/src/runtime/http-engine/errors/HttpEngineErrors.d.ts.map +1 -0
- package/build/src/runtime/http-engine/errors/HttpEngineErrors.js +227 -0
- package/build/src/runtime/http-engine/errors/HttpEngineErrors.js.map +1 -0
- package/build/src/runtime/http-engine/errors/index.d.ts +2 -0
- package/build/src/runtime/http-engine/errors/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/errors/index.js +2 -0
- package/build/src/runtime/http-engine/errors/index.js.map +1 -0
- package/build/src/runtime/http-engine/message/MessageBuilder.d.ts +66 -0
- package/build/src/runtime/http-engine/message/MessageBuilder.d.ts.map +1 -0
- package/build/src/runtime/http-engine/message/MessageBuilder.js +161 -0
- package/build/src/runtime/http-engine/message/MessageBuilder.js.map +1 -0
- package/build/src/runtime/http-engine/message/MessageProcessor.d.ts +27 -0
- package/build/src/runtime/http-engine/message/MessageProcessor.d.ts.map +1 -0
- package/build/src/runtime/http-engine/message/MessageProcessor.js +51 -0
- package/build/src/runtime/http-engine/message/MessageProcessor.js.map +1 -0
- package/build/src/runtime/http-engine/message/index.d.ts +3 -0
- package/build/src/runtime/http-engine/message/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/message/index.js +3 -0
- package/build/src/runtime/http-engine/message/index.js.map +1 -0
- package/build/src/runtime/http-engine/ntlm/NtlmAuth.d.ts +2 -8
- package/build/src/runtime/http-engine/ntlm/NtlmAuth.d.ts.map +1 -1
- package/build/src/runtime/http-engine/ntlm/NtlmAuth.js +11 -5
- package/build/src/runtime/http-engine/ntlm/NtlmAuth.js.map +1 -1
- package/build/src/runtime/http-engine/ntlm/NtlmMessage.js +6 -6
- package/build/src/runtime/http-engine/ntlm/NtlmMessage.js.map +1 -1
- package/build/src/runtime/http-engine/parsers/BodyParser.d.ts +39 -0
- package/build/src/runtime/http-engine/parsers/BodyParser.d.ts.map +1 -0
- package/build/src/runtime/http-engine/parsers/BodyParser.js +145 -0
- package/build/src/runtime/http-engine/parsers/BodyParser.js.map +1 -0
- package/build/src/runtime/http-engine/parsers/HeadersParser.d.ts +29 -0
- package/build/src/runtime/http-engine/parsers/HeadersParser.d.ts.map +1 -0
- package/build/src/runtime/http-engine/parsers/HeadersParser.js +88 -0
- package/build/src/runtime/http-engine/parsers/HeadersParser.js.map +1 -0
- package/build/src/runtime/http-engine/parsers/HttpResponseParser.d.ts +91 -0
- package/build/src/runtime/http-engine/parsers/HttpResponseParser.d.ts.map +1 -0
- package/build/src/runtime/http-engine/parsers/HttpResponseParser.js +236 -0
- package/build/src/runtime/http-engine/parsers/HttpResponseParser.js.map +1 -0
- package/build/src/runtime/http-engine/parsers/StatusParser.d.ts +20 -0
- package/build/src/runtime/http-engine/parsers/StatusParser.d.ts.map +1 -0
- package/build/src/runtime/http-engine/parsers/StatusParser.js +51 -0
- package/build/src/runtime/http-engine/parsers/StatusParser.js.map +1 -0
- package/build/src/runtime/http-engine/parsers/index.d.ts +5 -0
- package/build/src/runtime/http-engine/parsers/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/parsers/index.js +5 -0
- package/build/src/runtime/http-engine/parsers/index.js.map +1 -0
- package/build/src/runtime/http-engine/response/ResponseProcessor.d.ts +22 -0
- package/build/src/runtime/http-engine/response/ResponseProcessor.d.ts.map +1 -0
- package/build/src/runtime/http-engine/response/ResponseProcessor.js +25 -0
- package/build/src/runtime/http-engine/response/ResponseProcessor.js.map +1 -0
- package/build/src/runtime/http-engine/response/index.d.ts +2 -0
- package/build/src/runtime/http-engine/response/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/response/index.js +2 -0
- package/build/src/runtime/http-engine/response/index.js.map +1 -0
- package/build/src/runtime/http-engine/statistics/StatisticsProcessor.d.ts +7 -0
- package/build/src/runtime/http-engine/statistics/StatisticsProcessor.d.ts.map +1 -0
- package/build/src/runtime/http-engine/statistics/StatisticsProcessor.js +40 -0
- package/build/src/runtime/http-engine/statistics/StatisticsProcessor.js.map +1 -0
- package/build/src/runtime/http-engine/statistics/index.d.ts +2 -0
- package/build/src/runtime/http-engine/statistics/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/statistics/index.js +2 -0
- package/build/src/runtime/http-engine/statistics/index.js.map +1 -0
- package/build/src/runtime/http-engine/url/UrlProcessor.d.ts +24 -0
- package/build/src/runtime/http-engine/url/UrlProcessor.d.ts.map +1 -0
- package/build/src/runtime/http-engine/url/UrlProcessor.js +50 -0
- package/build/src/runtime/http-engine/url/UrlProcessor.js.map +1 -0
- package/build/src/runtime/http-engine/url/index.d.ts +2 -0
- package/build/src/runtime/http-engine/url/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/url/index.js +2 -0
- package/build/src/runtime/http-engine/url/index.js.map +1 -0
- package/build/src/runtime/http-runner/HttpRequestRunner.d.ts +3 -3
- package/build/src/runtime/http-runner/HttpRequestRunner.d.ts.map +1 -1
- package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -1
- package/build/src/runtime/node/InteropInterfaces.d.ts +3 -3
- package/build/src/runtime/node/InteropInterfaces.d.ts.map +1 -1
- package/build/src/runtime/node/InteropInterfaces.js.map +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.d.ts +2 -2
- package/build/src/runtime/node/ProjectRequestRunner.d.ts.map +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunner.d.ts.map +1 -1
- package/build/src/runtime/node/ProjectRunner.js +2 -2
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +24 -24
- package/package.json +2 -2
- package/src/lib/logging/DefaultLogger.ts +32 -0
- package/src/modeling/DomainModel.ts +11 -4
- package/src/models/ClientCertificate.ts +1 -1
- package/src/models/RequestConfig.ts +1 -1
- package/src/models/SerializableError.ts +1 -1
- package/src/proxy/RequestProxy.ts +2 -2
- package/src/runtime/http-engine/CoreEngine.ts +858 -893
- package/src/runtime/http-engine/PayloadSupport.ts +2 -1
- package/src/runtime/http-engine/auth/AuthManager.ts +242 -0
- package/src/runtime/http-engine/certificates/CertificateManager.ts +74 -0
- package/src/runtime/http-engine/compression/CompressionManager.ts +99 -0
- package/src/runtime/http-engine/connections/ConnectionManager.ts +123 -0
- package/src/runtime/http-engine/connections/DigestAuthHandler.ts +238 -0
- package/src/runtime/http-engine/connections/DirectConnection.ts +134 -0
- package/src/runtime/http-engine/connections/ProxyAuthHandler.ts +179 -0
- package/src/runtime/http-engine/connections/ProxyConnection.ts +55 -0
- package/src/runtime/http-engine/connections/TunnelConnection.ts +192 -0
- package/src/runtime/http-engine/constants.ts +103 -0
- package/src/runtime/http-engine/cookies/CookieProcessor.ts +25 -0
- package/src/runtime/http-engine/errors/HttpEngineErrors.ts +319 -0
- package/src/runtime/http-engine/message/MessageBuilder.ts +201 -0
- package/src/runtime/http-engine/message/MessageProcessor.ts +73 -0
- package/src/runtime/http-engine/ntlm/NtlmAuth.ts +16 -13
- package/src/runtime/http-engine/ntlm/NtlmMessage.ts +6 -6
- package/src/runtime/http-engine/parsers/BodyParser.ts +171 -0
- package/src/runtime/http-engine/parsers/HeadersParser.ts +103 -0
- package/src/runtime/http-engine/parsers/HttpResponseParser.ts +280 -0
- package/src/runtime/http-engine/parsers/StatusParser.ts +69 -0
- package/src/runtime/http-engine/response/ResponseProcessor.ts +46 -0
- package/src/runtime/http-engine/statistics/StatisticsProcessor.ts +52 -0
- package/src/runtime/http-engine/url/UrlProcessor.ts +55 -0
- package/src/runtime/http-runner/HttpRequestRunner.ts +3 -3
- package/src/runtime/node/InteropInterfaces.ts +3 -3
- package/src/runtime/node/ProjectRequestRunner.ts +2 -2
- package/src/runtime/node/ProjectRunner.ts +2 -2
- package/tests/servers/ProxyServer.ts +32 -19
- package/tests/servers/express-routes/ApiEndpoint.ts +24 -0
- package/tests/servers/express-routes/BasicAuthRoute.ts +36 -0
- package/tests/servers/express-routes/BearerAuthRoute.ts +35 -0
- package/tests/servers/express-routes/NTLMRoute.ts +2 -3
- package/tests/servers/express-routes/PostApi.ts +15 -2
- package/tests/servers/express-routes/RedirectsApi.ts +12 -1
- package/tests/servers/express-routes/ResponsesApi.ts +1 -1
- package/tests/servers/express-routes/StreamApi.ts +19 -0
- package/tests/servers/oauth2mock/ServerMock.js +1 -1
- package/tests/unit/modeling/domain_model_entities.spec.ts +306 -1
- package/tests/unit/runtime/http-engine/HttpResponseParser.spec.ts +337 -0
- package/tests/unit/runtime/http-engine/abort.spec.ts +4 -5
- package/tests/unit/runtime/http-engine/auth.spec.ts +7 -58
- package/tests/unit/runtime/http-engine/certificates/CertificateManager.spec.ts +482 -0
- package/tests/unit/runtime/http-engine/certificates.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/compression/CompressionManager.spec.ts +498 -0
- package/tests/unit/runtime/http-engine/compression.spec.ts +3 -72
- package/tests/unit/runtime/http-engine/connections/ConnectionManager.spec.ts +379 -0
- package/tests/unit/runtime/http-engine/connections/DigestAuthHandler.spec.ts +164 -0
- package/tests/unit/runtime/http-engine/core_engine.spec.ts +561 -0
- package/tests/unit/runtime/http-engine/engine_statuses.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/events.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/headers.spec.ts +2 -88
- package/tests/unit/runtime/http-engine/hosts.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/http-get.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/http-post.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/logger.spec.ts +0 -8
- package/tests/unit/runtime/http-engine/message.spec.ts +2 -194
- package/tests/unit/runtime/http-engine/params.spec.ts +4 -4
- package/tests/unit/runtime/http-engine/proxy.spec.ts +15 -14
- package/tests/unit/runtime/http-engine/redirects.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/responses.spec.ts +170 -277
- package/tests/unit/runtime/http-engine/timeout.spec.ts +3 -3
- package/tests/unit/runtime/http-engine/timings.spec.ts +2 -2
- package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +25 -28
- package/tests/unit/runtime/runners/project_runner.spec.ts +2 -2
- package/tests/unit/runtime/runners/request_runner.spec.ts +2 -2
- package/build/src/runtime/http-engine/HttpEngine.d.ts +0 -311
- package/build/src/runtime/http-engine/HttpEngine.d.ts.map +0 -1
- package/build/src/runtime/http-engine/HttpEngine.js +0 -802
- package/build/src/runtime/http-engine/HttpEngine.js.map +0 -1
- package/src/runtime/http-engine/HttpEngine.ts +0 -952
- package/tests/unit/runtime/http-engine/connecting.spec.ts +0 -140
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainModel.js","sourceRoot":"","sources":["../../../src/modeling/DomainModel.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGxD,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AA+BnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;IACU,WAAW;sBAAS,aA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,GAAG,MAAyB,CAAA;gBACvC,MAAM,GAAG,KAAK,CAAC,iBAAiB,EAAE,CAAA;YACpC,CAAC;YACD,MAAM,CAAC,IAAI,CAAC;gBACV,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG;gBAClB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC;gBACpD,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;aACrB,CAAC,CAAA;YACF,OAAO,MAAM,CAAC,OAAO,EAAE,CAAA;QACzB,CAAC;QAED;;;;;;;;;;WAUG;QACH,SAAS;YACP,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;QAC/B,CAAC;QAEO,WAAW,CAAC,GAAW;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;QAC9D,CAAC;QAED;;;;;;WAMG;QACH,SAAS,CAAC,GAAW;YACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACrB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;YACvC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,KAAK,CAAA;YACd,CAAC;YACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAA;YACb,CAAC;YACD,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,OAAQ,MAA0B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QACnD,CAAC;;;SAxVU,WAAW","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainEntityKind, DomainModelKind } from '../models/kinds.js'\nimport { DomainElement, DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange } from './observed.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { FileBreadcrumb } from '../models/store/File.js'\nimport { DomainEntity, type DomainEntitySchema } from './DomainEntity.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { AttachException } from '../exceptions/attach_exception.js'\nimport { DetachException } from '../exceptions/detach_exception.js'\n\nexport interface ModelOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'entity'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainModelSchema extends DomainElementSchema {\n kind: typeof DomainModelKind\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The ordered list of entities in the schema.\n */\n fields?: ModelOrderedItem[]\n\n /**\n * Whether this model is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * Represents a data model within a data domain.\n *\n * A `DomainModel` groups related `DomainEntity` instances, providing a logical structure for organizing\n * data. It acts as a container for entities that share a common purpose or context.\n *\n * **Key Features:**\n *\n * - **Entity Container:** Holds a collection of `DomainEntity` instances.\n * - **Logical Grouping:** Organizes entities into meaningful groups.\n * - **Metadata:** Supports a description for the data model.\n * - **Namespace Integration:** Belongs to a `DomainNamespace`, creating a hierarchical structure.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainModel` is through\n * the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const ns = dataDomain.addNamespace({\n * key: 'myNamespace',\n * });\n * const userModel = ns.addModel({\n * key: 'userModel',\n * info: { name: 'User Model' },\n * });\n * ```\n */\nexport class DomainModel extends DomainElement {\n override kind: typeof DomainModelKind\n\n /**\n * The description of the domain model.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * The ordered list of entities in the schema.\n */\n accessor fields: ModelOrderedItem[]\n /**\n * Whether this model is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full data model schema with defaults.\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainModelSchema> = {}): DomainModelSchema {\n const { key = nanoid(), fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'New model' }).toJSON()\n const result: DomainModelSchema = {\n kind: DomainModelKind,\n key,\n info,\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n return result\n }\n\n /**\n * Creates a new model instance.\n *\n * You should use the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial model schema.\n */\n constructor(root: DataDomain, input?: Partial<DomainModelSchema>) {\n const init = DomainModel.createSchema(input)\n super(root, init.key)\n this.kind = DomainModelKind\n this.info = new Thing(init.info)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n /**\n * Generates a JSON representation of the data model.\n *\n * @returns A plain object representation of the\n * `DomainModel`.\n * @example\n * ```typescript\n * const json = userModel.toJSON();\n * console.log(json);\n * ```\n */\n toJSON(): DomainModelSchema {\n const result: DomainModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Returns the parent namespace where this data model\n * exists.\n *\n * @returns The parent `DomainNamespace`.\n * @throws Error When no parent is found.\n * @example\n * ```typescript\n * const parent = userModel.getParentInstance();\n * console.log(parent.key);\n * ```\n */\n getParentInstance(): DomainNamespace | DataDomain {\n const parentKey = this.root.graph.parent(this.key)\n if (!parentKey) {\n return this.root\n }\n return this.root.graph.node(parentKey) as DomainNamespace\n }\n\n /**\n * Adds a child entity to the current model.\n *\n * @param value The partial entity schema.\n * @returns The created entity instance.\n * @example\n * ```typescript\n * const entity = model.addEntity({\n * key: 'address',\n * info: { name: 'Address' },\n * })\n * ```\n */\n addEntity(input?: Partial<DomainEntitySchema>): DomainEntity {\n if (input && input.key && this.root.graph.hasNode(input.key)) {\n throw new Error(`Entity with key ${input?.key} already exists`)\n }\n const item = new DomainEntity(this.root, input)\n this.root.graph.setNode(item.key, item)\n this.root.graph.setParent(item.key, this.key)\n this.fields.push({\n key: item.key,\n type: 'entity',\n })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes an entity from the current model.\n *\n * @param key The key of the model to remove.\n * @throws {RemoveEntityException} If the model does not exist.\n * @example\n * ```typescript\n * model.removeEntity('address')\n * ```\n */\n removeEntity(key: string): void {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not a child of this model`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * Attaches an entity to the current model. It changes the parent of the entity\n * to the current model in the graph.\n *\n * The attached entity must be already a child of another model. It detaches the entity\n * from the previous model.\n *\n * @param key The key of the entity to attach.\n * @throws {AttachException} If the entity does not exist.\n * @throws {AttachException} If passed key doesn't belong to an entity.\n * @throws {AttachException} When the entity is already a child of the current model.\n * @throws {AttachException} If the entity is not in the same domain.\n * @example\n * ```typescript\n * model.attachEntity('address')\n * ```\n */\n attachEntity(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new AttachException(`Trying to attach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not a entity`)\n }\n if (node.domain.key !== this.root.key) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not in the same domain`)\n }\n const parent = node.getParentInstance() as DomainModel\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is already a child of this model`)\n }\n parent.detachEntity(key)\n this.fields.push({\n type: 'entity',\n key: key,\n })\n this.root.graph.setParent(key, this.key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches an entity from the current model. It changes the parent of the entity\n * to the root graph.\n * Unlike remove, it doesn't remove the entity from the graph nor notifies the change.\n * @param key The key of the entity to detach.\n * @throws {DetachException} If the entity does not exist.\n * @throws {DetachException} If passed key doesn't belong to an entity.\n * @throws {DetachException} When the entity is not a child of the current model.\n */\n detachEntity(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new DetachException(`Trying to detach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not a child of this model`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all entities.\n *\n * Note, it accounts for the order of the entities as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainEntity`.\n * @example\n * ```typescript\n * for (const entity of model.listEntities()) {\n * console.log(entity.key);\n * }\n * ```\n */\n *listEntities(): Generator<DomainEntity> {\n for (const { key, type } of this.fields) {\n if (type !== 'entity') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this model has any entities.\n *\n * @returns True if the model has entities.\n * @example\n * ```typescript\n * if (model.hasEntities()) {\n * // ...\n * }\n * ```\n */\n hasEntities(): boolean {\n return this.fields.some((item) => item.type === 'entity')\n }\n\n /**\n * Creates breadcrumbs from this data model to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.getLabel('Unnamed model'),\n kind: DomainModelKind,\n })\n let parent: DomainNamespace | DataDomain = this.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.getLabel('Unnamed namespace'),\n })\n const typed = parent as DomainNamespace\n parent = typed.getParentInstance()\n }\n result.push({\n key: this.root.key,\n name: this.root.info.getLabel('Unnamed data domain'),\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Checks if this model has any fields (entities).\n *\n * @returns True if the model has fields.\n * @example\n * ```typescript\n * if (model.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks whether the data model is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the data model is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this data model is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n if (parent === this.root) {\n return false\n }\n return (parent as DomainNamespace).isChildOf(key)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomainModel.js","sourceRoot":"","sources":["../../../src/modeling/DomainModel.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,O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CAAC;QAEO,WAAW,CAAC,GAAW;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;QAC9D,CAAC;QAED;;;;;;WAMG;QACH,SAAS,CAAC,GAAW;YACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACrB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;YACvC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,KAAK,CAAA;YACd,CAAC;YACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAA;YACb,CAAC;YACD,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,OAAQ,MAA0B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QACnD,CAAC;;;SA/VU,WAAW","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainEntityKind, DomainModelKind } from '../models/kinds.js'\nimport { DomainElement, DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange } from './observed.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { FileBreadcrumb } from '../models/store/File.js'\nimport { DomainEntity, type DomainEntitySchema } from './DomainEntity.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { AttachException } from '../exceptions/attach_exception.js'\nimport { DetachException } from '../exceptions/detach_exception.js'\n\nexport interface ModelOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'entity'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainModelSchema extends DomainElementSchema {\n kind: typeof DomainModelKind\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The ordered list of entities in the schema.\n */\n fields?: ModelOrderedItem[]\n\n /**\n * Whether this model is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * Represents a data model within a data domain.\n *\n * A `DomainModel` groups related `DomainEntity` instances, providing a logical structure for organizing\n * data. It acts as a container for entities that share a common purpose or context.\n *\n * **Key Features:**\n *\n * - **Entity Container:** Holds a collection of `DomainEntity` instances.\n * - **Logical Grouping:** Organizes entities into meaningful groups.\n * - **Metadata:** Supports a description for the data model.\n * - **Namespace Integration:** Belongs to a `DomainNamespace`, creating a hierarchical structure.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainModel` is through\n * the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const ns = dataDomain.addNamespace({\n * key: 'myNamespace',\n * });\n * const userModel = ns.addModel({\n * key: 'userModel',\n * info: { name: 'User Model' },\n * });\n * ```\n */\nexport class DomainModel extends DomainElement {\n override kind: typeof DomainModelKind\n\n /**\n * The description of the domain model.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * The ordered list of entities in the schema.\n */\n accessor fields: ModelOrderedItem[]\n /**\n * Whether this model is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full data model schema with defaults.\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainModelSchema> = {}): DomainModelSchema {\n const { key = nanoid(), fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'New model' }).toJSON()\n const result: DomainModelSchema = {\n kind: DomainModelKind,\n key,\n info,\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n return result\n }\n\n /**\n * Creates a new model instance.\n *\n * You should use the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial model schema.\n */\n constructor(root: DataDomain, input?: Partial<DomainModelSchema>) {\n const init = DomainModel.createSchema(input)\n super(root, init.key)\n this.kind = DomainModelKind\n this.info = new Thing(init.info)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n /**\n * Generates a JSON representation of the data model.\n *\n * @returns A plain object representation of the\n * `DomainModel`.\n * @example\n * ```typescript\n * const json = userModel.toJSON();\n * console.log(json);\n * ```\n */\n toJSON(): DomainModelSchema {\n const result: DomainModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Returns the parent namespace where this data model\n * exists.\n *\n * @returns The parent `DomainNamespace`.\n * @throws Error When no parent is found.\n * @example\n * ```typescript\n * const parent = userModel.getParentInstance();\n * console.log(parent.key);\n * ```\n */\n getParentInstance(): DomainNamespace | DataDomain {\n const parentKey = this.root.graph.parent(this.key)\n if (!parentKey) {\n return this.root\n }\n return this.root.graph.node(parentKey) as DomainNamespace\n }\n\n /**\n * Adds a child entity to the current model.\n *\n * @param value The partial entity schema.\n * @returns The created entity instance.\n * @example\n * ```typescript\n * const entity = model.addEntity({\n * key: 'address',\n * info: { name: 'Address' },\n * })\n * ```\n */\n addEntity(input?: Partial<DomainEntitySchema>): DomainEntity {\n if (input && input.key && this.root.graph.hasNode(input.key)) {\n throw new Error(`Entity with key ${input?.key} already exists`)\n }\n const item = new DomainEntity(this.root, input)\n this.root.graph.setNode(item.key, item)\n this.root.graph.setParent(item.key, this.key)\n this.fields.push({\n key: item.key,\n type: 'entity',\n })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes an entity from the current model.\n *\n * @param key The key of the model to remove.\n * @throws {RemoveEntityException} If the model does not exist.\n * @example\n * ```typescript\n * model.removeEntity('address')\n * ```\n */\n removeEntity(key: string): void {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not a child of this model`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * Attaches an entity to the current model. It changes the parent of the entity\n * to the current model in the graph.\n *\n * The attached entity must be already a child of another model. It detaches the entity\n * from the previous model.\n *\n * @param key The key of the entity to attach.\n * @throws {AttachException} If the entity does not exist.\n * @throws {AttachException} If passed key doesn't belong to an entity.\n * @throws {AttachException} When the entity is already a child of the current model.\n * @throws {AttachException} If the entity is not in the same domain.\n * @example\n * ```typescript\n * model.attachEntity('address')\n * ```\n */\n attachEntity(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new AttachException(`Trying to attach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not a entity`)\n }\n if (node.domain.key !== this.root.key) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not in the same domain`)\n }\n const parent = node.getParentInstance() as DomainModel\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is already a child of this model`)\n }\n parent.detachEntity(key)\n if (!this.fields.some((item) => item.key === key)) {\n this.fields.push({\n type: 'entity',\n key: key,\n })\n }\n this.root.graph.setParent(key, this.key)\n // verify that the entity is moved to the current model\n const graphParent = this.root.graph.parent(key)\n if (graphParent !== this.key) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not a child of this model`)\n }\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches an entity from the current model. It changes the parent of the entity\n * to the root graph.\n * Unlike remove, it doesn't remove the entity from the graph nor notifies the change.\n * @param key The key of the entity to detach.\n * @throws {DetachException} If the entity does not exist.\n * @throws {DetachException} If passed key doesn't belong to an entity.\n * @throws {DetachException} When the entity is not a child of the current model.\n */\n detachEntity(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new DetachException(`Trying to detach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not a child of this model`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all entities.\n *\n * Note, it accounts for the order of the entities as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainEntity`.\n * @example\n * ```typescript\n * for (const entity of model.listEntities()) {\n * console.log(entity.key);\n * }\n * ```\n */\n *listEntities(): Generator<DomainEntity> {\n for (const { key, type } of this.fields) {\n if (type !== 'entity') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this model has any entities.\n *\n * @returns True if the model has entities.\n * @example\n * ```typescript\n * if (model.hasEntities()) {\n * // ...\n * }\n * ```\n */\n hasEntities(): boolean {\n return this.fields.some((item) => item.type === 'entity')\n }\n\n /**\n * Creates breadcrumbs from this data model to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.getLabel('Unnamed model'),\n kind: DomainModelKind,\n })\n let parent: DomainNamespace | DataDomain = this.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.getLabel('Unnamed namespace'),\n })\n const typed = parent as DomainNamespace\n parent = typed.getParentInstance()\n }\n result.push({\n key: this.root.key,\n name: this.root.info.getLabel('Unnamed data domain'),\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Checks if this model has any fields (entities).\n *\n * @returns True if the model has fields.\n * @example\n * ```typescript\n * if (model.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks whether the data model is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the data model is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this data model is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n if (parent === this.root) {\n return false\n }\n return (parent as DomainNamespace).isChildOf(key)\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientCertificate.js","sourceRoot":"","sources":["../../../src/models/ClientCertificate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AASrC,MAAM,CAAC,MAAM,IAAI,GAAG,kBAAkB,CAAA;AAoHtC;;GAEG;AACH,MAAM,OAAO,WAAW;IACtB,IAAI,GAAG,IAAI,CAAA;IACX;;OAEG;IACH,GAAG,CAAQ;IACX;;OAEG;IACH,IAAI,CAAQ;IACZ;;;OAGG;IACH,OAAO,GAAG,CAAC,CAAA;IACX;;OAEG;IACH,IAAI,CAAiB;IACrB;;OAEG;IACH,IAAI,CAAkB;IACtB;;OAEG;IACH,OAAO,CAAmB;IAE1B;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CACZ,GAA0B,EAC1B,GAA0B,EAC1B,IAAI,GAAG,qBAA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I,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAoB;YAC9B,IAAI,EAAE,IAAI;YACV,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACxC,MAAM,KAAK,GAAG,MAAoC,CAAA;YAClD,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnD,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { base64ToBuffer, bufferToBase64 } from '../lib/Buffer.js'\nimport { nanoid } from '../nanoid.js'\nimport {\n Certificate as LegacyCertificate,\n ARCCertificateIndex,\n RequestCertificate,\n} from './legacy/models/ClientCertificate.js'\n\nexport type CertificateType = 'p12' | 'pem'\n\nexport const Kind = 'Core#Certificate'\n\nexport type CertificateDataFormat = string | ArrayBuffer | Uint8Array\n\n/**\n * Represents a single certificate object (cert/key)\n */\nexport interface ICertificateData {\n /**\n * The certificate to use.\n * The `p12` type certificate must be a Buffer.\n */\n data: CertificateDataFormat\n /**\n * A passphrase to use to unlock the certificate.\n */\n passphrase?: string\n /**\n * The original data type of the certificate. This is only used internally by the data store\n * to move between buffers and string values stored in the store.\n * Outside the internal procedure of the data store this\n * is always `undefined` and the `data` contains the original data format.\n */\n type?: 'buffer'\n}\n\nexport interface ICertificate {\n kind: typeof Kind\n /**\n * The data store key to refer.\n */\n key: string\n /**\n * The custom name of the certificate.\n */\n name: string\n /**\n * The timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created?: number\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n}\n\nexport interface IP12Certificate extends ICertificate {\n type: 'p12'\n}\n\n/**\n * Represents a complete certificate configuration required to make\n * an HTTP request.\n */\nexport interface IPemCertificate extends ICertificate {\n type: 'pem'\n /**\n * The key for the `pem` type certificate.\n */\n certKey: ICertificateData\n}\n\nexport type HttpCertificate = IP12Certificate | IPemCertificate | ICertificate\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IPemCreateOptions {\n type: 'p12'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * The key contents.\n */\n key: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the key.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IP12CreateOptions {\n type: 'pem'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the certificate.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport type ICertificateCreateOptions = IPemCreateOptions | IP12CreateOptions\n\n/**\n * A class that represents a certificate in the system\n */\nexport class Certificate {\n kind = Kind\n /**\n * The data store key to refer.\n */\n key: string\n /**\n * Custom name of the certificate.\n */\n name: string\n /**\n * Timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created = 0\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n /**\n * The key for the `pem` type certificate.\n */\n certKey?: ICertificateData\n\n /**\n * Creates a new certificate instance for a PEM key\n *\n * @param pem The certificate contents\n * @param key The key contents\n * @param name The certificate name\n * @param keyPassphrase The key passphrase\n */\n static fromPem(\n pem: CertificateDataFormat,\n key: CertificateDataFormat,\n name = 'New PEM certificate',\n keyPassphrase?: string\n ): Certificate {\n const init: IPemCertificate = {\n kind: Kind,\n cert: {\n data: pem,\n },\n certKey: {\n data: key,\n },\n key: nanoid(),\n name,\n type: 'pem',\n created: Date.now(),\n }\n if (keyPassphrase) {\n init.certKey.passphrase = keyPassphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a new certificate instance for a P12 key\n *\n * @param cert The certificate contents\n * @param name The certificate name\n * @param passphrase The key passphrase\n */\n static fromP12(cert: CertificateDataFormat, name = 'New P12 certificate', passphrase?: string): Certificate {\n const init: IP12Certificate = {\n kind: Kind,\n cert: {\n data: cert,\n },\n key: nanoid(),\n name,\n type: 'p12',\n created: Date.now(),\n }\n if (passphrase) {\n init.cert.passphrase = passphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a certificate object from the ARC's legacy certificate definition.\n *\n * @param index The legacy certificate index object. If it has set `_id` it will be used as the `key`.\n * @param index The certificate data object as read from the data store. Do not restore the data\n * to its original format.\n */\n static fromLegacy(index: ARCCertificateIndex, cert: RequestCertificate): Certificate {\n const { name = '', type, created = Date.now(), _id = nanoid() } = index\n if (type === 'pem') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const key = Array.isArray(cert.key) ? cert.key[0] : (cert.key as LegacyCertificate)\n if (!key) {\n throw new Error(`Unable to create a PEM certificate without the key.`)\n }\n const init: IPemCertificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n certKey: key as ICertificateData,\n key: _id,\n name,\n type: 'pem',\n created,\n }\n return new Certificate(init)\n } else if (type === 'p12') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const init: IP12Certificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n key: _id,\n name,\n type: 'p12',\n created,\n }\n return new Certificate(init)\n }\n throw new Error(`Unable to create a certificate. Unknown type: ${type}.`)\n }\n\n constructor(certificate: HttpCertificate) {\n const { type, cert, key = nanoid(), name = '', created = Date.now() } = certificate\n this.key = key\n this.name = name\n this.type = type\n this.cert = Certificate.fromStore(cert)\n this.created = created\n if (type === 'pem') {\n const typed = certificate as IPemCertificate\n this.certKey = Certificate.fromStore(typed.certKey)\n }\n }\n\n /**\n * When needed it reads the certificate's original format.\n * @param data The certificate data.\n * @returns The restored certificate.\n */\n static fromStore(data: ICertificateData): ICertificateData {\n if (data.type) {\n delete data.type\n const content = data.data as string\n data.data = base64ToBuffer(content)\n }\n return data\n }\n\n /**\n * Prepares certificate object to be stored in the data store.\n * If the `data` property is not string then it assumes buffer (either\n * Node's or ArrayBuffer). In this case it converts buffer to base64 string.\n * It also adds `type` property set to `buffer` for the `fromStore()`\n * function to recognize what to do with the data.\n *\n * Note, for optimization, PEM keys should be strings as the content of the\n * certificate is already a base62 string. To spare double base64 conversion\n * use string data.\n *\n * @param data The certificate data object.\n * @throws When data is not set\n */\n static toStore(data: ICertificateData): ICertificateData {\n if (!data) {\n throw new Error('Certificate data is missing.')\n }\n if (!data.data) {\n throw new Error('Certificate content not set.')\n }\n if (typeof data.data !== 'string') {\n data.type = 'buffer'\n const buff = data.data as ArrayBuffer | Uint8Array\n data.data = bufferToBase64(buff)\n }\n return data\n }\n\n toJSON(): HttpCertificate {\n const result: HttpCertificate = {\n kind: Kind,\n key: this.key,\n cert: Certificate.toStore(this.cert),\n name: this.name,\n type: this.type,\n created: this.created,\n }\n\n if (this.type === 'pem' && this.certKey) {\n const typed = result as unknown as IPemCertificate\n typed.certKey = Certificate.toStore(this.certKey)\n }\n\n return result\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ClientCertificate.js","sourceRoot":"","sources":["../../../src/models/ClientCertificate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAS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M,CAAC,OAAO,CAAC,IAAsB;QACnC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;QACjD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;QACjD,CAAC;QACD,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClC,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA;YACpB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAgC,CAAA;YAClD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAoB;YAC9B,IAAI,EAAE,IAAI;YACV,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACxC,MAAM,KAAK,GAAG,MAAoC,CAAA;YAClD,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnD,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { base64ToBuffer, bufferToBase64 } from '../lib/Buffer.js'\nimport { nanoid } from '../nanoid.js'\nimport {\n Certificate as LegacyCertificate,\n ARCCertificateIndex,\n RequestCertificate,\n} from './legacy/models/ClientCertificate.js'\n\nexport type CertificateType = 'p12' | 'pem'\n\nexport const Kind = 'Core#Certificate'\n\nexport type CertificateDataFormat = string | ArrayBuffer | Uint8Array\n\n/**\n * Represents a single certificate object (cert/key)\n */\nexport interface ICertificateData {\n /**\n * The certificate to use.\n * The `p12` type certificate must be a Buffer.\n */\n data: CertificateDataFormat\n /**\n * A passphrase to use to unlock the certificate.\n */\n passphrase?: string\n /**\n * The original data type of the certificate. This is only used internally by the data store\n * to move between buffers and string values stored in the store.\n * Outside the internal procedure of the data store this\n * is always `undefined` and the `data` contains the original data format.\n */\n type?: 'buffer'\n}\n\nexport interface ICertificate {\n kind: typeof Kind\n /**\n * The data store key to refer under which this certificate is stored.\n */\n key: string\n /**\n * The custom name of the certificate.\n */\n name: string\n /**\n * The timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created?: number\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n}\n\nexport interface IP12Certificate extends ICertificate {\n type: 'p12'\n}\n\n/**\n * Represents a complete certificate configuration required to make\n * an HTTP request.\n */\nexport interface IPemCertificate extends ICertificate {\n type: 'pem'\n /**\n * The key for the `pem` type certificate.\n */\n certKey: ICertificateData\n}\n\nexport type HttpCertificate = IP12Certificate | IPemCertificate | ICertificate\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IPemCreateOptions {\n type: 'p12'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * The key contents.\n */\n key: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the key.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IP12CreateOptions {\n type: 'pem'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the certificate.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport type ICertificateCreateOptions = IPemCreateOptions | IP12CreateOptions\n\n/**\n * A class that represents a certificate in the system\n */\nexport class Certificate {\n kind = Kind\n /**\n * The data store key to refer.\n */\n key: string\n /**\n * Custom name of the certificate.\n */\n name: string\n /**\n * Timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created = 0\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n /**\n * The key for the `pem` type certificate.\n */\n certKey?: ICertificateData\n\n /**\n * Creates a new certificate instance for a PEM key\n *\n * @param pem The certificate contents\n * @param key The key contents\n * @param name The certificate name\n * @param keyPassphrase The key passphrase\n */\n static fromPem(\n pem: CertificateDataFormat,\n key: CertificateDataFormat,\n name = 'New PEM certificate',\n keyPassphrase?: string\n ): Certificate {\n const init: IPemCertificate = {\n kind: Kind,\n cert: {\n data: pem,\n },\n certKey: {\n data: key,\n },\n key: nanoid(),\n name,\n type: 'pem',\n created: Date.now(),\n }\n if (keyPassphrase) {\n init.certKey.passphrase = keyPassphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a new certificate instance for a P12 key\n *\n * @param cert The certificate contents\n * @param name The certificate name\n * @param passphrase The key passphrase\n */\n static fromP12(cert: CertificateDataFormat, name = 'New P12 certificate', passphrase?: string): Certificate {\n const init: IP12Certificate = {\n kind: Kind,\n cert: {\n data: cert,\n },\n key: nanoid(),\n name,\n type: 'p12',\n created: Date.now(),\n }\n if (passphrase) {\n init.cert.passphrase = passphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a certificate object from the ARC's legacy certificate definition.\n *\n * @param index The legacy certificate index object. If it has set `_id` it will be used as the `key`.\n * @param index The certificate data object as read from the data store. Do not restore the data\n * to its original format.\n */\n static fromLegacy(index: ARCCertificateIndex, cert: RequestCertificate): Certificate {\n const { name = '', type, created = Date.now(), _id = nanoid() } = index\n if (type === 'pem') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const key = Array.isArray(cert.key) ? cert.key[0] : (cert.key as LegacyCertificate)\n if (!key) {\n throw new Error(`Unable to create a PEM certificate without the key.`)\n }\n const init: IPemCertificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n certKey: key as ICertificateData,\n key: _id,\n name,\n type: 'pem',\n created,\n }\n return new Certificate(init)\n } else if (type === 'p12') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const init: IP12Certificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n key: _id,\n name,\n type: 'p12',\n created,\n }\n return new Certificate(init)\n }\n throw new Error(`Unable to create a certificate. Unknown type: ${type}.`)\n }\n\n constructor(certificate: HttpCertificate) {\n const { type, cert, key = nanoid(), name = '', created = Date.now() } = certificate\n this.key = key\n this.name = name\n this.type = type\n this.cert = Certificate.fromStore(cert)\n this.created = created\n if (type === 'pem') {\n const typed = certificate as IPemCertificate\n this.certKey = Certificate.fromStore(typed.certKey)\n }\n }\n\n /**\n * When needed it reads the certificate's original format.\n * @param data The certificate data.\n * @returns The restored certificate.\n */\n static fromStore(data: ICertificateData): ICertificateData {\n if (data.type) {\n delete data.type\n const content = data.data as string\n data.data = base64ToBuffer(content)\n }\n return data\n }\n\n /**\n * Prepares certificate object to be stored in the data store.\n * If the `data` property is not string then it assumes buffer (either\n * Node's or ArrayBuffer). In this case it converts buffer to base64 string.\n * It also adds `type` property set to `buffer` for the `fromStore()`\n * function to recognize what to do with the data.\n *\n * Note, for optimization, PEM keys should be strings as the content of the\n * certificate is already a base62 string. To spare double base64 conversion\n * use string data.\n *\n * @param data The certificate data object.\n * @throws When data is not set\n */\n static toStore(data: ICertificateData): ICertificateData {\n if (!data) {\n throw new Error('Certificate data is missing.')\n }\n if (!data.data) {\n throw new Error('Certificate content not set.')\n }\n if (typeof data.data !== 'string') {\n data.type = 'buffer'\n const buff = data.data as ArrayBuffer | Uint8Array\n data.data = bufferToBase64(buff)\n }\n return data\n }\n\n toJSON(): HttpCertificate {\n const result: HttpCertificate = {\n kind: Kind,\n key: this.key,\n cert: Certificate.toStore(this.cert),\n name: this.name,\n type: this.type,\n created: this.created,\n }\n\n if (this.type === 'pem' && this.certKey) {\n const typed = result as unknown as IPemCertificate\n typed.certKey = Certificate.toStore(this.certKey)\n }\n\n return result\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestConfig.js","sourceRoot":"","sources":["../../../src/models/RequestConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAa,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGnD,MAAM,CAAC,MAAM,IAAI,GAAG,oBAAoB,CAAA;AAyFxC,MAAM,OAAO,aAAa;IACxB,IAAI,GAAG,IAAI,CAAA;IACX;;OAEG;IACH,OAAO,GAAG,KAAK,CAAA;IACf;;;OAGG;IACH,OAAO,CAAS;IAChB;;OAEG;IACH,eAAe,CAAU;IACzB;;OAEG;IACH,oBAAoB,CAAU;IAC9B;;OAEG;IACH,KAAK,CAAa;IAClB;;OAEG;IACH,oBAAoB,CAAU;IAC9B;;OAEG;IACH,cAAc,CAAU;IACxB;;;;;OAKG;IACH,gBAAgB,CAAS;IACzB;;;;OAIG;IACH,aAAa,CAAS;IACtB;;;OAGG;IACH,SAAS,CAAa;IACtB;;;OAGG;IACH,KAAK,CAAS;IACd;;OAEG;IACH,aAAa,CAAS;IACtB;;OAEG;IACH,aAAa,CAAS;IACtB;;;;OAIG;IACH,gBAAgB,CAAS;IAEzB;;;OAGG;IACH,MAAM,CAAc;IAEpB,MAAM,CAAC,YAAY;QACjB,OAAO,IAAI,aAAa,CAAC;YACvB,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,EAAE;YACX,eAAe,EAAE,IAAI;YACrB,oBAAoB,EAAE,KAAK;YAC3B,oBAAoB,EAAE,KAAK;SAC5B,CAAC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AAI,CAAC,gBAAgB,CAAA;QACjD,CAAC;QACD,gCAAgC;QAChC,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { IHostRule, HostRule } from './HostRule.js'\nimport { IProperty, Property } from './Property.js'\nimport { RequestConfig as LegacyConfig } from './legacy/request/ArcRequest.js'\n\nexport const Kind = 'Core#RequestConfig'\n\nexport interface IRequestBaseConfig {\n /**\n * Request timeout in milliseconds\n * Default no timeout.\n */\n timeout?: number\n /**\n * When false the request object won't follow redirects.\n * @default true\n */\n followRedirects?: boolean\n /**\n * Hosts table configuration.\n */\n hosts?: IHostRule[]\n /**\n * A limit of characters to include into the `sentHttpMessage` property\n * of the request object. 0 to disable limit. Default to 2048.\n * @default 2048\n */\n sentMessageLimit?: number\n /**\n * When set the request adds `accept` and `user-agent` headers if missing.\n */\n defaultHeaders?: boolean\n /**\n * Default `user-agent` header to be used with request when `defaultHeaders`\n * is set.\n *\n * @default api-client\n */\n defaultUserAgent?: string\n /**\n * Default `accept` header to be used with request when `defaultHeaders`\n * is set.\n * @default *\\/*\n */\n defaultAccept?: string\n /**\n * The proxy URI to connect to when making the connection.\n * It should contain the host and port. Default port is 80.\n */\n proxy?: string\n /**\n * The proxy authorization username value.\n */\n proxyUsername?: string\n /**\n * The proxy authorization password value.\n */\n proxyPassword?: string\n /**\n * THe type of proxy authentication to use.\n */\n proxyAuthorization?: 'Basic'\n /**\n * Whether the processor should validate certificates.\n */\n validateCertificates?: boolean\n\n /**\n * Optional signal from an `AbortController`.\n * This is populated only when executing a request. This value is opaque for the data store.\n */\n signal?: AbortSignal\n}\n\n/**\n * API Client request `config` object.\n */\nexport interface IRequestConfig extends IRequestBaseConfig {\n kind: typeof Kind\n /**\n * Whether the processor should use this configuration.\n */\n enabled: boolean\n /**\n * Does not set session (saved) cookies to this request\n */\n ignoreSessionCookies?: boolean\n /**\n * A list of variables to use with the request.\n * Note, request variables override application and Folder variables.\n */\n variables?: IProperty[]\n}\n\nexport class RequestConfig {\n kind = Kind\n /**\n * Whether the processor should use this configuration.\n */\n enabled = false\n /**\n * The request timeout.\n * Default no timeout.\n */\n timeout?: number\n /**\n * Whether or not the request should follow redirects.\n */\n followRedirects?: boolean\n /**\n * Does not set session (saved) cookies to this request\n */\n ignoreSessionCookies?: boolean\n /**\n * Hosts table configuration.\n */\n hosts?: HostRule[]\n /**\n * Whether the processor should validate certificates.\n */\n validateCertificates?: boolean\n /**\n * Whether to put a \"default\" headers (accept and user agent)\n */\n defaultHeaders?: boolean\n /**\n * Default `user-agent` header to be used with request when `defaultHeaders`\n * is set.\n *\n * @default api-client\n */\n defaultUserAgent?: string\n /**\n * Default `accept` header to be used with request when `defaultHeaders`\n * is set.\n * @default *\\/*\n */\n defaultAccept?: string\n /**\n * A list of variables to use with the request.\n * Note, request variables override application and workspace variables.\n */\n variables?: Property[]\n /**\n * The proxy URI to connect to when making the connection.\n * It should contain the host and port. Default port is 80.\n */\n proxy?: string\n /**\n * The proxy authorization username value.\n */\n proxyUsername?: string\n /**\n * The proxy authorization password value.\n */\n proxyPassword?: string\n /**\n * A limit of characters to include into the `sentHttpMessage` property\n * of the request object. 0 to disable limit. Default to 2048.\n * @default 2048\n */\n sentMessageLimit?: number\n\n /**\n * Optional signal from an `AbortController`.\n * This is populated only when executing a request. This value is opaque for the data store.\n */\n signal?: AbortSignal\n\n static withDefaults(): RequestConfig {\n return new RequestConfig({\n kind: Kind,\n enabled: true,\n timeout: 90,\n followRedirects: true,\n ignoreSessionCookies: false,\n validateCertificates: false,\n })\n }\n\n static fromLegacy(config: LegacyConfig): RequestConfig {\n const { enabled, defaultHeaders, followRedirects, ignoreSessionCookies, timeout, validateCertificates } = config\n const init: IRequestConfig = {\n kind: Kind,\n enabled,\n }\n if (typeof defaultHeaders === 'boolean') {\n init.defaultHeaders = defaultHeaders\n }\n if (typeof followRedirects === 'boolean') {\n init.followRedirects = followRedirects\n }\n if (typeof ignoreSessionCookies === 'boolean') {\n init.ignoreSessionCookies = ignoreSessionCookies\n }\n if (typeof validateCertificates === 'boolean') {\n init.validateCertificates = validateCertificates\n }\n if (typeof timeout === 'number') {\n init.timeout = timeout\n }\n return new RequestConfig(init)\n }\n\n /**\n * @param input The request configuration definition used to restore the state.\n */\n constructor(input?: string | IRequestConfig) {\n let init: IRequestConfig\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: Kind,\n enabled: false,\n }\n }\n this.new(init)\n }\n\n /**\n * Creates a new request configuration clearing anything that is so far defined.\n */\n new(init: IRequestConfig): void {\n const {\n enabled,\n followRedirects,\n ignoreSessionCookies,\n validateCertificates,\n defaultHeaders,\n timeout,\n hosts,\n variables,\n defaultAccept,\n defaultUserAgent,\n proxy,\n proxyPassword,\n proxyUsername,\n sentMessageLimit,\n signal,\n } = init\n this.kind = Kind\n if (typeof enabled === 'boolean') {\n this.enabled = enabled\n } else {\n this.enabled = false\n }\n if (typeof followRedirects === 'boolean') {\n this.followRedirects = followRedirects\n } else {\n this.followRedirects = undefined\n }\n if (typeof ignoreSessionCookies === 'boolean') {\n this.ignoreSessionCookies = ignoreSessionCookies\n } else {\n this.ignoreSessionCookies = undefined\n }\n if (typeof validateCertificates === 'boolean') {\n this.validateCertificates = validateCertificates\n } else {\n this.validateCertificates = undefined\n }\n if (typeof defaultHeaders === 'boolean') {\n this.defaultHeaders = defaultHeaders\n } else {\n this.defaultHeaders = undefined\n }\n if (typeof timeout === 'number') {\n this.timeout = timeout\n } else {\n this.timeout = undefined\n }\n if (Array.isArray(hosts)) {\n this.hosts = hosts.map((i) => new HostRule(i))\n } else {\n this.hosts = []\n }\n if (Array.isArray(variables)) {\n this.variables = variables.map((i) => new Property(i))\n } else {\n this.variables = []\n }\n if (typeof defaultAccept === 'string') {\n this.defaultAccept = defaultAccept\n } else {\n this.defaultAccept = undefined\n }\n if (typeof defaultUserAgent === 'string') {\n this.defaultUserAgent = defaultUserAgent\n } else {\n this.defaultUserAgent = undefined\n }\n if (typeof proxy === 'string') {\n this.proxy = proxy\n } else {\n this.proxy = undefined\n }\n if (typeof proxyUsername === 'string') {\n this.proxyUsername = proxyUsername\n } else {\n this.proxyUsername = undefined\n }\n if (typeof proxyPassword === 'string') {\n this.proxyPassword = proxyPassword\n } else {\n this.proxyPassword = undefined\n }\n if (typeof sentMessageLimit === 'number') {\n this.sentMessageLimit = sentMessageLimit\n } else {\n this.sentMessageLimit = undefined\n }\n if (signal) {\n this.signal = signal\n } else {\n this.signal = undefined\n }\n }\n\n toJSON(): IRequestConfig {\n const result: IRequestConfig = {\n kind: Kind,\n enabled: this.enabled,\n }\n if (typeof this.followRedirects === 'boolean') {\n result.followRedirects = this.followRedirects\n }\n if (typeof this.ignoreSessionCookies === 'boolean') {\n result.ignoreSessionCookies = this.ignoreSessionCookies\n }\n if (typeof this.validateCertificates === 'boolean') {\n result.validateCertificates = this.validateCertificates\n }\n if (typeof this.defaultHeaders === 'boolean') {\n result.defaultHeaders = this.defaultHeaders\n }\n if (typeof this.timeout === 'number') {\n result.timeout = this.timeout\n }\n if (Array.isArray(this.hosts) && this.hosts.length) {\n result.hosts = this.hosts.map((i) => i.toJSON())\n }\n if (Array.isArray(this.variables) && this.variables.length) {\n result.variables = this.variables.map((i) => i.toJSON())\n }\n if (this.defaultAccept) {\n result.defaultAccept = this.defaultAccept\n }\n if (this.defaultUserAgent) {\n result.defaultUserAgent = this.defaultUserAgent\n }\n if (this.proxy) {\n result.proxy = this.proxy\n }\n if (this.proxyUsername) {\n result.proxyUsername = this.proxyUsername\n }\n if (this.proxyPassword) {\n result.proxyPassword = this.proxyPassword\n }\n if (this.sentMessageLimit) {\n result.sentMessageLimit = this.sentMessageLimit\n }\n // DO NOT put the `signal` here.\n return result\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RequestConfig.js","sourceRoot":"","sources":["../../../src/models/RequestConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EA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AAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YAC3D,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAA;QAC1D,CAAC;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAA;QAC3C,CAAC;QACD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAA;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QAC3B,CAAC;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAA;QAC3C,CAAC;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAA;QAC3C,CAAC;QACD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAA;QACjD,CAAC;QACD,gCAAgC;QAChC,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { IHostRule, HostRule } from './HostRule.js'\nimport { IProperty, Property } from './Property.js'\nimport { RequestConfig as LegacyConfig } from './legacy/request/ArcRequest.js'\n\nexport const Kind = 'Core#RequestConfig'\n\nexport interface IRequestBaseConfig {\n /**\n * Request timeout in milliseconds\n * Default no timeout.\n */\n timeout?: number\n /**\n * When false the request object won't follow redirects.\n * @default true\n */\n followRedirects?: boolean\n /**\n * Hosts table configuration.\n */\n hosts?: IHostRule[]\n /**\n * A limit of characters to include into the `sentHttpMessage` property\n * of the request object. 0 to disable limit. Default to 2048.\n * @default 2048\n */\n sentMessageLimit?: number\n /**\n * When set the request adds `accept` and `user-agent` headers if missing.\n */\n defaultHeaders?: boolean\n /**\n * Default `user-agent` header to be used with request when `defaultHeaders`\n * is set.\n *\n * @default api-client\n */\n defaultUserAgent?: string\n /**\n * Default `accept` header to be used with request when `defaultHeaders`\n * is set.\n * @default *\\/*\n */\n defaultAccept?: string\n /**\n * The proxy URI to connect to when making the connection.\n * It should contain the host and port. Default port is 80.\n */\n proxy?: string\n /**\n * The proxy authorization username value.\n */\n proxyUsername?: string\n /**\n * The proxy authorization password value.\n */\n proxyPassword?: string\n /**\n * The type of proxy authentication to use.\n */\n proxyAuthorization?: 'Basic'\n /**\n * Whether the processor should validate certificates.\n */\n validateCertificates?: boolean\n\n /**\n * Optional signal from an `AbortController`.\n * This is populated only when executing a request. This value is opaque for the data store.\n */\n signal?: AbortSignal\n}\n\n/**\n * API Client request `config` object.\n */\nexport interface IRequestConfig extends IRequestBaseConfig {\n kind: typeof Kind\n /**\n * Whether the processor should use this configuration.\n */\n enabled: boolean\n /**\n * Does not set session (saved) cookies to this request\n */\n ignoreSessionCookies?: boolean\n /**\n * A list of variables to use with the request.\n * Note, request variables override application and Folder variables.\n */\n variables?: IProperty[]\n}\n\nexport class RequestConfig {\n kind = Kind\n /**\n * Whether the processor should use this configuration.\n */\n enabled = false\n /**\n * The request timeout.\n * Default no timeout.\n */\n timeout?: number\n /**\n * Whether or not the request should follow redirects.\n */\n followRedirects?: boolean\n /**\n * Does not set session (saved) cookies to this request\n */\n ignoreSessionCookies?: boolean\n /**\n * Hosts table configuration.\n */\n hosts?: HostRule[]\n /**\n * Whether the processor should validate certificates.\n */\n validateCertificates?: boolean\n /**\n * Whether to put a \"default\" headers (accept and user agent)\n */\n defaultHeaders?: boolean\n /**\n * Default `user-agent` header to be used with request when `defaultHeaders`\n * is set.\n *\n * @default api-client\n */\n defaultUserAgent?: string\n /**\n * Default `accept` header to be used with request when `defaultHeaders`\n * is set.\n * @default *\\/*\n */\n defaultAccept?: string\n /**\n * A list of variables to use with the request.\n * Note, request variables override application and workspace variables.\n */\n variables?: Property[]\n /**\n * The proxy URI to connect to when making the connection.\n * It should contain the host and port. Default port is 80.\n */\n proxy?: string\n /**\n * The proxy authorization username value.\n */\n proxyUsername?: string\n /**\n * The proxy authorization password value.\n */\n proxyPassword?: string\n /**\n * A limit of characters to include into the `sentHttpMessage` property\n * of the request object. 0 to disable limit. Default to 2048.\n * @default 2048\n */\n sentMessageLimit?: number\n\n /**\n * Optional signal from an `AbortController`.\n * This is populated only when executing a request. This value is opaque for the data store.\n */\n signal?: AbortSignal\n\n static withDefaults(): RequestConfig {\n return new RequestConfig({\n kind: Kind,\n enabled: true,\n timeout: 90,\n followRedirects: true,\n ignoreSessionCookies: false,\n validateCertificates: false,\n })\n }\n\n static fromLegacy(config: LegacyConfig): RequestConfig {\n const { enabled, defaultHeaders, followRedirects, ignoreSessionCookies, timeout, validateCertificates } = config\n const init: IRequestConfig = {\n kind: Kind,\n enabled,\n }\n if (typeof defaultHeaders === 'boolean') {\n init.defaultHeaders = defaultHeaders\n }\n if (typeof followRedirects === 'boolean') {\n init.followRedirects = followRedirects\n }\n if (typeof ignoreSessionCookies === 'boolean') {\n init.ignoreSessionCookies = ignoreSessionCookies\n }\n if (typeof validateCertificates === 'boolean') {\n init.validateCertificates = validateCertificates\n }\n if (typeof timeout === 'number') {\n init.timeout = timeout\n }\n return new RequestConfig(init)\n }\n\n /**\n * @param input The request configuration definition used to restore the state.\n */\n constructor(input?: string | IRequestConfig) {\n let init: IRequestConfig\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: Kind,\n enabled: false,\n }\n }\n this.new(init)\n }\n\n /**\n * Creates a new request configuration clearing anything that is so far defined.\n */\n new(init: IRequestConfig): void {\n const {\n enabled,\n followRedirects,\n ignoreSessionCookies,\n validateCertificates,\n defaultHeaders,\n timeout,\n hosts,\n variables,\n defaultAccept,\n defaultUserAgent,\n proxy,\n proxyPassword,\n proxyUsername,\n sentMessageLimit,\n signal,\n } = init\n this.kind = Kind\n if (typeof enabled === 'boolean') {\n this.enabled = enabled\n } else {\n this.enabled = false\n }\n if (typeof followRedirects === 'boolean') {\n this.followRedirects = followRedirects\n } else {\n this.followRedirects = undefined\n }\n if (typeof ignoreSessionCookies === 'boolean') {\n this.ignoreSessionCookies = ignoreSessionCookies\n } else {\n this.ignoreSessionCookies = undefined\n }\n if (typeof validateCertificates === 'boolean') {\n this.validateCertificates = validateCertificates\n } else {\n this.validateCertificates = undefined\n }\n if (typeof defaultHeaders === 'boolean') {\n this.defaultHeaders = defaultHeaders\n } else {\n this.defaultHeaders = undefined\n }\n if (typeof timeout === 'number') {\n this.timeout = timeout\n } else {\n this.timeout = undefined\n }\n if (Array.isArray(hosts)) {\n this.hosts = hosts.map((i) => new HostRule(i))\n } else {\n this.hosts = []\n }\n if (Array.isArray(variables)) {\n this.variables = variables.map((i) => new Property(i))\n } else {\n this.variables = []\n }\n if (typeof defaultAccept === 'string') {\n this.defaultAccept = defaultAccept\n } else {\n this.defaultAccept = undefined\n }\n if (typeof defaultUserAgent === 'string') {\n this.defaultUserAgent = defaultUserAgent\n } else {\n this.defaultUserAgent = undefined\n }\n if (typeof proxy === 'string') {\n this.proxy = proxy\n } else {\n this.proxy = undefined\n }\n if (typeof proxyUsername === 'string') {\n this.proxyUsername = proxyUsername\n } else {\n this.proxyUsername = undefined\n }\n if (typeof proxyPassword === 'string') {\n this.proxyPassword = proxyPassword\n } else {\n this.proxyPassword = undefined\n }\n if (typeof sentMessageLimit === 'number') {\n this.sentMessageLimit = sentMessageLimit\n } else {\n this.sentMessageLimit = undefined\n }\n if (signal) {\n this.signal = signal\n } else {\n this.signal = undefined\n }\n }\n\n toJSON(): IRequestConfig {\n const result: IRequestConfig = {\n kind: Kind,\n enabled: this.enabled,\n }\n if (typeof this.followRedirects === 'boolean') {\n result.followRedirects = this.followRedirects\n }\n if (typeof this.ignoreSessionCookies === 'boolean') {\n result.ignoreSessionCookies = this.ignoreSessionCookies\n }\n if (typeof this.validateCertificates === 'boolean') {\n result.validateCertificates = this.validateCertificates\n }\n if (typeof this.defaultHeaders === 'boolean') {\n result.defaultHeaders = this.defaultHeaders\n }\n if (typeof this.timeout === 'number') {\n result.timeout = this.timeout\n }\n if (Array.isArray(this.hosts) && this.hosts.length) {\n result.hosts = this.hosts.map((i) => i.toJSON())\n }\n if (Array.isArray(this.variables) && this.variables.length) {\n result.variables = this.variables.map((i) => i.toJSON())\n }\n if (this.defaultAccept) {\n result.defaultAccept = this.defaultAccept\n }\n if (this.defaultUserAgent) {\n result.defaultUserAgent = this.defaultUserAgent\n }\n if (this.proxy) {\n result.proxy = this.proxy\n }\n if (this.proxyUsername) {\n result.proxyUsername = this.proxyUsername\n }\n if (this.proxyPassword) {\n result.proxyPassword = this.proxyPassword\n }\n if (this.sentMessageLimit) {\n result.sentMessageLimit = this.sentMessageLimit\n }\n // DO NOT put the `signal` here.\n return result\n }\n}\n"]}
|
|
@@ -18,7 +18,7 @@ export declare class SerializableError {
|
|
|
18
18
|
code?: number | string;
|
|
19
19
|
private stackValue?;
|
|
20
20
|
get stack(): string | undefined;
|
|
21
|
-
readonly name
|
|
21
|
+
readonly name: string;
|
|
22
22
|
constructor(message?: string | Error, options?: IErrorOptions | number | string);
|
|
23
23
|
new(values: ISerializedError): void;
|
|
24
24
|
toJSON(): ISerializedError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SerializableError.d.ts","sourceRoot":"","sources":["../../../src/models/SerializableError.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAA;CAC5B;AAED;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,QAAQ,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"SerializableError.d.ts","sourceRoot":"","sources":["../../../src/models/SerializableError.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAA;CAC5B;AAED;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAsB;gBAE/B,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,GAAE,aAAa,GAAG,MAAM,GAAG,MAAW;IAgBnF,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAYnC,MAAM,IAAI,gBAAgB;IAc1B,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SerializableError.js","sourceRoot":"","sources":["../../../src/models/SerializableError.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,MAAM,OAA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I,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,KAAK,CAAA;QAChC,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;QACzB,CAAC;IACH,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;QACjD,MAAM,MAAM,GAAqB;YAC/B,OAAO;SACR,CAAA;QACD,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;QACtB,CAAC;QACD,IAAI,IAAI,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;QACpB,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF","sourcesContent":["interface IErrorOptions {\n cause?: Error\n}\n\nexport interface ISerializedError {\n message: string\n stack?: string\n code?: string | number\n [key: PropertyKey]: unknown\n}\n\n/**\n * An error that serializes!\n * It is a copy of the normal definition of an error but allows\n * to serialize the value via the toJSON() function and restore previous values\n * with the `new()` function.\n */\nexport class SerializableError {\n message: string\n code?: number | string\n private stackValue?: string\n get stack(): string | undefined {\n return this.stackValue\n }\n\n readonly name: string = 'SerializableError'\n\n constructor(message?: string | Error, options: IErrorOptions | number | string = {}) {\n if (typeof message === 'string') {\n this.message = message\n } else if (message) {\n this.message = message.message\n this.stackValue = message.stack\n } else {\n this.message = ''\n }\n if (typeof options === 'string' || typeof options === 'number') {\n this.code = options\n } else if (options.cause && options.cause.stack) {\n this.stackValue = options.cause.stack\n }\n }\n\n new(values: ISerializedError): void {\n if (values.message) {\n this.message = values.message\n }\n if (values.stack) {\n this.stackValue = values.stack\n }\n if (values.code || values.code === 0) {\n this.code = values.code\n }\n }\n\n toJSON(): ISerializedError {\n const { message, stackValue: stack, code } = this\n const result: ISerializedError = {\n message,\n }\n if (stack) {\n result.stack = stack\n }\n if (code || code === 0) {\n result.code = code\n }\n return result\n }\n\n toString(): string {\n return this.message\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestProxy.d.ts","sourceRoot":"","sources":["../../../src/proxy/RequestProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"RequestProxy.d.ts","sourceRoot":"","sources":["../../../src/proxy/RequestProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AAItE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,eAAe,CAAA;IAC5B;;OAEG;IACH,OAAO,EAAE,YAAY,CAAA;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,qBAAqB,EAAE,CAAA;IACvC;;OAEG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC;;OAEG;IACH,WAAW,CAAC,EAAE,eAAe,CAAA;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,cAAc,EAAE,CAAA;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,KAAK;IAC7C,IAAI,CAAC,EAAE,iBAAiB,CAAA;IAElB,SAAS,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBjD,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;CAyBpD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Proxy from './Proxy.js';
|
|
2
|
-
import { DummyLogger } from '../lib/logging/DummyLogger.js';
|
|
3
2
|
import { HttpRequestRunner } from '../runtime/http-runner/HttpRequestRunner.js';
|
|
4
3
|
import { Exception } from '../exceptions/exception.js';
|
|
4
|
+
import { createLogger } from '../lib/logging/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Proxies a single HTTP request
|
|
7
7
|
*/
|
|
@@ -32,7 +32,7 @@ export default class RequestProxy extends Proxy {
|
|
|
32
32
|
const { request, authorization, certificate, config = {}, variables = {}, flows, assertions } = data;
|
|
33
33
|
const factory = new HttpRequestRunner();
|
|
34
34
|
factory.variables = variables;
|
|
35
|
-
factory.logger =
|
|
35
|
+
factory.logger = createLogger();
|
|
36
36
|
factory.config = { ...config, enabled: true };
|
|
37
37
|
if (Array.isArray(authorization) && authorization.length) {
|
|
38
38
|
factory.authorization = authorization;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestProxy.js","sourceRoot":"","sources":["../../../src/proxy/RequestProxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAuB,MAAM,YAAY,CAAA;AAEhD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"RequestProxy.js","sourceRoot":"","sources":["../../../src/proxy/RequestProxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAuB,MAAM,YAAY,CAAA;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAA;AAI/E,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAsCtD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,KAAK;IAC7C,IAAI,CAAoB;IAExB,KAAK,CAAC,SAAS,CAAC,IAAuB;QACrC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;QACxB,MAAM,eAAe,GAAG,iBAAiB,CAAA;QACzC,MAAM,IAAI,GAAG,mBAAmB,CAAA;QAChC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,SAAS,CAAC,eAAe,EAAE;gBACnC,IAAI,EAAE,sCAAsC;gBAC5C,MAAM,EAAE,GAAG;gBACX,IAAI;aACL,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YACjB,MAAM,IAAI,SAAS,CAAC,eAAe,EAAE;gBACnC,IAAI,EAAE,0CAA0C;gBAChD,MAAM,EAAE,GAAG;gBACX,IAAI;aACL,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAyB,CAAA;QAC3C,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,GAAG,EAAE,EAAE,SAAS,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;QACpG,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAE,CAAA;QACvC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAA;QAC7B,OAAO,CAAC,MAAM,GAAG,YAAY,EAAE,CAAA;QAC/B,OAAO,CAAC,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI,EAAoB,CAAA;QAC/D,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;YACzD,OAAO,CAAC,aAAa,GAAG,aAAa,CAAA;QACvC,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACzC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAA;QACvB,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACnD,OAAO,CAAC,UAAU,GAAG,UAAU,CAAA;QACjC,CAAC;QACD,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,YAAY,GAAG,CAAC,WAAW,CAAC,CAAA;QACtC,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACzC,OAAO;YACL,MAAM,EAAE,MAAM;YACd,SAAS;SACV,CAAA;IACH,CAAC;CACF","sourcesContent":["import { IHttpRequest, Kind as HttpRequestKind } from '../models/HttpRequest.js'\nimport { IRequestAuthorization } from '../models/RequestAuthorization.js'\nimport { IRequestConfig } from '../models/RequestConfig.js'\nimport Proxy, { IProxyResult } from './Proxy.js'\nimport { HttpCertificate } from '../models/ClientCertificate.js'\nimport { HttpRequestRunner } from '../runtime/http-runner/HttpRequestRunner.js'\nimport { IRequestLog } from '../models/RequestLog.js'\nimport { IHttpFlow } from '../models/http-flows/HttpFlows.js'\nimport { IHttpAssertion } from '../models/http-flows/HttpAssertion.js'\nimport { Exception } from '../exceptions/exception.js'\nimport { createLogger } from '../lib/logging/index.js'\n\nexport interface IRequestProxyInit {\n kind: typeof HttpRequestKind\n /**\n * The request to execute.\n */\n request: IHttpRequest\n /**\n * The authorization data to apply.\n */\n authorization?: IRequestAuthorization[]\n /**\n * The request configuration.\n */\n config?: IRequestConfig\n /**\n * The list of execution variables to use with the request.\n */\n variables?: Record<string, string>\n /**\n * The certificate data to use with the request.\n */\n certificate?: HttpCertificate\n /**\n * The request flows to execute with the request.\n */\n flows?: IHttpFlow[]\n /**\n * Assertions to execute with the request.\n */\n assertions?: IHttpAssertion[]\n /**\n * A signal to be sent to the proxy bindings to abort the request on demand.\n */\n signal?: AbortSignal | null\n}\n\n/**\n * Proxies a single HTTP request\n */\nexport default class RequestProxy extends Proxy {\n init?: IRequestProxyInit\n\n async configure(init: IRequestProxyInit): Promise<void> {\n const { request } = init\n const INVALID_REQUEST = 'Invalid request'\n const code = 'E_INVALID_REQUEST'\n if (!request) {\n throw new Exception(INVALID_REQUEST, {\n help: 'The \"request\" parameter is required.',\n status: 400,\n code,\n })\n }\n if (!request.url) {\n throw new Exception(INVALID_REQUEST, {\n help: 'The \"request.url\" parameter is required.',\n status: 400,\n code,\n })\n }\n this.init = init\n }\n\n async execute(): Promise<IProxyResult<IRequestLog>> {\n const data = this.init as IRequestProxyInit\n const { request, authorization, certificate, config = {}, variables = {}, flows, assertions } = data\n const factory = new HttpRequestRunner()\n factory.variables = variables\n factory.logger = createLogger()\n factory.config = { ...config, enabled: true } as IRequestConfig\n if (Array.isArray(authorization) && authorization.length) {\n factory.authorization = authorization\n }\n if (Array.isArray(flows) && flows.length) {\n factory.flows = flows\n }\n if (Array.isArray(assertions) && assertions.length) {\n factory.assertions = assertions\n }\n if (certificate) {\n factory.certificates = [certificate]\n }\n const result = await factory.run(request)\n return {\n result: result,\n variables,\n }\n }\n}\n"]}
|