@happyvertical/smrt-reactions 0.60.9 → 0.60.10

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.
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-reactions",
5
- "packageVersion": "0.60.9",
5
+ "packageVersion": "0.60.10",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-reactions:ReactionCollection": {
8
8
  "name": "reactioncollection",
@@ -31,8 +31,14 @@
31
31
  ],
32
32
  "schema": {
33
33
  "tableName": "record_reactions",
34
- "ddl": "CREATE TABLE IF NOT EXISTS \"record_reactions\" (\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 \"actor_profile_id\" UUID NOT NULL,\n \"kind\" TEXT NOT NULL DEFAULT 'like'\n);",
34
+ "ddl": "CREATE TABLE IF NOT EXISTS \"record_reactions\" (\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 \"actor_profile_id\" UUID NOT NULL,\n \"kind\" TEXT NOT NULL DEFAULT 'like'\n);",
35
35
  "columns": {
36
+ "_sync_origin_device_id": {
37
+ "type": "TEXT"
38
+ },
39
+ "_sync_revision": {
40
+ "type": "INTEGER"
41
+ },
36
42
  "id": {
37
43
  "type": "UUID",
38
44
  "primaryKey": true,
@@ -140,7 +146,7 @@
140
146
  ]
141
147
  }
142
148
  ],
143
- "version": "678ebe0f"
149
+ "version": "6beb1d23"
144
150
  },
145
151
  "importPath": "@happyvertical/smrt-reactions"
146
152
  },
@@ -171,8 +177,14 @@
171
177
  ],
172
178
  "schema": {
173
179
  "tableName": "record_polls",
174
- "ddl": "CREATE TABLE IF NOT EXISTS \"record_polls\" (\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 \"question\" TEXT NOT NULL,\n \"options_json\" TEXT,\n \"opens_at\" TIMESTAMP,\n \"closes_at\" TIMESTAMP,\n \"visibility\" TEXT DEFAULT 'always',\n \"one_vote_per_actor\" BOOLEAN NOT NULL DEFAULT TRUE,\n \"anonymous_tally\" BOOLEAN NOT NULL DEFAULT TRUE,\n \"closed\" BOOLEAN NOT NULL DEFAULT FALSE\n);",
180
+ "ddl": "CREATE TABLE IF NOT EXISTS \"record_polls\" (\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 \"question\" TEXT NOT NULL,\n \"options_json\" TEXT,\n \"opens_at\" TIMESTAMP,\n \"closes_at\" TIMESTAMP,\n \"visibility\" TEXT DEFAULT 'always',\n \"one_vote_per_actor\" BOOLEAN NOT NULL DEFAULT TRUE,\n \"anonymous_tally\" BOOLEAN NOT NULL DEFAULT TRUE,\n \"closed\" BOOLEAN NOT NULL DEFAULT FALSE\n);",
175
181
  "columns": {
182
+ "_sync_origin_device_id": {
183
+ "type": "TEXT"
184
+ },
185
+ "_sync_revision": {
186
+ "type": "INTEGER"
187
+ },
176
188
  "id": {
177
189
  "type": "UUID",
178
190
  "primaryKey": true,
@@ -303,7 +315,7 @@
303
315
  ]
304
316
  }
305
317
  ],
306
- "version": "f6713370"
318
+ "version": "65fbd5b2"
307
319
  },
308
320
  "importPath": "@happyvertical/smrt-reactions"
309
321
  },
@@ -334,8 +346,14 @@
334
346
  ],
335
347
  "schema": {
336
348
  "tableName": "poll_votes",
337
- "ddl": "CREATE TABLE IF NOT EXISTS \"poll_votes\" (\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 \"poll_id\" UUID NOT NULL,\n \"actor_profile_id\" UUID NOT NULL,\n \"option_id\" TEXT NOT NULL,\n \"participation_snapshot\" TEXT NOT NULL\n);",
349
+ "ddl": "CREATE TABLE IF NOT EXISTS \"poll_votes\" (\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 \"poll_id\" UUID NOT NULL,\n \"actor_profile_id\" UUID NOT NULL,\n \"option_id\" TEXT NOT NULL,\n \"participation_snapshot\" TEXT NOT NULL\n);",
338
350
  "columns": {
351
+ "_sync_origin_device_id": {
352
+ "type": "TEXT"
353
+ },
354
+ "_sync_revision": {
355
+ "type": "INTEGER"
356
+ },
339
357
  "id": {
340
358
  "type": "UUID",
341
359
  "primaryKey": true,
@@ -435,7 +453,7 @@
435
453
  ]
436
454
  }
437
455
  ],
438
- "version": "c22797d0"
456
+ "version": "9d5339f2"
439
457
  },
440
458
  "importPath": "@happyvertical/smrt-reactions"
441
459
  },
@@ -632,8 +650,14 @@
632
650
  ],
633
651
  "schema": {
634
652
  "tableName": "record_polls",
635
- "ddl": "CREATE TABLE IF NOT EXISTS \"record_polls\" (\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 \"question\" TEXT NOT NULL,\n \"options_json\" TEXT,\n \"opens_at\" TIMESTAMP,\n \"closes_at\" TIMESTAMP,\n \"visibility\" TEXT DEFAULT 'always',\n \"one_vote_per_actor\" BOOLEAN NOT NULL DEFAULT TRUE,\n \"anonymous_tally\" BOOLEAN NOT NULL DEFAULT TRUE,\n \"closed\" BOOLEAN NOT NULL DEFAULT FALSE\n);",
653
+ "ddl": "CREATE TABLE IF NOT EXISTS \"record_polls\" (\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 \"question\" TEXT NOT NULL,\n \"options_json\" TEXT,\n \"opens_at\" TIMESTAMP,\n \"closes_at\" TIMESTAMP,\n \"visibility\" TEXT DEFAULT 'always',\n \"one_vote_per_actor\" BOOLEAN NOT NULL DEFAULT TRUE,\n \"anonymous_tally\" BOOLEAN NOT NULL DEFAULT TRUE,\n \"closed\" BOOLEAN NOT NULL DEFAULT FALSE\n);",
636
654
  "columns": {
655
+ "_sync_origin_device_id": {
656
+ "type": "TEXT"
657
+ },
658
+ "_sync_revision": {
659
+ "type": "INTEGER"
660
+ },
637
661
  "id": {
638
662
  "type": "UUID",
639
663
  "primaryKey": true,
@@ -764,7 +788,7 @@
764
788
  ]
765
789
  }
766
790
  ],
767
- "version": "f6713370"
791
+ "version": "65fbd5b2"
768
792
  },
769
793
  "importPath": "@happyvertical/smrt-reactions"
770
794
  },
@@ -893,8 +917,14 @@
893
917
  ],
894
918
  "schema": {
895
919
  "tableName": "poll_votes",
896
- "ddl": "CREATE TABLE IF NOT EXISTS \"poll_votes\" (\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 \"poll_id\" UUID NOT NULL,\n \"actor_profile_id\" UUID NOT NULL,\n \"option_id\" TEXT NOT NULL,\n \"participation_snapshot\" TEXT NOT NULL\n);",
920
+ "ddl": "CREATE TABLE IF NOT EXISTS \"poll_votes\" (\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 \"poll_id\" UUID NOT NULL,\n \"actor_profile_id\" UUID NOT NULL,\n \"option_id\" TEXT NOT NULL,\n \"participation_snapshot\" TEXT NOT NULL\n);",
897
921
  "columns": {
922
+ "_sync_origin_device_id": {
923
+ "type": "TEXT"
924
+ },
925
+ "_sync_revision": {
926
+ "type": "INTEGER"
927
+ },
898
928
  "id": {
899
929
  "type": "UUID",
900
930
  "primaryKey": true,
@@ -994,7 +1024,7 @@
994
1024
  ]
995
1025
  }
996
1026
  ],
997
- "version": "c22797d0"
1027
+ "version": "9d5339f2"
998
1028
  },
999
1029
  "importPath": "@happyvertical/smrt-reactions"
1000
1030
  },
@@ -1150,8 +1180,14 @@
1150
1180
  ],
1151
1181
  "schema": {
1152
1182
  "tableName": "record_reactions",
1153
- "ddl": "CREATE TABLE IF NOT EXISTS \"record_reactions\" (\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 \"actor_profile_id\" UUID NOT NULL,\n \"kind\" TEXT NOT NULL DEFAULT 'like'\n);",
1183
+ "ddl": "CREATE TABLE IF NOT EXISTS \"record_reactions\" (\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 \"actor_profile_id\" UUID NOT NULL,\n \"kind\" TEXT NOT NULL DEFAULT 'like'\n);",
1154
1184
  "columns": {
1185
+ "_sync_origin_device_id": {
1186
+ "type": "TEXT"
1187
+ },
1188
+ "_sync_revision": {
1189
+ "type": "INTEGER"
1190
+ },
1155
1191
  "id": {
1156
1192
  "type": "UUID",
1157
1193
  "primaryKey": true,
@@ -1259,7 +1295,7 @@
1259
1295
  ]
1260
1296
  }
1261
1297
  ],
1262
- "version": "678ebe0f"
1298
+ "version": "6beb1d23"
1263
1299
  },
1264
1300
  "importPath": "@happyvertical/smrt-reactions"
1265
1301
  }
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as PollVote, i as Reaction, n as PollVoteCollection, o as Poll, r as ReactionCollection, s as withParticipationWrite, t as PollCollection } from "./chunks/src-C0jSZD4x.js";
1
+ import { a as PollVote, i as Reaction, n as PollVoteCollection, o as Poll, r as ReactionCollection, s as withParticipationWrite, t as PollCollection } from "./chunks/src-mr25j3zs.js";
2
2
  import { REACTION_KINDS } from "./types.js";
3
3
  import { ObjectRegistry } from "@happyvertical/smrt-core";
4
4
  import { withTenant } from "@happyvertical/smrt-tenancy";
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-reactions",
6
- "packageVersion": "0.60.9",
6
+ "packageVersion": "0.60.10",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "043d540cc840cb827a6c342eb63b122690a417f63707a6827876e3a82ac108c1",
11
- "packageJson": "c2a73699208ccfd6ac69f6f176c7c762fa598faca824428516b423d2ec3122b3",
10
+ "manifest": "0e4178cb47cd17ef6af7bf880f5a4b00e9221d2f7ff53e02e7372aa512ea932b",
11
+ "packageJson": "4ef3861eb9ca250979f7e511047f8b07ac06f3d75590b9c1f1d3bbaca93f0705",
12
12
  "agents": "c19832881616c1b4a422da22a888b71dfdeb4eea25974c30c6209f9d8c2242aa"
13
13
  },
14
14
  "exports": [
@@ -0,0 +1,60 @@
1
+ ---
2
+ type: "Component"
3
+ title: "@happyvertical/smrt-reactions"
4
+ description: "Tenant-scoped reactions and lightweight polls with shared participation enforcement"
5
+ status: "stable"
6
+ generated:
7
+ by: "smrt/scripts/generate-knowledge-okf.ts"
8
+ at: "2026-11-05T15:48:19Z"
9
+ audience: "internal"
10
+ evidence_level: "source-inspected"
11
+ source_revision: "sha256:6a2cfcba071d8e3d9b95655edac1b6190122f94d55f24b87df53680ffa7e783b"
12
+ sources:
13
+ - id: "manifest"
14
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/reactions/package.json"
15
+ title: "@happyvertical/smrt-reactions package manifest"
16
+ - id: "agents"
17
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/reactions/AGENTS.md"
18
+ title: "@happyvertical/smrt-reactions packages/reactions/AGENTS.md"
19
+ ---
20
+
21
+ # @happyvertical/smrt-reactions
22
+
23
+ ## Package
24
+
25
+ - Directory: `packages/reactions`
26
+ - Private: no
27
+ - Object source: `domain-artifact`
28
+ - Evidence level: `source-inspected`
29
+
30
+ ## Documentation
31
+
32
+ - `packages/reactions/AGENTS.md`
33
+
34
+ ## Framework dependencies
35
+
36
+ - [smrt-comments](/components/smrt-comments.md)
37
+ - [smrt-core](/components/smrt-core.md)
38
+ - [smrt-tenancy](/components/smrt-tenancy.md)
39
+ - [smrt-vitest](/components/smrt-vitest.md)
40
+
41
+ ## SDK dependencies
42
+
43
+ - `@happyvertical/sql`
44
+
45
+ ## Exports
46
+
47
+ - `.`
48
+ - `./manifest`
49
+ - `./manifest.json`
50
+ - `./server`
51
+ - `./svelte`
52
+
53
+ ## Models
54
+
55
+ - `Poll` (collection `polls`, extends `SmrtPolymorphicAssociation`)
56
+ - `PollCollection` (collection `polls`, extends `SmrtCollection`)
57
+ - `PollVote` (collection `pollvotes`, extends `SmrtObject`)
58
+ - `PollVoteCollection` (collection `pollvotes`, extends `SmrtCollection`)
59
+ - `Reaction` (collection `reactions`, extends `SmrtPolymorphicAssociation`)
60
+ - `ReactionCollection` (collection `reactions`, extends `SmrtCollection`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-reactions",
3
- "version": "0.60.9",
3
+ "version": "0.60.10",
4
4
  "description": "Tenant-scoped reactions and lightweight polls with shared participation enforcement",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,10 +28,10 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@happyvertical/smrt-core": "0.60.9",
32
- "@happyvertical/smrt-tenancy": "0.60.9",
33
- "@happyvertical/smrt-comments": "0.60.9",
34
- "@happyvertical/sql": "^0.111.3"
31
+ "@happyvertical/smrt-core": "0.60.10",
32
+ "@happyvertical/smrt-tenancy": "0.60.10",
33
+ "@happyvertical/smrt-comments": "0.60.10",
34
+ "@happyvertical/sql": "^0.111.5"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "svelte": "^5.57.0"
@@ -49,7 +49,7 @@
49
49
  "directory": "packages/reactions"
50
50
  },
51
51
  "devDependencies": {
52
- "@happyvertical/smrt-vitest": "0.60.9",
52
+ "@happyvertical/smrt-vitest": "0.60.10",
53
53
  "@sveltejs/package": "^2.5.8",
54
54
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
55
55
  "@testing-library/svelte": "^5.4.2",
@@ -1,263 +0,0 @@
1
- import { ObjectRegistry, SmrtCollection, SmrtObject, SmrtPolymorphicAssociation, ValidationError, crossPackageRef, field, foreignKey, smrt } from "@happyvertical/smrt-core";
2
- import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy";
3
- //#region src/__smrt-register__.ts
4
- ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-reactions","packageVersion":"0.60.9","objects":{"@happyvertical/smrt-reactions:ReactionCollection":{"name":"reactioncollection","className":"ReactionCollection","qualifiedName":"@happyvertical/smrt-reactions:ReactionCollection","collection":"reactions","filePath":"/home/runner/work/smrt/smrt/packages/reactions/src/collections/index.ts","packageName":"@happyvertical/smrt-reactions","fields":{},"methods":{},"decoratorConfig":{"tableName":"record_reactions","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"Reaction","exportName":"ReactionCollection","collectionExportName":"ReactionCollectionCollection","collectionOf":"@happyvertical/smrt-reactions:Reaction","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"record_reactions","ddl":"CREATE TABLE IF NOT EXISTS \\"record_reactions\\" (\\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 \\"actor_profile_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT NOT NULL DEFAULT 'like'\\n);","columns":{"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},"actor_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":true,"unique":false,"default":"like"}},"indexes":[{"name":"record_reactions_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"record_reactions_actor_kind","columns":["tenant_id","meta_type","meta_id","actor_profile_id","kind"],"unique":true},{"name":"record_reactions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"record_reactions_meta_type_meta_id_idx","columns":["meta_type","meta_id"]},{"name":"record_reactions_actor_profile_id_idx","columns":["actor_profile_id"]}],"version":"678ebe0f"},"importPath":"@happyvertical/smrt-reactions"},"@happyvertical/smrt-reactions:PollCollection":{"name":"pollcollection","className":"PollCollection","qualifiedName":"@happyvertical/smrt-reactions:PollCollection","collection":"polls","filePath":"/home/runner/work/smrt/smrt/packages/reactions/src/collections/index.ts","packageName":"@happyvertical/smrt-reactions","fields":{},"methods":{},"decoratorConfig":{"tableName":"record_polls","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"Poll","exportName":"PollCollection","collectionExportName":"PollCollectionCollection","collectionOf":"@happyvertical/smrt-reactions:Poll","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"record_polls","ddl":"CREATE TABLE IF NOT EXISTS \\"record_polls\\" (\\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 \\"question\\" TEXT NOT NULL,\\n \\"options_json\\" TEXT,\\n \\"opens_at\\" TIMESTAMP,\\n \\"closes_at\\" TIMESTAMP,\\n \\"visibility\\" TEXT DEFAULT 'always',\\n \\"one_vote_per_actor\\" BOOLEAN NOT NULL DEFAULT TRUE,\\n \\"anonymous_tally\\" BOOLEAN NOT NULL DEFAULT TRUE,\\n \\"closed\\" BOOLEAN NOT NULL DEFAULT FALSE\\n);","columns":{"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},"question":{"type":"TEXT","notNull":true,"unique":false},"options_json":{"type":"TEXT","notNull":false,"unique":false},"opens_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"closes_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"visibility":{"type":"TEXT","notNull":false,"unique":false,"default":"always"},"one_vote_per_actor":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true},"anonymous_tally":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true},"closed":{"type":"BOOLEAN","notNull":true,"unique":false,"default":false}},"indexes":[{"name":"record_polls_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"record_polls_target","columns":["tenant_id","meta_type","meta_id"]},{"name":"record_polls_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"record_polls_meta_type_meta_id_idx","columns":["meta_type","meta_id"]}],"version":"f6713370"},"importPath":"@happyvertical/smrt-reactions"},"@happyvertical/smrt-reactions:PollVoteCollection":{"name":"pollvotecollection","className":"PollVoteCollection","qualifiedName":"@happyvertical/smrt-reactions:PollVoteCollection","collection":"pollvotes","filePath":"/home/runner/work/smrt/smrt/packages/reactions/src/collections/index.ts","packageName":"@happyvertical/smrt-reactions","fields":{},"methods":{},"decoratorConfig":{"tableName":"poll_votes","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"PollVote","exportName":"PollVoteCollection","collectionExportName":"PollVoteCollectionCollection","collectionOf":"@happyvertical/smrt-reactions:PollVote","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"poll_votes","ddl":"CREATE TABLE IF NOT EXISTS \\"poll_votes\\" (\\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 \\"poll_id\\" UUID NOT NULL,\\n \\"actor_profile_id\\" UUID NOT NULL,\\n \\"option_id\\" TEXT NOT NULL,\\n \\"participation_snapshot\\" TEXT NOT NULL\\n);","columns":{"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},"poll_id":{"type":"UUID","referenceKind":"foreignKey","notNull":true,"unique":false,"foreignKey":{"table":"record_polls","column":"id","onDelete":"NO ACTION","onUpdate":"NO ACTION"}},"actor_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"option_id":{"type":"TEXT","notNull":true,"unique":false},"participation_snapshot":{"type":"TEXT","notNull":true,"unique":false}},"indexes":[{"name":"poll_votes_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"poll_votes_actor","columns":["tenant_id","poll_id","actor_profile_id"],"unique":true},{"name":"poll_votes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"poll_votes_poll_id_idx","columns":["poll_id"]},{"name":"poll_votes_actor_profile_id_idx","columns":["actor_profile_id"]}],"version":"c22797d0"},"importPath":"@happyvertical/smrt-reactions"},"@happyvertical/smrt-reactions:Poll":{"name":"poll","className":"Poll","qualifiedName":"@happyvertical/smrt-reactions:Poll","collection":"polls","filePath":"/home/runner/work/smrt/smrt/packages/reactions/src/models/Poll.ts","packageName":"@happyvertical/smrt-reactions","fields":{"metaType":{"type":"text","required":true,"_meta":{"required":true}},"metaId":{"type":"text","required":true,"_meta":{"required":true}},"role":{"type":"text","required":true,"_meta":{"required":true}},"sortOrder":{"type":"integer","required":false,"default":0},"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"question":{"type":"text","required":true,"_meta":{"required":true}},"optionsJson":{"type":"text","required":false,"_meta":{"readonly":true},"readonly":true},"opensAt":{"type":"datetime","required":false,"_meta":{"nullable":true}},"closesAt":{"type":"datetime","required":false,"_meta":{"nullable":true}},"visibility":{"type":"text","required":false,"default":"always","enum":["always","after_vote","after_close"]},"oneVotePerActor":{"type":"boolean","required":true,"default":true},"anonymousTally":{"type":"boolean","required":true,"default":true},"closed":{"type":"boolean","required":true,"default":false}},"methods":{"hydrate":{"name":"hydrate","async":true,"parameters":[],"returnType":"Promise<T | null>","isStatic":false,"isPublic":true},"assertWriteAuthority":{"name":"assertWriteAuthority","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"record_polls","api":false,"mcp":false,"cli":false,"hooks":{"beforeDelete":"assertWriteAuthority"},"indexes":[{"name":"record_polls_target","columns":["tenantId","metaType","metaId"]}],"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtPolymorphicAssociation","exportName":"Poll","collectionExportName":"PollCollection","validationRules":[{"field":"metaType","rule":"required","fieldType":"text"},{"field":"metaId","rule":"required","fieldType":"text"},{"field":"role","rule":"required","fieldType":"text"},{"field":"question","rule":"required","fieldType":"text"},{"field":"oneVotePerActor","rule":"required","fieldType":"boolean"},{"field":"anonymousTally","rule":"required","fieldType":"boolean"},{"field":"closed","rule":"required","fieldType":"boolean"}],"schema":{"tableName":"record_polls","ddl":"CREATE TABLE IF NOT EXISTS \\"record_polls\\" (\\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 \\"question\\" TEXT NOT NULL,\\n \\"options_json\\" TEXT,\\n \\"opens_at\\" TIMESTAMP,\\n \\"closes_at\\" TIMESTAMP,\\n \\"visibility\\" TEXT DEFAULT 'always',\\n \\"one_vote_per_actor\\" BOOLEAN NOT NULL DEFAULT TRUE,\\n \\"anonymous_tally\\" BOOLEAN NOT NULL DEFAULT TRUE,\\n \\"closed\\" BOOLEAN NOT NULL DEFAULT FALSE\\n);","columns":{"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},"question":{"type":"TEXT","notNull":true,"unique":false},"options_json":{"type":"TEXT","notNull":false,"unique":false},"opens_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"closes_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"visibility":{"type":"TEXT","notNull":false,"unique":false,"default":"always"},"one_vote_per_actor":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true},"anonymous_tally":{"type":"BOOLEAN","notNull":true,"unique":false,"default":true},"closed":{"type":"BOOLEAN","notNull":true,"unique":false,"default":false}},"indexes":[{"name":"record_polls_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"record_polls_target","columns":["tenant_id","meta_type","meta_id"]},{"name":"record_polls_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"record_polls_meta_type_meta_id_idx","columns":["meta_type","meta_id"]}],"version":"f6713370"},"importPath":"@happyvertical/smrt-reactions"},"@happyvertical/smrt-reactions:PollVote":{"name":"pollvote","className":"PollVote","qualifiedName":"@happyvertical/smrt-reactions:PollVote","collection":"pollvotes","description":"Append-only through PollService; no generated write API.","filePath":"/home/runner/work/smrt/smrt/packages/reactions/src/models/PollVote.ts","packageName":"@happyvertical/smrt-reactions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"pollId":{"type":"foreignKey","required":true,"related":"Poll","_meta":{"required":true,"onDelete":"NO ACTION","onUpdate":"NO ACTION"}},"actorProfileId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-profiles:Profile"},"optionId":{"type":"text","required":true,"_meta":{"required":true,"readonly":true},"readonly":true},"participationSnapshot":{"type":"text","required":true,"_meta":{"required":true,"readonly":true},"readonly":true}},"methods":{"assertWriteAuthority":{"name":"assertWriteAuthority","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"poll_votes","api":false,"mcp":false,"cli":false,"hooks":{"beforeDelete":"assertWriteAuthority"},"indexes":[{"name":"poll_votes_actor","columns":["tenantId","pollId","actorProfileId"],"unique":true}],"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"PollVote","collectionExportName":"PollVoteCollection","validationRules":[{"field":"pollId","rule":"required","fieldType":"foreignKey"},{"field":"actorProfileId","rule":"required","fieldType":"crossPackageRef"},{"field":"optionId","rule":"required","fieldType":"text"},{"field":"participationSnapshot","rule":"required","fieldType":"text"}],"schema":{"tableName":"poll_votes","ddl":"CREATE TABLE IF NOT EXISTS \\"poll_votes\\" (\\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 \\"poll_id\\" UUID NOT NULL,\\n \\"actor_profile_id\\" UUID NOT NULL,\\n \\"option_id\\" TEXT NOT NULL,\\n \\"participation_snapshot\\" TEXT NOT NULL\\n);","columns":{"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},"poll_id":{"type":"UUID","referenceKind":"foreignKey","notNull":true,"unique":false,"foreignKey":{"table":"record_polls","column":"id","onDelete":"NO ACTION","onUpdate":"NO ACTION"}},"actor_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"option_id":{"type":"TEXT","notNull":true,"unique":false},"participation_snapshot":{"type":"TEXT","notNull":true,"unique":false}},"indexes":[{"name":"poll_votes_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"poll_votes_actor","columns":["tenant_id","poll_id","actor_profile_id"],"unique":true},{"name":"poll_votes_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"poll_votes_poll_id_idx","columns":["poll_id"]},{"name":"poll_votes_actor_profile_id_idx","columns":["actor_profile_id"]}],"version":"c22797d0"},"importPath":"@happyvertical/smrt-reactions"},"@happyvertical/smrt-reactions:Reaction":{"name":"reaction","className":"Reaction","qualifiedName":"@happyvertical/smrt-reactions:Reaction","collection":"reactions","filePath":"/home/runner/work/smrt/smrt/packages/reactions/src/models/Reaction.ts","packageName":"@happyvertical/smrt-reactions","fields":{"metaType":{"type":"text","required":true,"_meta":{"required":true}},"metaId":{"type":"text","required":true,"_meta":{"required":true}},"role":{"type":"text","required":true,"_meta":{"required":true}},"sortOrder":{"type":"integer","required":false,"default":0},"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"actorProfileId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-profiles:Profile"},"kind":{"type":"text","required":true,"default":"like","_meta":{"required":true},"enum":["like","love","celebrate","insightful","support"]}},"methods":{"hydrate":{"name":"hydrate","async":true,"parameters":[],"returnType":"Promise<T | null>","isStatic":false,"isPublic":true},"assertWriteAuthority":{"name":"assertWriteAuthority","async":false,"parameters":[],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"record_reactions","api":false,"mcp":false,"cli":false,"hooks":{"beforeDelete":"assertWriteAuthority"},"indexes":[{"name":"record_reactions_actor_kind","columns":["tenantId","metaType","metaId","actorProfileId","kind"],"unique":true}],"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtPolymorphicAssociation","exportName":"Reaction","collectionExportName":"ReactionCollection","validationRules":[{"field":"metaType","rule":"required","fieldType":"text"},{"field":"metaId","rule":"required","fieldType":"text"},{"field":"role","rule":"required","fieldType":"text"},{"field":"actorProfileId","rule":"required","fieldType":"crossPackageRef"},{"field":"kind","rule":"required","fieldType":"text"}],"schema":{"tableName":"record_reactions","ddl":"CREATE TABLE IF NOT EXISTS \\"record_reactions\\" (\\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 \\"actor_profile_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT NOT NULL DEFAULT 'like'\\n);","columns":{"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},"actor_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":true,"unique":false,"default":"like"}},"indexes":[{"name":"record_reactions_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"record_reactions_actor_kind","columns":["tenant_id","meta_type","meta_id","actor_profile_id","kind"],"unique":true},{"name":"record_reactions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"record_reactions_meta_type_meta_id_idx","columns":["meta_type","meta_id"]},{"name":"record_reactions_actor_profile_id_idx","columns":["actor_profile_id"]}],"version":"678ebe0f"},"importPath":"@happyvertical/smrt-reactions"}},"moduleType":"smrt","smrtDependencies":["@happyvertical/smrt-comments","@happyvertical/smrt-core","@happyvertical/smrt-tenancy"],"browser":{"status":"server-only","issues":["#3624"],"via":["@happyvertical/smrt-tenancy"]},"stampsConstructors":true}`));
5
- //#endregion
6
- //#region src/write-authority.ts
7
- var authority = /* @__PURE__ */ new WeakMap();
8
- async function withParticipationWrite(executor, work) {
9
- authority.set(executor, (authority.get(executor) ?? 0) + 1);
10
- try {
11
- return await work();
12
- } finally {
13
- const remaining = (authority.get(executor) ?? 1) - 1;
14
- if (remaining) authority.set(executor, remaining);
15
- else authority.delete(executor);
16
- }
17
- }
18
- function assertParticipationWrite(executor) {
19
- if (!authority.has(executor)) throw new ValidationError("Participation records require service write authority.", "VALIDATION_PARTICIPATION_AUTHORITY");
20
- }
21
- //#endregion
22
- //#region src/models/Poll.ts
23
- var __defProp$2 = Object.defineProperty;
24
- var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
25
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value
30
- }) : obj[key] = value;
31
- var __decorateClass$2 = (decorators, target, key, kind) => {
32
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
33
- for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
34
- if (kind && result) __defProp$2(target, key, result);
35
- return result;
36
- };
37
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
38
- var Poll = class extends SmrtPolymorphicAssociation {
39
- tenantId = "";
40
- question = "";
41
- optionsJson = "[]";
42
- opensAt = null;
43
- closesAt = null;
44
- visibility = "always";
45
- oneVotePerActor = true;
46
- anonymousTally = true;
47
- closed = false;
48
- constructor(options = {}) {
49
- super(options);
50
- if (options.tenantId !== void 0) this.tenantId = options.tenantId;
51
- if (options.question !== void 0) this.question = options.question;
52
- if (options.optionsJson !== void 0) this.optionsJson = options.optionsJson;
53
- if (options.opensAt !== void 0) this.opensAt = options.opensAt;
54
- if (options.closesAt !== void 0) this.closesAt = options.closesAt;
55
- if (options.visibility !== void 0) this.visibility = options.visibility;
56
- if (options.anonymousTally !== void 0) this.anonymousTally = options.anonymousTally;
57
- if (options.closed !== void 0) this.closed = options.closed;
58
- }
59
- assertWriteAuthority() {
60
- assertParticipationWrite(this.db);
61
- }
62
- async validateBeforeSave() {
63
- assertParticipationWrite(this.db);
64
- await super.validateBeforeSave();
65
- this.pollOptions;
66
- if (this.id) {
67
- const existing = await this.getCanonicalPersistedRow({ id: this.id });
68
- if (existing && (existing.options_json !== this.optionsJson || existing.tenant_id !== this.tenantId || existing.meta_type !== this.metaType || existing.meta_id !== this.metaId)) throw new ValidationError("Poll target and options are immutable.", "VALIDATION_IMMUTABLE_POLL");
69
- }
70
- }
71
- get pollOptions() {
72
- const parsed = JSON.parse(this.optionsJson);
73
- if (!Array.isArray(parsed) || parsed.length < 2 || parsed.length > 50 || parsed.some((o) => !o || typeof o.id !== "string" || !o.id.trim() || typeof o.label !== "string" || !o.label.trim()) || new Set(parsed.map((o) => o.id)).size !== parsed.length) throw new TypeError("Invalid poll options.");
74
- return parsed.map((o) => ({
75
- id: o.id,
76
- label: o.label
77
- }));
78
- }
79
- };
80
- __publicField$2(Poll, "__smrtPackage__", "@happyvertical/smrt-reactions");
81
- __decorateClass$2([tenantId()], Poll.prototype, "tenantId", 2);
82
- __decorateClass$2([field({ required: true })], Poll.prototype, "question", 2);
83
- __decorateClass$2([field({
84
- type: "text",
85
- readonly: true
86
- })], Poll.prototype, "optionsJson", 2);
87
- __decorateClass$2([field({
88
- type: "datetime",
89
- nullable: true
90
- })], Poll.prototype, "opensAt", 2);
91
- __decorateClass$2([field({
92
- type: "datetime",
93
- nullable: true
94
- })], Poll.prototype, "closesAt", 2);
95
- __decorateClass$2([field()], Poll.prototype, "visibility", 2);
96
- __decorateClass$2([field()], Poll.prototype, "oneVotePerActor", 2);
97
- __decorateClass$2([field()], Poll.prototype, "anonymousTally", 2);
98
- __decorateClass$2([field()], Poll.prototype, "closed", 2);
99
- Poll = __decorateClass$2([TenantScoped({ mode: "required" }), smrt({
100
- tableName: "record_polls",
101
- api: false,
102
- mcp: false,
103
- cli: false,
104
- hooks: { beforeDelete: "assertWriteAuthority" },
105
- indexes: [{
106
- name: "record_polls_target",
107
- columns: [
108
- "tenantId",
109
- "metaType",
110
- "metaId"
111
- ]
112
- }]
113
- })], Poll);
114
- //#endregion
115
- //#region src/models/PollVote.ts
116
- var __defProp$1 = Object.defineProperty;
117
- var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
118
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
119
- enumerable: true,
120
- configurable: true,
121
- writable: true,
122
- value
123
- }) : obj[key] = value;
124
- var __decorateClass$1 = (decorators, target, key, kind) => {
125
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
126
- for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
127
- if (kind && result) __defProp$1(target, key, result);
128
- return result;
129
- };
130
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
131
- var PollVote = class extends SmrtObject {
132
- tenantId = "";
133
- pollId = "";
134
- actorProfileId = "";
135
- optionId = "";
136
- participationSnapshot = "{}";
137
- constructor(options = {}) {
138
- super(options);
139
- if (options.tenantId !== void 0) this.tenantId = options.tenantId;
140
- if (options.pollId !== void 0) this.pollId = options.pollId;
141
- if (options.actorProfileId !== void 0) this.actorProfileId = options.actorProfileId;
142
- if (options.optionId !== void 0) this.optionId = options.optionId;
143
- if (options.participationSnapshot !== void 0) this.participationSnapshot = options.participationSnapshot;
144
- }
145
- assertWriteAuthority() {
146
- assertParticipationWrite(this.db);
147
- }
148
- async validateBeforeSave() {
149
- assertParticipationWrite(this.db);
150
- await super.validateBeforeSave();
151
- const evidence = JSON.parse(this.participationSnapshot);
152
- if (!evidence || typeof evidence !== "object" || Array.isArray(evidence) || Object.keys(evidence).length === 0) throw new TypeError("Participation snapshot must be a nonempty JSON object.");
153
- if (this.id) {
154
- const existing = await this.getCanonicalPersistedRow({ id: this.id });
155
- if (existing && (existing.participation_snapshot !== this.participationSnapshot || existing.option_id !== this.optionId || existing.tenant_id !== this.tenantId || existing.poll_id !== this.pollId || existing.actor_profile_id !== this.actorProfileId)) throw new ValidationError("Recorded votes are immutable.", "VALIDATION_IMMUTABLE_VOTE");
156
- }
157
- }
158
- };
159
- __publicField$1(PollVote, "__smrtPackage__", "@happyvertical/smrt-reactions");
160
- __decorateClass$1([tenantId()], PollVote.prototype, "tenantId", 2);
161
- __decorateClass$1([foreignKey(Poll, {
162
- required: true,
163
- onUpdate: "NO ACTION",
164
- onDelete: "NO ACTION"
165
- })], PollVote.prototype, "pollId", 2);
166
- __decorateClass$1([crossPackageRef("@happyvertical/smrt-profiles:Profile", { required: true })], PollVote.prototype, "actorProfileId", 2);
167
- __decorateClass$1([field({
168
- required: true,
169
- readonly: true
170
- })], PollVote.prototype, "optionId", 2);
171
- __decorateClass$1([field({
172
- type: "text",
173
- required: true,
174
- readonly: true
175
- })], PollVote.prototype, "participationSnapshot", 2);
176
- PollVote = __decorateClass$1([TenantScoped({ mode: "required" }), smrt({
177
- tableName: "poll_votes",
178
- api: false,
179
- mcp: false,
180
- cli: false,
181
- hooks: { beforeDelete: "assertWriteAuthority" },
182
- indexes: [{
183
- name: "poll_votes_actor",
184
- columns: [
185
- "tenantId",
186
- "pollId",
187
- "actorProfileId"
188
- ],
189
- unique: true
190
- }]
191
- })], PollVote);
192
- //#endregion
193
- //#region src/models/Reaction.ts
194
- var __defProp = Object.defineProperty;
195
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
196
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
197
- enumerable: true,
198
- configurable: true,
199
- writable: true,
200
- value
201
- }) : obj[key] = value;
202
- var __decorateClass = (decorators, target, key, kind) => {
203
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
204
- for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
205
- if (kind && result) __defProp(target, key, result);
206
- return result;
207
- };
208
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
209
- var Reaction = class extends SmrtPolymorphicAssociation {
210
- tenantId = "";
211
- actorProfileId = "";
212
- kind = "like";
213
- constructor(options = {}) {
214
- super(options);
215
- if (options.tenantId !== void 0) this.tenantId = options.tenantId;
216
- if (options.actorProfileId !== void 0) this.actorProfileId = options.actorProfileId;
217
- if (options.kind !== void 0) this.kind = options.kind;
218
- }
219
- assertWriteAuthority() {
220
- assertParticipationWrite(this.db);
221
- }
222
- async validateBeforeSave() {
223
- assertParticipationWrite(this.db);
224
- await super.validateBeforeSave();
225
- }
226
- };
227
- __publicField(Reaction, "__smrtPackage__", "@happyvertical/smrt-reactions");
228
- __decorateClass([tenantId()], Reaction.prototype, "tenantId", 2);
229
- __decorateClass([crossPackageRef("@happyvertical/smrt-profiles:Profile", { required: true })], Reaction.prototype, "actorProfileId", 2);
230
- __decorateClass([field({ required: true })], Reaction.prototype, "kind", 2);
231
- Reaction = __decorateClass([TenantScoped({ mode: "required" }), smrt({
232
- tableName: "record_reactions",
233
- api: false,
234
- mcp: false,
235
- cli: false,
236
- hooks: { beforeDelete: "assertWriteAuthority" },
237
- indexes: [{
238
- name: "record_reactions_actor_kind",
239
- columns: [
240
- "tenantId",
241
- "metaType",
242
- "metaId",
243
- "actorProfileId",
244
- "kind"
245
- ],
246
- unique: true
247
- }]
248
- })], Reaction);
249
- //#endregion
250
- //#region src/collections/index.ts
251
- var ReactionCollection = class extends SmrtCollection {
252
- static _itemClass = Reaction;
253
- };
254
- var PollCollection = class extends SmrtCollection {
255
- static _itemClass = Poll;
256
- };
257
- var PollVoteCollection = class extends SmrtCollection {
258
- static _itemClass = PollVote;
259
- };
260
- //#endregion
261
- export { PollVote as a, Reaction as i, PollVoteCollection as n, Poll as o, ReactionCollection as r, withParticipationWrite as s, PollCollection as t };
262
-
263
- //# sourceMappingURL=src-C0jSZD4x.js.map