@api-client/core 0.5.12 → 0.5.16
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 -1
- 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 -0
- package/build/index.js.map +1 -1
- package/build/src/models/HttpProject.d.ts +85 -32
- package/build/src/models/HttpProject.js +181 -80
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/ProjectFolder.d.ts +43 -6
- package/build/src/models/ProjectFolder.js +37 -12
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/ProjectItem.d.ts +13 -6
- package/build/src/models/ProjectItem.js +24 -4
- package/build/src/models/ProjectItem.js.map +1 -1
- package/build/src/models/ProjectParent.d.ts +1 -42
- package/build/src/models/ProjectParent.js +1 -84
- package/build/src/models/ProjectParent.js.map +1 -1
- package/build/src/models/{Backend.d.ts → store/Backend.d.ts} +91 -4
- package/build/src/models/store/Backend.js +3 -0
- package/build/src/models/store/Backend.js.map +1 -0
- package/build/src/models/transformers/PostmanBackupTransformer.js +0 -1
- package/build/src/models/transformers/PostmanBackupTransformer.js.map +1 -1
- package/build/src/models/transformers/PostmanV21Transformer.js +0 -1
- package/build/src/models/transformers/PostmanV21Transformer.js.map +1 -1
- package/build/src/models/transformers/PostmanV2Transformer.js +0 -1
- 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/BackendSdk.d.ts +1 -1
- package/build/src/runtime/store/FilesSdk.d.ts +4 -6
- package/build/src/runtime/store/FilesSdk.js +2 -1
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/build/src/runtime/store/HistorySdk.d.ts +1 -1
- package/build/src/runtime/store/Sdk.d.ts +1 -1
- package/build/src/runtime/store/SharedSdk.d.ts +1 -1
- package/build/src/runtime/store/UsersSdk.d.ts +1 -1
- package/package.json +1 -1
- package/src/models/HttpProject.ts +236 -99
- package/src/models/ProjectFolder.ts +68 -17
- package/src/models/ProjectItem.ts +33 -11
- package/src/models/ProjectParent.ts +1 -110
- package/src/models/{Backend.ts → store/Backend.ts} +99 -4
- package/src/models/transformers/PostmanBackupTransformer.ts +0 -1
- package/src/models/transformers/PostmanV21Transformer.ts +0 -1
- package/src/models/transformers/PostmanV2Transformer.ts +0 -1
- package/src/runtime/node/ProjectRequestRunner.ts +1 -1
- package/src/runtime/store/BackendSdk.ts +1 -1
- package/src/runtime/store/FilesSdk.ts +8 -9
- package/src/runtime/store/HistorySdk.ts +1 -1
- package/src/runtime/store/Sdk.ts +1 -1
- package/src/runtime/store/SharedSdk.ts +1 -1
- package/src/runtime/store/UsersSdk.ts +1 -1
- package/build/src/models/Backend.js +0 -2
- package/build/src/models/Backend.js.map +0 -1
|
@@ -3,8 +3,6 @@ import { ProjectFolder } from "./ProjectFolder.js";
|
|
|
3
3
|
import { ProjectItem } from "./ProjectItem.js";
|
|
4
4
|
import { Thing, Kind as ThingKind } from "./Thing.js";
|
|
5
5
|
import { ProjectDefinitionProperty } from "./ProjectDefinitionProperty.js";
|
|
6
|
-
import { Environment, IEnvironment } from "./Environment.js";
|
|
7
|
-
import v4 from '../lib/uuid.js';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* A class that contains a common properties and methods of an `HttpProject` and
|
|
@@ -14,12 +12,7 @@ export abstract class ProjectParent implements ProjectDefinitionProperty {
|
|
|
14
12
|
kind: unknown;
|
|
15
13
|
key: string = '';
|
|
16
14
|
/**
|
|
17
|
-
* The environments
|
|
18
|
-
* If not set it is inherited from the parent.
|
|
19
|
-
*/
|
|
20
|
-
environments: string[] = [];
|
|
21
|
-
/**
|
|
22
|
-
* The ordered list of HTTP requests / folders in the projects.
|
|
15
|
+
* The ordered list of HTTP requests, folders, or environments in the projects.
|
|
23
16
|
* The UI uses this to manipulate the view without changing the definitions.
|
|
24
17
|
*/
|
|
25
18
|
items: ProjectItem[] = [];
|
|
@@ -35,106 +28,4 @@ export abstract class ProjectParent implements ProjectDefinitionProperty {
|
|
|
35
28
|
abstract getParent(): HttpProject | ProjectFolder | undefined;
|
|
36
29
|
|
|
37
30
|
abstract getProject(): HttpProject;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Adds an environment to the project.
|
|
41
|
-
*
|
|
42
|
-
* @param env The definition of the environment to use to create the environment
|
|
43
|
-
* @returns The same or created environment.
|
|
44
|
-
*/
|
|
45
|
-
addEnvironment(env: IEnvironment): Environment;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Adds an environment to the project.
|
|
49
|
-
*
|
|
50
|
-
* @param env The instance of the environment to add
|
|
51
|
-
* @returns The same or created environment.
|
|
52
|
-
*/
|
|
53
|
-
addEnvironment(env: Environment): Environment;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Adds an environment to the project.
|
|
57
|
-
*
|
|
58
|
-
* @param env The name of the environment to create
|
|
59
|
-
* @returns The same or created environment.
|
|
60
|
-
*/
|
|
61
|
-
addEnvironment(env: string): Environment;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Adds an environment to the project.
|
|
65
|
-
* @returns The same or created environment.
|
|
66
|
-
*/
|
|
67
|
-
addEnvironment(env: IEnvironment | Environment | string): Environment {
|
|
68
|
-
if (!Array.isArray(this.environments)) {
|
|
69
|
-
this.environments = [];
|
|
70
|
-
}
|
|
71
|
-
let finalEnv;
|
|
72
|
-
if (env instanceof Environment) {
|
|
73
|
-
finalEnv = env;
|
|
74
|
-
} else if (typeof env === 'string') {
|
|
75
|
-
finalEnv = Environment.fromName(env);
|
|
76
|
-
} else {
|
|
77
|
-
finalEnv = new Environment(env);
|
|
78
|
-
}
|
|
79
|
-
if (!finalEnv.key) {
|
|
80
|
-
finalEnv.key = v4();
|
|
81
|
-
}
|
|
82
|
-
const project = this.getProject();
|
|
83
|
-
if (!project.definitions.environments) {
|
|
84
|
-
project.definitions.environments = [];
|
|
85
|
-
}
|
|
86
|
-
project.definitions.environments.push(finalEnv);
|
|
87
|
-
this.environments.push(finalEnv.key);
|
|
88
|
-
return finalEnv;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
*
|
|
93
|
-
* @returns The list of environments defined in this folder.
|
|
94
|
-
*/
|
|
95
|
-
getEnvironments(): Environment[] {
|
|
96
|
-
const { environments } = this;
|
|
97
|
-
if (!environments.length) {
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
const project = this.getProject();
|
|
101
|
-
if (!project.definitions.environments) {
|
|
102
|
-
return [];
|
|
103
|
-
}
|
|
104
|
-
const result: Environment[] = [];
|
|
105
|
-
environments.forEach((key) => {
|
|
106
|
-
const env = project.definitions.environments.find(i => i.key === key);
|
|
107
|
-
if (env) {
|
|
108
|
-
result.push(env);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
return result;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* @param key The environment key to read.
|
|
116
|
-
*/
|
|
117
|
-
getEnvironment(key: string): Environment | undefined {
|
|
118
|
-
const { environments } = this;
|
|
119
|
-
if (!environments.length) {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
const has = environments.includes(key);
|
|
123
|
-
if (!has) {
|
|
124
|
-
return undefined;
|
|
125
|
-
}
|
|
126
|
-
const project = this.getProject();
|
|
127
|
-
if (!project.definitions.environments) {
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
return project.definitions.environments.find(i => i.key === key);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* This is a link to the `getEnvironments()`. The difference is that on the
|
|
135
|
-
* project level it won't return environments defined with the class initialization.
|
|
136
|
-
*/
|
|
137
|
-
listEnvironments(): Environment[] {
|
|
138
|
-
return this.getEnvironments();
|
|
139
|
-
}
|
|
140
31
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/* eslint-disable import/export */
|
|
2
|
+
|
|
3
|
+
import { JsonPatch } from '@api-client/json'
|
|
4
|
+
import { AccessOperation } from './Permission.js';
|
|
5
|
+
|
|
2
6
|
export type BackendMode = 'single-user' | 'multi-user';
|
|
3
7
|
|
|
4
8
|
export interface IBackendInfo {
|
|
@@ -16,14 +20,49 @@ export interface IBackendInfo {
|
|
|
16
20
|
* @default single-user
|
|
17
21
|
*/
|
|
18
22
|
mode: BackendMode;
|
|
23
|
+
|
|
19
24
|
/**
|
|
20
|
-
*
|
|
25
|
+
* Client authentication configuration
|
|
21
26
|
*/
|
|
22
|
-
|
|
27
|
+
auth: {
|
|
28
|
+
/**
|
|
29
|
+
* The path to the authentication endpoint.
|
|
30
|
+
* This is always populated whether the store is in the single- or multi-user mode.
|
|
31
|
+
*/
|
|
32
|
+
path: string;
|
|
33
|
+
/**
|
|
34
|
+
* When configured, the OAuth2 redirect URI.
|
|
35
|
+
*/
|
|
36
|
+
redirect?: string;
|
|
37
|
+
/**
|
|
38
|
+
* When configured the type of the authentication protocol.
|
|
39
|
+
*/
|
|
40
|
+
type?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
23
43
|
/**
|
|
24
|
-
* The
|
|
44
|
+
* The information about hosting.
|
|
25
45
|
*/
|
|
26
|
-
|
|
46
|
+
hosting: {
|
|
47
|
+
/**
|
|
48
|
+
* Optional, the store base path when set on the configuration.
|
|
49
|
+
*/
|
|
50
|
+
prefix?: string;
|
|
51
|
+
/**
|
|
52
|
+
* When configured with the host information, this is the public host name of the store.
|
|
53
|
+
* When using udp to discover the store in the local network, this is the ip address of the machine the store
|
|
54
|
+
* is running on.
|
|
55
|
+
*/
|
|
56
|
+
host?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The port number the store operates on, if the store was initialized on a port.
|
|
59
|
+
*/
|
|
60
|
+
port?: number;
|
|
61
|
+
/**
|
|
62
|
+
* The socket path, if the server was initialized on a socket.
|
|
63
|
+
*/
|
|
64
|
+
socket?: string;
|
|
65
|
+
}
|
|
27
66
|
}
|
|
28
67
|
|
|
29
68
|
export interface IBackendCommand {
|
|
@@ -205,3 +244,59 @@ export interface IHistoryAppListOptions extends IListOptions {
|
|
|
205
244
|
*/
|
|
206
245
|
id: string;
|
|
207
246
|
}
|
|
247
|
+
|
|
248
|
+
export interface IPatchBase {
|
|
249
|
+
/**
|
|
250
|
+
* Auto generated by the client sending the PATCH.
|
|
251
|
+
*/
|
|
252
|
+
id: string;
|
|
253
|
+
/**
|
|
254
|
+
* The application id that generated the patch.
|
|
255
|
+
* This is a string that is assigned to each application in the suite.
|
|
256
|
+
* External applications need to use a constant string for their apps.
|
|
257
|
+
*/
|
|
258
|
+
app: string;
|
|
259
|
+
/**
|
|
260
|
+
* The version of the application that generated the patch.
|
|
261
|
+
* This can and will be used to handle potential differences between suite applications.
|
|
262
|
+
*/
|
|
263
|
+
appVersion: string;
|
|
264
|
+
/**
|
|
265
|
+
* The patch generated by the client.
|
|
266
|
+
*/
|
|
267
|
+
patch: unknown;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* An interface describing a schema to be sent to the server
|
|
272
|
+
* when making a patch of a file.
|
|
273
|
+
*/
|
|
274
|
+
export interface IPatchInfo extends IPatchBase {
|
|
275
|
+
/**
|
|
276
|
+
* The patch generated by the client.
|
|
277
|
+
*/
|
|
278
|
+
patch: JsonPatch;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* An interface describing a schema to be sent to the server
|
|
283
|
+
* when making a patch with user access to a file.
|
|
284
|
+
*/
|
|
285
|
+
export interface IAccessPatchInfo extends IPatchBase {
|
|
286
|
+
/**
|
|
287
|
+
* The patch generated by the client.
|
|
288
|
+
*/
|
|
289
|
+
patch: AccessOperation[];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* A schema sent by the store server in a response to the patch request.
|
|
294
|
+
* It contains an information about the applied patch, the reverse operation associated with it,
|
|
295
|
+
* application information, and the generated by the client patch id.
|
|
296
|
+
*/
|
|
297
|
+
export interface IPatchRevision extends IPatchInfo {
|
|
298
|
+
/**
|
|
299
|
+
* The patch to apply to the object to revert the changes.
|
|
300
|
+
*/
|
|
301
|
+
revert: JsonPatch;
|
|
302
|
+
}
|
|
@@ -205,7 +205,7 @@ export class ProjectRequestRunner extends EventEmitter {
|
|
|
205
205
|
*/
|
|
206
206
|
protected async readEnvironments(parent: HttpProject | ProjectFolder): Promise<Environment[]> {
|
|
207
207
|
const folderKey = parent.kind === ProjectFolderKind ? (parent as ProjectFolder).key : undefined;
|
|
208
|
-
return this.project.readEnvironments({ folderKey });
|
|
208
|
+
return this.project.readEnvironments({ parent: folderKey });
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
/**
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import WebSocketNode from 'ws';
|
|
2
|
-
import { Patch } from '@api-client/json';
|
|
3
2
|
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, E_RESPONSE_LOCATION, ISdkRequestOptions } from './SdkBase.js';
|
|
4
3
|
import { RouteBuilder } from './RouteBuilder.js';
|
|
5
|
-
import { IListOptions, IListResponse } from '../../models/Backend.js';
|
|
6
|
-
import { AccessOperation } from '../../models/store/Permission.js';
|
|
4
|
+
import { IListOptions, IListResponse, IPatchInfo, IPatchRevision, IAccessPatchInfo } from '../../models/store/Backend.js';
|
|
7
5
|
import { IUser } from '../../models/store/User.js';
|
|
8
6
|
import { IFile } from '../../models/store/File.js';
|
|
9
7
|
import { Kind as ProjectKind } from '../../models/Project.js';
|
|
@@ -193,7 +191,7 @@ export class FilesSdk extends SdkBase {
|
|
|
193
191
|
* @param value The patch to apply.
|
|
194
192
|
* @param request Optional request options.
|
|
195
193
|
*/
|
|
196
|
-
patch(key: string, value:
|
|
194
|
+
patch(key: string, value: IPatchInfo, media: false, request?: ISdkRequestOptions): Promise<IPatchRevision>;
|
|
197
195
|
|
|
198
196
|
/**
|
|
199
197
|
* Patches file's content in the store.
|
|
@@ -202,7 +200,7 @@ export class FilesSdk extends SdkBase {
|
|
|
202
200
|
* @param value The patch to apply.
|
|
203
201
|
* @param request Optional request options.
|
|
204
202
|
*/
|
|
205
|
-
patch(key: string, value:
|
|
203
|
+
patch(key: string, value: IPatchInfo, media: true, request?: ISdkRequestOptions): Promise<IPatchRevision>;
|
|
206
204
|
|
|
207
205
|
/**
|
|
208
206
|
* Patches a file in the store.
|
|
@@ -211,7 +209,7 @@ export class FilesSdk extends SdkBase {
|
|
|
211
209
|
* @param request Optional request options.
|
|
212
210
|
* @returns The JSON patch to revert the change using the `@api-client/json` library
|
|
213
211
|
*/
|
|
214
|
-
async patch(key: string, value:
|
|
212
|
+
async patch(key: string, value: IPatchInfo, media?: boolean, request: ISdkRequestOptions = {}): Promise<IPatchRevision> {
|
|
215
213
|
const token = request.token || this.sdk.token;
|
|
216
214
|
const url = this.sdk.getUrl(RouteBuilder.file(key));
|
|
217
215
|
if (media) {
|
|
@@ -233,16 +231,17 @@ export class FilesSdk extends SdkBase {
|
|
|
233
231
|
if (!result.body) {
|
|
234
232
|
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
235
233
|
}
|
|
236
|
-
let data:
|
|
234
|
+
let data: IPatchRevision;
|
|
237
235
|
try {
|
|
238
236
|
data = JSON.parse(result.body);
|
|
239
237
|
} catch (e) {
|
|
240
238
|
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
241
239
|
}
|
|
240
|
+
// revert is added to the response
|
|
242
241
|
if (!data.revert) {
|
|
243
242
|
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
244
243
|
}
|
|
245
|
-
return data
|
|
244
|
+
return data;
|
|
246
245
|
}
|
|
247
246
|
|
|
248
247
|
/**
|
|
@@ -275,7 +274,7 @@ export class FilesSdk extends SdkBase {
|
|
|
275
274
|
* @param value The patch operation on the file's ACL
|
|
276
275
|
* @param request Optional request options.
|
|
277
276
|
*/
|
|
278
|
-
async patchUsers(key: string, value:
|
|
277
|
+
async patchUsers(key: string, value: IAccessPatchInfo, request: ISdkRequestOptions = {}): Promise<void> {
|
|
279
278
|
const token = request.token || this.sdk.token;
|
|
280
279
|
const url = this.sdk.getUrl(RouteBuilder.fileUsers(key));
|
|
281
280
|
const body = JSON.stringify(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, E_RESPONSE_LOCATION, ISdkRequestOptions } from './SdkBase.js';
|
|
2
2
|
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
-
import { IListResponse, HistoryListOptions, IHistoryRequestListOptions } from '../../models/Backend.js';
|
|
3
|
+
import { IListResponse, HistoryListOptions, IHistoryRequestListOptions } from '../../models/store/Backend.js';
|
|
4
4
|
import { IHttpHistory, IHttpHistoryBulkAdd, Kind as HttpHistoryKind } from '../../models/HttpHistory.js';
|
|
5
5
|
|
|
6
6
|
export class HistorySdk extends SdkBase {
|
package/src/runtime/store/Sdk.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, ISdkRequestOptions } from './SdkBase.js';
|
|
2
2
|
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
-
import { IListOptions, IListResponse } from '../../models/Backend.js';
|
|
3
|
+
import { IListOptions, IListResponse } from '../../models/store/Backend.js';
|
|
4
4
|
import { Kind as ProjectKind } from '../../models/Project.js';
|
|
5
5
|
import { Kind as WorkspaceKind } from '../../models/Workspace.js';
|
|
6
6
|
import { IFile } from '../../models/store/File.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, ISdkRequestOptions } from './SdkBase.js';
|
|
2
2
|
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
-
import { IListOptions, IListResponse } from '../../models/Backend.js';
|
|
3
|
+
import { IListOptions, IListResponse } from '../../models/store/Backend.js';
|
|
4
4
|
import { IUser } from '../../models/store/User.js';
|
|
5
5
|
|
|
6
6
|
export class UsersSdk extends SdkBase {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Backend.js","sourceRoot":"","sources":["../../../src/models/Backend.ts"],"names":[],"mappings":""}
|