@api-client/core 0.5.14 → 0.5.17

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.
Files changed (38) hide show
  1. package/build/src/lib/parsers/UriTemplate.d.ts +13 -0
  2. package/build/src/lib/parsers/UriTemplate.js +24 -3
  3. package/build/src/lib/parsers/UriTemplate.js.map +1 -1
  4. package/build/src/models/HttpProject.d.ts +85 -32
  5. package/build/src/models/HttpProject.js +181 -80
  6. package/build/src/models/HttpProject.js.map +1 -1
  7. package/build/src/models/ProjectFolder.d.ts +43 -6
  8. package/build/src/models/ProjectFolder.js +37 -12
  9. package/build/src/models/ProjectFolder.js.map +1 -1
  10. package/build/src/models/ProjectItem.d.ts +13 -6
  11. package/build/src/models/ProjectItem.js +24 -4
  12. package/build/src/models/ProjectItem.js.map +1 -1
  13. package/build/src/models/ProjectParent.d.ts +1 -42
  14. package/build/src/models/ProjectParent.js +1 -84
  15. package/build/src/models/ProjectParent.js.map +1 -1
  16. package/build/src/models/store/Backend.d.ts +28 -7
  17. package/build/src/models/transformers/PostmanBackupTransformer.js +0 -1
  18. package/build/src/models/transformers/PostmanBackupTransformer.js.map +1 -1
  19. package/build/src/models/transformers/PostmanV21Transformer.js +0 -1
  20. package/build/src/models/transformers/PostmanV21Transformer.js.map +1 -1
  21. package/build/src/models/transformers/PostmanV2Transformer.js +0 -1
  22. package/build/src/models/transformers/PostmanV2Transformer.js.map +1 -1
  23. package/build/src/runtime/node/ProjectRequestRunner.js +1 -1
  24. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  25. package/build/src/runtime/store/FilesSdk.d.ts +2 -3
  26. package/build/src/runtime/store/FilesSdk.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/lib/parsers/UriTemplate.ts +25 -4
  29. package/src/models/HttpProject.ts +236 -99
  30. package/src/models/ProjectFolder.ts +68 -17
  31. package/src/models/ProjectItem.ts +33 -11
  32. package/src/models/ProjectParent.ts +1 -110
  33. package/src/models/store/Backend.ts +30 -7
  34. package/src/models/transformers/PostmanBackupTransformer.ts +0 -1
  35. package/src/models/transformers/PostmanV21Transformer.ts +0 -1
  36. package/src/models/transformers/PostmanV2Transformer.ts +0 -1
  37. package/src/runtime/node/ProjectRequestRunner.ts +1 -1
  38. package/src/runtime/store/FilesSdk.ts +2 -3
@@ -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 defined for this project.
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,6 +1,7 @@
1
1
  /* eslint-disable import/export */
2
2
 
3
3
  import { JsonPatch } from '@api-client/json'
4
+ import { AccessOperation } from './Permission.js';
4
5
 
5
6
  export type BackendMode = 'single-user' | 'multi-user';
6
7
 
@@ -54,9 +55,13 @@ export interface IBackendInfo {
54
55
  */
55
56
  host?: string;
56
57
  /**
57
- * The port number the store operates on.
58
+ * The port number the store operates on, if the store was initialized on a port.
58
59
  */
59
- port: number;
60
+ port?: number;
61
+ /**
62
+ * The socket path, if the server was initialized on a socket.
63
+ */
64
+ socket?: string;
60
65
  }
61
66
  }
62
67
 
@@ -240,11 +245,7 @@ export interface IHistoryAppListOptions extends IListOptions {
240
245
  id: string;
241
246
  }
242
247
 
243
- /**
244
- * An interface describing a schema to be sent to the server
245
- * when making a patch of a file.
246
- */
247
- export interface IPatchInfo {
248
+ export interface IPatchBase {
248
249
  /**
249
250
  * Auto generated by the client sending the PATCH.
250
251
  */
@@ -260,12 +261,34 @@ export interface IPatchInfo {
260
261
  * This can and will be used to handle potential differences between suite applications.
261
262
  */
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 {
263
275
  /**
264
276
  * The patch generated by the client.
265
277
  */
266
278
  patch: JsonPatch;
267
279
  }
268
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
+
269
292
  /**
270
293
  * A schema sent by the store server in a response to the patch request.
271
294
  * It contains an information about the applied patch, the reverse operation associated with it,
@@ -146,7 +146,6 @@ export class PostmanBackupTransformer extends PostmanTransformer {
146
146
  const init: IHttpProject = {
147
147
  kind: ProjectKind,
148
148
  definitions: {},
149
- environments: [],
150
149
  info: {
151
150
  kind: ThingKind,
152
151
  name,
@@ -133,7 +133,6 @@ export class PostmanV21Transformer extends PostmanTransformer {
133
133
  const init: IHttpProject = {
134
134
  kind: ProjectKind,
135
135
  definitions: {},
136
- environments: [],
137
136
  info: {
138
137
  kind: ThingKind,
139
138
  name: info.name || 'Unnamed Postman project',
@@ -130,7 +130,6 @@ export class PostmanV2Transformer extends PostmanTransformer {
130
130
  const init: IHttpProject = {
131
131
  kind: ProjectKind,
132
132
  definitions: {},
133
- environments: [],
134
133
  info: {
135
134
  kind: ThingKind,
136
135
  name: info.name || 'Unnamed Postman project',
@@ -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,8 +1,7 @@
1
1
  import WebSocketNode from 'ws';
2
2
  import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, E_RESPONSE_LOCATION, ISdkRequestOptions } from './SdkBase.js';
3
3
  import { RouteBuilder } from './RouteBuilder.js';
4
- import { IListOptions, IListResponse, IPatchInfo, IPatchRevision } from '../../models/store/Backend.js';
5
- import { AccessOperation } from '../../models/store/Permission.js';
4
+ import { IListOptions, IListResponse, IPatchInfo, IPatchRevision, IAccessPatchInfo } from '../../models/store/Backend.js';
6
5
  import { IUser } from '../../models/store/User.js';
7
6
  import { IFile } from '../../models/store/File.js';
8
7
  import { Kind as ProjectKind } from '../../models/Project.js';
@@ -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: AccessOperation[], request: ISdkRequestOptions = {}): Promise<void> {
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);