@amityco/ts-sdk 6.4.3-9741e51.0 → 6.4.3

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.
@@ -4,9 +4,10 @@ import { PAYLOAD2MODEL } from '~/core/model';
4
4
  *
5
5
  * @param payload a "backend v3" payload object
6
6
  * @param options caching options like cachedAt or offline
7
+ * @param replace If TRUE it will overwrite the current cache with payload, if FALSE it will merge the payload into cache.
7
8
  *
8
9
  * @category Cache
9
10
  * @hidden
10
11
  */
11
- export declare const ingestInCache: (payload?: Record<keyof typeof PAYLOAD2MODEL, Amity.Model[]>, options?: Amity.CacheOptions) => void;
12
+ export declare const ingestInCache: (payload?: Record<keyof typeof PAYLOAD2MODEL, Amity.Model[]>, options?: Amity.CacheOptions, replace?: boolean) => void;
12
13
  //# sourceMappingURL=ingestInCache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ingestInCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/ingestInCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,MAAM,cAAc,CAAC;AAI1D;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,aACf,OAAO,MAAM,oBAAoB,EAAE,MAAM,KAAK,EAAE,CAAC,YAChD,MAAM,YAAY,SAa7B,CAAC"}
1
+ {"version":3,"file":"ingestInCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/ingestInCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,MAAM,cAAc,CAAC;AAK1D;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,aACf,OAAO,MAAM,oBAAoB,EAAE,MAAM,KAAK,EAAE,CAAC,YAChD,MAAM,YAAY,4BAc7B,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -96,8 +96,8 @@ const PostContentType = Object.freeze({
96
96
 
97
97
  function getVersion() {
98
98
  try {
99
- // the string ''v6.4.2-cjs'' should be replaced by actual value by @rollup/plugin-replace
100
- return 'v6.4.2-cjs';
99
+ // the string ''v6.4.3-cjs'' should be replaced by actual value by @rollup/plugin-replace
100
+ return 'v6.4.3-cjs';
101
101
  }
102
102
  catch (error) {
103
103
  return '__dev__';
@@ -20717,11 +20717,12 @@ const setClientToken = async (params) => {
20717
20717
  *
20718
20718
  * @param payload a "backend v3" payload object
20719
20719
  * @param options caching options like cachedAt or offline
20720
+ * @param replace If TRUE it will overwrite the current cache with payload, if FALSE it will merge the payload into cache.
20720
20721
  *
20721
20722
  * @category Cache
20722
20723
  * @hidden
20723
20724
  */
20724
- const ingestInCache = (payload = {}, options) => {
20725
+ const ingestInCache = (payload = {}, options, replace = true) => {
20725
20726
  Object.entries(payload).forEach(([key, models]) => {
20726
20727
  const type = PAYLOAD2MODEL[key];
20727
20728
  if (!type)
@@ -20730,7 +20731,7 @@ const ingestInCache = (payload = {}, options) => {
20730
20731
  if (!resolver)
20731
20732
  return;
20732
20733
  models.forEach(model => {
20733
- upsertInCache([type, 'get', resolver(model)], model, options);
20734
+ (replace ? pushToCache : upsertInCache)([type, 'get', resolver(model)], model, options);
20734
20735
  });
20735
20736
  });
20736
20737
  };
package/dist/index.esm.js CHANGED
@@ -82,8 +82,8 @@ const PostContentType = Object.freeze({
82
82
 
83
83
  function getVersion() {
84
84
  try {
85
- // the string ''v6.4.2-esm'' should be replaced by actual value by @rollup/plugin-replace
86
- return 'v6.4.2-esm';
85
+ // the string ''v6.4.3-esm'' should be replaced by actual value by @rollup/plugin-replace
86
+ return 'v6.4.3-esm';
87
87
  }
88
88
  catch (error) {
89
89
  return '__dev__';
@@ -20703,11 +20703,12 @@ const setClientToken = async (params) => {
20703
20703
  *
20704
20704
  * @param payload a "backend v3" payload object
20705
20705
  * @param options caching options like cachedAt or offline
20706
+ * @param replace If TRUE it will overwrite the current cache with payload, if FALSE it will merge the payload into cache.
20706
20707
  *
20707
20708
  * @category Cache
20708
20709
  * @hidden
20709
20710
  */
20710
- const ingestInCache = (payload = {}, options) => {
20711
+ const ingestInCache = (payload = {}, options, replace = true) => {
20711
20712
  Object.entries(payload).forEach(([key, models]) => {
20712
20713
  const type = PAYLOAD2MODEL[key];
20713
20714
  if (!type)
@@ -20716,7 +20717,7 @@ const ingestInCache = (payload = {}, options) => {
20716
20717
  if (!resolver)
20717
20718
  return;
20718
20719
  models.forEach(model => {
20719
- upsertInCache([type, 'get', resolver(model)], model, options);
20720
+ (replace ? pushToCache : upsertInCache)([type, 'get', resolver(model)], model, options);
20720
20721
  });
20721
20722
  });
20722
20723
  };