convex-feedback 0.1.0 → 0.1.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/README.md +281 -92
- package/dist/.tsbuildinfo +1 -1
- package/dist/client/api.d.ts +262 -67
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/config.d.ts +168 -29
- package/dist/client/config.d.ts.map +1 -1
- package/dist/client/config.js.map +1 -1
- package/dist/client/index.d.ts +26 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +4 -4
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/component.d.ts +2 -2
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/comments.d.ts +5 -5
- package/dist/component/entries.d.ts +22 -22
- package/dist/component/entries.d.ts.map +1 -1
- package/dist/component/entries.js +198 -72
- package/dist/component/entries.js.map +1 -1
- package/dist/component/model.d.ts +151 -0
- package/dist/component/model.d.ts.map +1 -1
- package/dist/react/index.d.ts +170 -54
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +67 -4
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client/api.ts +315 -30
- package/src/client/config.ts +191 -29
- package/src/client/index.ts +32 -4
- package/src/component/_generated/component.ts +2 -2
- package/src/component/entries.ts +282 -101
- package/src/component/model.ts +158 -0
- package/src/react/index.ts +206 -6
package/dist/react/index.d.ts
CHANGED
|
@@ -1,44 +1,162 @@
|
|
|
1
1
|
import type { FeedbackPublicApi } from "../client/api.js";
|
|
2
2
|
import type { CommentSort, EntryKind, EntrySort, EntryStatus } from "../component/model.js";
|
|
3
|
+
/**
|
|
4
|
+
* Client-side pagination defaults used by hooks created with
|
|
5
|
+
* `createFeedbackHooks`.
|
|
6
|
+
*
|
|
7
|
+
* These values control initial page sizes and subsequent `loadMore` sizes in
|
|
8
|
+
* the UI. They do not override the server-side maximum page sizes configured
|
|
9
|
+
* on the component.
|
|
10
|
+
*/
|
|
3
11
|
export interface FeedbackHooksOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Number of entries initially requested by `useEntries`.
|
|
14
|
+
*
|
|
15
|
+
* @default 20
|
|
16
|
+
*/
|
|
4
17
|
entryPageSize?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Number of top-level comments initially requested by `useComments`.
|
|
20
|
+
*
|
|
21
|
+
* @default 20
|
|
22
|
+
*/
|
|
5
23
|
commentPageSize?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Number of direct child replies initially requested when
|
|
26
|
+
* `parentCommentId` is supplied to `useComments`.
|
|
27
|
+
*
|
|
28
|
+
* @default 10
|
|
29
|
+
*/
|
|
6
30
|
replyPageSize?: number;
|
|
7
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Arguments accepted by `useEntries`.
|
|
34
|
+
*/
|
|
8
35
|
export interface UseEntriesArgs {
|
|
9
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Entry kinds to include.
|
|
38
|
+
*
|
|
39
|
+
* Filtering occurs in Convex before pagination. Omit to include every kind.
|
|
40
|
+
*
|
|
41
|
+
* The hook accepts a readonly array so configuration constants such as
|
|
42
|
+
* `readonly EntryKind[]` can be passed directly.
|
|
43
|
+
*/
|
|
44
|
+
kinds?: readonly EntryKind[];
|
|
45
|
+
/** Optional workflow-status filter. */
|
|
10
46
|
status?: EntryStatus;
|
|
47
|
+
/**
|
|
48
|
+
* Server-side entry ordering.
|
|
49
|
+
*
|
|
50
|
+
* When omitted, the host's configured default is used.
|
|
51
|
+
*/
|
|
11
52
|
sort?: EntrySort;
|
|
12
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Arguments accepted by `useComments`.
|
|
56
|
+
*
|
|
57
|
+
* Comment trees are intentionally loaded lazily. Every invocation retrieves
|
|
58
|
+
* exactly one level of the tree.
|
|
59
|
+
*/
|
|
13
60
|
export interface UseCommentsArgs {
|
|
61
|
+
/** Entry whose comments are being requested. */
|
|
14
62
|
entryId: string;
|
|
63
|
+
/**
|
|
64
|
+
* Direct parent whose replies should be requested.
|
|
65
|
+
*
|
|
66
|
+
* - Omitted → returns top-level comments.
|
|
67
|
+
* - Supplied → returns only direct children of this comment.
|
|
68
|
+
*
|
|
69
|
+
* Grandchildren and deeper descendants are never automatically loaded.
|
|
70
|
+
* Call `useComments` again with the child comment's ID when that branch is
|
|
71
|
+
* expanded.
|
|
72
|
+
*/
|
|
15
73
|
parentCommentId?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Server-side ordering for this level of comments.
|
|
76
|
+
*
|
|
77
|
+
* When omitted, the host's configured default is used.
|
|
78
|
+
*/
|
|
16
79
|
sort?: CommentSort;
|
|
17
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Arguments accepted by `useSearchEntries`.
|
|
83
|
+
*/
|
|
18
84
|
export interface SearchEntriesArgs {
|
|
85
|
+
/**
|
|
86
|
+
* Full-text query.
|
|
87
|
+
*
|
|
88
|
+
* Whitespace-only values skip the Convex query and return an empty array.
|
|
89
|
+
*/
|
|
19
90
|
searchQuery: string;
|
|
20
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Entry kinds to include.
|
|
93
|
+
*
|
|
94
|
+
* Filtering occurs on the server.
|
|
95
|
+
*/
|
|
96
|
+
kinds?: readonly EntryKind[];
|
|
97
|
+
/** Optional workflow-status filter. */
|
|
21
98
|
status?: EntryStatus;
|
|
99
|
+
/**
|
|
100
|
+
* Maximum number of results requested.
|
|
101
|
+
*
|
|
102
|
+
* The server applies its configured default when omitted and clamps the
|
|
103
|
+
* value to its configured maximum.
|
|
104
|
+
*/
|
|
22
105
|
limit?: number;
|
|
23
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Arguments accepted by `useSimilarEntries`.
|
|
109
|
+
*/
|
|
24
110
|
export interface SimilarEntriesArgs {
|
|
111
|
+
/**
|
|
112
|
+
* Proposed entry title.
|
|
113
|
+
*
|
|
114
|
+
* Used both for normalized exact-title matching and full-text search.
|
|
115
|
+
*/
|
|
25
116
|
title: string;
|
|
117
|
+
/**
|
|
118
|
+
* Proposed entry body.
|
|
119
|
+
*
|
|
120
|
+
* Used together with the title for full-text similarity search.
|
|
121
|
+
*/
|
|
26
122
|
body: string;
|
|
123
|
+
/**
|
|
124
|
+
* Restricts duplicate detection to one entry kind.
|
|
125
|
+
*
|
|
126
|
+
* Omit to search every kind.
|
|
127
|
+
*/
|
|
27
128
|
kind?: EntryKind;
|
|
129
|
+
/**
|
|
130
|
+
* Maximum combined number of suggestions requested.
|
|
131
|
+
*
|
|
132
|
+
* Exact normalized-title matches consume the limit first. Only remaining
|
|
133
|
+
* slots may be filled by relevance-ranked full-text matches.
|
|
134
|
+
*
|
|
135
|
+
* For example, `limit: 3` with two exact matches can return at most one
|
|
136
|
+
* additional similar match.
|
|
137
|
+
*/
|
|
28
138
|
limit?: number;
|
|
29
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Creates React hooks bound to a host application's exposed feedback API.
|
|
142
|
+
*
|
|
143
|
+
* Create this once in the consuming application and reuse the returned hook
|
|
144
|
+
* collection.
|
|
145
|
+
*/
|
|
30
146
|
export declare function createFeedbackHooks(api: FeedbackPublicApi, options?: FeedbackHooksOptions): {
|
|
147
|
+
/**
|
|
148
|
+
* Resolved client-side page sizes used by the generated hooks and useful
|
|
149
|
+
* when calling their `loadMore` functions.
|
|
150
|
+
*/
|
|
31
151
|
pageSizes: {
|
|
32
152
|
readonly entries: number;
|
|
33
153
|
readonly comments: number;
|
|
34
154
|
readonly replies: number;
|
|
35
155
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
sort?: EntrySort;
|
|
41
|
-
}, import("convex/server").PaginationResult<{
|
|
156
|
+
/**
|
|
157
|
+
* Returns a cursor-paginated, server-filtered entry list.
|
|
158
|
+
*/
|
|
159
|
+
useEntries(args?: UseEntriesArgs): import("convex/react").UsePaginatedQueryReturnType<import("convex/server").FunctionReference<"query", "public", import("../client/api.js").ListEntriesArgs, import("convex/server").PaginationResult<{
|
|
42
160
|
updatedAt?: number | undefined;
|
|
43
161
|
id: string;
|
|
44
162
|
creationTime: number;
|
|
@@ -51,6 +169,11 @@ export declare function createFeedbackHooks(api: FeedbackPublicApi, options?: Fe
|
|
|
51
169
|
commentCount: number;
|
|
52
170
|
viewerHasUpvoted: boolean;
|
|
53
171
|
}>, string | undefined>>;
|
|
172
|
+
/**
|
|
173
|
+
* Reactively retrieves one entry.
|
|
174
|
+
*
|
|
175
|
+
* Passing `null` or `undefined` skips the query.
|
|
176
|
+
*/
|
|
54
177
|
useEntry(entryId: string | null | undefined): {
|
|
55
178
|
updatedAt?: number | undefined;
|
|
56
179
|
id: string;
|
|
@@ -64,6 +187,11 @@ export declare function createFeedbackHooks(api: FeedbackPublicApi, options?: Fe
|
|
|
64
187
|
commentCount: number;
|
|
65
188
|
viewerHasUpvoted: boolean;
|
|
66
189
|
} | null | undefined;
|
|
190
|
+
/**
|
|
191
|
+
* Performs reactive full-text entry search.
|
|
192
|
+
*
|
|
193
|
+
* An empty/whitespace-only query returns `[]` without running Convex.
|
|
194
|
+
*/
|
|
67
195
|
useSearchEntries(args: SearchEntriesArgs): {
|
|
68
196
|
updatedAt?: number | undefined;
|
|
69
197
|
id: string;
|
|
@@ -77,6 +205,14 @@ export declare function createFeedbackHooks(api: FeedbackPublicApi, options?: Fe
|
|
|
77
205
|
commentCount: number;
|
|
78
206
|
viewerHasUpvoted: boolean;
|
|
79
207
|
}[] | undefined;
|
|
208
|
+
/**
|
|
209
|
+
* Reactively finds exact and similar entries for a proposed draft.
|
|
210
|
+
*
|
|
211
|
+
* The query is skipped only when both title and body are blank.
|
|
212
|
+
*
|
|
213
|
+
* `limit` is forwarded to the server unchanged. The server applies the
|
|
214
|
+
* combined exact-first limit semantics documented by `SimilarEntriesArgs`.
|
|
215
|
+
*/
|
|
80
216
|
useSimilarEntries(args: SimilarEntriesArgs): {
|
|
81
217
|
exact: {
|
|
82
218
|
updatedAt?: number | undefined;
|
|
@@ -105,12 +241,10 @@ export declare function createFeedbackHooks(api: FeedbackPublicApi, options?: Fe
|
|
|
105
241
|
viewerHasUpvoted: boolean;
|
|
106
242
|
}[];
|
|
107
243
|
} | undefined;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
sort?: CommentSort;
|
|
113
|
-
}, import("convex/server").PaginationResult<{
|
|
244
|
+
/**
|
|
245
|
+
* Returns one independently paginated level of comments.
|
|
246
|
+
*/
|
|
247
|
+
useComments(args: UseCommentsArgs): import("convex/react").UsePaginatedQueryReturnType<import("convex/server").FunctionReference<"query", "public", import("../client/api.js").ListCommentsArgs, import("convex/server").PaginationResult<{
|
|
114
248
|
updatedAt?: number | undefined;
|
|
115
249
|
parentCommentId?: string | undefined;
|
|
116
250
|
deletedAt?: number | undefined;
|
|
@@ -124,46 +258,28 @@ export declare function createFeedbackHooks(api: FeedbackPublicApi, options?: Fe
|
|
|
124
258
|
replyCount: number;
|
|
125
259
|
viewerHasLiked: boolean;
|
|
126
260
|
}>, string | undefined>>;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
desiredState: boolean;
|
|
144
|
-
}, {
|
|
145
|
-
active: boolean;
|
|
146
|
-
upvoteCount: number;
|
|
147
|
-
}, string | undefined>>;
|
|
148
|
-
useCreateComment(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", {
|
|
149
|
-
entryId: string;
|
|
150
|
-
parentCommentId?: string;
|
|
151
|
-
body: string;
|
|
152
|
-
}, string, string | undefined>>;
|
|
153
|
-
useUpdateComment(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", {
|
|
154
|
-
commentId: string;
|
|
155
|
-
body: string;
|
|
156
|
-
}, null, string | undefined>>;
|
|
157
|
-
useDeleteComment(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", {
|
|
158
|
-
commentId: string;
|
|
159
|
-
}, null, string | undefined>>;
|
|
160
|
-
useSetCommentLike(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", {
|
|
161
|
-
commentId: string;
|
|
162
|
-
desiredState: boolean;
|
|
163
|
-
}, {
|
|
164
|
-
active: boolean;
|
|
165
|
-
likeCount: number;
|
|
166
|
-
}, string | undefined>>;
|
|
261
|
+
/** Returns the bound create-entry mutation. */
|
|
262
|
+
useCreateEntry(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", import("../client/api.js").CreateEntryArgs, string, string | undefined>>;
|
|
263
|
+
/** Returns the bound update-entry mutation. */
|
|
264
|
+
useUpdateEntry(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", import("../client/api.js").UpdateEntryArgs, null, string | undefined>>;
|
|
265
|
+
/** Returns the bound status mutation. */
|
|
266
|
+
useSetEntryStatus(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", import("../client/api.js").SetEntryStatusArgs, null, string | undefined>>;
|
|
267
|
+
/** Returns the idempotent entry-upvote state mutation. */
|
|
268
|
+
useSetEntryUpvote(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", import("../client/api.js").SetEntryUpvoteArgs, import("../client/api.js").SetEntryUpvoteResult, string | undefined>>;
|
|
269
|
+
/** Returns the create-comment/reply mutation. */
|
|
270
|
+
useCreateComment(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", import("../client/api.js").CreateCommentArgs, string, string | undefined>>;
|
|
271
|
+
/** Returns the update-comment mutation. */
|
|
272
|
+
useUpdateComment(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", import("../client/api.js").UpdateCommentArgs, null, string | undefined>>;
|
|
273
|
+
/** Returns the soft-delete-comment mutation. */
|
|
274
|
+
useDeleteComment(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", import("../client/api.js").DeleteCommentArgs, null, string | undefined>>;
|
|
275
|
+
/** Returns the idempotent comment-like state mutation. */
|
|
276
|
+
useSetCommentLike(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", import("../client/api.js").SetCommentLikeArgs, import("../client/api.js").SetCommentLikeResult, string | undefined>>;
|
|
167
277
|
};
|
|
278
|
+
/**
|
|
279
|
+
* Hook collection returned by `createFeedbackHooks`.
|
|
280
|
+
*
|
|
281
|
+
* This type is intended to be passed to `FeedbackScreen` and other
|
|
282
|
+
* `convex-feedback-ui` integrations.
|
|
283
|
+
*/
|
|
168
284
|
export type FeedbackHooks = ReturnType<typeof createFeedbackHooks>;
|
|
169
285
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,EAEZ,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;OAOG;IACH,KAAK,CAAC,E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C,+CAA+C;;IAK/C,yCAAyC;;IAKzC,0DAA0D;;IAK1D,iDAAiD;;IAKjD,2CAA2C;;IAK3C,gDAAgD;;IAKhD,0DAA0D;;EAK7D;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/dist/react/index.js
CHANGED
|
@@ -1,65 +1,128 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { usePaginatedQuery } from "convex-helpers/react";
|
|
3
3
|
import { useMutation, useQuery } from "convex/react";
|
|
4
|
+
const emptySimilarEntriesResult = {
|
|
5
|
+
exact: [],
|
|
6
|
+
similar: [],
|
|
7
|
+
};
|
|
4
8
|
function positivePageSize(value, fallback) {
|
|
5
9
|
return value !== undefined && Number.isInteger(value) && value > 0
|
|
6
10
|
? value
|
|
7
11
|
: fallback;
|
|
8
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates React hooks bound to a host application's exposed feedback API.
|
|
15
|
+
*
|
|
16
|
+
* Create this once in the consuming application and reuse the returned hook
|
|
17
|
+
* collection.
|
|
18
|
+
*/
|
|
9
19
|
export function createFeedbackHooks(api, options = {}) {
|
|
10
20
|
const entryPageSize = positivePageSize(options.entryPageSize, 20);
|
|
11
21
|
const commentPageSize = positivePageSize(options.commentPageSize, 20);
|
|
12
22
|
const replyPageSize = positivePageSize(options.replyPageSize, 10);
|
|
13
23
|
return {
|
|
24
|
+
/**
|
|
25
|
+
* Resolved client-side page sizes used by the generated hooks and useful
|
|
26
|
+
* when calling their `loadMore` functions.
|
|
27
|
+
*/
|
|
14
28
|
pageSizes: {
|
|
15
29
|
entries: entryPageSize,
|
|
16
30
|
comments: commentPageSize,
|
|
17
31
|
replies: replyPageSize,
|
|
18
32
|
},
|
|
33
|
+
/**
|
|
34
|
+
* Returns a cursor-paginated, server-filtered entry list.
|
|
35
|
+
*/
|
|
19
36
|
useEntries(args = {}) {
|
|
20
|
-
|
|
37
|
+
const queryArgs = {
|
|
38
|
+
...(args.kinds === undefined ? {} : { kinds: [...args.kinds] }),
|
|
39
|
+
...(args.status === undefined ? {} : { status: args.status }),
|
|
40
|
+
...(args.sort === undefined ? {} : { sort: args.sort }),
|
|
41
|
+
};
|
|
42
|
+
return usePaginatedQuery(api.listEntries, queryArgs, {
|
|
21
43
|
initialNumItems: entryPageSize,
|
|
22
44
|
});
|
|
23
45
|
},
|
|
46
|
+
/**
|
|
47
|
+
* Reactively retrieves one entry.
|
|
48
|
+
*
|
|
49
|
+
* Passing `null` or `undefined` skips the query.
|
|
50
|
+
*/
|
|
24
51
|
useEntry(entryId) {
|
|
25
52
|
return useQuery(api.getEntry, entryId === null || entryId === undefined ? "skip" : { entryId });
|
|
26
53
|
},
|
|
54
|
+
/**
|
|
55
|
+
* Performs reactive full-text entry search.
|
|
56
|
+
*
|
|
57
|
+
* An empty/whitespace-only query returns `[]` without running Convex.
|
|
58
|
+
*/
|
|
27
59
|
useSearchEntries(args) {
|
|
28
60
|
const searchQuery = args.searchQuery.trim();
|
|
29
|
-
const
|
|
61
|
+
const queryArgs = {
|
|
62
|
+
searchQuery,
|
|
63
|
+
...(args.kinds === undefined ? {} : { kinds: [...args.kinds] }),
|
|
64
|
+
...(args.status === undefined ? {} : { status: args.status }),
|
|
65
|
+
...(args.limit === undefined ? {} : { limit: args.limit }),
|
|
66
|
+
};
|
|
67
|
+
const result = useQuery(api.searchEntries, searchQuery.length === 0 ? "skip" : queryArgs);
|
|
30
68
|
return searchQuery.length === 0 ? [] : result;
|
|
31
69
|
},
|
|
70
|
+
/**
|
|
71
|
+
* Reactively finds exact and similar entries for a proposed draft.
|
|
72
|
+
*
|
|
73
|
+
* The query is skipped only when both title and body are blank.
|
|
74
|
+
*
|
|
75
|
+
* `limit` is forwarded to the server unchanged. The server applies the
|
|
76
|
+
* combined exact-first limit semantics documented by `SimilarEntriesArgs`.
|
|
77
|
+
*/
|
|
32
78
|
useSimilarEntries(args) {
|
|
33
79
|
const shouldSkip = args.title.trim().length === 0 && args.body.trim().length === 0;
|
|
34
|
-
const
|
|
35
|
-
|
|
80
|
+
const queryArgs = {
|
|
81
|
+
title: args.title,
|
|
82
|
+
body: args.body,
|
|
83
|
+
...(args.kind === undefined ? {} : { kind: args.kind }),
|
|
84
|
+
...(args.limit === undefined ? {} : { limit: args.limit }),
|
|
85
|
+
};
|
|
86
|
+
const result = useQuery(api.findSimilarEntries, shouldSkip ? "skip" : queryArgs);
|
|
87
|
+
return shouldSkip ? emptySimilarEntriesResult : result;
|
|
36
88
|
},
|
|
89
|
+
/**
|
|
90
|
+
* Returns one independently paginated level of comments.
|
|
91
|
+
*/
|
|
37
92
|
useComments(args) {
|
|
38
93
|
return usePaginatedQuery(api.listComments, args, {
|
|
39
94
|
initialNumItems: args.parentCommentId === undefined ? commentPageSize : replyPageSize,
|
|
40
95
|
});
|
|
41
96
|
},
|
|
97
|
+
/** Returns the bound create-entry mutation. */
|
|
42
98
|
useCreateEntry() {
|
|
43
99
|
return useMutation(api.createEntry);
|
|
44
100
|
},
|
|
101
|
+
/** Returns the bound update-entry mutation. */
|
|
45
102
|
useUpdateEntry() {
|
|
46
103
|
return useMutation(api.updateEntry);
|
|
47
104
|
},
|
|
105
|
+
/** Returns the bound status mutation. */
|
|
48
106
|
useSetEntryStatus() {
|
|
49
107
|
return useMutation(api.setEntryStatus);
|
|
50
108
|
},
|
|
109
|
+
/** Returns the idempotent entry-upvote state mutation. */
|
|
51
110
|
useSetEntryUpvote() {
|
|
52
111
|
return useMutation(api.setEntryUpvote);
|
|
53
112
|
},
|
|
113
|
+
/** Returns the create-comment/reply mutation. */
|
|
54
114
|
useCreateComment() {
|
|
55
115
|
return useMutation(api.createComment);
|
|
56
116
|
},
|
|
117
|
+
/** Returns the update-comment mutation. */
|
|
57
118
|
useUpdateComment() {
|
|
58
119
|
return useMutation(api.updateComment);
|
|
59
120
|
},
|
|
121
|
+
/** Returns the soft-delete-comment mutation. */
|
|
60
122
|
useDeleteComment() {
|
|
61
123
|
return useMutation(api.deleteComment);
|
|
62
124
|
},
|
|
125
|
+
/** Returns the idempotent comment-like state mutation. */
|
|
63
126
|
useSetCommentLike() {
|
|
64
127
|
return useMutation(api.setCommentLike);
|
|
65
128
|
},
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAqKrD,MAAM,yBAAyB,GAAyB;IACtD,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,SAAS,gBAAgB,CAAC,KAAyB,EAAE,QAAgB;IACnE,OAAO,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAChE,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,QAAQ,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,GAAsB,EACtB,UAAgC,EAAE;IAElC,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IAClE,MAAM,eAAe,GAAG,gBAAgB,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IACtE,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IAElE,OAAO;QACL;;;WAG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