epicenter-libs 3.33.0 → 3.34.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 (76) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/browser/epicenter.js +105 -2
  3. package/dist/browser/epicenter.js.map +1 -1
  4. package/dist/cjs/epicenter.js +105 -2
  5. package/dist/cjs/epicenter.js.map +1 -1
  6. package/dist/epicenter.js +105 -2
  7. package/dist/epicenter.js.map +1 -1
  8. package/dist/epicenter.min.js +1 -1
  9. package/dist/epicenter.min.js.map +1 -1
  10. package/dist/module/epicenter.js +105 -2
  11. package/dist/module/epicenter.js.map +1 -1
  12. package/dist/types/adapters/chat.d.ts +63 -0
  13. package/package.json +1 -1
  14. package/src/adapters/chat.ts +95 -0
  15. package/src/utils/identification.ts +4 -0
  16. package/dist/test/_virtual/runtime.js +0 -3
  17. package/dist/test/_virtual/runtime2.js +0 -3
  18. package/dist/test/adapters/account.js +0 -169
  19. package/dist/test/adapters/admin.js +0 -53
  20. package/dist/test/adapters/asset.js +0 -425
  21. package/dist/test/adapters/authentication.js +0 -349
  22. package/dist/test/adapters/channel.js +0 -201
  23. package/dist/test/adapters/chat.js +0 -199
  24. package/dist/test/adapters/cometd.js +0 -514
  25. package/dist/test/adapters/consensus.js +0 -484
  26. package/dist/test/adapters/daily.js +0 -244
  27. package/dist/test/adapters/email.js +0 -179
  28. package/dist/test/adapters/episode.js +0 -175
  29. package/dist/test/adapters/group.js +0 -655
  30. package/dist/test/adapters/leaderboard.js +0 -162
  31. package/dist/test/adapters/matchmaker.js +0 -159
  32. package/dist/test/adapters/presence.js +0 -85
  33. package/dist/test/adapters/project.js +0 -94
  34. package/dist/test/adapters/recaptcha.js +0 -24
  35. package/dist/test/adapters/run.js +0 -1008
  36. package/dist/test/adapters/somebody.js +0 -154
  37. package/dist/test/adapters/task.js +0 -192
  38. package/dist/test/adapters/time.js +0 -28
  39. package/dist/test/adapters/user.js +0 -105
  40. package/dist/test/adapters/vault.js +0 -403
  41. package/dist/test/adapters/video.js +0 -249
  42. package/dist/test/adapters/vonage.js +0 -130
  43. package/dist/test/adapters/wallet.js +0 -130
  44. package/dist/test/adapters/world.js +0 -507
  45. package/dist/test/apis/video.js +0 -294
  46. package/dist/test/apis/vonage.js +0 -121
  47. package/dist/test/epicenter.js +0 -121
  48. package/dist/test/node_modules/@babel/runtime/helpers/esm/defineProperty.js +0 -12
  49. package/dist/test/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +0 -14
  50. package/dist/test/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +0 -9
  51. package/dist/test/node_modules/@babel/runtime/helpers/esm/typeof.js +0 -11
  52. package/dist/test/node_modules/cometd/AckExtension.js +0 -91
  53. package/dist/test/node_modules/cometd/CallbackPollingTransport.js +0 -148
  54. package/dist/test/node_modules/cometd/Client.js +0 -2160
  55. package/dist/test/node_modules/cometd/Extension.js +0 -47
  56. package/dist/test/node_modules/cometd/LongPollingTransport.js +0 -135
  57. package/dist/test/node_modules/cometd/ReloadExtension.js +0 -214
  58. package/dist/test/node_modules/cometd/RequestTransport.js +0 -252
  59. package/dist/test/node_modules/cometd/Transport.js +0 -167
  60. package/dist/test/node_modules/cometd/TransportRegistry.js +0 -107
  61. package/dist/test/node_modules/cometd/WebSocketTransport.js +0 -384
  62. package/dist/test/node_modules/cometd/cometd.js +0 -9
  63. package/dist/test/node_modules/regenerator-runtime/runtime.js +0 -773
  64. package/dist/test/utilities.js +0 -17
  65. package/dist/test/utils/config.js +0 -189
  66. package/dist/test/utils/constants.js +0 -293
  67. package/dist/test/utils/cookies.js +0 -75
  68. package/dist/test/utils/error-manager.js +0 -57
  69. package/dist/test/utils/error.js +0 -12
  70. package/dist/test/utils/fault.js +0 -34
  71. package/dist/test/utils/filter-parser.js +0 -68
  72. package/dist/test/utils/helpers.js +0 -9
  73. package/dist/test/utils/identification.js +0 -161
  74. package/dist/test/utils/result.js +0 -20
  75. package/dist/test/utils/router.js +0 -551
  76. package/dist/test/utils/store.js +0 -79
@@ -1,403 +0,0 @@
1
- import { SCOPE_BOUNDARY, ROLE } from '../utils/constants.js';
2
- import '../utils/helpers.js';
3
- import { parseFilterInput } from '../utils/filter-parser.js';
4
- import '../utils/config.js';
5
- import identification from '../utils/identification.js';
6
- import '../utils/error-manager.js';
7
- import Router from '../utils/router.js';
8
-
9
- // Generic type parameter for vault items structure
10
-
11
- /**
12
- * Updates a vault's items
13
- * Base URL: PUT `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vault/{VAULT_KEY}`
14
- *
15
- * @example
16
- * import { vaultAdapter } from 'epicenter-libs';
17
- * // Change the name of the first student object in the list of students in the vault to "Bob"
18
- * await vaultAdapter.update('00000166d59adcb0f497ddc1aad0270c0a62', { set: { 'students.0.name': 'Bob' } });
19
- *
20
- * @param vaultKey Vault key
21
- * @param items Object with a set/push/pop field to update the vault items with
22
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
23
- * @param [optionals.mutationKey] Mutation key for optimistic concurrency control
24
- * @returns promise that resolves to the vault
25
- */
26
- async function update(vaultKey, items, optionals = {}) {
27
- var _items$set, _items$push, _items$pop;
28
- const {
29
- mutationKey,
30
- ...routingOptions
31
- } = optionals;
32
- return await new Router().withSearchParams({
33
- mutationKey: mutationKey
34
- }).put(`/vault/${vaultKey}`, {
35
- body: {
36
- set: (_items$set = items.set) !== null && _items$set !== void 0 ? _items$set : {},
37
- push: (_items$push = items.push) !== null && _items$push !== void 0 ? _items$push : {},
38
- pop: (_items$pop = items.pop) !== null && _items$pop !== void 0 ? _items$pop : {}
39
- },
40
- ...routingOptions
41
- }).then(({
42
- body
43
- }) => body);
44
- }
45
-
46
- /**
47
- * Updates a vault's properties
48
- * Base URL: PATCH `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vault/{VAULT_KEY}`
49
- *
50
- * @example
51
- * import { vaultAdapter, ROLE } from 'epicenter-libs';
52
- * await vaultAdapter.updateProperties('00000166d59adcb0f497ddc1aad0270c0a62', {
53
- * allowChannel: true,
54
- * permit: {
55
- * readLock: ROLE.FACILITATOR,
56
- * writeLock: ROLE.FACILITATOR,
57
- * },
58
- * ttlSeconds: 3600,
59
- * });
60
- * });
61
- *
62
- * @param vaultKey Vault key
63
- * @param update Object with properties to update
64
- * @param [update.mutationKey] Mutation key for optimistic concurrency control
65
- * @param [update.allowChannel] Opt into push notifications for this resource
66
- * @param [update.permit] Permission settings for the vault
67
- * @param [update.ttlSeconds] Time to live in seconds
68
- * @param [optionals] Optional arguments; pass network call options overrides here.
69
- * @returns promise that resolves to the vault
70
- */
71
- async function updateProperties(vaultKey, update, optionals = {}) {
72
- return await new Router().patch(`/vault/${vaultKey}`, {
73
- body: {
74
- ...update
75
- },
76
- ...optionals
77
- }).then(({
78
- body
79
- }) => body);
80
- }
81
- const NOT_FOUND = 404;
82
-
83
- /**
84
- * Retrieves a vault by its vault key
85
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vault/{VAULT_KEY}`
86
- *
87
- * @example
88
- * import { vaultAdapter } from 'epicenter-libs';
89
- * const vault = await vaultAdapter.get('00000166d59adcb0f497ddc1aad0270c0a62');
90
- *
91
- * @param vaultKey Vault key
92
- * @param [optionals] Optional arguments; pass network call options overrides here.
93
- * @returns promise that resolves to the vault, or undefined if not found
94
- */
95
- async function get(vaultKey, optionals = {}) {
96
- return await new Router().get(`/vault/${vaultKey}`, optionals).catch(error => {
97
- if (error.status === NOT_FOUND) return {
98
- body: undefined
99
- };
100
- return Promise.reject(error);
101
- }).then(({
102
- body
103
- }) => body);
104
- }
105
-
106
- /**
107
- * Retrieves a vault by name within a specific scope
108
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vault/with/{SCOPE_BOUNDARY}/{SCOPE_KEY}/{VAULT_NAME}`
109
- *
110
- * @example
111
- * import { vaultAdapter, SCOPE_BOUNDARY } from 'epicenter-libs';
112
- * const vault = await vaultAdapter.withScope('my-vault-name', {
113
- * scopeBoundary: SCOPE_BOUNDARY.GROUP,
114
- * scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
115
- * });
116
- *
117
- * @param name Name of the vault
118
- * @param scope Scope associated with the vault
119
- * @param scope.scopeBoundary Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
120
- * @param scope.scopeKey Scope key, a unique identifier tied to the scope. E.g., if your `scopeBoundary` is `GROUP`, your `scopeKey` will be your `groupKey`; for `EPISODE`, `episodeKey`, etc.
121
- * @param [scope.userKey] Optional key to scope the vault to a user
122
- * @param [optionals] Optional arguments; pass network call options overrides here.
123
- * @returns promise that resolves to the vault, or undefined if not found
124
- */
125
- async function withScope(name, scope, optionals = {}) {
126
- const {
127
- scopeBoundary,
128
- scopeKey,
129
- userKey
130
- } = scope;
131
- const uriComponent = userKey ? `/${userKey}` : '';
132
- return await new Router().get(`/vault/with/${scopeBoundary}/${scopeKey}${uriComponent}/${name}`, optionals).catch(error => {
133
- if (error.status === NOT_FOUND) return {
134
- body: undefined
135
- };
136
- return Promise.reject(error);
137
- }).then(({
138
- body
139
- }) => body);
140
- }
141
-
142
- /**
143
- * Retrieves all vaults with a specific name within a group or episode
144
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vault/in/{GROUP_NAME}/{VAULT_NAME}`
145
- *
146
- * @example
147
- * import { vaultAdapter } from 'epicenter-libs';
148
- * const vaults = await vaultAdapter.byName('my-vault-name', {
149
- * groupName: 'my-group',
150
- * episodeName: 'my-episode',
151
- * includeEpisodes: true,
152
- * });
153
- *
154
- * @param name Name of the vault
155
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
156
- * @param [optionals.groupName] Name of the group to search within. Defaults to the session user's group.
157
- * @param [optionals.episodeName] Name of the episode to search within
158
- * @param [optionals.userKey] Optional user key to filter vaults by user
159
- * @param [optionals.includeEpisodes] Whether to include vaults from episodes within the group
160
- * @returns promise that resolves to an array of vaults with the specified name
161
- */
162
- async function byName(name, optionals = {}) {
163
- const {
164
- groupName,
165
- episodeName,
166
- userKey,
167
- includeEpisodes,
168
- ...routingOptions
169
- } = optionals;
170
- const session = identification.session;
171
- const searchParams = {
172
- userKey,
173
- includeEpisodes
174
- };
175
- return await new Router().withSearchParams(searchParams).get(`/vault/in/${groupName !== null && groupName !== void 0 ? groupName : session === null || session === void 0 ? void 0 : session.groupName}${episodeName ? `/${episodeName}` : ''}/${name}`, {
176
- ...routingOptions
177
- }).then(({
178
- body
179
- }) => body);
180
- }
181
-
182
- /**
183
- * Deletes a vault
184
- * Base URL: DELETE `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vault/{VAULT_KEY}`
185
- *
186
- * @example
187
- * import { vaultAdapter } from 'epicenter-libs';
188
- * await vaultAdapter.remove('00000166d59adcb0f497ddc1aad0270c0a62');
189
- *
190
- * @param vaultKey Vault key
191
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
192
- * @param [optionals.mutationKey] Mutation key for optimistic concurrency control
193
- * @returns promise that resolves to undefined when successful
194
- */
195
- async function remove(vaultKey, optionals = {}) {
196
- const {
197
- mutationKey,
198
- ...routingOptions
199
- } = optionals;
200
- return await new Router().withSearchParams({
201
- mutationKey: mutationKey
202
- }).delete(`/vault/${vaultKey}`, routingOptions).then(({
203
- body
204
- }) => body);
205
- }
206
-
207
- /**
208
- * Defines vault properties, used to create or modify a vault. Vault names are unique within their scope.
209
- * Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vault/{COLLECTION_NAME}`
210
- *
211
- * @example
212
- * import { vaultAdapter, SCOPE_BOUNDARY } from 'epicenter-libs';
213
- * vaultAdapter.define('my-vault-name', {
214
- * scopeBoundary: SCOPE_BOUNDARY.GROUP,
215
- * scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
216
- * });
217
- *
218
- * @param name Name of the vault
219
- * @param scope Scope associated with your vault
220
- * @param scope.scopeBoundary Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
221
- * @param scope.scopeKey Scope key, a unique identifier tied to the scope. E.g., if your `scopeBoundary` is `GROUP`, your `scopeKey` will be your `groupKey`; for `EPISODE`, `episodeKey`, etc.
222
- * @param [scope.userKey] Optional key to scope the vault to a user
223
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
224
- * @param [optionals.items] Optional items parameter for updating vault contents
225
- * @param [optionals.items.set] Sets a field in the vault, where `[name]: [value]`, send `[name]: null` to delete
226
- * @param [optionals.items.push] Adds an item to a list in the vault; if the list does not exist it will create one
227
- * @param [optionals.items.pop] Use to remove items from lists in a vault
228
- * @param [optionals.readLock] Role allowed to read
229
- * @param [optionals.writeLock] Role allowed to write
230
- * @param [optionals.ttlSeconds] Life span of the vault (defaults to null, minimum value of 1800 seconds / 30 minutes)
231
- * @param [optionals.mutationStrategy] Setting a mutation strategy allows for the following behaviors: ALLOW - Is an upsert which means if the entry exists it will be updated with the items in the POST. DISALLOW - Is an insert which means that if the entry exists no changes will be made (the 'changed' flag will be false). ERROR - Is an insert and, if the entry exists, a conflict exception will be thrown. If the mutationStrategy is omitted, it will simply search by scope and name; updating if it exists, creating if not.
232
- * @param [optionals.allowChannel] Opt into push notifications for this resource. Applicable to projects with phylogeny >= SILENT
233
- * @returns promise that resolves to the vault (created or modified)
234
- */
235
- async function define(name, scope, optionals = {}) {
236
- const {
237
- scopeBoundary,
238
- scopeKey,
239
- userKey
240
- } = scope;
241
- const {
242
- readLock,
243
- writeLock,
244
- items,
245
- ttlSeconds,
246
- mutationStrategy = 'ERROR',
247
- allowChannel,
248
- ...routingOptions
249
- } = optionals;
250
- const {
251
- WORLD
252
- } = SCOPE_BOUNDARY;
253
- const {
254
- PARTICIPANT,
255
- USER
256
- } = ROLE;
257
- const defaultLock = scopeBoundary === WORLD ? PARTICIPANT : USER;
258
- const searchParams = {
259
- mutationStrategy
260
- };
261
- return await new Router().withSearchParams(searchParams).post(`/vault/${name}`, {
262
- body: {
263
- scope: {
264
- scopeBoundary,
265
- scopeKey,
266
- userKey
267
- },
268
- permit: {
269
- readLock: readLock || defaultLock,
270
- writeLock: writeLock || defaultLock
271
- },
272
- ttlSeconds,
273
- items,
274
- allowChannel
275
- },
276
- ...routingOptions
277
- }).then(({
278
- body
279
- }) => body);
280
- }
281
-
282
- /**
283
- * @deprecated Use vaultAdapter.define instead. This method will be removed in the next release.
284
- *
285
- * Creates a new vault with the specified name, scope, and items
286
- * Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vault/{COLLECTION_NAME}`
287
- *
288
- * @example
289
- * import { vaultAdapter, SCOPE_BOUNDARY } from 'epicenter-libs';
290
- * await vaultAdapter.create('my-vault-name', {
291
- * scopeBoundary: SCOPE_BOUNDARY.GROUP,
292
- * scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
293
- * }, {
294
- * set: { foo: 'bar' }
295
- * });
296
- *
297
- * @param name Name of the vault
298
- * @param scope Scope associated with your vault
299
- * @param scope.scopeBoundary Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
300
- * @param scope.scopeKey Scope key, a unique identifier tied to the scope. E.g., if your `scopeBoundary` is `GROUP`, your `scopeKey` will be your `groupKey`; for `EPISODE`, `episodeKey`, etc.
301
- * @param [scope.userKey] Optional key to scope the vault to a user
302
- * @param items Items to set, push, or pop in the vault
303
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
304
- * @param [optionals.readLock] Role allowed to read
305
- * @param [optionals.writeLock] Role allowed to write
306
- * @param [optionals.ttlSeconds] Life span of the vault -- default to null, minimum value of 1800 (30 minutes)
307
- * @param [optionals.mutationStrategy] Mutation strategy: ALLOW (upsert), DISALLOW (insert without update), ERROR (insert with conflict exception if exists)
308
- * @returns promise that resolves to the created vault
309
- */
310
- async function create(name, scope, items, optionals = {}) {
311
- console.warn('DEPRECATION WARNING: vaultAdapter.create is deprecated and will be removed with the next release. Use vaultAdapter.define instead.');
312
- return await define(name, scope, {
313
- items,
314
- ...optionals
315
- });
316
- }
317
-
318
- /**
319
- * Searches for vaults that match the search options; not paginable (hence named 'list' and not 'query')
320
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vault/search`
321
- *
322
- * @example
323
- * import { vaultAdapter } from 'epicenter-libs';
324
- * vaultAdapter.list({
325
- * filter: [
326
- * 'name|=vault-one|vault-two', // looks for any vaults with the names provided
327
- * 'scopeBoundary=WORLD', // looks for vaults scoped to a world
328
- * 'scopeKey=00000165ad4e6a3cd22b993340b963820239', // used in conjunction with the scopeBoundary
329
- * ],
330
- * sort: ['+vault.created'], // sort all findings by the 'created' field (ascending)
331
- * first: 3, // page should start with the 4th item found (defaults to 0)
332
- * max: 10, // page should only include the first 10 items
333
- * }, {
334
- * groupName: 'my-group-name', // search within a group
335
- * });
336
- *
337
- * @param searchOptions Search options
338
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
339
- * @param [optionals.groupName] Name of the group
340
- * @returns promise that resolves to an array of vaults that match the search options
341
- */
342
- async function list(searchOptions, optionals = {}) {
343
- const {
344
- first,
345
- filter,
346
- max
347
- } = searchOptions;
348
- const searchParams = {
349
- filter: parseFilterInput(filter),
350
- first,
351
- max
352
- };
353
- const {
354
- groupName,
355
- ...routingOptions
356
- } = optionals;
357
- return new Router().withSearchParams(searchParams).get(`/vault/search${groupName ? `/${groupName}` : ''}`, routingOptions).then(({
358
- body
359
- }) => body);
360
- }
361
-
362
- /**
363
- * Counts the number of vaults that match the search options
364
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vault/count`
365
- *
366
- * @example
367
- * import { vaultAdapter } from 'epicenter-libs';
368
- * vaultAdapter.count({
369
- * filter: [
370
- * 'name|=vault-one|vault-two', // looks for any vaults with the names provided
371
- * 'scopeBoundary=WORLD', // looks for vaults scoped to a world
372
- * 'scopeKey=00000165ad4e6a3cd22b993340b963820239', // used in conjunction with the scopeBoundary
373
- * ],
374
- * }, {
375
- * groupName: 'my-group-name', // search within a group
376
- * });
377
- *
378
- * @param searchOptions Search options
379
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
380
- * @param [optionals.groupName] Name of the group
381
- * @returns promise that resolves to the number of vaults that match the search options
382
- */
383
- async function count(searchOptions, optionals = {}) {
384
- const {
385
- first,
386
- filter,
387
- max
388
- } = searchOptions;
389
- const searchParams = {
390
- filter: parseFilterInput(filter),
391
- first,
392
- max
393
- };
394
- const {
395
- groupName,
396
- ...routingOptions
397
- } = optionals;
398
- return new Router().withSearchParams(searchParams).get(`/vault/count${groupName ? `/${groupName}` : ''}`, routingOptions).then(({
399
- body
400
- }) => body);
401
- }
402
-
403
- export { byName, count, create, define, get, list, remove, update, updateProperties, withScope };
@@ -1,249 +0,0 @@
1
- import EpicenterError from '../utils/error.js';
2
- import { parseFilterInput } from '../utils/filter-parser.js';
3
- import { deleteVideoByKey, getVideoSearch, getVideoURLWith, getVideoURLByKey, getVideoDirectoryWith, getVideoDirectoryByKey, postVideoProcessor, downloadVideoWith, downloadVideoByKey } from '../apis/video.js';
4
-
5
- /**
6
- * Deletes a video (and its associated files)
7
- * Base URL: DELETE `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/video/{VIDEO_KEY}`
8
- *
9
- * @example
10
- * import { videoAdapter } from 'epicenter-libs';
11
- * await videoAdapter.remove(videoKey);
12
- *
13
- * @param videoKey Video key
14
- * @param [optionals] Optional arguments; pass network call options overrides here.
15
- * @returns promise that resolves to undefined when successful
16
- */
17
- async function remove(videoKey, optionals = {}) {
18
- return deleteVideoByKey(videoKey, optionals);
19
- }
20
-
21
- /**
22
- * Open search for video objects
23
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/video/search`
24
- *
25
- * @example
26
- * import { videoAdapter } from 'epicenter-libs';
27
- * const videos = await videoAdapter.query({
28
- * filter: [
29
- * 'affiliate=VONAGE', // searches for videos provided by the Vonage affiliate
30
- * 'episodeName=myEpisode', // searches for videos tied to the episode with name 'myEpisode'
31
- * 'created>=2022-01-03T20:30:53.054Z', // searches for videos created after Jan 3rd 2022
32
- * ],
33
- * sort: ['+video.created'], // sort all findings by the 'created' field (ascending)
34
- * first: 0,
35
- * max: 25,
36
- * });
37
- *
38
- * @param searchOptions Search options
39
- * @param [optionals] Optional arguments; pass network call options overrides here.
40
- * @returns promise that resolves to a page of video objects
41
- */
42
- async function query(searchOptions, optionals = {}) {
43
- const {
44
- filter,
45
- sort = [],
46
- first,
47
- max
48
- } = searchOptions;
49
- const searchParams = {
50
- filter: parseFilterInput(filter),
51
- sort: sort.join(';') || undefined,
52
- first,
53
- max
54
- };
55
- return getVideoSearch({
56
- query: searchParams,
57
- paginated: true,
58
- ...optionals
59
- });
60
- }
61
-
62
- /**
63
- * Gets a URL for a video file
64
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/video/url/{VIDEO_KEY}/{FILE}` or GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/video/url/with/{SCOPE_BOUNDARY}/{SCOPE_KEY}/{AFFILIATE}/{FAMILY}/{FILE}`
65
- *
66
- * @example
67
- * import { videoAdapter } from 'epicenter-libs';
68
- *
69
- * // get using video key
70
- * videoAdapter.getURL('archive.mp4', {
71
- * videoKey: '0000017e31bb902cfe17615867d5005c5d5f',
72
- * });
73
- *
74
- * // get using scope/affiliate/family
75
- * videoAdapter.getURL('archive.mp4', {
76
- * scope: {
77
- * scopeBoundary: SCOPE_BOUNDARY.GROUP,
78
- * scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
79
- * },
80
- * affiliate: 'VONAGE',
81
- * family: 'archiveName'
82
- * });
83
- *
84
- * @param file Name of the file
85
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
86
- * @param [optionals.scope] Scope object
87
- * @param [optionals.scope.scopeBoundary] Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
88
- * @param [optionals.scope.scopeKey] Scope key, a unique identifier tied to the scope. E.g., if your `scopeBoundary` is `GROUP`, your `scopeKey` will be your `groupKey`; for `EPISODE`, `episodeKey`, etc.
89
- * @param [optionals.scope.userKey] User attached to scope if necessary
90
- * @param [optionals.affiliate] Affiliate -- only support for one for now: Vonage
91
- * @param [optionals.family] Identifier for the resourced provided by the affiliate (in the case of Vonage, this is the archive name).
92
- * @param [optionals.videoKey] Key for the video object
93
- * @returns promise that resolves to the URL string for the video file
94
- */
95
- async function getURL(file, optionals = {}) {
96
- const {
97
- scope,
98
- affiliate,
99
- family,
100
- videoKey,
101
- ...routingOptions
102
- } = optionals;
103
- if (scope && family && affiliate) {
104
- return getVideoURLWith(file, family, affiliate, scope, routingOptions);
105
- }
106
- if (videoKey) {
107
- return getVideoURLByKey(file, videoKey, routingOptions);
108
- }
109
- throw new EpicenterError('Cannot get video URL -- either a video key or scope/affiliate/family specification is required.');
110
- }
111
-
112
- /**
113
- * Gets a directory URL for a video file
114
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/video/dir/{VIDEO_KEY}` or GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/video/dir/with/{SCOPE_BOUNDARY}/{SCOPE_KEY}/{AFFILIATE}/{FAMILY}`
115
- *
116
- * @example
117
- * import { videoAdapter } from 'epicenter-libs';
118
- *
119
- * // get using video key
120
- * videoAdapter.getDirectoryURL({
121
- * videoKey: '0000017e31bb902cfe17615867d5005c5d5f',
122
- * });
123
- *
124
- * // get using scope/affiliate/family
125
- * videoAdapter.getDirectoryURL({
126
- * scope: {
127
- * scopeBoundary: SCOPE_BOUNDARY.GROUP,
128
- * scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
129
- * },
130
- * affiliate: 'VONAGE',
131
- * family: 'archiveName'
132
- * });
133
- *
134
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
135
- * @param [optionals.scope] Scope object
136
- * @param [optionals.scope.scopeBoundary] Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
137
- * @param [optionals.scope.scopeKey] Scope key, a unique identifier tied to the scope. E.g., if your `scopeBoundary` is `GROUP`, your `scopeKey` will be your `groupKey`; for `EPISODE`, `episodeKey`, etc.
138
- * @param [optionals.scope.userKey] User attached to scope if necessary
139
- * @param [optionals.affiliate] Affiliate -- only support for one for now: Vonage
140
- * @param [optionals.family] Identifier for the resourced provided by the affiliate (in the case of Vonage, this is the archive name).
141
- * @param [optionals.videoKey] Key for the video object
142
- * @returns promise that resolves to a video directory object containing file list and metadata
143
- */
144
- async function getDirectoryURL(optionals = {}) {
145
- const {
146
- scope,
147
- affiliate,
148
- family,
149
- videoKey,
150
- ...routingOptions
151
- } = optionals;
152
- if (scope && family && affiliate) {
153
- return getVideoDirectoryWith(family, affiliate, scope, routingOptions);
154
- }
155
- if (videoKey) {
156
- return getVideoDirectoryByKey(videoKey, routingOptions);
157
- }
158
- throw new EpicenterError('Cannot get video URL -- either a video key or scope/affiliate/family specification is required.');
159
- }
160
-
161
- /**
162
- * Processes a video (one example of this is transcribing a video)
163
- * Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/video/execute/{VIDEO_KEY}`
164
- *
165
- * @example
166
- * const processors = [
167
- * {
168
- * mediaFormat: 'mp4',
169
- * languageCode: 'en-US',
170
- * objectType: 'transcription',
171
- * mediaFile: 'archive.mp4',
172
- * jobName: 'test-transcription',
173
- * },
174
- * ];
175
- * await videoAdapter.processVideo(videoKey, processors);
176
- *
177
- * @param videoKey Video key
178
- * @param [processors[]] List of processes to complete
179
- * @param [processors[].jobName] A string to specify the title of the newly file
180
- * @param [processors[].mediaFormat] The format of the file you are processing
181
- * @param [processors[].languageCode] The language which the video is recorded in
182
- * @param [processors[].timeoutMinutes] Optional- how long to wait before the call cancels out; defaults to 3 minutes
183
- * @param [processors[].mediaFile] The name of the media file to perform the process on
184
- * @param [processors[].objectType] The type of processing job to perform (currently limited to transcribe)
185
- * @param [optionals] Optional arguments; pass network call options overrides here.
186
- * @param [optionals.log] Name for log file
187
- * @returns promise that resolves to a boolean indicating success
188
- */
189
- async function processVideo(videoKey, processors, optionals = {}) {
190
- const {
191
- log,
192
- ...routingOptions
193
- } = optionals;
194
- const body = {
195
- processors,
196
- log
197
- };
198
- return postVideoProcessor(videoKey, body, routingOptions);
199
- }
200
-
201
- /**
202
- * Downloads a video file
203
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/video/download/{VIDEO_KEY}/{FILE}` or GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/video/download/with/{SCOPE_BOUNDARY}/{SCOPE_KEY}/{AFFILIATE}/{FAMILY}/{FILE}`
204
- *
205
- * @example
206
- * import { videoAdapter } from 'epicenter-libs';
207
- * // download using video key
208
- * await videoAdapter.download('archive.mp4', {
209
- * videoKey: '0000017e31bb902cfe17615867d5005c5d5f',
210
- * });
211
- * // download using scope/affiliate/family
212
- * await videoAdapter.download('archive.mp4', {
213
- * scope: {
214
- * scopeBoundary: SCOPE_BOUNDARY.GROUP,
215
- * scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
216
- * },
217
- * affiliate: 'VONAGE',
218
- * family: 'archiveName'
219
- * });
220
- *
221
- * @param file Name of the file
222
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
223
- * @param [optionals.scope] Scope object
224
- * @param [optionals.scope.scopeBoundary] Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
225
- * @param [optionals.scope.scopeKey] Scope key, a unique identifier tied to the scope. E.g., if your `scopeBoundary` is `GROUP`, your `scopeKey` will be your `groupKey`; for `EPISODE`, `episodeKey`, etc.
226
- * @param [optionals.scope.userKey] User attached to scope if necessary
227
- * @param [optionals.affiliate] Affiliate -- only support for one for now: Vonage
228
- * @param [optionals.family] Identifier for the resourced provided by the affiliate (in the case of Vonage, this is the archive name).
229
- * @param [optionals.videoKey] Key for the video object
230
- * @returns promise that resolves to undefined when download is complete
231
- */
232
- async function download(file, optionals = {}) {
233
- const {
234
- scope,
235
- affiliate,
236
- family,
237
- videoKey,
238
- ...routingOptions
239
- } = optionals;
240
- if (scope && family && affiliate) {
241
- return downloadVideoWith(file, family, affiliate, scope, routingOptions);
242
- }
243
- if (videoKey) {
244
- return downloadVideoByKey(file, videoKey, routingOptions);
245
- }
246
- throw new EpicenterError('Cannot download video -- either a video key or scope/affiliate/family specification is required.');
247
- }
248
-
249
- export { download, getDirectoryURL, getURL, processVideo, query, remove };