@api-client/core 0.8.7 → 0.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/authorization/OidcAuthorization.js.map +1 -1
- package/build/src/data/JsonReader.js.map +1 -1
- package/build/src/lib/parsers/UrlParser.js.map +1 -1
- package/build/src/mocking/LegacyMock.js.map +1 -1
- package/build/src/mocking/legacy/Http.js.map +1 -1
- package/build/src/mocking/legacy/HttpResponse.js.map +1 -1
- package/build/src/models/AppProject.js.map +1 -1
- package/build/src/models/AppRequest.js.map +1 -1
- package/build/src/models/Environment.d.ts +4 -0
- package/build/src/models/Environment.js +16 -0
- package/build/src/models/Environment.js.map +1 -1
- package/build/src/models/ErrorResponse.js.map +1 -1
- package/build/src/models/HttpProject.d.ts +1 -1
- package/build/src/models/HttpProject.js +1 -1
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/Project.js.map +1 -1
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/ProjectRequest.d.ts +17 -0
- package/build/src/models/ProjectRequest.js +35 -1
- package/build/src/models/ProjectRequest.js.map +1 -1
- package/build/src/models/Request.js +1 -0
- package/build/src/models/Request.js.map +1 -1
- package/build/src/models/Response.js.map +1 -1
- package/build/src/models/SentRequest.js.map +1 -1
- package/build/src/models/Workspace.js.map +1 -1
- package/build/src/models/data/DataFile.js.map +1 -1
- package/build/src/models/data/DataNamespace.js.map +1 -1
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/runtime/http-engine/CoreEngine.js.map +1 -1
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/src/runtime/store/Errors.js.map +1 -1
- package/package.json +1 -1
- package/src/authorization/OidcAuthorization.ts +4 -4
- package/src/data/JsonReader.ts +1 -1
- package/src/lib/parsers/UrlParser.ts +1 -1
- package/src/mocking/LegacyMock.ts +1 -1
- package/src/mocking/legacy/Http.ts +1 -1
- package/src/mocking/legacy/HttpResponse.ts +2 -2
- package/src/models/AppProject.ts +14 -14
- package/src/models/AppRequest.ts +6 -6
- package/src/models/Environment.ts +25 -8
- package/src/models/ErrorResponse.ts +3 -3
- package/src/models/HttpProject.ts +3 -3
- package/src/models/Project.ts +3 -3
- package/src/models/ProjectFolder.ts +2 -2
- package/src/models/ProjectRequest.ts +52 -7
- package/src/models/Request.ts +1 -0
- package/src/models/Response.ts +4 -4
- package/src/models/SentRequest.ts +3 -3
- package/src/models/Workspace.ts +3 -3
- package/src/models/data/DataFile.ts +3 -3
- package/src/models/data/DataNamespace.ts +1 -1
- package/src/models/store/File.ts +2 -2
- package/src/runtime/http-engine/CoreEngine.ts +4 -4
- package/src/runtime/node/ProjectRunner.ts +1 -1
- package/src/runtime/store/Errors.ts +1 -1
|
@@ -81,7 +81,7 @@ export class ProjectFolder extends ProjectParent {
|
|
|
81
81
|
return DefaultFolderName;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
kind = Kind;
|
|
84
|
+
override kind = Kind;
|
|
85
85
|
/**
|
|
86
86
|
* A reference to the top level project object.
|
|
87
87
|
*/
|
|
@@ -418,7 +418,7 @@ export class ProjectFolder extends ProjectParent {
|
|
|
418
418
|
* @param opts Cloning options
|
|
419
419
|
*/
|
|
420
420
|
clone(opts: IFolderCloneOptions = {}): ProjectFolder {
|
|
421
|
-
const { targetProject=this.project, targetFolder } = opts;
|
|
421
|
+
const { targetProject = this.project, targetFolder } = opts;
|
|
422
422
|
const copy = new ProjectFolder(targetProject, this.toJSON());
|
|
423
423
|
copy.key = v4();
|
|
424
424
|
|
|
@@ -6,6 +6,7 @@ import { HttpProject } from './HttpProject.js';
|
|
|
6
6
|
import v4 from '../lib/uuid.js';
|
|
7
7
|
import { IRequest, Request } from './Request.js';
|
|
8
8
|
import { IAppProjectRequest } from './AppProject.js';
|
|
9
|
+
import { Environment } from './Environment.js';
|
|
9
10
|
|
|
10
11
|
export const Kind = 'Core#ProjectRequest';
|
|
11
12
|
|
|
@@ -15,6 +16,10 @@ export interface IProjectRequest extends IProjectDefinitionProperty, IRequest {
|
|
|
15
16
|
* The identifier of the request.
|
|
16
17
|
*/
|
|
17
18
|
key: string;
|
|
19
|
+
/**
|
|
20
|
+
* The key of an environment defined on the project to apply to this request.
|
|
21
|
+
*/
|
|
22
|
+
environment?: string;
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
export interface IRequestCloneOptions {
|
|
@@ -39,15 +44,23 @@ export interface IRequestCloneOptions {
|
|
|
39
44
|
* safely store the payload.
|
|
40
45
|
*/
|
|
41
46
|
export class ProjectRequest extends Request implements ProjectDefinitionProperty {
|
|
42
|
-
kind = Kind;
|
|
47
|
+
override kind = Kind;
|
|
48
|
+
|
|
43
49
|
/**
|
|
44
50
|
* The identifier of the request.
|
|
45
51
|
*/
|
|
46
52
|
key = '';
|
|
53
|
+
|
|
47
54
|
/**
|
|
48
55
|
* A reference to the top level project object.
|
|
49
56
|
*/
|
|
50
57
|
project: HttpProject;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The key of an environment defined on the project to apply to this request.
|
|
61
|
+
*/
|
|
62
|
+
environment?: string;
|
|
63
|
+
|
|
51
64
|
/**
|
|
52
65
|
* Checks whether the input is a definition of a project folder.
|
|
53
66
|
*/
|
|
@@ -66,7 +79,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
66
79
|
* @param url The Request URL. This is required.
|
|
67
80
|
* @param project The parent project.
|
|
68
81
|
*/
|
|
69
|
-
static fromUrl(url: string, project?: HttpProject): ProjectRequest {
|
|
82
|
+
static override fromUrl(url: string, project?: HttpProject): ProjectRequest {
|
|
70
83
|
if (!project) {
|
|
71
84
|
throw new Error(`The project is required.`);
|
|
72
85
|
}
|
|
@@ -96,7 +109,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
96
109
|
* @param name The Request name.
|
|
97
110
|
* @param project The parent project.This is required.
|
|
98
111
|
*/
|
|
99
|
-
static fromName(name: string, project?: HttpProject): ProjectRequest {
|
|
112
|
+
static override fromName(name: string, project?: HttpProject): ProjectRequest {
|
|
100
113
|
if (!project) {
|
|
101
114
|
throw new Error(`The project is required.`);
|
|
102
115
|
}
|
|
@@ -126,7 +139,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
126
139
|
* @param project The parent project This is required.
|
|
127
140
|
* @param info The request data.
|
|
128
141
|
*/
|
|
129
|
-
static fromHttpRequest(info: IHttpRequest, project?: HttpProject): ProjectRequest {
|
|
142
|
+
static override fromHttpRequest(info: IHttpRequest, project?: HttpProject): ProjectRequest {
|
|
130
143
|
if (!project) {
|
|
131
144
|
throw new Error(`The project is required.`);
|
|
132
145
|
}
|
|
@@ -190,16 +203,22 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
190
203
|
this.new(init);
|
|
191
204
|
}
|
|
192
205
|
|
|
193
|
-
new(init: IProjectRequest | IAppProjectRequest): void {
|
|
206
|
+
override new(init: IProjectRequest | IAppProjectRequest): void {
|
|
194
207
|
super.new(init);
|
|
195
208
|
|
|
196
|
-
const { key } = init;
|
|
209
|
+
const { key, environment } = init as IProjectRequest;
|
|
197
210
|
this.key = key || v4();
|
|
211
|
+
if (environment) {
|
|
212
|
+
this.environment = environment;
|
|
213
|
+
}
|
|
198
214
|
}
|
|
199
215
|
|
|
200
|
-
toJSON(): IProjectRequest {
|
|
216
|
+
override toJSON(): IProjectRequest {
|
|
201
217
|
const request = super.toJSON();
|
|
202
218
|
const result: IProjectRequest = { ...request, key: this.key, kind: Kind };
|
|
219
|
+
if (this.environment) {
|
|
220
|
+
result.environment = this.environment;
|
|
221
|
+
}
|
|
203
222
|
return result;
|
|
204
223
|
}
|
|
205
224
|
|
|
@@ -275,4 +294,30 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
275
294
|
const obj = new ProjectRequest(project, request);
|
|
276
295
|
return obj.clone(opts);
|
|
277
296
|
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* @returns The environment that should be applied to the request, if any.
|
|
300
|
+
*/
|
|
301
|
+
getEnvironment(): Environment | undefined {
|
|
302
|
+
const { environment, project } = this;
|
|
303
|
+
if (!environment) {
|
|
304
|
+
return undefined;
|
|
305
|
+
}
|
|
306
|
+
let parent = this.getParent();
|
|
307
|
+
if (parent === project) {
|
|
308
|
+
parent = undefined;
|
|
309
|
+
}
|
|
310
|
+
return project.findEnvironment(environment);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* @returns All environments that can be applied to this request.
|
|
315
|
+
*/
|
|
316
|
+
readEnvironments(): Environment[] {
|
|
317
|
+
let parent = this.getParent();
|
|
318
|
+
if (parent === this.project) {
|
|
319
|
+
parent = undefined;
|
|
320
|
+
}
|
|
321
|
+
return this.project.readEnvironments({ parent: parent?.key });
|
|
322
|
+
}
|
|
278
323
|
}
|
package/src/models/Request.ts
CHANGED
package/src/models/Response.ts
CHANGED
|
@@ -42,7 +42,7 @@ export class Response extends HttpResponse {
|
|
|
42
42
|
*/
|
|
43
43
|
auth?: ResponseAuthorization;
|
|
44
44
|
|
|
45
|
-
static fromValues(status: number, statusText?: string, headers?: string): Response {
|
|
45
|
+
static override fromValues(status: number, statusText?: string, headers?: string): Response {
|
|
46
46
|
return new Response({
|
|
47
47
|
kind: Kind,
|
|
48
48
|
status,
|
|
@@ -52,7 +52,7 @@ export class Response extends HttpResponse {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
static async fromLegacy(input: LegacyResponse): Promise<Response> {
|
|
55
|
+
static override async fromLegacy(input: LegacyResponse): Promise<Response> {
|
|
56
56
|
const init: IResponse = {
|
|
57
57
|
kind: Kind,
|
|
58
58
|
status: input.status || 0,
|
|
@@ -109,7 +109,7 @@ export class Response extends HttpResponse {
|
|
|
109
109
|
/**
|
|
110
110
|
* Creates a new response clearing anything that is so far defined.
|
|
111
111
|
*/
|
|
112
|
-
new(init: IResponse): void {
|
|
112
|
+
override new(init: IResponse): void {
|
|
113
113
|
super.new(init);
|
|
114
114
|
const { loadingTime=0, timings, auth } = init;
|
|
115
115
|
this.loadingTime = loadingTime;
|
|
@@ -125,7 +125,7 @@ export class Response extends HttpResponse {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
toJSON(): IResponse {
|
|
128
|
+
override toJSON(): IResponse {
|
|
129
129
|
const response = super.toJSON() as IResponse;
|
|
130
130
|
response.loadingTime = this.loadingTime;
|
|
131
131
|
if (this.timings) {
|
|
@@ -51,7 +51,7 @@ export class SentRequest extends HttpRequest {
|
|
|
51
51
|
*/
|
|
52
52
|
endTime = 0;
|
|
53
53
|
|
|
54
|
-
static fromBaseValues(values: IBaseSentRequest): SentRequest {
|
|
54
|
+
static override fromBaseValues(values: IBaseSentRequest): SentRequest {
|
|
55
55
|
return new SentRequest({
|
|
56
56
|
...values,
|
|
57
57
|
kind: Kind,
|
|
@@ -105,7 +105,7 @@ export class SentRequest extends HttpRequest {
|
|
|
105
105
|
/**
|
|
106
106
|
* Creates a new sent request clearing anything that is so far defined.
|
|
107
107
|
*/
|
|
108
|
-
new(init: ISentRequest): void {
|
|
108
|
+
override new(init: ISentRequest): void {
|
|
109
109
|
super.new(init);
|
|
110
110
|
const { httpMessage, startTime=0, endTime=0 } = init;
|
|
111
111
|
this.httpMessage = httpMessage;
|
|
@@ -113,7 +113,7 @@ export class SentRequest extends HttpRequest {
|
|
|
113
113
|
this.endTime = endTime;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
toJSON(): ISentRequest {
|
|
116
|
+
override toJSON(): ISentRequest {
|
|
117
117
|
const request = super.toJSON() as ISentRequest;
|
|
118
118
|
request.httpMessage = this.httpMessage;
|
|
119
119
|
request.startTime = this.startTime;
|
package/src/models/Workspace.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface IWorkspace extends IFile {
|
|
|
20
20
|
* created by the system users, where they can store their projects and other data.
|
|
21
21
|
*/
|
|
22
22
|
export class Workspace extends File {
|
|
23
|
-
kind = Kind;
|
|
23
|
+
override kind = Kind;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Creates a new Space object from a name.
|
|
@@ -77,7 +77,7 @@ export class Workspace extends File {
|
|
|
77
77
|
*
|
|
78
78
|
* Note, this throws an error when the environment is not a space.
|
|
79
79
|
*/
|
|
80
|
-
new(init: IWorkspace): void {
|
|
80
|
+
override new(init: IWorkspace): void {
|
|
81
81
|
if (!Workspace.isWorkspace(init)) {
|
|
82
82
|
throw new Error(`Not a space.`);
|
|
83
83
|
}
|
|
@@ -96,7 +96,7 @@ export class Workspace extends File {
|
|
|
96
96
|
return true;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
toJSON(): IWorkspace {
|
|
99
|
+
override toJSON(): IWorkspace {
|
|
100
100
|
const result: IWorkspace = {
|
|
101
101
|
...super.toJSON(),
|
|
102
102
|
kind: Kind,
|
|
@@ -13,7 +13,7 @@ export interface IDataFile extends IFile {
|
|
|
13
13
|
* Used by the store. A file definition for the DataNamespace
|
|
14
14
|
*/
|
|
15
15
|
export class DataFile extends File {
|
|
16
|
-
kind = Kind;
|
|
16
|
+
override kind = Kind;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Creates the file definition for a DataNamespace contents.
|
|
@@ -66,7 +66,7 @@ export class DataFile extends File {
|
|
|
66
66
|
this.new(init);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
new(init: IDataFile): void {
|
|
69
|
+
override new(init: IDataFile): void {
|
|
70
70
|
if (!DataFile.isDataFile(init)) {
|
|
71
71
|
throw new Error(`Not a data file.`);
|
|
72
72
|
}
|
|
@@ -82,7 +82,7 @@ export class DataFile extends File {
|
|
|
82
82
|
return true;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
toJSON(): IDataFile {
|
|
85
|
+
override toJSON(): IDataFile {
|
|
86
86
|
const result: IDataFile = {
|
|
87
87
|
...super.toJSON(),
|
|
88
88
|
kind: Kind,
|
|
@@ -426,7 +426,7 @@ export class DataNamespace extends DataNamespaceParent {
|
|
|
426
426
|
* @param init The name of the namespace to add, namespace's schema, or instance.
|
|
427
427
|
* @param parent The optional key of the parent namespace to add the new namespace to.
|
|
428
428
|
*/
|
|
429
|
-
addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace {
|
|
429
|
+
override addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace {
|
|
430
430
|
let root: DataNamespace;
|
|
431
431
|
if (parent) {
|
|
432
432
|
const rootCandidate = this.findParent(parent);
|
package/src/models/store/File.ts
CHANGED
|
@@ -458,13 +458,13 @@ export class File extends StoredFile {
|
|
|
458
458
|
return this[permissionsSymbol];
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
-
new(init: IFile): void {
|
|
461
|
+
override new(init: IFile): void {
|
|
462
462
|
super.new(init);
|
|
463
463
|
const { permissions=[] } = init;
|
|
464
464
|
this[permissionsSymbol] = permissions.map(i => ({ ...i }));
|
|
465
465
|
}
|
|
466
466
|
|
|
467
|
-
toJSON(): IFile {
|
|
467
|
+
override toJSON(): IFile {
|
|
468
468
|
const result: IFile = {
|
|
469
469
|
...super.toJSON(),
|
|
470
470
|
permissions: [...this.permissions],
|
|
@@ -97,7 +97,7 @@ export class CoreEngine extends HttpEngine {
|
|
|
97
97
|
/**
|
|
98
98
|
* Cleans the state after finished.
|
|
99
99
|
*/
|
|
100
|
-
_cleanUp(): void {
|
|
100
|
+
override _cleanUp(): void {
|
|
101
101
|
super._cleanUp();
|
|
102
102
|
this.state = RequestState.Status;
|
|
103
103
|
this.rawHeaders = undefined;
|
|
@@ -109,7 +109,7 @@ export class CoreEngine extends HttpEngine {
|
|
|
109
109
|
/**
|
|
110
110
|
* Cleans up the state for redirect.
|
|
111
111
|
*/
|
|
112
|
-
_cleanUpRedirect(): void {
|
|
112
|
+
override _cleanUpRedirect(): void {
|
|
113
113
|
super._cleanUpRedirect();
|
|
114
114
|
this.state = RequestState.Status;
|
|
115
115
|
this.rawHeaders = undefined;
|
|
@@ -522,7 +522,7 @@ export class CoreEngine extends HttpEngine {
|
|
|
522
522
|
/**
|
|
523
523
|
* Generate response object and publish it to the listeners.
|
|
524
524
|
*/
|
|
525
|
-
_publishResponse(): Promise<void> {
|
|
525
|
+
override _publishResponse(): Promise<void> {
|
|
526
526
|
this.state = RequestState.Done;
|
|
527
527
|
if (!this._rawBody) {
|
|
528
528
|
if (this.responseInfo.body) {
|
|
@@ -538,7 +538,7 @@ export class CoreEngine extends HttpEngine {
|
|
|
538
538
|
* @param location The redirect location.
|
|
539
539
|
* @return Redirect response object
|
|
540
540
|
*/
|
|
541
|
-
async _createRedirectResponse(location: string): Promise<ResponseRedirect> {
|
|
541
|
+
override async _createRedirectResponse(location: string): Promise<ResponseRedirect> {
|
|
542
542
|
const { currentResponse = new Response() } = this;
|
|
543
543
|
this.currentResponse = currentResponse;
|
|
544
544
|
if (!this.currentResponse.payload) {
|
|
@@ -219,7 +219,7 @@ export abstract class ProjectRunner extends BaseRunner {
|
|
|
219
219
|
/**
|
|
220
220
|
* Creates the report of the execution.
|
|
221
221
|
*/
|
|
222
|
-
protected async createReport(): Promise<IProjectExecutionLog> {
|
|
222
|
+
protected override async createReport(): Promise<IProjectExecutionLog> {
|
|
223
223
|
const log: IProjectExecutionLog = {
|
|
224
224
|
started: this.startTime as number,
|
|
225
225
|
ended: this.endTime as number,
|