@api-client/core 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +69 -0
- package/amf-models/dialects/ApiProjectVocabulary.yaml +233 -0
- package/amf-models/dialects/Environment.yaml +38 -0
- package/amf-models/dialects/HttpProject.yaml +55 -0
- package/amf-models/dialects/License.yaml +31 -0
- package/amf-models/dialects/ProjectFolder.yaml +43 -0
- package/amf-models/dialects/ProjectItem.yaml +22 -0
- package/amf-models/dialects/ProjectRequest.yaml +23 -0
- package/amf-models/dialects/ProjectSchema.yaml +36 -0
- package/amf-models/dialects/Property.yaml +43 -0
- package/amf-models/dialects/Provider.yaml +32 -0
- package/amf-models/dialects/Server.yaml +31 -0
- package/amf-models/dialects/Thing.yaml +28 -0
- package/build/browser.d.ts +79 -0
- package/build/browser.js +92 -0
- package/build/browser.js.map +1 -0
- package/build/index.d.ts +89 -0
- package/build/index.js +108 -0
- package/build/index.js.map +1 -0
- package/build/src/data/DataReader.d.ts +10 -0
- package/build/src/data/DataReader.js +4 -0
- package/build/src/data/DataReader.js.map +1 -0
- package/build/src/data/DataUtils.d.ts +40 -0
- package/build/src/data/DataUtils.js +106 -0
- package/build/src/data/DataUtils.js.map +1 -0
- package/build/src/data/JmesparthReader.d.ts +12 -0
- package/build/src/data/JmesparthReader.js +27 -0
- package/build/src/data/JmesparthReader.js.map +1 -0
- package/build/src/data/Json2Xml.d.ts +84 -0
- package/build/src/data/Json2Xml.js +185 -0
- package/build/src/data/Json2Xml.js.map +1 -0
- package/build/src/data/JsonReader.d.ts +8 -0
- package/build/src/data/JsonReader.js +40 -0
- package/build/src/data/JsonReader.js.map +1 -0
- package/build/src/data/PayloadPointer.d.ts +19 -0
- package/build/src/data/PayloadPointer.js +46 -0
- package/build/src/data/PayloadPointer.js.map +1 -0
- package/build/src/data/RequestDataExtractor.d.ts +44 -0
- package/build/src/data/RequestDataExtractor.js +126 -0
- package/build/src/data/RequestDataExtractor.js.map +1 -0
- package/build/src/data/UrlEncodedReader.d.ts +11 -0
- package/build/src/data/UrlEncodedReader.js +20 -0
- package/build/src/data/UrlEncodedReader.js.map +1 -0
- package/build/src/data/XmlReader.d.ts +14 -0
- package/build/src/data/XmlReader.js +97 -0
- package/build/src/data/XmlReader.js.map +1 -0
- package/build/src/events/BaseEvents.d.ts +208 -0
- package/build/src/events/BaseEvents.js +117 -0
- package/build/src/events/BaseEvents.js.map +1 -0
- package/build/src/events/CustomEvent.d.ts +2 -0
- package/build/src/events/CustomEvent.js +24 -0
- package/build/src/events/CustomEvent.js.map +1 -0
- package/build/src/events/EventTypes.d.ts +91 -0
- package/build/src/events/EventTypes.js +19 -0
- package/build/src/events/EventTypes.js.map +1 -0
- package/build/src/events/Events.d.ts +20 -0
- package/build/src/events/Events.js +19 -0
- package/build/src/events/Events.js.map +1 -0
- package/build/src/events/authorization/AuthorizationEventTypes.d.ts +22 -0
- package/build/src/events/authorization/AuthorizationEventTypes.js +23 -0
- package/build/src/events/authorization/AuthorizationEventTypes.js.map +1 -0
- package/build/src/events/authorization/AuthorizationEvents.d.ts +34 -0
- package/build/src/events/authorization/AuthorizationEvents.js +55 -0
- package/build/src/events/authorization/AuthorizationEvents.js.map +1 -0
- package/build/src/events/cookies/CookieEventTypes.d.ts +13 -0
- package/build/src/events/cookies/CookieEventTypes.js +14 -0
- package/build/src/events/cookies/CookieEventTypes.js.map +1 -0
- package/build/src/events/cookies/CookieEvents.d.ts +90 -0
- package/build/src/events/cookies/CookieEvents.js +126 -0
- package/build/src/events/cookies/CookieEvents.js.map +1 -0
- package/build/src/events/encryption/EncryptionEventTypes.d.ts +4 -0
- package/build/src/events/encryption/EncryptionEventTypes.js +5 -0
- package/build/src/events/encryption/EncryptionEventTypes.js.map +1 -0
- package/build/src/events/encryption/EncryptionEvents.d.ts +36 -0
- package/build/src/events/encryption/EncryptionEvents.js +35 -0
- package/build/src/events/encryption/EncryptionEvents.js.map +1 -0
- package/build/src/events/environment/EnvironmentEventTypes.d.ts +3 -0
- package/build/src/events/environment/EnvironmentEventTypes.js +4 -0
- package/build/src/events/environment/EnvironmentEventTypes.js.map +1 -0
- package/build/src/events/environment/EnvironmentEvents.d.ts +15 -0
- package/build/src/events/environment/EnvironmentEvents.js +19 -0
- package/build/src/events/environment/EnvironmentEvents.js.map +1 -0
- package/build/src/events/models/ClientCertificateEvents.d.ts +56 -0
- package/build/src/events/models/ClientCertificateEvents.js +80 -0
- package/build/src/events/models/ClientCertificateEvents.js.map +1 -0
- package/build/src/events/models/ModelEventTypes.d.ts +47 -0
- package/build/src/events/models/ModelEventTypes.js +48 -0
- package/build/src/events/models/ModelEventTypes.js.map +1 -0
- package/build/src/events/models/ModelEvents.d.ts +6 -0
- package/build/src/events/models/ModelEvents.js +7 -0
- package/build/src/events/models/ModelEvents.js.map +1 -0
- package/build/src/events/models/ProjectEvents.d.ts +221 -0
- package/build/src/events/models/ProjectEvents.js +254 -0
- package/build/src/events/models/ProjectEvents.js.map +1 -0
- package/build/src/events/process/ProcessEventTypes.d.ts +5 -0
- package/build/src/events/process/ProcessEventTypes.js +6 -0
- package/build/src/events/process/ProcessEventTypes.js.map +1 -0
- package/build/src/events/process/ProcessEvents.d.ts +42 -0
- package/build/src/events/process/ProcessEvents.js +59 -0
- package/build/src/events/process/ProcessEvents.js.map +1 -0
- package/build/src/events/reporting/ReportingEventTypes.d.ts +3 -0
- package/build/src/events/reporting/ReportingEventTypes.js +4 -0
- package/build/src/events/reporting/ReportingEventTypes.js.map +1 -0
- package/build/src/events/reporting/ReportingEvents.d.ts +16 -0
- package/build/src/events/reporting/ReportingEvents.js +22 -0
- package/build/src/events/reporting/ReportingEvents.js.map +1 -0
- package/build/src/events/telemetry/TelemetryEventTypes.d.ts +10 -0
- package/build/src/events/telemetry/TelemetryEventTypes.js +11 -0
- package/build/src/events/telemetry/TelemetryEventTypes.js.map +1 -0
- package/build/src/events/telemetry/TelemetryEvents.d.ts +89 -0
- package/build/src/events/telemetry/TelemetryEvents.js +109 -0
- package/build/src/events/telemetry/TelemetryEvents.js.map +1 -0
- package/build/src/lib/cookies/Cookie.d.ts +123 -0
- package/build/src/lib/cookies/Cookie.js +257 -0
- package/build/src/lib/cookies/Cookie.js.map +1 -0
- package/build/src/lib/cookies/Cookies.d.ts +90 -0
- package/build/src/lib/cookies/Cookies.js +310 -0
- package/build/src/lib/cookies/Cookies.js.map +1 -0
- package/build/src/lib/cookies/Utils.d.ts +47 -0
- package/build/src/lib/cookies/Utils.js +163 -0
- package/build/src/lib/cookies/Utils.js.map +1 -0
- package/build/src/lib/headers/Headers.d.ts +67 -0
- package/build/src/lib/headers/Headers.js +202 -0
- package/build/src/lib/headers/Headers.js.map +1 -0
- package/build/src/lib/logging/DefaultLogger.d.ts +8 -0
- package/build/src/lib/logging/DefaultLogger.js +19 -0
- package/build/src/lib/logging/DefaultLogger.js.map +1 -0
- package/build/src/lib/logging/DummyLogger.d.ts +8 -0
- package/build/src/lib/logging/DummyLogger.js +21 -0
- package/build/src/lib/logging/DummyLogger.js.map +1 -0
- package/build/src/lib/logging/Logger.d.ts +14 -0
- package/build/src/lib/logging/Logger.js +3 -0
- package/build/src/lib/logging/Logger.js.map +1 -0
- package/build/src/lib/transformers/PayloadSerializer.d.ts +145 -0
- package/build/src/lib/transformers/PayloadSerializer.js +264 -0
- package/build/src/lib/transformers/PayloadSerializer.js.map +1 -0
- package/build/src/lib/transformers/Utils.d.ts +7 -0
- package/build/src/lib/transformers/Utils.js +19 -0
- package/build/src/lib/transformers/Utils.js.map +1 -0
- package/build/src/lib/uuid.d.ts +8 -0
- package/build/src/lib/uuid.js +38 -0
- package/build/src/lib/uuid.js.map +1 -0
- package/build/src/mocking/LegacyInterfaces.d.ts +47 -0
- package/build/src/mocking/LegacyInterfaces.js +2 -0
- package/build/src/mocking/LegacyInterfaces.js.map +1 -0
- package/build/src/mocking/LegacyMock.d.ts +24 -0
- package/build/src/mocking/LegacyMock.js +34 -0
- package/build/src/mocking/LegacyMock.js.map +1 -0
- package/build/src/mocking/legacy/Authorization.d.ts +19 -0
- package/build/src/mocking/legacy/Authorization.js +34 -0
- package/build/src/mocking/legacy/Authorization.js.map +1 -0
- package/build/src/mocking/legacy/Certificates.d.ts +54 -0
- package/build/src/mocking/legacy/Certificates.js +125 -0
- package/build/src/mocking/legacy/Certificates.js.map +1 -0
- package/build/src/mocking/legacy/Cookies.d.ts +19 -0
- package/build/src/mocking/legacy/Cookies.js +46 -0
- package/build/src/mocking/legacy/Cookies.js.map +1 -0
- package/build/src/mocking/legacy/HostRules.d.ts +20 -0
- package/build/src/mocking/legacy/HostRules.js +38 -0
- package/build/src/mocking/legacy/HostRules.js.map +1 -0
- package/build/src/mocking/legacy/Http.d.ts +78 -0
- package/build/src/mocking/legacy/Http.js +192 -0
- package/build/src/mocking/legacy/Http.js.map +1 -0
- package/build/src/mocking/legacy/HttpResponse.d.ts +22 -0
- package/build/src/mocking/legacy/HttpResponse.js +98 -0
- package/build/src/mocking/legacy/HttpResponse.js.map +1 -0
- package/build/src/mocking/legacy/RestApi.d.ts +13 -0
- package/build/src/mocking/legacy/RestApi.js +61 -0
- package/build/src/mocking/legacy/RestApi.js.map +1 -0
- package/build/src/mocking/legacy/Urls.d.ts +19 -0
- package/build/src/mocking/legacy/Urls.js +39 -0
- package/build/src/mocking/legacy/Urls.js.map +1 -0
- package/build/src/mocking/legacy/Variables.d.ts +17 -0
- package/build/src/mocking/legacy/Variables.js +50 -0
- package/build/src/mocking/legacy/Variables.js.map +1 -0
- package/build/src/models/ArcResponse.d.ts +63 -0
- package/build/src/models/ArcResponse.js +142 -0
- package/build/src/models/ArcResponse.js.map +1 -0
- package/build/src/models/Authorization.d.ts +452 -0
- package/build/src/models/Authorization.js +2 -0
- package/build/src/models/Authorization.js.map +1 -0
- package/build/src/models/AuthorizationData.d.ts +27 -0
- package/build/src/models/AuthorizationData.js +52 -0
- package/build/src/models/AuthorizationData.js.map +1 -0
- package/build/src/models/Backend.d.ts +71 -0
- package/build/src/models/Backend.js +2 -0
- package/build/src/models/Backend.js.map +1 -0
- package/build/src/models/ClientCertificate.d.ts +65 -0
- package/build/src/models/ClientCertificate.js +2 -0
- package/build/src/models/ClientCertificate.js.map +1 -0
- package/build/src/models/Environment.d.ts +125 -0
- package/build/src/models/Environment.js +215 -0
- package/build/src/models/Environment.js.map +1 -0
- package/build/src/models/ErrorResponse.d.ts +35 -0
- package/build/src/models/ErrorResponse.js +88 -0
- package/build/src/models/ErrorResponse.js.map +1 -0
- package/build/src/models/HistoryIndex.d.ts +43 -0
- package/build/src/models/HistoryIndex.js +53 -0
- package/build/src/models/HistoryIndex.js.map +1 -0
- package/build/src/models/HistoryRequest.d.ts +13 -0
- package/build/src/models/HistoryRequest.js +25 -0
- package/build/src/models/HistoryRequest.js.map +1 -0
- package/build/src/models/HostRule.d.ts +78 -0
- package/build/src/models/HostRule.js +134 -0
- package/build/src/models/HostRule.js.map +1 -0
- package/build/src/models/HttpCookie.d.ts +123 -0
- package/build/src/models/HttpCookie.js +209 -0
- package/build/src/models/HttpCookie.js.map +1 -0
- package/build/src/models/HttpProject.d.ts +455 -0
- package/build/src/models/HttpProject.js +987 -0
- package/build/src/models/HttpProject.js.map +1 -0
- package/build/src/models/HttpProjectListItem.d.ts +23 -0
- package/build/src/models/HttpProjectListItem.js +2 -0
- package/build/src/models/HttpProjectListItem.js.map +1 -0
- package/build/src/models/HttpRequest.d.ts +69 -0
- package/build/src/models/HttpRequest.js +92 -0
- package/build/src/models/HttpRequest.js.map +1 -0
- package/build/src/models/HttpResponse.d.ts +59 -0
- package/build/src/models/HttpResponse.js +116 -0
- package/build/src/models/HttpResponse.js.map +1 -0
- package/build/src/models/License.d.ts +52 -0
- package/build/src/models/License.js +91 -0
- package/build/src/models/License.js.map +1 -0
- package/build/src/models/ProjectDefinitionProperty.d.ts +34 -0
- package/build/src/models/ProjectDefinitionProperty.js +2 -0
- package/build/src/models/ProjectDefinitionProperty.js.map +1 -0
- package/build/src/models/ProjectFolder.d.ts +213 -0
- package/build/src/models/ProjectFolder.js +314 -0
- package/build/src/models/ProjectFolder.js.map +1 -0
- package/build/src/models/ProjectItem.d.ts +59 -0
- package/build/src/models/ProjectItem.js +119 -0
- package/build/src/models/ProjectItem.js.map +1 -0
- package/build/src/models/ProjectParent.d.ts +58 -0
- package/build/src/models/ProjectParent.js +77 -0
- package/build/src/models/ProjectParent.js.map +1 -0
- package/build/src/models/ProjectRequest.d.ts +118 -0
- package/build/src/models/ProjectRequest.js +238 -0
- package/build/src/models/ProjectRequest.js.map +1 -0
- package/build/src/models/ProjectSchema.d.ts +105 -0
- package/build/src/models/ProjectSchema.js +156 -0
- package/build/src/models/ProjectSchema.js.map +1 -0
- package/build/src/models/Property.d.ts +130 -0
- package/build/src/models/Property.js +392 -0
- package/build/src/models/Property.js.map +1 -0
- package/build/src/models/Provider.d.ts +52 -0
- package/build/src/models/Provider.js +75 -0
- package/build/src/models/Provider.js.map +1 -0
- package/build/src/models/Request.d.ts +157 -0
- package/build/src/models/Request.js +398 -0
- package/build/src/models/Request.js.map +1 -0
- package/build/src/models/RequestActions.d.ts +67 -0
- package/build/src/models/RequestActions.js +116 -0
- package/build/src/models/RequestActions.js.map +1 -0
- package/build/src/models/RequestAuthorization.d.ts +59 -0
- package/build/src/models/RequestAuthorization.js +85 -0
- package/build/src/models/RequestAuthorization.js.map +1 -0
- package/build/src/models/RequestConfig.d.ts +161 -0
- package/build/src/models/RequestConfig.js +246 -0
- package/build/src/models/RequestConfig.js.map +1 -0
- package/build/src/models/RequestLog.d.ts +70 -0
- package/build/src/models/RequestLog.js +133 -0
- package/build/src/models/RequestLog.js.map +1 -0
- package/build/src/models/RequestTime.d.ts +36 -0
- package/build/src/models/RequestTime.js +91 -0
- package/build/src/models/RequestTime.js.map +1 -0
- package/build/src/models/RequestUiMeta.d.ts +169 -0
- package/build/src/models/RequestUiMeta.js +120 -0
- package/build/src/models/RequestUiMeta.js.map +1 -0
- package/build/src/models/RequestsSize.d.ts +34 -0
- package/build/src/models/RequestsSize.js +52 -0
- package/build/src/models/RequestsSize.js.map +1 -0
- package/build/src/models/ResponseAuthorization.d.ts +54 -0
- package/build/src/models/ResponseAuthorization.js +82 -0
- package/build/src/models/ResponseAuthorization.js.map +1 -0
- package/build/src/models/ResponseRedirect.d.ts +73 -0
- package/build/src/models/ResponseRedirect.js +126 -0
- package/build/src/models/ResponseRedirect.js.map +1 -0
- package/build/src/models/RevisionInfo.d.ts +36 -0
- package/build/src/models/RevisionInfo.js +2 -0
- package/build/src/models/RevisionInfo.js.map +1 -0
- package/build/src/models/SentRequest.d.ts +62 -0
- package/build/src/models/SentRequest.js +93 -0
- package/build/src/models/SentRequest.js.map +1 -0
- package/build/src/models/SerializablePayload.d.ts +30 -0
- package/build/src/models/SerializablePayload.js +66 -0
- package/build/src/models/SerializablePayload.js.map +1 -0
- package/build/src/models/Server.d.ts +76 -0
- package/build/src/models/Server.js +121 -0
- package/build/src/models/Server.js.map +1 -0
- package/build/src/models/Thing.d.ts +56 -0
- package/build/src/models/Thing.js +85 -0
- package/build/src/models/Thing.js.map +1 -0
- package/build/src/models/Url.d.ts +51 -0
- package/build/src/models/Url.js +71 -0
- package/build/src/models/Url.js.map +1 -0
- package/build/src/models/User.d.ts +110 -0
- package/build/src/models/User.js +2 -0
- package/build/src/models/User.js.map +1 -0
- package/build/src/models/WebApi.d.ts +119 -0
- package/build/src/models/WebApi.js +175 -0
- package/build/src/models/WebApi.js.map +1 -0
- package/build/src/models/WebApiIndex.d.ts +70 -0
- package/build/src/models/WebApiIndex.js +72 -0
- package/build/src/models/WebApiIndex.js.map +1 -0
- package/build/src/models/Workspace.d.ts +98 -0
- package/build/src/models/Workspace.js +139 -0
- package/build/src/models/Workspace.js.map +1 -0
- package/build/src/models/actions/Action.d.ts +75 -0
- package/build/src/models/actions/Action.js +188 -0
- package/build/src/models/actions/Action.js.map +1 -0
- package/build/src/models/actions/ActionView.d.ts +15 -0
- package/build/src/models/actions/ActionView.js +33 -0
- package/build/src/models/actions/ActionView.js.map +1 -0
- package/build/src/models/actions/Condition.d.ts +81 -0
- package/build/src/models/actions/Condition.js +185 -0
- package/build/src/models/actions/Condition.js.map +1 -0
- package/build/src/models/actions/ConditionView.d.ts +17 -0
- package/build/src/models/actions/ConditionView.js +34 -0
- package/build/src/models/actions/ConditionView.js.map +1 -0
- package/build/src/models/actions/Enums.d.ts +26 -0
- package/build/src/models/actions/Enums.js +31 -0
- package/build/src/models/actions/Enums.js.map +1 -0
- package/build/src/models/actions/RunnableAction.d.ts +59 -0
- package/build/src/models/actions/RunnableAction.js +106 -0
- package/build/src/models/actions/RunnableAction.js.map +1 -0
- package/build/src/models/actions/runnable/DeleteCookieAction.d.ts +44 -0
- package/build/src/models/actions/runnable/DeleteCookieAction.js +92 -0
- package/build/src/models/actions/runnable/DeleteCookieAction.js.map +1 -0
- package/build/src/models/actions/runnable/Runnable.d.ts +8 -0
- package/build/src/models/actions/runnable/Runnable.js +4 -0
- package/build/src/models/actions/runnable/Runnable.js.map +1 -0
- package/build/src/models/actions/runnable/SetCookieAction.d.ts +87 -0
- package/build/src/models/actions/runnable/SetCookieAction.js +176 -0
- package/build/src/models/actions/runnable/SetCookieAction.js.map +1 -0
- package/build/src/models/actions/runnable/SetVariableAction.d.ts +31 -0
- package/build/src/models/actions/runnable/SetVariableAction.js +63 -0
- package/build/src/models/actions/runnable/SetVariableAction.js.map +1 -0
- package/build/src/models/actions/runnable/index.d.ts +7 -0
- package/build/src/models/actions/runnable/index.js +2 -0
- package/build/src/models/actions/runnable/index.js.map +1 -0
- package/build/src/models/legacy/DataExport.d.ts +168 -0
- package/build/src/models/legacy/DataExport.js +2 -0
- package/build/src/models/legacy/DataExport.js.map +1 -0
- package/build/src/models/legacy/Normalizer.d.ts +12 -0
- package/build/src/models/legacy/Normalizer.js +104 -0
- package/build/src/models/legacy/Normalizer.js.map +1 -0
- package/build/src/models/legacy/actions/Actions.d.ts +257 -0
- package/build/src/models/legacy/actions/Actions.js +2 -0
- package/build/src/models/legacy/actions/Actions.js.map +1 -0
- package/build/src/models/legacy/authorization/Authorization.d.ts +540 -0
- package/build/src/models/legacy/authorization/Authorization.js +3 -0
- package/build/src/models/legacy/authorization/Authorization.js.map +1 -0
- package/build/src/models/legacy/models/ApiTypes.d.ts +192 -0
- package/build/src/models/legacy/models/ApiTypes.js +2 -0
- package/build/src/models/legacy/models/ApiTypes.js.map +1 -0
- package/build/src/models/legacy/models/ArcLegacyProject.d.ts +37 -0
- package/build/src/models/legacy/models/ArcLegacyProject.js +2 -0
- package/build/src/models/legacy/models/ArcLegacyProject.js.map +1 -0
- package/build/src/models/legacy/models/AuthData.d.ts +14 -0
- package/build/src/models/legacy/models/AuthData.js +2 -0
- package/build/src/models/legacy/models/AuthData.js.map +1 -0
- package/build/src/models/legacy/models/ClientCertificate.d.ts +89 -0
- package/build/src/models/legacy/models/ClientCertificate.js +2 -0
- package/build/src/models/legacy/models/ClientCertificate.js.map +1 -0
- package/build/src/models/legacy/models/Cookies.d.ts +52 -0
- package/build/src/models/legacy/models/Cookies.js +2 -0
- package/build/src/models/legacy/models/Cookies.js.map +1 -0
- package/build/src/models/legacy/models/HostRule.d.ts +33 -0
- package/build/src/models/legacy/models/HostRule.js +2 -0
- package/build/src/models/legacy/models/HostRule.js.map +1 -0
- package/build/src/models/legacy/models/RestApi.d.ts +47 -0
- package/build/src/models/legacy/models/RestApi.js +2 -0
- package/build/src/models/legacy/models/RestApi.js.map +1 -0
- package/build/src/models/legacy/models/UrlHistory.d.ts +32 -0
- package/build/src/models/legacy/models/UrlHistory.js +2 -0
- package/build/src/models/legacy/models/UrlHistory.js.map +1 -0
- package/build/src/models/legacy/models/Variable.d.ts +38 -0
- package/build/src/models/legacy/models/Variable.js +2 -0
- package/build/src/models/legacy/models/Variable.js.map +1 -0
- package/build/src/models/legacy/request/ArcRequest.d.ts +387 -0
- package/build/src/models/legacy/request/ArcRequest.js +2 -0
- package/build/src/models/legacy/request/ArcRequest.js.map +1 -0
- package/build/src/models/legacy/request/ArcResponse.d.ts +166 -0
- package/build/src/models/legacy/request/ArcResponse.js +2 -0
- package/build/src/models/legacy/request/ArcResponse.js.map +1 -0
- package/build/src/models/legacy/request/HistoryData.d.ts +45 -0
- package/build/src/models/legacy/request/HistoryData.js +2 -0
- package/build/src/models/legacy/request/HistoryData.js.map +1 -0
- package/build/src/models/legacy/request/Legacy.d.ts +43 -0
- package/build/src/models/legacy/request/Legacy.js +2 -0
- package/build/src/models/legacy/request/Legacy.js.map +1 -0
- package/build/src/models/legacy/request/RequestBody.d.ts +82 -0
- package/build/src/models/legacy/request/RequestBody.js +2 -0
- package/build/src/models/legacy/request/RequestBody.js.map +1 -0
- package/build/src/models/transformers/ArcDexieTransformer.d.ts +108 -0
- package/build/src/models/transformers/ArcDexieTransformer.js +252 -0
- package/build/src/models/transformers/ArcDexieTransformer.js.map +1 -0
- package/build/src/models/transformers/ArcLegacyNormalizer.d.ts +42 -0
- package/build/src/models/transformers/ArcLegacyNormalizer.js +80 -0
- package/build/src/models/transformers/ArcLegacyNormalizer.js.map +1 -0
- package/build/src/models/transformers/ArcLegacyTransformer.d.ts +85 -0
- package/build/src/models/transformers/ArcLegacyTransformer.js +150 -0
- package/build/src/models/transformers/ArcLegacyTransformer.js.map +1 -0
- package/build/src/models/transformers/ArcPouchTransformer.d.ts +46 -0
- package/build/src/models/transformers/ArcPouchTransformer.js +170 -0
- package/build/src/models/transformers/ArcPouchTransformer.js.map +1 -0
- package/build/src/models/transformers/BaseTransformer.d.ts +48 -0
- package/build/src/models/transformers/BaseTransformer.js +104 -0
- package/build/src/models/transformers/BaseTransformer.js.map +1 -0
- package/build/src/models/transformers/ImportUtils.d.ts +44 -0
- package/build/src/models/transformers/ImportUtils.js +135 -0
- package/build/src/models/transformers/ImportUtils.js.map +1 -0
- package/build/src/models/transformers/LegacyDataExportToApiProject.d.ts +15 -0
- package/build/src/models/transformers/LegacyDataExportToApiProject.js +70 -0
- package/build/src/models/transformers/LegacyDataExportToApiProject.js.map +1 -0
- package/build/src/models/transformers/LegacyExportProcessor.d.ts +47 -0
- package/build/src/models/transformers/LegacyExportProcessor.js +219 -0
- package/build/src/models/transformers/LegacyExportProcessor.js.map +1 -0
- package/build/src/models/transformers/PostmanBackupTransformer.d.ts +96 -0
- package/build/src/models/transformers/PostmanBackupTransformer.js +188 -0
- package/build/src/models/transformers/PostmanBackupTransformer.js.map +1 -0
- package/build/src/models/transformers/PostmanDataTransformer.d.ts +9 -0
- package/build/src/models/transformers/PostmanDataTransformer.js +46 -0
- package/build/src/models/transformers/PostmanDataTransformer.js.map +1 -0
- package/build/src/models/transformers/PostmanTransformer.d.ts +49 -0
- package/build/src/models/transformers/PostmanTransformer.js +90 -0
- package/build/src/models/transformers/PostmanTransformer.js.map +1 -0
- package/build/src/models/transformers/PostmanV21Transformer.d.ts +125 -0
- package/build/src/models/transformers/PostmanV21Transformer.js +195 -0
- package/build/src/models/transformers/PostmanV21Transformer.js.map +1 -0
- package/build/src/models/transformers/PostmanV2Transformer.d.ts +123 -0
- package/build/src/models/transformers/PostmanV2Transformer.js +195 -0
- package/build/src/models/transformers/PostmanV2Transformer.js.map +1 -0
- package/build/src/models/transformers/har.d.ts +857 -0
- package/build/src/models/transformers/har.js +2 -0
- package/build/src/models/transformers/har.js.map +1 -0
- package/build/src/runtime/actions/ActionRunner.d.ts +17 -0
- package/build/src/runtime/actions/ActionRunner.js +74 -0
- package/build/src/runtime/actions/ActionRunner.js.map +1 -0
- package/build/src/runtime/actions/ConditionRunner.d.ts +74 -0
- package/build/src/runtime/actions/ConditionRunner.js +185 -0
- package/build/src/runtime/actions/ConditionRunner.js.map +1 -0
- package/build/src/runtime/actions/RunnableCondition.d.ts +28 -0
- package/build/src/runtime/actions/RunnableCondition.js +51 -0
- package/build/src/runtime/actions/RunnableCondition.js.map +1 -0
- package/build/src/runtime/actions/runnable/ActionRunnable.d.ts +13 -0
- package/build/src/runtime/actions/runnable/ActionRunnable.js +13 -0
- package/build/src/runtime/actions/runnable/ActionRunnable.js.map +1 -0
- package/build/src/runtime/actions/runnable/DeleteCookieRunnable.d.ts +7 -0
- package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js +36 -0
- package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js.map +1 -0
- package/build/src/runtime/actions/runnable/SetCookieRunnable.d.ts +10 -0
- package/build/src/runtime/actions/runnable/SetCookieRunnable.js +89 -0
- package/build/src/runtime/actions/runnable/SetCookieRunnable.js.map +1 -0
- package/build/src/runtime/actions/runnable/SetVariableRunnable.d.ts +10 -0
- package/build/src/runtime/actions/runnable/SetVariableRunnable.js +49 -0
- package/build/src/runtime/actions/runnable/SetVariableRunnable.js.map +1 -0
- package/build/src/runtime/http-engine/ArcEngine.d.ts +218 -0
- package/build/src/runtime/http-engine/ArcEngine.js +1034 -0
- package/build/src/runtime/http-engine/ArcEngine.js.map +1 -0
- package/build/src/runtime/http-engine/Errors.d.ts +10 -0
- package/build/src/runtime/http-engine/Errors.js +14 -0
- package/build/src/runtime/http-engine/Errors.js.map +1 -0
- package/build/src/runtime/http-engine/FormData.d.ts +16 -0
- package/build/src/runtime/http-engine/FormData.js +72 -0
- package/build/src/runtime/http-engine/FormData.js.map +1 -0
- package/build/src/runtime/http-engine/HttpEngine.d.ts +294 -0
- package/build/src/runtime/http-engine/HttpEngine.js +736 -0
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -0
- package/build/src/runtime/http-engine/HttpErrorCodes.d.ts +15 -0
- package/build/src/runtime/http-engine/HttpErrorCodes.js +223 -0
- package/build/src/runtime/http-engine/HttpErrorCodes.js.map +1 -0
- package/build/src/runtime/http-engine/NodeEngine.d.ts +154 -0
- package/build/src/runtime/http-engine/NodeEngine.js +761 -0
- package/build/src/runtime/http-engine/NodeEngine.js.map +1 -0
- package/build/src/runtime/http-engine/NodeEngineDirect.d.ts +113 -0
- package/build/src/runtime/http-engine/NodeEngineDirect.js +443 -0
- package/build/src/runtime/http-engine/NodeEngineDirect.js.map +1 -0
- package/build/src/runtime/http-engine/PayloadSupport.d.ts +26 -0
- package/build/src/runtime/http-engine/PayloadSupport.js +78 -0
- package/build/src/runtime/http-engine/PayloadSupport.js.map +1 -0
- package/build/src/runtime/http-engine/RequestUtils.d.ts +66 -0
- package/build/src/runtime/http-engine/RequestUtils.js +144 -0
- package/build/src/runtime/http-engine/RequestUtils.js.map +1 -0
- package/build/src/runtime/http-engine/ntlm/Des.d.ts +4 -0
- package/build/src/runtime/http-engine/ntlm/Des.js +343 -0
- package/build/src/runtime/http-engine/ntlm/Des.js.map +1 -0
- package/build/src/runtime/http-engine/ntlm/MD4.d.ts +13 -0
- package/build/src/runtime/http-engine/ntlm/MD4.js +120 -0
- package/build/src/runtime/http-engine/ntlm/MD4.js.map +1 -0
- package/build/src/runtime/http-engine/ntlm/NtlmAuth.d.ts +26 -0
- package/build/src/runtime/http-engine/ntlm/NtlmAuth.js +159 -0
- package/build/src/runtime/http-engine/ntlm/NtlmAuth.js.map +1 -0
- package/build/src/runtime/http-engine/ntlm/NtlmMessage.d.ts +10 -0
- package/build/src/runtime/http-engine/ntlm/NtlmMessage.js +51 -0
- package/build/src/runtime/http-engine/ntlm/NtlmMessage.js.map +1 -0
- package/build/src/runtime/modules/BasicAuthCache.d.ts +39 -0
- package/build/src/runtime/modules/BasicAuthCache.js +125 -0
- package/build/src/runtime/modules/BasicAuthCache.js.map +1 -0
- package/build/src/runtime/modules/ExecutionResponse.d.ts +4 -0
- package/build/src/runtime/modules/ExecutionResponse.js +6 -0
- package/build/src/runtime/modules/ExecutionResponse.js.map +1 -0
- package/build/src/runtime/modules/ModulesRegistry.d.ts +93 -0
- package/build/src/runtime/modules/ModulesRegistry.js +69 -0
- package/build/src/runtime/modules/ModulesRegistry.js.map +1 -0
- package/build/src/runtime/modules/RequestAuthorization.d.ts +6 -0
- package/build/src/runtime/modules/RequestAuthorization.js +114 -0
- package/build/src/runtime/modules/RequestAuthorization.js.map +1 -0
- package/build/src/runtime/modules/RequestCookies.d.ts +17 -0
- package/build/src/runtime/modules/RequestCookies.js +133 -0
- package/build/src/runtime/modules/RequestCookies.js.map +1 -0
- package/build/src/runtime/node/ProjectRunner.d.ts +125 -0
- package/build/src/runtime/node/ProjectRunner.js +178 -0
- package/build/src/runtime/node/ProjectRunner.js.map +1 -0
- package/build/src/runtime/node/RequestFactory.d.ts +139 -0
- package/build/src/runtime/node/RequestFactory.js +397 -0
- package/build/src/runtime/node/RequestFactory.js.map +1 -0
- package/build/src/runtime/node/VariablesStore.d.ts +9 -0
- package/build/src/runtime/node/VariablesStore.js +19 -0
- package/build/src/runtime/node/VariablesStore.js.map +1 -0
- package/build/src/runtime/variables/Cache.d.ts +23 -0
- package/build/src/runtime/variables/Cache.js +51 -0
- package/build/src/runtime/variables/Cache.js.map +1 -0
- package/build/src/runtime/variables/EvalFunctions.d.ts +58 -0
- package/build/src/runtime/variables/EvalFunctions.js +123 -0
- package/build/src/runtime/variables/EvalFunctions.js.map +1 -0
- package/build/src/runtime/variables/ProjectVariables.d.ts +5 -0
- package/build/src/runtime/variables/ProjectVariables.js +6 -0
- package/build/src/runtime/variables/ProjectVariables.js.map +1 -0
- package/build/src/runtime/variables/VariablesProcessor.d.ts +165 -0
- package/build/src/runtime/variables/VariablesProcessor.js +515 -0
- package/build/src/runtime/variables/VariablesProcessor.js.map +1 -0
- package/build/src/runtime/variables/VariablesTokenizer.d.ts +26 -0
- package/build/src/runtime/variables/VariablesTokenizer.js +53 -0
- package/build/src/runtime/variables/VariablesTokenizer.js.map +1 -0
- package/package.json +97 -0
- package/readme.md +51 -0
|
@@ -0,0 +1,987 @@
|
|
|
1
|
+
import { ProjectParent } from './ProjectParent.js';
|
|
2
|
+
import { Environment } from './Environment.js';
|
|
3
|
+
import { License } from './License.js';
|
|
4
|
+
import { Provider } from './Provider.js';
|
|
5
|
+
import { Thing, Kind as ThingKind } from './Thing.js';
|
|
6
|
+
import { ProjectItem } from './ProjectItem.js';
|
|
7
|
+
import { ProjectFolder, Kind as ProjectFolderKind } from './ProjectFolder.js';
|
|
8
|
+
import { ProjectRequest, Kind as ProjectRequestKind } from './ProjectRequest.js';
|
|
9
|
+
import { ProjectSchema } from './ProjectSchema.js';
|
|
10
|
+
import { Request } from './Request.js';
|
|
11
|
+
import v4 from '../lib/uuid.js';
|
|
12
|
+
import { PostmanDataTransformer } from './transformers/PostmanDataTransformer.js';
|
|
13
|
+
export const Kind = 'ARC#HttpProject';
|
|
14
|
+
/**
|
|
15
|
+
* An instance of an HttpProject.
|
|
16
|
+
*/
|
|
17
|
+
export class HttpProject extends ProjectParent {
|
|
18
|
+
kind = Kind;
|
|
19
|
+
initEnvironments;
|
|
20
|
+
/**
|
|
21
|
+
* The license information for this HTTP project.
|
|
22
|
+
*/
|
|
23
|
+
license;
|
|
24
|
+
/**
|
|
25
|
+
* Information about project provider.
|
|
26
|
+
*/
|
|
27
|
+
provider;
|
|
28
|
+
/**
|
|
29
|
+
* The list of all requests stored in this project.
|
|
30
|
+
* Note, this is not used to visualized the request in the UI.
|
|
31
|
+
* This is just the source of data.
|
|
32
|
+
* The `items` property is used to build the view.
|
|
33
|
+
*/
|
|
34
|
+
definitions = HttpProject.defaultDefinitions();
|
|
35
|
+
static defaultDefinitions() {
|
|
36
|
+
return { environments: [], folders: [], requests: [], schemas: [] };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new HTTP project from a name.
|
|
40
|
+
* @param {string} name The name to set.
|
|
41
|
+
*/
|
|
42
|
+
static fromName(name) {
|
|
43
|
+
const project = new HttpProject();
|
|
44
|
+
const info = Thing.fromName(name);
|
|
45
|
+
project.info = info;
|
|
46
|
+
return project;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates an HTTP project instance from ARC's legacy project definition.
|
|
50
|
+
*/
|
|
51
|
+
static async fromLegacy(project, requests) {
|
|
52
|
+
const { name = 'Unnamed project', description, requests: ids } = project;
|
|
53
|
+
const typedLegacyDb = project;
|
|
54
|
+
const result = HttpProject.fromName(name);
|
|
55
|
+
if (typedLegacyDb._id) {
|
|
56
|
+
result.key = typedLegacyDb._id;
|
|
57
|
+
}
|
|
58
|
+
if (description) {
|
|
59
|
+
result.info.description = description;
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(ids) && ids.length) {
|
|
62
|
+
const promises = ids.map(async (id) => {
|
|
63
|
+
const old = requests.find((item) => item._id === id);
|
|
64
|
+
if (!old) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const request = await Request.fromLegacy(old);
|
|
68
|
+
const projectRequest = ProjectRequest.fromRequest(request.toJSON(), result);
|
|
69
|
+
if (old._id) {
|
|
70
|
+
projectRequest.key = old._id;
|
|
71
|
+
}
|
|
72
|
+
result.addRequest(projectRequest);
|
|
73
|
+
});
|
|
74
|
+
await Promise.allSettled(promises);
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates an HTTP project from a Postman collection
|
|
80
|
+
* @param init The postman collection object or a string that can be parsed to one.
|
|
81
|
+
*/
|
|
82
|
+
static async fromPostman(init) {
|
|
83
|
+
const result = await PostmanDataTransformer.transform(init);
|
|
84
|
+
if (Array.isArray(result) && result.length > 1) {
|
|
85
|
+
throw new Error(`Unable to process postman data. It contains multiple collections.`);
|
|
86
|
+
}
|
|
87
|
+
const project = Array.isArray(result) ? result[0] : result;
|
|
88
|
+
return project;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Creates a new project from a set of options.
|
|
92
|
+
*/
|
|
93
|
+
static fromInitOptions(init) {
|
|
94
|
+
const { name = 'Unnamed project' } = init;
|
|
95
|
+
return HttpProject.fromName(name);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @param input The project definition used to restore the state.
|
|
99
|
+
* @param environments Optional list of environments to use with this project. It overrides environments stored in the project definition.
|
|
100
|
+
*/
|
|
101
|
+
constructor(input, environments) {
|
|
102
|
+
super();
|
|
103
|
+
if (Array.isArray(environments)) {
|
|
104
|
+
this.initEnvironments = environments.map(i => new Environment(i));
|
|
105
|
+
}
|
|
106
|
+
let init;
|
|
107
|
+
if (typeof input === 'string') {
|
|
108
|
+
init = JSON.parse(input);
|
|
109
|
+
}
|
|
110
|
+
else if (typeof input === 'object') {
|
|
111
|
+
init = input;
|
|
112
|
+
if (!init.kind) {
|
|
113
|
+
init.kind = Kind;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
init = {
|
|
118
|
+
kind: Kind,
|
|
119
|
+
key: v4(),
|
|
120
|
+
definitions: {},
|
|
121
|
+
items: [],
|
|
122
|
+
info: {
|
|
123
|
+
kind: ThingKind,
|
|
124
|
+
name: '',
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
this.new(init);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Creates a new project definition clearing anything that is so far defined.
|
|
132
|
+
*
|
|
133
|
+
* Note, this throws an error when the project is not an ARC project.
|
|
134
|
+
*/
|
|
135
|
+
new(init) {
|
|
136
|
+
if (!init || !init.definitions || !init.items) {
|
|
137
|
+
throw new Error(`Not an ARC project.`);
|
|
138
|
+
}
|
|
139
|
+
const { key = v4(), definitions = {}, items, info, license, provider, environments } = init;
|
|
140
|
+
this.key = key;
|
|
141
|
+
this.environments = [];
|
|
142
|
+
if (Array.isArray(environments)) {
|
|
143
|
+
this.environments = environments;
|
|
144
|
+
}
|
|
145
|
+
if (license) {
|
|
146
|
+
this.license = new License(license);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
this.license = undefined;
|
|
150
|
+
}
|
|
151
|
+
if (provider) {
|
|
152
|
+
this.provider = new Provider(provider);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this.provider = undefined;
|
|
156
|
+
}
|
|
157
|
+
if (info) {
|
|
158
|
+
this.info = new Thing(info);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.info = new Thing({ kind: ThingKind, name: '' });
|
|
162
|
+
}
|
|
163
|
+
this.items = [];
|
|
164
|
+
if (Array.isArray(items)) {
|
|
165
|
+
this.items = items.map(i => new ProjectItem(this, i));
|
|
166
|
+
}
|
|
167
|
+
this.definitions = HttpProject.defaultDefinitions();
|
|
168
|
+
if (Array.isArray(definitions.environments)) {
|
|
169
|
+
this.definitions.environments = definitions.environments.map(i => new Environment(i));
|
|
170
|
+
}
|
|
171
|
+
if (Array.isArray(definitions.requests)) {
|
|
172
|
+
this.definitions.requests = definitions.requests.map(i => {
|
|
173
|
+
const instance = new ProjectRequest(this, i);
|
|
174
|
+
instance.attachedCallback();
|
|
175
|
+
return instance;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (Array.isArray(definitions.folders)) {
|
|
179
|
+
this.definitions.folders = definitions.folders.map(i => {
|
|
180
|
+
const instance = new ProjectFolder(this, i);
|
|
181
|
+
instance.attachedCallback();
|
|
182
|
+
return instance;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (Array.isArray(definitions.schemas)) {
|
|
186
|
+
this.definitions.schemas = definitions.schemas.map(i => new ProjectSchema(i));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
toJSON() {
|
|
190
|
+
const result = {
|
|
191
|
+
kind: Kind,
|
|
192
|
+
key: this.key,
|
|
193
|
+
definitions: {},
|
|
194
|
+
environments: [],
|
|
195
|
+
items: [],
|
|
196
|
+
info: this.info.toJSON(),
|
|
197
|
+
};
|
|
198
|
+
if (Array.isArray(this.definitions.environments) && this.definitions.environments.length) {
|
|
199
|
+
result.definitions.environments = this.definitions.environments.map(i => i.toJSON());
|
|
200
|
+
}
|
|
201
|
+
if (Array.isArray(this.definitions.requests) && this.definitions.requests.length) {
|
|
202
|
+
result.definitions.requests = this.definitions.requests.map(i => i.toJSON());
|
|
203
|
+
}
|
|
204
|
+
if (Array.isArray(this.definitions.folders) && this.definitions.folders.length) {
|
|
205
|
+
result.definitions.folders = this.definitions.folders.map(i => i.toJSON());
|
|
206
|
+
}
|
|
207
|
+
if (Array.isArray(this.definitions.schemas) && this.definitions.schemas.length) {
|
|
208
|
+
result.definitions.schemas = this.definitions.schemas.map(i => i.toJSON());
|
|
209
|
+
}
|
|
210
|
+
if (Array.isArray(this.environments) && this.environments.length) {
|
|
211
|
+
result.environments = this.environments;
|
|
212
|
+
}
|
|
213
|
+
if (Array.isArray(this.items) && this.items.length) {
|
|
214
|
+
result.items = this.items.map(i => i.toJSON());
|
|
215
|
+
}
|
|
216
|
+
if (this.provider) {
|
|
217
|
+
result.provider = this.provider.toJSON();
|
|
218
|
+
}
|
|
219
|
+
if (this.license) {
|
|
220
|
+
result.license = this.license.toJSON();
|
|
221
|
+
}
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @returns JSON representation of the project
|
|
226
|
+
*/
|
|
227
|
+
toString() {
|
|
228
|
+
return JSON.stringify(this);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Finds a parent of a definition.
|
|
232
|
+
*
|
|
233
|
+
* @param key The key of the definition.
|
|
234
|
+
* @returns The parent or undefine when not found.
|
|
235
|
+
*/
|
|
236
|
+
findParent(key) {
|
|
237
|
+
const { definitions, items = [] } = this;
|
|
238
|
+
const projectItemsIndex = items.findIndex(i => i.key === key);
|
|
239
|
+
if (projectItemsIndex > -1) {
|
|
240
|
+
return this;
|
|
241
|
+
}
|
|
242
|
+
const definition = definitions.folders.find(i => i.items.some(item => item.key === key));
|
|
243
|
+
if (definition) {
|
|
244
|
+
return definition;
|
|
245
|
+
}
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Appends a new folder to the project or a sub-folder.
|
|
250
|
+
*
|
|
251
|
+
* Passing the folder schema as the fist argument is primarily used to insert a folder on the client side
|
|
252
|
+
* after a folder was created in the store.
|
|
253
|
+
*
|
|
254
|
+
* @param init The name or a folder schema. When not set a default name is assumed.
|
|
255
|
+
* @param opts Folder create options.
|
|
256
|
+
* @returns The newly inserted folder. If the folder already existed it returns its instance.
|
|
257
|
+
*/
|
|
258
|
+
addFolder(init = ProjectFolder.defaultName, opts = {}) {
|
|
259
|
+
if (!Array.isArray(this.items)) {
|
|
260
|
+
this.items = [];
|
|
261
|
+
}
|
|
262
|
+
if (!Array.isArray(this.definitions.folders)) {
|
|
263
|
+
this.definitions.folders = [];
|
|
264
|
+
}
|
|
265
|
+
const { skipExisting, parent } = opts;
|
|
266
|
+
let root;
|
|
267
|
+
if (parent) {
|
|
268
|
+
const rootCandidate = this.findFolder(parent);
|
|
269
|
+
if (!rootCandidate) {
|
|
270
|
+
throw new Error(`Unable to find the parent folder ${parent}`);
|
|
271
|
+
}
|
|
272
|
+
root = rootCandidate;
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
root = this;
|
|
276
|
+
}
|
|
277
|
+
let definition;
|
|
278
|
+
if (typeof init === 'string') {
|
|
279
|
+
definition = ProjectFolder.fromName(this, init);
|
|
280
|
+
}
|
|
281
|
+
else if (init instanceof ProjectFolder) {
|
|
282
|
+
definition = init;
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
definition = new ProjectFolder(this, init);
|
|
286
|
+
}
|
|
287
|
+
if (skipExisting) {
|
|
288
|
+
const folders = root.listFolderItems();
|
|
289
|
+
for (const item of folders) {
|
|
290
|
+
const existing = this.findFolder(item.key, { keyOnly: true });
|
|
291
|
+
if (existing && existing.info.name === definition.info.name) {
|
|
292
|
+
return existing;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
this.definitions.folders.push(definition);
|
|
297
|
+
const item = ProjectItem.projectFolder(this, definition.key);
|
|
298
|
+
if (!Array.isArray(root.items)) {
|
|
299
|
+
root.items = [];
|
|
300
|
+
}
|
|
301
|
+
if (typeof opts.index === 'number') {
|
|
302
|
+
root.items.splice(opts.index, 0, item);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
root.items.push(item);
|
|
306
|
+
}
|
|
307
|
+
definition.attachedCallback();
|
|
308
|
+
return definition;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Searches for a folder in the structure.
|
|
312
|
+
*
|
|
313
|
+
* @param nameOrKey The name or the key of the folder.
|
|
314
|
+
* @param opts Optional search options.
|
|
315
|
+
* @returns Found project folder or undefined.
|
|
316
|
+
*/
|
|
317
|
+
findFolder(nameOrKey, opts = {}) {
|
|
318
|
+
const { definitions } = this;
|
|
319
|
+
const item = definitions.folders.find((i) => {
|
|
320
|
+
if (i.kind !== ProjectFolderKind) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
const folder = i;
|
|
324
|
+
if (folder.key === nameOrKey) {
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
if (opts.keyOnly) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
return !!folder.info && folder.info.name === nameOrKey;
|
|
331
|
+
});
|
|
332
|
+
if (item) {
|
|
333
|
+
return item;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Removes a folder from the project.
|
|
338
|
+
* @param key The folder key. It ignores the name when searching to the folder to avoid ambiguity.
|
|
339
|
+
* @param opts Folder remove options.
|
|
340
|
+
* @returns The removed folder definition or undefined when not removed.
|
|
341
|
+
*/
|
|
342
|
+
removeFolder(key, opts = {}) {
|
|
343
|
+
const { definitions } = this;
|
|
344
|
+
const folder = this.findFolder(key, { keyOnly: true });
|
|
345
|
+
if (!folder) {
|
|
346
|
+
if (opts.safe) {
|
|
347
|
+
return undefined;
|
|
348
|
+
}
|
|
349
|
+
throw new Error(`Unable to find the folder ${key}`);
|
|
350
|
+
}
|
|
351
|
+
const parent = this.findParent(key);
|
|
352
|
+
if (!parent) {
|
|
353
|
+
if (opts.safe) {
|
|
354
|
+
return undefined;
|
|
355
|
+
}
|
|
356
|
+
throw new Error(`Unable to find a parent of the folder ${key}`);
|
|
357
|
+
}
|
|
358
|
+
const requests = folder.listRequests();
|
|
359
|
+
requests.forEach(r => r.remove());
|
|
360
|
+
const folders = folder.listFolders();
|
|
361
|
+
folders.forEach(f => f.remove());
|
|
362
|
+
const itemIndex = parent.items.findIndex(i => i.key === key);
|
|
363
|
+
const definitionIndex = definitions.folders.findIndex(i => i.key === key);
|
|
364
|
+
definitions.folders.splice(definitionIndex, 1);
|
|
365
|
+
folder.detachedCallback();
|
|
366
|
+
if (itemIndex >= 0) {
|
|
367
|
+
parent.items.splice(itemIndex, 1);
|
|
368
|
+
}
|
|
369
|
+
return folder;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Moves a folder between folders and the project or between items inside a folder or a project
|
|
373
|
+
*
|
|
374
|
+
* Note, when the `parent` option is not specified it moved the folder to the project's root.
|
|
375
|
+
*
|
|
376
|
+
* @param key The key of the request to move.
|
|
377
|
+
* @param opts The moving options.
|
|
378
|
+
*/
|
|
379
|
+
moveFolder(key, opts = {}) {
|
|
380
|
+
const { index, parent } = opts;
|
|
381
|
+
const movedFolder = this.findFolder(key);
|
|
382
|
+
if (!movedFolder) {
|
|
383
|
+
throw new Error(`Unable to locate the folder ${key}`);
|
|
384
|
+
}
|
|
385
|
+
const parentFolder = this.findParent(key);
|
|
386
|
+
if (!parentFolder) {
|
|
387
|
+
throw new Error(`Unable to locate a parent of the folder ${key}`);
|
|
388
|
+
}
|
|
389
|
+
if (parent) {
|
|
390
|
+
// check if moving a folder into another folder that is a child of the moved folder.
|
|
391
|
+
if (this.hasChild(parent, key)) {
|
|
392
|
+
throw new RangeError(`Unable to move a folder to its child.`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
const target = parent ? this.findFolder(parent) : this;
|
|
396
|
+
if (!target) {
|
|
397
|
+
throw new Error(`Unable to locate the new parent folder ${parent}`);
|
|
398
|
+
}
|
|
399
|
+
const hasIndex = typeof index === 'number';
|
|
400
|
+
if (hasIndex) {
|
|
401
|
+
// comparing to the `.length` and not `.length - 1` in case we are adding at the end.
|
|
402
|
+
const maxIndex = Math.max(target.items.length, 0);
|
|
403
|
+
if (index > maxIndex) {
|
|
404
|
+
throw new RangeError(`Index out of bounds. Maximum index is ${maxIndex}.`);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const itemIndex = parentFolder.items.findIndex(i => i.key === key);
|
|
408
|
+
const item = parentFolder.items.splice(itemIndex, 1)[0];
|
|
409
|
+
movedFolder.detachedCallback();
|
|
410
|
+
if (hasIndex && target.items.length > index) {
|
|
411
|
+
target.items.splice(index, 0, item);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
target.items.push(item);
|
|
415
|
+
}
|
|
416
|
+
movedFolder.attachedCallback();
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Checks whether a folder has a child (anywhere down the structure).
|
|
420
|
+
*
|
|
421
|
+
* @param child The **key** of the child.
|
|
422
|
+
* @param folder The **key** of the folder. When not set it searches from the project root.
|
|
423
|
+
* @returns True when the child is located somewhere down the structure.
|
|
424
|
+
*/
|
|
425
|
+
hasChild(child, folder) {
|
|
426
|
+
const target = folder ? this.findFolder(folder) : this;
|
|
427
|
+
if (!target) {
|
|
428
|
+
throw new Error(`Unable to locate the folder ${folder}`);
|
|
429
|
+
}
|
|
430
|
+
const { items = [] } = target;
|
|
431
|
+
for (const item of items) {
|
|
432
|
+
if (item.key === child) {
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
if (item.kind === ProjectFolderKind) {
|
|
436
|
+
const hasChild = this.hasChild(child, item.key);
|
|
437
|
+
if (hasChild) {
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Adds a request to the project or a sub-folder.
|
|
446
|
+
* @param request The request to add.
|
|
447
|
+
* @param opts Thew request add options.
|
|
448
|
+
* @returns The inserted into the definitions request.
|
|
449
|
+
*/
|
|
450
|
+
addRequest(request, opts = {}) {
|
|
451
|
+
if (!Array.isArray(this.definitions.requests)) {
|
|
452
|
+
this.definitions.requests = [];
|
|
453
|
+
}
|
|
454
|
+
// the request can be already added to the project as the same method is used to refresh a request after
|
|
455
|
+
// a store update. From the system perspective it is the same event.
|
|
456
|
+
if (typeof request === 'object' && request.key) {
|
|
457
|
+
const existing = this.definitions.requests.find(i => i.key === request.key);
|
|
458
|
+
if (existing) {
|
|
459
|
+
existing.new(request);
|
|
460
|
+
return existing;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
// if we got here, it means that we are adding a new request object to the project.
|
|
464
|
+
let finalRequest;
|
|
465
|
+
if (typeof request === 'string') {
|
|
466
|
+
finalRequest = ProjectRequest.fromUrl(request, this);
|
|
467
|
+
}
|
|
468
|
+
else if (request instanceof ProjectRequest) {
|
|
469
|
+
finalRequest = request;
|
|
470
|
+
if (finalRequest.project && finalRequest.project !== this) {
|
|
471
|
+
finalRequest.detachedCallback();
|
|
472
|
+
}
|
|
473
|
+
finalRequest.project = this;
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
finalRequest = new ProjectRequest(this, request);
|
|
477
|
+
}
|
|
478
|
+
if (!finalRequest.key) {
|
|
479
|
+
finalRequest.key = v4();
|
|
480
|
+
}
|
|
481
|
+
let root;
|
|
482
|
+
if (opts.parent) {
|
|
483
|
+
const rootCandidate = this.findFolder(opts.parent);
|
|
484
|
+
if (!rootCandidate) {
|
|
485
|
+
throw new Error(`Unable to find the parent folder ${opts.parent}.`);
|
|
486
|
+
}
|
|
487
|
+
root = rootCandidate;
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
root = this;
|
|
491
|
+
}
|
|
492
|
+
if (!Array.isArray(root.items)) {
|
|
493
|
+
root.items = [];
|
|
494
|
+
}
|
|
495
|
+
if (typeof opts.index === 'number') {
|
|
496
|
+
const maxIndex = Math.max(root.items.length - 1, 0);
|
|
497
|
+
if (opts.index > maxIndex) {
|
|
498
|
+
throw new RangeError(`Index out of bounds. Maximum index is ${maxIndex}.`);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
this.definitions.requests.push(finalRequest);
|
|
502
|
+
const item = ProjectItem.projectRequest(this, finalRequest.key);
|
|
503
|
+
if (typeof opts.index === 'number') {
|
|
504
|
+
root.items.splice(opts.index, 0, item);
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
root.items.push(item);
|
|
508
|
+
}
|
|
509
|
+
finalRequest.attachedCallback();
|
|
510
|
+
return finalRequest;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Adds a request to the project that has been created for a previous version of ARC.
|
|
514
|
+
*
|
|
515
|
+
* @param legacy The legacy request definition.
|
|
516
|
+
* @returns The created project request.
|
|
517
|
+
*/
|
|
518
|
+
async addLegacyRequest(legacy) {
|
|
519
|
+
const request = await Request.fromLegacy(legacy);
|
|
520
|
+
const projectRequest = ProjectRequest.fromRequest(request.toJSON(), this);
|
|
521
|
+
return this.addRequest(projectRequest);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Searches for a request in the project.
|
|
525
|
+
*
|
|
526
|
+
* @param nameOrKey The name or the key of the request.
|
|
527
|
+
* @param opts Optional search options.
|
|
528
|
+
* @returns Found project request or undefined.
|
|
529
|
+
*/
|
|
530
|
+
findRequest(nameOrKey, opts = {}) {
|
|
531
|
+
const { definitions } = this;
|
|
532
|
+
const item = definitions.requests.find((request) => {
|
|
533
|
+
if (request.key === nameOrKey) {
|
|
534
|
+
return true;
|
|
535
|
+
}
|
|
536
|
+
if (opts.keyOnly) {
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
return !!request.info && request.info.name === nameOrKey;
|
|
540
|
+
});
|
|
541
|
+
if (item) {
|
|
542
|
+
return item;
|
|
543
|
+
}
|
|
544
|
+
return undefined;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Removes a request from the project.
|
|
548
|
+
*
|
|
549
|
+
* @param key The request key. It ignores the name when searching to the request to avoid ambiguity.
|
|
550
|
+
* @param opts Request remove options.
|
|
551
|
+
* @returns The removed request definition or undefined when not removed.
|
|
552
|
+
*/
|
|
553
|
+
removeRequest(key, opts = {}) {
|
|
554
|
+
const { definitions } = this;
|
|
555
|
+
const request = this.findRequest(key, { keyOnly: true });
|
|
556
|
+
if (!request) {
|
|
557
|
+
if (opts.safe) {
|
|
558
|
+
return undefined;
|
|
559
|
+
}
|
|
560
|
+
throw new Error(`Unable to find the request ${key}`);
|
|
561
|
+
}
|
|
562
|
+
const parent = this.findParent(key);
|
|
563
|
+
if (!parent) {
|
|
564
|
+
if (opts.safe) {
|
|
565
|
+
return undefined;
|
|
566
|
+
}
|
|
567
|
+
throw new Error(`Unable to find a parent of the request ${key}`);
|
|
568
|
+
}
|
|
569
|
+
const itemIndex = parent.items.findIndex(i => i.key === key);
|
|
570
|
+
const definitionIndex = definitions.requests.findIndex(i => i.key === key);
|
|
571
|
+
definitions.requests.splice(definitionIndex, 1);
|
|
572
|
+
request.detachedCallback();
|
|
573
|
+
if (itemIndex >= 0) {
|
|
574
|
+
parent.items.splice(itemIndex, 1);
|
|
575
|
+
}
|
|
576
|
+
return request;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Moves a request between folders and the project or between items inside a folder or a project.
|
|
580
|
+
*
|
|
581
|
+
* Note, when the `parent` option is not specified it moved the request to the project's root.
|
|
582
|
+
*
|
|
583
|
+
* @param key The key of the request to move.
|
|
584
|
+
* @param opts The moving options.
|
|
585
|
+
*/
|
|
586
|
+
moveRequest(key, opts = {}) {
|
|
587
|
+
const { index, parent } = opts;
|
|
588
|
+
const request = this.findRequest(key);
|
|
589
|
+
if (!request) {
|
|
590
|
+
throw new Error(`Unable to locate the request ${key}`);
|
|
591
|
+
}
|
|
592
|
+
const parentFolder = this.findParent(key);
|
|
593
|
+
if (!parentFolder) {
|
|
594
|
+
throw new Error(`Unable to locate a parent of the request ${key}`);
|
|
595
|
+
}
|
|
596
|
+
const target = parent ? this.findFolder(parent) : this;
|
|
597
|
+
if (!target) {
|
|
598
|
+
throw new Error(`Unable to locate the new parent folder ${parent}`);
|
|
599
|
+
}
|
|
600
|
+
const hasIndex = typeof index === 'number';
|
|
601
|
+
if (hasIndex) {
|
|
602
|
+
// comparing to the `.length` and not `.length - 1` in case we are adding at the end.
|
|
603
|
+
const maxIndex = Math.max(target.items.length, 0);
|
|
604
|
+
if (index > maxIndex) {
|
|
605
|
+
throw new RangeError(`Index out of bounds. Maximum index is ${maxIndex}.`);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
const itemIndex = parentFolder.items.findIndex(i => i.key === key);
|
|
609
|
+
const item = parentFolder.items.splice(itemIndex, 1)[0];
|
|
610
|
+
request.detachedCallback();
|
|
611
|
+
if (hasIndex && target.items.length > index) {
|
|
612
|
+
target.items.splice(index, 0, item);
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
target.items.push(item);
|
|
616
|
+
}
|
|
617
|
+
request.attachedCallback();
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Lists items (not the actual definitions!) that are folders.
|
|
621
|
+
*/
|
|
622
|
+
listFolderItems() {
|
|
623
|
+
const { items = [] } = this;
|
|
624
|
+
return items.filter(i => i.kind === ProjectFolderKind);
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Lists items (not the actual definitions!) that are requests.
|
|
628
|
+
*/
|
|
629
|
+
listRequestItems() {
|
|
630
|
+
const { items = [] } = this;
|
|
631
|
+
return items.filter(i => i.kind === ProjectRequestKind);
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Lists folders from the project or a sub-folder.
|
|
635
|
+
* @param opts Folder listing options.
|
|
636
|
+
*/
|
|
637
|
+
listFolders(opts = {}) {
|
|
638
|
+
let root;
|
|
639
|
+
if (opts.folder) {
|
|
640
|
+
const parent = this.findFolder(opts.folder);
|
|
641
|
+
if (!parent) {
|
|
642
|
+
throw new Error(`Unable to find the folder ${opts.folder}.`);
|
|
643
|
+
}
|
|
644
|
+
root = parent;
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
root = this;
|
|
648
|
+
}
|
|
649
|
+
const items = root.listFolderItems();
|
|
650
|
+
const result = [];
|
|
651
|
+
const { definitions } = this;
|
|
652
|
+
items.forEach((i) => {
|
|
653
|
+
const definition = definitions.folders.find(d => i.key === d.key);
|
|
654
|
+
if (definition) {
|
|
655
|
+
result.push(definition);
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
return result;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Lists requests in this project or a sub-folder.
|
|
662
|
+
* @param folder The optional folder name or the key to list requests for.
|
|
663
|
+
*/
|
|
664
|
+
listRequests(folder) {
|
|
665
|
+
let root;
|
|
666
|
+
if (folder) {
|
|
667
|
+
const parent = this.findFolder(folder);
|
|
668
|
+
if (!parent) {
|
|
669
|
+
throw new Error(`Unable to find the folder ${folder}.`);
|
|
670
|
+
}
|
|
671
|
+
root = parent;
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
root = this;
|
|
675
|
+
}
|
|
676
|
+
const items = root.listRequestItems();
|
|
677
|
+
const result = [];
|
|
678
|
+
const { definitions } = this;
|
|
679
|
+
items.forEach((i) => {
|
|
680
|
+
const definition = definitions.requests.find(d => i.key === d.key);
|
|
681
|
+
if (definition) {
|
|
682
|
+
result.push(definition);
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
return result;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Lists definitions for the `items` of the project or a folder.
|
|
689
|
+
* @param folder Optionally the folder name to list the definitions for.
|
|
690
|
+
*/
|
|
691
|
+
listDefinitions(folder) {
|
|
692
|
+
let root;
|
|
693
|
+
if (folder) {
|
|
694
|
+
const parent = this.findFolder(folder);
|
|
695
|
+
if (!parent) {
|
|
696
|
+
throw new Error(`Unable to find the folder ${folder}`);
|
|
697
|
+
}
|
|
698
|
+
root = parent;
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
root = this;
|
|
702
|
+
}
|
|
703
|
+
const result = [];
|
|
704
|
+
const { items = [] } = root;
|
|
705
|
+
const { definitions } = this;
|
|
706
|
+
items.forEach((item) => {
|
|
707
|
+
let definition;
|
|
708
|
+
if (item.kind === ProjectFolderKind) {
|
|
709
|
+
definition = definitions.folders.find(d => item.key === d.key);
|
|
710
|
+
}
|
|
711
|
+
else if (item.kind === ProjectRequestKind) {
|
|
712
|
+
definition = definitions.requests.find(d => item.key === d.key);
|
|
713
|
+
}
|
|
714
|
+
if (definition) {
|
|
715
|
+
result.push(definition);
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
if (Array.isArray(root.environments)) {
|
|
719
|
+
root.environments.map((id) => {
|
|
720
|
+
const definition = definitions.environments.find(d => d.key === id);
|
|
721
|
+
if (definition) {
|
|
722
|
+
result.push(definition);
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
return result;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Makes sure the license information exists.
|
|
730
|
+
* @returns The set license.
|
|
731
|
+
*/
|
|
732
|
+
ensureLicense() {
|
|
733
|
+
if (!this.license) {
|
|
734
|
+
this.license = new License();
|
|
735
|
+
}
|
|
736
|
+
return this.license;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Makes sure the Provider information exists.
|
|
740
|
+
* @returns The set provider.
|
|
741
|
+
*/
|
|
742
|
+
ensureProvider() {
|
|
743
|
+
if (!this.provider) {
|
|
744
|
+
this.provider = new Provider();
|
|
745
|
+
}
|
|
746
|
+
return this.provider;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* @returns On the project level this always returns undefined.
|
|
750
|
+
*/
|
|
751
|
+
getParent() {
|
|
752
|
+
return undefined;
|
|
753
|
+
}
|
|
754
|
+
attachedCallback() {
|
|
755
|
+
// ...
|
|
756
|
+
}
|
|
757
|
+
detachedCallback() {
|
|
758
|
+
// ...
|
|
759
|
+
}
|
|
760
|
+
getProject() {
|
|
761
|
+
return this;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Reads the list of environments from then selected folder up to the project environments.
|
|
765
|
+
* It stops going up in the project structure when selected environment has the `encapsulated`
|
|
766
|
+
* property set to true.
|
|
767
|
+
* The environments are ordered from the top-most level to the selected folder.
|
|
768
|
+
*
|
|
769
|
+
* @param opts The environment read options
|
|
770
|
+
*/
|
|
771
|
+
async readEnvironments(opts = {}) {
|
|
772
|
+
const result = [];
|
|
773
|
+
const { folderKey, nameOrKey } = opts;
|
|
774
|
+
const root = folderKey ? this.findFolder(folderKey, { keyOnly: true }) : this;
|
|
775
|
+
if (!root) {
|
|
776
|
+
return result;
|
|
777
|
+
}
|
|
778
|
+
let current = root;
|
|
779
|
+
while (current) {
|
|
780
|
+
const environments = current.getEnvironments();
|
|
781
|
+
if (environments.length) {
|
|
782
|
+
const selected = nameOrKey ? environments.find(i => i.key === nameOrKey || i.info.name === nameOrKey) : environments[0];
|
|
783
|
+
if (selected) {
|
|
784
|
+
result.push(selected);
|
|
785
|
+
if (selected.encapsulated) {
|
|
786
|
+
break;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
current = current.getParent();
|
|
791
|
+
}
|
|
792
|
+
return result.reverse();
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Makes a copy of this project.
|
|
796
|
+
*/
|
|
797
|
+
clone(opts = {}) {
|
|
798
|
+
const copy = new HttpProject(this.toJSON());
|
|
799
|
+
if (!opts.withoutRevalidate) {
|
|
800
|
+
copy.key = v4();
|
|
801
|
+
HttpProject.regenerateKeys(copy);
|
|
802
|
+
}
|
|
803
|
+
return copy;
|
|
804
|
+
}
|
|
805
|
+
static clone(project, opts = {}) {
|
|
806
|
+
const obj = new HttpProject(project);
|
|
807
|
+
return obj.clone(opts);
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Re-generates keys in the project, taking care of the references.
|
|
811
|
+
*
|
|
812
|
+
* Note, this changes the project properties. Make a copy of the project before calling this.
|
|
813
|
+
*
|
|
814
|
+
* @param src The project instance to re-generate keys for.
|
|
815
|
+
*/
|
|
816
|
+
static regenerateKeys(src) {
|
|
817
|
+
const { items = [], definitions } = src;
|
|
818
|
+
// create a flat list of all "items" in the project and all folders.
|
|
819
|
+
let flatItems = [...items];
|
|
820
|
+
(definitions.folders || []).forEach((folder) => {
|
|
821
|
+
if (Array.isArray(folder.items) && folder.items.length) {
|
|
822
|
+
flatItems = flatItems.concat(folder.items);
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
const withEnvironments = [];
|
|
826
|
+
if (Array.isArray(src.environments) && src.environments.length) {
|
|
827
|
+
withEnvironments.push(src);
|
|
828
|
+
}
|
|
829
|
+
(definitions.folders || []).forEach((folder) => {
|
|
830
|
+
if (Array.isArray(folder.environments) && folder.environments.length) {
|
|
831
|
+
withEnvironments.push(folder);
|
|
832
|
+
}
|
|
833
|
+
const oldKey = folder.key;
|
|
834
|
+
const indexObject = flatItems.find(i => i.key === oldKey);
|
|
835
|
+
if (!indexObject) {
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
const newKey = v4();
|
|
839
|
+
indexObject.key = newKey;
|
|
840
|
+
folder.key = newKey;
|
|
841
|
+
});
|
|
842
|
+
(definitions.requests || []).forEach((request) => {
|
|
843
|
+
const oldKey = request.key;
|
|
844
|
+
const indexObject = flatItems.find(i => i.key === oldKey);
|
|
845
|
+
if (!indexObject) {
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
const newKey = v4();
|
|
849
|
+
indexObject.key = newKey;
|
|
850
|
+
request.key = newKey;
|
|
851
|
+
});
|
|
852
|
+
(definitions.schemas || []).forEach((schema) => {
|
|
853
|
+
schema.key = v4();
|
|
854
|
+
});
|
|
855
|
+
(definitions.environments || []).forEach((environment) => {
|
|
856
|
+
// project or folder that has the environment.
|
|
857
|
+
const parent = withEnvironments.find(item => item.environments.includes(environment.key));
|
|
858
|
+
const oldKey = environment.key;
|
|
859
|
+
const newKey = v4();
|
|
860
|
+
environment.key = newKey;
|
|
861
|
+
if (parent) {
|
|
862
|
+
const index = parent.environments.indexOf(oldKey);
|
|
863
|
+
parent.environments[index] = newKey;
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Adds a request to the project or a sub-folder.
|
|
869
|
+
* @param schema The schema to add.
|
|
870
|
+
* @param opts Thew schema add options.
|
|
871
|
+
* @returns The inserted into the schemas schema.
|
|
872
|
+
*/
|
|
873
|
+
addSchema(schema, opts = {}) {
|
|
874
|
+
if (!Array.isArray(this.definitions.schemas)) {
|
|
875
|
+
this.definitions.schemas = [];
|
|
876
|
+
}
|
|
877
|
+
// this renews existing schema
|
|
878
|
+
if (typeof schema === 'object' && schema.key) {
|
|
879
|
+
const existing = this.definitions.schemas.find(i => i.key === schema.key);
|
|
880
|
+
if (existing) {
|
|
881
|
+
existing.new(schema);
|
|
882
|
+
return existing;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
let finalSchema;
|
|
886
|
+
if (typeof schema === 'string') {
|
|
887
|
+
finalSchema = ProjectSchema.fromName(schema);
|
|
888
|
+
}
|
|
889
|
+
else if (schema instanceof ProjectSchema) {
|
|
890
|
+
finalSchema = schema;
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
finalSchema = new ProjectSchema(schema);
|
|
894
|
+
}
|
|
895
|
+
if (!finalSchema.key) {
|
|
896
|
+
finalSchema.key = v4();
|
|
897
|
+
}
|
|
898
|
+
const { index } = opts;
|
|
899
|
+
const hasIndex = typeof index === 'number';
|
|
900
|
+
if (hasIndex && this.definitions.schemas.length > index) {
|
|
901
|
+
// comparing to the `.length` and not `.length - 1` in case we are adding at the end.
|
|
902
|
+
const maxIndex = Math.max(this.definitions.schemas.length, 0);
|
|
903
|
+
if (index > maxIndex) {
|
|
904
|
+
throw new RangeError(`Index out of bounds. Maximum index is ${maxIndex}.`);
|
|
905
|
+
}
|
|
906
|
+
this.definitions.schemas.splice(index, 0, finalSchema);
|
|
907
|
+
}
|
|
908
|
+
else {
|
|
909
|
+
this.definitions.schemas.push(finalSchema);
|
|
910
|
+
}
|
|
911
|
+
return finalSchema;
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* @returns The current list of schemas in the project.
|
|
915
|
+
*/
|
|
916
|
+
listSchemas() {
|
|
917
|
+
if (!Array.isArray(this.definitions.schemas)) {
|
|
918
|
+
return [];
|
|
919
|
+
}
|
|
920
|
+
return this.definitions.schemas;
|
|
921
|
+
}
|
|
922
|
+
getEnvironments() {
|
|
923
|
+
if (Array.isArray(this.initEnvironments)) {
|
|
924
|
+
return this.initEnvironments;
|
|
925
|
+
}
|
|
926
|
+
return super.getEnvironments();
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Iterates over requests in the project,
|
|
930
|
+
*/
|
|
931
|
+
*requestIterator(opts = {}) {
|
|
932
|
+
const { definitions } = this;
|
|
933
|
+
const { ignore = [], parent, recursive, requests = [] } = opts;
|
|
934
|
+
const root = parent ? this.findFolder(parent) : this;
|
|
935
|
+
if (!root) {
|
|
936
|
+
throw new Error(`The parent folder not found: ${parent}.`);
|
|
937
|
+
}
|
|
938
|
+
const items = root.items;
|
|
939
|
+
if (!items || !items.length) {
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
for (const item of items) {
|
|
943
|
+
if (ignore.includes(item.key)) {
|
|
944
|
+
continue;
|
|
945
|
+
}
|
|
946
|
+
if (item.kind === ProjectRequestKind) {
|
|
947
|
+
const request = definitions.requests.find(i => i.key === item.key);
|
|
948
|
+
if (!request) {
|
|
949
|
+
continue;
|
|
950
|
+
}
|
|
951
|
+
const name = request.info.name || '';
|
|
952
|
+
if (ignore.includes(name)) {
|
|
953
|
+
continue;
|
|
954
|
+
}
|
|
955
|
+
if (requests.length && !requests.includes(item.key) && !requests.includes(name)) {
|
|
956
|
+
continue;
|
|
957
|
+
}
|
|
958
|
+
yield request;
|
|
959
|
+
}
|
|
960
|
+
else if (recursive && item.kind === ProjectFolderKind) {
|
|
961
|
+
const folder = definitions.folders.find(i => i.key === item.key);
|
|
962
|
+
if (!folder) {
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
const name = folder.info.name || '';
|
|
966
|
+
if (ignore.includes(name)) {
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
const it = this.requestIterator({
|
|
970
|
+
parent: item.key,
|
|
971
|
+
recursive,
|
|
972
|
+
ignore,
|
|
973
|
+
requests,
|
|
974
|
+
});
|
|
975
|
+
for (const request of it) {
|
|
976
|
+
yield request;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
[Symbol.iterator]() {
|
|
982
|
+
return this.requestIterator({
|
|
983
|
+
recursive: true,
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
//# sourceMappingURL=HttpProject.js.map
|