epicenter-libs 3.34.2 → 3.35.0
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/CHANGELOG.md +35 -0
- package/README.md +61 -86
- package/dist/browser/epicenter.js +1581 -226
- package/dist/browser/epicenter.js.map +1 -1
- package/dist/cjs/epicenter.js +1503 -141
- package/dist/cjs/epicenter.js.map +1 -1
- package/dist/epicenter.js +1587 -225
- package/dist/epicenter.js.map +1 -1
- package/dist/epicenter.min.js +1 -1
- package/dist/epicenter.min.js.map +1 -1
- package/dist/module/epicenter.js +1497 -142
- package/dist/module/epicenter.js.map +1 -1
- package/dist/types/adapters/docket.d.ts +80 -0
- package/dist/types/adapters/encyclopedia.d.ts +86 -0
- package/dist/types/adapters/file.d.ts +201 -0
- package/dist/types/adapters/git.d.ts +171 -0
- package/dist/types/adapters/index.d.ts +8 -1
- package/dist/types/adapters/pipeline.d.ts +88 -0
- package/dist/types/adapters/powerpoint.d.ts +130 -0
- package/dist/types/adapters/registration.d.ts +270 -0
- package/dist/types/adapters/task.d.ts +99 -37
- package/dist/types/epicenter.d.ts +2 -2
- package/dist/types/types.d.ts +6 -1
- package/dist/types/utils/router.d.ts +1 -0
- package/package.json +12 -7
- package/src/adapters/docket.ts +109 -0
- package/src/adapters/encyclopedia.ts +128 -0
- package/src/adapters/file.ts +332 -0
- package/src/adapters/git.ts +278 -0
- package/src/adapters/index.ts +14 -0
- package/src/adapters/pipeline.ts +145 -0
- package/src/adapters/powerpoint.ts +238 -0
- package/src/adapters/registration.ts +413 -0
- package/src/adapters/task.ts +170 -47
- package/src/epicenter.ts +10 -3
- package/src/globals.d.ts +6 -0
- package/src/types.ts +61 -0
- package/src/utils/router.ts +1 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import type { RoutingOptions } from '../utils/router';
|
|
2
|
+
|
|
3
|
+
import { Router } from '../utils';
|
|
4
|
+
|
|
5
|
+
// ──────────────────────────────────────────────
|
|
6
|
+
// Types
|
|
7
|
+
// ──────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
export type GitAlgorithm = 'rsa' | 'ed25519';
|
|
10
|
+
export type GitKeySpec = 'openssh' | 'pkcs8' | 'x509';
|
|
11
|
+
|
|
12
|
+
export interface GitStatusReadOutView {
|
|
13
|
+
currentBranch?: string | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface GitIntegrationReadOutView {
|
|
17
|
+
privateKeySpec?: GitKeySpec | null;
|
|
18
|
+
publicKey?: string | null;
|
|
19
|
+
uri?: string | null;
|
|
20
|
+
publicKeySpec?: GitKeySpec | null;
|
|
21
|
+
algorithm?: GitAlgorithm | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface GitIntegrationCreateInView {
|
|
25
|
+
privateKey: string;
|
|
26
|
+
privateKeySpec: GitKeySpec;
|
|
27
|
+
publicKey: string;
|
|
28
|
+
uri: string;
|
|
29
|
+
publicKeySpec: GitKeySpec;
|
|
30
|
+
algorithm: GitAlgorithm;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface GitIntegrationUpdateInView {
|
|
34
|
+
privateKey?: string | null;
|
|
35
|
+
privateKeySpec: GitKeySpec;
|
|
36
|
+
publicKey?: string | null;
|
|
37
|
+
uri?: string | null;
|
|
38
|
+
publicKeySpec: GitKeySpec;
|
|
39
|
+
algorithm: GitAlgorithm;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// ──────────────────────────────────────────────
|
|
44
|
+
// Functions
|
|
45
|
+
// ──────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the git integration configuration for the project.
|
|
49
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git`
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
53
|
+
* const integration = await gitAdapter.get();
|
|
54
|
+
*
|
|
55
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
56
|
+
* @returns promise that resolves to the git integration configuration
|
|
57
|
+
*/
|
|
58
|
+
export async function get(
|
|
59
|
+
optionals: RoutingOptions = {},
|
|
60
|
+
): Promise<GitIntegrationReadOutView> {
|
|
61
|
+
return new Router()
|
|
62
|
+
.get('/git', optionals)
|
|
63
|
+
.then(({ body }) => body);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves the current git status for the project.
|
|
69
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/status`
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
73
|
+
* const status = await gitAdapter.getStatus();
|
|
74
|
+
* console.log(status.currentBranch);
|
|
75
|
+
*
|
|
76
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
77
|
+
* @returns promise that resolves to the git status, including the current branch
|
|
78
|
+
*/
|
|
79
|
+
export async function getStatus(
|
|
80
|
+
optionals: RoutingOptions = {},
|
|
81
|
+
): Promise<GitStatusReadOutView> {
|
|
82
|
+
return new Router()
|
|
83
|
+
.get('/git/status', optionals)
|
|
84
|
+
.then(({ body }) => body);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Checks out a branch in the project's git repository.
|
|
90
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/checkout/{branch}`
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
94
|
+
* await gitAdapter.checkout('main');
|
|
95
|
+
*
|
|
96
|
+
* @param branch Name of the branch to check out
|
|
97
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
98
|
+
* @returns promise that resolves when the checkout is complete
|
|
99
|
+
*/
|
|
100
|
+
export async function checkout(
|
|
101
|
+
branch: string,
|
|
102
|
+
optionals: RoutingOptions = {},
|
|
103
|
+
): Promise<void> {
|
|
104
|
+
return new Router()
|
|
105
|
+
.get(`/git/checkout/${branch}`, optionals)
|
|
106
|
+
.then(({ body }) => body);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Resets the project's git repository, optionally to a specific branch.
|
|
112
|
+
* Base URL: DELETE `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/reset[/{branch}]`
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
116
|
+
* await gitAdapter.reset(); // reset current branch
|
|
117
|
+
* await gitAdapter.reset({ branch: 'main' }); // reset to 'main'
|
|
118
|
+
*
|
|
119
|
+
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
120
|
+
* @param [optionals.branch] Branch to reset to; if omitted, resets the current branch
|
|
121
|
+
* @returns promise that resolves when the reset is complete
|
|
122
|
+
*/
|
|
123
|
+
export async function reset(
|
|
124
|
+
optionals: { branch?: string } & RoutingOptions = {},
|
|
125
|
+
): Promise<void> {
|
|
126
|
+
const { branch, ...routingOptions } = optionals;
|
|
127
|
+
return new Router()
|
|
128
|
+
.delete(`/git/reset${branch ? `/${branch}` : ''}`, routingOptions)
|
|
129
|
+
.then(({ body }) => body);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Creates a git integration for the project.
|
|
135
|
+
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/integration`
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
139
|
+
* const integration = await gitAdapter.createIntegration({
|
|
140
|
+
* uri: 'git@github.com:myorg/myrepo.git',
|
|
141
|
+
* publicKey: '...',
|
|
142
|
+
* privateKey: '...',
|
|
143
|
+
* publicKeySpec: 'openssh',
|
|
144
|
+
* privateKeySpec: 'pkcs8',
|
|
145
|
+
* algorithm: 'ed25519',
|
|
146
|
+
* });
|
|
147
|
+
*
|
|
148
|
+
* @param integration Git integration configuration to create
|
|
149
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
150
|
+
* @returns promise that resolves to the created git integration
|
|
151
|
+
*/
|
|
152
|
+
export async function createIntegration(
|
|
153
|
+
integration: GitIntegrationCreateInView,
|
|
154
|
+
optionals: RoutingOptions = {},
|
|
155
|
+
): Promise<GitIntegrationReadOutView> {
|
|
156
|
+
return new Router()
|
|
157
|
+
.post('/git/integration', {
|
|
158
|
+
body: integration,
|
|
159
|
+
...optionals,
|
|
160
|
+
}).then(({ body }) => body);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Updates the git integration for the project.
|
|
166
|
+
* Base URL: PATCH `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/integration`
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
170
|
+
* const integration = await gitAdapter.updateIntegration({
|
|
171
|
+
* uri: 'git@github.com:myorg/newrepo.git',
|
|
172
|
+
* publicKeySpec: 'openssh',
|
|
173
|
+
* privateKeySpec: 'pkcs8',
|
|
174
|
+
* algorithm: 'ed25519',
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* @param integration Fields to update on the git integration
|
|
178
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
179
|
+
* @returns promise that resolves to the updated git integration
|
|
180
|
+
*/
|
|
181
|
+
export async function updateIntegration(
|
|
182
|
+
integration: GitIntegrationUpdateInView,
|
|
183
|
+
optionals: RoutingOptions = {},
|
|
184
|
+
): Promise<GitIntegrationReadOutView> {
|
|
185
|
+
return new Router()
|
|
186
|
+
.patch('/git/integration', {
|
|
187
|
+
body: integration,
|
|
188
|
+
...optionals,
|
|
189
|
+
}).then(({ body }) => body);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Removes the git integration for the project.
|
|
195
|
+
* Base URL: DELETE `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/integration`
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
199
|
+
* await gitAdapter.removeIntegration();
|
|
200
|
+
*
|
|
201
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
202
|
+
* @returns promise that resolves when the integration is removed
|
|
203
|
+
*/
|
|
204
|
+
export async function removeIntegration(
|
|
205
|
+
optionals: RoutingOptions = {},
|
|
206
|
+
): Promise<void> {
|
|
207
|
+
return new Router()
|
|
208
|
+
.delete('/git/integration', optionals)
|
|
209
|
+
.then(({ body }) => body);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Pushes local commits to the remote git repository.
|
|
215
|
+
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/push`
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
219
|
+
* await gitAdapter.push({ message: 'Update simulation data' });
|
|
220
|
+
*
|
|
221
|
+
* @param optionals Arguments object; also accepts network call option overrides.
|
|
222
|
+
* @param optionals.message Commit message (required)
|
|
223
|
+
* @param [optionals.password] Password for authentication
|
|
224
|
+
* @param [optionals.force] Force-push, bypassing non-fast-forward checks
|
|
225
|
+
* @returns promise that resolves when the push is complete
|
|
226
|
+
*/
|
|
227
|
+
export async function push(
|
|
228
|
+
optionals: {
|
|
229
|
+
message: string;
|
|
230
|
+
password?: string | null;
|
|
231
|
+
force?: boolean | null;
|
|
232
|
+
} & RoutingOptions,
|
|
233
|
+
): Promise<void> {
|
|
234
|
+
const { message, password, force, ...routingOptions } = optionals;
|
|
235
|
+
return new Router()
|
|
236
|
+
.withSearchParams({ force })
|
|
237
|
+
.post('/git/push', {
|
|
238
|
+
body: { message, password },
|
|
239
|
+
...routingOptions,
|
|
240
|
+
}).then(({ body }) => body);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Pulls changes from the remote git repository into the project.
|
|
246
|
+
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/pull`
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
250
|
+
* await gitAdapter.pull({ force: true, confirm: true });
|
|
251
|
+
*
|
|
252
|
+
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
253
|
+
* @param [optionals.password] Password for authentication
|
|
254
|
+
* @param [optionals.force] Force the pull, overwriting local changes
|
|
255
|
+
* @param [optionals.confirm] Set the `X-Forio-Confirmation` header to confirm an overwrite
|
|
256
|
+
* @returns promise that resolves when the pull is complete
|
|
257
|
+
*/
|
|
258
|
+
export async function pull(
|
|
259
|
+
optionals: {
|
|
260
|
+
password?: string | null;
|
|
261
|
+
force?: boolean | null;
|
|
262
|
+
confirm?: boolean | null;
|
|
263
|
+
} & RoutingOptions = {},
|
|
264
|
+
): Promise<void> {
|
|
265
|
+
const { password, force, confirm, headers: headersOverride, ...routingOptions } = optionals;
|
|
266
|
+
const headers = Object.assign(
|
|
267
|
+
{},
|
|
268
|
+
headersOverride,
|
|
269
|
+
confirm ? { 'X-Forio-Confirmation': true } : {},
|
|
270
|
+
);
|
|
271
|
+
return new Router()
|
|
272
|
+
.withSearchParams({ force })
|
|
273
|
+
.post('/git/pull', {
|
|
274
|
+
body: { password },
|
|
275
|
+
headers,
|
|
276
|
+
...routingOptions,
|
|
277
|
+
}).then(({ body }) => body);
|
|
278
|
+
}
|
package/src/adapters/index.ts
CHANGED
|
@@ -23,8 +23,15 @@ import * as somebodyAdapter from './somebody';
|
|
|
23
23
|
import * as matchmakerAdapter from './matchmaker';
|
|
24
24
|
import * as dailyAdapter from './daily';
|
|
25
25
|
import * as walletAdapter from './wallet';
|
|
26
|
+
import * as pipelineAdapter from './pipeline';
|
|
27
|
+
import * as encyclopediaAdapter from './encyclopedia';
|
|
28
|
+
import * as fileAdapter from './file';
|
|
29
|
+
import * as registrationAdapter from './registration';
|
|
30
|
+
import * as docketAdapter from './docket';
|
|
26
31
|
import { default as cometdAdapter } from './cometd';
|
|
27
32
|
import { default as Channel } from './channel';
|
|
33
|
+
import * as gitAdapter from './git';
|
|
34
|
+
import * as powerpointAdapter from './powerpoint';
|
|
28
35
|
|
|
29
36
|
export {
|
|
30
37
|
accountAdapter,
|
|
@@ -53,5 +60,12 @@ export {
|
|
|
53
60
|
matchmakerAdapter,
|
|
54
61
|
dailyAdapter,
|
|
55
62
|
walletAdapter,
|
|
63
|
+
pipelineAdapter,
|
|
64
|
+
encyclopediaAdapter,
|
|
65
|
+
fileAdapter,
|
|
66
|
+
registrationAdapter,
|
|
67
|
+
docketAdapter,
|
|
56
68
|
Channel,
|
|
69
|
+
gitAdapter,
|
|
70
|
+
powerpointAdapter,
|
|
57
71
|
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { Page, RoutingOptions } from '../utils/router';
|
|
2
|
+
|
|
3
|
+
import { Router } from '../utils';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export type PipelineExecutionStatus = 'RUNNING' | 'SUCCEEDED' | 'FAILED';
|
|
7
|
+
|
|
8
|
+
export interface PipelineAuditReadOutView {
|
|
9
|
+
status?: PipelineExecutionStatus | null;
|
|
10
|
+
started?: string | null;
|
|
11
|
+
finished?: string | null;
|
|
12
|
+
executionKey?: string | null;
|
|
13
|
+
accountShortName?: string | null;
|
|
14
|
+
projectShortName?: string | null;
|
|
15
|
+
configName?: string | null;
|
|
16
|
+
/* Virtual field: display name of the admin who triggered the execution. */
|
|
17
|
+
creator?: string | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Builds the NPM Docker images used by pipeline NPM operations.
|
|
23
|
+
* Requires `system` (admin) authorization.
|
|
24
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/pipeline/npm/images`
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* import { pipelineAdapter } from 'epicenter-libs';
|
|
28
|
+
* const built = await pipelineAdapter.buildImages();
|
|
29
|
+
*
|
|
30
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
31
|
+
* @returns promise that resolves to `true` when the images were built successfully
|
|
32
|
+
*/
|
|
33
|
+
export async function buildImages(
|
|
34
|
+
optionals: RoutingOptions = {},
|
|
35
|
+
): Promise<boolean> {
|
|
36
|
+
return await new Router()
|
|
37
|
+
.get('/pipeline/npm/images', optionals)
|
|
38
|
+
.then(({ body }) => body);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Executes a stored pipeline configuration. The operations to run are read server-side from the
|
|
44
|
+
* named config file; only step inputs (such as credentials) are supplied here via `attributes`.
|
|
45
|
+
* The execution runs asynchronously — the returned audit record starts in its `RUNNING` state and
|
|
46
|
+
* is updated by the worker on completion (poll `getExecution` to observe progress).
|
|
47
|
+
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/pipeline/{configName}`
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* import { pipelineAdapter } from 'epicenter-libs';
|
|
51
|
+
* // Pass the git credential the config's git step will consume, keyed by operation type
|
|
52
|
+
* const audit = await pipelineAdapter.execute('deploy', { git: 'my-git-token' });
|
|
53
|
+
*
|
|
54
|
+
* @param configName Name of the stored pipeline config to execute
|
|
55
|
+
* @param [attributes] Step inputs keyed by operation type (e.g. `{ git: '<token>' }`)
|
|
56
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
57
|
+
* @returns promise that resolves to the newly created audit record in its initial RUNNING state
|
|
58
|
+
*/
|
|
59
|
+
export async function execute(
|
|
60
|
+
configName: string,
|
|
61
|
+
attributes: Record<string, unknown> = {},
|
|
62
|
+
optionals: RoutingOptions = {},
|
|
63
|
+
): Promise<PipelineAuditReadOutView> {
|
|
64
|
+
return await new Router()
|
|
65
|
+
.post(`/pipeline/${encodeURIComponent(configName)}`, {
|
|
66
|
+
body: { attributes },
|
|
67
|
+
...optionals,
|
|
68
|
+
}).then(({ body }) => body);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves a single pipeline audit record by its execution key.
|
|
74
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/pipeline/{executionKey}`
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* import { pipelineAdapter } from 'epicenter-libs';
|
|
78
|
+
* const audit = await pipelineAdapter.getExecution('<executionKey>');
|
|
79
|
+
*
|
|
80
|
+
* @param executionKey Execution key of the audit record to retrieve
|
|
81
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
82
|
+
* @returns promise that resolves to the audit record
|
|
83
|
+
*/
|
|
84
|
+
export async function getExecution(
|
|
85
|
+
executionKey: string,
|
|
86
|
+
optionals: RoutingOptions = {},
|
|
87
|
+
): Promise<PipelineAuditReadOutView> {
|
|
88
|
+
return await new Router()
|
|
89
|
+
.get(`/pipeline/${encodeURIComponent(executionKey)}`, optionals)
|
|
90
|
+
.then(({ body }) => body);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Lists the audit history for a stored pipeline config.
|
|
96
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/pipeline/with/{configName}`
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* import { pipelineAdapter } from 'epicenter-libs';
|
|
100
|
+
* const page = await pipelineAdapter.listAudits('deploy', { first: 0, max: 20 });
|
|
101
|
+
*
|
|
102
|
+
* @param configName Name of the stored pipeline config
|
|
103
|
+
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
104
|
+
* @param [optionals.first] Index of the first record to return (for pagination)
|
|
105
|
+
* @param [optionals.max] Maximum number of records to return (for pagination)
|
|
106
|
+
* @returns promise that resolves to a page of audit records
|
|
107
|
+
*/
|
|
108
|
+
export async function listAudits(
|
|
109
|
+
configName: string,
|
|
110
|
+
optionals: {
|
|
111
|
+
first?: number;
|
|
112
|
+
max?: number;
|
|
113
|
+
} & RoutingOptions = {},
|
|
114
|
+
): Promise<Page<PipelineAuditReadOutView>> {
|
|
115
|
+
const { first = 0, max, ...routingOptions } = optionals;
|
|
116
|
+
return await new Router()
|
|
117
|
+
.withSearchParams({ first, max })
|
|
118
|
+
.get(`/pipeline/with/${encodeURIComponent(configName)}`, {
|
|
119
|
+
paginated: true,
|
|
120
|
+
...routingOptions,
|
|
121
|
+
}).then(({ body }) => body);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Deletes a pipeline audit record by its execution key.
|
|
127
|
+
* Requires `system` (admin) authorization.
|
|
128
|
+
* Base URL: DELETE `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/pipeline/{executionKey}`
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* import { pipelineAdapter } from 'epicenter-libs';
|
|
132
|
+
* await pipelineAdapter.deleteAudit('<executionKey>');
|
|
133
|
+
*
|
|
134
|
+
* @param executionKey Execution key of the audit record to delete
|
|
135
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
136
|
+
* @returns promise that resolves to `true` when the audit record was deleted
|
|
137
|
+
*/
|
|
138
|
+
export async function deleteAudit(
|
|
139
|
+
executionKey: string,
|
|
140
|
+
optionals: RoutingOptions = {},
|
|
141
|
+
): Promise<boolean> {
|
|
142
|
+
return await new Router()
|
|
143
|
+
.delete(`/pipeline/${encodeURIComponent(executionKey)}`, optionals)
|
|
144
|
+
.then(({ body }) => body);
|
|
145
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import fetch from 'cross-fetch';
|
|
2
|
+
|
|
3
|
+
import type { RoutingOptions } from '../utils/router';
|
|
4
|
+
import { Router, identification, config } from '../utils';
|
|
5
|
+
|
|
6
|
+
export type TemplateDirectory = 'DATA' | 'MODEL';
|
|
7
|
+
|
|
8
|
+
// ──────────────────────────────────────────────
|
|
9
|
+
// Data Points
|
|
10
|
+
// ──────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
export interface NDataPoint {
|
|
13
|
+
n?: number | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface XYDataPoint {
|
|
17
|
+
x?: number | null;
|
|
18
|
+
y?: number | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ──────────────────────────────────────────────
|
|
22
|
+
// Chart Series
|
|
23
|
+
// ──────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
export interface BarSeriesShadow {
|
|
26
|
+
objectType: 'bar';
|
|
27
|
+
name?: string;
|
|
28
|
+
data?: NDataPoint[] | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface AreaSeriesShadow {
|
|
32
|
+
objectType: 'area';
|
|
33
|
+
name?: string;
|
|
34
|
+
data?: NDataPoint[] | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface LineSeriesShadow {
|
|
38
|
+
objectType: 'line';
|
|
39
|
+
name?: string;
|
|
40
|
+
data?: NDataPoint[] | null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface PieSeriesShadow {
|
|
44
|
+
objectType: 'pie';
|
|
45
|
+
name?: string;
|
|
46
|
+
data?: NDataPoint[] | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ScatterSeriesShadow {
|
|
50
|
+
objectType: 'scatter';
|
|
51
|
+
name?: string;
|
|
52
|
+
data?: XYDataPoint[] | null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface YSeriesShadow {
|
|
56
|
+
objectType: 'y';
|
|
57
|
+
name?: string;
|
|
58
|
+
data?: number[] | null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface XYSeriesShadow {
|
|
62
|
+
objectType: 'xy';
|
|
63
|
+
name?: string;
|
|
64
|
+
data?: XYDataPoint[] | null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type SeriesShadow =
|
|
68
|
+
| BarSeriesShadow
|
|
69
|
+
| AreaSeriesShadow
|
|
70
|
+
| LineSeriesShadow
|
|
71
|
+
| PieSeriesShadow
|
|
72
|
+
| ScatterSeriesShadow
|
|
73
|
+
| YSeriesShadow
|
|
74
|
+
| XYSeriesShadow;
|
|
75
|
+
|
|
76
|
+
// ──────────────────────────────────────────────
|
|
77
|
+
// Chart, Table, Picture
|
|
78
|
+
// ──────────────────────────────────────────────
|
|
79
|
+
|
|
80
|
+
export interface ChartShadow {
|
|
81
|
+
name?: string;
|
|
82
|
+
categories?: unknown[] | null;
|
|
83
|
+
series?: SeriesShadow[] | null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface TableShadow {
|
|
87
|
+
name?: string;
|
|
88
|
+
header?: unknown;
|
|
89
|
+
data?: unknown[] | null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface PictureShadow {
|
|
93
|
+
name?: string;
|
|
94
|
+
data?: BinaryData;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ──────────────────────────────────────────────
|
|
98
|
+
// Binary Data
|
|
99
|
+
// ──────────────────────────────────────────────
|
|
100
|
+
|
|
101
|
+
export interface BinaryData {
|
|
102
|
+
encoding: 'HEX' | 'BASE_64';
|
|
103
|
+
data: unknown;
|
|
104
|
+
encryption?: 'AES' | null;
|
|
105
|
+
name?: string | null;
|
|
106
|
+
content_type?: string | null;
|
|
107
|
+
contentType?: unknown;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ──────────────────────────────────────────────
|
|
111
|
+
// Environment, Slide, Document
|
|
112
|
+
// ──────────────────────────────────────────────
|
|
113
|
+
|
|
114
|
+
export interface EnvironmentShadow {
|
|
115
|
+
parameters?: Record<string, unknown> | null;
|
|
116
|
+
charts?: ChartShadow[] | null;
|
|
117
|
+
tables?: TableShadow[] | null;
|
|
118
|
+
pictures?: PictureShadow[] | null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface SlideShadow {
|
|
122
|
+
/** Slide number (1-based) */
|
|
123
|
+
number?: number;
|
|
124
|
+
environment?: EnvironmentShadow;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface DocumentShadow {
|
|
128
|
+
output?: string;
|
|
129
|
+
environment?: EnvironmentShadow;
|
|
130
|
+
slides?: SlideShadow[] | null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Generates a PowerPoint file from a template and returns it as binary data (JSON-encoded)
|
|
136
|
+
* Base URL: PUT `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/powerpoint/{TEMPLATE_DIRECTORY}/{TEMPLATE_PATH}`
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* import { powerpointAdapter } from 'epicenter-libs';
|
|
140
|
+
* const binaryData = await powerpointAdapter.generate('MODEL', 'en-US-debrief-template.pptx', {
|
|
141
|
+
* output: 'debrief-slides.pptx',
|
|
142
|
+
* environment: {},
|
|
143
|
+
* slides: [
|
|
144
|
+
* {
|
|
145
|
+
* number: 1,
|
|
146
|
+
* environment: {
|
|
147
|
+
* tables: [{ name: 'Leaderboard', data: [['Rank', 'Name', 'Score']] }],
|
|
148
|
+
* },
|
|
149
|
+
* },
|
|
150
|
+
* ],
|
|
151
|
+
* });
|
|
152
|
+
*
|
|
153
|
+
* @param templateDirectory Directory where the template is stored: 'DATA' or 'MODEL'
|
|
154
|
+
* @param templatePath Path to the template file within the directory
|
|
155
|
+
* @param document Document shadow defining the output filename, environment, and slides
|
|
156
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
157
|
+
* @returns promise that resolves to the generated PowerPoint as BinaryData
|
|
158
|
+
*/
|
|
159
|
+
export async function generate(
|
|
160
|
+
templateDirectory: TemplateDirectory,
|
|
161
|
+
templatePath: string,
|
|
162
|
+
document: DocumentShadow,
|
|
163
|
+
optionals: RoutingOptions = {},
|
|
164
|
+
): Promise<BinaryData> {
|
|
165
|
+
return new Router()
|
|
166
|
+
.put(`/powerpoint/${templateDirectory}/${templatePath}`, {
|
|
167
|
+
body: document,
|
|
168
|
+
...optionals,
|
|
169
|
+
}).then(({ body }) => body);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Generates a PowerPoint file from a template and returns it as a streaming response.
|
|
175
|
+
* Useful for downloading the generated file directly.
|
|
176
|
+
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/powerpoint/{TEMPLATE_DIRECTORY}/{TEMPLATE_PATH}`
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* import { powerpointAdapter } from 'epicenter-libs';
|
|
180
|
+
* const response = await powerpointAdapter.stream('MODEL', 'en-US-debrief-template.pptx', {
|
|
181
|
+
* output: 'debrief-slides.pptx',
|
|
182
|
+
* environment: {},
|
|
183
|
+
* slides: [],
|
|
184
|
+
* });
|
|
185
|
+
* const blob = await response.blob();
|
|
186
|
+
*
|
|
187
|
+
* @param templateDirectory Directory where the template is stored: 'DATA' or 'MODEL'
|
|
188
|
+
* @param templatePath Path to the template file within the directory
|
|
189
|
+
* @param document Document shadow defining the output filename, environment, and slides
|
|
190
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
191
|
+
* @returns promise that resolves to the raw Response for streaming/blob handling
|
|
192
|
+
*/
|
|
193
|
+
export async function stream(
|
|
194
|
+
templateDirectory: TemplateDirectory,
|
|
195
|
+
templatePath: string,
|
|
196
|
+
document: DocumentShadow,
|
|
197
|
+
optionals: RoutingOptions = {},
|
|
198
|
+
): Promise<Response> {
|
|
199
|
+
const {
|
|
200
|
+
server,
|
|
201
|
+
accountShortName,
|
|
202
|
+
projectShortName,
|
|
203
|
+
useProjectProxy,
|
|
204
|
+
query,
|
|
205
|
+
headers: headersOverride,
|
|
206
|
+
authorization,
|
|
207
|
+
includeAuthorization,
|
|
208
|
+
} = optionals;
|
|
209
|
+
const url = new Router().getURL(`/powerpoint/${templateDirectory}/${templatePath}`, {
|
|
210
|
+
server,
|
|
211
|
+
accountShortName,
|
|
212
|
+
projectShortName,
|
|
213
|
+
useProjectProxy,
|
|
214
|
+
query,
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
const headers: Record<string, string> = {
|
|
218
|
+
'Content-type': 'application/json; charset=UTF-8',
|
|
219
|
+
...headersOverride,
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
if (includeAuthorization !== false) {
|
|
223
|
+
const { session } = identification;
|
|
224
|
+
if (!headers.Authorization) {
|
|
225
|
+
if (session) headers.Authorization = `Bearer ${session.token}`;
|
|
226
|
+
if (authorization) headers.Authorization = authorization;
|
|
227
|
+
if (config.authOverride) headers.Authorization = config.authOverride;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return fetch(url.toString(), {
|
|
232
|
+
method: 'POST',
|
|
233
|
+
cache: 'no-cache',
|
|
234
|
+
redirect: 'follow',
|
|
235
|
+
headers,
|
|
236
|
+
body: JSON.stringify(document),
|
|
237
|
+
});
|
|
238
|
+
}
|