@amityco/ts-sdk 6.34.0 → 6.34.1-7808d99.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.
- package/.env +26 -26
- package/dist/@types/domains/client.d.ts +2 -2
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/client/api/createClient.d.ts +2 -1
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/api/isConnected.d.ts.map +1 -1
- package/dist/client/api/logout.d.ts.map +1 -1
- package/dist/client/utils/modifyMqttConnection.d.ts.map +1 -1
- package/dist/core/subscription.d.ts.map +1 -1
- package/dist/index.cjs.js +128 -17
- package/dist/index.esm.js +128 -17
- package/dist/index.umd.js +2 -2
- package/dist/storyRepository/api/createImageStory.d.ts.map +1 -1
- package/dist/storyRepository/api/createVideoStory.d.ts.map +1 -1
- package/dist/storyRepository/internalApi/deleteStory.d.ts.map +1 -1
- package/dist/storyRepository/observers/getActiveStoriesByTarget.d.ts.map +1 -1
- package/dist/storyRepository/observers/getGlobalStoryTargets/GlobalStoryLiveCollectionController.d.ts.map +1 -1
- package/dist/storyRepository/utils/createOptimisticTarget.d.ts +5 -0
- package/dist/storyRepository/utils/createOptimisticTarget.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/@types/domains/client.ts +2 -2
- package/src/client/api/createClient.ts +10 -2
- package/src/client/api/isConnected.ts +4 -1
- package/src/client/api/login.ts +1 -1
- package/src/client/api/logout.ts +6 -5
- package/src/client/utils/modifyMqttConnection.ts +2 -0
- package/src/client/utils/setClientToken.ts +1 -1
- package/src/core/events.ts +2 -2
- package/src/core/subscription.ts +2 -0
- package/src/core/transports/ws.ts +1 -1
- package/src/storyRepository/api/createImageStory.ts +3 -0
- package/src/storyRepository/api/createVideoStory.ts +3 -0
- package/src/storyRepository/internalApi/deleteStory.ts +74 -0
- package/src/storyRepository/observers/getActiveStoriesByTarget.ts +16 -1
- package/src/storyRepository/observers/getGlobalStoryTargets/GlobalStoryLiveCollectionController.ts +14 -2
- package/src/storyRepository/utils/StoryComputedValue.ts +2 -2
- package/src/storyRepository/utils/createOptimisticTarget.ts +46 -0
package/.env
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
LIVE_STREAM_KEY='-----BEGIN PRIVATE KEY-----
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ
|
|
3
|
+
Qb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs
|
|
4
|
+
flbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ
|
|
5
|
+
pXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu
|
|
6
|
+
UVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2
|
|
7
|
+
jZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn
|
|
8
|
+
vuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz
|
|
9
|
+
E6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp
|
|
10
|
+
UgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj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Ta
|
|
25
|
+
9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6
|
|
26
|
+
vF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/
|
|
27
|
+
n0txLHYGHbx+nf95+JUg6lV3hg==
|
|
28
28
|
-----END PRIVATE KEY-----'
|
|
@@ -20,8 +20,8 @@ declare global {
|
|
|
20
20
|
version: string;
|
|
21
21
|
log: Logger;
|
|
22
22
|
http: AxiosInstance;
|
|
23
|
-
mqtt
|
|
24
|
-
ws
|
|
23
|
+
mqtt?: Amity.MqttClient;
|
|
24
|
+
ws?: SocketIOClient.Socket;
|
|
25
25
|
emitter: Emitter<Amity.Events>;
|
|
26
26
|
hasPermission: (permission: string) => Amity.PermissionChecker;
|
|
27
27
|
validateUrls: (urls: string[]) => Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;QAEtD,WAAW,sBAAsB;YAC/B,UAAU,cAAc;YACxB,YAAY,gBAAgB;YAC5B,YAAY,iBAAiB;SAC9B;QAED,WAAW,aAAa;YACtB,aAAa,gBAAgB;YAE7B,YAAY,iBAAiB;YAC7B,WAAW,gBAAgB;YAE3B,aAAa,iBAAiB;YAW9B,UAAU,eAAe;SAC1B;QAED,KAAK,MAAM,GAAG;YACZ,OAAO,EAAE,MAAM,CAAC;YAEhB,GAAG,EAAE,MAAM,CAAC;YACZ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,aAAa,CAAC,CAAC;QAEtF,KAAK,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG;YACxD;;eAEG;YACH,YAAY,EAAE,OAAO,CAAC;YACtB,WAAW,EAAE,OAAO,CAAC;SACtB,CAAC;KACH;CACF"}
|
|
@@ -15,12 +15,13 @@ import { API_REGIONS } from '~/client/utils/endpoints';
|
|
|
15
15
|
*
|
|
16
16
|
* @category Client API
|
|
17
17
|
* */
|
|
18
|
-
export declare const createClient: (apiKey: string, apiRegion?: (typeof API_REGIONS)[keyof typeof API_REGIONS], { debugSession, apiEndpoint, prefixDeviceIdKey, }?: {
|
|
18
|
+
export declare const createClient: (apiKey: string, apiRegion?: (typeof API_REGIONS)[keyof typeof API_REGIONS], { debugSession, apiEndpoint, prefixDeviceIdKey, rteEnabled, }?: {
|
|
19
19
|
debugSession?: string | undefined;
|
|
20
20
|
apiEndpoint?: {
|
|
21
21
|
http?: string | undefined;
|
|
22
22
|
mqtt?: string | undefined;
|
|
23
23
|
} | undefined;
|
|
24
24
|
prefixDeviceIdKey?: string | undefined;
|
|
25
|
+
rteEnabled?: boolean | undefined;
|
|
25
26
|
}) => Amity.Client;
|
|
26
27
|
//# sourceMappingURL=createClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.d.ts","sourceRoot":"","sources":["../../../src/client/api/createClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAc,MAAM,0BAA0B,CAAC;AAsBnE;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,YAAY,WACf,MAAM,cACH,CAAA,kBAAkB,EAAC,MAAM,kBAAkB,CAAC
|
|
1
|
+
{"version":3,"file":"createClient.d.ts","sourceRoot":"","sources":["../../../src/client/api/createClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAc,MAAM,0BAA0B,CAAC;AAsBnE;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,YAAY,WACf,MAAM,cACH,CAAA,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;;;;;;;;MAYtD,MAAM,MAkHR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isConnected.d.ts","sourceRoot":"","sources":["../../../src/client/api/isConnected.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,QAAO,
|
|
1
|
+
{"version":3,"file":"isConnected.d.ts","sourceRoot":"","sources":["../../../src/client/api/isConnected.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,QAAO,OAY9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/client/api/logout.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,QAAa,QAAQ,OAAO,
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/client/api/logout.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,QAAa,QAAQ,OAAO,CAyD9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modifyMqttConnection.d.ts","sourceRoot":"","sources":["../../../src/client/utils/modifyMqttConnection.ts"],"names":[],"mappings":"AAOA,wBAAsB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"modifyMqttConnection.d.ts","sourceRoot":"","sources":["../../../src/client/utils/modifyMqttConnection.ts"],"names":[],"mappings":"AAOA,wBAAsB,oBAAoB,kBAezC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/core/subscription.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,oBAAY,kBAAkB;IAC5B,SAAS,cAAc;I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,YAAY,KAAG,MAA6B,CAAC;AAE5F,eAAO,MAAM,kBAAkB,eAAgB,MAAM,YAAY,KAAG,MAC5C,CAAC;AAEzB,eAAO,MAAM,eAAe,YAAa,MAAM,YAAY,KAAG,MAAsB,CAAC;AAErF,eAAO,MAAM,qBAAqB,iCAG/B,KAAK,MAAM,UAAU,EAAE,WAAW,GAAG,cAAc,CAAC,KAAG,MAIzD,CAAC;AAEF,eAAO,MAAM,sBAAsB,cAIlC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,MAElC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAO,MAI3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,QAAO,MAI9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAO,MAI3C,CAAC;AAKF,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,GACzC,KAAK,CAAC,YAAY,CAOpB"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1349,14 +1349,14 @@ const createEventEmitter = () => {
|
|
|
1349
1349
|
*/
|
|
1350
1350
|
const proxyWebsocketEvents = (ws, emitter) => {
|
|
1351
1351
|
WS_EVENTS.forEach(event => {
|
|
1352
|
-
ws.on(event, (param) => {
|
|
1352
|
+
ws === null || ws === void 0 ? void 0 : ws.on(event, (param) => {
|
|
1353
1353
|
emitter.emit(event, param);
|
|
1354
1354
|
});
|
|
1355
1355
|
});
|
|
1356
1356
|
};
|
|
1357
1357
|
const proxyMqttEvents = (mqttClient, emitter) => {
|
|
1358
1358
|
MQTT_EVENTS.forEach(event => {
|
|
1359
|
-
mqttClient.on(event, (...params) => {
|
|
1359
|
+
mqttClient === null || mqttClient === void 0 ? void 0 : mqttClient.on(event, (...params) => {
|
|
1360
1360
|
emitter.emit(event, params.length === 1 ? params[0] : params);
|
|
1361
1361
|
});
|
|
1362
1362
|
});
|
|
@@ -1414,6 +1414,8 @@ let mqttUserId;
|
|
|
1414
1414
|
async function modifyMqttConnection() {
|
|
1415
1415
|
var _a;
|
|
1416
1416
|
const { mqtt, emitter, token } = getActiveClient();
|
|
1417
|
+
if (!mqtt)
|
|
1418
|
+
return;
|
|
1417
1419
|
const accessToken = (_a = token === null || token === void 0 ? void 0 : token.accessToken) !== null && _a !== void 0 ? _a : '';
|
|
1418
1420
|
const user = getActiveUser();
|
|
1419
1421
|
if (mqttAccessToken !== accessToken || mqttUserId !== user._id) {
|
|
@@ -1524,6 +1526,8 @@ const getSmartFeedMessageTopic = () => {
|
|
|
1524
1526
|
};
|
|
1525
1527
|
function subscribeTopic(topic, callback) {
|
|
1526
1528
|
const { mqtt } = getActiveClient();
|
|
1529
|
+
if (!mqtt)
|
|
1530
|
+
return () => null;
|
|
1527
1531
|
modifyMqttConnection();
|
|
1528
1532
|
return mqtt.subscribe(topic, callback);
|
|
1529
1533
|
}
|
|
@@ -5239,8 +5243,8 @@ class StoryComputedValue {
|
|
|
5239
5243
|
return;
|
|
5240
5244
|
}
|
|
5241
5245
|
const groupByType = stories.reduce((acc, story) => {
|
|
5242
|
-
const { data: { targetId, syncState }, } = story;
|
|
5243
|
-
if (targetId === this._targetId) {
|
|
5246
|
+
const { data: { targetId, syncState, isDeleted }, } = story;
|
|
5247
|
+
if (targetId === this._targetId && !isDeleted) {
|
|
5244
5248
|
acc[syncState] += 1;
|
|
5245
5249
|
}
|
|
5246
5250
|
return acc;
|
|
@@ -7763,7 +7767,8 @@ const setClientToken = async (params) => {
|
|
|
7763
7767
|
isUserDeleted: false,
|
|
7764
7768
|
};
|
|
7765
7769
|
// manually setup the token for ws transport
|
|
7766
|
-
client.ws
|
|
7770
|
+
if (client.ws)
|
|
7771
|
+
client.ws.io.opts.query = { token: accessToken };
|
|
7767
7772
|
client.token = { accessToken, issuedAt, expiresAt };
|
|
7768
7773
|
setSessionState("established" /* Amity.SessionStates.ESTABLISHED */);
|
|
7769
7774
|
return { accessToken, users };
|
|
@@ -8096,12 +8101,13 @@ var objectResolverEngineOnLoginHandler = () => {
|
|
|
8096
8101
|
* @async
|
|
8097
8102
|
*/
|
|
8098
8103
|
const logout = async () => {
|
|
8104
|
+
var _a, _b;
|
|
8099
8105
|
const client = getActiveClient();
|
|
8100
8106
|
client.log('client/api/disconnectClient');
|
|
8101
|
-
if (client.mqtt.connected) {
|
|
8107
|
+
if (client.mqtt && client.mqtt.connected) {
|
|
8102
8108
|
client.mqtt.disconnect();
|
|
8103
8109
|
}
|
|
8104
|
-
if (client.ws.connected) {
|
|
8110
|
+
if (client.ws && client.ws.connected) {
|
|
8105
8111
|
client.ws.disconnect();
|
|
8106
8112
|
}
|
|
8107
8113
|
/*
|
|
@@ -8120,8 +8126,8 @@ const logout = async () => {
|
|
|
8120
8126
|
setSessionState("notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */);
|
|
8121
8127
|
client.emitter.all.clear();
|
|
8122
8128
|
// FIXME: it removes listener in ws.ts, it breaks global ban event
|
|
8123
|
-
client.ws.removeAllListeners();
|
|
8124
|
-
client.mqtt.removeAllListeners();
|
|
8129
|
+
(_a = client.ws) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
|
|
8130
|
+
(_b = client.mqtt) === null || _b === void 0 ? void 0 : _b.removeAllListeners();
|
|
8125
8131
|
client.userId = undefined;
|
|
8126
8132
|
client.token = undefined;
|
|
8127
8133
|
client.http.defaults.headers.common.Authorization = '';
|
|
@@ -8130,7 +8136,8 @@ const logout = async () => {
|
|
|
8130
8136
|
isGlobalBanned: false,
|
|
8131
8137
|
isUserDeleted: false,
|
|
8132
8138
|
};
|
|
8133
|
-
client.ws
|
|
8139
|
+
if (client.ws)
|
|
8140
|
+
client.ws.io.opts.query = { token: '' };
|
|
8134
8141
|
if (typeof document !== 'undefined') {
|
|
8135
8142
|
document.cookie = '_ascSession=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
|
8136
8143
|
}
|
|
@@ -9113,6 +9120,7 @@ async function runMqtt() {
|
|
|
9113
9120
|
* @async
|
|
9114
9121
|
*/
|
|
9115
9122
|
const login = async (params, sessionHandler, config) => {
|
|
9123
|
+
var _a;
|
|
9116
9124
|
const client = getActiveClient();
|
|
9117
9125
|
let unsubWatcher;
|
|
9118
9126
|
client.log('client/api/connectClient', Object.assign({ apiKey: client.apiKey, sessionState: client.sessionState }, params));
|
|
@@ -9147,7 +9155,7 @@ const login = async (params, sessionHandler, config) => {
|
|
|
9147
9155
|
// FIXME: events are duplicated if connectClient is called few times without disconnectClient
|
|
9148
9156
|
// wire websocket events to our event emitter
|
|
9149
9157
|
proxyWebsocketEvents(client.ws, client.emitter);
|
|
9150
|
-
client.ws.open();
|
|
9158
|
+
(_a = client.ws) === null || _a === void 0 ? void 0 : _a.open();
|
|
9151
9159
|
client.userId = user.userId;
|
|
9152
9160
|
client.sessionHandler = sessionHandler;
|
|
9153
9161
|
/*
|
|
@@ -9352,7 +9360,7 @@ const DEFAULT_DEBUG_SESSION = 'amity';
|
|
|
9352
9360
|
*
|
|
9353
9361
|
* @category Client API
|
|
9354
9362
|
* */
|
|
9355
|
-
const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAULT_DEBUG_SESSION, apiEndpoint, prefixDeviceIdKey, } = {}) => {
|
|
9363
|
+
const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAULT_DEBUG_SESSION, apiEndpoint, prefixDeviceIdKey, rteEnabled = true, } = {}) => {
|
|
9356
9364
|
var _a, _b;
|
|
9357
9365
|
const log = createLogger(debugSession);
|
|
9358
9366
|
log('client/api/createClient', {
|
|
@@ -9362,8 +9370,12 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
9362
9370
|
const httpEndpoint = (_a = apiEndpoint === null || apiEndpoint === void 0 ? void 0 : apiEndpoint.http) !== null && _a !== void 0 ? _a : computeUrl('http', apiRegion);
|
|
9363
9371
|
const mqttEndpoint = (_b = apiEndpoint === null || apiEndpoint === void 0 ? void 0 : apiEndpoint.mqtt) !== null && _b !== void 0 ? _b : computeUrl('mqtt', apiRegion);
|
|
9364
9372
|
const http = createHttpTransport(httpEndpoint);
|
|
9365
|
-
|
|
9366
|
-
|
|
9373
|
+
let ws;
|
|
9374
|
+
let mqtt;
|
|
9375
|
+
if (rteEnabled) {
|
|
9376
|
+
ws = createWebsocketTransport(httpEndpoint);
|
|
9377
|
+
mqtt = createMqttTransport(mqttEndpoint);
|
|
9378
|
+
}
|
|
9367
9379
|
const emitter = createEventEmitter();
|
|
9368
9380
|
/*
|
|
9369
9381
|
* Since v6 cache is enabled by default
|
|
@@ -9487,9 +9499,11 @@ const isConnected = () => {
|
|
|
9487
9499
|
var _a, _b;
|
|
9488
9500
|
const client = getActiveClient();
|
|
9489
9501
|
client.log('client/api/isConnected', client);
|
|
9502
|
+
// if client is connected to ws, it means client is connected. If ws is undefined, it means ws is not used.
|
|
9503
|
+
const isWsConnected = (client.ws && client.ws.connected) || !!client.ws;
|
|
9490
9504
|
return !!(client.userId &&
|
|
9491
9505
|
((_b = String((_a = client.http.defaults.headers.common) === null || _a === void 0 ? void 0 : _a.Authorization)) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
9492
|
-
|
|
9506
|
+
isWsConnected);
|
|
9493
9507
|
};
|
|
9494
9508
|
|
|
9495
9509
|
var _GlobalFileAccessType_fileAccessType;
|
|
@@ -25327,7 +25341,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
25327
25341
|
getPoll: getPoll
|
|
25328
25342
|
});
|
|
25329
25343
|
|
|
25330
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
25344
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQN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O\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
|
|
25331
25345
|
/*
|
|
25332
25346
|
* The crypto algorithm used for importing key and signing string
|
|
25333
25347
|
*/
|
|
@@ -25764,6 +25778,30 @@ const createStory = async (payload) => {
|
|
|
25764
25778
|
};
|
|
25765
25779
|
};
|
|
25766
25780
|
|
|
25781
|
+
const createOptimisticTarget = async ({ targetId, targetType, }) => {
|
|
25782
|
+
var _a, _b;
|
|
25783
|
+
const targetCache = pullFromCache([
|
|
25784
|
+
"storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */,
|
|
25785
|
+
'get',
|
|
25786
|
+
targetId,
|
|
25787
|
+
]);
|
|
25788
|
+
if (!targetCache) {
|
|
25789
|
+
let optimisticTarget = {
|
|
25790
|
+
targetId,
|
|
25791
|
+
targetType,
|
|
25792
|
+
};
|
|
25793
|
+
if (targetType === 'community') {
|
|
25794
|
+
const community = await getCommunity$1(targetId);
|
|
25795
|
+
optimisticTarget = Object.assign(Object.assign({}, optimisticTarget), { targetPublicId: community.data.communityId, targetUpdatedAt: (_a = community.data.updatedAt) !== null && _a !== void 0 ? _a : new Date().toISOString() });
|
|
25796
|
+
}
|
|
25797
|
+
if (targetType === 'user') {
|
|
25798
|
+
const user = await getUser$2(targetId);
|
|
25799
|
+
optimisticTarget = Object.assign(Object.assign({}, optimisticTarget), { targetPublicId: user.data.userPublicId, targetUpdatedAt: (_b = user.data.updatedAt) !== null && _b !== void 0 ? _b : new Date().toISOString() });
|
|
25800
|
+
}
|
|
25801
|
+
pushToCache(["storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */, 'get', targetId], optimisticTarget);
|
|
25802
|
+
}
|
|
25803
|
+
};
|
|
25804
|
+
|
|
25767
25805
|
/**
|
|
25768
25806
|
* ```js
|
|
25769
25807
|
* import { StoryRepository } from '@amityco/ts-sdk'
|
|
@@ -25813,6 +25851,7 @@ const createImageStory = async (targetType, targetId, formData, metadata = {}, i
|
|
|
25813
25851
|
throw new Error('Failed to upload image');
|
|
25814
25852
|
const { fileId } = data[0];
|
|
25815
25853
|
payload = Object.assign(Object.assign({}, payload), { data: Object.assign(Object.assign({}, payload.data), { fileId }) });
|
|
25854
|
+
createOptimisticTarget({ targetId, targetType });
|
|
25816
25855
|
// Fire optimistic event - update fileId
|
|
25817
25856
|
createOptimisticEvent({ payload, formData }, optimisticData => {
|
|
25818
25857
|
fireEvent('local.story.created', optimisticData);
|
|
@@ -25866,6 +25905,7 @@ const createVideoStory = async (targetType, targetId, formData, metadata = {}, i
|
|
|
25866
25905
|
pushToCache(["story-sync-state" /* STORY_KEY_CACHE.SYNC_STATE */, targetId], "syncing" /* Amity.SyncState.Syncing */);
|
|
25867
25906
|
// Update local story expires time
|
|
25868
25907
|
pushToCache(["story-expire" /* STORY_KEY_CACHE.EXPIRE */, targetId], new Date(date.setFullYear(date.getFullYear() + 1)));
|
|
25908
|
+
createOptimisticTarget({ targetId, targetType });
|
|
25869
25909
|
// Fire optimistic event
|
|
25870
25910
|
createOptimisticEvent({ payload, formData, isVideo: true }, optimisticData => {
|
|
25871
25911
|
fireEvent('local.story.created', optimisticData);
|
|
@@ -25903,6 +25943,7 @@ const getStoryCache = (storyId) => {
|
|
|
25903
25943
|
};
|
|
25904
25944
|
|
|
25905
25945
|
const deleteStory = async (storyId, permanent = false) => {
|
|
25946
|
+
var _a, _b, _c;
|
|
25906
25947
|
const client = getActiveClient();
|
|
25907
25948
|
client.log('story/deleteStory', storyId);
|
|
25908
25949
|
let cached;
|
|
@@ -25919,6 +25960,57 @@ const deleteStory = async (storyId, permanent = false) => {
|
|
|
25919
25960
|
users: [],
|
|
25920
25961
|
stories: [Object.assign(Object.assign({}, data), { isDeleted: true })],
|
|
25921
25962
|
});
|
|
25963
|
+
/* ------ Unsynced story case ------ */
|
|
25964
|
+
if (data.syncState !== "synced" /* Amity.SyncState.Synced */) {
|
|
25965
|
+
if (permanent) {
|
|
25966
|
+
dropFromCache(["story" /* STORY_KEY_CACHE.STORY */, 'get', storyId]);
|
|
25967
|
+
}
|
|
25968
|
+
else {
|
|
25969
|
+
pushToCache(["story" /* STORY_KEY_CACHE.STORY */, 'get', storyId], Object.assign(Object.assign({}, cached.data), { isDeleted: true }));
|
|
25970
|
+
}
|
|
25971
|
+
const unsyncedStoriesCache = (_a = queryCache([
|
|
25972
|
+
"story" /* STORY_KEY_CACHE.STORY */,
|
|
25973
|
+
'get',
|
|
25974
|
+
])) === null || _a === void 0 ? void 0 : _a.filter(story => story.data.syncState !== "synced" /* Amity.SyncState.Synced */ &&
|
|
25975
|
+
story.data.targetId === data.targetId &&
|
|
25976
|
+
story.data.isDeleted !== true);
|
|
25977
|
+
// update localLastStoryExpiresAt to be the last story expires
|
|
25978
|
+
if (unsyncedStoriesCache && unsyncedStoriesCache.length > 0) {
|
|
25979
|
+
const lastStoryExpires = unsyncedStoriesCache.reduce((acc, story) => {
|
|
25980
|
+
const expireAt = new Date(story.data.expiresAt || 0);
|
|
25981
|
+
return expireAt > acc ? expireAt : acc;
|
|
25982
|
+
}, new Date(0));
|
|
25983
|
+
pushToCache(["story-expire" /* STORY_KEY_CACHE.EXPIRE */, cached.data.targetId], lastStoryExpires.toISOString());
|
|
25984
|
+
}
|
|
25985
|
+
else {
|
|
25986
|
+
// if no unsynced stories, remove last story expires since there is no more story
|
|
25987
|
+
dropFromCache(["story-expire" /* STORY_KEY_CACHE.EXPIRE */, cached.data.targetId]);
|
|
25988
|
+
}
|
|
25989
|
+
return true;
|
|
25990
|
+
}
|
|
25991
|
+
/* ------ Synced story case ------ */
|
|
25992
|
+
const targetCache = (_b = pullFromCache([
|
|
25993
|
+
"storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */,
|
|
25994
|
+
'get',
|
|
25995
|
+
data.targetId,
|
|
25996
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
25997
|
+
const syncedStoriesCache = (_c = queryCache([
|
|
25998
|
+
"story" /* STORY_KEY_CACHE.STORY */,
|
|
25999
|
+
'get',
|
|
26000
|
+
])) === null || _c === void 0 ? void 0 : _c.filter(story => story.data.syncState === "synced" /* Amity.SyncState.Synced */ &&
|
|
26001
|
+
story.data.targetId === data.targetId &&
|
|
26002
|
+
story.data.isDeleted !== true);
|
|
26003
|
+
let lastStoryExpiresAt;
|
|
26004
|
+
if (syncedStoriesCache && syncedStoriesCache.length > 0) {
|
|
26005
|
+
lastStoryExpiresAt = syncedStoriesCache === null || syncedStoriesCache === void 0 ? void 0 : syncedStoriesCache.reduce((acc, story) => {
|
|
26006
|
+
const expireAt = new Date(story.data.expiresAt || 0);
|
|
26007
|
+
return expireAt > acc ? expireAt : acc;
|
|
26008
|
+
}, new Date(0));
|
|
26009
|
+
}
|
|
26010
|
+
// update lastStoryExpiresAt from lastest synced story
|
|
26011
|
+
if (targetCache) {
|
|
26012
|
+
pushToCache(["storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */, 'get', data.targetId], Object.assign(Object.assign({}, targetCache), { lastStoryExpiresAt }));
|
|
26013
|
+
}
|
|
25922
26014
|
}
|
|
25923
26015
|
}
|
|
25924
26016
|
const response = await client.http.delete(`/api/v4/stories/${storyId}`, {
|
|
@@ -26231,6 +26323,7 @@ const getActiveStoriesByTarget = (params, callback) => {
|
|
|
26231
26323
|
});
|
|
26232
26324
|
};
|
|
26233
26325
|
const processNewData = (result, event, initial = false, loading = false, error = false) => {
|
|
26326
|
+
var _a;
|
|
26234
26327
|
const cached = pullFromCache(cacheKey);
|
|
26235
26328
|
const data = {
|
|
26236
26329
|
loading,
|
|
@@ -26249,6 +26342,14 @@ const getActiveStoriesByTarget = (params, callback) => {
|
|
|
26249
26342
|
: [...new Set([...data.data, ...result.map(getResolver('story'))])];
|
|
26250
26343
|
}
|
|
26251
26344
|
}
|
|
26345
|
+
const unSyncedStories = (_a = queryCache(["story" /* STORY_KEY_CACHE.STORY */, 'get'])) === null || _a === void 0 ? void 0 : _a.filter(story => story.data.targetId === params.targetId &&
|
|
26346
|
+
story.data.syncState !== "synced" /* Amity.SyncState.Synced */).map(story => getResolver('story')(story.data));
|
|
26347
|
+
if (unSyncedStories && (unSyncedStories === null || unSyncedStories === void 0 ? void 0 : unSyncedStories.length) > 0) {
|
|
26348
|
+
unSyncedStories.forEach(referenceId => {
|
|
26349
|
+
if (!data.data.includes(referenceId))
|
|
26350
|
+
data.data.push(referenceId);
|
|
26351
|
+
});
|
|
26352
|
+
}
|
|
26252
26353
|
pushToCache(cacheKey, data.data);
|
|
26253
26354
|
responder(data);
|
|
26254
26355
|
};
|
|
@@ -26680,13 +26781,23 @@ class GlobalStoryLiveCollectionController extends LiveCollectionController {
|
|
|
26680
26781
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26681
26782
|
if (!collection)
|
|
26682
26783
|
return;
|
|
26683
|
-
|
|
26784
|
+
const targetIds = collection.data;
|
|
26785
|
+
const cachedTargets = queryCache(["storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */]);
|
|
26786
|
+
if (cachedTargets && (cachedTargets === null || cachedTargets === void 0 ? void 0 : cachedTargets.length) > 0) {
|
|
26787
|
+
cachedTargets === null || cachedTargets === void 0 ? void 0 : cachedTargets.forEach(({ key }) => {
|
|
26788
|
+
if (!collection.data.includes(key[2]))
|
|
26789
|
+
targetIds.push(key[2]);
|
|
26790
|
+
});
|
|
26791
|
+
}
|
|
26792
|
+
let data = targetIds
|
|
26684
26793
|
.map(targetId => pullFromCache(["storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */, 'get', targetId]))
|
|
26685
26794
|
.filter(Boolean)
|
|
26686
26795
|
.map(storyTarget => LinkedObject.storyTarget(storyTarget.data));
|
|
26687
26796
|
if (!this.shouldNotify(data) && origin === 'event')
|
|
26688
26797
|
return;
|
|
26689
26798
|
data = this.applyFilter(data)
|
|
26799
|
+
// exclude story targets with invalid stories
|
|
26800
|
+
.filter(({ localSortingDate }) => !!localSortingDate)
|
|
26690
26801
|
// Remove internal fields
|
|
26691
26802
|
.map((_a) => {
|
|
26692
26803
|
var rest = __rest(_a, ["localFilter", "localLastExpires", "localLastSeen", "localSortingDate"]);
|