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.
- package/CHANGELOG.md +17 -0
- package/dist/browser/epicenter.js +105 -2
- package/dist/browser/epicenter.js.map +1 -1
- package/dist/cjs/epicenter.js +105 -2
- package/dist/cjs/epicenter.js.map +1 -1
- package/dist/epicenter.js +105 -2
- 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 +105 -2
- package/dist/module/epicenter.js.map +1 -1
- package/dist/types/adapters/chat.d.ts +63 -0
- package/package.json +1 -1
- package/src/adapters/chat.ts +95 -0
- package/src/utils/identification.ts +4 -0
- package/dist/test/_virtual/runtime.js +0 -3
- package/dist/test/_virtual/runtime2.js +0 -3
- package/dist/test/adapters/account.js +0 -169
- package/dist/test/adapters/admin.js +0 -53
- package/dist/test/adapters/asset.js +0 -425
- package/dist/test/adapters/authentication.js +0 -349
- package/dist/test/adapters/channel.js +0 -201
- package/dist/test/adapters/chat.js +0 -199
- package/dist/test/adapters/cometd.js +0 -514
- package/dist/test/adapters/consensus.js +0 -484
- package/dist/test/adapters/daily.js +0 -244
- package/dist/test/adapters/email.js +0 -179
- package/dist/test/adapters/episode.js +0 -175
- package/dist/test/adapters/group.js +0 -655
- package/dist/test/adapters/leaderboard.js +0 -162
- package/dist/test/adapters/matchmaker.js +0 -159
- package/dist/test/adapters/presence.js +0 -85
- package/dist/test/adapters/project.js +0 -94
- package/dist/test/adapters/recaptcha.js +0 -24
- package/dist/test/adapters/run.js +0 -1008
- package/dist/test/adapters/somebody.js +0 -154
- package/dist/test/adapters/task.js +0 -192
- package/dist/test/adapters/time.js +0 -28
- package/dist/test/adapters/user.js +0 -105
- package/dist/test/adapters/vault.js +0 -403
- package/dist/test/adapters/video.js +0 -249
- package/dist/test/adapters/vonage.js +0 -130
- package/dist/test/adapters/wallet.js +0 -130
- package/dist/test/adapters/world.js +0 -507
- package/dist/test/apis/video.js +0 -294
- package/dist/test/apis/vonage.js +0 -121
- package/dist/test/epicenter.js +0 -121
- package/dist/test/node_modules/@babel/runtime/helpers/esm/defineProperty.js +0 -12
- package/dist/test/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +0 -14
- package/dist/test/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +0 -9
- package/dist/test/node_modules/@babel/runtime/helpers/esm/typeof.js +0 -11
- package/dist/test/node_modules/cometd/AckExtension.js +0 -91
- package/dist/test/node_modules/cometd/CallbackPollingTransport.js +0 -148
- package/dist/test/node_modules/cometd/Client.js +0 -2160
- package/dist/test/node_modules/cometd/Extension.js +0 -47
- package/dist/test/node_modules/cometd/LongPollingTransport.js +0 -135
- package/dist/test/node_modules/cometd/ReloadExtension.js +0 -214
- package/dist/test/node_modules/cometd/RequestTransport.js +0 -252
- package/dist/test/node_modules/cometd/Transport.js +0 -167
- package/dist/test/node_modules/cometd/TransportRegistry.js +0 -107
- package/dist/test/node_modules/cometd/WebSocketTransport.js +0 -384
- package/dist/test/node_modules/cometd/cometd.js +0 -9
- package/dist/test/node_modules/regenerator-runtime/runtime.js +0 -773
- package/dist/test/utilities.js +0 -17
- package/dist/test/utils/config.js +0 -189
- package/dist/test/utils/constants.js +0 -293
- package/dist/test/utils/cookies.js +0 -75
- package/dist/test/utils/error-manager.js +0 -57
- package/dist/test/utils/error.js +0 -12
- package/dist/test/utils/fault.js +0 -34
- package/dist/test/utils/filter-parser.js +0 -68
- package/dist/test/utils/helpers.js +0 -9
- package/dist/test/utils/identification.js +0 -161
- package/dist/test/utils/result.js +0 -20
- package/dist/test/utils/router.js +0 -551
- package/dist/test/utils/store.js +0 -79
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import Router from '../utils/router.js';
|
|
2
|
-
import { parseFilterInput } from '../utils/filter-parser.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Updates the permissions of a chat
|
|
6
|
-
* Base URL: PATCH `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/chat/{CHAT_KEY}`
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* import { chatAdapter, ROLE } from 'epicenter-libs';
|
|
10
|
-
* await chatAdapter.updatePermit('0000017dd3bf540e5ada5b1e058f08f20461', {
|
|
11
|
-
* readLock: ROLE.PARTICIPANT,
|
|
12
|
-
* writeLock: ROLE.FACILITATOR,
|
|
13
|
-
* });
|
|
14
|
-
*
|
|
15
|
-
* @param chatKey Key associated with the chat
|
|
16
|
-
* @param permit Permit object with the updated permissions
|
|
17
|
-
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
18
|
-
* @returns promise that resolves to the updated chat
|
|
19
|
-
*/
|
|
20
|
-
async function updatePermit(chatKey, permit, optionals = {}) {
|
|
21
|
-
return new Router().patch(`/chat/${chatKey}`, {
|
|
22
|
-
...optionals,
|
|
23
|
-
body: {
|
|
24
|
-
permit
|
|
25
|
-
}
|
|
26
|
-
}).then(({
|
|
27
|
-
body
|
|
28
|
-
}) => body);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Creates a chat
|
|
33
|
-
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/chat`
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* import { chatAdapter, SCOPE_BOUNDARY, ROLE } from 'epicenter-libs';
|
|
37
|
-
* const chat = await chatAdapter.create(
|
|
38
|
-
* 'my-chat-room',
|
|
39
|
-
* { scopeBoundary: SCOPE_BOUNDARY.GROUP, scopeKey: '00000165ad4e6a3cd22b993340b963820239' },
|
|
40
|
-
* { readLock: ROLE.PARTICIPANT, writeLock: ROLE.PARTICIPANT }
|
|
41
|
-
* );
|
|
42
|
-
*
|
|
43
|
-
* @param room Name of the chat
|
|
44
|
-
* @param scope Scope of the chat; will not accept user scope
|
|
45
|
-
* @param scope.scopeBoundary Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
|
|
46
|
-
* @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.
|
|
47
|
-
* @param permit Permissions for the chat
|
|
48
|
-
* @param permit.readLock Role allowed to read
|
|
49
|
-
* @param permit.writeLock Role allowed to write
|
|
50
|
-
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
51
|
-
* @returns promise that resolves to the newly created chat
|
|
52
|
-
*/
|
|
53
|
-
async function create(room, scope, permit, optionals = {}) {
|
|
54
|
-
return new Router().post('/chat', {
|
|
55
|
-
body: {
|
|
56
|
-
scope: {
|
|
57
|
-
scopeBoundary: scope.scopeBoundary,
|
|
58
|
-
scopeKey: scope.scopeKey
|
|
59
|
-
},
|
|
60
|
-
permit,
|
|
61
|
-
room
|
|
62
|
-
},
|
|
63
|
-
...optionals
|
|
64
|
-
}).then(({
|
|
65
|
-
body
|
|
66
|
-
}) => body);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Gets a chat
|
|
71
|
-
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/chat/{CHAT_KEY}`
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* import { chatAdapter } from 'epicenter-libs';
|
|
75
|
-
* const chat = await chatAdapter.get('00000165ad4e6a3cd22b993340b963820239');
|
|
76
|
-
*
|
|
77
|
-
* @param chatKey Key of the associated chat
|
|
78
|
-
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
79
|
-
* @returns promise that resolves to the chat
|
|
80
|
-
*/
|
|
81
|
-
async function get(chatKey, optionals = {}) {
|
|
82
|
-
return new Router().get(`/chat/${chatKey}`, optionals).then(({
|
|
83
|
-
body
|
|
84
|
-
}) => body);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Open search for chats, returns a page
|
|
89
|
-
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/chat/search`
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* import { chatAdapter } from 'epicenter-libs';
|
|
93
|
-
* const page = await chatAdapter.query({
|
|
94
|
-
* filter: [
|
|
95
|
-
* 'room|=my-chat-room|my-other-chat|room-three', // looks for any rooms with the names provided
|
|
96
|
-
* 'scopeBoundary=GROUP', // keeps the search within the group scope
|
|
97
|
-
* 'scopeKey=00000165ad4e6a3cd22b993340b963820239', // used in conjunction with the scopeBoundary
|
|
98
|
-
* 'chatKey=0000017dd3bf540e5ada5b1e058f08f20461', // searches for a specific chat
|
|
99
|
-
* 'created>=2022-01-03T20:30:53.054Z', // looks for any chats created after Jan 3rd 2022
|
|
100
|
-
* ],
|
|
101
|
-
* sort: ['+chat.created'], // sort all findings by the 'created' field (ascending)
|
|
102
|
-
* first: 3, // page should start with the 4th item found (defaults to 0)
|
|
103
|
-
* max: 10, // page should only include the first 10 items
|
|
104
|
-
* });
|
|
105
|
-
*
|
|
106
|
-
* @param searchOptions Search options for the query
|
|
107
|
-
* @param [searchOptions.filter] Filters for searching
|
|
108
|
-
* @param [searchOptions.sort] Sorting criteria
|
|
109
|
-
* @param [searchOptions.first] The starting index of the page returned
|
|
110
|
-
* @param [searchOptions.max] The number of entries per page
|
|
111
|
-
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
112
|
-
* @returns promise that resolves to a page of chats
|
|
113
|
-
*/
|
|
114
|
-
async function query(searchOptions, optionals = {}) {
|
|
115
|
-
const {
|
|
116
|
-
filter,
|
|
117
|
-
sort = [],
|
|
118
|
-
first = 0,
|
|
119
|
-
max
|
|
120
|
-
} = searchOptions;
|
|
121
|
-
const searchParams = {
|
|
122
|
-
filter: parseFilterInput(filter),
|
|
123
|
-
sort: sort.join(';') || undefined,
|
|
124
|
-
first,
|
|
125
|
-
max
|
|
126
|
-
};
|
|
127
|
-
return await new Router().withSearchParams(searchParams).get('/chat/search', {
|
|
128
|
-
paginated: true,
|
|
129
|
-
...optionals
|
|
130
|
-
}).then(({
|
|
131
|
-
body
|
|
132
|
-
}) => body);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Sends a message to a chat
|
|
137
|
-
* Base URL: PUT `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/chat/message/{CHAT_KEY}` or PUT `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/chat/message/{CHAT_KEY}/{USER_KEY}`
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* import { chatAdapter } from 'epicenter-libs';
|
|
141
|
-
* // Send a public message to the chat
|
|
142
|
-
* await chatAdapter.sendMessage('0000017dd3bf540e5ada5b1e058f08f20461', 'hello');
|
|
143
|
-
* // Send a private message to a specific user
|
|
144
|
-
* await chatAdapter.sendMessage('0000017dd3bf540e5ada5b1e058f08f20461', 'hello, privately', { userKey: '000001796733eef0842f4d6d960997018a33' });
|
|
145
|
-
*
|
|
146
|
-
* @param chatKey Key associated with the chat
|
|
147
|
-
* @param message Message text to send
|
|
148
|
-
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
149
|
-
* @param [optionals.userKey] Key of the user to send the message to. If omitted, will send as a public message
|
|
150
|
-
* @returns promise that resolves to the chat message created
|
|
151
|
-
*/
|
|
152
|
-
async function sendMessage(chatKey, message, optionals = {}) {
|
|
153
|
-
const {
|
|
154
|
-
userKey,
|
|
155
|
-
...routingOptions
|
|
156
|
-
} = optionals;
|
|
157
|
-
const uriComponent = userKey ? `/${userKey}` : '';
|
|
158
|
-
return new Router().put(`/chat/message/${chatKey}${uriComponent}`, {
|
|
159
|
-
body: {
|
|
160
|
-
message
|
|
161
|
-
},
|
|
162
|
-
...routingOptions
|
|
163
|
-
}).then(({
|
|
164
|
-
body
|
|
165
|
-
}) => body);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Retrieves messages from for a given chat
|
|
170
|
-
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/chat/message/{CHAT_KEY}`
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* import { chatAdapter } from 'epicenter-libs';
|
|
174
|
-
* // gets the chat message with id: 5
|
|
175
|
-
* const message = await chatAdapter.getMessages('0000017dd3bf540e5ada5b1e058f08f20461', { horizon: 5, maxRecords: 1 });
|
|
176
|
-
* // gets the 10 chat messages starting from id 5 (inclusive)
|
|
177
|
-
* const messages = await chatAdapter.getMessages('0000017dd3bf540e5ada5b1e058f08f20461', { horizon: 5, maxRecords: 10 });
|
|
178
|
-
*
|
|
179
|
-
* @param chatKey Key associated with the chat
|
|
180
|
-
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
181
|
-
* @param [optionals.maxRecords] Maximum number of messages to get
|
|
182
|
-
* @param [optionals.horizon] The message ID from which to start with; works backwards so if `maxRecords=20` and `horizon=50`, it will get the 20 messages starting from message ID 50, working backwards (50, 49, 48..., etc.). If this value is omitted the platform assumes it is the most recent message in the chat
|
|
183
|
-
* @returns promise that resolves to the list of chat messages requested
|
|
184
|
-
*/
|
|
185
|
-
async function getMessages(chatKey, optionals = {}) {
|
|
186
|
-
const {
|
|
187
|
-
maxRecords,
|
|
188
|
-
horizon,
|
|
189
|
-
...routingOptions
|
|
190
|
-
} = optionals;
|
|
191
|
-
return new Router().withSearchParams({
|
|
192
|
-
maxRecords,
|
|
193
|
-
horizon
|
|
194
|
-
}).get(`/chat/message/${chatKey}`, routingOptions).then(({
|
|
195
|
-
body
|
|
196
|
-
}) => body);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export { create, get, getMessages, query, sendMessage, updatePermit };
|