@api-client/core 0.3.2 → 0.3.5
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/browser.d.ts +1 -0
- package/build/browser.js +1 -0
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/src/models/ErrorResponse.d.ts +5 -4
- package/build/src/models/ErrorResponse.js +18 -5
- package/build/src/models/ErrorResponse.js.map +1 -1
- package/build/src/models/SerializableError.d.ts +30 -0
- package/build/src/models/SerializableError.js +63 -0
- package/build/src/models/SerializableError.js.map +1 -0
- package/build/src/runtime/http-engine/ArcEngine.js +8 -4
- package/build/src/runtime/http-engine/ArcEngine.js.map +1 -1
- package/build/src/runtime/http-engine/HttpEngine.d.ts +3 -3
- package/build/src/runtime/http-engine/HttpEngine.js +3 -3
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
- package/build/src/runtime/http-engine/NodeEngine.js +9 -4
- package/build/src/runtime/http-engine/NodeEngine.js.map +1 -1
- package/build/src/runtime/http-engine/NodeEngineDirect.js +8 -2
- package/build/src/runtime/http-engine/NodeEngineDirect.js.map +1 -1
- package/build/src/runtime/node/ProjectRunner.d.ts +2 -2
- package/build/src/runtime/node/ProjectRunner.js +9 -2
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/src/runtime/store/StoreSdk.js +10 -15
- package/build/src/runtime/store/StoreSdk.js.map +1 -1
- package/package.json +1 -1
- package/src/data/DataReader.ts +11 -0
- package/src/data/DataUtils.ts +108 -0
- package/src/data/JmesparthReader.ts +26 -0
- package/src/data/Json2Xml.ts +190 -0
- package/src/data/JsonReader.ts +41 -0
- package/src/data/PayloadPointer.ts +48 -0
- package/src/data/RequestDataExtractor.ts +133 -0
- package/src/data/UrlEncodedReader.ts +20 -0
- package/src/data/XmlReader.ts +103 -0
- package/src/events/BaseEvents.ts +259 -0
- package/src/events/CustomEvent.ts +27 -0
- package/src/events/EventTypes.ts +19 -0
- package/src/events/Events.ts +19 -0
- package/src/events/authorization/AuthorizationEventTypes.ts +22 -0
- package/src/events/authorization/AuthorizationEvents.ts +61 -0
- package/src/events/cookies/CookieEventTypes.ts +13 -0
- package/src/events/cookies/CookieEvents.ts +157 -0
- package/src/events/encryption/EncryptionEventTypes.ts +4 -0
- package/src/events/encryption/EncryptionEvents.ts +51 -0
- package/src/events/environment/EnvironmentEventTypes.ts +3 -0
- package/src/events/environment/EnvironmentEvents.ts +24 -0
- package/src/events/models/ClientCertificateEvents.ts +87 -0
- package/src/events/models/ModelEventTypes.ts +47 -0
- package/src/events/models/ModelEvents.ts +7 -0
- package/src/events/models/ProjectEvents.ts +331 -0
- package/src/events/process/ProcessEventTypes.ts +5 -0
- package/src/events/process/ProcessEvents.ts +76 -0
- package/src/events/readme.md +22 -0
- package/src/events/reporting/ReportingEventTypes.ts +3 -0
- package/src/events/reporting/ReportingEvents.ts +28 -0
- package/src/events/telemetry/TelemetryEventTypes.ts +10 -0
- package/src/events/telemetry/TelemetryEvents.ts +156 -0
- package/src/lib/cookies/Cookie.ts +312 -0
- package/src/lib/cookies/Cookies.ts +326 -0
- package/src/lib/cookies/Utils.ts +168 -0
- package/src/lib/headers/Headers.ts +219 -0
- package/src/lib/logging/DefaultLogger.ts +19 -0
- package/src/lib/logging/DummyLogger.ts +21 -0
- package/src/lib/logging/Logger.ts +16 -0
- package/src/lib/transformers/PayloadSerializer.ts +332 -0
- package/src/lib/transformers/Utils.ts +18 -0
- package/src/lib/uuid.ts +40 -0
- package/src/mocking/LegacyInterfaces.ts +52 -0
- package/src/mocking/LegacyMock.ts +37 -0
- package/src/mocking/legacy/Authorization.ts +39 -0
- package/src/mocking/legacy/Certificates.ts +145 -0
- package/src/mocking/legacy/Cookies.ts +51 -0
- package/src/mocking/legacy/HostRules.ts +43 -0
- package/src/mocking/legacy/Http.ts +236 -0
- package/src/mocking/legacy/HttpResponse.ts +106 -0
- package/src/mocking/legacy/RestApi.ts +68 -0
- package/src/mocking/legacy/Urls.ts +44 -0
- package/src/mocking/legacy/Variables.ts +53 -0
- package/src/models/ArcResponse.ts +166 -0
- package/src/models/Authorization.ts +481 -0
- package/src/models/AuthorizationData.ts +60 -0
- package/src/models/Backend.ts +107 -0
- package/src/models/ClientCertificate.ts +68 -0
- package/src/models/Environment.ts +279 -0
- package/src/models/ErrorResponse.ts +113 -0
- package/src/models/HistoryIndex.ts +76 -0
- package/src/models/HistoryRequest.ts +28 -0
- package/src/models/HostRule.ts +163 -0
- package/src/models/HttpCookie.ts +285 -0
- package/src/models/HttpProject.ts +1294 -0
- package/src/models/HttpProjectListItem.ts +23 -0
- package/src/models/HttpRequest.ts +124 -0
- package/src/models/HttpResponse.ts +143 -0
- package/src/models/License.ts +113 -0
- package/src/models/ProjectDefinitionProperty.ts +40 -0
- package/src/models/ProjectFolder.ts +439 -0
- package/src/models/ProjectItem.ts +135 -0
- package/src/models/ProjectParent.ts +113 -0
- package/src/models/ProjectRequest.ts +277 -0
- package/src/models/ProjectSchema.ts +202 -0
- package/src/models/Property.ts +423 -0
- package/src/models/Provider.ts +98 -0
- package/src/models/README.md +20 -0
- package/src/models/Request.ts +452 -0
- package/src/models/RequestActions.ts +163 -0
- package/src/models/RequestAuthorization.ts +115 -0
- package/src/models/RequestConfig.ts +317 -0
- package/src/models/RequestLog.ts +159 -0
- package/src/models/RequestTime.ts +108 -0
- package/src/models/RequestUiMeta.ts +258 -0
- package/src/models/RequestsSize.ts +65 -0
- package/src/models/ResponseAuthorization.ts +104 -0
- package/src/models/ResponseRedirect.ts +158 -0
- package/src/models/RevisionInfo.ts +37 -0
- package/src/models/SentRequest.ts +125 -0
- package/src/models/SerializableError.ts +80 -0
- package/src/models/SerializablePayload.ts +68 -0
- package/src/models/Server.ts +153 -0
- package/src/models/Thing.ts +110 -0
- package/src/models/Url.ts +90 -0
- package/src/models/User.ts +120 -0
- package/src/models/WebApi.ts +234 -0
- package/src/models/WebApiIndex.ts +122 -0
- package/src/models/Workspace.ts +182 -0
- package/src/models/actions/Action.ts +213 -0
- package/src/models/actions/ActionView.ts +40 -0
- package/src/models/actions/Condition.ts +207 -0
- package/src/models/actions/ConditionView.ts +42 -0
- package/src/models/actions/Enums.ts +29 -0
- package/src/models/actions/RunnableAction.ts +144 -0
- package/src/models/actions/runnable/DeleteCookieAction.ts +113 -0
- package/src/models/actions/runnable/Runnable.ts +9 -0
- package/src/models/actions/runnable/SetCookieAction.ts +216 -0
- package/src/models/actions/runnable/SetVariableAction.ts +81 -0
- package/src/models/legacy/DataExport.ts +172 -0
- package/src/models/legacy/Normalizer.ts +110 -0
- package/src/models/legacy/actions/Actions.ts +269 -0
- package/src/models/legacy/authorization/Authorization.ts +572 -0
- package/src/models/legacy/models/ApiTypes.ts +202 -0
- package/src/models/legacy/models/ArcLegacyProject.ts +39 -0
- package/src/models/legacy/models/AuthData.ts +17 -0
- package/src/models/legacy/models/ClientCertificate.ts +95 -0
- package/src/models/legacy/models/Cookies.ts +52 -0
- package/src/models/legacy/models/HostRule.ts +35 -0
- package/src/models/legacy/models/RestApi.ts +49 -0
- package/src/models/legacy/models/UrlHistory.ts +37 -0
- package/src/models/legacy/models/Variable.ts +43 -0
- package/src/models/legacy/models/base.d.ts +95 -0
- package/src/models/legacy/request/ArcRequest.ts +405 -0
- package/src/models/legacy/request/ArcResponse.ts +177 -0
- package/src/models/legacy/request/HistoryData.ts +47 -0
- package/src/models/legacy/request/Legacy.ts +45 -0
- package/src/models/legacy/request/RequestBody.ts +87 -0
- package/src/models/transformers/ArcDexieTransformer.ts +323 -0
- package/src/models/transformers/ArcLegacyNormalizer.ts +85 -0
- package/src/models/transformers/ArcLegacyTransformer.ts +200 -0
- package/src/models/transformers/ArcPouchTransformer.ts +184 -0
- package/src/models/transformers/BaseTransformer.ts +116 -0
- package/src/models/transformers/ImportUtils.ts +141 -0
- package/src/models/transformers/LegacyDataExportToApiProject.ts +76 -0
- package/src/models/transformers/LegacyExportProcessor.ts +252 -0
- package/src/models/transformers/PostmanBackupTransformer.ts +306 -0
- package/src/models/transformers/PostmanDataTransformer.ts +50 -0
- package/src/models/transformers/PostmanTransformer.ts +106 -0
- package/src/models/transformers/PostmanV21Transformer.ts +311 -0
- package/src/models/transformers/PostmanV2Transformer.ts +308 -0
- package/src/models/transformers/har.ts +865 -0
- package/src/runtime/actions/ActionRunner.ts +83 -0
- package/src/runtime/actions/ConditionRunner.ts +194 -0
- package/src/runtime/actions/RunnableCondition.ts +57 -0
- package/src/runtime/actions/runnable/ActionRunnable.ts +19 -0
- package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +39 -0
- package/src/runtime/actions/runnable/SetCookieRunnable.ts +92 -0
- package/src/runtime/actions/runnable/SetVariableRunnable.ts +53 -0
- package/src/runtime/http-engine/ArcEngine.ts +1068 -0
- package/src/runtime/http-engine/FormData.ts +85 -0
- package/src/runtime/http-engine/HttpEngine.ts +874 -0
- package/src/runtime/http-engine/HttpErrorCodes.ts +270 -0
- package/src/runtime/http-engine/NodeEngine.ts +792 -0
- package/src/runtime/http-engine/NodeEngineDirect.ts +482 -0
- package/src/runtime/http-engine/PayloadSupport.ts +84 -0
- package/src/runtime/http-engine/RequestUtils.ts +164 -0
- package/src/runtime/http-engine/ntlm/Des.ts +345 -0
- package/src/runtime/http-engine/ntlm/MD4.ts +135 -0
- package/src/runtime/http-engine/ntlm/NtlmAuth.ts +186 -0
- package/src/runtime/http-engine/ntlm/NtlmMessage.ts +57 -0
- package/src/runtime/modules/BasicAuthCache.ts +133 -0
- package/src/runtime/modules/ExecutionResponse.ts +4 -0
- package/src/runtime/modules/ModulesRegistry.ts +136 -0
- package/src/runtime/modules/RequestAuthorization.ts +110 -0
- package/src/runtime/modules/RequestCookies.ts +145 -0
- package/src/runtime/node/ProjectRunner.ts +281 -0
- package/src/runtime/node/RequestFactory.ts +422 -0
- package/src/runtime/node/VariablesStore.ts +25 -0
- package/src/runtime/store/StoreSdk.ts +838 -0
- package/src/runtime/variables/Cache.ts +53 -0
- package/src/runtime/variables/EvalFunctions.ts +132 -0
- package/src/runtime/variables/ProjectVariables.ts +6 -0
- package/src/runtime/variables/VariablesProcessor.ts +543 -0
- package/src/runtime/variables/VariablesTokenizer.ts +55 -0
- package/build/src/runtime/http-engine/Errors.d.ts +0 -10
- package/build/src/runtime/http-engine/Errors.js +0 -14
- package/build/src/runtime/http-engine/Errors.js.map +0 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export type AccessControlLevel = 'read' | 'comment' | 'write' | 'admin' | 'owner';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is used in the communication with the backend to add/change user's access to the resource.
|
|
5
|
+
*/
|
|
6
|
+
export interface IUserAccessOperation {
|
|
7
|
+
/**
|
|
8
|
+
* The user id.
|
|
9
|
+
*/
|
|
10
|
+
uid: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IUserAccessAddOperation extends IUserAccessOperation {
|
|
14
|
+
op: "add";
|
|
15
|
+
/**
|
|
16
|
+
* The level that the user has access to.
|
|
17
|
+
*/
|
|
18
|
+
value: AccessControlLevel;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface IUserAccessRemoveOperation extends IUserAccessOperation {
|
|
22
|
+
op: "remove";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type UserAccessOperation = IUserAccessAddOperation | IUserAccessRemoveOperation;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The definition of an access control.
|
|
29
|
+
* The user may have access to a workspace so this is the object describing the level of the workspace.
|
|
30
|
+
*/
|
|
31
|
+
export interface IAccessControl {
|
|
32
|
+
/**
|
|
33
|
+
* The data store key of the referenced object the user has access to.
|
|
34
|
+
*/
|
|
35
|
+
key: string;
|
|
36
|
+
/**
|
|
37
|
+
* The level that the user has access to.
|
|
38
|
+
*/
|
|
39
|
+
level: AccessControlLevel;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface IEmail {
|
|
43
|
+
/**
|
|
44
|
+
* When available the email of the user.
|
|
45
|
+
*/
|
|
46
|
+
email?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the `email` was verified.
|
|
49
|
+
* Not verified emails should have limited use in the system.
|
|
50
|
+
*/
|
|
51
|
+
verified?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface IUserPicture {
|
|
55
|
+
/**
|
|
56
|
+
* When available, the URL to the user's picture image.
|
|
57
|
+
*/
|
|
58
|
+
url?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Alternative to the `imageUrl`. When set it is a data URL value of the image.
|
|
61
|
+
*/
|
|
62
|
+
data?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const Kind = 'ARC#User';
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Represents a user in the system.
|
|
69
|
+
* This can be embedded in various situations like project's revision history,
|
|
70
|
+
* ACL, Authorization, etc.
|
|
71
|
+
*
|
|
72
|
+
* Note, the store implementation may have additional fields that support external
|
|
73
|
+
* identity providers. However, this is not exposed to the user through the API.
|
|
74
|
+
*/
|
|
75
|
+
export interface IUser {
|
|
76
|
+
/**
|
|
77
|
+
* Data store key of the user.
|
|
78
|
+
*/
|
|
79
|
+
key: string;
|
|
80
|
+
/**
|
|
81
|
+
* The display name of the user.
|
|
82
|
+
*/
|
|
83
|
+
name: string;
|
|
84
|
+
/**
|
|
85
|
+
* When available the email of the user.
|
|
86
|
+
*/
|
|
87
|
+
email?: IEmail[];
|
|
88
|
+
/**
|
|
89
|
+
* The user picture to render.
|
|
90
|
+
*/
|
|
91
|
+
picture?: IUserPicture;
|
|
92
|
+
/**
|
|
93
|
+
* General purpose tags field.
|
|
94
|
+
*/
|
|
95
|
+
tags?: string[];
|
|
96
|
+
/**
|
|
97
|
+
* Optional user locale information.
|
|
98
|
+
*/
|
|
99
|
+
locale?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Optional metadata related to the auth provider.
|
|
102
|
+
*/
|
|
103
|
+
provider?: unknown;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* This object may be created for each user in the system.
|
|
108
|
+
* It describes to which spaces user has access to.
|
|
109
|
+
*/
|
|
110
|
+
export interface IUserSpaces {
|
|
111
|
+
/**
|
|
112
|
+
* The list of access to the spaces for the user.
|
|
113
|
+
*/
|
|
114
|
+
spaces: IAccessControl[];
|
|
115
|
+
/**
|
|
116
|
+
* The data store key of the user that has access to the space.
|
|
117
|
+
* This is also the key of the entry.
|
|
118
|
+
*/
|
|
119
|
+
user: string;
|
|
120
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
export const Kind = 'ARC#WebApi';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated This was used in the old version of ARC.
|
|
5
|
+
*/
|
|
6
|
+
export interface ILegacyRestApi {
|
|
7
|
+
/**
|
|
8
|
+
* The ID of the index item that this entry refers to.
|
|
9
|
+
*/
|
|
10
|
+
indexId: string;
|
|
11
|
+
/**
|
|
12
|
+
* Version name of the API
|
|
13
|
+
*/
|
|
14
|
+
version: string;
|
|
15
|
+
/**
|
|
16
|
+
* API data model. It is the output of the AMF parser run on the API.
|
|
17
|
+
*/
|
|
18
|
+
data: string;
|
|
19
|
+
/**
|
|
20
|
+
* The AMF parser version used to parse this document.
|
|
21
|
+
*/
|
|
22
|
+
amfVersion?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface IWebApi {
|
|
26
|
+
kind: typeof Kind;
|
|
27
|
+
/**
|
|
28
|
+
* The ID of the index item that this entry refers to.
|
|
29
|
+
*/
|
|
30
|
+
indexId: string;
|
|
31
|
+
/**
|
|
32
|
+
* Version name of the API
|
|
33
|
+
*/
|
|
34
|
+
version: string;
|
|
35
|
+
/**
|
|
36
|
+
* API data model. It is the output of the AMF parser run on the API.
|
|
37
|
+
* This is left for compatibility.
|
|
38
|
+
* @deprecated This was used in the old version of ARC. v18 uses the `path` with the location of the API project.
|
|
39
|
+
*/
|
|
40
|
+
data?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The AMF parser version used to parse this document.
|
|
43
|
+
* This is left for compatibility.
|
|
44
|
+
* @deprecated This was used in the old version of ARC. v18 does not use this information.
|
|
45
|
+
*/
|
|
46
|
+
amfVersion?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The location of the API project. This can be any URI to get the sources of the API project.
|
|
49
|
+
*/
|
|
50
|
+
path: string;
|
|
51
|
+
/**
|
|
52
|
+
* Optional information to point to the API's main file.
|
|
53
|
+
*/
|
|
54
|
+
main?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The API format's media type.
|
|
57
|
+
*/
|
|
58
|
+
mime?: string;
|
|
59
|
+
/**
|
|
60
|
+
* The API vendor. E.g. RAML 1.0, OAS 3.0, ASYNC 2.0, ...
|
|
61
|
+
*/
|
|
62
|
+
vendor?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export class WebApi {
|
|
66
|
+
kind = Kind;
|
|
67
|
+
/**
|
|
68
|
+
* The ID of the index item that this entry refers to.
|
|
69
|
+
*/
|
|
70
|
+
indexId = '';
|
|
71
|
+
/**
|
|
72
|
+
* Version name of the API
|
|
73
|
+
*/
|
|
74
|
+
version = '';
|
|
75
|
+
/**
|
|
76
|
+
* API data model. It is the output of the AMF parser run on the API.
|
|
77
|
+
* This is left for compatibility.
|
|
78
|
+
* @deprecated This was used in the old version of ARC. v18 uses the `path` with the location of the API project.
|
|
79
|
+
*/
|
|
80
|
+
data?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The AMF parser version used to parse this document.
|
|
83
|
+
* This is left for compatibility.
|
|
84
|
+
* @deprecated This was used in the old version of ARC. v18 does not use this information.
|
|
85
|
+
*/
|
|
86
|
+
amfVersion?: string;
|
|
87
|
+
/**
|
|
88
|
+
* The location of the API project. This can be any URI to get the sources of the API project.
|
|
89
|
+
*/
|
|
90
|
+
path = '';
|
|
91
|
+
/**
|
|
92
|
+
* Optional information to point to the API's main file.
|
|
93
|
+
*/
|
|
94
|
+
main?: string;
|
|
95
|
+
/**
|
|
96
|
+
* The API format's media type.
|
|
97
|
+
*/
|
|
98
|
+
mime?: string;
|
|
99
|
+
/**
|
|
100
|
+
* The API vendor. E.g. RAML 1.0, OAS 3.0, ASYNC 2.0, ...
|
|
101
|
+
*/
|
|
102
|
+
vendor?: string;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Checks whether the object represents a legacy way of storing the web API data.
|
|
106
|
+
*/
|
|
107
|
+
get isLegacy(): boolean {
|
|
108
|
+
return !!this.data;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Checks whether the object is the legacy schema for web API (formally known as RestAPI)
|
|
113
|
+
*/
|
|
114
|
+
static isLegacy(api: unknown): boolean {
|
|
115
|
+
const legacy = api as ILegacyRestApi;
|
|
116
|
+
if (legacy.data) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static fromLegacy(api: ILegacyRestApi): WebApi {
|
|
123
|
+
const { version, amfVersion, data, indexId } = api;
|
|
124
|
+
const init: IWebApi = {
|
|
125
|
+
kind: Kind,
|
|
126
|
+
version,
|
|
127
|
+
path: '',
|
|
128
|
+
indexId,
|
|
129
|
+
};
|
|
130
|
+
if (amfVersion) {
|
|
131
|
+
init.amfVersion = amfVersion;
|
|
132
|
+
}
|
|
133
|
+
if (data) {
|
|
134
|
+
init.data = data;
|
|
135
|
+
}
|
|
136
|
+
return new WebApi(init);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Creates an identifier of this web API object.
|
|
141
|
+
* @param indexId The id of the corresponding index item. This is usually the base URI of the API.
|
|
142
|
+
* @param version The version name of this web API.
|
|
143
|
+
* @returns The unique and reversible identifier of this web API.
|
|
144
|
+
*/
|
|
145
|
+
static createId(indexId: string, version: string): string {
|
|
146
|
+
return `${indexId}|${version}`;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
constructor(input?: string|IWebApi) {
|
|
150
|
+
let init: IWebApi;
|
|
151
|
+
if (typeof input === 'string') {
|
|
152
|
+
init = JSON.parse(input);
|
|
153
|
+
} else if (typeof input === 'object') {
|
|
154
|
+
init = input;
|
|
155
|
+
} else {
|
|
156
|
+
init = {
|
|
157
|
+
kind: Kind,
|
|
158
|
+
version: '',
|
|
159
|
+
path: '',
|
|
160
|
+
indexId: '',
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
this.new(init);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
new(init: IWebApi): void {
|
|
167
|
+
const { version, data, amfVersion, path, main, mime, vendor, indexId } = init;
|
|
168
|
+
if (indexId) {
|
|
169
|
+
this.indexId = indexId;
|
|
170
|
+
} else {
|
|
171
|
+
this.indexId = '';
|
|
172
|
+
}
|
|
173
|
+
if (version) {
|
|
174
|
+
this.version = version;
|
|
175
|
+
} else {
|
|
176
|
+
this.version = '';
|
|
177
|
+
}
|
|
178
|
+
if (data) {
|
|
179
|
+
this.data = data;
|
|
180
|
+
} else {
|
|
181
|
+
this.data = undefined;
|
|
182
|
+
}
|
|
183
|
+
if (amfVersion) {
|
|
184
|
+
this.amfVersion = amfVersion;
|
|
185
|
+
} else {
|
|
186
|
+
this.amfVersion = undefined;
|
|
187
|
+
}
|
|
188
|
+
if (path) {
|
|
189
|
+
this.path = path;
|
|
190
|
+
} else {
|
|
191
|
+
this.path = '';
|
|
192
|
+
}
|
|
193
|
+
if (main) {
|
|
194
|
+
this.main = main;
|
|
195
|
+
} else {
|
|
196
|
+
this.main = undefined
|
|
197
|
+
}
|
|
198
|
+
if (mime) {
|
|
199
|
+
this.mime = mime;
|
|
200
|
+
} else {
|
|
201
|
+
this.mime = mime;
|
|
202
|
+
}
|
|
203
|
+
if (vendor) {
|
|
204
|
+
this.vendor = vendor;
|
|
205
|
+
} else {
|
|
206
|
+
this.vendor = undefined;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
toJSON(): IWebApi {
|
|
211
|
+
const result: IWebApi = {
|
|
212
|
+
kind: Kind,
|
|
213
|
+
version: this.version,
|
|
214
|
+
path: this.path,
|
|
215
|
+
indexId: this.indexId,
|
|
216
|
+
};
|
|
217
|
+
if (this.data) {
|
|
218
|
+
result.data = this.data;
|
|
219
|
+
}
|
|
220
|
+
if (this.amfVersion) {
|
|
221
|
+
result.amfVersion = this.amfVersion;
|
|
222
|
+
}
|
|
223
|
+
if (this.main) {
|
|
224
|
+
result.main = this.main;
|
|
225
|
+
}
|
|
226
|
+
if (this.mime) {
|
|
227
|
+
result.mime = this.mime;
|
|
228
|
+
}
|
|
229
|
+
if (this.vendor) {
|
|
230
|
+
result.vendor = this.vendor;
|
|
231
|
+
}
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export const Kind = 'ARC#WebApiIndex';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated This was used in the old version of ARC.
|
|
5
|
+
*/
|
|
6
|
+
export interface ILegacyWebApiIndex {
|
|
7
|
+
/**
|
|
8
|
+
* API title
|
|
9
|
+
*/
|
|
10
|
+
title: string;
|
|
11
|
+
/**
|
|
12
|
+
* API media type
|
|
13
|
+
* @deprecated This has been renamed to `vendor`.
|
|
14
|
+
*/
|
|
15
|
+
type: string;
|
|
16
|
+
/**
|
|
17
|
+
* API order on the list
|
|
18
|
+
*/
|
|
19
|
+
order: number;
|
|
20
|
+
/**
|
|
21
|
+
* List of version names stored with this API.
|
|
22
|
+
*/
|
|
23
|
+
versions: string[];
|
|
24
|
+
/**
|
|
25
|
+
* The latest added version name.
|
|
26
|
+
*/
|
|
27
|
+
latest: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface IWebApiIndex {
|
|
31
|
+
kind: typeof Kind;
|
|
32
|
+
/**
|
|
33
|
+
* API title
|
|
34
|
+
*/
|
|
35
|
+
title: string;
|
|
36
|
+
/**
|
|
37
|
+
* List of version names stored with this API.
|
|
38
|
+
*/
|
|
39
|
+
versions: string[];
|
|
40
|
+
/**
|
|
41
|
+
* The latest added version name.
|
|
42
|
+
*/
|
|
43
|
+
latest: string;
|
|
44
|
+
/**
|
|
45
|
+
* The API vendor. E.g. RAML 1.0, OAS 3.0, ASYNC 2.0, ...
|
|
46
|
+
*/
|
|
47
|
+
vendor: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class WebApiIndex {
|
|
51
|
+
kind = Kind;
|
|
52
|
+
/**
|
|
53
|
+
* API title
|
|
54
|
+
*/
|
|
55
|
+
title = '';
|
|
56
|
+
/**
|
|
57
|
+
* List of version names stored with this API.
|
|
58
|
+
*/
|
|
59
|
+
versions: string[] = [];
|
|
60
|
+
/**
|
|
61
|
+
* The latest added version name.
|
|
62
|
+
*/
|
|
63
|
+
latest = '';
|
|
64
|
+
/**
|
|
65
|
+
* The API vendor. E.g. RAML 1.0, OAS 3.0, ASYNC 2.0, ...
|
|
66
|
+
*/
|
|
67
|
+
vendor = '';
|
|
68
|
+
|
|
69
|
+
static isLegacy(api: unknown): boolean {
|
|
70
|
+
const legacy = api as ILegacyWebApiIndex;
|
|
71
|
+
return !!legacy.type;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static fromLegacy(api: ILegacyWebApiIndex): WebApiIndex {
|
|
75
|
+
const { title, type, versions=[], latest } = api;
|
|
76
|
+
const init: IWebApiIndex = {
|
|
77
|
+
kind: Kind,
|
|
78
|
+
title,
|
|
79
|
+
versions,
|
|
80
|
+
latest,
|
|
81
|
+
vendor: type,
|
|
82
|
+
};
|
|
83
|
+
return new WebApiIndex(init);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
constructor(input?: string|IWebApiIndex) {
|
|
87
|
+
let init: IWebApiIndex;
|
|
88
|
+
if (typeof input === 'string') {
|
|
89
|
+
init = JSON.parse(input);
|
|
90
|
+
} else if (typeof input === 'object') {
|
|
91
|
+
init = input;
|
|
92
|
+
} else {
|
|
93
|
+
init = {
|
|
94
|
+
kind: Kind,
|
|
95
|
+
latest: '',
|
|
96
|
+
title: '',
|
|
97
|
+
vendor: '',
|
|
98
|
+
versions: [],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
this.new(init);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
new(init: IWebApiIndex): void {
|
|
105
|
+
const { latest='', title='', vendor='', versions=[] } = init;
|
|
106
|
+
this.latest = latest;
|
|
107
|
+
this.versions = versions;
|
|
108
|
+
this.title = title;
|
|
109
|
+
this.vendor = vendor;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
toJSON(): IWebApiIndex {
|
|
113
|
+
const result: IWebApiIndex = {
|
|
114
|
+
kind: Kind,
|
|
115
|
+
latest: this.latest,
|
|
116
|
+
versions: this.versions,
|
|
117
|
+
title: this.title,
|
|
118
|
+
vendor: this.vendor,
|
|
119
|
+
};
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { AccessControlLevel } from "./User.js";
|
|
2
|
+
import { IThing, Thing, Kind as ThingKind } from './Thing.js';
|
|
3
|
+
import v4 from '../lib/uuid.js';
|
|
4
|
+
|
|
5
|
+
export const Kind = 'ARC#Space';
|
|
6
|
+
/**
|
|
7
|
+
* A definition of the working space for users.
|
|
8
|
+
*
|
|
9
|
+
* A working space is a logical container in the data store
|
|
10
|
+
* created by the system users, where they can store their projects and other data.
|
|
11
|
+
*/
|
|
12
|
+
export interface IWorkspace {
|
|
13
|
+
kind: 'ARC#Space';
|
|
14
|
+
/**
|
|
15
|
+
* The space identifier.
|
|
16
|
+
*/
|
|
17
|
+
key: string;
|
|
18
|
+
/**
|
|
19
|
+
* The environment's meta info.
|
|
20
|
+
*/
|
|
21
|
+
info: IThing;
|
|
22
|
+
/**
|
|
23
|
+
* The list of users added to this space. May not be set when owner did not add anyone to the space.
|
|
24
|
+
*/
|
|
25
|
+
users?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* The owner of this space. The id of the User object.
|
|
28
|
+
* Set to `default` when there are no users in the system (no authentication).
|
|
29
|
+
*/
|
|
30
|
+
owner: string;
|
|
31
|
+
/**
|
|
32
|
+
* The list of project keys added to the workspace.
|
|
33
|
+
* @deprecated This is not actually used.
|
|
34
|
+
*/
|
|
35
|
+
projects: string[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The workspace information set to a specific client what contains user specific data.
|
|
40
|
+
*/
|
|
41
|
+
export interface IUserWorkspace extends IWorkspace {
|
|
42
|
+
access: AccessControlLevel;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const DefaultOwner = 'default';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A definition of the working space for users.
|
|
49
|
+
*
|
|
50
|
+
* A working space is a logical container in the data store
|
|
51
|
+
* created by the system users, where they can store their projects and other data.
|
|
52
|
+
*/
|
|
53
|
+
export class Workspace {
|
|
54
|
+
kind = Kind;
|
|
55
|
+
/**
|
|
56
|
+
* The space identifier.
|
|
57
|
+
*/
|
|
58
|
+
key = '';
|
|
59
|
+
/**
|
|
60
|
+
* The name of the environment.
|
|
61
|
+
*/
|
|
62
|
+
info: Thing = new Thing({ kind: ThingKind });
|
|
63
|
+
/**
|
|
64
|
+
* The list of users added to this space. May not be set when owner did not add anyone to the space.
|
|
65
|
+
*/
|
|
66
|
+
users?: string[];
|
|
67
|
+
/**
|
|
68
|
+
* The owner of this space. The id of the User object.
|
|
69
|
+
* Set to `default` when there are no users in the system (no authentication).
|
|
70
|
+
*/
|
|
71
|
+
owner = '';
|
|
72
|
+
/**
|
|
73
|
+
* The list of keys of projects added to the workspace.
|
|
74
|
+
* @deprecated This is not actually used.
|
|
75
|
+
*/
|
|
76
|
+
projects: string[] = [];
|
|
77
|
+
/**
|
|
78
|
+
* Only set when the object was created from the data received by the ARC backend.
|
|
79
|
+
* Level access of the current user to the space.
|
|
80
|
+
* Note, this information is never serialized with the object.
|
|
81
|
+
*/
|
|
82
|
+
access?: AccessControlLevel;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Creates a new Space object from a name.
|
|
86
|
+
*
|
|
87
|
+
* @param name The name to set.
|
|
88
|
+
* @param owner The user id that is the owner of the space.
|
|
89
|
+
*/
|
|
90
|
+
static fromName(name: string, owner = DefaultOwner): Workspace {
|
|
91
|
+
const key = v4();
|
|
92
|
+
const info = new Thing({ kind: ThingKind, name });
|
|
93
|
+
const definition = new Workspace({
|
|
94
|
+
key,
|
|
95
|
+
kind: Kind,
|
|
96
|
+
info: info.toJSON(),
|
|
97
|
+
owner,
|
|
98
|
+
projects: [],
|
|
99
|
+
});
|
|
100
|
+
return definition;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param input The environment definition used to restore the state.
|
|
105
|
+
*/
|
|
106
|
+
constructor(input?: string | IWorkspace | IUserWorkspace) {
|
|
107
|
+
let init: IWorkspace;
|
|
108
|
+
if (typeof input === 'string') {
|
|
109
|
+
init = JSON.parse(input);
|
|
110
|
+
} else if (typeof input === 'object') {
|
|
111
|
+
init = input;
|
|
112
|
+
} else {
|
|
113
|
+
init = {
|
|
114
|
+
kind: Kind,
|
|
115
|
+
key: v4(),
|
|
116
|
+
info: {
|
|
117
|
+
kind: ThingKind,
|
|
118
|
+
name: '',
|
|
119
|
+
},
|
|
120
|
+
owner: DefaultOwner,
|
|
121
|
+
projects: [],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
this.new(init);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Creates a new environment clearing anything that is so far defined.
|
|
129
|
+
*
|
|
130
|
+
* Note, this throws an error when the environment is not an ARC environment.
|
|
131
|
+
*/
|
|
132
|
+
new(init: IWorkspace | IUserWorkspace): void {
|
|
133
|
+
if (!Workspace.isWorkspace(init)) {
|
|
134
|
+
throw new Error(`Not an ARC space.`);
|
|
135
|
+
}
|
|
136
|
+
const { key = v4(), projects = [], info, owner = DefaultOwner, users } = init;
|
|
137
|
+
this.kind = Kind;
|
|
138
|
+
this.key = key;
|
|
139
|
+
this.projects = projects;
|
|
140
|
+
this.owner = owner;
|
|
141
|
+
if (info) {
|
|
142
|
+
this.info = new Thing(info);
|
|
143
|
+
} else {
|
|
144
|
+
this.info = new Thing({ kind: ThingKind, name: '' });
|
|
145
|
+
}
|
|
146
|
+
if (Array.isArray(users)) {
|
|
147
|
+
this.users = users;
|
|
148
|
+
} else {
|
|
149
|
+
this.users = [];
|
|
150
|
+
}
|
|
151
|
+
const typed = init as IUserWorkspace;
|
|
152
|
+
if (typed.access) {
|
|
153
|
+
this.access = typed.access;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Checks whether the input is a definition of an user space.
|
|
159
|
+
*/
|
|
160
|
+
static isWorkspace(input: unknown): boolean {
|
|
161
|
+
const typed = input as IWorkspace;
|
|
162
|
+
if (!input || typed.kind !== Kind) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
toJSON(): IWorkspace {
|
|
169
|
+
const { projects = [], owner = DefaultOwner, users } = this;
|
|
170
|
+
const result: IWorkspace = {
|
|
171
|
+
kind: Kind,
|
|
172
|
+
key: this.key,
|
|
173
|
+
info: this.info.toJSON(),
|
|
174
|
+
projects,
|
|
175
|
+
owner,
|
|
176
|
+
};
|
|
177
|
+
if (Array.isArray(users) && users.length) {
|
|
178
|
+
result.users = users;
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
}
|