@amityco/ts-sdk 7.32.1-6d2e2c1e.0 → 7.32.1-6f09276b.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/comment.d.ts +2 -2
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +15 -1
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/cache/api/queryCache.d.ts.map +1 -1
- package/dist/commentRepository/api/createComment.d.ts +1 -1
- package/dist/commentRepository/api/createComment.d.ts.map +1 -1
- package/dist/commentRepository/api/tests/createComment.gif.test.d.ts +2 -0
- package/dist/commentRepository/api/tests/createComment.gif.test.d.ts.map +1 -0
- package/dist/commentRepository/api/tests/deleteComment.gif.test.d.ts +2 -0
- package/dist/commentRepository/api/tests/deleteComment.gif.test.d.ts.map +1 -0
- package/dist/commentRepository/api/tests/updateComment.gif.test.d.ts +2 -0
- package/dist/commentRepository/api/tests/updateComment.gif.test.d.ts.map +1 -0
- package/dist/commentRepository/api/updateComment.d.ts +9 -2
- package/dist/commentRepository/api/updateComment.d.ts.map +1 -1
- package/dist/commentRepository/observers/tests/getComments.gif.test.d.ts +2 -0
- package/dist/commentRepository/observers/tests/getComments.gif.test.d.ts.map +1 -0
- package/dist/commentRepository/utils/dataTypes.d.ts +2 -0
- package/dist/commentRepository/utils/dataTypes.d.ts.map +1 -0
- package/dist/index.cjs.js +57 -20
- package/dist/index.esm.js +57 -20
- package/dist/index.umd.js +2 -2
- package/dist/utils/gifAttachment.d.ts +5 -0
- package/dist/utils/gifAttachment.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/cache/api/tests/queryCache.test.d.ts +0 -2
- package/dist/cache/api/tests/queryCache.test.d.ts.map +0 -1
|
@@ -11,7 +11,7 @@ declare global {
|
|
|
11
11
|
* Absent on the wire means `approved` — see `prepareCommentPayload`.
|
|
12
12
|
*/
|
|
13
13
|
type CommentApprovalStatus = `${CommentApprovalStatusEnum}`;
|
|
14
|
-
type CommentContentType = 'text';
|
|
14
|
+
type CommentContentType = 'text' | 'gif';
|
|
15
15
|
type CommentReferenceType = 'content' | 'post' | 'story';
|
|
16
16
|
type CommentActionType = 'onFetch' | 'onCreate' | 'onUpdate' | 'onDelete' | 'onFlagged' | 'onUnflagged' | 'onReactionAdded' | 'onReactionRemoved';
|
|
17
17
|
type RawComment<T extends CommentContentType = any> = {
|
|
@@ -57,7 +57,7 @@ declare global {
|
|
|
57
57
|
limit?: number;
|
|
58
58
|
page?: Amity.Token;
|
|
59
59
|
dataTypes?: {
|
|
60
|
-
values: ('image' | 'text')[];
|
|
60
|
+
values: ('image' | 'text' | 'gif')[];
|
|
61
61
|
matchType: 'any' | 'exact';
|
|
62
62
|
};
|
|
63
63
|
excludeBlockUserComments?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,WAAW,yBAAyB;YAClC,OAAO,YAAY;YACnB,QAAQ,aAAa;YACrB,QAAQ,aAAa;SACtB;QAED;;;WAGG;QACH,KAAK,qBAAqB,GAAG,GAAG,yBAAyB,EAAE,CAAC;QAE5D,KAAK,kBAAkB,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"comment.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,WAAW,yBAAyB;YAClC,OAAO,YAAY;YACnB,QAAQ,aAAa;YACrB,QAAQ,aAAa;SACtB;QAED;;;WAGG;QACH,KAAK,qBAAqB,GAAG,GAAG,yBAAyB,EAAE,CAAC;QAE5D,KAAK,kBAAkB,GAAG,MAAM,GAAG,KAAK,C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gBAGrC,SAAS,EAAE,KAAK,GAAG,OAAO,CAAC;aAC5B,CAAC;YACF,wBAAwB,CAAC,EAAE,OAAO,CAAC;SACpC,CAAC;QAEF,KAAK,qBAAqB,GAAG,KAAK,CAAC,oBAAoB,CACrD,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,MAAM,CAAC,GAAG;YACvC,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,CAAC;SACzC,CACF,CAAC;QAEF,KAAK,0BAA0B,GAAG,KAAK,CAAC,mBAAmB,CACzD,KAAK,CAAC,eAAe,CAAC,WAAW,CAAC,EAClC;YAAE,IAAI,CAAC,EAAE,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CACnD,CAAC;QAEF,KAAK,uBAAuB,GAAG;YAC7B,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;YAC5C,yFAAyF;YACzF,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9B,2EAA2E;YAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,yDAAyD;YACzD,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,sFAAsF;YACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;SACnB,CAAC;QAEF,KAAK,gCAAgC,GAAG,KAAK,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;QAE5F,KAAK,qCAAqC,GAAG,KAAK,CAAC,mBAAmB,CACpE,KAAK,CAAC,eAAe,CAAC,WAAW,CAAC,EAClC;YAAE,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CACnB,CAAC;KACH;CACF"}
|
|
@@ -49,11 +49,25 @@ declare global {
|
|
|
49
49
|
fileId: Amity.File<'image'>['fileId'];
|
|
50
50
|
caption?: string;
|
|
51
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* A GIF picked by the app from its own provider. It is a link, not a file: nothing is
|
|
54
|
+
* uploaded and there is no `fileId`. Leave out a size that has no value; `null` is refused,
|
|
55
|
+
* and so is any other key (alt text and provider fields included).
|
|
56
|
+
*/
|
|
57
|
+
type GifAttachment = {
|
|
58
|
+
type: 'gif';
|
|
59
|
+
/** https, path ends in `.gif`, at most 2,000 characters. Checked by the server. */
|
|
60
|
+
url: string;
|
|
61
|
+
/** 1 to 4096 */
|
|
62
|
+
width?: number;
|
|
63
|
+
/** 1 to 4096 */
|
|
64
|
+
height?: number;
|
|
65
|
+
};
|
|
52
66
|
type Attachment = {
|
|
53
67
|
type: 'image' | 'link';
|
|
54
68
|
url?: string;
|
|
55
69
|
fileId?: Amity.File<'image'>['fileId'];
|
|
56
|
-
};
|
|
70
|
+
} | GifAttachment;
|
|
57
71
|
type ContentDataVideo = {
|
|
58
72
|
/**
|
|
59
73
|
* Null until the server has finished transcoding the video: the field is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/content.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;EAM1B,CAAC;AAEH,oBAAY,qBAAqB;IAC/B,mBAAmB,iCAAiC;IACpD,iBAAiB,uBAAuB;IACxC,oBAAoB,2BAA2B;IAC/C,iBAAiB,yBAAyB;IAC1C,4BAA4B,oCAAoC;IAChE,sBAAsB,2CAA2C;IACjE,qBAAqB,6BAA6B;IAClD,WAAW,kBAAkB;IAC7B,gBAAgB,wCAAwC;IACxD,MAAM,WAAW;CAClB;AAED;;;GAGG;AACH,OAAO,EAAE,qBAAqB,IAAI,0BAA0B,EAAE,CAAC;AAE/D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,iBAAiB,GAClB,OAAO,CAAC,GAAG,qBAAqB,EAAE,EAAE,GAAG,qBAAqB,CAAC,MAAM,EAAE,CAAC,GACtE,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;QAElB;;;;;;WAMG;QAC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K,cAAc,CAAC,CAAC,SAAS,WAAW,GAAG,MAAM,GAAG,OAAO,IAAI,CAAC,SAAS,MAAM,GAC5E,kBAAkB,GAClB,CAAC,SAAS,OAAO,GACjB,mBAAmB,GACnB,KAAK,CAAC;KACX;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/queryCache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queryCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/queryCache.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,+EActB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare type CreateCommentBundle = Pick<Amity.Comment<
|
|
1
|
+
declare type CreateCommentBundle = Pick<Amity.Comment<'text'>, 'data' | 'referenceType' | 'referenceId' | 'parentId' | 'metadata' | 'mentionees' | 'attachments' | 'links'>;
|
|
2
2
|
/**
|
|
3
3
|
* ```js
|
|
4
4
|
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/createComment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/createComment.ts"],"names":[],"mappings":"AA2BA,aAAK,mBAAmB,GAAG,IAAI,CAC7B,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EACnB,MAAM,GACN,eAAe,GACf,aAAa,GACb,UAAU,GACV,UAAU,GACV,YAAY,GACZ,aAAa,GACb,OAAO,CACV,CAAC;AAqEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,aAAa,WAChB,mBAAmB,6BAE1B,QAAQ,MAAM,MAAM,CAAC,aAAa,CAAC,CAmHrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createComment.gif.test.d.ts","sourceRoot":"","sources":["../../../../src/commentRepository/api/tests/createComment.gif.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteComment.gif.test.d.ts","sourceRoot":"","sources":["../../../../src/commentRepository/api/tests/deleteComment.gif.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateComment.gif.test.d.ts","sourceRoot":"","sources":["../../../../src/commentRepository/api/tests/updateComment.gif.test.ts"],"names":[],"mappings":""}
|
|
@@ -4,9 +4,16 @@
|
|
|
4
4
|
* const updated = await CommentRepository.updateComment(commentId, {
|
|
5
5
|
* data: { text: 'hello world' }
|
|
6
6
|
* })
|
|
7
|
+
*
|
|
8
|
+
* // Replace the GIF, or remove it and keep the text
|
|
9
|
+
* await CommentRepository.updateComment(commentId, {
|
|
10
|
+
* attachments: [{ type: 'gif', url: 'https://media.giphy.com/media/l0MYt5jPR6QX5pnqM/giphy.gif' }],
|
|
11
|
+
* })
|
|
12
|
+
* await CommentRepository.updateComment(commentId, { attachments: [] })
|
|
7
13
|
* ```
|
|
8
14
|
*
|
|
9
|
-
* Updates an {@link Amity.Comment}
|
|
15
|
+
* Updates an {@link Amity.Comment}. `attachments` replaces the current ones, `[]` removes them,
|
|
16
|
+
* and leaving `attachments` out keeps them as they are.
|
|
10
17
|
*
|
|
11
18
|
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
12
19
|
* @param patch The patch data to apply
|
|
@@ -15,5 +22,5 @@
|
|
|
15
22
|
* @category Comment API
|
|
16
23
|
* @async
|
|
17
24
|
*/
|
|
18
|
-
export declare const updateComment: (commentId: Amity.Comment['commentId'], patch: Patch<Amity.Comment, 'data' | 'metadata' | 'mentionees' | 'links'>) => Promise<Amity.Cached<Amity.Comment>>;
|
|
25
|
+
export declare const updateComment: (commentId: Amity.Comment['commentId'], patch: Patch<Amity.Comment, 'data' | 'metadata' | 'mentionees' | 'links' | 'attachments'>) => Promise<Amity.Cached<Amity.Comment>>;
|
|
19
26
|
//# sourceMappingURL=updateComment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/updateComment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/updateComment.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,aAAa,cACb,aAAa,CAAC,WAAW,CAAC,SAC9B,MAAM,aAAa,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,OAAO,GAAG,aAAa,CAAC,KACxF,QAAQ,MAAM,MAAM,CAAC,aAAa,CAAC,CAoCrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getComments.gif.test.d.ts","sourceRoot":"","sources":["../../../../src/commentRepository/observers/tests/getComments.gif.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataTypes.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/utils/dataTypes.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,SACvB,MAAM,GAAG,SAAS,eACX,MAAM,UAAU,EAAE,GAAG,SAAS,KAC1C,MAAM,kBAAkB,EAI1B,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1184,17 +1184,6 @@ const wipeCache = async (storageKey = 'amitySdk') => {
|
|
|
1184
1184
|
return true;
|
|
1185
1185
|
};
|
|
1186
1186
|
|
|
1187
|
-
const isPrimitiveKey = (key) => Array.isArray(key) &&
|
|
1188
|
-
key.length > 0 &&
|
|
1189
|
-
key.every(segment => typeof segment === 'string' || typeof segment === 'number');
|
|
1190
|
-
const createMatcher = (key) => {
|
|
1191
|
-
if (isPrimitiveKey(key)) {
|
|
1192
|
-
const encoded = encodeKey(key);
|
|
1193
|
-
const prefix = `${encoded.slice(0, -1)},`;
|
|
1194
|
-
return encodedKey => encodedKey === encoded || encodedKey.startsWith(prefix);
|
|
1195
|
-
}
|
|
1196
|
-
return encodedKey => partialMatch(key, decodeKey(encodedKey));
|
|
1197
|
-
};
|
|
1198
1187
|
/**
|
|
1199
1188
|
* ```js
|
|
1200
1189
|
* import { queryCache } from '@amityco/ts-sdk'
|
|
@@ -1215,9 +1204,11 @@ const queryCache = (key) => {
|
|
|
1215
1204
|
if (!cache)
|
|
1216
1205
|
return;
|
|
1217
1206
|
log('cache/api/queryCache', { key });
|
|
1218
|
-
const matches = createMatcher(key);
|
|
1219
1207
|
return Object.keys(cache.data)
|
|
1220
|
-
.filter(
|
|
1208
|
+
.filter(stringKey => {
|
|
1209
|
+
const decodedKey = decodeKey(stringKey);
|
|
1210
|
+
return partialMatch(key, decodedKey);
|
|
1211
|
+
})
|
|
1221
1212
|
.map(stringKey => cache.data[stringKey]);
|
|
1222
1213
|
};
|
|
1223
1214
|
|
|
@@ -27752,8 +27743,40 @@ getCommentByIds.locally = (commentIds) => {
|
|
|
27752
27743
|
};
|
|
27753
27744
|
};
|
|
27754
27745
|
|
|
27746
|
+
const GIF_OPTIONAL_KEYS = ['width', 'height'];
|
|
27747
|
+
/*
|
|
27748
|
+
* The server refuses a GIF attachment that carries `null` or any key it does not know, so the
|
|
27749
|
+
* request keeps `type`, `url` and only the optional fields that have a value. The SDK does not
|
|
27750
|
+
* check the values themselves: the server answers 400 for a bad one.
|
|
27751
|
+
*/
|
|
27752
|
+
const toGifAttachmentPayload = (gif) => {
|
|
27753
|
+
const payload = { type: 'gif', url: gif.url };
|
|
27754
|
+
GIF_OPTIONAL_KEYS.forEach(key => {
|
|
27755
|
+
const value = gif[key];
|
|
27756
|
+
if (value !== undefined && value !== null)
|
|
27757
|
+
Object.assign(payload, { [key]: value });
|
|
27758
|
+
});
|
|
27759
|
+
return payload;
|
|
27760
|
+
};
|
|
27761
|
+
/* Builds each GIF from its known keys; every other attachment is sent as the caller gave it. */
|
|
27762
|
+
const toAttachmentsPayload = (attachments) => attachments.map(attachment => attachment.type === 'gif'
|
|
27763
|
+
? toGifAttachmentPayload(attachment)
|
|
27764
|
+
: attachment);
|
|
27765
|
+
|
|
27766
|
+
/*
|
|
27767
|
+
* The data types the server lists for a comment, known before it answers: one per attachment
|
|
27768
|
+
* type, plus `text` when there is text. Sorted, as the server sorts them.
|
|
27769
|
+
*/
|
|
27770
|
+
const commentDataTypesOf = (text, attachments) => {
|
|
27771
|
+
const types = new Set((attachments !== null && attachments !== void 0 ? attachments : []).map(attachment => attachment.type));
|
|
27772
|
+
if (text)
|
|
27773
|
+
types.add('text');
|
|
27774
|
+
return [...types].sort();
|
|
27775
|
+
};
|
|
27776
|
+
|
|
27755
27777
|
const getLocalCommentId = () => uuid();
|
|
27756
27778
|
const createCommentOptimistic = (bundle) => {
|
|
27779
|
+
var _a;
|
|
27757
27780
|
const client = getActiveClient();
|
|
27758
27781
|
if (!client.cache)
|
|
27759
27782
|
return;
|
|
@@ -27788,6 +27811,7 @@ const createCommentOptimistic = (bundle) => {
|
|
|
27788
27811
|
targetId: '',
|
|
27789
27812
|
targetType: 'community',
|
|
27790
27813
|
dataType: 'text',
|
|
27814
|
+
dataTypes: commentDataTypesOf((_a = bundle.data) === null || _a === void 0 ? void 0 : _a.text, bundle.attachments),
|
|
27791
27815
|
syncState: "syncing" /* Amity.SyncState.Syncing */,
|
|
27792
27816
|
// In a gated community the optimistic object stays out of public collections until the
|
|
27793
27817
|
// response settles the status; the author's own view still updates through the local event
|
|
@@ -27834,12 +27858,15 @@ const createCommentOptimistic = (bundle) => {
|
|
|
27834
27858
|
const createComment = async (bundle, isOptimistic = true) => {
|
|
27835
27859
|
const client = getActiveClient();
|
|
27836
27860
|
client.log('comment/createComment', Object.assign(Object.assign({}, bundle), { isOptimistic }));
|
|
27861
|
+
// A GIF is sent with its known keys only; the server refuses `null` and unknown keys.
|
|
27862
|
+
const request = bundle.attachments
|
|
27863
|
+
? Object.assign(Object.assign({}, bundle), { attachments: toAttachmentsPayload(bundle.attachments) }) : bundle;
|
|
27837
27864
|
// Without a local comment the server assigns the id; with one, the same id travels through the
|
|
27838
27865
|
// optimistic object, the response and every realtime event so each step recognises it.
|
|
27839
|
-
const optimisticData = isOptimistic ? createCommentOptimistic(
|
|
27866
|
+
const optimisticData = isOptimistic ? createCommentOptimistic(request) : undefined;
|
|
27840
27867
|
const commentId = optimisticData === null || optimisticData === void 0 ? void 0 : optimisticData.commentId;
|
|
27841
27868
|
try {
|
|
27842
|
-
const { data: payload } = await client.http.post('/api/v3/comments', Object.assign(Object.assign({},
|
|
27869
|
+
const { data: payload } = await client.http.post('/api/v3/comments', Object.assign(Object.assign({}, request), { commentId }));
|
|
27843
27870
|
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
27844
27871
|
if (payload.comments.length === 0)
|
|
27845
27872
|
throw new Error('Comment not created');
|
|
@@ -27932,9 +27959,16 @@ const createComment = async (bundle, isOptimistic = true) => {
|
|
|
27932
27959
|
* const updated = await CommentRepository.updateComment(commentId, {
|
|
27933
27960
|
* data: { text: 'hello world' }
|
|
27934
27961
|
* })
|
|
27962
|
+
*
|
|
27963
|
+
* // Replace the GIF, or remove it and keep the text
|
|
27964
|
+
* await CommentRepository.updateComment(commentId, {
|
|
27965
|
+
* attachments: [{ type: 'gif', url: 'https://media.giphy.com/media/l0MYt5jPR6QX5pnqM/giphy.gif' }],
|
|
27966
|
+
* })
|
|
27967
|
+
* await CommentRepository.updateComment(commentId, { attachments: [] })
|
|
27935
27968
|
* ```
|
|
27936
27969
|
*
|
|
27937
|
-
* Updates an {@link Amity.Comment}
|
|
27970
|
+
* Updates an {@link Amity.Comment}. `attachments` replaces the current ones, `[]` removes them,
|
|
27971
|
+
* and leaving `attachments` out keeps them as they are.
|
|
27938
27972
|
*
|
|
27939
27973
|
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
27940
27974
|
* @param patch The patch data to apply
|
|
@@ -27948,7 +27982,10 @@ const updateComment = async (commentId, patch) => {
|
|
|
27948
27982
|
const client = getActiveClient();
|
|
27949
27983
|
client.log('user/updateComment', patch);
|
|
27950
27984
|
const previous = (_a = pullFromCache(['comment', 'get', commentId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
27951
|
-
|
|
27985
|
+
// A GIF is sent with its known keys only; the server refuses `null` and unknown keys.
|
|
27986
|
+
const body = patch.attachments
|
|
27987
|
+
? Object.assign(Object.assign({}, patch), { attachments: toAttachmentsPayload(patch.attachments) }) : patch;
|
|
27988
|
+
const { data: payload } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, body);
|
|
27952
27989
|
const data = prepareCommentPayload(payload);
|
|
27953
27990
|
const updated = data.comments.find(comment => comment.commentId === commentId);
|
|
27954
27991
|
const cachedAt = client.cache && Date.now();
|
|
@@ -28079,13 +28116,13 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
28079
28116
|
permanent,
|
|
28080
28117
|
},
|
|
28081
28118
|
});
|
|
28082
|
-
// to support hard deletion
|
|
28083
|
-
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
28119
|
+
// to support hard deletion; the server empties a deleted comment's attachments
|
|
28120
|
+
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true, attachments: [] });
|
|
28084
28121
|
if (permanent) {
|
|
28085
28122
|
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
28086
28123
|
}
|
|
28087
28124
|
else {
|
|
28088
|
-
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
28125
|
+
upsertInCache(['comment', 'get', commentId], { isDeleted: true, attachments: [] });
|
|
28089
28126
|
}
|
|
28090
28127
|
if (comment.data.referenceType === 'story') {
|
|
28091
28128
|
const story = await getStoryByStoryId$1(comment.data.referenceId);
|
package/dist/index.esm.js
CHANGED
|
@@ -1168,17 +1168,6 @@ const wipeCache = async (storageKey = 'amitySdk') => {
|
|
|
1168
1168
|
return true;
|
|
1169
1169
|
};
|
|
1170
1170
|
|
|
1171
|
-
const isPrimitiveKey = (key) => Array.isArray(key) &&
|
|
1172
|
-
key.length > 0 &&
|
|
1173
|
-
key.every(segment => typeof segment === 'string' || typeof segment === 'number');
|
|
1174
|
-
const createMatcher = (key) => {
|
|
1175
|
-
if (isPrimitiveKey(key)) {
|
|
1176
|
-
const encoded = encodeKey(key);
|
|
1177
|
-
const prefix = `${encoded.slice(0, -1)},`;
|
|
1178
|
-
return encodedKey => encodedKey === encoded || encodedKey.startsWith(prefix);
|
|
1179
|
-
}
|
|
1180
|
-
return encodedKey => partialMatch(key, decodeKey(encodedKey));
|
|
1181
|
-
};
|
|
1182
1171
|
/**
|
|
1183
1172
|
* ```js
|
|
1184
1173
|
* import { queryCache } from '@amityco/ts-sdk'
|
|
@@ -1199,9 +1188,11 @@ const queryCache = (key) => {
|
|
|
1199
1188
|
if (!cache)
|
|
1200
1189
|
return;
|
|
1201
1190
|
log('cache/api/queryCache', { key });
|
|
1202
|
-
const matches = createMatcher(key);
|
|
1203
1191
|
return Object.keys(cache.data)
|
|
1204
|
-
.filter(
|
|
1192
|
+
.filter(stringKey => {
|
|
1193
|
+
const decodedKey = decodeKey(stringKey);
|
|
1194
|
+
return partialMatch(key, decodedKey);
|
|
1195
|
+
})
|
|
1205
1196
|
.map(stringKey => cache.data[stringKey]);
|
|
1206
1197
|
};
|
|
1207
1198
|
|
|
@@ -27752,8 +27743,40 @@ getCommentByIds.locally = (commentIds) => {
|
|
|
27752
27743
|
};
|
|
27753
27744
|
};
|
|
27754
27745
|
|
|
27746
|
+
const GIF_OPTIONAL_KEYS = ['width', 'height'];
|
|
27747
|
+
/*
|
|
27748
|
+
* The server refuses a GIF attachment that carries `null` or any key it does not know, so the
|
|
27749
|
+
* request keeps `type`, `url` and only the optional fields that have a value. The SDK does not
|
|
27750
|
+
* check the values themselves: the server answers 400 for a bad one.
|
|
27751
|
+
*/
|
|
27752
|
+
const toGifAttachmentPayload = (gif) => {
|
|
27753
|
+
const payload = { type: 'gif', url: gif.url };
|
|
27754
|
+
GIF_OPTIONAL_KEYS.forEach(key => {
|
|
27755
|
+
const value = gif[key];
|
|
27756
|
+
if (value !== undefined && value !== null)
|
|
27757
|
+
Object.assign(payload, { [key]: value });
|
|
27758
|
+
});
|
|
27759
|
+
return payload;
|
|
27760
|
+
};
|
|
27761
|
+
/* Builds each GIF from its known keys; every other attachment is sent as the caller gave it. */
|
|
27762
|
+
const toAttachmentsPayload = (attachments) => attachments.map(attachment => attachment.type === 'gif'
|
|
27763
|
+
? toGifAttachmentPayload(attachment)
|
|
27764
|
+
: attachment);
|
|
27765
|
+
|
|
27766
|
+
/*
|
|
27767
|
+
* The data types the server lists for a comment, known before it answers: one per attachment
|
|
27768
|
+
* type, plus `text` when there is text. Sorted, as the server sorts them.
|
|
27769
|
+
*/
|
|
27770
|
+
const commentDataTypesOf = (text, attachments) => {
|
|
27771
|
+
const types = new Set((attachments !== null && attachments !== void 0 ? attachments : []).map(attachment => attachment.type));
|
|
27772
|
+
if (text)
|
|
27773
|
+
types.add('text');
|
|
27774
|
+
return [...types].sort();
|
|
27775
|
+
};
|
|
27776
|
+
|
|
27755
27777
|
const getLocalCommentId = () => uuid();
|
|
27756
27778
|
const createCommentOptimistic = (bundle) => {
|
|
27779
|
+
var _a;
|
|
27757
27780
|
const client = getActiveClient();
|
|
27758
27781
|
if (!client.cache)
|
|
27759
27782
|
return;
|
|
@@ -27788,6 +27811,7 @@ const createCommentOptimistic = (bundle) => {
|
|
|
27788
27811
|
targetId: '',
|
|
27789
27812
|
targetType: 'community',
|
|
27790
27813
|
dataType: 'text',
|
|
27814
|
+
dataTypes: commentDataTypesOf((_a = bundle.data) === null || _a === void 0 ? void 0 : _a.text, bundle.attachments),
|
|
27791
27815
|
syncState: "syncing" /* Amity.SyncState.Syncing */,
|
|
27792
27816
|
// In a gated community the optimistic object stays out of public collections until the
|
|
27793
27817
|
// response settles the status; the author's own view still updates through the local event
|
|
@@ -27834,12 +27858,15 @@ const createCommentOptimistic = (bundle) => {
|
|
|
27834
27858
|
const createComment = async (bundle, isOptimistic = true) => {
|
|
27835
27859
|
const client = getActiveClient();
|
|
27836
27860
|
client.log('comment/createComment', Object.assign(Object.assign({}, bundle), { isOptimistic }));
|
|
27861
|
+
// A GIF is sent with its known keys only; the server refuses `null` and unknown keys.
|
|
27862
|
+
const request = bundle.attachments
|
|
27863
|
+
? Object.assign(Object.assign({}, bundle), { attachments: toAttachmentsPayload(bundle.attachments) }) : bundle;
|
|
27837
27864
|
// Without a local comment the server assigns the id; with one, the same id travels through the
|
|
27838
27865
|
// optimistic object, the response and every realtime event so each step recognises it.
|
|
27839
|
-
const optimisticData = isOptimistic ? createCommentOptimistic(
|
|
27866
|
+
const optimisticData = isOptimistic ? createCommentOptimistic(request) : undefined;
|
|
27840
27867
|
const commentId = optimisticData === null || optimisticData === void 0 ? void 0 : optimisticData.commentId;
|
|
27841
27868
|
try {
|
|
27842
|
-
const { data: payload } = await client.http.post('/api/v3/comments', Object.assign(Object.assign({},
|
|
27869
|
+
const { data: payload } = await client.http.post('/api/v3/comments', Object.assign(Object.assign({}, request), { commentId }));
|
|
27843
27870
|
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
27844
27871
|
if (payload.comments.length === 0)
|
|
27845
27872
|
throw new Error('Comment not created');
|
|
@@ -27932,9 +27959,16 @@ const createComment = async (bundle, isOptimistic = true) => {
|
|
|
27932
27959
|
* const updated = await CommentRepository.updateComment(commentId, {
|
|
27933
27960
|
* data: { text: 'hello world' }
|
|
27934
27961
|
* })
|
|
27962
|
+
*
|
|
27963
|
+
* // Replace the GIF, or remove it and keep the text
|
|
27964
|
+
* await CommentRepository.updateComment(commentId, {
|
|
27965
|
+
* attachments: [{ type: 'gif', url: 'https://media.giphy.com/media/l0MYt5jPR6QX5pnqM/giphy.gif' }],
|
|
27966
|
+
* })
|
|
27967
|
+
* await CommentRepository.updateComment(commentId, { attachments: [] })
|
|
27935
27968
|
* ```
|
|
27936
27969
|
*
|
|
27937
|
-
* Updates an {@link Amity.Comment}
|
|
27970
|
+
* Updates an {@link Amity.Comment}. `attachments` replaces the current ones, `[]` removes them,
|
|
27971
|
+
* and leaving `attachments` out keeps them as they are.
|
|
27938
27972
|
*
|
|
27939
27973
|
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
27940
27974
|
* @param patch The patch data to apply
|
|
@@ -27948,7 +27982,10 @@ const updateComment = async (commentId, patch) => {
|
|
|
27948
27982
|
const client = getActiveClient();
|
|
27949
27983
|
client.log('user/updateComment', patch);
|
|
27950
27984
|
const previous = (_a = pullFromCache(['comment', 'get', commentId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
27951
|
-
|
|
27985
|
+
// A GIF is sent with its known keys only; the server refuses `null` and unknown keys.
|
|
27986
|
+
const body = patch.attachments
|
|
27987
|
+
? Object.assign(Object.assign({}, patch), { attachments: toAttachmentsPayload(patch.attachments) }) : patch;
|
|
27988
|
+
const { data: payload } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, body);
|
|
27952
27989
|
const data = prepareCommentPayload(payload);
|
|
27953
27990
|
const updated = data.comments.find(comment => comment.commentId === commentId);
|
|
27954
27991
|
const cachedAt = client.cache && Date.now();
|
|
@@ -28079,13 +28116,13 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
28079
28116
|
permanent,
|
|
28080
28117
|
},
|
|
28081
28118
|
});
|
|
28082
|
-
// to support hard deletion
|
|
28083
|
-
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
28119
|
+
// to support hard deletion; the server empties a deleted comment's attachments
|
|
28120
|
+
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true, attachments: [] });
|
|
28084
28121
|
if (permanent) {
|
|
28085
28122
|
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
28086
28123
|
}
|
|
28087
28124
|
else {
|
|
28088
|
-
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
28125
|
+
upsertInCache(['comment', 'get', commentId], { isDeleted: true, attachments: [] });
|
|
28089
28126
|
}
|
|
28090
28127
|
if (comment.data.referenceType === 'story') {
|
|
28091
28128
|
const story = await getStoryByStoryId$1(comment.data.referenceId);
|