@etohq/review 0.0.0-stage → 2.1.0

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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +12 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +9 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/migrations/Migration20261028141707.d.ts +5 -0
  7. package/dist/migrations/Migration20261028141707.d.ts.map +1 -0
  8. package/dist/migrations/Migration20261028141707.js +29 -0
  9. package/dist/migrations/Migration20261028141707.js.map +1 -0
  10. package/dist/models/index.d.ts +5 -0
  11. package/dist/models/index.d.ts.map +1 -0
  12. package/dist/models/index.js +15 -0
  13. package/dist/models/index.js.map +1 -0
  14. package/dist/models/review-flag.d.ts +19 -0
  15. package/dist/models/review-flag.d.ts.map +1 -0
  16. package/dist/models/review-flag.js +31 -0
  17. package/dist/models/review-flag.js.map +1 -0
  18. package/dist/models/review-revision.d.ts +17 -0
  19. package/dist/models/review-revision.d.ts.map +1 -0
  20. package/dist/models/review-revision.js +28 -0
  21. package/dist/models/review-revision.js.map +1 -0
  22. package/dist/models/review-summary.d.ts +22 -0
  23. package/dist/models/review-summary.d.ts.map +1 -0
  24. package/dist/models/review-summary.js +34 -0
  25. package/dist/models/review-summary.js.map +1 -0
  26. package/dist/models/review.d.ts +53 -0
  27. package/dist/models/review.d.ts.map +1 -0
  28. package/dist/models/review.js +103 -0
  29. package/dist/models/review.js.map +1 -0
  30. package/dist/repositories/index.d.ts +3 -0
  31. package/dist/repositories/index.d.ts.map +1 -0
  32. package/dist/repositories/index.js +4 -0
  33. package/dist/repositories/index.js.map +1 -0
  34. package/dist/services/index.d.ts +2 -0
  35. package/dist/services/index.d.ts.map +1 -0
  36. package/dist/services/index.js +9 -0
  37. package/dist/services/index.js.map +1 -0
  38. package/dist/services/review-module-service.d.ts +269 -0
  39. package/dist/services/review-module-service.d.ts.map +1 -0
  40. package/dist/services/review-module-service.js +784 -0
  41. package/dist/services/review-module-service.js.map +1 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -0
  43. package/dist/types/container.d.ts +9 -0
  44. package/dist/types/container.d.ts.map +1 -0
  45. package/dist/types/container.js +3 -0
  46. package/dist/types/container.js.map +1 -0
  47. package/package.json +64 -3
  48. package/README.md +0 -3
@@ -0,0 +1,269 @@
1
+ import { Context, DAL, ModulesSdkTypes } from "@etohq/framework/types";
2
+ import { ModulesSdkUtils } from "@etohq/framework/utils";
3
+ import type { EditReviewDTO, FlagReviewDTO, IReviewModuleService, ListPublicReviewsDTO, ModerateReviewDTO, PublicReviewDTO, RespondToReviewDTO, ReviewDTO, ReviewFlagDTO, ReviewRef, ReviewRevisionDTO, ReviewSubjectQuery, ReviewSummaryDTO, SubmitReviewDTO, SubmitReviewResult, WithdrawReviewDTO } from "@etohq/types/review";
4
+ import { Review, ReviewFlag, ReviewRevision, ReviewSummary } from "../models";
5
+ type InjectedDependencies = {
6
+ baseRepository: DAL.RepositoryService;
7
+ reviewService: ModulesSdkTypes.IEtoInternalService<typeof Review>;
8
+ reviewRevisionService: ModulesSdkTypes.IEtoInternalService<typeof ReviewRevision>;
9
+ reviewFlagService: ModulesSdkTypes.IEtoInternalService<typeof ReviewFlag>;
10
+ reviewSummaryService: ModulesSdkTypes.IEtoInternalService<typeof ReviewSummary>;
11
+ };
12
+ type Pending = {
13
+ name: string;
14
+ data: Record<string, unknown>;
15
+ };
16
+ declare const ReviewModuleService_base: ModulesSdkUtils.EtoServiceReturnType<{
17
+ Review: {
18
+ dto: ReviewDTO;
19
+ };
20
+ ReviewRevision: {
21
+ dto: ReviewRevisionDTO;
22
+ };
23
+ ReviewFlag: {
24
+ dto: ReviewFlagDTO;
25
+ };
26
+ ReviewSummary: {
27
+ dto: ReviewSummaryDTO;
28
+ };
29
+ }>;
30
+ /**
31
+ * The review engine.
32
+ *
33
+ * Every invariant in DESIGN.md is enforced here or by an index. Eligibility —
34
+ * whether the reviewer really took part — is the consumer's, attested on the
35
+ * input (`verified`, `eligible_until`) and composed by the consumer's flow ahead
36
+ * of the canonical workflows.
37
+ */
38
+ export default class ReviewModuleService extends ReviewModuleService_base implements IReviewModuleService {
39
+ protected baseRepository_: DAL.RepositoryService;
40
+ protected reviewService_: ModulesSdkTypes.IEtoInternalService<typeof Review>;
41
+ protected reviewRevisionService_: ModulesSdkTypes.IEtoInternalService<typeof ReviewRevision>;
42
+ protected reviewFlagService_: ModulesSdkTypes.IEtoInternalService<typeof ReviewFlag>;
43
+ protected reviewSummaryService_: ModulesSdkTypes.IEtoInternalService<typeof ReviewSummary>;
44
+ constructor(dependencies: InjectedDependencies);
45
+ submitReview(data: SubmitReviewDTO, sharedContext?: Context): Promise<SubmitReviewResult>;
46
+ protected submitReview_(data: SubmitReviewDTO, sharedContext?: Context): Promise<{
47
+ review: any;
48
+ replayed: boolean;
49
+ revealed_ids: string[];
50
+ events: Pending[];
51
+ }>;
52
+ editReview(data: EditReviewDTO, sharedContext?: Context): Promise<ReviewDTO>;
53
+ protected editReview_(data: EditReviewDTO, sharedContext?: Context): Promise<{
54
+ review: {
55
+ id: string;
56
+ space_id: string;
57
+ subject_type: string;
58
+ subject_id: string;
59
+ subject_owner_id: string | null;
60
+ reviewer_type: string;
61
+ reviewer_id: string;
62
+ reviewer_display: string | null;
63
+ anonymous: boolean;
64
+ context_type: string;
65
+ context_id: string;
66
+ scope: string | null;
67
+ rating: number;
68
+ dimensions: Record<string, unknown> | null;
69
+ tags: Record<string, unknown> | null;
70
+ title: string | null;
71
+ body: string | null;
72
+ media: Record<string, unknown> | null;
73
+ locale: string | null;
74
+ verified: boolean;
75
+ status: "pending" | "published" | "hidden" | "withdrawn";
76
+ revealed_at: Date | null;
77
+ reveal_after: Date | null;
78
+ eligible_until: Date | null;
79
+ occurred_at: Date;
80
+ edited_at: Date | null;
81
+ response_body: string | null;
82
+ responder_id: string | null;
83
+ responded_at: Date | null;
84
+ moderated_by: string | null;
85
+ moderated_at: Date | null;
86
+ moderation_reason: string | null;
87
+ open_flag_count: number;
88
+ idempotency_key: string | null;
89
+ metadata: Record<string, unknown> | null;
90
+ created_at: Date;
91
+ updated_at: Date;
92
+ deleted_at: Date | null;
93
+ };
94
+ events: Pending[];
95
+ }>;
96
+ withdrawReview(data: WithdrawReviewDTO, sharedContext?: Context): Promise<ReviewDTO>;
97
+ protected withdrawReview_(data: WithdrawReviewDTO, sharedContext?: Context): Promise<{
98
+ review: {
99
+ id: string;
100
+ space_id: string;
101
+ subject_type: string;
102
+ subject_id: string;
103
+ subject_owner_id: string | null;
104
+ reviewer_type: string;
105
+ reviewer_id: string;
106
+ reviewer_display: string | null;
107
+ anonymous: boolean;
108
+ context_type: string;
109
+ context_id: string;
110
+ scope: string | null;
111
+ rating: number;
112
+ dimensions: Record<string, unknown> | null;
113
+ tags: Record<string, unknown> | null;
114
+ title: string | null;
115
+ body: string | null;
116
+ media: Record<string, unknown> | null;
117
+ locale: string | null;
118
+ verified: boolean;
119
+ status: "pending" | "published" | "hidden" | "withdrawn";
120
+ revealed_at: Date | null;
121
+ reveal_after: Date | null;
122
+ eligible_until: Date | null;
123
+ occurred_at: Date;
124
+ edited_at: Date | null;
125
+ response_body: string | null;
126
+ responder_id: string | null;
127
+ responded_at: Date | null;
128
+ moderated_by: string | null;
129
+ moderated_at: Date | null;
130
+ moderation_reason: string | null;
131
+ open_flag_count: number;
132
+ idempotency_key: string | null;
133
+ metadata: Record<string, unknown> | null;
134
+ created_at: Date;
135
+ updated_at: Date;
136
+ deleted_at: Date | null;
137
+ };
138
+ events: Pending[];
139
+ }>;
140
+ respondToReview(data: RespondToReviewDTO, sharedContext?: Context): Promise<ReviewDTO>;
141
+ protected respondToReview_(data: RespondToReviewDTO, sharedContext?: Context): Promise<{
142
+ id: string;
143
+ space_id: string;
144
+ subject_type: string;
145
+ subject_id: string;
146
+ subject_owner_id: string | null;
147
+ reviewer_type: string;
148
+ reviewer_id: string;
149
+ reviewer_display: string | null;
150
+ anonymous: boolean;
151
+ context_type: string;
152
+ context_id: string;
153
+ scope: string | null;
154
+ rating: number;
155
+ dimensions: Record<string, unknown> | null;
156
+ tags: Record<string, unknown> | null;
157
+ title: string | null;
158
+ body: string | null;
159
+ media: Record<string, unknown> | null;
160
+ locale: string | null;
161
+ verified: boolean;
162
+ status: "pending" | "published" | "hidden" | "withdrawn";
163
+ revealed_at: Date | null;
164
+ reveal_after: Date | null;
165
+ eligible_until: Date | null;
166
+ occurred_at: Date;
167
+ edited_at: Date | null;
168
+ response_body: string | null;
169
+ responder_id: string | null;
170
+ responded_at: Date | null;
171
+ moderated_by: string | null;
172
+ moderated_at: Date | null;
173
+ moderation_reason: string | null;
174
+ open_flag_count: number;
175
+ idempotency_key: string | null;
176
+ metadata: Record<string, unknown> | null;
177
+ created_at: Date;
178
+ updated_at: Date;
179
+ deleted_at: Date | null;
180
+ }>;
181
+ moderateReview(data: ModerateReviewDTO, sharedContext?: Context): Promise<ReviewDTO>;
182
+ protected moderateReview_(data: ModerateReviewDTO, sharedContext?: Context): Promise<{
183
+ review: {
184
+ id: string;
185
+ space_id: string;
186
+ subject_type: string;
187
+ subject_id: string;
188
+ subject_owner_id: string | null;
189
+ reviewer_type: string;
190
+ reviewer_id: string;
191
+ reviewer_display: string | null;
192
+ anonymous: boolean;
193
+ context_type: string;
194
+ context_id: string;
195
+ scope: string | null;
196
+ rating: number;
197
+ dimensions: Record<string, unknown> | null;
198
+ tags: Record<string, unknown> | null;
199
+ title: string | null;
200
+ body: string | null;
201
+ media: Record<string, unknown> | null;
202
+ locale: string | null;
203
+ verified: boolean;
204
+ status: "pending" | "published" | "hidden" | "withdrawn";
205
+ revealed_at: Date | null;
206
+ reveal_after: Date | null;
207
+ eligible_until: Date | null;
208
+ occurred_at: Date;
209
+ edited_at: Date | null;
210
+ response_body: string | null;
211
+ responder_id: string | null;
212
+ responded_at: Date | null;
213
+ moderated_by: string | null;
214
+ moderated_at: Date | null;
215
+ moderation_reason: string | null;
216
+ open_flag_count: number;
217
+ idempotency_key: string | null;
218
+ metadata: Record<string, unknown> | null;
219
+ created_at: Date;
220
+ updated_at: Date;
221
+ deleted_at: Date | null;
222
+ };
223
+ events: Pending[];
224
+ }>;
225
+ flagReview(data: FlagReviewDTO, sharedContext?: Context): Promise<ReviewFlagDTO>;
226
+ protected flagReview_(data: FlagReviewDTO, sharedContext?: Context): Promise<any>;
227
+ revealDueReviews(data?: {
228
+ now?: Date | string;
229
+ }, sharedContext?: Context): Promise<{
230
+ revealed_ids: string[];
231
+ }>;
232
+ protected revealDueReviews_(data: {
233
+ now?: Date | string;
234
+ }, sharedContext?: Context): Promise<{
235
+ revealed_ids: string[];
236
+ events: Pending[];
237
+ }>;
238
+ anonymizeReviewer(data: {
239
+ reviewer: ReviewRef;
240
+ }, sharedContext?: Context): Promise<{
241
+ anonymized: number;
242
+ }>;
243
+ protected anonymizeReviewer_(data: {
244
+ reviewer: ReviewRef;
245
+ }, sharedContext?: Context): Promise<{
246
+ anonymized: number;
247
+ }>;
248
+ getReviewSummary(query: ReviewSubjectQuery, sharedContext?: Context): Promise<ReviewSummaryDTO>;
249
+ getReviewSummaries(query: {
250
+ space_id: string;
251
+ subject_type: string;
252
+ subject_ids: string[];
253
+ scope?: string | null;
254
+ }, sharedContext?: Context): Promise<ReviewSummaryDTO[]>;
255
+ listPublicReviews(query: ListPublicReviewsDTO, sharedContext?: Context): Promise<{
256
+ reviews: PublicReviewDTO[];
257
+ count: number;
258
+ }>;
259
+ private ownReview_;
260
+ /**
261
+ * Recompute summaries from the rows, in SQL, under a per-subject advisory
262
+ * lock held to the end of the transaction. Two reviews of one subject at once
263
+ * serialise here, so the second recompute sees the first's row.
264
+ */
265
+ private recomputeSummaries_;
266
+ private emit_;
267
+ }
268
+ export {};
269
+ //# sourceMappingURL=review-module-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-module-service.d.ts","sourceRoot":"","sources":["../../src/services/review-module-service.ts"],"names":[],"mappings":"AAAA,OA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