refactor: align combined JSON gossip keys with dedicated mixins
Delegate combined mixins (slash/oauth/invite/permission/worker) use the same gossip keysField and initMethod as dedicated *-json-mixin.js modules. Extract platform-message-enrichment.js and platform-delivery-receipts-imports.js from index.js (~38 lines removed). Mesh ingest and heal behavior unchanged. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -54,6 +54,8 @@ Application facade: one `PearcordPlatform` class that wires identity, database,
|
||||
|
||||
**Phase 723 (v0.8.699):** Dedicated slash registry & invoke audit export JSON — `slash-registry-json-mixin.js`, `slash-invoke-audit-json-mixin.js`, spans `slash-registry.json` / `slash-invoke-audit.json`, `getSlashInvokeAuditExportJsonExport`, `clearSlashInvokeAuditExportJsonExports`, deep links `openSlashRegistryJson` / `openSlashInvokeAuditJson`. Bundle: `npm run test:ci-phase723`.
|
||||
|
||||
**Phase 728 (v0.8.704):** Combined delegate json mixins align gossip `keysField` with dedicated mixins; `platform-message-enrichment.js` + `platform-delivery-receipts-imports.js` extracted from index. Bundle: `npm run test:ci-phase728`.
|
||||
|
||||
**Phase 727 (v0.8.703):** Mixin registration extracted to `apply-platform-mixins.js` (59 assigns, same order). `createJsonExportHealDelegateMixin` for slash/oauth/invite/permission/worker combined json mixins. Bundle: `npm run test:ci-phase727`.
|
||||
|
||||
**Phase 726 (v0.8.702):** Legacy combined `*-json-mixin.js` files migrated to `pearcord-json-export-mixin` (`createJsonExportDualHealMixin`, gossip+delegate pattern). All 21 legacy mixins factory-backed; audit keeps custom mod-digest heal. Bundle: `npm run test:ci-phase726`.
|
||||
|
||||
@@ -229,7 +229,7 @@ const {
|
||||
computeArchiveFetchBackoffMs,
|
||||
HookFailureAlertStore,
|
||||
RECEIPTS_COLLECTION
|
||||
} = require('pearcord-delivery-receipts')
|
||||
} = require('./platform-delivery-receipts-imports')
|
||||
const { exportBodyFromSlice } = require('pearcord-shared/signed-json-export')
|
||||
const {
|
||||
listWorkerTemplates,
|
||||
@@ -276,9 +276,7 @@ const {
|
||||
} = require('pearcord-announcement-hub')
|
||||
const {
|
||||
buildHubMirrorCard,
|
||||
formatHubMirrorFallback,
|
||||
parseHubMirrorJson,
|
||||
hubMirrorFromMessage
|
||||
formatHubMirrorFallback
|
||||
} = require('pearcord-hub-cards')
|
||||
const {
|
||||
createInstallToken,
|
||||
@@ -381,9 +379,11 @@ const {
|
||||
FOLDER_COLORS
|
||||
} = require('pearcord-server-folders')
|
||||
const {
|
||||
classifyMessageLayout,
|
||||
LAYOUT
|
||||
} = require('pearcord-message-layout')
|
||||
messageLayoutKind,
|
||||
enrichMessageStickerNames,
|
||||
enrichMessageHubMirror,
|
||||
enrichMessageRow
|
||||
} = require('./platform-message-enrichment')
|
||||
const {
|
||||
COLLECTIONS,
|
||||
CHANNEL_TYPES,
|
||||
@@ -448,44 +448,6 @@ const {
|
||||
const { viewToMask } = require('pearcord-guild-roles/permissions')
|
||||
const { maskToPermissionView, memberPermissionMask } = require('pearcord-guild-roles/permissions')
|
||||
|
||||
function messageLayoutKind (m) {
|
||||
const layout = classifyMessageLayout(m)
|
||||
if (layout === LAYOUT.HUB) return 'hub'
|
||||
if (layout === LAYOUT.COMBO) return 'combo'
|
||||
if (layout === LAYOUT.STICKER_ONLY) return 'sticker-only'
|
||||
if (layout === LAYOUT.EMOJI_ONLY) return 'emoji-only'
|
||||
return 'text'
|
||||
}
|
||||
|
||||
function enrichMessageStickerNames (m) {
|
||||
if (!m) return m
|
||||
if ((m.stickerNames || []).length) return m
|
||||
if (!m.stickerNamesJson) return m
|
||||
try {
|
||||
const parsed = JSON.parse(m.stickerNamesJson)
|
||||
if (Array.isArray(parsed) && parsed.length) {
|
||||
return { ...m, stickerNames: parsed }
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
return m
|
||||
}
|
||||
|
||||
function enrichMessageHubMirror (m) {
|
||||
if (!m) return m
|
||||
if (m.hubMirror?.kind === 'hub-mirror') return m
|
||||
if (m.hubMirrorJson) {
|
||||
const card = parseHubMirrorJson(m.hubMirrorJson)
|
||||
if (card) return { ...m, hubMirror: card }
|
||||
}
|
||||
const legacy = hubMirrorFromMessage(m)
|
||||
if (legacy) return { ...m, hubMirror: legacy }
|
||||
return m
|
||||
}
|
||||
|
||||
function enrichMessageRow (m) {
|
||||
return enrichMessageHubMirror(enrichMessageStickerNames(m))
|
||||
}
|
||||
|
||||
/** HyperDB uint fields must be positive integers. */
|
||||
function coerceSyncUint (v, fallback = 0) {
|
||||
const n = Number(v)
|
||||
|
||||
+11
-4
@@ -3,11 +3,18 @@
|
||||
const { createJsonExportHealDelegateMixin } = require('pearcord-json-export-mixin')
|
||||
|
||||
const inviteJsonMixin = createJsonExportHealDelegateMixin({
|
||||
keysField: '_inviteLinkJsonGossipKeys',
|
||||
initMethod: '_initInviteJsonMixinState',
|
||||
gossipEntries: [
|
||||
{ method: '_shouldGossipInviteLinkJson', gossipHashPrefix: '' },
|
||||
{ method: '_shouldGossipVanityUrlExportJson', gossipHashPrefix: 'vanity:' }
|
||||
{
|
||||
method: '_shouldGossipInviteLinkJson',
|
||||
keysField: '_inviteLinkRegistryJsonGossipKeys',
|
||||
initMethod: '_initInviteLinkJsonMixinState'
|
||||
},
|
||||
{
|
||||
method: '_shouldGossipVanityUrlExportJson',
|
||||
gossipHashPrefix: 'vanity:',
|
||||
keysField: '_vanityUrlRegistryJsonGossipKeys',
|
||||
initMethod: '_initVanityUrlJsonMixinState'
|
||||
}
|
||||
],
|
||||
delegates: [
|
||||
{
|
||||
|
||||
+11
-4
@@ -3,11 +3,18 @@
|
||||
const { createJsonExportHealDelegateMixin } = require('pearcord-json-export-mixin')
|
||||
|
||||
const oauthJsonMixin = createJsonExportHealDelegateMixin({
|
||||
keysField: '_oauthGrantJsonGossipKeys',
|
||||
initMethod: '_initOauthJsonMixinState',
|
||||
gossipEntries: [
|
||||
{ method: '_shouldGossipOAuthGrantJson', gossipHashPrefix: '' },
|
||||
{ method: '_shouldGossipOAuthInstallTokenExportJson', gossipHashPrefix: 'install:' }
|
||||
{
|
||||
method: '_shouldGossipOAuthGrantJson',
|
||||
keysField: '_oauthGrantRegistryJsonGossipKeys',
|
||||
initMethod: '_initOAuthGrantJsonMixinState'
|
||||
},
|
||||
{
|
||||
method: '_shouldGossipOAuthInstallTokenExportJson',
|
||||
gossipHashPrefix: 'install:',
|
||||
keysField: '_oauthInstallTokenRegistryJsonGossipKeys',
|
||||
initMethod: '_initOAuthInstallTokenJsonMixinState'
|
||||
}
|
||||
],
|
||||
delegates: [
|
||||
{
|
||||
|
||||
@@ -3,11 +3,18 @@
|
||||
const { createJsonExportHealDelegateMixin } = require('pearcord-json-export-mixin')
|
||||
|
||||
const permissionJsonMixin = createJsonExportHealDelegateMixin({
|
||||
keysField: '_roleOverrideJsonGossipKeys',
|
||||
initMethod: '_initPermissionJsonMixinState',
|
||||
gossipEntries: [
|
||||
{ method: '_shouldGossipRoleOverrideJson', gossipHashPrefix: '' },
|
||||
{ method: '_shouldGossipEffectivePermissionExportJson', gossipHashPrefix: 'effective:' }
|
||||
{
|
||||
method: '_shouldGossipRoleOverrideJson',
|
||||
keysField: '_roleOverrideRegistryJsonGossipKeys',
|
||||
initMethod: '_initRoleOverrideJsonMixinState'
|
||||
},
|
||||
{
|
||||
method: '_shouldGossipEffectivePermissionExportJson',
|
||||
gossipHashPrefix: 'effective:',
|
||||
keysField: '_effectivePermissionRegistryJsonGossipKeys',
|
||||
initMethod: '_initEffectivePermissionJsonMixinState'
|
||||
}
|
||||
],
|
||||
delegates: [
|
||||
{
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
'use strict'
|
||||
|
||||
/** Re-export subset of pearcord-delivery-receipts used by PearcordPlatform (keeps index.js lean). */
|
||||
module.exports = require('pearcord-delivery-receipts')
|
||||
@@ -0,0 +1,49 @@
|
||||
'use strict'
|
||||
|
||||
const { classifyMessageLayout, LAYOUT } = require('pearcord-message-layout')
|
||||
const { parseHubMirrorJson, hubMirrorFromMessage } = require('pearcord-hub-cards')
|
||||
|
||||
function messageLayoutKind (m) {
|
||||
const layout = classifyMessageLayout(m)
|
||||
if (layout === LAYOUT.HUB) return 'hub'
|
||||
if (layout === LAYOUT.COMBO) return 'combo'
|
||||
if (layout === LAYOUT.STICKER_ONLY) return 'sticker-only'
|
||||
if (layout === LAYOUT.EMOJI_ONLY) return 'emoji-only'
|
||||
return 'text'
|
||||
}
|
||||
|
||||
function enrichMessageStickerNames (m) {
|
||||
if (!m) return m
|
||||
if ((m.stickerNames || []).length) return m
|
||||
if (!m.stickerNamesJson) return m
|
||||
try {
|
||||
const parsed = JSON.parse(m.stickerNamesJson)
|
||||
if (Array.isArray(parsed) && parsed.length) {
|
||||
return { ...m, stickerNames: parsed }
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
return m
|
||||
}
|
||||
|
||||
function enrichMessageHubMirror (m) {
|
||||
if (!m) return m
|
||||
if (m.hubMirror?.kind === 'hub-mirror') return m
|
||||
if (m.hubMirrorJson) {
|
||||
const card = parseHubMirrorJson(m.hubMirrorJson)
|
||||
if (card) return { ...m, hubMirror: card }
|
||||
}
|
||||
const legacy = hubMirrorFromMessage(m)
|
||||
if (legacy) return { ...m, hubMirror: legacy }
|
||||
return m
|
||||
}
|
||||
|
||||
function enrichMessageRow (m) {
|
||||
return enrichMessageHubMirror(enrichMessageStickerNames(m))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
messageLayoutKind,
|
||||
enrichMessageStickerNames,
|
||||
enrichMessageHubMirror,
|
||||
enrichMessageRow
|
||||
}
|
||||
+11
-4
@@ -3,11 +3,18 @@
|
||||
const { createJsonExportHealDelegateMixin } = require('pearcord-json-export-mixin')
|
||||
|
||||
const slashJsonMixin = createJsonExportHealDelegateMixin({
|
||||
keysField: '_slashRegistryJsonGossipKeys',
|
||||
initMethod: '_initSlashJsonMixinState',
|
||||
gossipEntries: [
|
||||
{ method: '_shouldGossipSlashRegistryJson', gossipHashPrefix: '' },
|
||||
{ method: '_shouldGossipSlashInvokeAuditExportJson', gossipHashPrefix: 'invoke:' }
|
||||
{
|
||||
method: '_shouldGossipSlashRegistryJson',
|
||||
keysField: '_slashRegistryExportJsonGossipKeys',
|
||||
initMethod: '_initSlashRegistryJsonMixinState'
|
||||
},
|
||||
{
|
||||
method: '_shouldGossipSlashInvokeAuditExportJson',
|
||||
gossipHashPrefix: 'invoke:',
|
||||
keysField: '_slashInvokeAuditRegistryJsonGossipKeys',
|
||||
initMethod: '_initSlashInvokeAuditJsonMixinState'
|
||||
}
|
||||
],
|
||||
delegates: [
|
||||
{
|
||||
|
||||
+11
-4
@@ -4,11 +4,18 @@ const { createJsonExportHealDelegateMixin } = require('pearcord-json-export-mixi
|
||||
|
||||
/** Legacy gossip dedupe for worker release + integration manifest (heal lives in dedicated mixins). */
|
||||
const workerJsonMixin = createJsonExportHealDelegateMixin({
|
||||
keysField: '_workerReleaseJsonGossipKeys',
|
||||
initMethod: '_initWorkerJsonMixinState',
|
||||
gossipEntries: [
|
||||
{ method: '_shouldGossipWorkerReleaseJson', gossipHashPrefix: '' },
|
||||
{ method: '_shouldGossipIntegrationManifestExportJson', gossipHashPrefix: 'manifest:' }
|
||||
{
|
||||
method: '_shouldGossipWorkerReleaseJson',
|
||||
keysField: '_workerReleaseRegistryJsonGossipKeys',
|
||||
initMethod: '_initWorkerReleaseJsonMixinState'
|
||||
},
|
||||
{
|
||||
method: '_shouldGossipIntegrationManifestExportJson',
|
||||
gossipHashPrefix: 'manifest:',
|
||||
keysField: '_integrationManifestRegistryJsonGossipKeys',
|
||||
initMethod: '_initIntegrationManifestJsonMixinState'
|
||||
}
|
||||
],
|
||||
delegates: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user