epicenter-libs 3.34.2 → 3.35.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.
- package/CHANGELOG.md +61 -0
- package/README.md +61 -86
- package/dist/browser/epicenter.js +1589 -228
- package/dist/browser/epicenter.js.map +1 -1
- package/dist/cjs/epicenter.js +1512 -144
- package/dist/cjs/epicenter.js.map +1 -1
- package/dist/epicenter.js +1595 -227
- 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 +1506 -145
- 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/authentication.ts +2 -1
- package/src/adapters/cometd.ts +7 -2
- 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,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
|
+
}
|