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,154 +0,0 @@
1
- import Router from '../utils/router.js';
2
-
3
- /**
4
- * Adds somebody to an account; somebody is a person who is not a user, but whose information is used in a simulation; requires support level authentication
5
- * Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/somebody`
6
- *
7
- * @example
8
- * import { somebodyAdapter, SCOPE_BOUNDARY } from 'epicenter-libs';
9
- * const email = 'test@test.com';
10
- * const scope = {
11
- * scopeBoundary: SCOPE_BOUNDARY.GROUP,
12
- * scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
13
- * };
14
- * const somebody = await somebodyAdapter.create(email, scope, {
15
- * givenName: 'Person',
16
- * familyName: 'Family',
17
- * });
18
- *
19
- * @param email Email of the person being added
20
- * @param scope Scope associated with the somebody
21
- * @param scope.scopeBoundary Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
22
- * @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.
23
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
24
- * @param [optionals.givenName] Given name of the person
25
- * @param [optionals.familyName] Family name of the person
26
- * @returns promise that resolves to the newly created somebody object
27
- */
28
-
29
- async function create(email, scope, optionals = {}) {
30
- const {
31
- givenName,
32
- familyName,
33
- ...routingOptions
34
- } = optionals;
35
- return await new Router().post('/somebody', {
36
- body: {
37
- email,
38
- givenName,
39
- familyName,
40
- scope
41
- },
42
- ...routingOptions
43
- }).then(({
44
- body
45
- }) => body);
46
- }
47
-
48
- /**
49
- * Gets a somebody by their key
50
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/somebody/{SOMEBODY_KEY}`
51
- *
52
- * @example
53
- * import { somebodyAdapter } from 'epicenter-libs';
54
- * const somebodyKey = '0000017dd3bf540e5ada5b1e058f08f20461';
55
- * const somebody = await somebodyAdapter.get(somebodyKey);
56
- *
57
- * @param somebodyKey Key associated with the somebody
58
- * @param [optionals] Optional arguments; pass network call options overrides here.
59
- * @returns promise that resolves to the somebody object, or undefined if not found
60
- */
61
- const NOT_FOUND = 404;
62
- async function get(somebodyKey, optionals = {}) {
63
- return await new Router().get(`/somebody/${somebodyKey}`, optionals).catch(error => {
64
- if (error.status === NOT_FOUND) return {
65
- body: undefined
66
- };
67
- return Promise.reject(error);
68
- }).then(({
69
- body
70
- }) => body);
71
- }
72
-
73
- /**
74
- * Gets all somebodies within a specific scope
75
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/somebody/in/{SCOPE_BOUNDARY}/{SCOPE_KEY}`
76
- *
77
- * @example
78
- * import { somebodyAdapter, SCOPE_BOUNDARY } from 'epicenter-libs';
79
- * const scope = {
80
- * scopeBoundary: SCOPE_BOUNDARY.GROUP,
81
- * scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
82
- * };
83
- * const somebodies = await somebodyAdapter.inScope(scope, { first: 0, max: 100 });
84
- *
85
- * @param scope Scope associated with the somebodies
86
- * @param scope.scopeBoundary Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
87
- * @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.
88
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
89
- * @param [optionals.first] Index of first result to return
90
- * @param [optionals.max] Maximum number of results to return (max of 300; default of 300)
91
- * @returns promise that resolves to a page of somebody objects, or undefined if not found
92
- */
93
- async function inScope(scope, optionals = {}) {
94
- const {
95
- scopeBoundary,
96
- scopeKey
97
- } = scope;
98
- const {
99
- first,
100
- max,
101
- ...routingOptions
102
- } = optionals;
103
- const searchParams = {
104
- first,
105
- max
106
- };
107
- return await new Router().withSearchParams(searchParams).get(`/somebody/in/${scopeBoundary}/${scopeKey}`, {
108
- paginated: true,
109
- ...routingOptions
110
- }).catch(error => {
111
- if (error.status === NOT_FOUND) return {
112
- body: undefined
113
- };
114
- return Promise.reject(error);
115
- }).then(({
116
- body
117
- }) => body);
118
- }
119
-
120
- /**
121
- * Gets a somebody by their email within a specific scope
122
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/somebody/with/{SCOPE_BOUNDARY}/{SCOPE_KEY}/{EMAIL}`
123
- *
124
- * @example
125
- * import { somebodyAdapter, SCOPE_BOUNDARY } from 'epicenter-libs';
126
- * const scope = {
127
- * scopeBoundary: SCOPE_BOUNDARY.GROUP,
128
- * scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
129
- * };
130
- * const somebody = await somebodyAdapter.byEmail('test@test.com', scope);
131
- *
132
- * @param email Email of the somebody to retrieve
133
- * @param scope Scope associated with the somebody
134
- * @param scope.scopeBoundary Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
135
- * @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.
136
- * @param [optionals] Optional arguments; pass network call options overrides here.
137
- * @returns promise that resolves to the somebody object, or undefined if not found
138
- */
139
- async function byEmail(email, scope, optionals = {}) {
140
- const {
141
- scopeBoundary,
142
- scopeKey
143
- } = scope;
144
- return await new Router().get(`/somebody/with/${scopeBoundary}/${scopeKey}/${email}`, optionals).catch(error => {
145
- if (error.status === NOT_FOUND) return {
146
- body: undefined
147
- };
148
- return Promise.reject(error);
149
- }).then(({
150
- body
151
- }) => body);
152
- }
153
-
154
- export { byEmail, create, get, inScope };
@@ -1,192 +0,0 @@
1
- import Router from '../utils/router.js';
2
-
3
- let RETRY_POLICY = /*#__PURE__*/function (RETRY_POLICY) {
4
- RETRY_POLICY["DO_NOTHING"] = "DO_NOTHING";
5
- // If the task fails, do nothing (this is the default)
6
- RETRY_POLICY["RESCHEDULE"] = "RESCHEDULE";
7
- // If the task fails retry at the next scheduled time point
8
- RETRY_POLICY["FIRE_ON_FAIL_SAFE"] = "FIRE_ON_FAIL_SAFE"; // Will re-execute the task after it fails; how long until this occurs is equal to ttlSeconds
9
- return RETRY_POLICY;
10
- }({});
11
-
12
- // Generic type aliases for task adapter
13
-
14
- // Status type for group status tasks
15
-
16
- // Trigger type definitions for creating tasks
17
-
18
- // Payload type definitions for creating tasks
19
-
20
- // Payload type definitions for reading tasks
21
-
22
- // Task response structure
23
-
24
- /**
25
- * Creates a task; requires support level authentication
26
- * Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/task`
27
- *
28
- * @example
29
- * import { taskAdapter, SCOPE_BOUNDARY } from 'epicenter-libs';
30
- * const scope = {
31
- * scopeBoundary: SCOPE_BOUNDARY.GROUP,
32
- * scopeKey: session.groupKey,
33
- * };
34
- * const name = 'task-1-send-emails';
35
- * const payload = {
36
- * method: 'POST',
37
- * url: 'https://forio.com/app/forio-dev/test-project/send-out-emails',
38
- * };
39
- * const trigger = {
40
- * value: '0 7 15 * * ?', // triggers on day 15 7am of each month
41
- * objectType: 'cron',
42
- * };
43
- * await taskAdapter.create(scope, name, payload, trigger);
44
- *
45
- * @param scope Scope associated with the task
46
- * @param scope.scopeBoundary Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
47
- * @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.
48
- * @param [scope.userKey] Key associated with the user
49
- * @param name Name of the task
50
- * @param payload An HTTP task object that will be executed when the task is triggered
51
- * @param payload.method Type of method to use with the HTTP request (e.g., 'GET', 'POST', 'PATCH')
52
- * @param payload.url The URL the HTTP request will be sent to
53
- * @param [payload.body] The body of the HTTP request
54
- * @param [payload.headers] Headers to send along with the HTTP request
55
- * @param trigger Object that determines when to run the task (cron, offset, or date)
56
- * @param [trigger.value] For cron: cron expression (e.g., '0 7 * * * ?'). For date: ISO-8601 date-time string
57
- * @param [trigger.objectType] Type of trigger: 'cron', 'offset', or 'date'
58
- * @param [trigger.minutes] For offset triggers: number of minutes until the task triggers
59
- * @param [trigger.hours] For offset triggers: number of hours until the task triggers
60
- * @param [trigger.days] For offset triggers: number of days until the task triggers
61
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
62
- * @param [optionals.accountShortName] Name of account (by default will be the account associated with the session)
63
- * @param [optionals.projectShortName] Name of project (by default will be the project associated with the session)
64
- * @param [optionals.retryPolicy] Specifies what to do should the task fail; see RETRY_POLICY
65
- * @param [optionals.failSafeTermination] The ISO-8601 date-time when the task will be deleted regardless of any triggers; defaults to null
66
- * @param [optionals.ttlSeconds] Max life expectancy of the task; used to determine if retrying the task is necessary
67
- * @returns promise that resolves to the task object including the taskKey
68
- */
69
- async function create(scope, name, payload, trigger, optionals = {}) {
70
- const {
71
- retryPolicy,
72
- failSafeTermination,
73
- ttlSeconds,
74
- ...routingOptions
75
- } = optionals;
76
- return await new Router().post('/task', {
77
- body: {
78
- payload: {
79
- objectType: 'http',
80
- ...payload
81
- },
82
- trigger,
83
- retryPolicy,
84
- failSafeTermination,
85
- ttlSeconds,
86
- scope,
87
- name
88
- },
89
- ...routingOptions
90
- }).then(({
91
- body
92
- }) => body);
93
- }
94
-
95
- /**
96
- * Deletes a task (changes status to cancelled); requires support level authentication
97
- * Base URL: DELETE `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/task/{TASK_KEY}`
98
- *
99
- * @example
100
- * import { taskAdapter } from 'epicenter-libs';
101
- * const taskKey = '0000017dd3bf540e5ada5b1e058f08f20461';
102
- * await taskAdapter.destroy(taskKey);
103
- *
104
- * @param taskKey Unique key associated with a task
105
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
106
- * @param [optionals.accountShortName] Name of account (by default will be the account associated with the session)
107
- * @param [optionals.projectShortName] Name of project (by default will be the project associated with the session)
108
- * @returns promise that resolves to undefined when successful
109
- */
110
- async function destroy(taskKey, optionals = {}) {
111
- return await new Router().delete(`/task/${taskKey}`, optionals).then(({
112
- body
113
- }) => body);
114
- }
115
-
116
- /**
117
- * Gets a task by taskKey; requires support level authentication
118
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/task/{TASK_KEY}`
119
- *
120
- * @example
121
- * import { taskAdapter } from 'epicenter-libs';
122
- * const taskKey = '0000017dd3bf540e5ada5b1e058f08f20461';
123
- * const task = await taskAdapter.get(taskKey);
124
- *
125
- * @param taskKey Unique key associated with a task
126
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
127
- * @param [optionals.accountShortName] Name of account (by default will be the account associated with the session)
128
- * @param [optionals.projectShortName] Name of project (by default will be the project associated with the session)
129
- * @returns promise that resolves to the task object
130
- */
131
- async function get(taskKey, optionals = {}) {
132
- return await new Router().get(`/task/${taskKey}`, optionals).then(({
133
- body
134
- }) => body);
135
- }
136
-
137
- /**
138
- * Gets the history (100 most recent times it has triggered) of a task by taskKey; requires support level authentication
139
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/task/history/{TASK_KEY}`
140
- *
141
- * @example
142
- * import { taskAdapter } from 'epicenter-libs';
143
- * const taskKey = '0000017dd3bf540e5ada5b1e058f08f20461';
144
- * const history = await taskAdapter.getHistory(taskKey);
145
- *
146
- * @param taskKey Unique key associated with a task
147
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
148
- * @param [optionals.accountShortName] Name of account (by default will be the account associated with the session)
149
- * @param [optionals.projectShortName] Name of project (by default will be the project associated with the session)
150
- * @returns promise that resolves to an array of task history objects
151
- */
152
- async function getHistory(taskKey, optionals = {}) {
153
- return await new Router().get(`/task/history/${taskKey}`, optionals).then(({
154
- body
155
- }) => body);
156
- }
157
-
158
- /**
159
- * Gets most recent 100 tasks related to the selected scope; requires support level authentication
160
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/task/in/{SCOPE_BOUNDARY}/{SCOPE_KEY}` or GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/task/in/{SCOPE_BOUNDARY}/{SCOPE_KEY}/{USER_KEY}`
161
- *
162
- * Note: Will retrieve all tasks that were CREATED in the specified scope. If something was created with episode scope, it will not be retrievable through group scoping.
163
- *
164
- * @example
165
- * import { taskAdapter, SCOPE_BOUNDARY } from 'epicenter-libs';
166
- * const scope = {
167
- * scopeBoundary: SCOPE_BOUNDARY.GROUP,
168
- * scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
169
- * };
170
- * const tasks = await taskAdapter.getTaskIn(scope);
171
- *
172
- * @param scope Scope associated with the tasks
173
- * @param scope.scopeBoundary Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
174
- * @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.
175
- * @param [scope.userKey] Key associated with the user; will retrieve tasks in the scope that were made by the specified user
176
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
177
- * @param [optionals.accountShortName] Name of account (by default will be the account associated with the session)
178
- * @param [optionals.projectShortName] Name of project (by default will be the project associated with the session)
179
- * @returns promise that resolves to an array of task objects
180
- */
181
- async function getTaskIn(scope, optionals = {}) {
182
- const {
183
- scopeBoundary,
184
- scopeKey,
185
- userKey
186
- } = scope;
187
- return await new Router().get(`/task/in/${scopeBoundary}/${scopeKey}${userKey ? `/${userKey}` : ''}`, optionals).then(({
188
- body
189
- }) => body);
190
- }
191
-
192
- export { RETRY_POLICY, create, destroy, get, getHistory, getTaskIn };
@@ -1,28 +0,0 @@
1
- import Router from '../utils/router.js';
2
-
3
- /**
4
- * Fetches the current server time
5
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/time`
6
- *
7
- * @example
8
- * import { timeAdapter } from 'epicenter-libs';
9
- * const serverTime = await timeAdapter.get();
10
- *
11
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
12
- * @param [optionals.accountShortName] Name of account (by default will be the account associated with the session)
13
- * @param [optionals.projectShortName] Name of project (by default will be the project associated with the session)
14
- * @returns promise that resolves to the current server time in ISO 8601 format, or undefined if not found
15
- */
16
- const NOT_FOUND = 404;
17
- async function get(optionals = {}) {
18
- return await new Router().get('/time', optionals).catch(error => {
19
- if (error.status === NOT_FOUND) return {
20
- body: undefined
21
- };
22
- return Promise.reject(error);
23
- }).then(({
24
- body
25
- }) => body);
26
- }
27
-
28
- export { get };
@@ -1,105 +0,0 @@
1
- import Router from '../utils/router.js';
2
-
3
- // Generic type alias for SSO realm data
4
-
5
- /**
6
- * Upload a CSV file to create multiple users
7
- * Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/user/upload`
8
- *
9
- * @example
10
- * import { userAdapter } from 'epicenter-libs';
11
- * const file = new File([csvContent], 'users.csv');
12
- * const report = await userAdapter.uploadCSV(file, { overwrite: true });
13
- *
14
- * @param file CSV file containing user data
15
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
16
- * @param [optionals.overwrite] If true, overwrites existing users with matching identifiers; defaults to false
17
- * @returns promise that resolves to a report containing created, updated, and discarded users
18
- */
19
- async function uploadCSV(file, optionals = {}) {
20
- const {
21
- overwrite,
22
- ...routingOptions
23
- } = optionals;
24
- const formdata = new FormData();
25
- formdata.append('file', file);
26
- return await new Router().withSearchParams({
27
- overwrite
28
- }).post('/user/upload', {
29
- body: formdata,
30
- ...routingOptions
31
- }).then(({
32
- body
33
- }) => body);
34
- }
35
-
36
- /**
37
- * Create a new user (native or external).
38
- * Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/user`
39
- *
40
- * @example
41
- * import { userAdapter } from 'epicenter-libs';
42
- * // Create a native user
43
- * const user = await userAdapter.createUser({
44
- * objectType: 'native',
45
- * handle: 'john.doe',
46
- * displayName: 'John Doe',
47
- * email: 'john@example.com',
48
- * });
49
- *
50
- * @param view User data to create; can be either a native or external user
51
- * @param [optionals] Optional arguments; pass network call options overrides here.
52
- * @returns promise that resolves to the created user
53
- */
54
- async function createUser(view, optionals = {}) {
55
- return await new Router().post('/user', {
56
- body: view,
57
- ...optionals
58
- }).then(({
59
- body
60
- }) => body);
61
- }
62
-
63
- /**
64
- * Gets a specific user.
65
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/user/{USER_KEY}`
66
- *
67
- * @example
68
- * import { userAdapter } from 'epicenter-libs';
69
- * const user = await userAdapter.get('00000179b4d3fb0c84f822df8cd2aa53be25');
70
- *
71
- * @param userKey The user key
72
- * @param [optionals] Optional arguments; pass network call options overrides here.
73
- * @returns promise that resolves to a user
74
- */
75
- async function get(userKey, optionals = {}) {
76
- return await new Router().get(`/user/${userKey}`, optionals).then(({
77
- body
78
- }) => body);
79
- }
80
-
81
- /**
82
- * Gets a specific user by their handle.
83
- * Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/user/with/{HANDLE}` or GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/user/with/{HANDLE}/{MODALITY}`
84
- *
85
- * @example
86
- * import { userAdapter } from 'epicenter-libs';
87
- * const user = await userAdapter.getWithHandle('john.doe@example.com', { modality: 'email' });
88
- *
89
- * @param handle Handle of the user to retrieve
90
- * @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
91
- * @param [optionals.modality] Modality to filter by (e.g., 'email', 'sms')
92
- * @returns promise that resolves to a user
93
- */
94
- async function getWithHandle(handle, optionals = {}) {
95
- const {
96
- modality,
97
- ...routingOptions
98
- } = optionals;
99
- const uriComponent = modality ? `/${modality}` : '';
100
- return await new Router().get(`/user/with/${handle}${uriComponent}`, routingOptions).then(({
101
- body
102
- }) => body);
103
- }
104
-
105
- export { createUser, get, getWithHandle, uploadCSV };