@pkcprotocol/pkc-js 0.0.112 → 0.0.113
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 +4 -4
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/pages/pkc-js-page-sorts/active.js +3 -2
- package/dist/browser/pages/pkc-js-page-sorts/active.js.map +1 -1
- package/dist/browser/publications/comment/schema.js +4 -4
- package/dist/browser/publications/comment/schema.js.map +1 -1
- package/dist/browser/runtime/node/community/db-handler.d.ts +1 -0
- package/dist/browser/runtime/node/community/db-handler.js +50 -35
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/version.js +1 -1
- package/dist/bundled/bundle-manifest.json +43 -43
- package/dist/bundled/chunks/{helia-for-pkc-DDLK491v.js → helia-for-pkc-DoOp7t8V.js} +33 -33
- package/dist/bundled/chunks/{local-community-kjNJHOud.js → local-community-CFX753RE.js} +1 -1
- package/dist/bundled/chunks/{local-community-DJGHwkuK.js → local-community-CaV30etW.js} +66 -55
- package/dist/bundled/chunks/{node-C_wuNW9S.js → node-gyqBss4j.js} +5 -5
- package/dist/bundled/chunks/{rpc-local-community-BHSnYv5v.js → rpc-local-community-DWv8wZMB.js} +1 -1
- package/dist/bundled/chunks/{util-C68VdI47.js → util-B9JenRyE.js} +2 -2
- package/dist/bundled/chunks/{util-BuDJJAAP.js → util-CH8WrVZq.js} +1 -1
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/pages/pkc-js-page-sorts/active.js +3 -2
- package/dist/node/pages/pkc-js-page-sorts/active.js.map +1 -1
- package/dist/node/publications/comment/schema.js +4 -4
- package/dist/node/publications/comment/schema.js.map +1 -1
- package/dist/node/runtime/node/community/db-handler.d.ts +1 -0
- package/dist/node/runtime/node/community/db-handler.js +50 -35
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,8 +92,8 @@ CommentUpdate /* (IPFS file) */ {
|
|
|
92
92
|
upvoteCount: number
|
|
93
93
|
downvoteCount: number
|
|
94
94
|
replies?: Pages // only preload page 1 sorted by 'best', might preload more later, only provide sorting for posts (not comments) that have 100+ child comments
|
|
95
|
-
replyCount: number
|
|
96
|
-
childCount?: number // the
|
|
95
|
+
replyCount: number // direct and indirect replies; removed, deleted, disapproved and pending replies are not counted, the present replies under them are (docs/protocol/comment-lifecycle.md, "Which Replies Count")
|
|
96
|
+
childCount?: number // the direct replies replyCount counts, does not include indirect replies
|
|
97
97
|
number?: number // sequential comment number assigned by the community
|
|
98
98
|
postNumber?: number // sequential post number assigned by the community
|
|
99
99
|
flairs?: Flair[] // arbitrary colored strings to describe the comment, added by mods, override comment.flairs and comment.edit.flairs (which are added by author)
|
|
@@ -111,8 +111,8 @@ CommentUpdate /* (IPFS file) */ {
|
|
|
111
111
|
author?: { // add commentUpdate.author.community to comment.author.community, override comment.author.flairs with commentUpdate.author.community.flairs if any
|
|
112
112
|
community: CommunityAuthor
|
|
113
113
|
}
|
|
114
|
-
lastReplyTimestamp?: number // the timestamp of the most recent
|
|
115
|
-
lastChildCid?: string // the CID of the most recent direct
|
|
114
|
+
lastReplyTimestamp?: number // the timestamp of the most recent reply that replyCount counts, so removing a reply un-bumps its thread
|
|
115
|
+
lastChildCid?: string // the CID of the most recent direct reply that childCount counts
|
|
116
116
|
}
|
|
117
117
|
Author {
|
|
118
118
|
address: string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.113";
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// CommentUpdate already carries as lastReplyTimestamp (the recursive MAX(timestamp) the community computes when a
|
|
3
3
|
// descendant changes, before pages are generated in the same cycle). A per-comment score like every other built-in,
|
|
4
4
|
// so a client re-sorts by bump order from the page alone. lastReplyTimestamp hard-codes the removed/deleted/unapproved
|
|
5
|
-
// exclusions
|
|
6
|
-
// threads: bump time is
|
|
5
|
+
// exclusions at every depth (a removed or deleted reply never bumps; the present replies under it do), so an owner
|
|
6
|
+
// who turns excludeRemovedComments off for posts still does not get removed replies bumping threads: bump time is
|
|
7
|
+
// what the CommentUpdate carries.
|
|
7
8
|
const active = () => ({
|
|
8
9
|
sortName: "active",
|
|
9
10
|
description: "Most recently bumped first: posts ordered by the newest reply anywhere in their thread",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active.js","sourceRoot":"","sources":["../../../../src/pages/pkc-js-page-sorts/active.ts"],"names":[],"mappings":"AAEA,iHAAiH;AACjH,kHAAkH;AAClH,oHAAoH;AACpH,uHAAuH;AACvH,
|
|
1
|
+
{"version":3,"file":"active.js","sourceRoot":"","sources":["../../../../src/pages/pkc-js-page-sorts/active.ts"],"names":[],"mappings":"AAEA,iHAAiH;AACjH,kHAAkH;AAClH,oHAAoH;AACpH,uHAAuH;AACvH,mHAAmH;AACnH,kHAAkH;AAClH,kCAAkC;AAClC,MAAM,MAAM,GAAwB,GAAG,EAAE,CAAC,CAAC;IACvC,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,wFAAwF;IACrG,YAAY,EAAE,EAAE,EAAE,4EAA4E;IAC9F,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,kBAAkB,IAAI,CAAC,CAAC;CAC5G,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -85,8 +85,8 @@ export const CommentUpdateSchema = z
|
|
|
85
85
|
cid: CidStringSchema, // cid of the comment, need it in signature to prevent attack
|
|
86
86
|
upvoteCount: z.number().nonnegative().int(),
|
|
87
87
|
downvoteCount: z.number().nonnegative().int(),
|
|
88
|
-
replyCount: z.number().nonnegative().int(), // the total of reply trees underneath this comment, which includes direct and indirect children
|
|
89
|
-
childCount: z.number().nonnegative().int().optional(), // the
|
|
88
|
+
replyCount: z.number().nonnegative().int(), // the total of reply trees underneath this comment, which includes direct and indirect children; removed, deleted, disapproved and pending replies are not counted, the present replies under them are (docs/protocol/comment-lifecycle.md)
|
|
89
|
+
childCount: z.number().nonnegative().int().optional(), // the direct replies replyCount counts, does not include indirect replies
|
|
90
90
|
number: z.number().int().positive().optional(),
|
|
91
91
|
postNumber: z.number().int().positive().optional(),
|
|
92
92
|
edit: CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema.optional(), // most recent edit by comment author, commentUpdate.edit.content, commentUpdate.edit.deleted, commentUpdate.edit.flairs override Comment instance props. Validate commentUpdate.edit.signature
|
|
@@ -101,8 +101,8 @@ export const CommentUpdateSchema = z
|
|
|
101
101
|
approved: z.boolean().optional(), // if comment was pending approval and it got approved or disapproved. Does not apply to comments pending approvals, you need to use moderation.pageCids.pendingApproval to fetch pending comments
|
|
102
102
|
updatedAt: PKCTimestampSchema, // timestamp in seconds the CommentUpdate was updated
|
|
103
103
|
author: AuthorWithCommentUpdateSchema.pick({ community: true }).optional(), // add commentUpdate.author.community to comment.author.community, override comment.author.flairs with commentUpdate.author.community.flairs if any
|
|
104
|
-
lastChildCid: CidStringSchema.optional(), // The cid of the most recent direct
|
|
105
|
-
lastReplyTimestamp: PKCTimestampSchema.optional(), // The timestamp of the most recent
|
|
104
|
+
lastChildCid: CidStringSchema.optional(), // The cid of the most recent direct reply that childCount counts
|
|
105
|
+
lastReplyTimestamp: PKCTimestampSchema.optional(), // The timestamp of the most recent reply that replyCount counts
|
|
106
106
|
signature: JsonSignatureSchema, // signature of the CommentUpdate by the community owner to protect against malicious gateway
|
|
107
107
|
protocolVersion: ProtocolVersionSchema,
|
|
108
108
|
// The getter defers TypeScript inference of the comment-schema <-> pages-schema cycle; the
|
|
@@ -1 +1 @@
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BAAiB;CACpB,CAAC,CAAC;AAEH,gCAAgC"}
|
|
@@ -240,6 +240,7 @@ export declare class DbHandler {
|
|
|
240
240
|
private _calculateCommentUpdates;
|
|
241
241
|
private _cidChunks;
|
|
242
242
|
private _queryVoteCountsByCids;
|
|
243
|
+
private _replyWalkPresentExpression;
|
|
243
244
|
private _queryReplyCountsByParentCids;
|
|
244
245
|
private _queryLastReplyTimestampsByParentCids;
|
|
245
246
|
private _queryLastChildCidsByParentCids;
|
|
@@ -1598,14 +1598,19 @@ export class DbHandler {
|
|
|
1598
1598
|
_collectCommentsToBeUpdated() {
|
|
1599
1599
|
const windowed = this._buildWindowedReplySortArms(timestamp());
|
|
1600
1600
|
const notPending = (alias) => `(${alias}.pendingApproval IS NULL OR ${alias}.pendingApproval != 1)`;
|
|
1601
|
-
|
|
1601
|
+
const countedChildAddress = this._communityAddressClauseNamed("c", "countedChild");
|
|
1602
|
+
// A child that counts towards its parent's childCount: has a CommentUpdate and this community's address, not
|
|
1603
|
+
// removed, not deleted by its author, not disapproved (the rule _queryReplyCountsByParentCids and
|
|
1604
|
+
// _queryLastChildCidsByParentCids apply, or the parent is re-flagged every cycle)
|
|
1602
1605
|
const countedChild = `
|
|
1603
1606
|
FROM ${TABLES.COMMENTS} c
|
|
1604
1607
|
JOIN ${TABLES.COMMENT_UPDATES} cu_child ON c.cid = cu_child.cid
|
|
1605
1608
|
WHERE c.parentCid IS NOT NULL
|
|
1609
|
+
AND ${countedChildAddress.clause}
|
|
1606
1610
|
AND ${notPending("c")}
|
|
1607
1611
|
AND (cu_child.removed IS NOT 1 AND cu_child.removed IS NOT TRUE)
|
|
1608
|
-
AND (json_extract(cu_child.edit, '$.deleted') IS NULL OR json_extract(cu_child.edit, '$.deleted') != 1)
|
|
1612
|
+
AND (json_extract(cu_child.edit, '$.deleted') IS NULL OR json_extract(cu_child.edit, '$.deleted') != 1)
|
|
1613
|
+
AND COALESCE(cu_child.approved, 1) != 0`;
|
|
1609
1614
|
const insert = `INSERT OR IGNORE INTO ${COMMENTS_TO_UPDATE_TEMP_TABLE}`;
|
|
1610
1615
|
const arms = [
|
|
1611
1616
|
`${insert}
|
|
@@ -1637,7 +1642,6 @@ export class DbHandler {
|
|
|
1637
1642
|
WITH last_child_rowids AS (
|
|
1638
1643
|
SELECT c.parentCid AS cid, MAX(c.rowid) AS last_child_rowid
|
|
1639
1644
|
${countedChild}
|
|
1640
|
-
AND COALESCE(cu_child.approved, 1) != 0
|
|
1641
1645
|
GROUP BY c.parentCid
|
|
1642
1646
|
)
|
|
1643
1647
|
SELECT parent.rowid
|
|
@@ -1685,9 +1689,11 @@ export class DbHandler {
|
|
|
1685
1689
|
)
|
|
1686
1690
|
SELECT id FROM parent_chain`
|
|
1687
1691
|
];
|
|
1692
|
+
const allParams = { ...windowed.params, ...countedChildAddress.params };
|
|
1688
1693
|
for (const arm of arms) {
|
|
1689
|
-
// Each statement is bound only to the named parameters it mentions (the windowed arms' window bounds
|
|
1690
|
-
|
|
1694
|
+
// Each statement is bound only to the named parameters it mentions (the windowed arms' window bounds, the
|
|
1695
|
+
// counted-child address)
|
|
1696
|
+
const params = Object.fromEntries(Object.entries(allParams).filter(([name]) => arm.includes(`:${name}`)));
|
|
1691
1697
|
this._prepareCached(arm).run(params);
|
|
1692
1698
|
}
|
|
1693
1699
|
}
|
|
@@ -2294,79 +2300,88 @@ export class DbHandler {
|
|
|
2294
2300
|
}
|
|
2295
2301
|
return result;
|
|
2296
2302
|
}
|
|
2297
|
-
//
|
|
2298
|
-
//
|
|
2299
|
-
//
|
|
2303
|
+
// Whether a comment in a reply walk is present (neither removed, deleted nor disapproved), over the cu and d aliases
|
|
2304
|
+
// the walks join. A comment that is not present is skipped by the counts but still walked through: reply pages keep
|
|
2305
|
+
// it as a tombstone, so the present replies under it are still part of the thread (#405). A disapproved comment
|
|
2306
|
+
// never has replies under it, since publishing under a pending or disapproved comment is rejected.
|
|
2307
|
+
_replyWalkPresentExpression() {
|
|
2308
|
+
return `CASE WHEN (cu.removed IS NOT 1 AND cu.removed IS NOT TRUE) AND (d.deleted_flag IS NULL OR d.deleted_flag != 1) AND COALESCE(cu.approved, 1) != 0 THEN 1 ELSE 0 END`;
|
|
2309
|
+
}
|
|
2310
|
+
// replyCount and childCount of every parent in one recursive walk anchored on all of them: the walk follows every
|
|
2311
|
+
// descendant whose path from the parent has a CommentUpdate and this community's address, and a descendant counts
|
|
2312
|
+
// when it is also present (neither removed, deleted nor disapproved); childCount is the level-1 part of the same count.
|
|
2300
2313
|
_queryReplyCountsByParentCids(parentCids) {
|
|
2301
2314
|
const result = new Map();
|
|
2302
2315
|
const { clause: addrClause, params: addrParams } = this._communityAddressClause("c");
|
|
2303
|
-
const
|
|
2316
|
+
const present = this._replyWalkPresentExpression();
|
|
2304
2317
|
const deletedLookup = `(SELECT cid, json_extract(edit, '$.deleted') AS deleted_flag FROM ${TABLES.COMMENT_UPDATES})`;
|
|
2305
2318
|
for (const { placeholders, params } of this._cidChunks(parentCids, addrParams.length * 2)) {
|
|
2306
|
-
const rows = this._prepareCached(`WITH RECURSIVE descendants(root, cid, level) AS (
|
|
2307
|
-
SELECT c.parentCid, c.cid, 1 FROM ${TABLES.COMMENTS} c
|
|
2319
|
+
const rows = this._prepareCached(`WITH RECURSIVE descendants(root, cid, level, present) AS (
|
|
2320
|
+
SELECT c.parentCid, c.cid, 1, ${present} FROM ${TABLES.COMMENTS} c
|
|
2308
2321
|
INNER JOIN ${TABLES.COMMENT_UPDATES} cu ON c.cid = cu.cid
|
|
2309
2322
|
LEFT JOIN ${deletedLookup} AS d ON c.cid = d.cid
|
|
2310
|
-
WHERE c.parentCid IN (${placeholders}) AND ${
|
|
2323
|
+
WHERE c.parentCid IN (${placeholders}) AND ${addrClause}
|
|
2311
2324
|
UNION ALL
|
|
2312
|
-
SELECT desc_nodes.root, c.cid, desc_nodes.level + 1 FROM ${TABLES.COMMENTS} c
|
|
2325
|
+
SELECT desc_nodes.root, c.cid, desc_nodes.level + 1, ${present} FROM ${TABLES.COMMENTS} c
|
|
2313
2326
|
INNER JOIN ${TABLES.COMMENT_UPDATES} cu ON c.cid = cu.cid
|
|
2314
2327
|
LEFT JOIN ${deletedLookup} AS d ON c.cid = d.cid
|
|
2315
2328
|
JOIN descendants desc_nodes ON c.parentCid = desc_nodes.cid
|
|
2316
|
-
WHERE ${
|
|
2329
|
+
WHERE ${addrClause}
|
|
2317
2330
|
)
|
|
2318
|
-
SELECT root,
|
|
2331
|
+
SELECT root, SUM(present) AS replyCount, SUM(CASE WHEN level = 1 THEN present ELSE 0 END) AS childCount
|
|
2319
2332
|
FROM descendants GROUP BY root`).all(...params, ...addrParams, ...addrParams);
|
|
2320
2333
|
for (const row of rows)
|
|
2321
2334
|
result.set(row.root, { replyCount: row.replyCount, childCount: row.childCount });
|
|
2322
2335
|
}
|
|
2323
2336
|
return result;
|
|
2324
2337
|
}
|
|
2325
|
-
// lastReplyTimestamp of every parent: the newest timestamp
|
|
2326
|
-
//
|
|
2327
|
-
//
|
|
2338
|
+
// lastReplyTimestamp of every parent: the newest timestamp among the replies replyCount counts, with the walk further
|
|
2339
|
+
// narrowed to comments that are not pending. A removed, deleted or disapproved reply does not bump its thread (#403),
|
|
2340
|
+
// but the present replies under it do (#405).
|
|
2328
2341
|
_queryLastReplyTimestampsByParentCids(parentCids) {
|
|
2329
2342
|
const result = new Map();
|
|
2330
2343
|
const { clause: addrClause, params: addrParams } = this._communityAddressClause("c");
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2344
|
+
const walked = `${addrClause} AND (c.pendingApproval IS NULL OR c.pendingApproval != 1)`;
|
|
2345
|
+
const present = this._replyWalkPresentExpression();
|
|
2346
|
+
const deletedLookup = `(SELECT cid, json_extract(edit, '$.deleted') AS deleted_flag FROM ${TABLES.COMMENT_UPDATES})`;
|
|
2347
|
+
for (const { placeholders, params } of this._cidChunks(parentCids, addrParams.length * 2)) {
|
|
2348
|
+
const rows = this._prepareCached(`WITH RECURSIVE descendants(root, cid, timestamp, present) AS (
|
|
2349
|
+
SELECT c.parentCid, c.cid, c.timestamp, ${present} FROM ${TABLES.COMMENTS} c
|
|
2350
|
+
INNER JOIN ${TABLES.COMMENT_UPDATES} cu ON c.cid = cu.cid
|
|
2351
|
+
LEFT JOIN ${deletedLookup} AS d ON c.cid = d.cid
|
|
2352
|
+
WHERE c.parentCid IN (${placeholders}) AND ${walked}
|
|
2338
2353
|
UNION ALL
|
|
2339
|
-
SELECT desc_nodes.root, c.cid, c.timestamp FROM ${TABLES.COMMENTS} c
|
|
2354
|
+
SELECT desc_nodes.root, c.cid, c.timestamp, ${present} FROM ${TABLES.COMMENTS} c
|
|
2340
2355
|
INNER JOIN ${TABLES.COMMENT_UPDATES} cu ON c.cid = cu.cid
|
|
2341
|
-
LEFT JOIN
|
|
2356
|
+
LEFT JOIN ${deletedLookup} AS d ON c.cid = d.cid
|
|
2342
2357
|
JOIN descendants desc_nodes ON c.parentCid = desc_nodes.cid
|
|
2343
|
-
WHERE ${
|
|
2344
|
-
AND COALESCE(cu.approved, 1) != 0
|
|
2345
|
-
AND (c.pendingApproval IS NULL OR c.pendingApproval != 1)
|
|
2358
|
+
WHERE ${walked}
|
|
2346
2359
|
)
|
|
2347
|
-
SELECT root, MAX(timestamp) AS maxTimestamp FROM descendants GROUP BY root`).all(...params, ...addrParams);
|
|
2360
|
+
SELECT root, MAX(CASE WHEN present = 1 THEN timestamp END) AS maxTimestamp FROM descendants GROUP BY root`).all(...params, ...addrParams, ...addrParams);
|
|
2348
2361
|
for (const row of rows)
|
|
2349
2362
|
if (row.maxTimestamp !== null)
|
|
2350
2363
|
result.set(row.root, row.maxTimestamp);
|
|
2351
2364
|
}
|
|
2352
2365
|
return result;
|
|
2353
2366
|
}
|
|
2354
|
-
// lastChildCid of every parent: its newest direct reply that has a CommentUpdate and
|
|
2355
|
-
// removed or deleted (MAX(rowid) with the bare cid column: SQLite returns the cid of that row).
|
|
2367
|
+
// lastChildCid of every parent: its newest direct reply that has a CommentUpdate and this community's address and is
|
|
2368
|
+
// not pending, disapproved, removed or deleted (MAX(rowid) with the bare cid column: SQLite returns the cid of that row).
|
|
2356
2369
|
_queryLastChildCidsByParentCids(parentCids) {
|
|
2357
2370
|
const result = new Map();
|
|
2358
|
-
|
|
2371
|
+
const { clause: addrClause, params: addrParams } = this._communityAddressClause("c");
|
|
2372
|
+
for (const { placeholders, params } of this._cidChunks(parentCids, addrParams.length)) {
|
|
2359
2373
|
const rows = this._prepareCached(`SELECT c.parentCid AS parentCid, c.cid AS cid, MAX(c.rowid) AS lastRowid FROM ${TABLES.COMMENTS} c
|
|
2360
2374
|
INNER JOIN ${TABLES.COMMENT_UPDATES} cu ON cu.cid = c.cid
|
|
2361
2375
|
LEFT JOIN (
|
|
2362
2376
|
SELECT cid, json_extract(edit, '$.deleted') AS deleted_flag FROM ${TABLES.COMMENT_UPDATES}
|
|
2363
2377
|
) deleted_lookup ON deleted_lookup.cid = c.cid
|
|
2364
2378
|
WHERE c.parentCid IN (${placeholders})
|
|
2379
|
+
AND ${addrClause}
|
|
2365
2380
|
AND (c.pendingApproval IS NULL OR c.pendingApproval != 1)
|
|
2366
2381
|
AND COALESCE(cu.approved, 1) != 0
|
|
2367
2382
|
AND (cu.removed IS NOT 1 AND cu.removed IS NOT TRUE)
|
|
2368
2383
|
AND (deleted_lookup.deleted_flag IS NULL OR deleted_lookup.deleted_flag != 1)
|
|
2369
|
-
GROUP BY c.parentCid`).all(...params);
|
|
2384
|
+
GROUP BY c.parentCid`).all(...params, ...addrParams);
|
|
2370
2385
|
for (const row of rows)
|
|
2371
2386
|
result.set(row.parentCid, row.cid);
|
|
2372
2387
|
}
|