@agentbadge/database 0.6.3 → 0.6.4

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.
@@ -16,8 +16,10 @@ export interface SurveyAnswerUpsert {
16
16
  surveyId: string;
17
17
  agentId?: string | null;
18
18
  fpHash?: string | null;
19
+ softFpHash?: string | null;
19
20
  answers: JsonValue;
20
21
  rated?: boolean;
22
+ flag?: string | null;
21
23
  createdAtMs: number;
22
24
  }
23
25
  export declare class AgentSurveyRepository {
@@ -31,6 +33,7 @@ export declare class AgentSurveyRepository {
31
33
  getAnswer(id: string): Promise<AnswerRow | null>;
32
34
  findAnswerByAgent(surveyId: string, agentId: string): Promise<AnswerRow | null>;
33
35
  findAnswerByFp(surveyId: string, fpHash: string): Promise<AnswerRow | null>;
36
+ findAnswerBySoftFp(surveyId: string, softFpHash: string): Promise<AnswerRow | null>;
34
37
  listAnswers(surveyId: string, limit?: number): Promise<AnswerRow[]>;
35
38
  markRated(id: string): Promise<boolean>;
36
39
  }
@@ -46,8 +46,10 @@ export class AgentSurveyRepository {
46
46
  surveyId: a.surveyId,
47
47
  agentId: a.agentId ?? null,
48
48
  fpHash: a.fpHash ?? null,
49
+ softFpHash: a.softFpHash ?? null,
49
50
  answers: a.answers,
50
51
  rated: a.rated ?? false,
52
+ flag: a.flag ?? null,
51
53
  createdAtMs: BigInt(a.createdAtMs),
52
54
  });
53
55
  }
@@ -66,6 +68,12 @@ export class AgentSurveyRepository {
66
68
  }).all();
67
69
  return rows.find((r) => r.fpHash === fpHash && r.agentId === null) ?? null;
68
70
  }
71
+ async findAnswerBySoftFp(surveyId, softFpHash) {
72
+ const rows = await this.db.orm.public.SurveyAnswer.where({
73
+ surveyId,
74
+ }).all();
75
+ return rows.find((r) => r.softFpHash === softFpHash) ?? null;
76
+ }
69
77
  async listAnswers(surveyId, limit = 500) {
70
78
  return this.db.orm.public.SurveyAnswer.where({ surveyId })
71
79
  .orderBy((a) => a.createdAtMs.desc())
@@ -0,0 +1,75 @@
1
+ import type { PrismaDb } from "./event-repository.js";
2
+ import type { AgreementStatusPatch, CommerceAgreementInsert, CommerceAgreementRow, CommerceAgreementStore, CommerceEvidenceInsert, CommerceEvidenceRow, CommerceEvidenceStore, CommerceEventInsert, CommerceEventRow, CommerceEventStore, CommerceOfferInsert, CommerceOfferRow, CommerceOfferStore, CommercePaymentInsert, CommercePaymentRow, CommercePaymentStore, CommerceStores, CommerceSubmissionInsert, CommerceSubmissionRow, CommerceSubmissionStore, CommerceTaskInsert, CommerceTaskRow, CommerceTaskStore, PaymentStatusPatch, SubmissionStatusPatch } from "./commerce-store.js";
3
+ export declare class CommerceTaskRepository implements CommerceTaskStore {
4
+ private readonly db;
5
+ constructor(db: PrismaDb);
6
+ private get orm();
7
+ create(t: CommerceTaskInsert): Promise<CommerceTaskRow | null>;
8
+ getById(id: string): Promise<CommerceTaskRow | null>;
9
+ list(opts?: {
10
+ status?: string;
11
+ buyerWallet?: string;
12
+ limit?: number;
13
+ }): Promise<CommerceTaskRow[]>;
14
+ applyStatus(id: string, expectedFrom: string, to: string): Promise<CommerceTaskRow | null>;
15
+ }
16
+ export declare class CommerceOfferRepository implements CommerceOfferStore {
17
+ private readonly db;
18
+ constructor(db: PrismaDb);
19
+ private get orm();
20
+ create(o: CommerceOfferInsert): Promise<CommerceOfferRow | null>;
21
+ getById(id: string): Promise<CommerceOfferRow | null>;
22
+ listByTask(taskId: string): Promise<CommerceOfferRow[]>;
23
+ applyStatus(id: string, expectedFrom: string, to: string): Promise<CommerceOfferRow | null>;
24
+ }
25
+ export declare class CommerceAgreementRepository implements CommerceAgreementStore {
26
+ private readonly db;
27
+ constructor(db: PrismaDb);
28
+ private get orm();
29
+ create(a: CommerceAgreementInsert): Promise<CommerceAgreementRow | null>;
30
+ getById(id: string): Promise<CommerceAgreementRow | null>;
31
+ getByTaskId(taskId: string): Promise<CommerceAgreementRow | null>;
32
+ getByOfferId(offerId: string): Promise<CommerceAgreementRow | null>;
33
+ applyStatus(id: string, expectedFrom: string, to: string, patch?: AgreementStatusPatch): Promise<CommerceAgreementRow | null>;
34
+ }
35
+ export declare class CommerceSubmissionRepository implements CommerceSubmissionStore {
36
+ private readonly db;
37
+ constructor(db: PrismaDb);
38
+ private get orm();
39
+ create(s: CommerceSubmissionInsert): Promise<CommerceSubmissionRow | null>;
40
+ getById(id: string): Promise<CommerceSubmissionRow | null>;
41
+ listByAgreement(agreementId: string): Promise<CommerceSubmissionRow[]>;
42
+ applyStatus(id: string, expectedFrom: string, to: string, patch?: SubmissionStatusPatch): Promise<CommerceSubmissionRow | null>;
43
+ }
44
+ export declare class CommerceEvidenceRepository implements CommerceEvidenceStore {
45
+ private readonly db;
46
+ constructor(db: PrismaDb);
47
+ private get orm();
48
+ append(e: CommerceEvidenceInsert): Promise<CommerceEvidenceRow | null>;
49
+ getById(id: string): Promise<CommerceEvidenceRow | null>;
50
+ listBySubmission(submissionId: string): Promise<CommerceEvidenceRow[]>;
51
+ listByAgreement(agreementId: string): Promise<CommerceEvidenceRow[]>;
52
+ }
53
+ export declare class CommerceEventRepository implements CommerceEventStore {
54
+ private readonly db;
55
+ constructor(db: PrismaDb);
56
+ private get orm();
57
+ append(e: CommerceEventInsert): Promise<CommerceEventRow | null>;
58
+ getById(id: string): Promise<CommerceEventRow | null>;
59
+ latest(): Promise<CommerceEventRow | null>;
60
+ listByEntity(entityType: string, entityId: string): Promise<CommerceEventRow[]>;
61
+ list(opts?: {
62
+ entityType?: string;
63
+ limit?: number;
64
+ }): Promise<CommerceEventRow[]>;
65
+ }
66
+ export declare class CommercePaymentRepository implements CommercePaymentStore {
67
+ private readonly db;
68
+ constructor(db: PrismaDb);
69
+ private get orm();
70
+ create(p: CommercePaymentInsert): Promise<CommercePaymentRow | null>;
71
+ getById(id: string): Promise<CommercePaymentRow | null>;
72
+ getByAgreement(agreementId: string): Promise<CommercePaymentRow | null>;
73
+ applyStatus(id: string, expectedFrom: string, to: string, patch?: PaymentStatusPatch): Promise<CommercePaymentRow | null>;
74
+ }
75
+ export declare function createPrismaCommerceStores(db: PrismaDb): CommerceStores;
@@ -0,0 +1,492 @@
1
+ const dec = (v) => String(v);
2
+ const decOrNull = (v) => v === null || v === undefined ? null : String(v);
3
+ const numOrNull = (v) => v === null || v === undefined ? null : Number(v);
4
+ const toTaskRow = (r) => ({
5
+ id: r.id,
6
+ buyerWallet: r.buyerWallet,
7
+ buyerAgentId: r.buyerAgentId,
8
+ title: r.title,
9
+ description: r.description,
10
+ requirements: r.requirements,
11
+ budget: decOrNull(r.budget),
12
+ currency: r.currency,
13
+ expiresAtMs: numOrNull(r.expiresAtMs),
14
+ status: r.status,
15
+ payload: r.payload,
16
+ createdAt: r.createdAt,
17
+ updatedAt: r.updatedAt,
18
+ });
19
+ const toOfferRow = (r) => ({
20
+ id: r.id,
21
+ taskId: r.taskId,
22
+ providerWallet: r.providerWallet,
23
+ providerAgentId: r.providerAgentId,
24
+ price: dec(r.price),
25
+ currency: r.currency,
26
+ eta: r.eta,
27
+ proposal: r.proposal,
28
+ status: r.status,
29
+ payload: r.payload,
30
+ createdAt: r.createdAt,
31
+ updatedAt: r.updatedAt,
32
+ });
33
+ const toAgreementRow = (r) => ({
34
+ id: r.id,
35
+ taskId: r.taskId,
36
+ offerId: r.offerId,
37
+ buyerWallet: r.buyerWallet,
38
+ providerWallet: r.providerWallet,
39
+ agreedAmount: dec(r.agreedAmount),
40
+ currency: r.currency,
41
+ acceptanceCriteria: r.acceptanceCriteria,
42
+ status: r.status,
43
+ completedAtMs: numOrNull(r.completedAtMs),
44
+ payload: r.payload,
45
+ createdAt: r.createdAt,
46
+ updatedAt: r.updatedAt,
47
+ });
48
+ const toSubmissionRow = (r) => ({
49
+ id: r.id,
50
+ agreementId: r.agreementId,
51
+ providerWallet: r.providerWallet,
52
+ summary: r.summary,
53
+ resultUrl: r.resultUrl,
54
+ status: r.status,
55
+ reviewNote: r.reviewNote,
56
+ submittedAtMs: Number(r.submittedAtMs),
57
+ reviewedAtMs: numOrNull(r.reviewedAtMs),
58
+ payload: r.payload,
59
+ createdAt: r.createdAt,
60
+ updatedAt: r.updatedAt,
61
+ });
62
+ const toEvidenceRow = (r) => ({
63
+ id: r.id,
64
+ submissionId: r.submissionId,
65
+ agreementId: r.agreementId,
66
+ type: r.type,
67
+ url: r.url,
68
+ hash: r.hash,
69
+ content: r.content,
70
+ metadata: r.metadata,
71
+ payload: r.payload,
72
+ createdAt: r.createdAt,
73
+ });
74
+ const toEventRow = (r) => ({
75
+ id: r.id,
76
+ entityType: r.entityType,
77
+ entityId: r.entityId,
78
+ eventType: r.eventType,
79
+ actorWallet: r.actorWallet,
80
+ prevHash: r.prevHash,
81
+ hash: r.hash,
82
+ payload: r.payload,
83
+ eventSeq: String(r.eventSeq),
84
+ createdAt: r.createdAt,
85
+ });
86
+ const toPaymentRow = (r) => ({
87
+ id: r.id,
88
+ agreementId: r.agreementId,
89
+ mode: r.mode,
90
+ status: r.status,
91
+ amount: decOrNull(r.amount),
92
+ currency: r.currency,
93
+ paymentId: r.paymentId,
94
+ recordedBy: r.recordedBy,
95
+ recordedAtMs: numOrNull(r.recordedAtMs),
96
+ verifiedBy: r.verifiedBy,
97
+ verifiedAtMs: numOrNull(r.verifiedAtMs),
98
+ note: r.note,
99
+ payload: r.payload,
100
+ createdAt: r.createdAt,
101
+ updatedAt: r.updatedAt,
102
+ });
103
+ export class CommerceTaskRepository {
104
+ db;
105
+ constructor(db) {
106
+ this.db = db;
107
+ }
108
+ get orm() {
109
+ return this.db.orm.public.CommerceTask;
110
+ }
111
+ async create(t) {
112
+ if (await this.getById(t.id))
113
+ return null;
114
+ const row = await this.orm.create({
115
+ id: t.id,
116
+ buyerWallet: t.buyerWallet,
117
+ buyerAgentId: t.buyerAgentId ?? null,
118
+ title: t.title,
119
+ description: t.description,
120
+ requirements: t.requirements ?? null,
121
+ budget: t.budget != null
122
+ ? t.budget
123
+ : null,
124
+ currency: t.currency ?? "USD",
125
+ expiresAtMs: t.expiresAtMs != null
126
+ ? BigInt(t.expiresAtMs)
127
+ : null,
128
+ status: t.status,
129
+ payload: t.payload,
130
+ });
131
+ return toTaskRow(row);
132
+ }
133
+ async getById(id) {
134
+ const r = await this.orm.where({ id }).first();
135
+ return r ? toTaskRow(r) : null;
136
+ }
137
+ async list(opts) {
138
+ let q = this.orm.orderBy((t) => t.createdAt.desc());
139
+ if (opts?.status !== undefined && opts?.buyerWallet !== undefined) {
140
+ q = q.where({ status: opts.status, buyerWallet: opts.buyerWallet });
141
+ }
142
+ else if (opts?.status !== undefined) {
143
+ q = q.where({ status: opts.status });
144
+ }
145
+ else if (opts?.buyerWallet !== undefined) {
146
+ q = q.where({ buyerWallet: opts.buyerWallet });
147
+ }
148
+ if (opts?.limit !== undefined)
149
+ q = q.limit(opts.limit);
150
+ return (await q.all()).map(toTaskRow);
151
+ }
152
+ async applyStatus(id, expectedFrom, to) {
153
+ const row = await this.orm
154
+ .where({ id, status: expectedFrom })
155
+ .update({ status: to });
156
+ return row ? toTaskRow(row) : null;
157
+ }
158
+ }
159
+ export class CommerceOfferRepository {
160
+ db;
161
+ constructor(db) {
162
+ this.db = db;
163
+ }
164
+ get orm() {
165
+ return this.db.orm.public.CommerceOffer;
166
+ }
167
+ async create(o) {
168
+ if (await this.getById(o.id))
169
+ return null;
170
+ const row = await this.orm.create({
171
+ id: o.id,
172
+ taskId: o.taskId,
173
+ providerWallet: o.providerWallet,
174
+ providerAgentId: o.providerAgentId ?? null,
175
+ price: o.price,
176
+ currency: o.currency ?? "USD",
177
+ eta: o.eta ?? null,
178
+ proposal: o.proposal,
179
+ status: o.status,
180
+ payload: o.payload,
181
+ });
182
+ return toOfferRow(row);
183
+ }
184
+ async getById(id) {
185
+ const r = await this.orm.where({ id }).first();
186
+ return r ? toOfferRow(r) : null;
187
+ }
188
+ async listByTask(taskId) {
189
+ const rows = await this.orm
190
+ .orderBy((o) => o.createdAt.asc())
191
+ .where({ taskId })
192
+ .all();
193
+ return rows.map(toOfferRow);
194
+ }
195
+ async applyStatus(id, expectedFrom, to) {
196
+ const row = await this.orm
197
+ .where({ id, status: expectedFrom })
198
+ .update({ status: to });
199
+ return row ? toOfferRow(row) : null;
200
+ }
201
+ }
202
+ export class CommerceAgreementRepository {
203
+ db;
204
+ constructor(db) {
205
+ this.db = db;
206
+ }
207
+ get orm() {
208
+ return this.db.orm.public.CommerceAgreement;
209
+ }
210
+ async create(a) {
211
+ if (await this.getById(a.id))
212
+ return null;
213
+ if (await this.getByTaskId(a.taskId))
214
+ return null;
215
+ if (await this.getByOfferId(a.offerId))
216
+ return null;
217
+ const row = await this.orm.create({
218
+ id: a.id,
219
+ taskId: a.taskId,
220
+ offerId: a.offerId,
221
+ buyerWallet: a.buyerWallet,
222
+ providerWallet: a.providerWallet,
223
+ agreedAmount: a.agreedAmount,
224
+ currency: a.currency ?? "USD",
225
+ acceptanceCriteria: a.acceptanceCriteria ?? null,
226
+ status: a.status,
227
+ completedAtMs: a.completedAtMs != null
228
+ ? BigInt(a.completedAtMs)
229
+ : null,
230
+ payload: a.payload,
231
+ });
232
+ return toAgreementRow(row);
233
+ }
234
+ async getById(id) {
235
+ const r = await this.orm.where({ id }).first();
236
+ return r ? toAgreementRow(r) : null;
237
+ }
238
+ async getByTaskId(taskId) {
239
+ const r = await this.orm.where({ taskId }).first();
240
+ return r ? toAgreementRow(r) : null;
241
+ }
242
+ async getByOfferId(offerId) {
243
+ const r = await this.orm.where({ offerId }).first();
244
+ return r ? toAgreementRow(r) : null;
245
+ }
246
+ async applyStatus(id, expectedFrom, to, patch) {
247
+ const row = await this.orm
248
+ .where({ id, status: expectedFrom })
249
+ .update({
250
+ status: to,
251
+ ...(patch?.completedAtMs !== undefined
252
+ ? {
253
+ completedAtMs: BigInt(patch.completedAtMs),
254
+ }
255
+ : {}),
256
+ });
257
+ return row ? toAgreementRow(row) : null;
258
+ }
259
+ }
260
+ export class CommerceSubmissionRepository {
261
+ db;
262
+ constructor(db) {
263
+ this.db = db;
264
+ }
265
+ get orm() {
266
+ return this.db.orm.public.CommerceSubmission;
267
+ }
268
+ async create(s) {
269
+ if (await this.getById(s.id))
270
+ return null;
271
+ const row = await this.orm.create({
272
+ id: s.id,
273
+ agreementId: s.agreementId,
274
+ providerWallet: s.providerWallet,
275
+ summary: s.summary,
276
+ resultUrl: s.resultUrl ?? null,
277
+ status: s.status,
278
+ reviewNote: s.reviewNote ?? null,
279
+ submittedAtMs: BigInt(s.submittedAtMs),
280
+ reviewedAtMs: s.reviewedAtMs != null
281
+ ? BigInt(s.reviewedAtMs)
282
+ : null,
283
+ payload: s.payload,
284
+ });
285
+ return toSubmissionRow(row);
286
+ }
287
+ async getById(id) {
288
+ const r = await this.orm.where({ id }).first();
289
+ return r ? toSubmissionRow(r) : null;
290
+ }
291
+ async listByAgreement(agreementId) {
292
+ const rows = await this.orm
293
+ .orderBy((s) => s.createdAt.asc())
294
+ .where({ agreementId })
295
+ .all();
296
+ return rows.map(toSubmissionRow);
297
+ }
298
+ async applyStatus(id, expectedFrom, to, patch) {
299
+ const row = await this.orm
300
+ .where({ id, status: expectedFrom })
301
+ .update({
302
+ status: to,
303
+ ...(patch?.reviewNote !== undefined
304
+ ? { reviewNote: patch.reviewNote }
305
+ : {}),
306
+ ...(patch?.reviewedAtMs !== undefined
307
+ ? {
308
+ reviewedAtMs: BigInt(patch.reviewedAtMs),
309
+ }
310
+ : {}),
311
+ });
312
+ return row ? toSubmissionRow(row) : null;
313
+ }
314
+ }
315
+ export class CommerceEvidenceRepository {
316
+ db;
317
+ constructor(db) {
318
+ this.db = db;
319
+ }
320
+ get orm() {
321
+ return this.db.orm.public.CommerceEvidence;
322
+ }
323
+ async append(e) {
324
+ if (await this.getById(e.id))
325
+ return null;
326
+ const row = await this.orm.create({
327
+ id: e.id,
328
+ submissionId: e.submissionId ?? null,
329
+ agreementId: e.agreementId ?? null,
330
+ type: e.type,
331
+ url: e.url ?? null,
332
+ hash: e.hash ?? null,
333
+ content: e.content ?? null,
334
+ metadata: e.metadata ?? null,
335
+ payload: e.payload,
336
+ });
337
+ return toEvidenceRow(row);
338
+ }
339
+ async getById(id) {
340
+ const r = await this.orm.where({ id }).first();
341
+ return r ? toEvidenceRow(r) : null;
342
+ }
343
+ async listBySubmission(submissionId) {
344
+ const rows = await this.orm
345
+ .orderBy((e) => e.createdAt.asc())
346
+ .where({ submissionId })
347
+ .all();
348
+ return rows.map(toEvidenceRow);
349
+ }
350
+ async listByAgreement(agreementId) {
351
+ const rows = await this.orm
352
+ .orderBy((e) => e.createdAt.asc())
353
+ .where({ agreementId })
354
+ .all();
355
+ return rows.map(toEvidenceRow);
356
+ }
357
+ }
358
+ export class CommerceEventRepository {
359
+ db;
360
+ constructor(db) {
361
+ this.db = db;
362
+ }
363
+ get orm() {
364
+ return this.db.orm.public.CommerceEvent;
365
+ }
366
+ async append(e) {
367
+ if (await this.getById(e.id))
368
+ return null;
369
+ const row = await this.orm.create({
370
+ id: e.id,
371
+ entityType: e.entityType,
372
+ entityId: e.entityId,
373
+ eventType: e.eventType,
374
+ actorWallet: e.actorWallet ?? null,
375
+ prevHash: e.prevHash,
376
+ hash: e.hash,
377
+ payload: e.payload,
378
+ });
379
+ return toEventRow(row);
380
+ }
381
+ async getById(id) {
382
+ const r = await this.orm.where({ id }).first();
383
+ return r ? toEventRow(r) : null;
384
+ }
385
+ async latest() {
386
+ const r = await this.orm
387
+ .orderBy((e) => e.eventSeq.desc())
388
+ .limit(1)
389
+ .first();
390
+ return r ? toEventRow(r) : null;
391
+ }
392
+ async listByEntity(entityType, entityId) {
393
+ const rows = await this.orm
394
+ .orderBy((e) => e.eventSeq.asc())
395
+ .where({ entityType, entityId })
396
+ .all();
397
+ return rows.map(toEventRow);
398
+ }
399
+ async list(opts) {
400
+ let q = this.orm.orderBy((e) => e.eventSeq.desc());
401
+ if (opts?.entityType !== undefined) {
402
+ q = q.where({ entityType: opts.entityType });
403
+ }
404
+ if (opts?.limit !== undefined)
405
+ q = q.limit(opts.limit);
406
+ return (await q.all()).map(toEventRow);
407
+ }
408
+ }
409
+ export class CommercePaymentRepository {
410
+ db;
411
+ constructor(db) {
412
+ this.db = db;
413
+ }
414
+ get orm() {
415
+ return this.db.orm.public.CommercePayment;
416
+ }
417
+ async create(p) {
418
+ if (await this.getById(p.id))
419
+ return null;
420
+ if (await this.getByAgreement(p.agreementId))
421
+ return null;
422
+ const row = await this.orm.create({
423
+ id: p.id,
424
+ agreementId: p.agreementId,
425
+ mode: p.mode ?? "RECORD_ONLY",
426
+ status: p.status,
427
+ amount: p.amount != null
428
+ ? p.amount
429
+ : null,
430
+ currency: p.currency ?? "USD",
431
+ paymentId: p.paymentId ?? null,
432
+ recordedBy: p.recordedBy ?? null,
433
+ recordedAtMs: p.recordedAtMs != null
434
+ ? BigInt(p.recordedAtMs)
435
+ : null,
436
+ verifiedBy: p.verifiedBy ?? null,
437
+ verifiedAtMs: p.verifiedAtMs != null
438
+ ? BigInt(p.verifiedAtMs)
439
+ : null,
440
+ note: p.note ?? null,
441
+ payload: p.payload,
442
+ });
443
+ return toPaymentRow(row);
444
+ }
445
+ async getById(id) {
446
+ const r = await this.orm.where({ id }).first();
447
+ return r ? toPaymentRow(r) : null;
448
+ }
449
+ async getByAgreement(agreementId) {
450
+ const r = await this.orm.where({ agreementId }).first();
451
+ return r ? toPaymentRow(r) : null;
452
+ }
453
+ async applyStatus(id, expectedFrom, to, patch) {
454
+ const row = await this.orm
455
+ .where({ id, status: expectedFrom })
456
+ .update({
457
+ status: to,
458
+ ...(patch?.recordedBy !== undefined
459
+ ? { recordedBy: patch.recordedBy }
460
+ : {}),
461
+ ...(patch?.recordedAtMs !== undefined
462
+ ? {
463
+ recordedAtMs: BigInt(patch.recordedAtMs),
464
+ }
465
+ : {}),
466
+ ...(patch?.verifiedBy !== undefined
467
+ ? { verifiedBy: patch.verifiedBy }
468
+ : {}),
469
+ ...(patch?.verifiedAtMs !== undefined
470
+ ? {
471
+ verifiedAtMs: BigInt(patch.verifiedAtMs),
472
+ }
473
+ : {}),
474
+ ...(patch?.paymentId !== undefined
475
+ ? { paymentId: patch.paymentId }
476
+ : {}),
477
+ ...(patch?.note !== undefined ? { note: patch.note } : {}),
478
+ });
479
+ return row ? toPaymentRow(row) : null;
480
+ }
481
+ }
482
+ export function createPrismaCommerceStores(db) {
483
+ return {
484
+ tasks: new CommerceTaskRepository(db),
485
+ offers: new CommerceOfferRepository(db),
486
+ agreements: new CommerceAgreementRepository(db),
487
+ submissions: new CommerceSubmissionRepository(db),
488
+ evidence: new CommerceEvidenceRepository(db),
489
+ events: new CommerceEventRepository(db),
490
+ payments: new CommercePaymentRepository(db),
491
+ };
492
+ }