@api-client/core 0.9.24 → 0.9.25
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 +9 -8
- package/build/browser.js +12 -8
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +9 -8
- package/build/index.js +12 -8
- package/build/index.js.map +1 -1
- package/build/src/mocking/lib/Response.js +2 -2
- package/build/src/mocking/lib/Response.js.map +1 -1
- package/build/src/models/CertificateFile.d.ts +2 -2
- package/build/src/models/CertificateFile.js +7 -7
- package/build/src/models/CertificateFile.js.map +1 -1
- package/build/src/models/Environment.js +6 -9
- package/build/src/models/Environment.js.map +1 -1
- package/build/src/models/ErrorResponse.js +5 -4
- package/build/src/models/ErrorResponse.js.map +1 -1
- package/build/src/models/Folder.d.ts +2 -2
- package/build/src/models/Folder.js +7 -7
- package/build/src/models/Folder.js.map +1 -1
- package/build/src/models/HttpProject.js +5 -7
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/HttpResponse.d.ts +0 -1
- package/build/src/models/HttpResponse.js +6 -6
- package/build/src/models/HttpResponse.js.map +1 -1
- package/build/src/models/Project.d.ts +2 -2
- package/build/src/models/Project.js +7 -7
- package/build/src/models/Project.js.map +1 -1
- package/build/src/models/ProjectFolder.d.ts +2 -2
- package/build/src/models/ProjectFolder.js +13 -16
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/ProjectItem.d.ts +2 -1
- package/build/src/models/ProjectItem.js +1 -1
- package/build/src/models/ProjectItem.js.map +1 -1
- package/build/src/models/ProjectParent.js +2 -2
- package/build/src/models/ProjectParent.js.map +1 -1
- package/build/src/models/ProjectRequest.js +5 -17
- package/build/src/models/ProjectRequest.js.map +1 -1
- package/build/src/models/Request.js +6 -24
- package/build/src/models/Request.js.map +1 -1
- package/build/src/models/Response.d.ts +1 -2
- package/build/src/models/Response.js +5 -5
- package/build/src/models/Response.js.map +1 -1
- package/build/src/models/ResponseRedirect.js +2 -1
- package/build/src/models/ResponseRedirect.js.map +1 -1
- package/build/src/models/Thing.d.ts +2 -2
- package/build/src/models/Thing.js +7 -7
- package/build/src/models/Thing.js.map +1 -1
- package/build/src/models/data/DataNamespace.d.ts +3 -3
- package/build/src/models/data/DataNamespace.js +8 -8
- package/build/src/models/data/DataNamespace.js.map +1 -1
- package/build/src/models/kinds.d.ts +8 -0
- package/build/src/models/kinds.js +9 -0
- package/build/src/models/kinds.js.map +1 -0
- package/build/src/models/store/File.js +4 -5
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/transformers/PostmanBackupTransformer.js +4 -7
- package/build/src/models/transformers/PostmanBackupTransformer.js.map +1 -1
- package/build/src/models/transformers/PostmanDataTransformer.d.ts +1 -1
- package/build/src/models/transformers/PostmanV21Transformer.js +2 -5
- package/build/src/models/transformers/PostmanV21Transformer.js.map +1 -1
- package/build/src/models/transformers/PostmanV2Transformer.js +4 -7
- package/build/src/models/transformers/PostmanV2Transformer.js.map +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.js +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
- package/build/src/runtime/store/FilesSdk.d.ts +1 -4
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/package.json +1 -1
- package/src/mocking/lib/Response.ts +3 -2
- package/src/models/CertificateFile.ts +8 -9
- package/src/models/Environment.ts +6 -9
- package/src/models/ErrorResponse.ts +5 -4
- package/src/models/Folder.ts +8 -8
- package/src/models/HttpProject.ts +5 -7
- package/src/models/HttpResponse.ts +6 -7
- package/src/models/Project.ts +8 -9
- package/src/models/ProjectFolder.ts +14 -17
- package/src/models/ProjectItem.ts +2 -1
- package/src/models/ProjectParent.ts +2 -2
- package/src/models/ProjectRequest.ts +5 -17
- package/src/models/Request.ts +6 -24
- package/src/models/Response.ts +5 -6
- package/src/models/ResponseRedirect.ts +2 -1
- package/src/models/Thing.ts +8 -8
- package/src/models/data/DataNamespace.ts +10 -10
- package/src/models/kinds.ts +8 -0
- package/src/models/store/File.ts +4 -5
- package/src/models/transformers/PostmanBackupTransformer.ts +4 -7
- package/src/models/transformers/PostmanDataTransformer.ts +1 -1
- package/src/models/transformers/PostmanV21Transformer.ts +2 -5
- package/src/models/transformers/PostmanV2Transformer.ts +4 -7
- package/src/runtime/node/ProjectRequestRunner.ts +2 -1
- package/src/runtime/store/FilesSdk.ts +5 -5
|
@@ -6,9 +6,9 @@ import { IProjectDefinitionProperty } from './ProjectDefinitionProperty.js';
|
|
|
6
6
|
import { Environment, IEnvironment, Kind as EnvironmentKind } from './Environment.js';
|
|
7
7
|
import { License, ILicense } from './License.js';
|
|
8
8
|
import { Provider, IProvider } from './Provider.js';
|
|
9
|
-
import { IThing, Thing
|
|
9
|
+
import { IThing, Thing } from './Thing.js';
|
|
10
10
|
import { ProjectItem, IProjectItem } from './ProjectItem.js';
|
|
11
|
-
import { IProjectFolder, ProjectFolder
|
|
11
|
+
import { IProjectFolder, ProjectFolder } from './ProjectFolder.js';
|
|
12
12
|
import { IProjectRequest, ProjectRequest, Kind as ProjectRequestKind } from './ProjectRequest.js';
|
|
13
13
|
import { ProjectSchema, IProjectSchema } from './ProjectSchema.js';
|
|
14
14
|
import { Request } from './Request.js';
|
|
@@ -18,6 +18,7 @@ import { ArcLegacyProject, ARCProject } from './legacy/models/ArcLegacyProject.j
|
|
|
18
18
|
import { PostmanDataTransformer } from './transformers/PostmanDataTransformer.js';
|
|
19
19
|
import { Certificate, HttpCertificate } from './ClientCertificate.js';
|
|
20
20
|
import { ICCAuthorization } from './Authorization.js';
|
|
21
|
+
import { ProjectFolderKind } from './kinds.js';
|
|
21
22
|
|
|
22
23
|
export const Kind = 'Core#HttpProject';
|
|
23
24
|
|
|
@@ -374,10 +375,7 @@ export class HttpProject extends ProjectParent {
|
|
|
374
375
|
key: v4(),
|
|
375
376
|
definitions: {},
|
|
376
377
|
items: [],
|
|
377
|
-
info:
|
|
378
|
-
kind: ThingKind,
|
|
379
|
-
name: '',
|
|
380
|
-
},
|
|
378
|
+
info: Thing.fromName('').toJSON(),
|
|
381
379
|
}
|
|
382
380
|
}
|
|
383
381
|
this.new(init);
|
|
@@ -407,7 +405,7 @@ export class HttpProject extends ProjectParent {
|
|
|
407
405
|
if (info) {
|
|
408
406
|
this.info = new Thing(info);
|
|
409
407
|
} else {
|
|
410
|
-
this.info =
|
|
408
|
+
this.info = Thing.fromName('');
|
|
411
409
|
}
|
|
412
410
|
this.items = [];
|
|
413
411
|
if (Array.isArray(items)) {
|
|
@@ -2,8 +2,7 @@ import { ISerializablePayload, SerializablePayload } from './SerializablePayload
|
|
|
2
2
|
import { PayloadSerializer } from '../lib/transformers/PayloadSerializer.js';
|
|
3
3
|
import { HTTPResponse as LegacyHttpResponse } from './legacy/request/ArcResponse.js';
|
|
4
4
|
import { Normalizer } from './legacy/Normalizer.js';
|
|
5
|
-
|
|
6
|
-
export const Kind = 'Core#HttpResponse';
|
|
5
|
+
import { HttpResponseKind } from './kinds.js';
|
|
7
6
|
|
|
8
7
|
export interface IHttpResponse extends ISerializablePayload {
|
|
9
8
|
kind?: string;
|
|
@@ -22,7 +21,7 @@ export interface IHttpResponse extends ISerializablePayload {
|
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export class HttpResponse extends SerializablePayload {
|
|
25
|
-
kind =
|
|
24
|
+
kind = HttpResponseKind;
|
|
26
25
|
/**
|
|
27
26
|
* The response status code
|
|
28
27
|
*/
|
|
@@ -38,7 +37,7 @@ export class HttpResponse extends SerializablePayload {
|
|
|
38
37
|
|
|
39
38
|
static fromValues(status: number, statusText?: string, headers?: string): HttpResponse {
|
|
40
39
|
return new HttpResponse({
|
|
41
|
-
kind:
|
|
40
|
+
kind: HttpResponseKind,
|
|
42
41
|
status,
|
|
43
42
|
statusText,
|
|
44
43
|
headers,
|
|
@@ -47,7 +46,7 @@ export class HttpResponse extends SerializablePayload {
|
|
|
47
46
|
|
|
48
47
|
static async fromLegacy(response: LegacyHttpResponse): Promise<HttpResponse> {
|
|
49
48
|
const init: IHttpResponse = {
|
|
50
|
-
kind:
|
|
49
|
+
kind: HttpResponseKind,
|
|
51
50
|
status: response.status || 0,
|
|
52
51
|
};
|
|
53
52
|
if (response.statusText) {
|
|
@@ -77,7 +76,7 @@ export class HttpResponse extends SerializablePayload {
|
|
|
77
76
|
init = input;
|
|
78
77
|
} else {
|
|
79
78
|
init = {
|
|
80
|
-
kind:
|
|
79
|
+
kind: HttpResponseKind,
|
|
81
80
|
status: 0,
|
|
82
81
|
};
|
|
83
82
|
}
|
|
@@ -93,7 +92,7 @@ export class HttpResponse extends SerializablePayload {
|
|
|
93
92
|
if (!HttpResponse.isHttpResponse(init)) {
|
|
94
93
|
throw new Error(`Not a response.`);
|
|
95
94
|
}
|
|
96
|
-
const { status, statusText, headers, payload, kind =
|
|
95
|
+
const { status, statusText, headers, payload, kind = HttpResponseKind } = init;
|
|
97
96
|
this.kind = kind;
|
|
98
97
|
this.status = status;
|
|
99
98
|
this.statusText = statusText;
|
package/src/models/Project.ts
CHANGED
|
@@ -2,15 +2,14 @@ import { IFile, File, DefaultOwner } from "./store/File.js";
|
|
|
2
2
|
import { Thing } from './Thing.js';
|
|
3
3
|
import { HttpProject, IHttpProject } from './HttpProject.js';
|
|
4
4
|
import v4 from '../lib/uuid.js';
|
|
5
|
-
|
|
6
|
-
export const Kind = 'Core#Project';
|
|
5
|
+
import { ProjectKind } from "./kinds.js";
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* This model represents a meta data for an HTTP project stored with the data store.
|
|
10
9
|
* This does not include the HTTP project entity, though, it is referenced through the same key.
|
|
11
10
|
*/
|
|
12
11
|
export interface IProject extends IFile {
|
|
13
|
-
kind: typeof
|
|
12
|
+
kind: typeof ProjectKind;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
/**
|
|
@@ -18,7 +17,7 @@ export interface IProject extends IFile {
|
|
|
18
17
|
* This does not include the HTTP project entity, though, it is referenced through the same key.
|
|
19
18
|
*/
|
|
20
19
|
export class Project extends File {
|
|
21
|
-
override kind =
|
|
20
|
+
override kind = ProjectKind;
|
|
22
21
|
|
|
23
22
|
static fromProject(project: HttpProject | IHttpProject, space: string, owner = DefaultOwner): Project {
|
|
24
23
|
let final: IHttpProject;
|
|
@@ -28,7 +27,7 @@ export class Project extends File {
|
|
|
28
27
|
final = project as IHttpProject;
|
|
29
28
|
}
|
|
30
29
|
const init: IProject = {
|
|
31
|
-
kind:
|
|
30
|
+
kind: ProjectKind,
|
|
32
31
|
key: project.key,
|
|
33
32
|
space,
|
|
34
33
|
info: { ...final.info },
|
|
@@ -50,7 +49,7 @@ export class Project extends File {
|
|
|
50
49
|
init = input;
|
|
51
50
|
} else {
|
|
52
51
|
init = {
|
|
53
|
-
kind:
|
|
52
|
+
kind: ProjectKind,
|
|
54
53
|
key: v4(),
|
|
55
54
|
space: '',
|
|
56
55
|
info: Thing.fromName('').toJSON(),
|
|
@@ -69,12 +68,12 @@ export class Project extends File {
|
|
|
69
68
|
throw new Error(`Not a project file.`);
|
|
70
69
|
}
|
|
71
70
|
super.new(init);
|
|
72
|
-
this.kind =
|
|
71
|
+
this.kind = ProjectKind;
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
static isProject(input: unknown): boolean {
|
|
76
75
|
const typed = input as IProject;
|
|
77
|
-
if (!input || typed.kind !==
|
|
76
|
+
if (!input || typed.kind !== ProjectKind) {
|
|
78
77
|
return false;
|
|
79
78
|
}
|
|
80
79
|
return true;
|
|
@@ -83,7 +82,7 @@ export class Project extends File {
|
|
|
83
82
|
override toJSON(): IProject {
|
|
84
83
|
const result: IProject = {
|
|
85
84
|
...super.toJSON(),
|
|
86
|
-
kind:
|
|
85
|
+
kind: ProjectKind,
|
|
87
86
|
};
|
|
88
87
|
return result;
|
|
89
88
|
}
|
|
@@ -3,11 +3,11 @@ import { IProjectDefinitionProperty } from './ProjectDefinitionProperty.js';
|
|
|
3
3
|
import { ProjectItem, IProjectItem } from './ProjectItem.js';
|
|
4
4
|
import { ProjectRequest, Kind as ProjectRequestKind, IProjectRequest } from './ProjectRequest.js';
|
|
5
5
|
import { HttpProject, IEnvironmentCreateOptions } from './HttpProject.js';
|
|
6
|
-
import { IThing, Thing
|
|
6
|
+
import { IThing, Thing } from './Thing.js';
|
|
7
7
|
import { Environment, IEnvironment } from './Environment.js';
|
|
8
|
+
import { ProjectFolderKind } from './kinds.js';
|
|
8
9
|
import v4 from '../lib/uuid.js';
|
|
9
10
|
|
|
10
|
-
export const Kind = 'Core#ProjectFolder';
|
|
11
11
|
export const DefaultFolderName = 'New folder';
|
|
12
12
|
|
|
13
13
|
export interface IFolderAddOptions {
|
|
@@ -45,7 +45,7 @@ export interface IFolderCloneOptions {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export interface IProjectFolder extends IProjectDefinitionProperty {
|
|
48
|
-
kind: typeof
|
|
48
|
+
kind: typeof ProjectFolderKind;
|
|
49
49
|
/**
|
|
50
50
|
* The identifier of the folder.
|
|
51
51
|
*/
|
|
@@ -80,7 +80,7 @@ export class ProjectFolder extends ProjectParent {
|
|
|
80
80
|
return DefaultFolderName;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
override kind =
|
|
83
|
+
override kind = ProjectFolderKind;
|
|
84
84
|
/**
|
|
85
85
|
* A reference to the top level project object.
|
|
86
86
|
*/
|
|
@@ -105,11 +105,8 @@ export class ProjectFolder extends ProjectParent {
|
|
|
105
105
|
} else {
|
|
106
106
|
const now: number = Date.now();
|
|
107
107
|
init = {
|
|
108
|
-
kind:
|
|
109
|
-
info:
|
|
110
|
-
kind: ThingKind,
|
|
111
|
-
name: DefaultFolderName,
|
|
112
|
-
},
|
|
108
|
+
kind: ProjectFolderKind,
|
|
109
|
+
info: Thing.fromName(DefaultFolderName).toJSON(),
|
|
113
110
|
created: now,
|
|
114
111
|
updated: now,
|
|
115
112
|
items: [],
|
|
@@ -129,7 +126,7 @@ export class ProjectFolder extends ProjectParent {
|
|
|
129
126
|
throw new Error(`Not a project folder.`);
|
|
130
127
|
}
|
|
131
128
|
const { key = v4(), created = Date.now(), updated = Date.now(), items, info } = init;
|
|
132
|
-
this.kind =
|
|
129
|
+
this.kind = ProjectFolderKind;
|
|
133
130
|
this.key = key;
|
|
134
131
|
this.created = created;
|
|
135
132
|
this.updated = updated;
|
|
@@ -141,7 +138,7 @@ export class ProjectFolder extends ProjectParent {
|
|
|
141
138
|
if (info) {
|
|
142
139
|
this.info = new Thing(info);
|
|
143
140
|
} else {
|
|
144
|
-
this.info =
|
|
141
|
+
this.info = Thing.fromName(DefaultFolderName);
|
|
145
142
|
}
|
|
146
143
|
}
|
|
147
144
|
|
|
@@ -150,7 +147,7 @@ export class ProjectFolder extends ProjectParent {
|
|
|
150
147
|
*/
|
|
151
148
|
static isProjectFolder(input: unknown): boolean {
|
|
152
149
|
const typed = input as IProjectFolder;
|
|
153
|
-
if (!input || typed.kind !==
|
|
150
|
+
if (!input || typed.kind !== ProjectFolderKind) {
|
|
154
151
|
return false;
|
|
155
152
|
}
|
|
156
153
|
return true;
|
|
@@ -158,7 +155,7 @@ export class ProjectFolder extends ProjectParent {
|
|
|
158
155
|
|
|
159
156
|
toJSON(): IProjectFolder {
|
|
160
157
|
const result: IProjectFolder = {
|
|
161
|
-
kind:
|
|
158
|
+
kind: ProjectFolderKind,
|
|
162
159
|
info: this.info.toJSON(),
|
|
163
160
|
key: this.key,
|
|
164
161
|
created: this.created,
|
|
@@ -179,13 +176,13 @@ export class ProjectFolder extends ProjectParent {
|
|
|
179
176
|
static fromName(project: HttpProject, name = DefaultFolderName): ProjectFolder {
|
|
180
177
|
const now = Date.now();
|
|
181
178
|
const key = v4();
|
|
182
|
-
const info =
|
|
179
|
+
const info = Thing.fromName(name);
|
|
183
180
|
const definition = new ProjectFolder(project, {
|
|
184
181
|
key,
|
|
185
182
|
created: now,
|
|
186
183
|
updated: now,
|
|
187
184
|
items: [],
|
|
188
|
-
kind:
|
|
185
|
+
kind: ProjectFolderKind,
|
|
189
186
|
info: info.toJSON(),
|
|
190
187
|
});
|
|
191
188
|
return definition;
|
|
@@ -295,7 +292,7 @@ export class ProjectFolder extends ProjectParent {
|
|
|
295
292
|
*/
|
|
296
293
|
listFolderItems(): ProjectItem[] {
|
|
297
294
|
const { items = [] } = this;
|
|
298
|
-
return items.filter(i => i.kind ===
|
|
295
|
+
return items.filter(i => i.kind === ProjectFolderKind);
|
|
299
296
|
}
|
|
300
297
|
|
|
301
298
|
/**
|
|
@@ -471,7 +468,7 @@ export class ProjectFolder extends ProjectParent {
|
|
|
471
468
|
* @param withRequests Whether to clone requests with the folder.
|
|
472
469
|
*/
|
|
473
470
|
protected cloneSubFolders(folder: ProjectFolder, project: HttpProject, withRequests = true): void {
|
|
474
|
-
const folders = this.items.filter(i => i.kind ===
|
|
471
|
+
const folders = this.items.filter(i => i.kind === ProjectFolderKind);
|
|
475
472
|
folders.forEach(f => {
|
|
476
473
|
const definition = project.findFolder(f.key, { keyOnly: true });
|
|
477
474
|
if (!definition) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ProjectFolder } from './ProjectFolder.js';
|
|
2
2
|
import { Kind as ProjectRequestKind, ProjectRequest } from './ProjectRequest.js';
|
|
3
3
|
import { Kind as EnvironmentKind, Environment } from './Environment.js';
|
|
4
4
|
import { HttpProject } from './HttpProject.js';
|
|
5
|
+
import { ProjectFolderKind } from './kinds.js';
|
|
5
6
|
|
|
6
7
|
type Kind = typeof ProjectFolderKind | typeof ProjectRequestKind | typeof EnvironmentKind;
|
|
7
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpProject } from "./HttpProject.js";
|
|
2
2
|
import { ProjectFolder } from "./ProjectFolder.js";
|
|
3
3
|
import { ProjectItem } from "./ProjectItem.js";
|
|
4
|
-
import { Thing
|
|
4
|
+
import { Thing } from "./Thing.js";
|
|
5
5
|
import { ProjectDefinitionProperty } from "./ProjectDefinitionProperty.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -22,7 +22,7 @@ export abstract class ProjectParent implements ProjectDefinitionProperty {
|
|
|
22
22
|
/**
|
|
23
23
|
* The basic information about the project / folder.
|
|
24
24
|
*/
|
|
25
|
-
info: Thing =
|
|
25
|
+
info: Thing = Thing.fromName('');
|
|
26
26
|
|
|
27
27
|
abstract attachedCallback(): void;
|
|
28
28
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Kind as ThingKind } from './Thing.js';
|
|
2
1
|
import { ProjectDefinitionProperty, IProjectDefinitionProperty } from './ProjectDefinitionProperty.js';
|
|
3
2
|
import { ProjectFolder } from './ProjectFolder.js';
|
|
4
3
|
import { IHttpRequest, Kind as HttpRequestKind } from './HttpRequest.js';
|
|
@@ -10,6 +9,7 @@ import { Property } from './Property.js';
|
|
|
10
9
|
import { Server } from './Server.js';
|
|
11
10
|
import { UriTemplate } from '../lib/parsers/UriTemplate.js';
|
|
12
11
|
import { RequestAuthorization } from './RequestAuthorization.js';
|
|
12
|
+
import { Thing } from './Thing.js';
|
|
13
13
|
|
|
14
14
|
export const Kind = 'Core#ProjectRequest';
|
|
15
15
|
|
|
@@ -118,10 +118,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
118
118
|
method: 'GET',
|
|
119
119
|
url,
|
|
120
120
|
},
|
|
121
|
-
info:
|
|
122
|
-
kind: ThingKind,
|
|
123
|
-
name: url,
|
|
124
|
-
},
|
|
121
|
+
info: Thing.fromName(url).toJSON(),
|
|
125
122
|
});
|
|
126
123
|
return request;
|
|
127
124
|
}
|
|
@@ -148,10 +145,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
148
145
|
method: 'GET',
|
|
149
146
|
url: '',
|
|
150
147
|
},
|
|
151
|
-
info:
|
|
152
|
-
kind: ThingKind,
|
|
153
|
-
name,
|
|
154
|
-
},
|
|
148
|
+
info: Thing.fromName(name).toJSON(),
|
|
155
149
|
});
|
|
156
150
|
return request;
|
|
157
151
|
}
|
|
@@ -180,10 +174,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
180
174
|
headers: info.headers,
|
|
181
175
|
payload: info.payload,
|
|
182
176
|
},
|
|
183
|
-
info:
|
|
184
|
-
kind: ThingKind,
|
|
185
|
-
name: info.url,
|
|
186
|
-
},
|
|
177
|
+
info: Thing.fromName(info.url).toJSON(),
|
|
187
178
|
});
|
|
188
179
|
return request;
|
|
189
180
|
}
|
|
@@ -218,10 +209,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
218
209
|
method: 'GET',
|
|
219
210
|
url: '',
|
|
220
211
|
},
|
|
221
|
-
info:
|
|
222
|
-
kind: ThingKind,
|
|
223
|
-
name: '',
|
|
224
|
-
},
|
|
212
|
+
info: Thing.fromName('').toJSON(),
|
|
225
213
|
};
|
|
226
214
|
}
|
|
227
215
|
this.new(init);
|
package/src/models/Request.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Core as JsonCore } from '@api-client/json'
|
|
2
2
|
import { IRequestConfig, RequestConfig } from './RequestConfig.js';
|
|
3
|
-
import { Thing, IThing
|
|
3
|
+
import { Thing, IThing } from './Thing.js';
|
|
4
4
|
import { HttpCertificate, Certificate } from './ClientCertificate.js';
|
|
5
5
|
import { IRequestAuthorization, RequestAuthorization } from './RequestAuthorization.js';
|
|
6
6
|
import { IRequestLog, RequestLog, Kind as LogKind } from './RequestLog.js';
|
|
@@ -139,10 +139,7 @@ export class Request {
|
|
|
139
139
|
method: 'GET',
|
|
140
140
|
url,
|
|
141
141
|
},
|
|
142
|
-
info:
|
|
143
|
-
kind: ThingKind,
|
|
144
|
-
name: url,
|
|
145
|
-
},
|
|
142
|
+
info: Thing.fromName(url).toJSON(),
|
|
146
143
|
});
|
|
147
144
|
return request;
|
|
148
145
|
}
|
|
@@ -163,10 +160,7 @@ export class Request {
|
|
|
163
160
|
method: 'GET',
|
|
164
161
|
url: '',
|
|
165
162
|
},
|
|
166
|
-
info:
|
|
167
|
-
kind: ThingKind,
|
|
168
|
-
name,
|
|
169
|
-
},
|
|
163
|
+
info: Thing.fromName(name).toJSON(),
|
|
170
164
|
});
|
|
171
165
|
return request;
|
|
172
166
|
}
|
|
@@ -189,10 +183,7 @@ export class Request {
|
|
|
189
183
|
headers: info.headers,
|
|
190
184
|
payload: info.payload,
|
|
191
185
|
},
|
|
192
|
-
info:
|
|
193
|
-
kind: ThingKind,
|
|
194
|
-
name: info.url,
|
|
195
|
-
},
|
|
186
|
+
info: Thing.fromName(info.url).toJSON(),
|
|
196
187
|
});
|
|
197
188
|
return request;
|
|
198
189
|
}
|
|
@@ -210,10 +201,7 @@ export class Request {
|
|
|
210
201
|
url: normalized.url || '',
|
|
211
202
|
headers: normalized.headers,
|
|
212
203
|
},
|
|
213
|
-
info:
|
|
214
|
-
kind: ThingKind,
|
|
215
|
-
name: normalized.name || 'Unnamed request',
|
|
216
|
-
},
|
|
204
|
+
info: Thing.fromName(normalized.name || 'Unnamed request').toJSON(),
|
|
217
205
|
};
|
|
218
206
|
init.created = normalized.created;
|
|
219
207
|
init.updated = normalized.updated;
|
|
@@ -341,10 +329,7 @@ export class Request {
|
|
|
341
329
|
method: 'GET',
|
|
342
330
|
url: '',
|
|
343
331
|
},
|
|
344
|
-
info:
|
|
345
|
-
kind: ThingKind,
|
|
346
|
-
name: '',
|
|
347
|
-
},
|
|
332
|
+
info: Thing.fromName('').toJSON(),
|
|
348
333
|
};
|
|
349
334
|
}
|
|
350
335
|
this.new(init);
|
|
@@ -358,9 +343,6 @@ export class Request {
|
|
|
358
343
|
this.expects = new HttpRequest();
|
|
359
344
|
}
|
|
360
345
|
if (info) {
|
|
361
|
-
if (!info.kind) {
|
|
362
|
-
info.kind = ThingKind;
|
|
363
|
-
}
|
|
364
346
|
this.info = new Thing(info);
|
|
365
347
|
} else {
|
|
366
348
|
this.info = Thing.fromName('')
|
package/src/models/Response.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { IHttpResponse, HttpResponse
|
|
1
|
+
import { IHttpResponse, HttpResponse } from './HttpResponse.js';
|
|
2
2
|
import { IRequestTime, RequestTime } from './RequestTime.js';
|
|
3
3
|
import { IResponseAuthorization, ResponseAuthorization } from './ResponseAuthorization.js';
|
|
4
4
|
import { IErrorResponse } from './ErrorResponse.js';
|
|
5
5
|
import { Response as LegacyResponse } from './legacy/request/ArcResponse.js';
|
|
6
6
|
import { PayloadSerializer } from '../lib/transformers/PayloadSerializer.js';
|
|
7
7
|
import { Normalizer } from './legacy/Normalizer.js';
|
|
8
|
-
|
|
9
|
-
export { Kind };
|
|
8
|
+
import { HttpResponseKind } from './kinds.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* An HTTP response object.
|
|
@@ -44,7 +43,7 @@ export class Response extends HttpResponse {
|
|
|
44
43
|
|
|
45
44
|
static override fromValues(status: number, statusText?: string, headers?: string): Response {
|
|
46
45
|
return new Response({
|
|
47
|
-
kind:
|
|
46
|
+
kind: HttpResponseKind,
|
|
48
47
|
status,
|
|
49
48
|
statusText,
|
|
50
49
|
headers,
|
|
@@ -54,7 +53,7 @@ export class Response extends HttpResponse {
|
|
|
54
53
|
|
|
55
54
|
static override async fromLegacy(input: LegacyResponse): Promise<Response> {
|
|
56
55
|
const init: IResponse = {
|
|
57
|
-
kind:
|
|
56
|
+
kind: HttpResponseKind,
|
|
58
57
|
status: input.status || 0,
|
|
59
58
|
loadingTime: input.loadingTime || 0,
|
|
60
59
|
};
|
|
@@ -98,7 +97,7 @@ export class Response extends HttpResponse {
|
|
|
98
97
|
init = input;
|
|
99
98
|
} else {
|
|
100
99
|
init = {
|
|
101
|
-
kind:
|
|
100
|
+
kind: HttpResponseKind,
|
|
102
101
|
status: 0,
|
|
103
102
|
loadingTime: 0,
|
|
104
103
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IHttpResponse, HttpResponse
|
|
1
|
+
import { IHttpResponse, HttpResponse } from './HttpResponse.js';
|
|
2
2
|
import { IRequestTime, RequestTime } from './RequestTime.js';
|
|
3
3
|
import { ResponseRedirect as LegacyRedirect } from './legacy/request/ArcResponse.js';
|
|
4
|
+
import { ResponseKind } from './kinds.js';
|
|
4
5
|
|
|
5
6
|
export const Kind = 'Core#HttpResponseRedirect';
|
|
6
7
|
|
package/src/models/Thing.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { ThingKind } from "./kinds.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* An interface describing a base metadata of a thing.
|
|
@@ -7,7 +7,7 @@ export declare interface IThing {
|
|
|
7
7
|
/**
|
|
8
8
|
* The data kind. The application ignores the input with an unknown `kind`, unless it can be determined from the context.
|
|
9
9
|
*/
|
|
10
|
-
kind?: typeof
|
|
10
|
+
kind?: typeof ThingKind;
|
|
11
11
|
/**
|
|
12
12
|
* The name of the thing.
|
|
13
13
|
*/
|
|
@@ -28,7 +28,7 @@ export declare interface IThing {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export class Thing {
|
|
31
|
-
kind =
|
|
31
|
+
kind = ThingKind;
|
|
32
32
|
/**
|
|
33
33
|
* The name of the thing.
|
|
34
34
|
*/
|
|
@@ -63,7 +63,7 @@ export class Thing {
|
|
|
63
63
|
static fromName(name: string): Thing {
|
|
64
64
|
const thing = new Thing({
|
|
65
65
|
name,
|
|
66
|
-
kind:
|
|
66
|
+
kind: ThingKind,
|
|
67
67
|
});
|
|
68
68
|
return thing;
|
|
69
69
|
}
|
|
@@ -79,7 +79,7 @@ export class Thing {
|
|
|
79
79
|
init = input;
|
|
80
80
|
} else {
|
|
81
81
|
init = {
|
|
82
|
-
kind:
|
|
82
|
+
kind: ThingKind,
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
this.new(init);
|
|
@@ -95,7 +95,7 @@ export class Thing {
|
|
|
95
95
|
throw new Error(`Not a thing.`);
|
|
96
96
|
}
|
|
97
97
|
const { description, name, version, displayName } = init;
|
|
98
|
-
this.kind =
|
|
98
|
+
this.kind = ThingKind;
|
|
99
99
|
this.name = name;
|
|
100
100
|
this.displayName = displayName;
|
|
101
101
|
this.description = description;
|
|
@@ -107,7 +107,7 @@ export class Thing {
|
|
|
107
107
|
*/
|
|
108
108
|
static isThing(input: unknown): boolean {
|
|
109
109
|
const typed = input as IThing;
|
|
110
|
-
if (input && typed.kind ===
|
|
110
|
+
if (input && typed.kind === ThingKind) {
|
|
111
111
|
return true;
|
|
112
112
|
}
|
|
113
113
|
return false;
|
|
@@ -115,7 +115,7 @@ export class Thing {
|
|
|
115
115
|
|
|
116
116
|
toJSON(): IThing {
|
|
117
117
|
const result: IThing = {
|
|
118
|
-
kind:
|
|
118
|
+
kind: ThingKind,
|
|
119
119
|
};
|
|
120
120
|
if (typeof this.name === 'string') {
|
|
121
121
|
result.name = this.name;
|
|
@@ -4,10 +4,10 @@ import { IDataAssociation, DataAssociation, AssociationTarget } from "./DataAsso
|
|
|
4
4
|
import { IDataEntity, DataEntity } from "./DataEntity.js";
|
|
5
5
|
import { IDataModel, DataModel, Kind as DataModelKind } from "./DataModel.js";
|
|
6
6
|
import { IDataProperty, DataProperty } from "./DataProperty.js";
|
|
7
|
+
import { DataNamespaceKind } from "../kinds.js";
|
|
7
8
|
import v4 from '../../lib/uuid.js';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
type ItemKind = typeof Kind | typeof DataModelKind;
|
|
10
|
+
type ItemKind = typeof DataNamespaceKind | typeof DataModelKind;
|
|
11
11
|
|
|
12
12
|
interface IDataDefinitions {
|
|
13
13
|
models?: IDataModel[];
|
|
@@ -32,7 +32,7 @@ interface DataDefinitions {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
interface IDataNamespaceParent {
|
|
35
|
-
kind: typeof
|
|
35
|
+
kind: typeof DataNamespaceKind;
|
|
36
36
|
/**
|
|
37
37
|
* The key of the namespace.
|
|
38
38
|
*/
|
|
@@ -73,7 +73,7 @@ export interface IDataItem {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
class DataNamespaceParent {
|
|
76
|
-
kind =
|
|
76
|
+
kind = DataNamespaceKind;
|
|
77
77
|
|
|
78
78
|
key = '';
|
|
79
79
|
|
|
@@ -130,7 +130,7 @@ class DataNamespaceParent {
|
|
|
130
130
|
const root = this.getRoot();
|
|
131
131
|
const { namespaces } = root.definitions;
|
|
132
132
|
items.forEach(i => {
|
|
133
|
-
if (i.kind !==
|
|
133
|
+
if (i.kind !== DataNamespaceKind) {
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
const def = namespaces.find(j => j.key === i.key);
|
|
@@ -203,7 +203,7 @@ export class DataItem implements IDataItem {
|
|
|
203
203
|
|
|
204
204
|
static isDataItem(input: unknown): boolean {
|
|
205
205
|
const typed = input as IDataItem;
|
|
206
|
-
if (!input || ![DataModelKind,
|
|
206
|
+
if (!input || ![DataModelKind, DataNamespaceKind].includes(typed.kind)) {
|
|
207
207
|
return false;
|
|
208
208
|
}
|
|
209
209
|
return true;
|
|
@@ -211,7 +211,7 @@ export class DataItem implements IDataItem {
|
|
|
211
211
|
|
|
212
212
|
static dataNamespace(root: DataNamespace, key: string): DataItem {
|
|
213
213
|
const item = new DataItem(root, {
|
|
214
|
-
kind:
|
|
214
|
+
kind: DataNamespaceKind,
|
|
215
215
|
key,
|
|
216
216
|
});
|
|
217
217
|
return item;
|
|
@@ -319,11 +319,11 @@ export class DataNamespace extends DataNamespaceParent {
|
|
|
319
319
|
} else if (typeof input === 'object') {
|
|
320
320
|
init = input;
|
|
321
321
|
if (!init.kind) {
|
|
322
|
-
init.kind =
|
|
322
|
+
init.kind = DataNamespaceKind;
|
|
323
323
|
}
|
|
324
324
|
} else {
|
|
325
325
|
init = {
|
|
326
|
-
kind:
|
|
326
|
+
kind: DataNamespaceKind,
|
|
327
327
|
key: v4(),
|
|
328
328
|
definitions: {},
|
|
329
329
|
items: [],
|
|
@@ -386,7 +386,7 @@ export class DataNamespace extends DataNamespaceParent {
|
|
|
386
386
|
toJSON(): IDataNamespace {
|
|
387
387
|
const result: IDataNamespace = {
|
|
388
388
|
key: this.key,
|
|
389
|
-
kind:
|
|
389
|
+
kind: DataNamespaceKind,
|
|
390
390
|
info: this.info.toJSON(),
|
|
391
391
|
items: this.items.map(i => i.toJSON()),
|
|
392
392
|
definitions: {},
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const ProjectFolderKind = 'Core#ProjectFolder';
|
|
2
|
+
export const ResponseKind = 'Core#HttpResponse';
|
|
3
|
+
export const HttpResponseKind = 'Core#HttpResponse';
|
|
4
|
+
export const CertificateFileKind = 'Core#CertificateFile';
|
|
5
|
+
export const DataNamespaceKind = 'Core#DataNamespace';
|
|
6
|
+
export const FolderKind = 'Core#Folder';
|
|
7
|
+
export const ProjectKind = 'Core#Project';
|
|
8
|
+
export const ThingKind = 'Core#Thing';
|
package/src/models/store/File.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { IUser, Kind as UserKind } from './User.js';
|
|
|
5
5
|
import { IThing, Thing } from '../Thing.js';
|
|
6
6
|
import v4 from '../../lib/uuid.js';
|
|
7
7
|
import { ICapabilities } from './Capabilities.js';
|
|
8
|
+
import { FolderKind } from '../kinds.js';
|
|
8
9
|
// this causes error
|
|
9
10
|
// import { Kind as FolderKind } from '../Folder.js';
|
|
10
11
|
|
|
@@ -397,15 +398,13 @@ export class StoredFile {
|
|
|
397
398
|
canUntrash: isOwner,
|
|
398
399
|
canReadMedia: false,
|
|
399
400
|
};
|
|
400
|
-
|
|
401
|
-
// an error.
|
|
402
|
-
if (file.kind === 'Core#Folder' && isWriter) {
|
|
401
|
+
if (file.kind === FolderKind && isWriter) {
|
|
403
402
|
result.canAddChildren = true;
|
|
404
403
|
}
|
|
405
|
-
if (file.kind ===
|
|
404
|
+
if (file.kind === FolderKind) {
|
|
406
405
|
result.canListChildren = isReader;
|
|
407
406
|
}
|
|
408
|
-
if (file.kind !==
|
|
407
|
+
if (file.kind !== FolderKind) {
|
|
409
408
|
result.canReadMedia = isReader;
|
|
410
409
|
}
|
|
411
410
|
return result;
|