@api-client/core 0.8.22 → 0.9.1

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 (207) hide show
  1. package/build/browser.d.ts +12 -5
  2. package/build/browser.js +2 -3
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +12 -5
  5. package/build/index.js +2 -4
  6. package/build/index.js.map +1 -1
  7. package/build/src/events/BaseEvents.d.ts +137 -18
  8. package/build/src/events/BaseEvents.js.map +1 -1
  9. package/build/src/events/EventTypes.d.ts +0 -14
  10. package/build/src/events/EventTypes.js +0 -2
  11. package/build/src/events/EventTypes.js.map +1 -1
  12. package/build/src/events/Events.d.ts +1 -5
  13. package/build/src/events/Events.js +0 -2
  14. package/build/src/events/Events.js.map +1 -1
  15. package/build/src/events/transport/TransportEventTypes.d.ts +0 -1
  16. package/build/src/events/transport/TransportEventTypes.js +0 -1
  17. package/build/src/events/transport/TransportEventTypes.js.map +1 -1
  18. package/build/src/events/transport/TransportEvents.d.ts +0 -8
  19. package/build/src/events/transport/TransportEvents.js +0 -11
  20. package/build/src/events/transport/TransportEvents.js.map +1 -1
  21. package/build/src/mocking/ProjectMock.d.ts +0 -3
  22. package/build/src/mocking/ProjectMock.js +0 -3
  23. package/build/src/mocking/ProjectMock.js.map +1 -1
  24. package/build/src/mocking/lib/History.js +5 -0
  25. package/build/src/mocking/lib/History.js.map +1 -1
  26. package/build/src/models/{Workspace.d.ts → Folder.d.ts} +7 -7
  27. package/build/src/models/{Workspace.js → Folder.js} +5 -5
  28. package/build/src/models/Folder.js.map +1 -0
  29. package/build/src/models/HttpHistory.d.ts +38 -43
  30. package/build/src/models/HttpHistory.js +27 -34
  31. package/build/src/models/HttpHistory.js.map +1 -1
  32. package/build/src/models/HttpProject.d.ts +0 -2
  33. package/build/src/models/HttpProject.js +0 -27
  34. package/build/src/models/HttpProject.js.map +1 -1
  35. package/build/src/models/Project.d.ts +0 -8
  36. package/build/src/models/Project.js +0 -4
  37. package/build/src/models/Project.js.map +1 -1
  38. package/build/src/models/ProjectFolder.d.ts +0 -2
  39. package/build/src/models/ProjectFolder.js +0 -14
  40. package/build/src/models/ProjectFolder.js.map +1 -1
  41. package/build/src/models/ProjectItem.d.ts +0 -2
  42. package/build/src/models/ProjectItem.js +0 -20
  43. package/build/src/models/ProjectItem.js.map +1 -1
  44. package/build/src/models/ProjectRequest.d.ts +2 -3
  45. package/build/src/models/ProjectRequest.js.map +1 -1
  46. package/build/src/models/RequestConfig.d.ts +1 -1
  47. package/build/src/models/Space.d.ts +25 -0
  48. package/build/src/models/Space.js +76 -0
  49. package/build/src/models/Space.js.map +1 -0
  50. package/build/src/models/TrashEntry.d.ts +27 -0
  51. package/build/src/models/TrashEntry.js +2 -0
  52. package/build/src/models/TrashEntry.js.map +1 -0
  53. package/build/src/models/store/Backend.d.ts +0 -315
  54. package/build/src/models/store/Backend.js +0 -1
  55. package/build/src/models/store/Backend.js.map +1 -1
  56. package/build/src/models/store/File.d.ts +31 -1
  57. package/build/src/models/store/File.js +6 -6
  58. package/build/src/models/store/File.js.map +1 -1
  59. package/build/src/proxy/HttpProjectProxy.d.ts +4 -0
  60. package/build/src/proxy/HttpProjectProxy.js +10 -2
  61. package/build/src/proxy/HttpProjectProxy.js.map +1 -1
  62. package/build/src/proxy/ProxyService.d.ts +0 -10
  63. package/build/src/proxy/ProxyService.js +0 -14
  64. package/build/src/proxy/ProxyService.js.map +1 -1
  65. package/build/src/runtime/node/InteropInterfaces.d.ts +1 -2
  66. package/build/src/runtime/node/ProjectParallelRunner.d.ts +2 -3
  67. package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
  68. package/build/src/runtime/node/ProjectRequestRunner.d.ts +7 -8
  69. package/build/src/runtime/node/ProjectRequestRunner.js +2 -3
  70. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  71. package/build/src/runtime/node/ProjectRunner.d.ts +3 -4
  72. package/build/src/runtime/node/ProjectRunner.js.map +1 -1
  73. package/build/src/runtime/node/ProjectRunnerWorker.js +0 -4
  74. package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -1
  75. package/build/src/runtime/store/CertificatesSdk.d.ts +46 -0
  76. package/build/src/runtime/store/CertificatesSdk.js +227 -0
  77. package/build/src/runtime/store/CertificatesSdk.js.map +1 -0
  78. package/build/src/runtime/store/FilesSdk.d.ts +21 -16
  79. package/build/src/runtime/store/FilesSdk.js +75 -23
  80. package/build/src/runtime/store/FilesSdk.js.map +1 -1
  81. package/build/src/runtime/store/HistorySdk.d.ts +11 -8
  82. package/build/src/runtime/store/HistorySdk.js +140 -17
  83. package/build/src/runtime/store/HistorySdk.js.map +1 -1
  84. package/build/src/runtime/store/RevisionsSdk.d.ts +12 -0
  85. package/build/src/runtime/store/RevisionsSdk.js +43 -0
  86. package/build/src/runtime/store/RevisionsSdk.js.map +1 -0
  87. package/build/src/runtime/store/RouteBuilder.d.ts +16 -18
  88. package/build/src/runtime/store/RouteBuilder.js +33 -60
  89. package/build/src/runtime/store/RouteBuilder.js.map +1 -1
  90. package/build/src/runtime/store/Sdk.d.ts +10 -7
  91. package/build/src/runtime/store/Sdk.js +12 -5
  92. package/build/src/runtime/store/Sdk.js.map +1 -1
  93. package/build/src/runtime/store/SdkBase.js.map +1 -1
  94. package/build/src/runtime/store/SharedSdk.d.ts +2 -2
  95. package/build/src/runtime/store/SharedSdk.js.map +1 -1
  96. package/build/src/runtime/store/SpacesSdk.d.ts +29 -0
  97. package/build/src/runtime/store/SpacesSdk.js +135 -0
  98. package/build/src/runtime/store/SpacesSdk.js.map +1 -0
  99. package/build/src/runtime/store/TrashSdk.d.ts +35 -0
  100. package/build/src/runtime/store/TrashSdk.js +155 -0
  101. package/build/src/runtime/store/TrashSdk.js.map +1 -0
  102. package/build/src/runtime/store/UsersSdk.d.ts +2 -2
  103. package/build/src/runtime/store/UsersSdk.js.map +1 -1
  104. package/build/src/runtime/store/interfaces/ApiClientStore.d.ts +30 -0
  105. package/build/src/runtime/store/interfaces/ApiClientStore.js +2 -0
  106. package/build/src/runtime/store/interfaces/ApiClientStore.js.map +1 -0
  107. package/build/src/runtime/store/interfaces/Certificates.d.ts +49 -0
  108. package/build/src/runtime/store/interfaces/Certificates.js +2 -0
  109. package/build/src/runtime/store/interfaces/Certificates.js.map +1 -0
  110. package/build/src/runtime/store/interfaces/Files.d.ts +63 -0
  111. package/build/src/runtime/store/interfaces/Files.js +2 -0
  112. package/build/src/runtime/store/interfaces/Files.js.map +1 -0
  113. package/build/src/runtime/store/interfaces/History.d.ts +63 -0
  114. package/build/src/runtime/store/interfaces/History.js +2 -0
  115. package/build/src/runtime/store/interfaces/History.js.map +1 -0
  116. package/build/src/runtime/store/interfaces/Media.d.ts +42 -0
  117. package/build/src/runtime/store/interfaces/Media.js +2 -0
  118. package/build/src/runtime/store/interfaces/Media.js.map +1 -0
  119. package/build/src/runtime/store/interfaces/Revisions.d.ts +25 -0
  120. package/build/src/runtime/store/interfaces/Revisions.js +2 -0
  121. package/build/src/runtime/store/interfaces/Revisions.js.map +1 -0
  122. package/build/src/runtime/store/interfaces/Spaces.d.ts +42 -0
  123. package/build/src/runtime/store/interfaces/Spaces.js +2 -0
  124. package/build/src/runtime/store/interfaces/Spaces.js.map +1 -0
  125. package/build/src/runtime/store/interfaces/Trash.d.ts +38 -0
  126. package/build/src/runtime/store/interfaces/Trash.js +2 -0
  127. package/build/src/runtime/store/interfaces/Trash.js.map +1 -0
  128. package/package.json +1 -1
  129. package/src/events/BaseEvents.ts +148 -18
  130. package/src/events/EventTypes.ts +0 -2
  131. package/src/events/Events.ts +0 -2
  132. package/src/events/transport/TransportEventTypes.ts +0 -1
  133. package/src/events/transport/TransportEvents.ts +0 -13
  134. package/src/mocking/ProjectMock.ts +0 -4
  135. package/src/mocking/lib/History.ts +5 -0
  136. package/src/models/{Workspace.ts → Folder.ts} +12 -12
  137. package/src/models/HttpHistory.ts +53 -63
  138. package/src/models/HttpProject.ts +0 -29
  139. package/src/models/Project.ts +0 -8
  140. package/src/models/ProjectFolder.ts +0 -16
  141. package/src/models/ProjectItem.ts +0 -18
  142. package/src/models/ProjectRequest.ts +3 -4
  143. package/src/models/RequestConfig.ts +1 -1
  144. package/src/models/Space.ts +91 -0
  145. package/src/models/TrashEntry.ts +29 -0
  146. package/src/models/store/Backend.ts +0 -342
  147. package/src/models/store/File.ts +39 -6
  148. package/src/proxy/HttpProjectProxy.ts +14 -2
  149. package/src/proxy/ProxyService.ts +0 -15
  150. package/src/proxy/readme.md +0 -1
  151. package/src/runtime/node/InteropInterfaces.ts +1 -2
  152. package/src/runtime/node/ProjectParallelRunner.ts +2 -3
  153. package/src/runtime/node/ProjectRequestRunner.ts +13 -14
  154. package/src/runtime/node/ProjectRunner.ts +3 -4
  155. package/src/runtime/node/ProjectRunnerWorker.ts +1 -4
  156. package/src/runtime/store/CertificatesSdk.ts +231 -0
  157. package/src/runtime/store/FilesSdk.ts +88 -35
  158. package/src/runtime/store/HistorySdk.ts +145 -33
  159. package/src/runtime/store/RevisionsSdk.ts +44 -0
  160. package/src/runtime/store/RouteBuilder.ts +37 -69
  161. package/src/runtime/store/Sdk.ts +17 -7
  162. package/src/runtime/store/SdkBase.ts +1 -1
  163. package/src/runtime/store/SharedSdk.ts +3 -3
  164. package/src/runtime/store/SpacesSdk.ts +136 -0
  165. package/src/runtime/store/TrashSdk.ts +159 -0
  166. package/src/runtime/store/UsersSdk.ts +3 -3
  167. package/src/runtime/store/interfaces/ApiClientStore.ts +39 -0
  168. package/src/runtime/store/interfaces/Certificates.ts +56 -0
  169. package/src/runtime/store/interfaces/Files.ts +70 -0
  170. package/src/runtime/store/interfaces/History.ts +64 -0
  171. package/src/runtime/store/interfaces/Media.ts +46 -0
  172. package/src/runtime/store/interfaces/Revisions.ts +27 -0
  173. package/src/runtime/store/interfaces/Spaces.ts +48 -0
  174. package/src/runtime/store/interfaces/Trash.ts +42 -0
  175. package/build/src/events/models/ClientCertificateEvents.d.ts +0 -54
  176. package/build/src/events/models/ClientCertificateEvents.js +0 -78
  177. package/build/src/events/models/ClientCertificateEvents.js.map +0 -1
  178. package/build/src/events/models/ModelEventTypes.d.ts +0 -13
  179. package/build/src/events/models/ModelEventTypes.js +0 -14
  180. package/build/src/events/models/ModelEventTypes.js.map +0 -1
  181. package/build/src/events/models/ModelEvents.d.ts +0 -4
  182. package/build/src/events/models/ModelEvents.js +0 -5
  183. package/build/src/events/models/ModelEvents.js.map +0 -1
  184. package/build/src/mocking/lib/App.d.ts +0 -36
  185. package/build/src/mocking/lib/App.js +0 -70
  186. package/build/src/mocking/lib/App.js.map +0 -1
  187. package/build/src/models/AppProject.d.ts +0 -817
  188. package/build/src/models/AppProject.js +0 -1721
  189. package/build/src/models/AppProject.js.map +0 -1
  190. package/build/src/models/AppRequest.d.ts +0 -69
  191. package/build/src/models/AppRequest.js +0 -150
  192. package/build/src/models/AppRequest.js.map +0 -1
  193. package/build/src/models/Workspace.js.map +0 -1
  194. package/build/src/proxy/AppProjectProxy.d.ts +0 -28
  195. package/build/src/proxy/AppProjectProxy.js +0 -107
  196. package/build/src/proxy/AppProjectProxy.js.map +0 -1
  197. package/build/src/runtime/store/AppSdk.d.ts +0 -213
  198. package/build/src/runtime/store/AppSdk.js +0 -836
  199. package/build/src/runtime/store/AppSdk.js.map +0 -1
  200. package/src/events/models/ClientCertificateEvents.ts +0 -85
  201. package/src/events/models/ModelEventTypes.ts +0 -13
  202. package/src/events/models/ModelEvents.ts +0 -5
  203. package/src/mocking/lib/App.ts +0 -101
  204. package/src/models/AppProject.ts +0 -2188
  205. package/src/models/AppRequest.ts +0 -176
  206. package/src/proxy/AppProjectProxy.ts +0 -126
  207. package/src/runtime/store/AppSdk.ts +0 -842
@@ -6,10 +6,43 @@ import { IThing, Thing } from '../Thing.js';
6
6
  import v4 from '../../lib/uuid.js';
7
7
  import { ICapabilities } from './Capabilities.js';
8
8
  // this causes error
9
- // import { Kind as WorkspaceKind } from '../Workspace.js';
9
+ // import { Kind as FolderKind } from '../Folder.js';
10
10
 
11
11
  export const DefaultOwner = 'default';
12
12
 
13
+ export interface FileAddOptions {
14
+ /**
15
+ * The parent folder where to put the file.
16
+ * The `parents` array is always cleared from the file object before adding it to the store.
17
+ */
18
+ parent?: string;
19
+ }
20
+
21
+ export interface MediaReadOptions {
22
+ /**
23
+ * When set it reads the file that was marked as `_deleted`. By default it throws when file was deleted.
24
+ */
25
+ deleted?: boolean;
26
+ }
27
+
28
+ /**
29
+ * A breadcrumb when creating the breadcrumb list for a file.
30
+ */
31
+ export interface FileBreadcrumb {
32
+ /**
33
+ * The datastore key of the object.
34
+ */
35
+ key: string;
36
+ /**
37
+ * THe kind of the object.
38
+ */
39
+ kind: string;
40
+ /**
41
+ * The name of the object.
42
+ */
43
+ name: string;
44
+ }
45
+
13
46
  export interface IStoredFile {
14
47
  /**
15
48
  * The kind of the File
@@ -160,7 +193,7 @@ export class StoredFile {
160
193
  [ownerSymbol]: string = DefaultOwner;
161
194
 
162
195
  /**
163
- * The owner of this space. The id of the User object.
196
+ * The owner of this file. This is the id of the User object.
164
197
  * Set to `default` when there are no users in the system (no authentication).
165
198
  */
166
199
  get owner(): string {
@@ -354,15 +387,15 @@ export class StoredFile {
354
387
  canUntrash: isOwner,
355
388
  canReadMedia: false,
356
389
  };
357
- // Do not use the `WorkspaceKind` reference here as it's circular and creates
390
+ // Do not use the `FolderKind` reference here as it's circular and creates
358
391
  // an error.
359
- if (file.kind === 'Core#Space' && isWriter) {
392
+ if (file.kind === 'Core#Folder' && isWriter) {
360
393
  result.canAddChildren = true;
361
394
  }
362
- if (file.kind === 'Core#Space') {
395
+ if (file.kind === 'Core#Folder') {
363
396
  result.canListChildren = isReader;
364
397
  }
365
- if (file.kind !== 'Core#Space') {
398
+ if (file.kind !== 'Core#Folder') {
366
399
  result.canReadMedia = isReader;
367
400
  }
368
401
  return result;
@@ -25,6 +25,10 @@ export interface IHttpProjectStoreProxyInit extends ProxyInit {
25
25
  * Project key
26
26
  */
27
27
  pid: string;
28
+ /**
29
+ * The parent space key.
30
+ */
31
+ space: string;
28
32
  }
29
33
 
30
34
  /**
@@ -35,7 +39,7 @@ export default class HttpProjectProxy extends Proxy {
35
39
  options?: IProjectRunnerOptions;
36
40
 
37
41
  protected async configureStore(init: IHttpProjectStoreProxyInit, token: string, baseUri: string): Promise<void> {
38
- const { pid, options } = init;
42
+ const { pid, options, space } = init;
39
43
  if (!pid) {
40
44
  throw new ApiError({
41
45
  error: true,
@@ -44,6 +48,14 @@ export default class HttpProjectProxy extends Proxy {
44
48
  code: 400,
45
49
  });
46
50
  }
51
+ if (!space) {
52
+ throw new ApiError({
53
+ error: true,
54
+ message: 'Invalid request',
55
+ detail: 'The "space" parameter is required.',
56
+ code: 400,
57
+ });
58
+ }
47
59
  if (!options) {
48
60
  throw new ApiError({
49
61
  error: true,
@@ -80,7 +92,7 @@ export default class HttpProjectProxy extends Proxy {
80
92
  sdk.token = token;
81
93
  let project: IHttpProject;
82
94
  try {
83
- project = await sdk.file.read(pid, true) as IHttpProject;
95
+ project = await sdk.file.read(space, pid, true) as IHttpProject;
84
96
  } catch (cause) {
85
97
  const e = cause as Error;
86
98
  throw new ApiError(e.message, 400);
@@ -1,6 +1,5 @@
1
1
  import { IProjectExecutionLog } from "../runtime/reporters/Reporter.js";
2
2
  import { IRequestLog } from "../models/RequestLog.js";
3
- import AppProjectProxy, { IAppProjectProxyInit } from "./AppProjectProxy.js";
4
3
  import HttpProjectProxy, { IHttpProjectProxyInit, IHttpProjectStoreProxyInit } from "./HttpProjectProxy.js";
5
4
  import { IProxyResult } from "./Proxy.js";
6
5
  import RequestProxy, { IRequestProxyInit } from "./RequestProxy.js";
@@ -31,18 +30,4 @@ export default class ProxyService {
31
30
  await proxy.configure(init, token, storeUri);
32
31
  return proxy.execute();
33
32
  }
34
-
35
- /**
36
- * Executes an AppProject.
37
- *
38
- * @param token The user access token to read data from the store.
39
- * @param storeUri The store's base URI.
40
- * @param init The project run configuration.
41
- * @returns The key under which the proxy is cached.
42
- */
43
- async proxyAppProject(token: string, storeUri: string, init: IAppProjectProxyInit): Promise<IProxyResult<IProjectExecutionLog>> {
44
- const proxy = new AppProjectProxy();
45
- await proxy.configure(init, token, storeUri);
46
- return proxy.execute() as Promise<IProxyResult<IProjectExecutionLog>>;
47
- }
48
33
  }
@@ -4,6 +4,5 @@ The libraries to create an HTTP/Socket proxy for API things (projects, requests)
4
4
 
5
5
  ## Libraries
6
6
 
7
- - `AppProjectProxy` - a class that runs request from an `AppProject`
8
7
  - `HttpProjectProxy` - a class that runs request from an `HttpProject`
9
8
  - `RequestProxy` - a class that runs a single request as `HttpRequest`
@@ -4,7 +4,6 @@ import { Environment } from '../../models/Environment.js';
4
4
  import { Logger } from '../../lib/logging/Logger.js';
5
5
  import { IRequestLog } from '../../models/RequestLog.js';
6
6
  import { CookieJar } from '../../cookies/CookieJar.js';
7
- import { IAppProject } from 'browser.js';
8
7
 
9
8
  export interface IRequestRunnerOptions {
10
9
  /**
@@ -72,7 +71,7 @@ export interface IProjectParallelRunnerOptions extends IProjectRunnerOptions {
72
71
  }
73
72
 
74
73
  export interface IProjectParallelWorkerOptions extends IProjectRunnerOptions {
75
- project: IHttpProject | IAppProject;
74
+ project: IHttpProject;
76
75
  }
77
76
 
78
77
  export interface IProjectRunnerOptions {
@@ -3,7 +3,6 @@ import { cpus } from 'os';
3
3
  import { dirname, join } from 'path';
4
4
  import { fileURLToPath } from 'url';
5
5
  import { HttpProject } from '../../models/HttpProject.js';
6
- import { AppProject } from '../../models/AppProject.js';
7
6
  import { IProjectExecutionLog, IProjectExecutionIteration } from '../reporters/Reporter.js';
8
7
  import { BaseRunner } from './BaseRunner.js';
9
8
  import { State } from './enums.js';
@@ -67,13 +66,13 @@ export interface ProjectParallelRunner {
67
66
  * change. This event can be user to refresh the UI to reflect the newest state.
68
67
  */
69
68
  export class ProjectParallelRunner extends BaseRunner {
70
- project: HttpProject | AppProject;
69
+ project: HttpProject;
71
70
  options: IProjectParallelRunnerOptions;
72
71
  workers: WorkerInfoInternal[] = [];
73
72
  private mainResolver?: (report: IProjectExecutionLog) => void;
74
73
  private mainRejecter?: (err: Error) => void;
75
74
 
76
- constructor(project: HttpProject | AppProject, opts: IProjectParallelRunnerOptions = {}) {
75
+ constructor(project: HttpProject, opts: IProjectParallelRunnerOptions = {}) {
77
76
  super();
78
77
  this.project = project;
79
78
  this.options = opts;
@@ -14,7 +14,6 @@ import { IProjectExecutionResult, IRequestRunnerOptions, IRequestRunnerRunOption
14
14
  import { State } from './enums.js';
15
15
  import { HttpRequestRunner } from '../http-runner/HttpRequestRunner.js';
16
16
  import { CookieJar } from '../../cookies/CookieJar.js';
17
- import { AppProject, AppProjectFolder, AppProjectFolderKind, AppProjectItem, AppProjectRequest, AppProjectRequestKind } from '../../models/AppProject.js';
18
17
  import { ProjectItem } from '../../models/ProjectItem.js';
19
18
 
20
19
  export interface ProjectRequestRunner {
@@ -53,7 +52,7 @@ export interface ProjectRequestRunner {
53
52
  */
54
53
  export class ProjectRequestRunner extends EventEmitter {
55
54
  logger?: Logger;
56
- project: HttpProject | AppProject;
55
+ project: HttpProject;
57
56
  /**
58
57
  * An instance of a cookie jar (store) to put/read cookies.
59
58
  */
@@ -73,7 +72,7 @@ export class ProjectRequestRunner extends EventEmitter {
73
72
  return this._state;
74
73
  }
75
74
 
76
- constructor(project: HttpProject | AppProject, opts: IRequestRunnerOptions = {}) {
75
+ constructor(project: HttpProject, opts: IRequestRunnerOptions = {}) {
77
76
  super();
78
77
  this.project = project;
79
78
  this.logger = opts.logger;
@@ -126,32 +125,32 @@ export class ProjectRequestRunner extends EventEmitter {
126
125
  }
127
126
  }
128
127
 
129
- protected async * _runIterator(items: (ProjectItem | AppProjectItem)[], variables: Record<string, string>, options: IRequestRunnerRunOptions): AsyncGenerator<IRunResult> {
128
+ protected async * _runIterator(items: ProjectItem[], variables: Record<string, string>, options: IRequestRunnerRunOptions): AsyncGenerator<IRunResult> {
130
129
  for (const item of items) {
131
130
  const current = item.getItem();
132
131
  if (!current) {
133
132
  continue;
134
133
  }
135
- if (current.kind === AppProjectRequestKind || current.kind === ProjectRequestKind) {
134
+ if (current.kind === ProjectRequestKind) {
136
135
  if (Array.isArray(options.ignore) && options.ignore.includes(current.key)) {
137
136
  continue;
138
137
  }
139
138
  if (Array.isArray(options.requests) && !options.requests.includes(current.key) && !options.requests.includes(current.info.name || '')) {
140
139
  continue;
141
140
  }
142
- const info = await this._runItem(current as AppProjectRequest | ProjectRequest, variables);
141
+ const info = await this._runItem(current as ProjectRequest, variables);
143
142
  yield info;
144
- } else if (current.kind === ProjectFolderKind || current.kind === AppProjectFolderKind) {
143
+ } else if (current.kind === ProjectFolderKind) {
145
144
  if (!options.recursive) {
146
145
  continue;
147
146
  }
148
- const parent = current as ProjectFolder | AppProjectFolder;
147
+ const parent = current as ProjectFolder;
149
148
  // make a copy so the variables executed in the encapsulated environment won't leak out to the current environment.
150
149
  let encapsulated = false;
151
150
  // we restore the `baseUri` after exiting the folder.
152
151
  const currentBaseUri = variables.baseUri;
153
152
  const { items: parentItems } = parent;
154
- const envItem = (parentItems as (ProjectItem | AppProjectItem)[]).find(i => i.kind === EnvironmentKind);
153
+ const envItem = (parentItems as ProjectItem[]).find(i => i.kind === EnvironmentKind);
155
154
  let parentVariables: Record<string, string> = {};
156
155
  let childVariables = variables;
157
156
  if (envItem) {
@@ -214,7 +213,7 @@ export class ProjectRequestRunner extends EventEmitter {
214
213
  }
215
214
  }
216
215
 
217
- private async _runItem(request: ProjectRequest | AppProjectRequest, variables: Record<string, string>): Promise<IRunResult> {
216
+ private async _runItem(request: ProjectRequest, variables: Record<string, string>): Promise<IRunResult> {
218
217
  if (this._state === State.Aborted) {
219
218
  throw new Error(`The execution has been aborted.`);
220
219
  }
@@ -226,7 +225,7 @@ export class ProjectRequestRunner extends EventEmitter {
226
225
  return info;
227
226
  }
228
227
 
229
- protected async execute(request: ProjectRequest | AppProjectRequest, variables: Record<string, string>): Promise<IRunResult> {
228
+ protected async execute(request: ProjectRequest, variables: Record<string, string>): Promise<IRunResult> {
230
229
  const config = request.getConfig();
231
230
  const factory = new HttpRequestRunner();
232
231
  factory.variables = variables;
@@ -285,14 +284,14 @@ export class ProjectRequestRunner extends EventEmitter {
285
284
  return info;
286
285
  }
287
286
 
288
- protected async getVariables(parent: HttpProject | AppProject | ProjectFolder | AppProjectFolder): Promise<Record<string, string>> {
287
+ protected async getVariables(parent: HttpProject | ProjectFolder): Promise<Record<string, string>> {
289
288
  if (this.masterEnvironment) {
290
289
  return this.applyVariables([this.masterEnvironment]);
291
290
  }
292
291
  return this.createEnvironment(parent);
293
292
  }
294
293
 
295
- protected async createEnvironment(parent: HttpProject | AppProject | ProjectFolder | AppProjectFolder): Promise<Record<string, string>> {
294
+ protected async createEnvironment(parent: HttpProject | ProjectFolder): Promise<Record<string, string>> {
296
295
  const envs = await this.readEnvironments(parent);
297
296
  return this.applyVariables(envs);
298
297
  }
@@ -300,7 +299,7 @@ export class ProjectRequestRunner extends EventEmitter {
300
299
  /**
301
300
  * Reads the list of the environments to apply to this runtime.
302
301
  */
303
- protected async readEnvironments(parent: HttpProject | AppProject | ProjectFolder | AppProjectFolder): Promise<Environment[]> {
302
+ protected async readEnvironments(parent: HttpProject | ProjectFolder): Promise<Environment[]> {
304
303
  const folderKey = parent.kind === ProjectFolderKind ? (parent as ProjectFolder).key : undefined;
305
304
  return this.project.readEnvironments({ parent: folderKey });
306
305
  }
@@ -11,9 +11,8 @@ import { pathExists, readJson } from '../../lib/fs/Fs.js';
11
11
  import { BaseRunner } from './BaseRunner.js';
12
12
  import { IProjectRunnerOptions, IRequestRunnerOptions } from './InteropInterfaces.js';
13
13
  import { State } from './enums.js';
14
- import { AppProject, AppProjectFolder } from '../../models/AppProject.js';
15
14
 
16
- type ProjectParent = HttpProject | ProjectFolder | AppProject | AppProjectFolder;
15
+ type ProjectParent = HttpProject | ProjectFolder;
17
16
 
18
17
  export interface ProjectRunner {
19
18
  /**
@@ -90,7 +89,7 @@ export abstract class ProjectRunner extends BaseRunner {
90
89
  /**
91
90
  * The HTTP project to run requests from.
92
91
  */
93
- project?: HttpProject | AppProject;
92
+ project?: HttpProject;
94
93
  /**
95
94
  * The execution options for the project.
96
95
  */
@@ -173,7 +172,7 @@ export abstract class ProjectRunner extends BaseRunner {
173
172
  * A required step before running the project.
174
173
  * It configures the execution context. It may throw an error when configuration is not valid.
175
174
  */
176
- async configure(project: HttpProject | AppProject, opts: IProjectRunnerOptions = {}): Promise<void> {
175
+ async configure(project: HttpProject, opts: IProjectRunnerOptions = {}): Promise<void> {
177
176
  this.project = project;
178
177
  this.options = opts || {};
179
178
  if (typeof this.options.iterations === 'number' && this.options.iterations >= 0) {
@@ -3,7 +3,6 @@
3
3
  import process from 'process';
4
4
  import cluster from 'cluster';
5
5
  import { HttpProject, Kind as HttpProjectKind } from '../../models/HttpProject.js';
6
- import { AppProject, AppProjectKind } from '../../models/AppProject.js';
7
6
  import { IProjectExecutionLog } from '../reporters/Reporter.js';
8
7
  import { IWorkerMessage } from './ProjectParallelRunner.js';
9
8
  import { IProjectParallelWorkerOptions } from './InteropInterfaces.js';
@@ -33,11 +32,9 @@ class ProjectExeWorker extends ProjectRunner {
33
32
  options.cookies = new InMemoryCookieJar();
34
33
  try {
35
34
  const schema = options.project;
36
- let project: HttpProject | AppProject;
35
+ let project: HttpProject;
37
36
  if (schema.kind === HttpProjectKind) {
38
37
  project = new HttpProject(schema);
39
- } else if (schema.kind === AppProjectKind) {
40
- project = new AppProject(schema);
41
38
  } else {
42
39
  throw new Error(`Unknown project kind: ${schema.kind}`);
43
40
  }
@@ -0,0 +1,231 @@
1
+ import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, ISdkRequestOptions } from './SdkBase.js';
2
+ import { RouteBuilder } from './RouteBuilder.js';
3
+ import { ContextChangeRecord, ContextDeleteRecord, ContextListResult, ContextSpaceListOptions, IBulkOperationResult } from '../../events/BaseEvents.js';
4
+ import { HttpCertificate } from '../../models/ClientCertificate.js';
5
+ import { SdkError } from './Errors.js';
6
+
7
+ export class CertificatesSdk extends SdkBase {
8
+ /**
9
+ * Inserts a certificate to the store
10
+ *
11
+ * @param value The value to insert.
12
+ * @param space The parent space of the certificate.
13
+ */
14
+ async add(value: HttpCertificate, space: string, request: ISdkRequestOptions = {}): Promise<ContextChangeRecord<HttpCertificate>> {
15
+ const token = request.token || this.sdk.token;
16
+ const url = this.sdk.getUrl(RouteBuilder.certificates());
17
+ url.searchParams.set('space', space);
18
+ const body = JSON.stringify(value);
19
+ const result = await this.sdk.http.post(url.toString(), { token, body });
20
+ this.inspectCommonStatusCodes(result.status);
21
+ const E_PREFIX = 'Unable to create a certificate. ';
22
+ if (result.status !== 200) {
23
+ this.logInvalidResponse(result);
24
+ let e = this.createGenericSdkError(result.body)
25
+ if (!e) {
26
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
27
+ e.response = result.body;
28
+ }
29
+ throw e;
30
+ }
31
+ if (!result.body) {
32
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
33
+ }
34
+ let data: ContextChangeRecord<HttpCertificate>;
35
+ try {
36
+ data = JSON.parse(result.body);
37
+ } catch (e) {
38
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
39
+ }
40
+ if (!data.key) {
41
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
42
+ }
43
+ return data;
44
+ }
45
+
46
+ /**
47
+ * Adds certificates in a bulk operation.
48
+ * @param value The lits of certificates to add.
49
+ * @param space The parent workspace
50
+ * @returns The list of inserted certificates. `undefined` when there was an error inserting a certificate.
51
+ */
52
+ async addBulk(values: HttpCertificate[], space: string, request: ISdkRequestOptions = {}): Promise<IBulkOperationResult<ContextChangeRecord<HttpCertificate>>> {
53
+ const token = request.token || this.sdk.token;
54
+ const url = this.sdk.getUrl(RouteBuilder.certificateBatchCreate());
55
+ url.searchParams.set('space', space);
56
+ const body = JSON.stringify(values);
57
+ const result = await this.sdk.http.post(url.toString(), { token, body });
58
+ this.inspectCommonStatusCodes(result.status);
59
+ const E_PREFIX = 'Unable to create a bulk certificates. ';
60
+ if (result.status !== 200) {
61
+ this.logInvalidResponse(result);
62
+ let e = this.createGenericSdkError(result.body)
63
+ if (!e) {
64
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
65
+ e.response = result.body;
66
+ }
67
+ throw e;
68
+ }
69
+ if (!result.body) {
70
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
71
+ }
72
+ let data: IBulkOperationResult<ContextChangeRecord<HttpCertificate>>;
73
+ try {
74
+ data = JSON.parse(result.body).items;
75
+ } catch (e) {
76
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
77
+ }
78
+ if (!data.items) {
79
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
80
+ }
81
+ return data;
82
+ }
83
+
84
+ /**
85
+ * @param key The key of the certificate to read.
86
+ */
87
+ async read(key: string, request: ISdkRequestOptions = {}): Promise<HttpCertificate> {
88
+ const token = request.token || this.sdk.token;
89
+ const url = this.sdk.getUrl(RouteBuilder.certificate(key));
90
+ const result = await this.sdk.http.get(url.toString(), { token });
91
+ this.inspectCommonStatusCodes(result.status);
92
+ const E_PREFIX = 'Unable to read a certificate. ';
93
+ if (result.status !== 200) {
94
+ this.logInvalidResponse(result);
95
+ let e = this.createGenericSdkError(result.body)
96
+ if (!e) {
97
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
98
+ e.response = result.body;
99
+ }
100
+ throw e;
101
+ }
102
+ if (!result.body) {
103
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
104
+ }
105
+ let data: HttpCertificate;
106
+ try {
107
+ data = JSON.parse(result.body);
108
+ } catch (e) {
109
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
110
+ }
111
+ if (!data.kind) {
112
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
113
+ }
114
+ return data;
115
+ }
116
+
117
+ /**
118
+ * Lists certificate entires.
119
+ *
120
+ * @param space The parent space of the certificate.
121
+ * @param options The list query options.
122
+ */
123
+ async list(options?: ContextSpaceListOptions, request: ISdkRequestOptions = {}): Promise<ContextListResult<HttpCertificate>> {
124
+ const token = request.token || this.sdk.token;
125
+ const url = this.sdk.getUrl(RouteBuilder.certificates());
126
+ this.sdk.appendListOptions(url, options);
127
+ const result = await this.sdk.http.get(url.toString(), { token });
128
+ this.inspectCommonStatusCodes(result.status);
129
+ const E_PREFIX = 'Unable to list certificates. ';
130
+ if (result.status !== 200) {
131
+ this.logInvalidResponse(result);
132
+ let e = this.createGenericSdkError(result.body)
133
+ if (!e) {
134
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
135
+ e.response = result.body;
136
+ }
137
+ throw e;
138
+ }
139
+ if (!result.body) {
140
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
141
+ }
142
+ let data: ContextListResult<HttpCertificate>;
143
+ try {
144
+ data = JSON.parse(result.body);
145
+ } catch (e) {
146
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
147
+ }
148
+ if (!Array.isArray(data.items)) {
149
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
150
+ }
151
+ return data;
152
+ }
153
+
154
+ /**
155
+ * Marks the certificate as deleted.
156
+ *
157
+ * @param key The key of the certificate to delete.
158
+ */
159
+ async delete(key: string, request: ISdkRequestOptions = {}): Promise<void> {
160
+ const token = request.token || this.sdk.token;
161
+ const url = this.sdk.getUrl(RouteBuilder.certificate(key));
162
+ const result = await this.sdk.http.delete(url.toString(), { token });
163
+ this.inspectCommonStatusCodes(result.status, result.body);
164
+ const E_PREFIX = 'Unable to delete the certificate. ';
165
+ if (result.status !== 204) {
166
+ this.logInvalidResponse(result);
167
+ let e = this.createGenericSdkError(result.body)
168
+ if (!e) {
169
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
170
+ e.response = result.body;
171
+ }
172
+ throw e;
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Removed certificates in a bulk operation.
178
+ * @param keys The list of certificate keys to delete.
179
+ */
180
+ async deleteBulk(keys: string[], request: ISdkRequestOptions = {}): Promise<IBulkOperationResult<ContextDeleteRecord>> {
181
+ const token = request.token || this.sdk.token;
182
+ const url = this.sdk.getUrl(RouteBuilder.certificateBatchDelete());
183
+ const result = await this.sdk.http.post(url.toString(), { token, body: JSON.stringify(keys) });
184
+ this.inspectCommonStatusCodes(result.status);
185
+ const E_PREFIX = 'Unable to delete history. ';
186
+ if (result.status !== 200) {
187
+ this.logInvalidResponse(result);
188
+ let e = this.createGenericSdkError(result.body)
189
+ if (!e) {
190
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
191
+ e.response = result.body;
192
+ }
193
+ throw e;
194
+ }
195
+ if (!result.body) {
196
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
197
+ }
198
+
199
+ let data: IBulkOperationResult<ContextDeleteRecord>;
200
+ try {
201
+ data = JSON.parse(result.body);
202
+ } catch (e) {
203
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
204
+ }
205
+ if (!Array.isArray(data.items)) {
206
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
207
+ }
208
+ return data;
209
+ }
210
+
211
+ /**
212
+ * Removes all certificates from the store for the given workspace.
213
+ * @param space The parent workspace key
214
+ */
215
+ async empty(space: string, request: ISdkRequestOptions = {}): Promise<void> {
216
+ const token = request.token || this.sdk.token;
217
+ const url = this.sdk.getUrl(RouteBuilder.certificatesEmpty(space));
218
+ const result = await this.sdk.http.delete(url.toString(), { token });
219
+ this.inspectCommonStatusCodes(result.status, result.body);
220
+ const E_PREFIX = 'Unable to delete the certificate. ';
221
+ if (result.status !== 204) {
222
+ this.logInvalidResponse(result);
223
+ let e = this.createGenericSdkError(result.body)
224
+ if (!e) {
225
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
226
+ e.response = result.body;
227
+ }
228
+ throw e;
229
+ }
230
+ }
231
+ }