@amityco/ts-sdk 7.31.1-e63a36d.0 → 7.32.1-23b143a2.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/dist/@types/domains/client.d.ts +2 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/cache/api/dropFromCache.d.ts.map +1 -1
- package/dist/cache/api/pushToCache.d.ts.map +1 -1
- package/dist/cache/api/queryCache.d.ts.map +1 -1
- package/dist/cache/api/queryCacheByProperty.d.ts +3 -0
- package/dist/cache/api/queryCacheByProperty.d.ts.map +1 -0
- package/dist/cache/api/tests/queryCache.test.d.ts +2 -0
- package/dist/cache/api/tests/queryCache.test.d.ts.map +1 -0
- package/dist/cache/utils/cacheIndex.d.ts +15 -0
- package/dist/cache/utils/cacheIndex.d.ts.map +1 -0
- package/dist/client/utils/autoSubscriptionManager.d.ts.map +1 -1
- package/dist/index.cjs.js +133 -18
- package/dist/index.esm.js +133 -18
- package/dist/index.umd.js +2 -2
- package/dist/messageRepository/utils/getMessageFromMainDB.d.ts.map +1 -1
- package/dist/messageRepository/utils/prepareMessagePayload.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/tests/channelCachePerformance.test.d.ts +2 -0
- package/dist/utils/linkedObject/tests/channelCachePerformance.test.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -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;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,0BAAkB,4BAA4B;IAC5C,SAAS,cAAc;IACvB,UAAU,eAAe;CAC1B;AAED,oBAAY,qBAAqB;IAC/B,IAAI,SA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AK,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;YAChD,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;SACrC,CAAC;QAEF,KAAK,4BAA4B,GAAG;YAClC,aAAa,CAAC,EAAE,MAAM,CAAC;YACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC;SACjC,CAAC;QAEF,KAAK,mBAAmB,GAAG;YACzB,UAAU,EAAE,OAAO,CAAC;SACrB,CAAC;QAEF,KAAK,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,aAAa,CAAC,CAAC;QAEtF,KAAK,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG;YACxD,WAAW,EAAE,OAAO,CAAC;SACtB,CAAC;KACH;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropFromCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/dropFromCache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dropFromCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/dropFromCache.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,4CAAyC,OAqBlE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushToCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/pushToCache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pushToCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/pushToCache.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,8BAEhB,OAAO,YACJ,MAAM,YAAY,KAC1B,OAmBF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/queryCache.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,+
|
|
1
|
+
{"version":3,"file":"queryCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/queryCache.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,+EAWtB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Internal model lookup; deliberately excluded from the public Cache API. @hidden */
|
|
2
|
+
export declare const queryCacheByProperty: <T>(prefix: [string, string], property: keyof T & string, value: string) => Amity.CacheEntry<T>[] | undefined;
|
|
3
|
+
//# sourceMappingURL=queryCacheByProperty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryCacheByProperty.d.ts","sourceRoot":"","sources":["../../../src/cache/api/queryCacheByProperty.ts"],"names":[],"mappings":"AAGA,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,cACvB,CAAC,MAAM,EAAE,MAAM,CAAC,qCAEjB,MAAM,sCAKd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryCache.test.d.ts","sourceRoot":"","sources":["../../../../src/cache/api/tests/queryCache.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare type IndexedKey = {
|
|
2
|
+
encodedKey: string;
|
|
3
|
+
key: Amity.CacheKey;
|
|
4
|
+
order: number;
|
|
5
|
+
};
|
|
6
|
+
/** @hidden */
|
|
7
|
+
export declare const getMatchingCacheKeys: (data: Amity.Cache['data'], key: Amity.CacheKey) => IndexedKey[];
|
|
8
|
+
/** Update only an index that has already been used; writes alone need no index build. @hidden */
|
|
9
|
+
export declare const updateCacheIndex: (data: Amity.Cache['data'], encodedKey: string) => void;
|
|
10
|
+
/** @hidden */
|
|
11
|
+
export declare const removeFromCacheIndex: (data: Amity.Cache['data'], encodedKey: string) => void;
|
|
12
|
+
/** Index a string model property within one domain/operation, retaining cache insertion order. @hidden */
|
|
13
|
+
export declare const getCacheEntriesByProperty: <T>(data: Amity.Cache['data'], prefix: [string, string], property: string, value: string) => Amity.CacheEntry<T>[];
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=cacheIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheIndex.d.ts","sourceRoot":"","sources":["../../../src/cache/utils/cacheIndex.ts"],"names":[],"mappings":"AAEA,aAAK,UAAU,GAAG;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAsFF,cAAc;AACd,eAAO,MAAM,oBAAoB,SAAU,WAAW,CAAC,MAAM,CAAC,sCACoC,CAAC;AAEnG,iGAAiG;AACjG,eAAO,MAAM,gBAAgB,SAAU,WAAW,CAAC,MAAM,CAAC,cAAc,MAAM,SAQ7E,CAAC;AAEF,cAAc;AACd,eAAO,MAAM,oBAAoB,SAAU,WAAW,CAAC,MAAM,CAAC,cAAc,MAAM,SAWjF,CAAC;AAEF,0GAA0G;AAC1G,eAAO,MAAM,yBAAyB,YAC9B,WAAW,CAAC,MAAM,CAAC,UACjB,CAAC,MAAM,EAAE,MAAM,CAAC,YACd,MAAM,SACT,MAAM,0BAed,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoSubscriptionManager.d.ts","sourceRoot":"","sources":["../../../src/client/utils/autoSubscriptionManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"autoSubscriptionManager.d.ts","sourceRoot":"","sources":["../../../src/client/utils/autoSubscriptionManager.ts"],"names":[],"mappings":"AAwCA,mFAAmF;AACnF,cAAM,uBAAuB;IAC3B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6C;IAE/E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2D;;IAMrF,OAAO,CAAC,IAAI;IAKZ,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,iBAAiB;IAKzB,kHAAkH;IAClH,UAAU;IAMV,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,gBAAgB;IAMzC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,gBAAgB;IAM3C,aAAa,IAAI,KAAK,CAAC,qBAAqB,EAAE;IAS9C,KAAK;CAKN;AAID,eAAO,MAAM,0BAA0B,QAAO,uBAG7C,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,8BAA8B,QAAO,MAAM,YAGpD,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -37,6 +37,7 @@ exports.AmityAutoSubscription = void 0;
|
|
|
37
37
|
AmityAutoSubscription["NETWORK"] = "network";
|
|
38
38
|
AmityAutoSubscription["LIVESTREAM"] = "livestream";
|
|
39
39
|
AmityAutoSubscription["BLOCK"] = "block";
|
|
40
|
+
AmityAutoSubscription["USER"] = "user";
|
|
40
41
|
})(exports.AmityAutoSubscription || (exports.AmityAutoSubscription = {}));
|
|
41
42
|
|
|
42
43
|
exports.UserTypeEnum = void 0;
|
|
@@ -360,8 +361,8 @@ exports.AmityLiveViewerCountMode = void 0;
|
|
|
360
361
|
|
|
361
362
|
function getVersion() {
|
|
362
363
|
try {
|
|
363
|
-
// the string ''v7.
|
|
364
|
-
return 'v7.
|
|
364
|
+
// the string ''v7.32.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
365
|
+
return 'v7.32.0-cjs';
|
|
365
366
|
}
|
|
366
367
|
catch (error) {
|
|
367
368
|
return '__dev__';
|
|
@@ -1183,6 +1184,116 @@ const wipeCache = async (storageKey = 'amitySdk') => {
|
|
|
1183
1184
|
return true;
|
|
1184
1185
|
};
|
|
1185
1186
|
|
|
1187
|
+
// Indexes never enter persisted cache data. Replacing data (restore/wipe/enable) starts a new index.
|
|
1188
|
+
const indexes = new WeakMap();
|
|
1189
|
+
const prefixesFor = (key) => {
|
|
1190
|
+
if (typeof key[0] !== 'string')
|
|
1191
|
+
return [];
|
|
1192
|
+
const prefixes = [JSON.stringify([key[0]])];
|
|
1193
|
+
if (typeof key[1] === 'string')
|
|
1194
|
+
prefixes.push(JSON.stringify([key[0], key[1]]));
|
|
1195
|
+
return prefixes;
|
|
1196
|
+
};
|
|
1197
|
+
const removePropertyValue = (property, indexed) => {
|
|
1198
|
+
const previous = property.previousValues.get(indexed.encodedKey);
|
|
1199
|
+
if (previous === undefined)
|
|
1200
|
+
return;
|
|
1201
|
+
const matches = property.values.get(previous);
|
|
1202
|
+
matches.delete(indexed);
|
|
1203
|
+
if (!matches.size)
|
|
1204
|
+
property.values.delete(previous);
|
|
1205
|
+
property.previousValues.delete(indexed.encodedKey);
|
|
1206
|
+
};
|
|
1207
|
+
const addPropertyValue = (data, property, indexed) => {
|
|
1208
|
+
var _a;
|
|
1209
|
+
if (!partialMatch(property.prefix, indexed.key))
|
|
1210
|
+
return;
|
|
1211
|
+
const value = (_a = data[indexed.encodedKey].data) === null || _a === void 0 ? void 0 : _a[property.property];
|
|
1212
|
+
if (typeof value !== 'string')
|
|
1213
|
+
return;
|
|
1214
|
+
let matches = property.values.get(value);
|
|
1215
|
+
if (!matches) {
|
|
1216
|
+
matches = new Set();
|
|
1217
|
+
property.values.set(value, matches);
|
|
1218
|
+
}
|
|
1219
|
+
matches.add(indexed);
|
|
1220
|
+
property.previousValues.set(indexed.encodedKey, value);
|
|
1221
|
+
};
|
|
1222
|
+
const addKey = (index, encodedKey) => {
|
|
1223
|
+
const indexed = { encodedKey, key: decodeKey(encodedKey), order: index.nextOrder };
|
|
1224
|
+
index.nextOrder += 1; // eslint-disable-line no-param-reassign
|
|
1225
|
+
index.keys.set(encodedKey, indexed);
|
|
1226
|
+
prefixesFor(indexed.key).forEach(prefix => {
|
|
1227
|
+
let keys = index.prefixes.get(prefix);
|
|
1228
|
+
if (!keys) {
|
|
1229
|
+
keys = new Map();
|
|
1230
|
+
index.prefixes.set(prefix, keys);
|
|
1231
|
+
}
|
|
1232
|
+
keys.set(encodedKey, indexed);
|
|
1233
|
+
});
|
|
1234
|
+
return indexed;
|
|
1235
|
+
};
|
|
1236
|
+
const getIndex = (data) => {
|
|
1237
|
+
let index = indexes.get(data);
|
|
1238
|
+
if (!index) {
|
|
1239
|
+
index = { keys: new Map(), prefixes: new Map(), properties: new Map(), nextOrder: 0 };
|
|
1240
|
+
Object.keys(data).forEach(encodedKey => addKey(index, encodedKey));
|
|
1241
|
+
indexes.set(data, index);
|
|
1242
|
+
}
|
|
1243
|
+
return index;
|
|
1244
|
+
};
|
|
1245
|
+
const candidatesFor = (index, key) => {
|
|
1246
|
+
var _a, _b;
|
|
1247
|
+
const prefixes = prefixesFor(key);
|
|
1248
|
+
if (!prefixes.length)
|
|
1249
|
+
return index.keys.values();
|
|
1250
|
+
return (_b = (_a = index.prefixes.get(prefixes[prefixes.length - 1])) === null || _a === void 0 ? void 0 : _a.values()) !== null && _b !== void 0 ? _b : [];
|
|
1251
|
+
};
|
|
1252
|
+
/** @hidden */
|
|
1253
|
+
const getMatchingCacheKeys = (data, key) => Array.from(candidatesFor(getIndex(data), key)).filter(indexed => partialMatch(key, indexed.key));
|
|
1254
|
+
/** Update only an index that has already been used; writes alone need no index build. @hidden */
|
|
1255
|
+
const updateCacheIndex = (data, encodedKey) => {
|
|
1256
|
+
var _a;
|
|
1257
|
+
const index = indexes.get(data);
|
|
1258
|
+
if (!index)
|
|
1259
|
+
return;
|
|
1260
|
+
const indexed = (_a = index.keys.get(encodedKey)) !== null && _a !== void 0 ? _a : addKey(index, encodedKey);
|
|
1261
|
+
index.properties.forEach(property => {
|
|
1262
|
+
removePropertyValue(property, indexed);
|
|
1263
|
+
addPropertyValue(data, property, indexed);
|
|
1264
|
+
});
|
|
1265
|
+
};
|
|
1266
|
+
/** @hidden */
|
|
1267
|
+
const removeFromCacheIndex = (data, encodedKey) => {
|
|
1268
|
+
const index = indexes.get(data);
|
|
1269
|
+
const indexed = index === null || index === void 0 ? void 0 : index.keys.get(encodedKey);
|
|
1270
|
+
if (!index || !indexed)
|
|
1271
|
+
return;
|
|
1272
|
+
index.properties.forEach(property => removePropertyValue(property, indexed));
|
|
1273
|
+
prefixesFor(indexed.key).forEach(prefix => {
|
|
1274
|
+
const keys = index.prefixes.get(prefix);
|
|
1275
|
+
keys.delete(encodedKey);
|
|
1276
|
+
if (!keys.size)
|
|
1277
|
+
index.prefixes.delete(prefix);
|
|
1278
|
+
});
|
|
1279
|
+
index.keys.delete(encodedKey);
|
|
1280
|
+
};
|
|
1281
|
+
/** Index a string model property within one domain/operation, retaining cache insertion order. @hidden */
|
|
1282
|
+
const getCacheEntriesByProperty = (data, prefix, property, value) => {
|
|
1283
|
+
var _a;
|
|
1284
|
+
const index = getIndex(data);
|
|
1285
|
+
const identity = JSON.stringify([prefix, property]);
|
|
1286
|
+
let propertyIndex = index.properties.get(identity);
|
|
1287
|
+
if (!propertyIndex) {
|
|
1288
|
+
propertyIndex = { prefix, property, values: new Map(), previousValues: new Map() };
|
|
1289
|
+
index.properties.set(identity, propertyIndex);
|
|
1290
|
+
Array.from(candidatesFor(index, prefix)).forEach(indexed => addPropertyValue(data, propertyIndex, indexed));
|
|
1291
|
+
}
|
|
1292
|
+
return Array.from((_a = propertyIndex.values.get(value)) !== null && _a !== void 0 ? _a : [])
|
|
1293
|
+
.sort((a, b) => a.order - b.order)
|
|
1294
|
+
.map(({ encodedKey }) => data[encodedKey]);
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1186
1297
|
/**
|
|
1187
1298
|
* ```js
|
|
1188
1299
|
* import { queryCache } from '@amityco/ts-sdk'
|
|
@@ -1203,12 +1314,7 @@ const queryCache = (key) => {
|
|
|
1203
1314
|
if (!cache)
|
|
1204
1315
|
return;
|
|
1205
1316
|
log('cache/api/queryCache', { key });
|
|
1206
|
-
return
|
|
1207
|
-
.filter(stringKey => {
|
|
1208
|
-
const decodedKey = decodeKey(stringKey);
|
|
1209
|
-
return partialMatch(key, decodedKey);
|
|
1210
|
-
})
|
|
1211
|
-
.map(stringKey => cache.data[stringKey]);
|
|
1317
|
+
return getMatchingCacheKeys(cache.data, key).map(({ encodedKey }) => cache.data[encodedKey]);
|
|
1212
1318
|
};
|
|
1213
1319
|
|
|
1214
1320
|
/**
|
|
@@ -1264,6 +1370,7 @@ const pushToCache = (key, data, options = { cachedAt: Date.now() }) => {
|
|
|
1264
1370
|
}
|
|
1265
1371
|
const encodedKey = encodeKey(key);
|
|
1266
1372
|
cache.data[encodedKey] = Object.assign({ key, data }, options);
|
|
1373
|
+
updateCacheIndex(cache.data, encodedKey);
|
|
1267
1374
|
return true;
|
|
1268
1375
|
};
|
|
1269
1376
|
|
|
@@ -1348,15 +1455,14 @@ const dropFromCache = (key, exact = false) => {
|
|
|
1348
1455
|
return false;
|
|
1349
1456
|
log('cache/api/dropFromCache', { key, exact });
|
|
1350
1457
|
if (!exact) {
|
|
1351
|
-
return
|
|
1352
|
-
.map(
|
|
1353
|
-
.filter(candidate => partialMatch(key, candidate))
|
|
1354
|
-
.map(filteredKey => dropFromCache(filteredKey, true))
|
|
1458
|
+
return getMatchingCacheKeys(cache.data, key)
|
|
1459
|
+
.map(({ key: filteredKey }) => dropFromCache(filteredKey, true))
|
|
1355
1460
|
.every(returned => returned);
|
|
1356
1461
|
}
|
|
1357
1462
|
const encodedKey = encodeKey(key);
|
|
1358
1463
|
if (encodedKey in cache.data) {
|
|
1359
1464
|
delete cache.data[encodedKey];
|
|
1465
|
+
removeFromCacheIndex(cache.data, encodedKey);
|
|
1360
1466
|
return true;
|
|
1361
1467
|
}
|
|
1362
1468
|
return false;
|
|
@@ -2746,6 +2852,7 @@ const TOPICS = {
|
|
|
2746
2852
|
],
|
|
2747
2853
|
[exports.AmityAutoSubscription.LIVESTREAM]: [getLiveStreamTopic],
|
|
2748
2854
|
[exports.AmityAutoSubscription.BLOCK]: [getMyFollowersTopic, getMyFollowingsTopic],
|
|
2855
|
+
[exports.AmityAutoSubscription.USER]: [() => getUserTopic(getActiveUser())], // global ban
|
|
2749
2856
|
};
|
|
2750
2857
|
const DEFAULT_TOPICS = [
|
|
2751
2858
|
exports.AmityAutoSubscription.CHAT,
|
|
@@ -3744,13 +3851,20 @@ const getUserMarker = async () => {
|
|
|
3744
3851
|
return { data: latestUserMarker, cachedAt };
|
|
3745
3852
|
};
|
|
3746
3853
|
|
|
3854
|
+
/** Internal model lookup; deliberately excluded from the public Cache API. @hidden */
|
|
3855
|
+
const queryCacheByProperty = (prefix, property, value) => {
|
|
3856
|
+
const { cache } = getActiveClient();
|
|
3857
|
+
if (!cache)
|
|
3858
|
+
return;
|
|
3859
|
+
return getCacheEntriesByProperty(cache.data, prefix, property, value);
|
|
3860
|
+
};
|
|
3861
|
+
|
|
3747
3862
|
const getMessageFromMainDB = (messageId) => {
|
|
3748
|
-
var _a, _b;
|
|
3863
|
+
var _a, _b, _c;
|
|
3749
3864
|
const message = (_a = pullFromCache(['message', 'get', messageId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
3750
3865
|
if (message)
|
|
3751
3866
|
return message;
|
|
3752
|
-
|
|
3753
|
-
return (_b = messages === null || messages === void 0 ? void 0 : messages.find(({ data }) => data.messageId === messageId)) === null || _b === void 0 ? void 0 : _b.data;
|
|
3867
|
+
return (_c = (_b = queryCacheByProperty(['message', 'get'], 'messageId', messageId)) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.data;
|
|
3754
3868
|
};
|
|
3755
3869
|
|
|
3756
3870
|
/** @hidden */
|
|
@@ -3892,7 +4006,8 @@ function convertFromRaw$2(_a) {
|
|
|
3892
4006
|
|
|
3893
4007
|
const mergePayloadWithLocal = (payload) => {
|
|
3894
4008
|
var _a, _b, _c;
|
|
3895
|
-
|
|
4009
|
+
// Cache keys may be local referenceIds even after a server messageId is assigned.
|
|
4010
|
+
const localMessage = (_b = (_a = queryCacheByProperty(['message', 'get'], 'messageId', payload.messageId)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.data;
|
|
3896
4011
|
if (localMessage) {
|
|
3897
4012
|
return Object.assign(Object.assign(Object.assign({}, localMessage), payload), {
|
|
3898
4013
|
// NOTE: referenceId is missing in the some payload event. If we have local message data with referenceId, use it instead.
|
|
@@ -5459,9 +5574,9 @@ const channelLinkedObject = (channel) => {
|
|
|
5459
5574
|
var _a;
|
|
5460
5575
|
let previewMembers = [];
|
|
5461
5576
|
if (['conversation', 'community'].includes(channel.type)) {
|
|
5462
|
-
const channelUsers =
|
|
5577
|
+
const channelUsers = queryCacheByProperty(['channelUsers', 'get'], 'channelId', channel.channelId);
|
|
5463
5578
|
if (channelUsers && (channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.length) > 0) {
|
|
5464
|
-
previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.
|
|
5579
|
+
previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.membership !== 'none')) !== null && _a !== void 0 ? _a : [])
|
|
5465
5580
|
// sort in ascending order by userInternalId
|
|
5466
5581
|
.sort((a, b) => a.data.userInternalId.localeCompare(b.data.userInternalId))
|
|
5467
5582
|
// Select only first 4 members
|
package/dist/index.esm.js
CHANGED
|
@@ -21,6 +21,7 @@ var AmityAutoSubscription;
|
|
|
21
21
|
AmityAutoSubscription["NETWORK"] = "network";
|
|
22
22
|
AmityAutoSubscription["LIVESTREAM"] = "livestream";
|
|
23
23
|
AmityAutoSubscription["BLOCK"] = "block";
|
|
24
|
+
AmityAutoSubscription["USER"] = "user";
|
|
24
25
|
})(AmityAutoSubscription || (AmityAutoSubscription = {}));
|
|
25
26
|
|
|
26
27
|
var UserTypeEnum;
|
|
@@ -344,8 +345,8 @@ var AmityLiveViewerCountMode;
|
|
|
344
345
|
|
|
345
346
|
function getVersion() {
|
|
346
347
|
try {
|
|
347
|
-
// the string ''v7.
|
|
348
|
-
return 'v7.
|
|
348
|
+
// the string ''v7.32.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
349
|
+
return 'v7.32.0-esm';
|
|
349
350
|
}
|
|
350
351
|
catch (error) {
|
|
351
352
|
return '__dev__';
|
|
@@ -1167,6 +1168,116 @@ const wipeCache = async (storageKey = 'amitySdk') => {
|
|
|
1167
1168
|
return true;
|
|
1168
1169
|
};
|
|
1169
1170
|
|
|
1171
|
+
// Indexes never enter persisted cache data. Replacing data (restore/wipe/enable) starts a new index.
|
|
1172
|
+
const indexes = new WeakMap();
|
|
1173
|
+
const prefixesFor = (key) => {
|
|
1174
|
+
if (typeof key[0] !== 'string')
|
|
1175
|
+
return [];
|
|
1176
|
+
const prefixes = [JSON.stringify([key[0]])];
|
|
1177
|
+
if (typeof key[1] === 'string')
|
|
1178
|
+
prefixes.push(JSON.stringify([key[0], key[1]]));
|
|
1179
|
+
return prefixes;
|
|
1180
|
+
};
|
|
1181
|
+
const removePropertyValue = (property, indexed) => {
|
|
1182
|
+
const previous = property.previousValues.get(indexed.encodedKey);
|
|
1183
|
+
if (previous === undefined)
|
|
1184
|
+
return;
|
|
1185
|
+
const matches = property.values.get(previous);
|
|
1186
|
+
matches.delete(indexed);
|
|
1187
|
+
if (!matches.size)
|
|
1188
|
+
property.values.delete(previous);
|
|
1189
|
+
property.previousValues.delete(indexed.encodedKey);
|
|
1190
|
+
};
|
|
1191
|
+
const addPropertyValue = (data, property, indexed) => {
|
|
1192
|
+
var _a;
|
|
1193
|
+
if (!partialMatch(property.prefix, indexed.key))
|
|
1194
|
+
return;
|
|
1195
|
+
const value = (_a = data[indexed.encodedKey].data) === null || _a === void 0 ? void 0 : _a[property.property];
|
|
1196
|
+
if (typeof value !== 'string')
|
|
1197
|
+
return;
|
|
1198
|
+
let matches = property.values.get(value);
|
|
1199
|
+
if (!matches) {
|
|
1200
|
+
matches = new Set();
|
|
1201
|
+
property.values.set(value, matches);
|
|
1202
|
+
}
|
|
1203
|
+
matches.add(indexed);
|
|
1204
|
+
property.previousValues.set(indexed.encodedKey, value);
|
|
1205
|
+
};
|
|
1206
|
+
const addKey = (index, encodedKey) => {
|
|
1207
|
+
const indexed = { encodedKey, key: decodeKey(encodedKey), order: index.nextOrder };
|
|
1208
|
+
index.nextOrder += 1; // eslint-disable-line no-param-reassign
|
|
1209
|
+
index.keys.set(encodedKey, indexed);
|
|
1210
|
+
prefixesFor(indexed.key).forEach(prefix => {
|
|
1211
|
+
let keys = index.prefixes.get(prefix);
|
|
1212
|
+
if (!keys) {
|
|
1213
|
+
keys = new Map();
|
|
1214
|
+
index.prefixes.set(prefix, keys);
|
|
1215
|
+
}
|
|
1216
|
+
keys.set(encodedKey, indexed);
|
|
1217
|
+
});
|
|
1218
|
+
return indexed;
|
|
1219
|
+
};
|
|
1220
|
+
const getIndex = (data) => {
|
|
1221
|
+
let index = indexes.get(data);
|
|
1222
|
+
if (!index) {
|
|
1223
|
+
index = { keys: new Map(), prefixes: new Map(), properties: new Map(), nextOrder: 0 };
|
|
1224
|
+
Object.keys(data).forEach(encodedKey => addKey(index, encodedKey));
|
|
1225
|
+
indexes.set(data, index);
|
|
1226
|
+
}
|
|
1227
|
+
return index;
|
|
1228
|
+
};
|
|
1229
|
+
const candidatesFor = (index, key) => {
|
|
1230
|
+
var _a, _b;
|
|
1231
|
+
const prefixes = prefixesFor(key);
|
|
1232
|
+
if (!prefixes.length)
|
|
1233
|
+
return index.keys.values();
|
|
1234
|
+
return (_b = (_a = index.prefixes.get(prefixes[prefixes.length - 1])) === null || _a === void 0 ? void 0 : _a.values()) !== null && _b !== void 0 ? _b : [];
|
|
1235
|
+
};
|
|
1236
|
+
/** @hidden */
|
|
1237
|
+
const getMatchingCacheKeys = (data, key) => Array.from(candidatesFor(getIndex(data), key)).filter(indexed => partialMatch(key, indexed.key));
|
|
1238
|
+
/** Update only an index that has already been used; writes alone need no index build. @hidden */
|
|
1239
|
+
const updateCacheIndex = (data, encodedKey) => {
|
|
1240
|
+
var _a;
|
|
1241
|
+
const index = indexes.get(data);
|
|
1242
|
+
if (!index)
|
|
1243
|
+
return;
|
|
1244
|
+
const indexed = (_a = index.keys.get(encodedKey)) !== null && _a !== void 0 ? _a : addKey(index, encodedKey);
|
|
1245
|
+
index.properties.forEach(property => {
|
|
1246
|
+
removePropertyValue(property, indexed);
|
|
1247
|
+
addPropertyValue(data, property, indexed);
|
|
1248
|
+
});
|
|
1249
|
+
};
|
|
1250
|
+
/** @hidden */
|
|
1251
|
+
const removeFromCacheIndex = (data, encodedKey) => {
|
|
1252
|
+
const index = indexes.get(data);
|
|
1253
|
+
const indexed = index === null || index === void 0 ? void 0 : index.keys.get(encodedKey);
|
|
1254
|
+
if (!index || !indexed)
|
|
1255
|
+
return;
|
|
1256
|
+
index.properties.forEach(property => removePropertyValue(property, indexed));
|
|
1257
|
+
prefixesFor(indexed.key).forEach(prefix => {
|
|
1258
|
+
const keys = index.prefixes.get(prefix);
|
|
1259
|
+
keys.delete(encodedKey);
|
|
1260
|
+
if (!keys.size)
|
|
1261
|
+
index.prefixes.delete(prefix);
|
|
1262
|
+
});
|
|
1263
|
+
index.keys.delete(encodedKey);
|
|
1264
|
+
};
|
|
1265
|
+
/** Index a string model property within one domain/operation, retaining cache insertion order. @hidden */
|
|
1266
|
+
const getCacheEntriesByProperty = (data, prefix, property, value) => {
|
|
1267
|
+
var _a;
|
|
1268
|
+
const index = getIndex(data);
|
|
1269
|
+
const identity = JSON.stringify([prefix, property]);
|
|
1270
|
+
let propertyIndex = index.properties.get(identity);
|
|
1271
|
+
if (!propertyIndex) {
|
|
1272
|
+
propertyIndex = { prefix, property, values: new Map(), previousValues: new Map() };
|
|
1273
|
+
index.properties.set(identity, propertyIndex);
|
|
1274
|
+
Array.from(candidatesFor(index, prefix)).forEach(indexed => addPropertyValue(data, propertyIndex, indexed));
|
|
1275
|
+
}
|
|
1276
|
+
return Array.from((_a = propertyIndex.values.get(value)) !== null && _a !== void 0 ? _a : [])
|
|
1277
|
+
.sort((a, b) => a.order - b.order)
|
|
1278
|
+
.map(({ encodedKey }) => data[encodedKey]);
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1170
1281
|
/**
|
|
1171
1282
|
* ```js
|
|
1172
1283
|
* import { queryCache } from '@amityco/ts-sdk'
|
|
@@ -1187,12 +1298,7 @@ const queryCache = (key) => {
|
|
|
1187
1298
|
if (!cache)
|
|
1188
1299
|
return;
|
|
1189
1300
|
log('cache/api/queryCache', { key });
|
|
1190
|
-
return
|
|
1191
|
-
.filter(stringKey => {
|
|
1192
|
-
const decodedKey = decodeKey(stringKey);
|
|
1193
|
-
return partialMatch(key, decodedKey);
|
|
1194
|
-
})
|
|
1195
|
-
.map(stringKey => cache.data[stringKey]);
|
|
1301
|
+
return getMatchingCacheKeys(cache.data, key).map(({ encodedKey }) => cache.data[encodedKey]);
|
|
1196
1302
|
};
|
|
1197
1303
|
|
|
1198
1304
|
/**
|
|
@@ -1248,6 +1354,7 @@ const pushToCache = (key, data, options = { cachedAt: Date.now() }) => {
|
|
|
1248
1354
|
}
|
|
1249
1355
|
const encodedKey = encodeKey(key);
|
|
1250
1356
|
cache.data[encodedKey] = Object.assign({ key, data }, options);
|
|
1357
|
+
updateCacheIndex(cache.data, encodedKey);
|
|
1251
1358
|
return true;
|
|
1252
1359
|
};
|
|
1253
1360
|
|
|
@@ -1332,15 +1439,14 @@ const dropFromCache = (key, exact = false) => {
|
|
|
1332
1439
|
return false;
|
|
1333
1440
|
log('cache/api/dropFromCache', { key, exact });
|
|
1334
1441
|
if (!exact) {
|
|
1335
|
-
return
|
|
1336
|
-
.map(
|
|
1337
|
-
.filter(candidate => partialMatch(key, candidate))
|
|
1338
|
-
.map(filteredKey => dropFromCache(filteredKey, true))
|
|
1442
|
+
return getMatchingCacheKeys(cache.data, key)
|
|
1443
|
+
.map(({ key: filteredKey }) => dropFromCache(filteredKey, true))
|
|
1339
1444
|
.every(returned => returned);
|
|
1340
1445
|
}
|
|
1341
1446
|
const encodedKey = encodeKey(key);
|
|
1342
1447
|
if (encodedKey in cache.data) {
|
|
1343
1448
|
delete cache.data[encodedKey];
|
|
1449
|
+
removeFromCacheIndex(cache.data, encodedKey);
|
|
1344
1450
|
return true;
|
|
1345
1451
|
}
|
|
1346
1452
|
return false;
|
|
@@ -2730,6 +2836,7 @@ const TOPICS = {
|
|
|
2730
2836
|
],
|
|
2731
2837
|
[AmityAutoSubscription.LIVESTREAM]: [getLiveStreamTopic],
|
|
2732
2838
|
[AmityAutoSubscription.BLOCK]: [getMyFollowersTopic, getMyFollowingsTopic],
|
|
2839
|
+
[AmityAutoSubscription.USER]: [() => getUserTopic(getActiveUser())], // global ban
|
|
2733
2840
|
};
|
|
2734
2841
|
const DEFAULT_TOPICS = [
|
|
2735
2842
|
AmityAutoSubscription.CHAT,
|
|
@@ -3744,13 +3851,20 @@ const getUserMarker = async () => {
|
|
|
3744
3851
|
return { data: latestUserMarker, cachedAt };
|
|
3745
3852
|
};
|
|
3746
3853
|
|
|
3854
|
+
/** Internal model lookup; deliberately excluded from the public Cache API. @hidden */
|
|
3855
|
+
const queryCacheByProperty = (prefix, property, value) => {
|
|
3856
|
+
const { cache } = getActiveClient();
|
|
3857
|
+
if (!cache)
|
|
3858
|
+
return;
|
|
3859
|
+
return getCacheEntriesByProperty(cache.data, prefix, property, value);
|
|
3860
|
+
};
|
|
3861
|
+
|
|
3747
3862
|
const getMessageFromMainDB = (messageId) => {
|
|
3748
|
-
var _a, _b;
|
|
3863
|
+
var _a, _b, _c;
|
|
3749
3864
|
const message = (_a = pullFromCache(['message', 'get', messageId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
3750
3865
|
if (message)
|
|
3751
3866
|
return message;
|
|
3752
|
-
|
|
3753
|
-
return (_b = messages === null || messages === void 0 ? void 0 : messages.find(({ data }) => data.messageId === messageId)) === null || _b === void 0 ? void 0 : _b.data;
|
|
3867
|
+
return (_c = (_b = queryCacheByProperty(['message', 'get'], 'messageId', messageId)) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.data;
|
|
3754
3868
|
};
|
|
3755
3869
|
|
|
3756
3870
|
/** @hidden */
|
|
@@ -3892,7 +4006,8 @@ function convertFromRaw$2(_a) {
|
|
|
3892
4006
|
|
|
3893
4007
|
const mergePayloadWithLocal = (payload) => {
|
|
3894
4008
|
var _a, _b, _c;
|
|
3895
|
-
|
|
4009
|
+
// Cache keys may be local referenceIds even after a server messageId is assigned.
|
|
4010
|
+
const localMessage = (_b = (_a = queryCacheByProperty(['message', 'get'], 'messageId', payload.messageId)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.data;
|
|
3896
4011
|
if (localMessage) {
|
|
3897
4012
|
return Object.assign(Object.assign(Object.assign({}, localMessage), payload), {
|
|
3898
4013
|
// NOTE: referenceId is missing in the some payload event. If we have local message data with referenceId, use it instead.
|
|
@@ -5459,9 +5574,9 @@ const channelLinkedObject = (channel) => {
|
|
|
5459
5574
|
var _a;
|
|
5460
5575
|
let previewMembers = [];
|
|
5461
5576
|
if (['conversation', 'community'].includes(channel.type)) {
|
|
5462
|
-
const channelUsers =
|
|
5577
|
+
const channelUsers = queryCacheByProperty(['channelUsers', 'get'], 'channelId', channel.channelId);
|
|
5463
5578
|
if (channelUsers && (channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.length) > 0) {
|
|
5464
|
-
previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.
|
|
5579
|
+
previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.membership !== 'none')) !== null && _a !== void 0 ? _a : [])
|
|
5465
5580
|
// sort in ascending order by userInternalId
|
|
5466
5581
|
.sort((a, b) => a.data.userInternalId.localeCompare(b.data.userInternalId))
|
|
5467
5582
|
// Select only first 4 members
|