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.
Files changed (38) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +61 -86
  3. package/dist/browser/epicenter.js +1581 -226
  4. package/dist/browser/epicenter.js.map +1 -1
  5. package/dist/cjs/epicenter.js +1503 -141
  6. package/dist/cjs/epicenter.js.map +1 -1
  7. package/dist/epicenter.js +1587 -225
  8. package/dist/epicenter.js.map +1 -1
  9. package/dist/epicenter.min.js +1 -1
  10. package/dist/epicenter.min.js.map +1 -1
  11. package/dist/module/epicenter.js +1497 -142
  12. package/dist/module/epicenter.js.map +1 -1
  13. package/dist/types/adapters/docket.d.ts +80 -0
  14. package/dist/types/adapters/encyclopedia.d.ts +86 -0
  15. package/dist/types/adapters/file.d.ts +201 -0
  16. package/dist/types/adapters/git.d.ts +171 -0
  17. package/dist/types/adapters/index.d.ts +8 -1
  18. package/dist/types/adapters/pipeline.d.ts +88 -0
  19. package/dist/types/adapters/powerpoint.d.ts +130 -0
  20. package/dist/types/adapters/registration.d.ts +270 -0
  21. package/dist/types/adapters/task.d.ts +99 -37
  22. package/dist/types/epicenter.d.ts +2 -2
  23. package/dist/types/types.d.ts +6 -1
  24. package/dist/types/utils/router.d.ts +1 -0
  25. package/package.json +12 -7
  26. package/src/adapters/docket.ts +109 -0
  27. package/src/adapters/encyclopedia.ts +128 -0
  28. package/src/adapters/file.ts +332 -0
  29. package/src/adapters/git.ts +278 -0
  30. package/src/adapters/index.ts +14 -0
  31. package/src/adapters/pipeline.ts +145 -0
  32. package/src/adapters/powerpoint.ts +238 -0
  33. package/src/adapters/registration.ts +413 -0
  34. package/src/adapters/task.ts +170 -47
  35. package/src/epicenter.ts +10 -3
  36. package/src/globals.d.ts +6 -0
  37. package/src/types.ts +61 -0
  38. package/src/utils/router.ts +1 -0
@@ -0,0 +1,413 @@
1
+ import type { RoutingOptions } from '../utils/router';
2
+ import { Router } from '../utils';
3
+
4
+ export interface RegistrationInfo {
5
+ projectShortName?: string | null;
6
+ groupName?: string | null;
7
+ accountShortName?: string | null;
8
+ accountName?: string | null;
9
+ familyName?: string | null;
10
+ givenName?: string | null;
11
+ projectName?: string | null;
12
+ email?: string | null;
13
+ groupKey?: string | null;
14
+ }
15
+
16
+ export interface TeamRegistrationInfo {
17
+ accountShortName?: string | null;
18
+ accountName?: string | null;
19
+ familyName?: string | null;
20
+ givenName?: string | null;
21
+ email?: string | null;
22
+ }
23
+
24
+ export type WhoAmIObjectType = 'system' | 'dashboard' | 'account' | 'admin' | 'user' | 'anonymous';
25
+
26
+ export interface WhoAmI {
27
+ objectType: WhoAmIObjectType;
28
+ sessionKey?: string | null;
29
+ timeoutMinutes?: number | null;
30
+ token?: string | null;
31
+ expires?: boolean | null;
32
+ [key: string]: unknown;
33
+ }
34
+
35
+ export interface RegistrationResult {
36
+ whoAmI: WhoAmI;
37
+ redirectUrl?: string | null;
38
+ }
39
+
40
+ export type TeamRole = 'OWNER' | 'AUTHOR' | 'SUPPORT' | 'ASSOCIATE';
41
+
42
+ /**
43
+ * Currently the API only supports `SAML`. This type is intentionally narrow so that adding new
44
+ * protocols on the backend requires an explicit type update here.
45
+ */
46
+ export type SsoProtocol = 'SAML';
47
+
48
+
49
+ /**
50
+ * Gets registration info for a self-registration token.
51
+ * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/registration/self/{token}`
52
+ *
53
+ * @example
54
+ * import { registrationAdapter } from 'epicenter-libs';
55
+ * const info = await registrationAdapter.getSelfRegistrationInfo('my-token');
56
+ *
57
+ * @param token Self-registration token
58
+ * @param [optionals] Optional arguments; pass network call options overrides here.
59
+ * @returns promise that resolves to registration info
60
+ */
61
+ export async function getSelfRegistrationInfo(
62
+ token: string,
63
+ optionals: RoutingOptions = {},
64
+ ): Promise<RegistrationInfo> {
65
+ return await new Router()
66
+ .get(`/registration/self/${token}`, optionals)
67
+ .then(({ body }) => body);
68
+ }
69
+
70
+
71
+ /**
72
+ * Completes a self-registration using a token.
73
+ * Base URL: PATCH `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/registration/self/{token}`
74
+ *
75
+ * @example
76
+ * import { registrationAdapter } from 'epicenter-libs';
77
+ * const result = await registrationAdapter.completeSelfRegistration('my-token', 'secret123', {
78
+ * displayName: 'John Doe',
79
+ * handle: 'johnd',
80
+ * });
81
+ *
82
+ * @param token Self-registration token
83
+ * @param password Password for the new account
84
+ * @param [optionals] Optional arguments; pass network call options overrides here.
85
+ * @param [optionals.displayName] Display name for the new user
86
+ * @param [optionals.givenName] Given name for the new user
87
+ * @param [optionals.familyName] Family name for the new user
88
+ * @param [optionals.handle] Handle for the new user
89
+ * @returns promise that resolves to the registration result including session info
90
+ */
91
+ export async function completeSelfRegistration(
92
+ token: string,
93
+ password: string,
94
+ optionals: {
95
+ displayName?: string;
96
+ givenName?: string;
97
+ familyName?: string;
98
+ handle?: string;
99
+ } & RoutingOptions = {},
100
+ ): Promise<RegistrationResult> {
101
+ const { displayName, givenName, familyName, handle, ...routingOptions } = optionals;
102
+ return await new Router()
103
+ .patch(`/registration/self/${token}`, {
104
+ body: { password, displayName, givenName, familyName, handle },
105
+ ...routingOptions,
106
+ })
107
+ .then(({ body }) => body);
108
+ }
109
+
110
+
111
+ /**
112
+ * Sends a self-registration invite email to a user. Pass an `Accept-Language` header via
113
+ * `optionals.headers` to localize the email.
114
+ * Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/registration/self/{groupKey}`
115
+ *
116
+ * @example
117
+ * import { registrationAdapter } from 'epicenter-libs';
118
+ * await registrationAdapter.sendSelfRegistrationInvite('group-key', 'user@example.com', {
119
+ * linkDestination: 'DASHBOARD',
120
+ * redirectUrl: 'https://app.example.com',
121
+ * headers: { 'Accept-Language': 'fr-FR' },
122
+ * });
123
+ *
124
+ * @param groupKey Group key to register the user into
125
+ * @param email Email address of the user to invite
126
+ * @param [optionals] Optional arguments; pass network call options overrides here.
127
+ * @param [optionals.linkDestination] Destination for the registration link ('DASHBOARD' or 'MANAGER')
128
+ * @param [optionals.modality] Registration modality
129
+ * @param [optionals.redirectUrl] URL to redirect to after registration
130
+ * @param [optionals.subject] Subject line for the invite email
131
+ * @param [optionals.givenName] Pre-populate given name in the registration form
132
+ * @param [optionals.familyName] Pre-populate family name in the registration form
133
+ * @param [optionals.linkUrl] Custom URL to use for the registration link
134
+ * @param [optionals.confirmation] Whether to send a confirmation email
135
+ * @returns promise that resolves to undefined if successful
136
+ */
137
+ export async function sendSelfRegistrationInvite(
138
+ groupKey: string,
139
+ email: string,
140
+ optionals: {
141
+ linkDestination?: 'DASHBOARD' | 'MANAGER';
142
+ modality?: 'NONE' | 'HBP' | 'ICC' | 'SSO';
143
+ redirectUrl?: string;
144
+ subject?: string;
145
+ givenName?: string;
146
+ familyName?: string;
147
+ linkUrl?: string;
148
+ confirmation?: boolean;
149
+ } & RoutingOptions = {},
150
+ ): Promise<void> {
151
+ const {
152
+ linkDestination, modality, redirectUrl, subject,
153
+ givenName, familyName, linkUrl, confirmation,
154
+ ...routingOptions
155
+ } = optionals;
156
+ return await new Router()
157
+ .post(`/registration/self/${groupKey}`, {
158
+ body: { email, linkDestination, modality, redirectUrl, subject, givenName, familyName, linkUrl, confirmation },
159
+ ...routingOptions,
160
+ })
161
+ .then(({ body }) => body);
162
+ }
163
+
164
+
165
+ /**
166
+ * Gets registration info for an invite token.
167
+ * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/registration/invite/{token}`
168
+ *
169
+ * @example
170
+ * import { registrationAdapter } from 'epicenter-libs';
171
+ * const info = await registrationAdapter.getInviteRegistrationInfo('invite-token');
172
+ *
173
+ * @param token Invite registration token
174
+ * @param [optionals] Optional arguments; pass network call options overrides here.
175
+ * @returns promise that resolves to registration info
176
+ */
177
+ export async function getInviteRegistrationInfo(
178
+ token: string,
179
+ optionals: RoutingOptions = {},
180
+ ): Promise<RegistrationInfo> {
181
+ return await new Router()
182
+ .get(`/registration/invite/${token}`, optionals)
183
+ .then(({ body }) => body);
184
+ }
185
+
186
+
187
+ /**
188
+ * Completes an invite registration using a token.
189
+ * Base URL: PATCH `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/registration/invite/{token}`
190
+ *
191
+ * @example
192
+ * import { registrationAdapter } from 'epicenter-libs';
193
+ * const result = await registrationAdapter.completeInviteRegistration('invite-token', 'pass456', {
194
+ * displayName: 'Jane Doe',
195
+ * });
196
+ *
197
+ * @param token Invite registration token
198
+ * @param password Password for the new account
199
+ * @param [optionals] Optional arguments; pass network call options overrides here.
200
+ * @param [optionals.displayName] Display name for the new user
201
+ * @param [optionals.givenName] Given name for the new user
202
+ * @param [optionals.familyName] Family name for the new user
203
+ * @param [optionals.handle] Handle for the new user
204
+ * @returns promise that resolves to the registration result including session info
205
+ */
206
+ export async function completeInviteRegistration(
207
+ token: string,
208
+ password: string,
209
+ optionals: {
210
+ displayName?: string;
211
+ givenName?: string;
212
+ familyName?: string;
213
+ handle?: string;
214
+ } & RoutingOptions = {},
215
+ ): Promise<RegistrationResult> {
216
+ const { displayName, givenName, familyName, handle, ...routingOptions } = optionals;
217
+ return await new Router()
218
+ .patch(`/registration/invite/${token}`, {
219
+ body: { password, displayName, givenName, familyName, handle },
220
+ ...routingOptions,
221
+ })
222
+ .then(({ body }) => body);
223
+ }
224
+
225
+
226
+ /**
227
+ * Sends an invite registration email to a user. Pass an `Accept-Language` header via
228
+ * `optionals.headers` to localize the email.
229
+ * Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/registration/invite/{groupKey}`
230
+ *
231
+ * @example
232
+ * import { registrationAdapter } from 'epicenter-libs';
233
+ * await registrationAdapter.sendInvite('group-key', 'invited@example.com', {
234
+ * givenName: 'New',
235
+ * familyName: 'User',
236
+ * redirectUrl: 'https://app.example.com',
237
+ * });
238
+ *
239
+ * @param groupKey Group key to invite the user into
240
+ * @param email Email address of the user to invite
241
+ * @param [optionals] Optional arguments; pass network call options overrides here.
242
+ * @param [optionals.linkDestination] Destination for the registration link ('DASHBOARD' or 'MANAGER')
243
+ * @param [optionals.modality] Registration modality
244
+ * @param [optionals.redirectUrl] URL to redirect to after registration
245
+ * @param [optionals.subject] Subject line for the invite email
246
+ * @param [optionals.givenName] Pre-populate given name in the registration form
247
+ * @param [optionals.familyName] Pre-populate family name in the registration form
248
+ * @param [optionals.linkUrl] Custom URL to use for the registration link
249
+ * @param [optionals.confirmation] Whether to send a confirmation email
250
+ * @returns promise that resolves to undefined if successful
251
+ */
252
+ export async function sendInvite(
253
+ groupKey: string,
254
+ email: string,
255
+ optionals: {
256
+ linkDestination?: 'DASHBOARD' | 'MANAGER';
257
+ modality?: 'NONE' | 'HBP' | 'ICC' | 'SSO';
258
+ redirectUrl?: string;
259
+ subject?: string;
260
+ givenName?: string;
261
+ familyName?: string;
262
+ linkUrl?: string;
263
+ confirmation?: boolean;
264
+ } & RoutingOptions = {},
265
+ ): Promise<void> {
266
+ const {
267
+ linkDestination, modality, redirectUrl, subject,
268
+ givenName, familyName, linkUrl, confirmation,
269
+ ...routingOptions
270
+ } = optionals;
271
+ return await new Router()
272
+ .post(`/registration/invite/${groupKey}`, {
273
+ body: { email, linkDestination, modality, redirectUrl, subject, givenName, familyName, linkUrl, confirmation },
274
+ ...routingOptions,
275
+ })
276
+ .then(({ body }) => body);
277
+ }
278
+
279
+
280
+ /**
281
+ * Gets registration info for a team invite token.
282
+ * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/registration/team/{token}`
283
+ *
284
+ * @example
285
+ * import { registrationAdapter } from 'epicenter-libs';
286
+ * const info = await registrationAdapter.getTeamRegistrationInfo('team-token');
287
+ *
288
+ * @param token Team invite token
289
+ * @param [optionals] Optional arguments; pass network call options overrides here.
290
+ * @returns promise that resolves to team registration info
291
+ */
292
+ export async function getTeamRegistrationInfo(
293
+ token: string,
294
+ optionals: RoutingOptions = {},
295
+ ): Promise<TeamRegistrationInfo> {
296
+ return await new Router()
297
+ .get(`/registration/team/${token}`, optionals)
298
+ .then(({ body }) => body);
299
+ }
300
+
301
+
302
+ /**
303
+ * Sends a team invite email. Pass an `Accept-Language` header via `optionals.headers` to
304
+ * localize the email.
305
+ * Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/registration/team`
306
+ *
307
+ * @example
308
+ * import { registrationAdapter } from 'epicenter-libs';
309
+ * await registrationAdapter.sendTeamInvite(
310
+ * 'Jane Author',
311
+ * 'AUTHOR',
312
+ * 'https://app.example.com',
313
+ * 'newteammate@example.com',
314
+ * { subject: 'Welcome to the team!' },
315
+ * );
316
+ *
317
+ * @param invitingAuthor Name or identifier of the person sending the invite
318
+ * @param role Role to assign to the invited user
319
+ * @param redirectUrl URL to redirect to after accepting the invite
320
+ * @param email Email address of the user to invite
321
+ * @param [optionals] Optional arguments; pass network call options overrides here.
322
+ * @param [optionals.subject] Subject line for the invite email
323
+ * @param [optionals.givenName] Pre-populate given name for the invited user
324
+ * @param [optionals.familyName] Pre-populate family name for the invited user
325
+ * @returns promise that resolves to undefined if successful
326
+ */
327
+ export async function sendTeamInvite(
328
+ invitingAuthor: string,
329
+ role: TeamRole,
330
+ redirectUrl: string,
331
+ email: string,
332
+ optionals: {
333
+ subject?: string;
334
+ givenName?: string;
335
+ familyName?: string;
336
+ } & RoutingOptions = {},
337
+ ): Promise<void> {
338
+ const { subject, givenName, familyName, ...routingOptions } = optionals;
339
+ return await new Router()
340
+ .post('/registration/team', {
341
+ body: { invitingAuthor, role, redirectUrl, email, subject, givenName, familyName },
342
+ ...routingOptions,
343
+ })
344
+ .then(({ body }) => body);
345
+ }
346
+
347
+
348
+ /**
349
+ * @deprecated Use getSsoAdminRegistration or getSsoUserRegistration instead.
350
+ * Gets SSO registration info for a given SSO protocol.
351
+ * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/registration/sso/{ssoProtocol}`
352
+ *
353
+ * @example
354
+ * import { registrationAdapter } from 'epicenter-libs';
355
+ * const info = await registrationAdapter.getSsoRegistration('SAML');
356
+ *
357
+ * @param ssoProtocol The SSO protocol (e.g. 'SAML')
358
+ * @param [optionals] Optional arguments; pass network call options overrides here.
359
+ * @returns promise that resolves to SSO registration data
360
+ */
361
+ export async function getSsoRegistration(
362
+ ssoProtocol: SsoProtocol,
363
+ optionals: RoutingOptions = {},
364
+ ): Promise<unknown> {
365
+ console.warn('DEPRECATION WARNING: registrationAdapter.getSsoRegistration is deprecated and will be removed with the next release. Use registrationAdapter.getSsoAdminRegistration or registrationAdapter.getSsoUserRegistration instead.');
366
+ return await new Router()
367
+ .get(`/registration/sso/${ssoProtocol}`, optionals)
368
+ .then(({ body }) => body);
369
+ }
370
+
371
+
372
+ /**
373
+ * Gets admin SSO registration info for a given SSO protocol.
374
+ * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/registration/sso/admin/{ssoProtocol}`
375
+ *
376
+ * @example
377
+ * import { registrationAdapter } from 'epicenter-libs';
378
+ * const info = await registrationAdapter.getSsoAdminRegistration('SAML');
379
+ *
380
+ * @param ssoProtocol The SSO protocol (e.g. 'SAML')
381
+ * @param [optionals] Optional arguments; pass network call options overrides here.
382
+ * @returns promise that resolves to SSO admin registration data
383
+ */
384
+ export async function getSsoAdminRegistration(
385
+ ssoProtocol: SsoProtocol,
386
+ optionals: RoutingOptions = {},
387
+ ): Promise<unknown> {
388
+ return await new Router()
389
+ .get(`/registration/sso/admin/${ssoProtocol}`, optionals)
390
+ .then(({ body }) => body);
391
+ }
392
+
393
+
394
+ /**
395
+ * Gets user SSO registration info for a given SSO protocol.
396
+ * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/registration/sso/user/{ssoProtocol}`
397
+ *
398
+ * @example
399
+ * import { registrationAdapter } from 'epicenter-libs';
400
+ * const info = await registrationAdapter.getSsoUserRegistration('SAML');
401
+ *
402
+ * @param ssoProtocol The SSO protocol (e.g. 'SAML')
403
+ * @param [optionals] Optional arguments; pass network call options overrides here.
404
+ * @returns promise that resolves to SSO user registration data
405
+ */
406
+ export async function getSsoUserRegistration(
407
+ ssoProtocol: SsoProtocol,
408
+ optionals: RoutingOptions = {},
409
+ ): Promise<unknown> {
410
+ return await new Router()
411
+ .get(`/registration/sso/user/${ssoProtocol}`, optionals)
412
+ .then(({ body }) => body);
413
+ }