@happyvertical/smrt-comments 0.61.3 → 0.61.5
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/chunks/participation-DhhyArQd.js +282 -0
- package/dist/chunks/participation-DhhyArQd.js.map +1 -0
- package/dist/index.js +24 -10
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +325 -137
- package/dist/models/Comment.d.ts.map +1 -1
- package/dist/models/CommentReport.d.ts.map +1 -1
- package/dist/models/CommentRevision.d.ts +1 -1
- package/dist/models/CommentRevision.d.ts.map +1 -1
- package/dist/models/ParticipationBan.d.ts.map +1 -1
- package/dist/models/ParticipationRateBucket.d.ts.map +1 -1
- package/dist/participation.js +1 -1
- package/dist/services/CommentService.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +7 -7
- package/package.json +5 -5
- package/dist/chunks/participation-1LmzO_j8.js +0 -276
- package/dist/chunks/participation-1LmzO_j8.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"participation-DhhyArQd.js","names":[],"sources":["../../src/__smrt-register__.ts","../../src/models/ParticipationBan.ts","../../src/models/ParticipationPolicy.ts","../../src/models/ParticipationRateBucket.ts","../../src/collections/ParticipationCollection.ts","../../src/participation-contract.ts","../../src/services/ParticipationService.ts"],"sourcesContent":["// Generated by @happyvertical/smrt-core smrtPlugin at library build time.\n// The package manifest is inlined so self-registration cannot miss when a\n// downstream bundler relocates this module away from dist/manifest.json\n// (https://github.com/happyvertical/smrt/issues/1506,\n// https://github.com/happyvertical/smrt/issues/1507).\nimport { ObjectRegistry } from '@happyvertical/smrt-core';\n\nObjectRegistry.registerPackageManifest(JSON.parse(\"{\\\"version\\\":\\\"1.0.0\\\",\\\"timestamp\\\":0,\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"packageVersion\\\":\\\"0.61.5\\\",\\\"objects\\\":{\\\"@happyvertical/smrt-comments:CommentCollection\\\":{\\\"name\\\":\\\"commentcollection\\\",\\\"className\\\":\\\"CommentCollection\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:CommentCollection\\\",\\\"collection\\\":\\\"comments\\\",\\\"filePath\\\":\\\"src/collections/CommentCollection.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{},\\\"methods\\\":{\\\"listForRecord\\\":{\\\"name\\\":\\\"listForRecord\\\",\\\"async\\\":true,\\\"parameters\\\":[{\\\"name\\\":\\\"recordType\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false},{\\\"name\\\":\\\"recordId\\\",\\\"type\\\":\\\"string\\\",\\\"optional\\\":false}],\\\"returnType\\\":\\\"Promise<Comment[]>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"record_comments\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false},\\\"extends\\\":\\\"SmrtCollection\\\",\\\"extendsTypeArg\\\":\\\"Comment\\\",\\\"exportName\\\":\\\"CommentCollection\\\",\\\"collectionExportName\\\":\\\"CommentCollectionCollection\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-comments:Comment\\\",\\\"inheritedExposure\\\":[\\\"api\\\",\\\"mcp\\\",\\\"cli\\\"],\\\"schema\\\":{\\\"tableName\\\":\\\"record_comments\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"record_comments\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"meta_type\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"meta_id\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"role\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"sort_order\\\\\\\" INTEGER DEFAULT 0,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"author_user_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"body\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"mentions\\\\\\\" TEXT,\\\\n \\\\\\\"idempotency_key\\\\\\\" TEXT,\\\\n \\\\\\\"retry_tenant_id\\\\\\\" TEXT,\\\\n \\\\\\\"request_digest\\\\\\\" TEXT,\\\\n \\\\\\\"parent_comment_id\\\\\\\" UUID,\\\\n \\\\\\\"status\\\\\\\" TEXT NOT NULL DEFAULT 'visible',\\\\n \\\\\\\"participation_snapshot\\\\\\\" TEXT,\\\\n \\\\\\\"edited_at\\\\\\\" TIMESTAMP\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"meta_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"meta_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"role\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"sort_order\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"default\\\":0},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"author_user_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"body\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"mentions\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"idempotency_key\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"retry_tenant_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"request_digest\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"parent_comment_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"status\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":\\\"visible\\\"},\\\"participation_snapshot\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"edited_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"record_comments_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"record_comments_tenant_request_key\\\",\\\"columns\\\":[\\\"retry_tenant_id\\\",\\\"idempotency_key\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"record_comments_record_created_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"meta_type\\\",\\\"meta_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"record_comments_parent_created_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"parent_comment_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"record_comments_moderation_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"status\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"record_comments_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"record_comments_meta_type_meta_id_idx\\\",\\\"columns\\\":[\\\"meta_type\\\",\\\"meta_id\\\"]},{\\\"name\\\":\\\"record_comments_author_user_id_idx\\\",\\\"columns\\\":[\\\"author_user_id\\\"]},{\\\"name\\\":\\\"record_comments_parent_comment_id_idx\\\",\\\"columns\\\":[\\\"parent_comment_id\\\"]}],\\\"version\\\":\\\"b3737a6a\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"},\\\"@happyvertical/smrt-comments:CommentReportCollection\\\":{\\\"name\\\":\\\"commentreportcollection\\\",\\\"className\\\":\\\"CommentReportCollection\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:CommentReportCollection\\\",\\\"collection\\\":\\\"commentreports\\\",\\\"filePath\\\":\\\"src/collections/CommentReportCollection.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"comment_reports\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false},\\\"extends\\\":\\\"SmrtCollection\\\",\\\"extendsTypeArg\\\":\\\"CommentReport\\\",\\\"exportName\\\":\\\"CommentReportCollection\\\",\\\"collectionExportName\\\":\\\"CommentReportCollectionCollection\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-comments:CommentReport\\\",\\\"inheritedExposure\\\":[\\\"api\\\",\\\"mcp\\\",\\\"cli\\\"],\\\"schema\\\":{\\\"tableName\\\":\\\"comment_reports\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"comment_reports\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"comment_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"reporter_user_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"reason\\\\\\\" TEXT,\\\\n \\\\\\\"status\\\\\\\" TEXT NOT NULL DEFAULT 'open'\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"comment_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"reporter_user_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"reason\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"status\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":\\\"open\\\"}},\\\"indexes\\\":[{\\\"name\\\":\\\"comment_reports_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"comment_reports_actor_target_unique\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"reporter_user_id\\\",\\\"comment_id\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"comment_reports_queue_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"status\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"comment_reports_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"comment_reports_comment_id_idx\\\",\\\"columns\\\":[\\\"comment_id\\\"]},{\\\"name\\\":\\\"comment_reports_reporter_user_id_idx\\\",\\\"columns\\\":[\\\"reporter_user_id\\\"]}],\\\"version\\\":\\\"cb5130b8\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"},\\\"@happyvertical/smrt-comments:CommentRevisionCollection\\\":{\\\"name\\\":\\\"commentrevisioncollection\\\",\\\"className\\\":\\\"CommentRevisionCollection\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:CommentRevisionCollection\\\",\\\"collection\\\":\\\"commentrevisions\\\",\\\"filePath\\\":\\\"src/collections/CommentRevisionCollection.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"comment_revisions\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false},\\\"extends\\\":\\\"SmrtCollection\\\",\\\"extendsTypeArg\\\":\\\"CommentRevision\\\",\\\"exportName\\\":\\\"CommentRevisionCollection\\\",\\\"collectionExportName\\\":\\\"CommentRevisionCollectionCollection\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-comments:CommentRevision\\\",\\\"inheritedExposure\\\":[\\\"api\\\",\\\"mcp\\\",\\\"cli\\\"],\\\"schema\\\":{\\\"tableName\\\":\\\"comment_revisions\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"comment_revisions\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"comment_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"editor_user_id\\\\\\\" UUID,\\\\n \\\\\\\"body\\\\\\\" TEXT NOT NULL\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"comment_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"editor_user_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"body\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"comment_revisions_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"comment_revisions_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"comment_revisions_comment_id_idx\\\",\\\"columns\\\":[\\\"comment_id\\\"]},{\\\"name\\\":\\\"comment_revisions_editor_user_id_idx\\\",\\\"columns\\\":[\\\"editor_user_id\\\"]}],\\\"version\\\":\\\"72b36add\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"},\\\"@happyvertical/smrt-comments:ParticipationPolicyCollection\\\":{\\\"name\\\":\\\"participationpolicycollection\\\",\\\"className\\\":\\\"ParticipationPolicyCollection\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:ParticipationPolicyCollection\\\",\\\"collection\\\":\\\"participationpolicies\\\",\\\"filePath\\\":\\\"src/collections/ParticipationCollection.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"participation_policies\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false},\\\"extends\\\":\\\"SmrtCollection\\\",\\\"extendsTypeArg\\\":\\\"ParticipationPolicy\\\",\\\"exportName\\\":\\\"ParticipationPolicyCollection\\\",\\\"collectionExportName\\\":\\\"ParticipationPolicyCollectionCollection\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-comments:ParticipationPolicy\\\",\\\"inheritedExposure\\\":[\\\"api\\\",\\\"mcp\\\",\\\"cli\\\"],\\\"schema\\\":{\\\"tableName\\\":\\\"participation_policies\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"participation_policies\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"record_type\\\\\\\" TEXT,\\\\n \\\\\\\"record_id\\\\\\\" TEXT,\\\\n \\\\\\\"action\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"moderation_mode\\\\\\\" TEXT NOT NULL DEFAULT 'open',\\\\n \\\\\\\"max_actions\\\\\\\" INTEGER NOT NULL DEFAULT 0,\\\\n \\\\\\\"window_seconds\\\\\\\" INTEGER NOT NULL DEFAULT 0\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"record_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"record_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"action\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"moderation_mode\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":\\\"open\\\"},\\\"max_actions\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":0},\\\"window_seconds\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":0}},\\\"indexes\\\":[{\\\"name\\\":\\\"participation_policies_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"participation_policies_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]}],\\\"version\\\":\\\"0aa39678\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"},\\\"@happyvertical/smrt-comments:ParticipationBanCollection\\\":{\\\"name\\\":\\\"participationbancollection\\\",\\\"className\\\":\\\"ParticipationBanCollection\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:ParticipationBanCollection\\\",\\\"collection\\\":\\\"participationbans\\\",\\\"filePath\\\":\\\"src/collections/ParticipationCollection.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"participation_bans\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false},\\\"extends\\\":\\\"SmrtCollection\\\",\\\"extendsTypeArg\\\":\\\"ParticipationBan\\\",\\\"exportName\\\":\\\"ParticipationBanCollection\\\",\\\"collectionExportName\\\":\\\"ParticipationBanCollectionCollection\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-comments:ParticipationBan\\\",\\\"inheritedExposure\\\":[\\\"api\\\",\\\"mcp\\\",\\\"cli\\\"],\\\"schema\\\":{\\\"tableName\\\":\\\"participation_bans\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"participation_bans\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"actor_user_id\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"record_type\\\\\\\" TEXT,\\\\n \\\\\\\"record_id\\\\\\\" TEXT,\\\\n \\\\\\\"reason\\\\\\\" TEXT,\\\\n \\\\\\\"expires_at\\\\\\\" TIMESTAMP\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"actor_user_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"record_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"record_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reason\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"expires_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"participation_bans_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"participation_bans_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]}],\\\"version\\\":\\\"94015082\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"},\\\"@happyvertical/smrt-comments:ParticipationRateBucketCollection\\\":{\\\"name\\\":\\\"participationratebucketcollection\\\",\\\"className\\\":\\\"ParticipationRateBucketCollection\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:ParticipationRateBucketCollection\\\",\\\"collection\\\":\\\"participationratebuckets\\\",\\\"filePath\\\":\\\"src/collections/ParticipationCollection.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"participation_rate_buckets\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false},\\\"extends\\\":\\\"SmrtCollection\\\",\\\"extendsTypeArg\\\":\\\"ParticipationRateBucket\\\",\\\"exportName\\\":\\\"ParticipationRateBucketCollection\\\",\\\"collectionExportName\\\":\\\"ParticipationRateBucketCollectionCollection\\\",\\\"collectionOf\\\":\\\"@happyvertical/smrt-comments:ParticipationRateBucket\\\",\\\"inheritedExposure\\\":[\\\"api\\\",\\\"mcp\\\",\\\"cli\\\"],\\\"schema\\\":{\\\"tableName\\\":\\\"participation_rate_buckets\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"participation_rate_buckets\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"bucket_key\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"action_count\\\\\\\" INTEGER NOT NULL DEFAULT 0\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"bucket_key\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"action_count\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":0}},\\\"indexes\\\":[{\\\"name\\\":\\\"participation_rate_buckets_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"participation_rate_bucket_unique\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"bucket_key\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"participation_rate_buckets_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]}],\\\"version\\\":\\\"73800b88\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"},\\\"@happyvertical/smrt-comments:Comment\\\":{\\\"name\\\":\\\"comment\\\",\\\"className\\\":\\\"Comment\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:Comment\\\",\\\"collection\\\":\\\"comments\\\",\\\"filePath\\\":\\\"src/models/Comment.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{\\\"metaType\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"requiredFor\\\"],\\\"required\\\":true,\\\"requiredFor\\\":\\\"identity\\\"},\\\"required\\\":true},\\\"metaId\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"requiredFor\\\"],\\\"required\\\":true,\\\"requiredFor\\\":\\\"identity\\\"},\\\"required\\\":true},\\\"role\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\"],\\\"required\\\":true},\\\"required\\\":true},\\\"sortOrder\\\":{\\\"type\\\":\\\"integer\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"default\\\"]},\\\"required\\\":false,\\\"default\\\":0},\\\"tenantId\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__tenancy\\\":{\\\"isTenantIdField\\\":true,\\\"autoFilter\\\":true,\\\"required\\\":true,\\\"autoPopulate\\\":true,\\\"nullable\\\":false,\\\"mode\\\":\\\"required\\\",\\\"field\\\":\\\"tenantId\\\",\\\"allowSuperAdminBypass\\\":false},\\\"__statedOptions\\\":[\\\"sqlType\\\",\\\"requiredFor\\\",\\\"__tenancy\\\"],\\\"sqlType\\\":\\\"UUID\\\",\\\"requiredFor\\\":\\\"tenant-scope\\\"},\\\"required\\\":true},\\\"authorUserId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"requiredFor\\\",\\\"related\\\"],\\\"required\\\":true,\\\"requiredFor\\\":\\\"identity\\\"},\\\"required\\\":true,\\\"related\\\":\\\"@happyvertical/smrt-users:User\\\"},\\\"body\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"requiredFor\\\"],\\\"required\\\":true,\\\"requiredFor\\\":\\\"idempotency\\\"},\\\"required\\\":true},\\\"mentions\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[]},\\\"required\\\":false},\\\"idempotencyKey\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"nullable\\\",\\\"readonly\\\",\\\"required\\\"],\\\"readonly\\\":true,\\\"nullable\\\":true,\\\"required\\\":false},\\\"required\\\":false,\\\"readonly\\\":true},\\\"retryTenantId\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"nullable\\\",\\\"readonly\\\",\\\"required\\\"],\\\"readonly\\\":true,\\\"nullable\\\":true,\\\"required\\\":false},\\\"required\\\":false,\\\"readonly\\\":true},\\\"requestDigest\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"nullable\\\",\\\"readonly\\\",\\\"required\\\"],\\\"readonly\\\":true,\\\"nullable\\\":true,\\\"required\\\":false},\\\"required\\\":false,\\\"readonly\\\":true},\\\"parentCommentId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"nullable\\\",\\\"constraint\\\",\\\"related\\\",\\\"required\\\"],\\\"nullable\\\":true,\\\"constraint\\\":false,\\\"required\\\":false},\\\"required\\\":false,\\\"related\\\":\\\"Comment\\\"},\\\"status\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"default\\\",\\\"enum\\\"],\\\"required\\\":true},\\\"required\\\":true,\\\"default\\\":\\\"visible\\\",\\\"enum\\\":[\\\"visible\\\",\\\"hidden\\\",\\\"pending\\\",\\\"deleted\\\"]},\\\"participationSnapshot\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"nullable\\\",\\\"readonly\\\",\\\"required\\\"],\\\"readonly\\\":true,\\\"nullable\\\":true,\\\"required\\\":false},\\\"required\\\":false,\\\"readonly\\\":true},\\\"editedAt\\\":{\\\"type\\\":\\\"datetime\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"nullable\\\",\\\"readonly\\\",\\\"required\\\"],\\\"readonly\\\":true,\\\"nullable\\\":true,\\\"required\\\":false},\\\"required\\\":false,\\\"readonly\\\":true}},\\\"methods\\\":{\\\"hydrate\\\":{\\\"name\\\":\\\"hydrate\\\",\\\"async\\\":true,\\\"parameters\\\":[],\\\"returnType\\\":\\\"Promise<T | null>\\\",\\\"isStatic\\\":false,\\\"isPublic\\\":true}},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"record_comments\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false,\\\"indexes\\\":[{\\\"name\\\":\\\"record_comments_tenant_request_key\\\",\\\"columns\\\":[\\\"retryTenantId\\\",\\\"idempotencyKey\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"record_comments_record_created_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"metaType\\\",\\\"metaId\\\",\\\"createdAt\\\"]},{\\\"name\\\":\\\"record_comments_parent_created_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"parentCommentId\\\",\\\"createdAt\\\"]},{\\\"name\\\":\\\"record_comments_moderation_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"status\\\",\\\"createdAt\\\"]}],\\\"tenantScoped\\\":{\\\"mode\\\":\\\"required\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtPolymorphicAssociation\\\",\\\"exportName\\\":\\\"Comment\\\",\\\"collectionExportName\\\":\\\"CommentCollection\\\",\\\"validationRules\\\":[{\\\"field\\\":\\\"metaType\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"},{\\\"field\\\":\\\"metaId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"},{\\\"field\\\":\\\"role\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"},{\\\"field\\\":\\\"authorUserId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"crossPackageRef\\\"},{\\\"field\\\":\\\"body\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"},{\\\"field\\\":\\\"status\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"}],\\\"schema\\\":{\\\"tableName\\\":\\\"record_comments\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"record_comments\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"meta_type\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"meta_id\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"role\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"sort_order\\\\\\\" INTEGER DEFAULT 0,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"author_user_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"body\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"mentions\\\\\\\" TEXT,\\\\n \\\\\\\"idempotency_key\\\\\\\" TEXT,\\\\n \\\\\\\"retry_tenant_id\\\\\\\" TEXT,\\\\n \\\\\\\"request_digest\\\\\\\" TEXT,\\\\n \\\\\\\"parent_comment_id\\\\\\\" UUID,\\\\n \\\\\\\"status\\\\\\\" TEXT NOT NULL DEFAULT 'visible',\\\\n \\\\\\\"participation_snapshot\\\\\\\" TEXT,\\\\n \\\\\\\"edited_at\\\\\\\" TIMESTAMP\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"meta_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"meta_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"role\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"sort_order\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":false,\\\"unique\\\":false,\\\"default\\\":0},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"author_user_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"body\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"mentions\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"idempotency_key\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"retry_tenant_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"request_digest\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"parent_comment_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"status\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":\\\"visible\\\"},\\\"participation_snapshot\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"edited_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"record_comments_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"record_comments_tenant_request_key\\\",\\\"columns\\\":[\\\"retry_tenant_id\\\",\\\"idempotency_key\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"record_comments_record_created_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"meta_type\\\",\\\"meta_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"record_comments_parent_created_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"parent_comment_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"record_comments_moderation_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"status\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"record_comments_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"record_comments_meta_type_meta_id_idx\\\",\\\"columns\\\":[\\\"meta_type\\\",\\\"meta_id\\\"]},{\\\"name\\\":\\\"record_comments_author_user_id_idx\\\",\\\"columns\\\":[\\\"author_user_id\\\"]},{\\\"name\\\":\\\"record_comments_parent_comment_id_idx\\\",\\\"columns\\\":[\\\"parent_comment_id\\\"]}],\\\"version\\\":\\\"b3737a6a\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"},\\\"@happyvertical/smrt-comments:CommentReport\\\":{\\\"name\\\":\\\"commentreport\\\",\\\"className\\\":\\\"CommentReport\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:CommentReport\\\",\\\"collection\\\":\\\"commentreports\\\",\\\"description\\\":\\\"A tenant-local report; moderation resolution never deletes the report.\\\",\\\"filePath\\\":\\\"src/models/CommentReport.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{\\\"tenantId\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__tenancy\\\":{\\\"isTenantIdField\\\":true,\\\"autoFilter\\\":true,\\\"required\\\":true,\\\"autoPopulate\\\":true,\\\"nullable\\\":false,\\\"mode\\\":\\\"required\\\",\\\"field\\\":\\\"tenantId\\\",\\\"allowSuperAdminBypass\\\":false},\\\"__statedOptions\\\":[\\\"sqlType\\\",\\\"requiredFor\\\",\\\"__tenancy\\\"],\\\"sqlType\\\":\\\"UUID\\\",\\\"requiredFor\\\":\\\"tenant-scope\\\"},\\\"required\\\":true},\\\"commentId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"requiredFor\\\",\\\"constraint\\\",\\\"related\\\"],\\\"required\\\":true,\\\"requiredFor\\\":\\\"identity\\\",\\\"constraint\\\":false},\\\"required\\\":true,\\\"related\\\":\\\"Comment\\\"},\\\"reporterUserId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"requiredFor\\\",\\\"related\\\"],\\\"required\\\":true,\\\"requiredFor\\\":\\\"identity\\\"},\\\"required\\\":true,\\\"related\\\":\\\"@happyvertical/smrt-users:User\\\"},\\\"reason\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[]},\\\"required\\\":false},\\\"status\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"default\\\",\\\"enum\\\"],\\\"required\\\":true},\\\"required\\\":true,\\\"default\\\":\\\"open\\\",\\\"enum\\\":[\\\"open\\\",\\\"resolved\\\",\\\"dismissed\\\"]}},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"comment_reports\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false,\\\"indexes\\\":[{\\\"name\\\":\\\"comment_reports_actor_target_unique\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"reporterUserId\\\",\\\"commentId\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"comment_reports_queue_idx\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"status\\\",\\\"createdAt\\\"]}],\\\"tenantScoped\\\":{\\\"mode\\\":\\\"required\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"CommentReport\\\",\\\"collectionExportName\\\":\\\"CommentReportCollection\\\",\\\"validationRules\\\":[{\\\"field\\\":\\\"commentId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"foreignKey\\\"},{\\\"field\\\":\\\"reporterUserId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"crossPackageRef\\\"},{\\\"field\\\":\\\"status\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"}],\\\"schema\\\":{\\\"tableName\\\":\\\"comment_reports\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"comment_reports\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"comment_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"reporter_user_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"reason\\\\\\\" TEXT,\\\\n \\\\\\\"status\\\\\\\" TEXT NOT NULL DEFAULT 'open'\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"comment_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"reporter_user_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"reason\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"status\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":\\\"open\\\"}},\\\"indexes\\\":[{\\\"name\\\":\\\"comment_reports_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"comment_reports_actor_target_unique\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"reporter_user_id\\\",\\\"comment_id\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"comment_reports_queue_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"status\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"comment_reports_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"comment_reports_comment_id_idx\\\",\\\"columns\\\":[\\\"comment_id\\\"]},{\\\"name\\\":\\\"comment_reports_reporter_user_id_idx\\\",\\\"columns\\\":[\\\"reporter_user_id\\\"]}],\\\"version\\\":\\\"cb5130b8\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"},\\\"@happyvertical/smrt-comments:CommentRevision\\\":{\\\"name\\\":\\\"commentrevision\\\",\\\"className\\\":\\\"CommentRevision\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:CommentRevision\\\",\\\"collection\\\":\\\"commentrevisions\\\",\\\"description\\\":\\\"Immutable prior body retained whenever an author edits a comment.\\\",\\\"filePath\\\":\\\"src/models/CommentRevision.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{\\\"tenantId\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__tenancy\\\":{\\\"isTenantIdField\\\":true,\\\"autoFilter\\\":true,\\\"required\\\":true,\\\"autoPopulate\\\":true,\\\"nullable\\\":false,\\\"mode\\\":\\\"required\\\",\\\"field\\\":\\\"tenantId\\\",\\\"allowSuperAdminBypass\\\":false},\\\"__statedOptions\\\":[\\\"sqlType\\\",\\\"requiredFor\\\",\\\"__tenancy\\\"],\\\"sqlType\\\":\\\"UUID\\\",\\\"requiredFor\\\":\\\"tenant-scope\\\"},\\\"required\\\":true},\\\"commentId\\\":{\\\"type\\\":\\\"foreignKey\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"requiredFor\\\",\\\"constraint\\\",\\\"related\\\"],\\\"required\\\":true,\\\"requiredFor\\\":\\\"identity\\\",\\\"constraint\\\":false},\\\"required\\\":true,\\\"related\\\":\\\"Comment\\\"},\\\"editorUserId\\\":{\\\"type\\\":\\\"crossPackageRef\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"nullable\\\",\\\"related\\\",\\\"required\\\"],\\\"nullable\\\":true,\\\"required\\\":false},\\\"required\\\":false,\\\"related\\\":\\\"@happyvertical/smrt-users:User\\\"},\\\"body\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"requiredFor\\\"],\\\"required\\\":true,\\\"requiredFor\\\":\\\"idempotency\\\"},\\\"required\\\":true}},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"comment_revisions\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false,\\\"tenantScoped\\\":{\\\"mode\\\":\\\"required\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"CommentRevision\\\",\\\"collectionExportName\\\":\\\"CommentRevisionCollection\\\",\\\"validationRules\\\":[{\\\"field\\\":\\\"commentId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"foreignKey\\\"},{\\\"field\\\":\\\"body\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"}],\\\"schema\\\":{\\\"tableName\\\":\\\"comment_revisions\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"comment_revisions\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"comment_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"editor_user_id\\\\\\\" UUID,\\\\n \\\\\\\"body\\\\\\\" TEXT NOT NULL\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"comment_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"foreignKey\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"editor_user_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"crossPackageRef\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"body\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"comment_revisions_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"comment_revisions_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]},{\\\"name\\\":\\\"comment_revisions_comment_id_idx\\\",\\\"columns\\\":[\\\"comment_id\\\"]},{\\\"name\\\":\\\"comment_revisions_editor_user_id_idx\\\",\\\"columns\\\":[\\\"editor_user_id\\\"]}],\\\"version\\\":\\\"72b36add\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"},\\\"@happyvertical/smrt-comments:ParticipationBan\\\":{\\\"name\\\":\\\"participationban\\\",\\\"className\\\":\\\"ParticipationBan\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:ParticipationBan\\\",\\\"collection\\\":\\\"participationbans\\\",\\\"description\\\":\\\"Tenant-local, reusable participation ban; a blank target applies tenant-wide.\\\",\\\"filePath\\\":\\\"src/models/ParticipationBan.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{\\\"tenantId\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__tenancy\\\":{\\\"isTenantIdField\\\":true,\\\"autoFilter\\\":true,\\\"required\\\":true,\\\"autoPopulate\\\":true,\\\"nullable\\\":false,\\\"mode\\\":\\\"required\\\",\\\"field\\\":\\\"tenantId\\\",\\\"allowSuperAdminBypass\\\":false},\\\"__statedOptions\\\":[\\\"sqlType\\\",\\\"requiredFor\\\",\\\"__tenancy\\\"],\\\"sqlType\\\":\\\"UUID\\\",\\\"requiredFor\\\":\\\"tenant-scope\\\"},\\\"required\\\":true},\\\"actorUserId\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"requiredFor\\\"],\\\"required\\\":true,\\\"requiredFor\\\":\\\"identity\\\"},\\\"required\\\":true},\\\"recordType\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[]},\\\"required\\\":false},\\\"recordId\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[]},\\\"required\\\":false},\\\"reason\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[]},\\\"required\\\":false},\\\"expiresAt\\\":{\\\"type\\\":\\\"datetime\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"nullable\\\",\\\"required\\\"],\\\"nullable\\\":true,\\\"required\\\":false},\\\"required\\\":false}},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"participation_bans\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false,\\\"tenantScoped\\\":{\\\"mode\\\":\\\"required\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"ParticipationBan\\\",\\\"collectionExportName\\\":\\\"ParticipationBanCollection\\\",\\\"validationRules\\\":[{\\\"field\\\":\\\"actorUserId\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"}],\\\"schema\\\":{\\\"tableName\\\":\\\"participation_bans\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"participation_bans\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"actor_user_id\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"record_type\\\\\\\" TEXT,\\\\n \\\\\\\"record_id\\\\\\\" TEXT,\\\\n \\\\\\\"reason\\\\\\\" TEXT,\\\\n \\\\\\\"expires_at\\\\\\\" TIMESTAMP\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"actor_user_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"record_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"record_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"reason\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"expires_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":false,\\\"unique\\\":false}},\\\"indexes\\\":[{\\\"name\\\":\\\"participation_bans_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"participation_bans_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]}],\\\"version\\\":\\\"94015082\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"},\\\"@happyvertical/smrt-comments:ParticipationPolicy\\\":{\\\"name\\\":\\\"participationpolicy\\\",\\\"className\\\":\\\"ParticipationPolicy\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:ParticipationPolicy\\\",\\\"collection\\\":\\\"participationpolicies\\\",\\\"description\\\":\\\"A generic tenant default or exact-record override for participation actions.\\\",\\\"filePath\\\":\\\"src/models/ParticipationPolicy.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{\\\"tenantId\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__tenancy\\\":{\\\"isTenantIdField\\\":true,\\\"autoFilter\\\":true,\\\"required\\\":true,\\\"autoPopulate\\\":true,\\\"nullable\\\":false,\\\"mode\\\":\\\"required\\\",\\\"field\\\":\\\"tenantId\\\",\\\"allowSuperAdminBypass\\\":false},\\\"__statedOptions\\\":[\\\"sqlType\\\",\\\"requiredFor\\\",\\\"__tenancy\\\"],\\\"sqlType\\\":\\\"UUID\\\",\\\"requiredFor\\\":\\\"tenant-scope\\\"},\\\"required\\\":true},\\\"recordType\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[]},\\\"required\\\":false},\\\"recordId\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[]},\\\"required\\\":false},\\\"action\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\"],\\\"required\\\":true},\\\"required\\\":true},\\\"moderationMode\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"default\\\",\\\"enum\\\"],\\\"required\\\":true},\\\"required\\\":true,\\\"default\\\":\\\"open\\\",\\\"enum\\\":[\\\"open\\\",\\\"pre_moderated\\\",\\\"members_only\\\",\\\"closed\\\"]},\\\"maxActions\\\":{\\\"type\\\":\\\"integer\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"default\\\"],\\\"required\\\":true},\\\"required\\\":true,\\\"default\\\":0},\\\"windowSeconds\\\":{\\\"type\\\":\\\"integer\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"default\\\"],\\\"required\\\":true},\\\"required\\\":true,\\\"default\\\":0}},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"participation_policies\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false,\\\"tenantScoped\\\":{\\\"mode\\\":\\\"required\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"ParticipationPolicy\\\",\\\"collectionExportName\\\":\\\"ParticipationPolicyCollection\\\",\\\"validationRules\\\":[{\\\"field\\\":\\\"action\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"},{\\\"field\\\":\\\"moderationMode\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"},{\\\"field\\\":\\\"maxActions\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"integer\\\"},{\\\"field\\\":\\\"windowSeconds\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"integer\\\"}],\\\"schema\\\":{\\\"tableName\\\":\\\"participation_policies\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"participation_policies\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"record_type\\\\\\\" TEXT,\\\\n \\\\\\\"record_id\\\\\\\" TEXT,\\\\n \\\\\\\"action\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"moderation_mode\\\\\\\" TEXT NOT NULL DEFAULT 'open',\\\\n \\\\\\\"max_actions\\\\\\\" INTEGER NOT NULL DEFAULT 0,\\\\n \\\\\\\"window_seconds\\\\\\\" INTEGER NOT NULL DEFAULT 0\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"record_type\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"record_id\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":false,\\\"unique\\\":false},\\\"action\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"moderation_mode\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":\\\"open\\\"},\\\"max_actions\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":0},\\\"window_seconds\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":0}},\\\"indexes\\\":[{\\\"name\\\":\\\"participation_policies_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"participation_policies_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]}],\\\"version\\\":\\\"0aa39678\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"},\\\"@happyvertical/smrt-comments:ParticipationRateBucket\\\":{\\\"name\\\":\\\"participationratebucket\\\",\\\"className\\\":\\\"ParticipationRateBucket\\\",\\\"qualifiedName\\\":\\\"@happyvertical/smrt-comments:ParticipationRateBucket\\\",\\\"collection\\\":\\\"participationratebuckets\\\",\\\"description\\\":\\\"Service-owned fixed-window counter. Never delete a currently active bucket.\\\",\\\"filePath\\\":\\\"src/models/ParticipationRateBucket.ts\\\",\\\"packageName\\\":\\\"@happyvertical/smrt-comments\\\",\\\"fields\\\":{\\\"tenantId\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__tenancy\\\":{\\\"isTenantIdField\\\":true,\\\"autoFilter\\\":true,\\\"required\\\":true,\\\"autoPopulate\\\":true,\\\"nullable\\\":false,\\\"mode\\\":\\\"required\\\",\\\"field\\\":\\\"tenantId\\\",\\\"allowSuperAdminBypass\\\":false},\\\"__statedOptions\\\":[\\\"sqlType\\\",\\\"requiredFor\\\",\\\"__tenancy\\\"],\\\"sqlType\\\":\\\"UUID\\\",\\\"requiredFor\\\":\\\"tenant-scope\\\"},\\\"required\\\":true},\\\"bucketKey\\\":{\\\"type\\\":\\\"text\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"requiredFor\\\"],\\\"required\\\":true,\\\"requiredFor\\\":\\\"identity\\\"},\\\"required\\\":true},\\\"actionCount\\\":{\\\"type\\\":\\\"integer\\\",\\\"_meta\\\":{\\\"__statedOptions\\\":[\\\"required\\\",\\\"default\\\"],\\\"required\\\":true},\\\"required\\\":true,\\\"default\\\":0}},\\\"methods\\\":{},\\\"decoratorConfig\\\":{\\\"tableName\\\":\\\"participation_rate_buckets\\\",\\\"api\\\":false,\\\"mcp\\\":false,\\\"cli\\\":false,\\\"indexes\\\":[{\\\"name\\\":\\\"participation_rate_bucket_unique\\\",\\\"columns\\\":[\\\"tenantId\\\",\\\"bucketKey\\\"],\\\"unique\\\":true}],\\\"tenantScoped\\\":{\\\"mode\\\":\\\"required\\\"},\\\"conflictColumns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"]},\\\"extends\\\":\\\"SmrtObject\\\",\\\"exportName\\\":\\\"ParticipationRateBucket\\\",\\\"collectionExportName\\\":\\\"ParticipationRateBucketCollection\\\",\\\"validationRules\\\":[{\\\"field\\\":\\\"bucketKey\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"text\\\"},{\\\"field\\\":\\\"actionCount\\\",\\\"rule\\\":\\\"required\\\",\\\"fieldType\\\":\\\"integer\\\"}],\\\"schema\\\":{\\\"tableName\\\":\\\"participation_rate_buckets\\\",\\\"ddl\\\":\\\"CREATE TABLE IF NOT EXISTS \\\\\\\"participation_rate_buckets\\\\\\\" (\\\\n \\\\\\\"_sync_origin_device_id\\\\\\\" TEXT,\\\\n \\\\\\\"_sync_revision\\\\\\\" INTEGER,\\\\n \\\\\\\"id\\\\\\\" UUID PRIMARY KEY NOT NULL,\\\\n \\\\\\\"slug\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"context\\\\\\\" TEXT NOT NULL DEFAULT '',\\\\n \\\\\\\"created_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"updated_at\\\\\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\\\n \\\\\\\"tenant_id\\\\\\\" UUID NOT NULL,\\\\n \\\\\\\"bucket_key\\\\\\\" TEXT NOT NULL,\\\\n \\\\\\\"action_count\\\\\\\" INTEGER NOT NULL DEFAULT 0\\\\n);\\\",\\\"columns\\\":{\\\"_sync_origin_device_id\\\":{\\\"type\\\":\\\"TEXT\\\"},\\\"_sync_revision\\\":{\\\"type\\\":\\\"INTEGER\\\"},\\\"id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"primaryKey\\\":true,\\\"referenceKind\\\":\\\"id\\\",\\\"notNull\\\":true},\\\"slug\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true},\\\"context\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"\\\"},\\\"created_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"updated_at\\\":{\\\"type\\\":\\\"TIMESTAMP\\\",\\\"notNull\\\":true,\\\"default\\\":\\\"current_timestamp\\\"},\\\"tenant_id\\\":{\\\"type\\\":\\\"UUID\\\",\\\"referenceKind\\\":\\\"tenantId\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"bucket_key\\\":{\\\"type\\\":\\\"TEXT\\\",\\\"notNull\\\":true,\\\"unique\\\":false},\\\"action_count\\\":{\\\"type\\\":\\\"INTEGER\\\",\\\"notNull\\\":true,\\\"unique\\\":false,\\\"default\\\":0}},\\\"indexes\\\":[{\\\"name\\\":\\\"participation_rate_buckets_slug_context_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"slug\\\",\\\"context\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"participation_rate_bucket_unique\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"bucket_key\\\"],\\\"unique\\\":true},{\\\"name\\\":\\\"participation_rate_buckets_tenant_id_created_at_idx\\\",\\\"columns\\\":[\\\"tenant_id\\\",\\\"created_at\\\"]}],\\\"version\\\":\\\"73800b88\\\"},\\\"importPath\\\":\\\"@happyvertical/smrt-comments\\\"}},\\\"moduleType\\\":\\\"smrt\\\",\\\"recipes\\\":[{\\\"id\\\":\\\"comments.records\\\",\\\"className\\\":\\\"RecordCommentsRecipe\\\",\\\"label\\\":\\\"Record comments\\\",\\\"summary\\\":\\\"Discuss work directly on the records it concerns.\\\",\\\"synonyms\\\":[\\\"comments\\\",\\\"mentions\\\",\\\"discussion\\\"],\\\"models\\\":[\\\"@happyvertical/smrt-comments:Comment\\\",\\\"@happyvertical/smrt-comments:CommentRevision\\\",\\\"@happyvertical/smrt-comments:CommentReport\\\",\\\"@happyvertical/smrt-comments:ParticipationPolicy\\\",\\\"@happyvertical/smrt-comments:ParticipationBan\\\",\\\"@happyvertical/smrt-comments:ParticipationRateBucket\\\"],\\\"nav\\\":[],\\\"requires\\\":[],\\\"group\\\":{\\\"id\\\":\\\"comments\\\",\\\"label\\\":\\\"Comments\\\",\\\"summary\\\":\\\"Keep discussions alongside the records your team works on.\\\"},\\\"help\\\":{\\\"markdown\\\":\\\"## Overview\\\\n\\\\nRecord comments keep a discussion next to the work it concerns. Open a record\\\\nyou can access to read its discussion or add a comment. Comments are part of\\\\nthe record page, rather than a separate list of every discussion.\\\\n\\\\n## Tasks\\\\n\\\\n### Add a comment\\\\n\\\\nOpen the record, find Comments, write your message and choose Post comment.\\\\nYour app controls who can read the record and who can contribute to its discussion.\\\\n\\\\n### Mention someone\\\\n\\\\nIf your app provides mention selection, choose a teammate who can access the\\\\nrecord. When mention notifications are connected, that person receives a\\\\nnotification. Typing a name alone does not select a recipient.\\\\n\\\\n### Check a failed post\\\\n\\\\nIf posting reports an error, refresh the discussion before trying again. A\\\\ncomment may have been saved even when its mention notification could not be\\\\ndelivered. If it appears in the discussion, do not post it a second time.\\\\n\\\",\\\"fieldRefs\\\":[]},\\\"surfaces\\\":[{\\\"kind\\\":\\\"playground\\\",\\\"export\\\":\\\"@happyvertical/smrt-comments/svelte#RecordCommentsPlayground\\\",\\\"label\\\":\\\"Record discussion preview\\\"}],\\\"runtime\\\":\\\"both\\\",\\\"demoSeed\\\":{\\\"export\\\":\\\"@happyvertical/smrt-comments/svelte#recordCommentsDemo\\\"},\\\"demo\\\":{\\\"mode\\\":\\\"server\\\",\\\"reasons\\\":[\\\"Needs a server because its package depends on @happyvertical/smrt-tenancy, which do not build for a browser (#3624).\\\"]}}],\\\"smrtDependencies\\\":[\\\"@happyvertical/smrt-core\\\",\\\"@happyvertical/smrt-messages\\\",\\\"@happyvertical/smrt-tenancy\\\"],\\\"browser\\\":{\\\"status\\\":\\\"server-only\\\",\\\"issues\\\":[\\\"#3624\\\"],\\\"via\\\":[\\\"@happyvertical/smrt-tenancy\\\"]},\\\"stampsConstructors\\\":true}\"));\n","import { field, SmrtObject, smrt } from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/** Tenant-local, reusable participation ban; a blank target applies tenant-wide. */\n@TenantScoped({ mode: 'required' })\n@smrt({ tableName: 'participation_bans', api: false, mcp: false, cli: false })\nexport class ParticipationBan extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-comments\";\n @tenantId() tenantId = '';\n @field({ required: true, requiredFor: 'identity' }) actorUserId = '';\n @field() recordType = '';\n @field() recordId = '';\n @field() reason = '';\n @field({ type: 'datetime', nullable: true }) expiresAt: Date | null = null;\n protected override async validateBeforeSave(): Promise<void> {\n for (const identity of [this.tenantId, this.actorUserId, this.recordId]) {\n if (\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(\n identity,\n ) &&\n identity !== identity.toLowerCase()\n )\n throw new TypeError(\n 'Participation administrative UUIDs must be lowercase.',\n );\n }\n if (Boolean(this.recordType) !== Boolean(this.recordId))\n throw new TypeError(\n 'Participation target requires both recordType and recordId.',\n );\n await super.validateBeforeSave();\n }\n}\n","import { field, SmrtObject, smrt } from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/** A generic tenant default or exact-record override for participation actions. */\n@TenantScoped({ mode: 'required' })\n@smrt({\n tableName: 'participation_policies',\n api: false,\n mcp: false,\n cli: false,\n})\nexport class ParticipationPolicy extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-comments\";\n @tenantId() tenantId = '';\n @field() recordType = '';\n @field() recordId = '';\n @field({ required: true }) action = 'comment';\n @field({ required: true }) moderationMode:\n | 'open'\n | 'pre_moderated'\n | 'members_only'\n | 'closed' = 'open';\n @field({ required: true }) maxActions = 0;\n @field({ required: true }) windowSeconds = 0;\n protected override async validateBeforeSave(): Promise<void> {\n for (const identity of [this.tenantId, this.recordId]) {\n if (\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(\n identity,\n ) &&\n identity !== identity.toLowerCase()\n )\n throw new TypeError(\n 'Participation administrative UUIDs must be lowercase.',\n );\n }\n if (Boolean(this.recordType) !== Boolean(this.recordId))\n throw new TypeError(\n 'Participation target requires both recordType and recordId.',\n );\n if (\n !['comment', 'react', 'vote', 'report'].includes(this.action) ||\n !['open', 'pre_moderated', 'members_only', 'closed'].includes(\n this.moderationMode,\n ) ||\n !Number.isSafeInteger(this.maxActions) ||\n this.maxActions < 0 ||\n !Number.isSafeInteger(this.windowSeconds) ||\n this.windowSeconds < 0 ||\n (this.maxActions > 0 && this.windowSeconds === 0)\n )\n throw new TypeError('Invalid participation policy.');\n await super.validateBeforeSave();\n }\n}\n","import { field, SmrtObject, smrt } from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/** Service-owned fixed-window counter. Never delete a currently active bucket. */\n@TenantScoped({ mode: 'required' })\n@smrt({\n tableName: 'participation_rate_buckets',\n api: false,\n mcp: false,\n cli: false,\n indexes: [\n {\n name: 'participation_rate_bucket_unique',\n columns: ['tenantId', 'bucketKey'],\n unique: true,\n },\n ],\n})\nexport class ParticipationRateBucket extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-comments\";\n @tenantId() tenantId = '';\n @field({ required: true, requiredFor: 'identity' }) bucketKey = '';\n @field({ required: true }) actionCount = 0;\n}\n","import { SmrtCollection } from '@happyvertical/smrt-core';\nimport { ParticipationBan } from '../models/ParticipationBan.js';\nimport { ParticipationPolicy } from '../models/ParticipationPolicy.js';\nimport { ParticipationRateBucket } from '../models/ParticipationRateBucket.js';\n\nexport class ParticipationPolicyCollection extends SmrtCollection<ParticipationPolicy> {\n static readonly _itemClass = ParticipationPolicy;\n}\nexport class ParticipationBanCollection extends SmrtCollection<ParticipationBan> {\n static readonly _itemClass = ParticipationBan;\n}\nexport class ParticipationRateBucketCollection extends SmrtCollection<ParticipationRateBucket> {\n static readonly _itemClass = ParticipationRateBucket;\n}\n","/**\n * Neutral participation boundary shared by record discussions and lightweight\n * reactions/votes. This package owns the generic policy/ban schema; hosts bind\n * only identity and entitlement facts through the authorizer.\n */\nexport type ParticipationAction = 'comment' | 'react' | 'vote' | 'report';\n\nexport interface ParticipationTarget {\n tenantId: string;\n recordType: string;\n recordId: string;\n}\n\nexport interface ParticipationRequest extends ParticipationTarget {\n actorUserId: string;\n action: ParticipationAction;\n}\n\nexport interface ParticipationDecision {\n allowed: boolean;\n /** Trusted entitlement fact required by members_only policy. */\n member?: boolean;\n /** Immutable host-provided entitlement/roll evidence retained by the row. */\n snapshot?: Record<string, unknown>;\n /** Comments may enter the moderation queue without exposing host policy. */\n initialCommentStatus?: 'visible' | 'pending';\n reason?: string;\n}\n\n/**\n * The host supplies entitlement facts; the package's policy/ban/rate service\n * combines them with its tenant-scoped generic anti-abuse records.\n */\nexport interface ParticipationAuthorizer {\n authorize(request: ParticipationRequest): Promise<ParticipationDecision>;\n}\n\nexport class ParticipationDeniedError extends Error {\n constructor(readonly reason?: string) {\n super(reason ? `Participation denied: ${reason}` : 'Participation denied.');\n this.name = 'ParticipationDeniedError';\n }\n}\n","import {\n digestRunOnceContent,\n type SmrtClassOptions,\n} from '@happyvertical/smrt-core';\nimport { withTenant } from '@happyvertical/smrt-tenancy';\nimport {\n ParticipationBanCollection,\n ParticipationPolicyCollection,\n ParticipationRateBucketCollection,\n} from '../collections/ParticipationCollection.js';\nimport type { ParticipationPolicy } from '../models/ParticipationPolicy.js';\nimport {\n type ParticipationAuthorizer,\n type ParticipationDecision,\n ParticipationDeniedError,\n type ParticipationRequest,\n} from '../participation-contract.js';\n\ntype Database = ParticipationRateBucketCollection['db'];\nconst canonical = (value: string) =>\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value)\n ? value.toLowerCase()\n : value;\n\n/** Shared generic policy, ban, and transactional quota enforcement. */\nexport class ParticipationService {\n constructor(\n private readonly options: {\n db: SmrtClassOptions['db'];\n entitlement?: ParticipationAuthorizer;\n /** Trusted clock for deterministic fixed-window boundaries. */\n now?: () => Date;\n },\n ) {}\n\n private normalize(request: ParticipationRequest): ParticipationRequest {\n if (\n !request ||\n !['comment', 'react', 'vote', 'report'].includes(request.action) ||\n [\n request.tenantId,\n request.actorUserId,\n request.recordType,\n request.recordId,\n ].some((value) => typeof value !== 'string' || !value.trim())\n ) {\n throw new TypeError('Invalid participation request.');\n }\n return {\n ...request,\n tenantId: canonical(request.tenantId),\n actorUserId: canonical(request.actorUserId),\n recordId: canonical(request.recordId),\n };\n }\n\n private async evaluate(\n request: ParticipationRequest,\n db: SmrtClassOptions['db'],\n ) {\n const now = (this.options.now?.() ?? new Date()).getTime();\n if (!Number.isFinite(now))\n throw new TypeError('Invalid participation clock.');\n const policies = await ParticipationPolicyCollection.create({ db });\n const rows = await policies.list({\n where: { tenantId: request.tenantId, action: request.action },\n });\n const exact = rows.filter(\n (p) =>\n p.recordType === request.recordType && p.recordId === request.recordId,\n );\n const defaults = rows.filter(\n (p) => p.recordType === '' && p.recordId === '',\n );\n if (exact.length > 1 || defaults.length > 1)\n throw new ParticipationDeniedError('Ambiguous participation policy.');\n const policy = exact[0] ?? defaults[0];\n if (\n policy &&\n (!['open', 'pre_moderated', 'members_only', 'closed'].includes(\n policy.moderationMode,\n ) ||\n !Number.isSafeInteger(policy.maxActions) ||\n policy.maxActions < 0 ||\n !Number.isSafeInteger(policy.windowSeconds) ||\n policy.windowSeconds < 0 ||\n (policy.maxActions > 0 && policy.windowSeconds < 1))\n ) {\n throw new ParticipationDeniedError('Invalid participation policy.');\n }\n if (policy?.moderationMode === 'closed')\n throw new ParticipationDeniedError('Participation is closed.');\n const bans = await ParticipationBanCollection.create({ db });\n for (const ban of await bans.list({\n where: { tenantId: request.tenantId, actorUserId: request.actorUserId },\n })) {\n if (\n (ban.recordType === '' && ban.recordId === '') ||\n (ban.recordType === request.recordType &&\n ban.recordId === request.recordId)\n ) {\n const expiry =\n ban.expiresAt === null ? null : new Date(ban.expiresAt).getTime();\n if (expiry === null || !Number.isFinite(expiry) || expiry > now)\n throw new ParticipationDeniedError('Actor is banned.');\n }\n }\n const decision = this.options.entitlement\n ? await this.options.entitlement.authorize(request)\n : { allowed: true };\n if (\n decision?.allowed !== true ||\n (policy?.moderationMode === 'members_only' && decision.member !== true)\n ) {\n throw new ParticipationDeniedError(\n decision?.reason ?? 'Membership required.',\n );\n }\n if (\n decision.initialCommentStatus !== undefined &&\n !['visible', 'pending'].includes(decision.initialCommentStatus)\n )\n throw new ParticipationDeniedError('Invalid moderation decision.');\n return {\n policy,\n now,\n decision: {\n ...decision,\n initialCommentStatus:\n policy?.moderationMode === 'pre_moderated'\n ? ('pending' as const)\n : decision.initialCommentStatus,\n },\n };\n }\n\n /** Checks current permission without consuming quota (including keyed replays). */\n async authorize(input: ParticipationRequest): Promise<ParticipationDecision> {\n const request = this.normalize(input);\n return withTenant(\n { tenantId: request.tenantId },\n async () => (await this.evaluate(request, this.options.db)).decision,\n );\n }\n\n private async reserve(\n db: Database,\n request: ParticipationRequest,\n policy: ParticipationPolicy | undefined,\n now: number,\n ) {\n if (!policy?.maxActions) return;\n const buckets = await ParticipationRateBucketCollection.create({ db });\n const bucketKey = digestRunOnceContent({\n actor: request.actorUserId,\n action: request.action,\n recordType: policy.recordType,\n recordId: policy.recordId,\n windowSeconds: policy.windowSeconds,\n window: Math.floor(now / (policy.windowSeconds * 1000)),\n });\n const table = `\"${buckets.tableName.replace(/\"/g, '\"\"')}\"`;\n const id = crypto.randomUUID();\n // One bounded atomic upsert arbitrates all service instances and processes.\n // The supplied transaction also owns the guarded mutation; failures release quota.\n const result = await db.query(\n `INSERT INTO ${table} (id, slug, context, tenant_id, bucket_key, action_count) VALUES (?, ?, '', ?, ?, 1) ON CONFLICT (tenant_id, bucket_key) DO UPDATE SET action_count = ${table}.action_count + 1 WHERE ${table}.action_count < ? RETURNING action_count`,\n id,\n id,\n request.tenantId,\n bucketKey,\n policy.maxActions,\n );\n if (result.rows.length !== 1)\n throw new ParticipationDeniedError('Rate limit exceeded.');\n }\n\n /** Run one new mutation atomically with its reservation. Caller owns retry identity. */\n async execute<T>(\n input: ParticipationRequest,\n work: (db: Database, decision: ParticipationDecision) => Promise<T>,\n ): Promise<T> {\n const request = this.normalize(input);\n return withTenant({ tenantId: request.tenantId }, async () => {\n const collection = await ParticipationRateBucketCollection.create({\n db: this.options.db,\n });\n if (!collection.db.transaction)\n throw new Error('Participation requires transactions.');\n return collection.db.transaction((tx) =>\n this.executeInTransaction(tx, request, work),\n );\n });\n }\n\n /** Compose with an existing caller-owned transaction; propagate failures to roll it back. */\n async executeInTransaction<T>(\n tx: Database,\n input: ParticipationRequest,\n work: (db: Database, decision: ParticipationDecision) => Promise<T>,\n ): Promise<T> {\n const request = this.normalize(input);\n return withTenant({ tenantId: request.tenantId }, async () => {\n const { policy, now, decision } = await this.evaluate(request, tx);\n await this.reserve(tx, request, policy, now);\n return work(tx, decision);\n });\n }\n}\n"],"mappings":";;;AAOA,eAAe,wBAAwB,KAAK,MAAM,k02CAAskhD,CAAC;;;;;;;;;;;;;;;;;;ACDlnhD,IAAM,mBAAN,cAA+B,WAAW;CACnC,WAAW;CAC6B,cAAc;CACzD,aAAa;CACb,WAAW;CACX,SAAS;CAC2B,YAAyB;CACtE,MAAyB,qBAAoC;EAC3D,KAAA,MAAW,YAAY;GAAC,KAAK;GAAU,KAAK;GAAa,KAAK;EAAQ,GACpE,IACE,kEAAkE,KAChE,QACF,KACA,aAAa,SAAS,YAAY,GAElC,MAAM,IAAI,UACR,uDACF;EAEJ,IAAI,QAAQ,KAAK,UAAU,MAAM,QAAQ,KAAK,QAAQ,GACpD,MAAM,IAAI,UACR,6DACF;EACF,MAAM,MAAM,mBAAmB;CACjC;AACF;AAzBmD,gBAAtC,kBAA6C,mBAAkB,8BAAA;AAC9D,kBAAA,CAAX,SAAS,CAAA,GADC,iBACC,WAAA,YAAA,CAAA;AACwC,kBAAA,CAAnD,MAAM;CAAE,UAAU;CAAM,aAAa;AAAW,CAAC,CAAA,GAFvC,iBAEyC,WAAA,eAAA,CAAA;AAC3C,kBAAA,CAAR,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,KAAK,QAAQ,GACnB,CAAC;GACD,IAAI,CAAC,WAAW,GAAG,aACjB,MAAM,IAAI,MAAM,sCAAsC;GACxD,OAAO,WAAW,GAAG,aAAa,OAChC,KAAK,qBAAqB,IAAI,SAAS,IAAI,CAC7C;EACF,CAAC;CACH;;CAGA,MAAM,qBACJ,IACA,OACA,MACY;EACZ,MAAM,UAAU,KAAK,UAAU,KAAK;EACpC,OAAO,WAAW,EAAE,UAAU,QAAQ,SAAS,GAAG,YAAY;GAC5D,MAAM,EAAE,QAAQ,KAAK,aAAa,MAAM,KAAK,SAAS,SAAS,EAAE;GACjE,MAAM,KAAK,QAAQ,IAAI,SAAS,QAAQ,GAAG;GAC3C,OAAO,KAAK,IAAI,QAAQ;EAC1B,CAAC;CACH;AACF"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ParticipationRateBucketCollection, c as ParticipationBan, i as ParticipationPolicyCollection, n as ParticipationDeniedError, o as ParticipationRateBucket, r as ParticipationBanCollection, s as ParticipationPolicy, t as ParticipationService } from "./chunks/participation-
|
|
2
|
-
import { SmrtCollection, SmrtObject, SmrtPolymorphicAssociation, SmrtRecipe, crossPackageRef, digestRunOnceContent, field, foreignKey, runOnce, smrt } from "@happyvertical/smrt-core";
|
|
1
|
+
import { a as ParticipationRateBucketCollection, c as ParticipationBan, i as ParticipationPolicyCollection, n as ParticipationDeniedError, o as ParticipationRateBucket, r as ParticipationBanCollection, s as ParticipationPolicy, t as ParticipationService } from "./chunks/participation-DhhyArQd.js";
|
|
2
|
+
import { ObjectRegistry, SmrtCollection, SmrtObject, SmrtPolymorphicAssociation, SmrtRecipe, crossPackageRef, digestRunOnceContent, field, foreignKey, runOnce, smrt } from "@happyvertical/smrt-core";
|
|
3
3
|
import { TenantIsolationError, TenantScoped, getCurrentTenant, tenantId, withTenant } from "@happyvertical/smrt-tenancy";
|
|
4
4
|
//#region src/models/Comment.ts
|
|
5
5
|
var __defProp$2 = Object.defineProperty;
|
|
@@ -63,8 +63,14 @@ var Comment = class extends SmrtPolymorphicAssociation {
|
|
|
63
63
|
};
|
|
64
64
|
__publicField$2(Comment, "__smrtPackage__", "@happyvertical/smrt-comments");
|
|
65
65
|
__decorateClass$2([tenantId()], Comment.prototype, "tenantId", 2);
|
|
66
|
-
__decorateClass$2([crossPackageRef("@happyvertical/smrt-users:User", {
|
|
67
|
-
|
|
66
|
+
__decorateClass$2([crossPackageRef("@happyvertical/smrt-users:User", {
|
|
67
|
+
required: true,
|
|
68
|
+
requiredFor: "identity"
|
|
69
|
+
})], Comment.prototype, "authorUserId", 2);
|
|
70
|
+
__decorateClass$2([field({
|
|
71
|
+
required: true,
|
|
72
|
+
requiredFor: "idempotency"
|
|
73
|
+
})], Comment.prototype, "body", 2);
|
|
68
74
|
__decorateClass$2([field({
|
|
69
75
|
type: "text",
|
|
70
76
|
nullable: true,
|
|
@@ -178,10 +184,14 @@ __publicField$1(CommentReport, "__smrtPackage__", "@happyvertical/smrt-comments"
|
|
|
178
184
|
__decorateClass$1([tenantId()], CommentReport.prototype, "tenantId", 2);
|
|
179
185
|
__decorateClass$1([foreignKey("Comment", {
|
|
180
186
|
required: true,
|
|
187
|
+
requiredFor: "identity",
|
|
181
188
|
constraint: false
|
|
182
189
|
})], CommentReport.prototype, "commentId", 2);
|
|
183
|
-
__decorateClass$1([crossPackageRef("@happyvertical/smrt-users:User", {
|
|
184
|
-
|
|
190
|
+
__decorateClass$1([crossPackageRef("@happyvertical/smrt-users:User", {
|
|
191
|
+
required: true,
|
|
192
|
+
requiredFor: "identity"
|
|
193
|
+
})], CommentReport.prototype, "reporterUserId", 2);
|
|
194
|
+
__decorateClass$1([field()], CommentReport.prototype, "reason", 2);
|
|
185
195
|
__decorateClass$1([field({ required: true })], CommentReport.prototype, "status", 2);
|
|
186
196
|
CommentReport = __decorateClass$1([TenantScoped({ mode: "required" }), smrt({
|
|
187
197
|
tableName: "comment_reports",
|
|
@@ -230,17 +240,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
230
240
|
var CommentRevision = class extends SmrtObject {
|
|
231
241
|
tenantId = "";
|
|
232
242
|
commentId = "";
|
|
233
|
-
editorUserId =
|
|
243
|
+
editorUserId = null;
|
|
234
244
|
body = "";
|
|
235
245
|
};
|
|
236
246
|
__publicField(CommentRevision, "__smrtPackage__", "@happyvertical/smrt-comments");
|
|
237
247
|
__decorateClass([tenantId()], CommentRevision.prototype, "tenantId", 2);
|
|
238
248
|
__decorateClass([foreignKey("Comment", {
|
|
239
249
|
required: true,
|
|
250
|
+
requiredFor: "identity",
|
|
240
251
|
constraint: false
|
|
241
252
|
})], CommentRevision.prototype, "commentId", 2);
|
|
242
|
-
__decorateClass([crossPackageRef("@happyvertical/smrt-users:User", {
|
|
243
|
-
__decorateClass([field({
|
|
253
|
+
__decorateClass([crossPackageRef("@happyvertical/smrt-users:User", { nullable: true })], CommentRevision.prototype, "editorUserId", 2);
|
|
254
|
+
__decorateClass([field({
|
|
255
|
+
required: true,
|
|
256
|
+
requiredFor: "idempotency"
|
|
257
|
+
})], CommentRevision.prototype, "body", 2);
|
|
244
258
|
CommentRevision = __decorateClass([TenantScoped({ mode: "required" }), smrt({
|
|
245
259
|
tableName: "comment_revisions",
|
|
246
260
|
api: false,
|
|
@@ -478,7 +492,7 @@ var CommentService = class {
|
|
|
478
492
|
entitlement: this.options.participation
|
|
479
493
|
}).authorize(participationRequest);
|
|
480
494
|
if (!body?.trim()) throw new TypeError("Comment body is required.");
|
|
481
|
-
const prepared = new Comment();
|
|
495
|
+
const prepared = new (ObjectRegistry.resolveEffectiveConstructor(Comment))();
|
|
482
496
|
if (mentions !== void 0) prepared.mentionUserIds = mentions;
|
|
483
497
|
if (idempotencyKey !== void 0 && (typeof idempotencyKey !== "string" || !idempotencyKey.trim() || idempotencyKey !== idempotencyKey.trim() || idempotencyKey.length > 200)) throw new TypeError("Comment idempotencyKey must be a nonempty trimmed string of at most 200 characters.");
|
|
484
498
|
const normalizedMentions = [...prepared.mentionUserIds].sort();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["row"],"sources":["../src/models/Comment.ts","../src/collections/CommentCollection.ts","../src/models/CommentReport.ts","../src/collections/CommentReportCollection.ts","../src/models/CommentRevision.ts","../src/collections/CommentRevisionCollection.ts","../src/recipes.ts","../src/services/CommentService.ts","../src/services/mentionNotifications.ts"],"sourcesContent":["import {\n crossPackageRef,\n field,\n foreignKey,\n SmrtPolymorphicAssociation,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\nimport type { CommentOptions, CommentStatus } from '../types.js';\n\nconst MAX_MENTIONS = 50;\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n@TenantScoped({ mode: 'required' })\n@smrt({\n tableName: 'record_comments',\n api: false,\n mcp: false,\n cli: false,\n indexes: [\n {\n name: 'record_comments_tenant_request_key',\n columns: ['retryTenantId', 'idempotencyKey'],\n unique: true,\n },\n {\n name: 'record_comments_record_created_idx',\n columns: ['tenantId', 'metaType', 'metaId', 'createdAt'],\n },\n {\n name: 'record_comments_parent_created_idx',\n columns: ['tenantId', 'parentCommentId', 'createdAt'],\n },\n {\n name: 'record_comments_moderation_idx',\n columns: ['tenantId', 'status', 'createdAt'],\n },\n ],\n})\nexport class Comment extends SmrtPolymorphicAssociation { static __smrtPackage__ = \"@happyvertical/smrt-comments\";\n @tenantId()\n tenantId = '';\n\n @crossPackageRef('@happyvertical/smrt-users:User', { required: true })\n authorUserId = '';\n\n @field({ required: true })\n body = '';\n\n /** JSON array of referenced User UUIDs; use mentionUserIds for validation. */\n mentions = '[]';\n\n /** Service-owned binding retained after generic runOnce claim retention. */\n @field({ type: 'text', nullable: true, readonly: true })\n idempotencyKey: string | null = null;\n\n /** Canonical retry namespace; never rewrites stored tenant/user references. */\n @field({ type: 'text', nullable: true, readonly: true })\n retryTenantId: string | null = null;\n\n /** Digest of the original authenticated author, parent and normalized payload. */\n @field({ type: 'text', nullable: true, readonly: true })\n requestDigest: string | null = null;\n\n /** A reply stays within this comment's already-authorized record thread. */\n // DuckDB cannot safely insert self-referential FKs; CommentService binds it.\n @foreignKey('Comment', { nullable: true, constraint: false })\n parentCommentId: string | null = null;\n\n /** Visible comments are public to the host's authorized record readers. */\n @field({ required: true })\n status: CommentStatus = 'visible';\n\n /** JSON retained from the host participation decision at post time. */\n @field({ type: 'text', nullable: true, readonly: true })\n participationSnapshot: string | null = null;\n\n @field({ type: 'datetime', nullable: true, readonly: true })\n editedAt: Date | null = null;\n\n constructor(options: CommentOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.authorUserId !== undefined)\n this.authorUserId = options.authorUserId;\n if (options.body !== undefined) this.body = options.body;\n if (options.idempotencyKey !== undefined)\n this.idempotencyKey = options.idempotencyKey;\n if (options.retryTenantId !== undefined)\n this.retryTenantId = options.retryTenantId;\n if (options.requestDigest !== undefined)\n this.requestDigest = options.requestDigest;\n if (options.parentCommentId !== undefined)\n this.parentCommentId = options.parentCommentId;\n if (options.status !== undefined) this.status = options.status;\n if (options.participationSnapshot !== undefined)\n this.participationSnapshot = options.participationSnapshot;\n const mentions = options.mentions as unknown;\n if (Array.isArray(mentions)) this.mentionUserIds = mentions;\n else if (typeof mentions === 'string') this.mentions = mentions;\n }\n\n get mentionUserIds(): string[] {\n try {\n const parsed: unknown = JSON.parse(this.mentions);\n return Array.isArray(parsed) &&\n parsed.every((value) => typeof value === 'string')\n ? parsed\n : [];\n } catch {\n return [];\n }\n }\n\n set mentionUserIds(value: readonly string[]) {\n const unique = [...new Set(value.map((id) => id.trim()).filter(Boolean))];\n if (unique.length > MAX_MENTIONS || unique.some((id) => !UUID.test(id))) {\n throw new TypeError(\n 'Comment mentions must contain at most 50 user UUIDs.',\n );\n }\n this.mentions = JSON.stringify(unique);\n }\n}\n","import { SmrtCollection } from '@happyvertical/smrt-core';\nimport {\n getCurrentTenant,\n TenantIsolationError,\n} from '@happyvertical/smrt-tenancy';\nimport { Comment } from '../models/Comment.js';\n\nexport class CommentCollection extends SmrtCollection<Comment> {\n static readonly _itemClass = Comment;\n\n async listForRecord(\n recordType: string,\n recordId: string,\n ): Promise<Comment[]> {\n const tenantId = getCurrentTenant()?.tenantId;\n if (!tenantId) {\n throw new TenantIsolationError(\n 'Record comments require a tenant context.',\n );\n }\n return this.list({\n where: { tenantId, metaType: recordType, metaId: recordId },\n orderBy: ['createdAt ASC'],\n });\n }\n}\n","import {\n crossPackageRef,\n field,\n foreignKey,\n SmrtObject,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/** A tenant-local report; moderation resolution never deletes the report. */\n@TenantScoped({ mode: 'required' })\n@smrt({\n tableName: 'comment_reports',\n api: false,\n mcp: false,\n cli: false,\n indexes: [\n {\n name: 'comment_reports_actor_target_unique',\n columns: ['tenantId', 'reporterUserId', 'commentId'],\n unique: true,\n },\n {\n name: 'comment_reports_queue_idx',\n columns: ['tenantId', 'status', 'createdAt'],\n },\n ],\n})\nexport class CommentReport extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-comments\";\n @tenantId()\n tenantId = '';\n\n // Reports outlive comment-state changes and must work on DuckDB.\n @foreignKey('Comment', { required: true, constraint: false })\n commentId = '';\n\n @crossPackageRef('@happyvertical/smrt-users:User', { required: true })\n reporterUserId = '';\n\n @field({ required: true })\n reason = '';\n\n @field({ required: true })\n status: 'open' | 'resolved' | 'dismissed' = 'open';\n}\n","import { SmrtCollection } from '@happyvertical/smrt-core';\nimport { CommentReport } from '../models/CommentReport.js';\n\nexport class CommentReportCollection extends SmrtCollection<CommentReport> {\n static readonly _itemClass = CommentReport;\n}\n","import {\n crossPackageRef,\n field,\n foreignKey,\n SmrtObject,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/** Immutable prior body retained whenever an author edits a comment. */\n@TenantScoped({ mode: 'required' })\n@smrt({ tableName: 'comment_revisions', api: false, mcp: false, cli: false })\nexport class CommentRevision extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-comments\";\n @tenantId()\n tenantId = '';\n\n // Retained history is service-owned; keep cross-dialect schema portable.\n @foreignKey('Comment', { required: true, constraint: false })\n commentId = '';\n\n @crossPackageRef('@happyvertical/smrt-users:User', { required: true })\n editorUserId = '';\n\n @field({ required: true })\n body = '';\n}\n","import { SmrtCollection } from '@happyvertical/smrt-core';\nimport { CommentRevision } from '../models/CommentRevision.js';\n\nexport class CommentRevisionCollection extends SmrtCollection<CommentRevision> {\n static readonly _itemClass = CommentRevision;\n}\n","import { SmrtRecipe } from '@happyvertical/smrt-core';\nimport { Comment } from './models/Comment.js';\nimport { CommentReport } from './models/CommentReport.js';\nimport { CommentRevision } from './models/CommentRevision.js';\nimport { ParticipationBan } from './models/ParticipationBan.js';\nimport { ParticipationPolicy } from './models/ParticipationPolicy.js';\nimport { ParticipationRateBucket } from './models/ParticipationRateBucket.js';\n\n/** Discussion attached to any authorized business record. */\nexport class RecordCommentsRecipe extends SmrtRecipe {\n static id = 'comments.records';\n static label = 'Record comments';\n static summary = 'Discuss work directly on the records it concerns.';\n static synonyms = ['comments', 'mentions', 'discussion'];\n static group = {\n id: 'comments',\n label: 'Comments',\n summary: 'Keep discussions alongside the records your team works on.',\n };\n static models = [\n Comment,\n CommentRevision,\n CommentReport,\n ParticipationPolicy,\n ParticipationBan,\n ParticipationRateBucket,\n ];\n // Record discussions need an authorized parent record, not a global list.\n static nav = [];\n static runtime = 'both' as const;\n static surfaces = [\n {\n kind: 'playground',\n export: '@happyvertical/smrt-comments/svelte#RecordCommentsPlayground',\n label: 'Record discussion preview',\n },\n ] as const;\n static demoSeed = {\n export: '@happyvertical/smrt-comments/svelte#recordCommentsDemo',\n } as const;\n static help = './comments.records.recipe.md';\n}\n","import {\n digestRunOnceContent,\n runOnce,\n type SmrtClassOptions,\n} from '@happyvertical/smrt-core';\nimport { withTenant } from '@happyvertical/smrt-tenancy';\nimport { CommentCollection } from '../collections/CommentCollection.js';\nimport { CommentReportCollection } from '../collections/CommentReportCollection.js';\nimport { CommentRevisionCollection } from '../collections/CommentRevisionCollection.js';\nimport { Comment } from '../models/Comment.js';\nimport type {\n ParticipationAuthorizer,\n ParticipationDecision,\n} from '../participation-contract.js';\nimport type {\n CommentActorContext,\n CommentMentionNotificationAdapter,\n CommentRecordAccess,\n CommentStatus,\n CreateCommentInput,\n} from '../types.js';\nimport { ParticipationService } from './ParticipationService.js';\n\n// Native UUID columns canonicalize case; identity and digests must agree with them.\nconst canonicalUuid = (value: string) =>\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value)\n ? value.toLowerCase()\n : value;\n\n/** A reused request differs, or its retained comment is no longer available. */\nexport class CommentIdempotencyError extends Error {\n constructor(\n readonly code: 'COMMENT_REQUEST_CONFLICT' | 'COMMENT_REQUEST_UNAVAILABLE',\n ) {\n super(\n code === 'COMMENT_REQUEST_CONFLICT'\n ? 'Comment request key already used with different content.'\n : 'Comment request no longer has a valid retained creation binding.',\n );\n this.name = 'CommentIdempotencyError';\n }\n}\n\nexport class CommentService {\n constructor(\n private readonly options: {\n db: SmrtClassOptions['db'];\n actor: CommentActorContext;\n authorizeRecord: (access: CommentRecordAccess) => Promise<boolean>;\n participation?: ParticipationAuthorizer;\n mentionNotifications?: CommentMentionNotificationAdapter;\n },\n ) {}\n\n private async authorize(\n recordType: string,\n recordId: string,\n action: 'read' | 'comment' | 'moderate',\n ) {\n const { actor } = this.options;\n if (\n !actor.tenantId ||\n !actor.userId ||\n !recordType ||\n !recordId ||\n !(await this.options.authorizeRecord({\n ...actor,\n recordType,\n recordId,\n action,\n }))\n ) {\n throw new Error('Comment record access denied.');\n }\n }\n\n private async getAuthorizedComment(\n commentId: string,\n action: 'read' | 'moderate',\n ) {\n const tenantId = this.options.actor.tenantId;\n const comment = await withTenant({ tenantId }, async () =>\n (await CommentCollection.create({ db: this.options.db })).get(commentId),\n );\n if (!comment || canonicalUuid(comment.tenantId) !== canonicalUuid(tenantId))\n throw new Error('Comment not found.');\n await this.authorize(comment.metaType, comment.metaId, action);\n return comment;\n }\n\n /** Edits retain the exact former body before changing the visible comment. */\n async edit(commentId: string, body: string): Promise<Comment> {\n if (!body.trim()) throw new TypeError('Comment body is required.');\n const comment = await this.getAuthorizedComment(commentId, 'read');\n if (\n canonicalUuid(comment.authorUserId) !==\n canonicalUuid(this.options.actor.userId)\n )\n throw new Error('Comment edit denied.');\n await this.authorize(comment.metaType, comment.metaId, 'comment');\n const tenantId = this.options.actor.tenantId;\n return withTenant({ tenantId }, async () => {\n const collection = await CommentCollection.create({\n db: this.options.db,\n });\n if (!collection.db.transaction)\n throw new Error('Comment edits require transactions.');\n return collection.db.transaction(async (tx) => {\n const scoped = await CommentCollection.create({ db: tx });\n // Acquire the row's write lock before reading the body retained as history.\n const table = `\"${scoped.tableName.replace(/\"/g, '\"\"')}\"`;\n await tx.query(\n `UPDATE ${table} SET body = body WHERE id = ? AND tenant_id = ?`,\n commentId,\n tenantId,\n );\n const current = await scoped.get(commentId);\n if (\n !current ||\n canonicalUuid(current.authorUserId) !==\n canonicalUuid(this.options.actor.userId)\n )\n throw new Error('Comment edit denied.');\n const participation = new ParticipationService({\n db: tx,\n entitlement: this.options.participation,\n });\n return participation.executeInTransaction(\n tx,\n {\n tenantId,\n actorUserId: this.options.actor.userId,\n action: 'comment',\n recordType: current.metaType,\n recordId: current.metaId,\n },\n async (guardedTx, decision) =>\n withTenant({ tenantId: current.tenantId }, async () => {\n const revisions = await CommentRevisionCollection.create({\n db: guardedTx,\n });\n await revisions.create({\n tenantId: current.tenantId,\n commentId,\n editorUserId: this.options.actor.userId,\n body: current.body,\n });\n if (\n current.status === 'visible' &&\n decision.initialCommentStatus === 'pending'\n ) {\n current.status = 'pending';\n }\n current.body = body;\n current.editedAt = new Date();\n await current.save();\n return current;\n }),\n );\n });\n });\n }\n\n /** A moderator may make a row visible, hidden, pending, or deleted. */\n async moderate(commentId: string, status: CommentStatus): Promise<Comment> {\n const comment = await this.getAuthorizedComment(commentId, 'moderate');\n if (!['visible', 'hidden', 'pending', 'deleted'].includes(status))\n throw new TypeError('Invalid comment moderation status.');\n return withTenant({ tenantId: comment.tenantId }, async () => {\n const collection = await CommentCollection.create({\n db: this.options.db,\n });\n if (!collection.db.transaction)\n throw new Error('Comment moderation requires transactions.');\n return collection.db.transaction(async (tx) => {\n const scoped = await CommentCollection.create({ db: tx });\n const table = `\"${scoped.tableName.replace(/\"/g, '\"\"')}\"`;\n // Reload after locking so the save lifecycle cannot clobber a concurrent edit.\n await tx.query(\n `UPDATE ${table} SET body = body WHERE id = ? AND tenant_id = ?`,\n commentId,\n comment.tenantId,\n );\n const current = await scoped.get(commentId);\n if (!current) throw new Error('Comment not found.');\n current.status = status;\n await current.save();\n return current;\n });\n });\n }\n\n /** One retained report per actor/comment; new reports consume shared report quota. */\n async report(commentId: string, reason: string) {\n if (!reason.trim())\n throw new TypeError('Comment report reason is required.');\n const comment = await this.getAuthorizedComment(commentId, 'read');\n if (comment.status !== 'visible')\n throw new Error('Comment is not reportable.');\n commentId = canonicalUuid(comment.id ?? commentId);\n const tenantId = canonicalUuid(this.options.actor.tenantId);\n const reporterUserId = canonicalUuid(this.options.actor.userId);\n const request = {\n tenantId,\n actorUserId: reporterUserId,\n action: 'report' as const,\n recordType: comment.metaType,\n recordId: comment.metaId,\n };\n const guard = new ParticipationService({\n db: this.options.db,\n entitlement: this.options.participation,\n });\n await guard.authorize(request);\n return withTenant({ tenantId }, async () => {\n const reports = await CommentReportCollection.create({\n db: this.options.db,\n });\n const id = await runOnce(\n {\n db: reports.db,\n tenantId,\n actor: 'smrt-comments.report:v1',\n token: `${reporterUserId}:${canonicalUuid(commentId)}`,\n content: 'retained-report:v1',\n },\n async (tx) => {\n const scoped = await CommentReportCollection.create({ db: tx });\n const existing = await scoped.list({\n where: { tenantId, reporterUserId, commentId },\n });\n if (existing[0]) return existing[0].id;\n return guard.executeInTransaction(tx, request, async (guardedTx) => {\n const current = await withTenant(\n { tenantId: comment.tenantId },\n async () =>\n (await CommentCollection.create({ db: guardedTx })).get(\n commentId,\n ),\n );\n if (!current || current.status !== 'visible')\n throw new Error('Comment is not reportable.');\n return (\n await (\n await CommentReportCollection.create({ db: guardedTx })\n ).create({\n tenantId,\n commentId,\n reporterUserId,\n reason: reason.trim(),\n status: 'open',\n })\n ).id;\n });\n },\n );\n const report = id ? await reports.get(id) : null;\n if (\n !report ||\n report.commentId !== canonicalUuid(commentId) ||\n report.reporterUserId !== reporterUserId\n )\n throw new Error('Retained report unavailable.');\n return report;\n });\n }\n\n async listForRecord(\n recordType: string,\n recordId: string,\n ): Promise<Comment[]> {\n await this.authorize(recordType, recordId, 'read');\n const tenantId = this.options.actor.tenantId;\n const binding = canonicalUuid(tenantId);\n const rows = await withTenant({ tenantId }, async () =>\n (await CommentCollection.create({ db: this.options.db })).listForRecord(\n recordType,\n recordId,\n ),\n );\n const collection = await withTenant({ tenantId }, () =>\n CommentCollection.create({ db: this.options.db }),\n );\n // The canonical retry namespace is separate from legacy reference spelling.\n // This query is tenant/parent-bound before any scoped hydration.\n const bound = await collection.db.query(\n `SELECT CAST(id AS TEXT) AS id, CAST(tenant_id AS TEXT) AS tenant_id FROM \"${collection.tableName.replace(/\"/g, '\"\"')}\" WHERE retry_tenant_id = ? AND meta_type = ? AND meta_id = ? AND idempotency_key IS NOT NULL`,\n binding,\n recordType,\n recordId,\n );\n for (const stored of bound.rows) {\n const row = await this.loadBoundComment(collection.db, stored, binding);\n if (row.metaType !== recordType || row.metaId !== recordId) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n rows.push(row);\n }\n for (const row of rows) {\n if (row.idempotencyKey !== null && row.retryTenantId !== binding) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n }\n return [...new Map(rows.map((row) => [row.id, row])).values()].sort(\n (a, b) =>\n (a.created_at?.getTime() ?? 0) - (b.created_at?.getTime() ?? 0) ||\n (a.id ?? '').localeCompare(b.id ?? ''),\n );\n }\n\n private async loadBoundComment(\n db: CommentCollection['db'],\n stored: { [key: string]: unknown },\n binding: string,\n ): Promise<Comment> {\n const id = stored.id;\n const tenantId = stored.tenant_id;\n if (\n typeof id !== 'string' ||\n typeof tenantId !== 'string' ||\n canonicalUuid(tenantId) !== binding\n ) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n // This is the original spelling of the same authorized tenant, not a bypass.\n const row = await withTenant({ tenantId }, async () =>\n (await CommentCollection.create({ db })).get(id),\n );\n if (\n !row ||\n canonicalUuid(row.tenantId) !== binding ||\n row.retryTenantId !== binding ||\n row.idempotencyKey === null\n ) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n return row;\n }\n\n async create(commentOptions: CreateCommentInput): Promise<Comment> {\n const {\n tenantId: inputTenantId,\n authorUserId: inputAuthorUserId,\n metaType,\n metaId,\n body,\n mentions,\n idempotencyKey,\n parentCommentId: inputParentCommentId,\n } = commentOptions;\n const parentCommentId = inputParentCommentId\n ? canonicalUuid(inputParentCommentId)\n : inputParentCommentId;\n if (!inputTenantId || !inputAuthorUserId) {\n throw new TypeError('Comments require a tenant and author.');\n }\n if (\n canonicalUuid(inputTenantId) !==\n canonicalUuid(this.options.actor.tenantId) ||\n canonicalUuid(inputAuthorUserId) !==\n canonicalUuid(this.options.actor.userId)\n ) {\n throw new Error('Comment actor context mismatch.');\n }\n // Preserve the trusted context's stored spelling on text-backed databases.\n const tenantId = this.options.actor.tenantId;\n const authorUserId = this.options.actor.userId;\n await this.authorize(metaType ?? '', metaId ?? '', 'comment');\n const participationRequest = {\n tenantId,\n actorUserId: authorUserId,\n action: 'comment' as const,\n recordType: metaType ?? '',\n recordId: metaId ?? '',\n };\n await new ParticipationService({\n db: this.options.db,\n entitlement: this.options.participation,\n }).authorize(participationRequest);\n if (!body?.trim()) throw new TypeError('Comment body is required.');\n // Validate through the model's public setter before collection.create()\n // persists. Supply its normalized JSON in that single insert.\n const prepared = new Comment();\n if (mentions !== undefined) prepared.mentionUserIds = mentions;\n if (\n idempotencyKey !== undefined &&\n (typeof idempotencyKey !== 'string' ||\n !idempotencyKey.trim() ||\n idempotencyKey !== idempotencyKey.trim() ||\n idempotencyKey.length > 200)\n ) {\n throw new TypeError(\n 'Comment idempotencyKey must be a nonempty trimmed string of at most 200 characters.',\n );\n }\n const normalizedMentions = [...prepared.mentionUserIds].sort();\n const requestDigest = digestRunOnceContent({\n tenantId: canonicalUuid(tenantId),\n authorUserId: canonicalUuid(authorUserId),\n metaType,\n metaId,\n body,\n mentions: normalizedMentions,\n ...(parentCommentId ? { parentCommentId } : {}),\n });\n const comment = await withTenant({ tenantId }, async () => {\n const collection = await CommentCollection.create({\n db: this.options.db,\n });\n const insert = async (\n target: CommentCollection,\n inTransaction = false,\n ) => {\n const guard = new ParticipationService({\n db: target.db,\n entitlement: this.options.participation,\n });\n const work = async (\n tx: CommentCollection['db'],\n participation: ParticipationDecision,\n ) =>\n withTenant({ tenantId }, async () => {\n target = await CommentCollection.create({ db: tx });\n if (parentCommentId) {\n const parent = await target.get(parentCommentId);\n if (\n !parent ||\n canonicalUuid(parent.tenantId) !== canonicalUuid(tenantId) ||\n parent.metaType !== metaType ||\n parent.metaId !== metaId\n ) {\n throw new Error(\n 'Comment parent does not belong to this record.',\n );\n }\n }\n const id = crypto.randomUUID();\n return target.create({\n tenantId,\n authorUserId,\n metaType,\n metaId,\n body,\n id,\n slug: id,\n context: '',\n _insertOnly: true,\n mentions: prepared.mentions,\n idempotencyKey: idempotencyKey ?? null,\n requestDigest:\n idempotencyKey === undefined ? null : requestDigest,\n retryTenantId:\n idempotencyKey === undefined ? null : canonicalUuid(tenantId),\n parentCommentId: parentCommentId ?? null,\n status: participation.initialCommentStatus ?? 'visible',\n participationSnapshot: participation.snapshot\n ? JSON.stringify(participation.snapshot)\n : null,\n });\n });\n return inTransaction\n ? guard.executeInTransaction(target.db, participationRequest, work)\n : guard.execute(participationRequest, work);\n };\n if (idempotencyKey === undefined) return insert(collection);\n // The internal actor is an arbitration namespace, NOT the authenticated\n // author. All authors sharing a tenant/key must contend on the same claim.\n // Actual author and payload are bound by the independently checked digest.\n const receipt = await runOnce(\n {\n db: collection.db,\n tenantId: canonicalUuid(tenantId),\n actor: 'smrt-comments.create:v1',\n token: idempotencyKey,\n content: 'comment-request-binding:v1',\n },\n async (tx) => {\n const scoped = await CommentCollection.create({ db: tx });\n const matches = await tx.query(\n `SELECT CAST(id AS TEXT) AS id, CAST(tenant_id AS TEXT) AS tenant_id FROM \"${scoped.tableName.replace(/\"/g, '\"\"')}\" WHERE retry_tenant_id = ? AND idempotency_key = ?`,\n canonicalUuid(tenantId),\n idempotencyKey,\n );\n if (matches.rows.length > 1) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n const row = matches.rows[0]\n ? await this.loadBoundComment(\n tx,\n matches.rows[0],\n canonicalUuid(tenantId),\n )\n : await insert(scoped, true);\n return {\n id: row.id,\n digest: row.requestDigest,\n tenant_id: row.tenantId,\n };\n },\n );\n if (receipt.digest !== requestDigest)\n throw new CommentIdempotencyError('COMMENT_REQUEST_CONFLICT');\n const row = await this.loadBoundComment(\n collection.db,\n receipt,\n canonicalUuid(tenantId),\n );\n const retainedBodies = row.editedAt\n ? await withTenant({ tenantId: row.tenantId }, async () =>\n (\n await (\n await CommentRevisionCollection.create({ db: collection.db })\n ).list({\n where: { commentId: row.id, tenantId: row.tenantId },\n })\n ).map((revision) => revision.body),\n )\n : [row.body];\n if (\n canonicalUuid(row.tenantId) !== canonicalUuid(tenantId) ||\n row.idempotencyKey !== idempotencyKey ||\n row.requestDigest !== requestDigest ||\n !retainedBodies.some(\n (retainedBody) =>\n digestRunOnceContent({\n tenantId: canonicalUuid(row.tenantId),\n authorUserId: canonicalUuid(row.authorUserId),\n metaType: row.metaType,\n metaId: row.metaId,\n body: retainedBody,\n mentions: [...row.mentionUserIds].sort(),\n ...(row.parentCommentId\n ? { parentCommentId: canonicalUuid(row.parentCommentId) }\n : {}),\n }) === requestDigest,\n )\n ) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n return row;\n });\n if (\n !this.options.mentionNotifications ||\n !comment.id ||\n comment.status !== 'visible'\n )\n return comment;\n for (const recipientUserId of comment.mentionUserIds) {\n if (\n canonicalUuid(recipientUserId) === canonicalUuid(comment.authorUserId)\n )\n continue;\n await this.options.mentionNotifications.notifyMention({\n commentId: comment.id,\n tenantId: comment.tenantId,\n authorUserId: comment.authorUserId,\n recipientUserId,\n recordType: comment.metaType,\n recordId: comment.metaId,\n body: comment.body,\n });\n }\n return comment;\n }\n}\n","import type {\n CommentMention,\n CommentMentionNotificationAdapter,\n} from '../types.js';\n\n/** Structural subset implemented by smrt-messages UserNotificationService. */\nexport interface CommentNotificationService {\n notify(input: {\n tenantId: string;\n recipientUserId: string;\n kind: string;\n title: string;\n body: string;\n sourceRef: string;\n }): Promise<unknown>;\n}\n\n/** Hosts must check recipient membership AND access to the referenced record. */\nexport function createCommentMentionNotifications(options: {\n notifications: CommentNotificationService;\n canNotify: (mention: CommentMention) => Promise<boolean>;\n}): CommentMentionNotificationAdapter {\n return {\n async notifyMention(mention) {\n if (!(await options.canNotify(mention))) return;\n await options.notifications.notify({\n tenantId: mention.tenantId,\n recipientUserId: mention.recipientUserId,\n kind: 'comments.mention',\n title: 'You were mentioned in a comment',\n body: mention.body,\n sourceRef: `comments.mention:${mention.commentId}`,\n });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,IAAM,eAAe;AACrB,IAAM,OAAO;AA4BN,IAAM,UAAN,cAAsB,2BAA2B;CAE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comment.ts","../src/collections/CommentCollection.ts","../src/models/CommentReport.ts","../src/collections/CommentReportCollection.ts","../src/models/CommentRevision.ts","../src/collections/CommentRevisionCollection.ts","../src/recipes.ts","../src/services/CommentService.ts","../src/services/mentionNotifications.ts"],"sourcesContent":["import {\n crossPackageRef,\n field,\n foreignKey,\n SmrtPolymorphicAssociation,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\nimport type { CommentOptions, CommentStatus } from '../types.js';\n\nconst MAX_MENTIONS = 50;\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n@TenantScoped({ mode: 'required' })\n@smrt({\n tableName: 'record_comments',\n api: false,\n mcp: false,\n cli: false,\n indexes: [\n {\n name: 'record_comments_tenant_request_key',\n columns: ['retryTenantId', 'idempotencyKey'],\n unique: true,\n },\n {\n name: 'record_comments_record_created_idx',\n columns: ['tenantId', 'metaType', 'metaId', 'createdAt'],\n },\n {\n name: 'record_comments_parent_created_idx',\n columns: ['tenantId', 'parentCommentId', 'createdAt'],\n },\n {\n name: 'record_comments_moderation_idx',\n columns: ['tenantId', 'status', 'createdAt'],\n },\n ],\n})\nexport class Comment extends SmrtPolymorphicAssociation { static __smrtPackage__ = \"@happyvertical/smrt-comments\";\n @tenantId()\n tenantId = '';\n\n @crossPackageRef('@happyvertical/smrt-users:User', {\n required: true,\n requiredFor: 'identity',\n })\n authorUserId = '';\n\n @field({ required: true, requiredFor: 'idempotency' })\n body = '';\n\n /** JSON array of referenced User UUIDs; use mentionUserIds for validation. */\n mentions = '[]';\n\n /** Service-owned binding retained after generic runOnce claim retention. */\n @field({ type: 'text', nullable: true, readonly: true })\n idempotencyKey: string | null = null;\n\n /** Canonical retry namespace; never rewrites stored tenant/user references. */\n @field({ type: 'text', nullable: true, readonly: true })\n retryTenantId: string | null = null;\n\n /** Digest of the original authenticated author, parent and normalized payload. */\n @field({ type: 'text', nullable: true, readonly: true })\n requestDigest: string | null = null;\n\n /** A reply stays within this comment's already-authorized record thread. */\n // DuckDB cannot safely insert self-referential FKs; CommentService binds it.\n @foreignKey('Comment', { nullable: true, constraint: false })\n parentCommentId: string | null = null;\n\n /** Visible comments are public to the host's authorized record readers. */\n @field({ required: true })\n status: CommentStatus = 'visible';\n\n /** JSON retained from the host participation decision at post time. */\n @field({ type: 'text', nullable: true, readonly: true })\n participationSnapshot: string | null = null;\n\n @field({ type: 'datetime', nullable: true, readonly: true })\n editedAt: Date | null = null;\n\n constructor(options: CommentOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.authorUserId !== undefined)\n this.authorUserId = options.authorUserId;\n if (options.body !== undefined) this.body = options.body;\n if (options.idempotencyKey !== undefined)\n this.idempotencyKey = options.idempotencyKey;\n if (options.retryTenantId !== undefined)\n this.retryTenantId = options.retryTenantId;\n if (options.requestDigest !== undefined)\n this.requestDigest = options.requestDigest;\n if (options.parentCommentId !== undefined)\n this.parentCommentId = options.parentCommentId;\n if (options.status !== undefined) this.status = options.status;\n if (options.participationSnapshot !== undefined)\n this.participationSnapshot = options.participationSnapshot;\n const mentions = options.mentions as unknown;\n if (Array.isArray(mentions)) this.mentionUserIds = mentions;\n else if (typeof mentions === 'string') this.mentions = mentions;\n }\n\n get mentionUserIds(): string[] {\n try {\n const parsed: unknown = JSON.parse(this.mentions);\n return Array.isArray(parsed) &&\n parsed.every((value) => typeof value === 'string')\n ? parsed\n : [];\n } catch {\n return [];\n }\n }\n\n set mentionUserIds(value: readonly string[]) {\n const unique = [...new Set(value.map((id) => id.trim()).filter(Boolean))];\n if (unique.length > MAX_MENTIONS || unique.some((id) => !UUID.test(id))) {\n throw new TypeError(\n 'Comment mentions must contain at most 50 user UUIDs.',\n );\n }\n this.mentions = JSON.stringify(unique);\n }\n}\n","import { SmrtCollection } from '@happyvertical/smrt-core';\nimport {\n getCurrentTenant,\n TenantIsolationError,\n} from '@happyvertical/smrt-tenancy';\nimport { Comment } from '../models/Comment.js';\n\nexport class CommentCollection extends SmrtCollection<Comment> {\n static readonly _itemClass = Comment;\n\n async listForRecord(\n recordType: string,\n recordId: string,\n ): Promise<Comment[]> {\n const tenantId = getCurrentTenant()?.tenantId;\n if (!tenantId) {\n throw new TenantIsolationError(\n 'Record comments require a tenant context.',\n );\n }\n return this.list({\n where: { tenantId, metaType: recordType, metaId: recordId },\n orderBy: ['createdAt ASC'],\n });\n }\n}\n","import {\n crossPackageRef,\n field,\n foreignKey,\n SmrtObject,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/** A tenant-local report; moderation resolution never deletes the report. */\n@TenantScoped({ mode: 'required' })\n@smrt({\n tableName: 'comment_reports',\n api: false,\n mcp: false,\n cli: false,\n indexes: [\n {\n name: 'comment_reports_actor_target_unique',\n columns: ['tenantId', 'reporterUserId', 'commentId'],\n unique: true,\n },\n {\n name: 'comment_reports_queue_idx',\n columns: ['tenantId', 'status', 'createdAt'],\n },\n ],\n})\nexport class CommentReport extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-comments\";\n @tenantId()\n tenantId = '';\n\n // Reports outlive comment-state changes and must work on DuckDB.\n @foreignKey('Comment', {\n required: true,\n requiredFor: 'identity',\n constraint: false,\n })\n commentId = '';\n\n @crossPackageRef('@happyvertical/smrt-users:User', {\n required: true,\n requiredFor: 'identity',\n })\n reporterUserId = '';\n\n @field()\n reason = '';\n\n @field({ required: true })\n status: 'open' | 'resolved' | 'dismissed' = 'open';\n}\n","import { SmrtCollection } from '@happyvertical/smrt-core';\nimport { CommentReport } from '../models/CommentReport.js';\n\nexport class CommentReportCollection extends SmrtCollection<CommentReport> {\n static readonly _itemClass = CommentReport;\n}\n","import {\n crossPackageRef,\n field,\n foreignKey,\n SmrtObject,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/** Immutable prior body retained whenever an author edits a comment. */\n@TenantScoped({ mode: 'required' })\n@smrt({ tableName: 'comment_revisions', api: false, mcp: false, cli: false })\nexport class CommentRevision extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-comments\";\n @tenantId()\n tenantId = '';\n\n // Retained history is service-owned; keep cross-dialect schema portable.\n @foreignKey('Comment', {\n required: true,\n requiredFor: 'identity',\n constraint: false,\n })\n commentId = '';\n\n @crossPackageRef('@happyvertical/smrt-users:User', { nullable: true })\n editorUserId: string | null = null;\n\n @field({ required: true, requiredFor: 'idempotency' })\n body = '';\n}\n","import { SmrtCollection } from '@happyvertical/smrt-core';\nimport { CommentRevision } from '../models/CommentRevision.js';\n\nexport class CommentRevisionCollection extends SmrtCollection<CommentRevision> {\n static readonly _itemClass = CommentRevision;\n}\n","import { SmrtRecipe } from '@happyvertical/smrt-core';\nimport { Comment } from './models/Comment.js';\nimport { CommentReport } from './models/CommentReport.js';\nimport { CommentRevision } from './models/CommentRevision.js';\nimport { ParticipationBan } from './models/ParticipationBan.js';\nimport { ParticipationPolicy } from './models/ParticipationPolicy.js';\nimport { ParticipationRateBucket } from './models/ParticipationRateBucket.js';\n\n/** Discussion attached to any authorized business record. */\nexport class RecordCommentsRecipe extends SmrtRecipe {\n static id = 'comments.records';\n static label = 'Record comments';\n static summary = 'Discuss work directly on the records it concerns.';\n static synonyms = ['comments', 'mentions', 'discussion'];\n static group = {\n id: 'comments',\n label: 'Comments',\n summary: 'Keep discussions alongside the records your team works on.',\n };\n static models = [\n Comment,\n CommentRevision,\n CommentReport,\n ParticipationPolicy,\n ParticipationBan,\n ParticipationRateBucket,\n ];\n // Record discussions need an authorized parent record, not a global list.\n static nav = [];\n static runtime = 'both' as const;\n static surfaces = [\n {\n kind: 'playground',\n export: '@happyvertical/smrt-comments/svelte#RecordCommentsPlayground',\n label: 'Record discussion preview',\n },\n ] as const;\n static demoSeed = {\n export: '@happyvertical/smrt-comments/svelte#recordCommentsDemo',\n } as const;\n static help = './comments.records.recipe.md';\n}\n","import {\n digestRunOnceContent,\n ObjectRegistry,\n runOnce,\n type SmrtClassOptions,\n} from '@happyvertical/smrt-core';\nimport { withTenant } from '@happyvertical/smrt-tenancy';\nimport { CommentCollection } from '../collections/CommentCollection.js';\nimport { CommentReportCollection } from '../collections/CommentReportCollection.js';\nimport { CommentRevisionCollection } from '../collections/CommentRevisionCollection.js';\nimport { Comment } from '../models/Comment.js';\nimport type {\n ParticipationAuthorizer,\n ParticipationDecision,\n} from '../participation-contract.js';\nimport type {\n CommentActorContext,\n CommentMentionNotificationAdapter,\n CommentRecordAccess,\n CommentStatus,\n CreateCommentInput,\n} from '../types.js';\nimport { ParticipationService } from './ParticipationService.js';\n\n// Native UUID columns canonicalize case; identity and digests must agree with them.\nconst canonicalUuid = (value: string) =>\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value)\n ? value.toLowerCase()\n : value;\n\n/** A reused request differs, or its retained comment is no longer available. */\nexport class CommentIdempotencyError extends Error {\n constructor(\n readonly code: 'COMMENT_REQUEST_CONFLICT' | 'COMMENT_REQUEST_UNAVAILABLE',\n ) {\n super(\n code === 'COMMENT_REQUEST_CONFLICT'\n ? 'Comment request key already used with different content.'\n : 'Comment request no longer has a valid retained creation binding.',\n );\n this.name = 'CommentIdempotencyError';\n }\n}\n\nexport class CommentService {\n constructor(\n private readonly options: {\n db: SmrtClassOptions['db'];\n actor: CommentActorContext;\n authorizeRecord: (access: CommentRecordAccess) => Promise<boolean>;\n participation?: ParticipationAuthorizer;\n mentionNotifications?: CommentMentionNotificationAdapter;\n },\n ) {}\n\n private async authorize(\n recordType: string,\n recordId: string,\n action: 'read' | 'comment' | 'moderate',\n ) {\n const { actor } = this.options;\n if (\n !actor.tenantId ||\n !actor.userId ||\n !recordType ||\n !recordId ||\n !(await this.options.authorizeRecord({\n ...actor,\n recordType,\n recordId,\n action,\n }))\n ) {\n throw new Error('Comment record access denied.');\n }\n }\n\n private async getAuthorizedComment(\n commentId: string,\n action: 'read' | 'moderate',\n ) {\n const tenantId = this.options.actor.tenantId;\n const comment = await withTenant({ tenantId }, async () =>\n (await CommentCollection.create({ db: this.options.db })).get(commentId),\n );\n if (!comment || canonicalUuid(comment.tenantId) !== canonicalUuid(tenantId))\n throw new Error('Comment not found.');\n await this.authorize(comment.metaType, comment.metaId, action);\n return comment;\n }\n\n /** Edits retain the exact former body before changing the visible comment. */\n async edit(commentId: string, body: string): Promise<Comment> {\n if (!body.trim()) throw new TypeError('Comment body is required.');\n const comment = await this.getAuthorizedComment(commentId, 'read');\n if (\n canonicalUuid(comment.authorUserId) !==\n canonicalUuid(this.options.actor.userId)\n )\n throw new Error('Comment edit denied.');\n await this.authorize(comment.metaType, comment.metaId, 'comment');\n const tenantId = this.options.actor.tenantId;\n return withTenant({ tenantId }, async () => {\n const collection = await CommentCollection.create({\n db: this.options.db,\n });\n if (!collection.db.transaction)\n throw new Error('Comment edits require transactions.');\n return collection.db.transaction(async (tx) => {\n const scoped = await CommentCollection.create({ db: tx });\n // Acquire the row's write lock before reading the body retained as history.\n const table = `\"${scoped.tableName.replace(/\"/g, '\"\"')}\"`;\n await tx.query(\n `UPDATE ${table} SET body = body WHERE id = ? AND tenant_id = ?`,\n commentId,\n tenantId,\n );\n const current = await scoped.get(commentId);\n if (\n !current ||\n canonicalUuid(current.authorUserId) !==\n canonicalUuid(this.options.actor.userId)\n )\n throw new Error('Comment edit denied.');\n const participation = new ParticipationService({\n db: tx,\n entitlement: this.options.participation,\n });\n return participation.executeInTransaction(\n tx,\n {\n tenantId,\n actorUserId: this.options.actor.userId,\n action: 'comment',\n recordType: current.metaType,\n recordId: current.metaId,\n },\n async (guardedTx, decision) =>\n withTenant({ tenantId: current.tenantId }, async () => {\n const revisions = await CommentRevisionCollection.create({\n db: guardedTx,\n });\n await revisions.create({\n tenantId: current.tenantId,\n commentId,\n editorUserId: this.options.actor.userId,\n body: current.body,\n });\n if (\n current.status === 'visible' &&\n decision.initialCommentStatus === 'pending'\n ) {\n current.status = 'pending';\n }\n current.body = body;\n current.editedAt = new Date();\n await current.save();\n return current;\n }),\n );\n });\n });\n }\n\n /** A moderator may make a row visible, hidden, pending, or deleted. */\n async moderate(commentId: string, status: CommentStatus): Promise<Comment> {\n const comment = await this.getAuthorizedComment(commentId, 'moderate');\n if (!['visible', 'hidden', 'pending', 'deleted'].includes(status))\n throw new TypeError('Invalid comment moderation status.');\n return withTenant({ tenantId: comment.tenantId }, async () => {\n const collection = await CommentCollection.create({\n db: this.options.db,\n });\n if (!collection.db.transaction)\n throw new Error('Comment moderation requires transactions.');\n return collection.db.transaction(async (tx) => {\n const scoped = await CommentCollection.create({ db: tx });\n const table = `\"${scoped.tableName.replace(/\"/g, '\"\"')}\"`;\n // Reload after locking so the save lifecycle cannot clobber a concurrent edit.\n await tx.query(\n `UPDATE ${table} SET body = body WHERE id = ? AND tenant_id = ?`,\n commentId,\n comment.tenantId,\n );\n const current = await scoped.get(commentId);\n if (!current) throw new Error('Comment not found.');\n current.status = status;\n await current.save();\n return current;\n });\n });\n }\n\n /** One retained report per actor/comment; new reports consume shared report quota. */\n async report(commentId: string, reason: string) {\n if (!reason.trim())\n throw new TypeError('Comment report reason is required.');\n const comment = await this.getAuthorizedComment(commentId, 'read');\n if (comment.status !== 'visible')\n throw new Error('Comment is not reportable.');\n commentId = canonicalUuid(comment.id ?? commentId);\n const tenantId = canonicalUuid(this.options.actor.tenantId);\n const reporterUserId = canonicalUuid(this.options.actor.userId);\n const request = {\n tenantId,\n actorUserId: reporterUserId,\n action: 'report' as const,\n recordType: comment.metaType,\n recordId: comment.metaId,\n };\n const guard = new ParticipationService({\n db: this.options.db,\n entitlement: this.options.participation,\n });\n await guard.authorize(request);\n return withTenant({ tenantId }, async () => {\n const reports = await CommentReportCollection.create({\n db: this.options.db,\n });\n const id = await runOnce(\n {\n db: reports.db,\n tenantId,\n actor: 'smrt-comments.report:v1',\n token: `${reporterUserId}:${canonicalUuid(commentId)}`,\n content: 'retained-report:v1',\n },\n async (tx) => {\n const scoped = await CommentReportCollection.create({ db: tx });\n const existing = await scoped.list({\n where: { tenantId, reporterUserId, commentId },\n });\n if (existing[0]) return existing[0].id;\n return guard.executeInTransaction(tx, request, async (guardedTx) => {\n const current = await withTenant(\n { tenantId: comment.tenantId },\n async () =>\n (await CommentCollection.create({ db: guardedTx })).get(\n commentId,\n ),\n );\n if (!current || current.status !== 'visible')\n throw new Error('Comment is not reportable.');\n return (\n await (\n await CommentReportCollection.create({ db: guardedTx })\n ).create({\n tenantId,\n commentId,\n reporterUserId,\n reason: reason.trim(),\n status: 'open',\n })\n ).id;\n });\n },\n );\n const report = id ? await reports.get(id) : null;\n if (\n !report ||\n report.commentId !== canonicalUuid(commentId) ||\n report.reporterUserId !== reporterUserId\n )\n throw new Error('Retained report unavailable.');\n return report;\n });\n }\n\n async listForRecord(\n recordType: string,\n recordId: string,\n ): Promise<Comment[]> {\n await this.authorize(recordType, recordId, 'read');\n const tenantId = this.options.actor.tenantId;\n const binding = canonicalUuid(tenantId);\n const rows = await withTenant({ tenantId }, async () =>\n (await CommentCollection.create({ db: this.options.db })).listForRecord(\n recordType,\n recordId,\n ),\n );\n const collection = await withTenant({ tenantId }, () =>\n CommentCollection.create({ db: this.options.db }),\n );\n // The canonical retry namespace is separate from legacy reference spelling.\n // This query is tenant/parent-bound before any scoped hydration.\n const bound = await collection.db.query(\n `SELECT CAST(id AS TEXT) AS id, CAST(tenant_id AS TEXT) AS tenant_id FROM \"${collection.tableName.replace(/\"/g, '\"\"')}\" WHERE retry_tenant_id = ? AND meta_type = ? AND meta_id = ? AND idempotency_key IS NOT NULL`,\n binding,\n recordType,\n recordId,\n );\n for (const stored of bound.rows) {\n const row = await this.loadBoundComment(collection.db, stored, binding);\n if (row.metaType !== recordType || row.metaId !== recordId) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n rows.push(row);\n }\n for (const row of rows) {\n if (row.idempotencyKey !== null && row.retryTenantId !== binding) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n }\n return [...new Map(rows.map((row) => [row.id, row])).values()].sort(\n (a, b) =>\n (a.created_at?.getTime() ?? 0) - (b.created_at?.getTime() ?? 0) ||\n (a.id ?? '').localeCompare(b.id ?? ''),\n );\n }\n\n private async loadBoundComment(\n db: CommentCollection['db'],\n stored: { [key: string]: unknown },\n binding: string,\n ): Promise<Comment> {\n const id = stored.id;\n const tenantId = stored.tenant_id;\n if (\n typeof id !== 'string' ||\n typeof tenantId !== 'string' ||\n canonicalUuid(tenantId) !== binding\n ) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n // This is the original spelling of the same authorized tenant, not a bypass.\n const row = await withTenant({ tenantId }, async () =>\n (await CommentCollection.create({ db })).get(id),\n );\n if (\n !row ||\n canonicalUuid(row.tenantId) !== binding ||\n row.retryTenantId !== binding ||\n row.idempotencyKey === null\n ) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n return row;\n }\n\n async create(commentOptions: CreateCommentInput): Promise<Comment> {\n const {\n tenantId: inputTenantId,\n authorUserId: inputAuthorUserId,\n metaType,\n metaId,\n body,\n mentions,\n idempotencyKey,\n parentCommentId: inputParentCommentId,\n } = commentOptions;\n const parentCommentId = inputParentCommentId\n ? canonicalUuid(inputParentCommentId)\n : inputParentCommentId;\n if (!inputTenantId || !inputAuthorUserId) {\n throw new TypeError('Comments require a tenant and author.');\n }\n if (\n canonicalUuid(inputTenantId) !==\n canonicalUuid(this.options.actor.tenantId) ||\n canonicalUuid(inputAuthorUserId) !==\n canonicalUuid(this.options.actor.userId)\n ) {\n throw new Error('Comment actor context mismatch.');\n }\n // Preserve the trusted context's stored spelling on text-backed databases.\n const tenantId = this.options.actor.tenantId;\n const authorUserId = this.options.actor.userId;\n await this.authorize(metaType ?? '', metaId ?? '', 'comment');\n const participationRequest = {\n tenantId,\n actorUserId: authorUserId,\n action: 'comment' as const,\n recordType: metaType ?? '',\n recordId: metaId ?? '',\n };\n await new ParticipationService({\n db: this.options.db,\n entitlement: this.options.participation,\n }).authorize(participationRequest);\n if (!body?.trim()) throw new TypeError('Comment body is required.');\n // Validate through the model's public setter before collection.create()\n // persists. Supply its normalized JSON in that single insert.\n const prepared = new (ObjectRegistry.resolveEffectiveConstructor(\n Comment,\n ))();\n if (mentions !== undefined) prepared.mentionUserIds = mentions;\n if (\n idempotencyKey !== undefined &&\n (typeof idempotencyKey !== 'string' ||\n !idempotencyKey.trim() ||\n idempotencyKey !== idempotencyKey.trim() ||\n idempotencyKey.length > 200)\n ) {\n throw new TypeError(\n 'Comment idempotencyKey must be a nonempty trimmed string of at most 200 characters.',\n );\n }\n const normalizedMentions = [...prepared.mentionUserIds].sort();\n const requestDigest = digestRunOnceContent({\n tenantId: canonicalUuid(tenantId),\n authorUserId: canonicalUuid(authorUserId),\n metaType,\n metaId,\n body,\n mentions: normalizedMentions,\n ...(parentCommentId ? { parentCommentId } : {}),\n });\n const comment = await withTenant({ tenantId }, async () => {\n const collection = await CommentCollection.create({\n db: this.options.db,\n });\n const insert = async (\n target: CommentCollection,\n inTransaction = false,\n ) => {\n const guard = new ParticipationService({\n db: target.db,\n entitlement: this.options.participation,\n });\n const work = async (\n tx: CommentCollection['db'],\n participation: ParticipationDecision,\n ) =>\n withTenant({ tenantId }, async () => {\n target = await CommentCollection.create({ db: tx });\n if (parentCommentId) {\n const parent = await target.get(parentCommentId);\n if (\n !parent ||\n canonicalUuid(parent.tenantId) !== canonicalUuid(tenantId) ||\n parent.metaType !== metaType ||\n parent.metaId !== metaId\n ) {\n throw new Error(\n 'Comment parent does not belong to this record.',\n );\n }\n }\n const id = crypto.randomUUID();\n return target.create({\n tenantId,\n authorUserId,\n metaType,\n metaId,\n body,\n id,\n slug: id,\n context: '',\n _insertOnly: true,\n mentions: prepared.mentions,\n idempotencyKey: idempotencyKey ?? null,\n requestDigest:\n idempotencyKey === undefined ? null : requestDigest,\n retryTenantId:\n idempotencyKey === undefined ? null : canonicalUuid(tenantId),\n parentCommentId: parentCommentId ?? null,\n status: participation.initialCommentStatus ?? 'visible',\n participationSnapshot: participation.snapshot\n ? JSON.stringify(participation.snapshot)\n : null,\n });\n });\n return inTransaction\n ? guard.executeInTransaction(target.db, participationRequest, work)\n : guard.execute(participationRequest, work);\n };\n if (idempotencyKey === undefined) return insert(collection);\n // The internal actor is an arbitration namespace, NOT the authenticated\n // author. All authors sharing a tenant/key must contend on the same claim.\n // Actual author and payload are bound by the independently checked digest.\n const receipt = await runOnce(\n {\n db: collection.db,\n tenantId: canonicalUuid(tenantId),\n actor: 'smrt-comments.create:v1',\n token: idempotencyKey,\n content: 'comment-request-binding:v1',\n },\n async (tx) => {\n const scoped = await CommentCollection.create({ db: tx });\n const matches = await tx.query(\n `SELECT CAST(id AS TEXT) AS id, CAST(tenant_id AS TEXT) AS tenant_id FROM \"${scoped.tableName.replace(/\"/g, '\"\"')}\" WHERE retry_tenant_id = ? AND idempotency_key = ?`,\n canonicalUuid(tenantId),\n idempotencyKey,\n );\n if (matches.rows.length > 1) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n const row = matches.rows[0]\n ? await this.loadBoundComment(\n tx,\n matches.rows[0],\n canonicalUuid(tenantId),\n )\n : await insert(scoped, true);\n return {\n id: row.id,\n digest: row.requestDigest,\n tenant_id: row.tenantId,\n };\n },\n );\n if (receipt.digest !== requestDigest)\n throw new CommentIdempotencyError('COMMENT_REQUEST_CONFLICT');\n const row = await this.loadBoundComment(\n collection.db,\n receipt,\n canonicalUuid(tenantId),\n );\n const retainedBodies = row.editedAt\n ? await withTenant({ tenantId: row.tenantId }, async () =>\n (\n await (\n await CommentRevisionCollection.create({ db: collection.db })\n ).list({\n where: { commentId: row.id, tenantId: row.tenantId },\n })\n ).map((revision) => revision.body),\n )\n : [row.body];\n if (\n canonicalUuid(row.tenantId) !== canonicalUuid(tenantId) ||\n row.idempotencyKey !== idempotencyKey ||\n row.requestDigest !== requestDigest ||\n !retainedBodies.some(\n (retainedBody) =>\n digestRunOnceContent({\n tenantId: canonicalUuid(row.tenantId),\n authorUserId: canonicalUuid(row.authorUserId),\n metaType: row.metaType,\n metaId: row.metaId,\n body: retainedBody,\n mentions: [...row.mentionUserIds].sort(),\n ...(row.parentCommentId\n ? { parentCommentId: canonicalUuid(row.parentCommentId) }\n : {}),\n }) === requestDigest,\n )\n ) {\n throw new CommentIdempotencyError('COMMENT_REQUEST_UNAVAILABLE');\n }\n return row;\n });\n if (\n !this.options.mentionNotifications ||\n !comment.id ||\n comment.status !== 'visible'\n )\n return comment;\n for (const recipientUserId of comment.mentionUserIds) {\n if (\n canonicalUuid(recipientUserId) === canonicalUuid(comment.authorUserId)\n )\n continue;\n await this.options.mentionNotifications.notifyMention({\n commentId: comment.id,\n tenantId: comment.tenantId,\n authorUserId: comment.authorUserId,\n recipientUserId,\n recordType: comment.metaType,\n recordId: comment.metaId,\n body: comment.body,\n });\n }\n return comment;\n }\n}\n","import type {\n CommentMention,\n CommentMentionNotificationAdapter,\n} from '../types.js';\n\n/** Structural subset implemented by smrt-messages UserNotificationService. */\nexport interface CommentNotificationService {\n notify(input: {\n tenantId: string;\n recipientUserId: string;\n kind: string;\n title: string;\n body: string;\n sourceRef: string;\n }): Promise<unknown>;\n}\n\n/** Hosts must check recipient membership AND access to the referenced record. */\nexport function createCommentMentionNotifications(options: {\n notifications: CommentNotificationService;\n canNotify: (mention: CommentMention) => Promise<boolean>;\n}): CommentMentionNotificationAdapter {\n return {\n async notifyMention(mention) {\n if (!(await options.canNotify(mention))) return;\n await options.notifications.notify({\n tenantId: mention.tenantId,\n recipientUserId: mention.recipientUserId,\n kind: 'comments.mention',\n title: 'You were mentioned in a comment',\n body: mention.body,\n sourceRef: `comments.mention:${mention.commentId}`,\n });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,IAAM,eAAe;AACrB,IA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