@agentbadge/database 0.6.2 → 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.
- package/dist/database.d.ts +6 -0
- package/dist/database.js +10 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +6 -2
- package/dist/prisma/contract.json +5454 -2128
- package/dist/repositories/agent-request-repository.d.ts +56 -0
- package/dist/repositories/agent-request-repository.js +145 -0
- package/dist/repositories/agent-survey-repository.d.ts +40 -0
- package/dist/repositories/agent-survey-repository.js +90 -0
- package/dist/repositories/commerce-repository.d.ts +75 -0
- package/dist/repositories/commerce-repository.js +492 -0
- package/dist/repositories/commerce-store.d.ts +249 -0
- package/dist/repositories/commerce-store.js +311 -0
- package/dist/repositories/payment-repository.d.ts +29 -1
- package/dist/repositories/payment-repository.js +179 -0
- package/dist/repositories/payment-store.d.ts +81 -0
- package/dist/repositories/payment-store.js +105 -0
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { JsonValue } from "@prisma/orm-postgres/target/codec-types";
|
|
2
|
+
import type { Models } from "../prisma/contract.d.js";
|
|
3
|
+
import type { PrismaDb } from "./event-repository.js";
|
|
4
|
+
type Row = Models.public_AgentRequest;
|
|
5
|
+
type QaRow = Models.public_AgentQAPair;
|
|
6
|
+
export interface AgentRequestUpsert {
|
|
7
|
+
id: string;
|
|
8
|
+
state: string;
|
|
9
|
+
kind?: string | null;
|
|
10
|
+
payload?: JsonValue | null;
|
|
11
|
+
fingerprint: JsonValue;
|
|
12
|
+
fpHash: string;
|
|
13
|
+
agentId?: string | null;
|
|
14
|
+
verified?: boolean;
|
|
15
|
+
response?: JsonValue | null;
|
|
16
|
+
spamFlag?: boolean;
|
|
17
|
+
idempotencyKey?: string | null;
|
|
18
|
+
expiresAtMs: number;
|
|
19
|
+
createdAtMs: number;
|
|
20
|
+
respondedAtMs?: number | null;
|
|
21
|
+
}
|
|
22
|
+
export interface AgentQAPairUpsert {
|
|
23
|
+
id: string;
|
|
24
|
+
questionHash: string;
|
|
25
|
+
question: string;
|
|
26
|
+
response: JsonValue;
|
|
27
|
+
sourceRequestId: string;
|
|
28
|
+
createdAtMs: number;
|
|
29
|
+
}
|
|
30
|
+
export declare class AgentRequestRepository {
|
|
31
|
+
private readonly db;
|
|
32
|
+
constructor(db: PrismaDb);
|
|
33
|
+
put(r: AgentRequestUpsert): Promise<Row>;
|
|
34
|
+
get(id: string): Promise<Row | null>;
|
|
35
|
+
findByIdempotency(idempotencyKey: string, fpHash: string): Promise<Row | null>;
|
|
36
|
+
listByState(opts?: {
|
|
37
|
+
state?: string;
|
|
38
|
+
sinceMs?: number;
|
|
39
|
+
limit?: number;
|
|
40
|
+
}): Promise<Row[]>;
|
|
41
|
+
transition(id: string, from: string, to: string, patch?: {
|
|
42
|
+
response?: JsonValue | null;
|
|
43
|
+
respondedAtMs?: number | null;
|
|
44
|
+
spamFlag?: boolean;
|
|
45
|
+
state?: never;
|
|
46
|
+
}): Promise<Row | null>;
|
|
47
|
+
setSpamFlag(id: string, spamFlag: boolean): Promise<Row | null>;
|
|
48
|
+
listExpired(nowMs: number, limit?: number): Promise<Row[]>;
|
|
49
|
+
listPurgeable(cutoffMs: number, limit?: number): Promise<Row[]>;
|
|
50
|
+
purgePayload(id: string): Promise<boolean>;
|
|
51
|
+
delete(id: string): Promise<boolean>;
|
|
52
|
+
upsertQaPair(qa: AgentQAPairUpsert): Promise<QaRow>;
|
|
53
|
+
getQaByHash(questionHash: string): Promise<QaRow | null>;
|
|
54
|
+
searchQa(substring: string, limit?: number): Promise<QaRow[]>;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
const toBig = (n) => BigInt(n);
|
|
2
|
+
const toBigOrNull = (n) => n == null ? null : BigInt(n);
|
|
3
|
+
const REQ_STATES_TERMINAL = ["completed", "failed"];
|
|
4
|
+
export class AgentRequestRepository {
|
|
5
|
+
db;
|
|
6
|
+
constructor(db) {
|
|
7
|
+
this.db = db;
|
|
8
|
+
}
|
|
9
|
+
async put(r) {
|
|
10
|
+
return this.db.orm.public.AgentRequest.upsert({
|
|
11
|
+
create: {
|
|
12
|
+
id: r.id,
|
|
13
|
+
state: r.state,
|
|
14
|
+
kind: r.kind ?? null,
|
|
15
|
+
payload: r.payload ?? null,
|
|
16
|
+
fingerprint: r.fingerprint,
|
|
17
|
+
fpHash: r.fpHash,
|
|
18
|
+
agentId: r.agentId ?? null,
|
|
19
|
+
verified: r.verified ?? false,
|
|
20
|
+
response: r.response ?? null,
|
|
21
|
+
spamFlag: r.spamFlag ?? false,
|
|
22
|
+
idempotencyKey: r.idempotencyKey ?? null,
|
|
23
|
+
expiresAtMs: toBig(r.expiresAtMs),
|
|
24
|
+
createdAtMs: toBig(r.createdAtMs),
|
|
25
|
+
respondedAtMs: toBigOrNull(r.respondedAtMs),
|
|
26
|
+
},
|
|
27
|
+
update: {
|
|
28
|
+
state: r.state,
|
|
29
|
+
kind: r.kind ?? null,
|
|
30
|
+
payload: r.payload ?? null,
|
|
31
|
+
fingerprint: r.fingerprint,
|
|
32
|
+
agentId: r.agentId ?? null,
|
|
33
|
+
verified: r.verified ?? false,
|
|
34
|
+
response: r.response ?? null,
|
|
35
|
+
spamFlag: r.spamFlag ?? false,
|
|
36
|
+
respondedAtMs: toBigOrNull(r.respondedAtMs),
|
|
37
|
+
},
|
|
38
|
+
conflictOn: { id: r.id },
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async get(id) {
|
|
42
|
+
return this.db.orm.public.AgentRequest.where({ id }).first();
|
|
43
|
+
}
|
|
44
|
+
async findByIdempotency(idempotencyKey, fpHash) {
|
|
45
|
+
return this.db.orm.public.AgentRequest.where({
|
|
46
|
+
idempotencyKey,
|
|
47
|
+
fpHash,
|
|
48
|
+
}).first();
|
|
49
|
+
}
|
|
50
|
+
async listByState(opts) {
|
|
51
|
+
let q = this.db.orm.public.AgentRequest.orderBy((r) => r.createdAtMs.desc());
|
|
52
|
+
if (opts?.state !== undefined)
|
|
53
|
+
q = q.where({ state: opts.state });
|
|
54
|
+
const rows = await q.limit(opts?.limit ?? 500).all();
|
|
55
|
+
return opts?.sinceMs === undefined
|
|
56
|
+
? rows
|
|
57
|
+
: rows.filter((r) => Number(r.createdAtMs) >= opts.sinceMs);
|
|
58
|
+
}
|
|
59
|
+
async transition(id, from, to, patch) {
|
|
60
|
+
const row = await this.db.orm.public.AgentRequest.where({
|
|
61
|
+
id,
|
|
62
|
+
state: from,
|
|
63
|
+
}).update({
|
|
64
|
+
state: to,
|
|
65
|
+
...(patch?.response !== undefined ? { response: patch.response } : {}),
|
|
66
|
+
...(patch?.respondedAtMs !== undefined
|
|
67
|
+
? { respondedAtMs: toBigOrNull(patch.respondedAtMs) }
|
|
68
|
+
: {}),
|
|
69
|
+
...(patch?.spamFlag !== undefined ? { spamFlag: patch.spamFlag } : {}),
|
|
70
|
+
});
|
|
71
|
+
return row;
|
|
72
|
+
}
|
|
73
|
+
async setSpamFlag(id, spamFlag) {
|
|
74
|
+
return this.db.orm.public.AgentRequest.where({ id }).update({
|
|
75
|
+
spamFlag,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async listExpired(nowMs, limit = 500) {
|
|
79
|
+
const rows = await this.db.orm.public.AgentRequest.orderBy((r) => r.expiresAtMs.asc())
|
|
80
|
+
.limit(limit)
|
|
81
|
+
.all();
|
|
82
|
+
return rows.filter((r) => Number(r.expiresAtMs) < nowMs);
|
|
83
|
+
}
|
|
84
|
+
async listPurgeable(cutoffMs, limit = 500) {
|
|
85
|
+
const out = [];
|
|
86
|
+
for (const state of REQ_STATES_TERMINAL) {
|
|
87
|
+
const rows = await this.db.orm.public.AgentRequest.where({
|
|
88
|
+
state,
|
|
89
|
+
})
|
|
90
|
+
.orderBy((r) => r.createdAtMs.asc())
|
|
91
|
+
.limit(limit)
|
|
92
|
+
.all();
|
|
93
|
+
for (const r of rows) {
|
|
94
|
+
if (r.payload !== null && Number(r.createdAtMs) < cutoffMs) {
|
|
95
|
+
out.push(r);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
async purgePayload(id) {
|
|
102
|
+
const row = await this.db.orm.public.AgentRequest.where({
|
|
103
|
+
id,
|
|
104
|
+
}).update({ payload: null });
|
|
105
|
+
return row !== null;
|
|
106
|
+
}
|
|
107
|
+
async delete(id) {
|
|
108
|
+
return ((await this.db.orm.public.AgentRequest.where({ id }).delete()) !==
|
|
109
|
+
null);
|
|
110
|
+
}
|
|
111
|
+
async upsertQaPair(qa) {
|
|
112
|
+
const existing = await this.db.orm.public.AgentQAPair.where({
|
|
113
|
+
questionHash: qa.questionHash,
|
|
114
|
+
}).first();
|
|
115
|
+
if (existing) {
|
|
116
|
+
const updated = await this.db.orm.public.AgentQAPair.where({
|
|
117
|
+
id: existing.id,
|
|
118
|
+
}).update({ uses: existing.uses + 1 });
|
|
119
|
+
return updated ?? existing;
|
|
120
|
+
}
|
|
121
|
+
return this.db.orm.public.AgentQAPair.create({
|
|
122
|
+
id: qa.id,
|
|
123
|
+
questionHash: qa.questionHash,
|
|
124
|
+
question: qa.question,
|
|
125
|
+
response: qa.response,
|
|
126
|
+
sourceRequestId: qa.sourceRequestId,
|
|
127
|
+
uses: 0,
|
|
128
|
+
createdAtMs: BigInt(qa.createdAtMs),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
async getQaByHash(questionHash) {
|
|
132
|
+
return this.db.orm.public.AgentQAPair.where({
|
|
133
|
+
questionHash,
|
|
134
|
+
}).first();
|
|
135
|
+
}
|
|
136
|
+
async searchQa(substring, limit = 50) {
|
|
137
|
+
const needle = substring.toLowerCase();
|
|
138
|
+
const rows = await this.db.orm.public.AgentQAPair.orderBy((r) => r.createdAtMs.desc())
|
|
139
|
+
.limit(500)
|
|
140
|
+
.all();
|
|
141
|
+
return rows
|
|
142
|
+
.filter((r) => r.question.toLowerCase().includes(needle))
|
|
143
|
+
.slice(0, limit);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { JsonValue } from "@prisma/orm-postgres/target/codec-types";
|
|
2
|
+
import type { Models } from "../prisma/contract.d.js";
|
|
3
|
+
import type { PrismaDb } from "./event-repository.js";
|
|
4
|
+
type SurveyRow = Models.public_AgentSurvey;
|
|
5
|
+
type AnswerRow = Models.public_SurveyAnswer;
|
|
6
|
+
export interface AgentSurveyUpsert {
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
questions: JsonValue;
|
|
10
|
+
active?: boolean;
|
|
11
|
+
closesAtMs?: number | null;
|
|
12
|
+
createdAtMs: number;
|
|
13
|
+
}
|
|
14
|
+
export interface SurveyAnswerUpsert {
|
|
15
|
+
id: string;
|
|
16
|
+
surveyId: string;
|
|
17
|
+
agentId?: string | null;
|
|
18
|
+
fpHash?: string | null;
|
|
19
|
+
softFpHash?: string | null;
|
|
20
|
+
answers: JsonValue;
|
|
21
|
+
rated?: boolean;
|
|
22
|
+
flag?: string | null;
|
|
23
|
+
createdAtMs: number;
|
|
24
|
+
}
|
|
25
|
+
export declare class AgentSurveyRepository {
|
|
26
|
+
private readonly db;
|
|
27
|
+
constructor(db: PrismaDb);
|
|
28
|
+
putSurvey(s: AgentSurveyUpsert): Promise<SurveyRow>;
|
|
29
|
+
getSurvey(id: string): Promise<SurveyRow | null>;
|
|
30
|
+
listOpenSurveys(nowMs: number, limit?: number): Promise<SurveyRow[]>;
|
|
31
|
+
setSurveyActive(id: string, active: boolean): Promise<SurveyRow | null>;
|
|
32
|
+
putAnswer(a: SurveyAnswerUpsert): Promise<AnswerRow>;
|
|
33
|
+
getAnswer(id: string): Promise<AnswerRow | null>;
|
|
34
|
+
findAnswerByAgent(surveyId: string, agentId: string): Promise<AnswerRow | null>;
|
|
35
|
+
findAnswerByFp(surveyId: string, fpHash: string): Promise<AnswerRow | null>;
|
|
36
|
+
findAnswerBySoftFp(surveyId: string, softFpHash: string): Promise<AnswerRow | null>;
|
|
37
|
+
listAnswers(surveyId: string, limit?: number): Promise<AnswerRow[]>;
|
|
38
|
+
markRated(id: string): Promise<boolean>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const toBigOrNull = (n) => n == null ? null : BigInt(n);
|
|
2
|
+
export class AgentSurveyRepository {
|
|
3
|
+
db;
|
|
4
|
+
constructor(db) {
|
|
5
|
+
this.db = db;
|
|
6
|
+
}
|
|
7
|
+
async putSurvey(s) {
|
|
8
|
+
return this.db.orm.public.AgentSurvey.upsert({
|
|
9
|
+
create: {
|
|
10
|
+
id: s.id,
|
|
11
|
+
title: s.title,
|
|
12
|
+
questions: s.questions,
|
|
13
|
+
active: s.active ?? true,
|
|
14
|
+
closesAtMs: toBigOrNull(s.closesAtMs),
|
|
15
|
+
createdAtMs: BigInt(s.createdAtMs),
|
|
16
|
+
},
|
|
17
|
+
update: {
|
|
18
|
+
title: s.title,
|
|
19
|
+
questions: s.questions,
|
|
20
|
+
active: s.active ?? true,
|
|
21
|
+
closesAtMs: toBigOrNull(s.closesAtMs),
|
|
22
|
+
},
|
|
23
|
+
conflictOn: { id: s.id },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async getSurvey(id) {
|
|
27
|
+
return this.db.orm.public.AgentSurvey.where({ id }).first();
|
|
28
|
+
}
|
|
29
|
+
async listOpenSurveys(nowMs, limit = 50) {
|
|
30
|
+
const rows = await this.db.orm.public.AgentSurvey.where({
|
|
31
|
+
active: true,
|
|
32
|
+
})
|
|
33
|
+
.orderBy((s) => s.createdAtMs.desc())
|
|
34
|
+
.limit(limit)
|
|
35
|
+
.all();
|
|
36
|
+
return rows.filter((s) => s.closesAtMs === null || Number(s.closesAtMs) > nowMs);
|
|
37
|
+
}
|
|
38
|
+
async setSurveyActive(id, active) {
|
|
39
|
+
return this.db.orm.public.AgentSurvey.where({ id }).update({
|
|
40
|
+
active,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async putAnswer(a) {
|
|
44
|
+
return this.db.orm.public.SurveyAnswer.create({
|
|
45
|
+
id: a.id,
|
|
46
|
+
surveyId: a.surveyId,
|
|
47
|
+
agentId: a.agentId ?? null,
|
|
48
|
+
fpHash: a.fpHash ?? null,
|
|
49
|
+
softFpHash: a.softFpHash ?? null,
|
|
50
|
+
answers: a.answers,
|
|
51
|
+
rated: a.rated ?? false,
|
|
52
|
+
flag: a.flag ?? null,
|
|
53
|
+
createdAtMs: BigInt(a.createdAtMs),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async getAnswer(id) {
|
|
57
|
+
return this.db.orm.public.SurveyAnswer.where({ id }).first();
|
|
58
|
+
}
|
|
59
|
+
async findAnswerByAgent(surveyId, agentId) {
|
|
60
|
+
return this.db.orm.public.SurveyAnswer.where({
|
|
61
|
+
surveyId,
|
|
62
|
+
agentId,
|
|
63
|
+
}).first();
|
|
64
|
+
}
|
|
65
|
+
async findAnswerByFp(surveyId, fpHash) {
|
|
66
|
+
const rows = await this.db.orm.public.SurveyAnswer.where({
|
|
67
|
+
surveyId,
|
|
68
|
+
}).all();
|
|
69
|
+
return rows.find((r) => r.fpHash === fpHash && r.agentId === null) ?? null;
|
|
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
|
+
}
|
|
77
|
+
async listAnswers(surveyId, limit = 500) {
|
|
78
|
+
return this.db.orm.public.SurveyAnswer.where({ surveyId })
|
|
79
|
+
.orderBy((a) => a.createdAtMs.desc())
|
|
80
|
+
.limit(limit)
|
|
81
|
+
.all();
|
|
82
|
+
}
|
|
83
|
+
async markRated(id) {
|
|
84
|
+
const row = await this.db.orm.public.SurveyAnswer.where({
|
|
85
|
+
id,
|
|
86
|
+
rated: false,
|
|
87
|
+
}).update({ rated: true });
|
|
88
|
+
return row !== null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -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;
|