@agentbadge/database 0.6.18 → 0.6.19
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.
|
@@ -3108,6 +3108,13 @@
|
|
|
3108
3108
|
"kind": "scalar"
|
|
3109
3109
|
}
|
|
3110
3110
|
},
|
|
3111
|
+
"milestoneRef": {
|
|
3112
|
+
"nullable": true,
|
|
3113
|
+
"type": {
|
|
3114
|
+
"codecId": "pg/text@1",
|
|
3115
|
+
"kind": "scalar"
|
|
3116
|
+
}
|
|
3117
|
+
},
|
|
3111
3118
|
"payload": {
|
|
3112
3119
|
"nullable": false,
|
|
3113
3120
|
"type": {
|
|
@@ -3184,6 +3191,9 @@
|
|
|
3184
3191
|
"id": {
|
|
3185
3192
|
"column": "id"
|
|
3186
3193
|
},
|
|
3194
|
+
"milestoneRef": {
|
|
3195
|
+
"column": "milestoneRef"
|
|
3196
|
+
},
|
|
3187
3197
|
"payload": {
|
|
3188
3198
|
"column": "payload"
|
|
3189
3199
|
},
|
|
@@ -3274,6 +3284,13 @@
|
|
|
3274
3284
|
"kind": "scalar"
|
|
3275
3285
|
}
|
|
3276
3286
|
},
|
|
3287
|
+
"maxProviders": {
|
|
3288
|
+
"nullable": false,
|
|
3289
|
+
"type": {
|
|
3290
|
+
"codecId": "pg/int4@1",
|
|
3291
|
+
"kind": "scalar"
|
|
3292
|
+
}
|
|
3293
|
+
},
|
|
3277
3294
|
"payload": {
|
|
3278
3295
|
"nullable": false,
|
|
3279
3296
|
"type": {
|
|
@@ -3337,6 +3354,9 @@
|
|
|
3337
3354
|
"id": {
|
|
3338
3355
|
"column": "id"
|
|
3339
3356
|
},
|
|
3357
|
+
"maxProviders": {
|
|
3358
|
+
"column": "maxProviders"
|
|
3359
|
+
},
|
|
3340
3360
|
"payload": {
|
|
3341
3361
|
"column": "payload"
|
|
3342
3362
|
},
|
|
@@ -10103,6 +10123,14 @@
|
|
|
10103
10123
|
"name": "commerceAgreement_status_idx_e98638ab",
|
|
10104
10124
|
"prefix": "commerceAgreement_status_idx",
|
|
10105
10125
|
"unique": false
|
|
10126
|
+
},
|
|
10127
|
+
{
|
|
10128
|
+
"columns": [
|
|
10129
|
+
"taskId"
|
|
10130
|
+
],
|
|
10131
|
+
"name": "commerceAgreement_taskId_idx_4965c936",
|
|
10132
|
+
"prefix": "commerceAgreement_taskId_idx",
|
|
10133
|
+
"unique": false
|
|
10106
10134
|
}
|
|
10107
10135
|
],
|
|
10108
10136
|
"primaryKey": {
|
|
@@ -10111,11 +10139,6 @@
|
|
|
10111
10139
|
]
|
|
10112
10140
|
},
|
|
10113
10141
|
"uniques": [
|
|
10114
|
-
{
|
|
10115
|
-
"columns": [
|
|
10116
|
-
"taskId"
|
|
10117
|
-
]
|
|
10118
|
-
},
|
|
10119
10142
|
{
|
|
10120
10143
|
"columns": [
|
|
10121
10144
|
"offerId"
|
|
@@ -10559,6 +10582,11 @@
|
|
|
10559
10582
|
"nativeType": "text",
|
|
10560
10583
|
"nullable": false
|
|
10561
10584
|
},
|
|
10585
|
+
"milestoneRef": {
|
|
10586
|
+
"codecId": "pg/text@1",
|
|
10587
|
+
"nativeType": "text",
|
|
10588
|
+
"nullable": true
|
|
10589
|
+
},
|
|
10562
10590
|
"payload": {
|
|
10563
10591
|
"codecId": "pg/json@1",
|
|
10564
10592
|
"nativeType": "json",
|
|
@@ -10616,6 +10644,14 @@
|
|
|
10616
10644
|
"prefix": "commerceSubmission_agreementId_createdAt_idx",
|
|
10617
10645
|
"unique": false
|
|
10618
10646
|
},
|
|
10647
|
+
{
|
|
10648
|
+
"columns": [
|
|
10649
|
+
"milestoneRef"
|
|
10650
|
+
],
|
|
10651
|
+
"name": "commerceSubmission_milestoneRef_idx_47b89f34",
|
|
10652
|
+
"prefix": "commerceSubmission_milestoneRef_idx",
|
|
10653
|
+
"unique": false
|
|
10654
|
+
},
|
|
10619
10655
|
{
|
|
10620
10656
|
"columns": [
|
|
10621
10657
|
"providerWallet"
|
|
@@ -10690,6 +10726,15 @@
|
|
|
10690
10726
|
"nativeType": "text",
|
|
10691
10727
|
"nullable": false
|
|
10692
10728
|
},
|
|
10729
|
+
"maxProviders": {
|
|
10730
|
+
"codecId": "pg/int4@1",
|
|
10731
|
+
"default": {
|
|
10732
|
+
"kind": "literal",
|
|
10733
|
+
"value": 1
|
|
10734
|
+
},
|
|
10735
|
+
"nativeType": "int4",
|
|
10736
|
+
"nullable": false
|
|
10737
|
+
},
|
|
10693
10738
|
"payload": {
|
|
10694
10739
|
"codecId": "pg/json@1",
|
|
10695
10740
|
"nativeType": "json",
|
|
@@ -14699,7 +14744,7 @@
|
|
|
14699
14744
|
"kind": "postgres-schema"
|
|
14700
14745
|
}
|
|
14701
14746
|
},
|
|
14702
|
-
"storageHash": "
|
|
14747
|
+
"storageHash": "c9f2020ddef080ce0f72aac86fcec6f3731b2218a222c863d70eba658341621b"
|
|
14703
14748
|
},
|
|
14704
14749
|
"execution": {
|
|
14705
14750
|
"executionHash": "c1d96fa5dc0fd50b864424442bd2c1efd0a624a783ed51f04011d30bc34f5c24",
|
|
@@ -31,6 +31,10 @@ export declare class CommerceAgreementRepository implements CommerceAgreementSto
|
|
|
31
31
|
create(a: CommerceAgreementInsert): Promise<CommerceAgreementRow | null>;
|
|
32
32
|
getById(id: string): Promise<CommerceAgreementRow | null>;
|
|
33
33
|
getByTaskId(taskId: string): Promise<CommerceAgreementRow | null>;
|
|
34
|
+
listByTaskId(taskId: string): Promise<CommerceAgreementRow[]>;
|
|
35
|
+
countByTaskId(taskId: string, opts?: {
|
|
36
|
+
excludeStatuses?: string[];
|
|
37
|
+
}): Promise<number>;
|
|
34
38
|
getByOfferId(offerId: string): Promise<CommerceAgreementRow | null>;
|
|
35
39
|
applyStatus(id: string, expectedFrom: string, to: string, patch?: AgreementStatusPatch): Promise<CommerceAgreementRow | null>;
|
|
36
40
|
}
|
|
@@ -23,6 +23,7 @@ const toTaskRow = (r) => ({
|
|
|
23
23
|
requirements: r.requirements,
|
|
24
24
|
budget: decOrNull(r.budget),
|
|
25
25
|
currency: r.currency,
|
|
26
|
+
maxProviders: r.maxProviders,
|
|
26
27
|
expiresAtMs: numOrNull(r.expiresAtMs),
|
|
27
28
|
status: r.status,
|
|
28
29
|
payload: r.payload,
|
|
@@ -64,6 +65,7 @@ const toSubmissionRow = (r) => ({
|
|
|
64
65
|
providerWallet: r.providerWallet,
|
|
65
66
|
summary: r.summary,
|
|
66
67
|
resultUrl: r.resultUrl,
|
|
68
|
+
milestoneRef: r.milestoneRef,
|
|
67
69
|
status: r.status,
|
|
68
70
|
reviewNote: r.reviewNote,
|
|
69
71
|
submittedAtMs: Number(r.submittedAtMs),
|
|
@@ -135,6 +137,7 @@ export class CommerceTaskRepository {
|
|
|
135
137
|
? t.budget
|
|
136
138
|
: null,
|
|
137
139
|
currency: t.currency ?? "USD",
|
|
140
|
+
maxProviders: t.maxProviders ?? 1,
|
|
138
141
|
expiresAtMs: t.expiresAtMs != null
|
|
139
142
|
? BigInt(t.expiresAtMs)
|
|
140
143
|
: null,
|
|
@@ -231,8 +234,6 @@ export class CommerceAgreementRepository {
|
|
|
231
234
|
async create(a) {
|
|
232
235
|
if (await this.getById(a.id))
|
|
233
236
|
return null;
|
|
234
|
-
if (await this.getByTaskId(a.taskId))
|
|
235
|
-
return null;
|
|
236
237
|
if (await this.getByOfferId(a.offerId))
|
|
237
238
|
return null;
|
|
238
239
|
const row = await catchUnique(this.orm.create({
|
|
@@ -257,9 +258,24 @@ export class CommerceAgreementRepository {
|
|
|
257
258
|
return r ? toAgreementRow(r) : null;
|
|
258
259
|
}
|
|
259
260
|
async getByTaskId(taskId) {
|
|
260
|
-
const r = await this.orm
|
|
261
|
+
const r = await this.orm
|
|
262
|
+
.where({ taskId })
|
|
263
|
+
.orderBy((x) => x.createdAt.asc())
|
|
264
|
+
.first();
|
|
261
265
|
return r ? toAgreementRow(r) : null;
|
|
262
266
|
}
|
|
267
|
+
async listByTaskId(taskId) {
|
|
268
|
+
const rows = await this.orm
|
|
269
|
+
.where({ taskId })
|
|
270
|
+
.orderBy((x) => x.createdAt.asc())
|
|
271
|
+
.all();
|
|
272
|
+
return rows.map(toAgreementRow);
|
|
273
|
+
}
|
|
274
|
+
async countByTaskId(taskId, opts) {
|
|
275
|
+
const ex = opts?.excludeStatuses ?? [];
|
|
276
|
+
const rows = await this.orm.where({ taskId }).all();
|
|
277
|
+
return rows.filter((r) => !ex.includes(r.status)).length;
|
|
278
|
+
}
|
|
263
279
|
async getByOfferId(offerId) {
|
|
264
280
|
const r = await this.orm.where({ offerId }).first();
|
|
265
281
|
return r ? toAgreementRow(r) : null;
|
|
@@ -295,6 +311,7 @@ export class CommerceSubmissionRepository {
|
|
|
295
311
|
providerWallet: s.providerWallet,
|
|
296
312
|
summary: s.summary,
|
|
297
313
|
resultUrl: s.resultUrl ?? null,
|
|
314
|
+
milestoneRef: s.milestoneRef ?? null,
|
|
298
315
|
status: s.status,
|
|
299
316
|
reviewNote: s.reviewNote ?? null,
|
|
300
317
|
submittedAtMs: BigInt(s.submittedAtMs),
|
|
@@ -8,6 +8,7 @@ export interface CommerceTaskInsert {
|
|
|
8
8
|
requirements?: JsonValue | null;
|
|
9
9
|
budget?: string | null;
|
|
10
10
|
currency?: string;
|
|
11
|
+
maxProviders?: number | null;
|
|
11
12
|
expiresAtMs?: number | null;
|
|
12
13
|
status: string;
|
|
13
14
|
payload: JsonValue;
|
|
@@ -73,6 +74,10 @@ export interface CommerceAgreementStore {
|
|
|
73
74
|
create(a: CommerceAgreementInsert): Promise<CommerceAgreementRow | null>;
|
|
74
75
|
getById(id: string): Promise<CommerceAgreementRow | null>;
|
|
75
76
|
getByTaskId(taskId: string): Promise<CommerceAgreementRow | null>;
|
|
77
|
+
listByTaskId(taskId: string): Promise<CommerceAgreementRow[]>;
|
|
78
|
+
countByTaskId(taskId: string, opts?: {
|
|
79
|
+
excludeStatuses?: string[];
|
|
80
|
+
}): Promise<number>;
|
|
76
81
|
getByOfferId(offerId: string): Promise<CommerceAgreementRow | null>;
|
|
77
82
|
applyStatus(id: string, expectedFrom: string, to: string, patch?: AgreementStatusPatch): Promise<CommerceAgreementRow | null>;
|
|
78
83
|
}
|
|
@@ -82,6 +87,7 @@ export interface CommerceSubmissionInsert {
|
|
|
82
87
|
providerWallet: string;
|
|
83
88
|
summary: string;
|
|
84
89
|
resultUrl?: string | null;
|
|
90
|
+
milestoneRef?: string | null;
|
|
85
91
|
status: string;
|
|
86
92
|
reviewNote?: string | null;
|
|
87
93
|
submittedAtMs: number;
|
|
@@ -223,6 +229,10 @@ export declare class InMemoryCommerceAgreementStore implements CommerceAgreement
|
|
|
223
229
|
create(a: CommerceAgreementInsert): Promise<CommerceAgreementRow | null>;
|
|
224
230
|
getById(id: string): Promise<CommerceAgreementRow | null>;
|
|
225
231
|
getByTaskId(taskId: string): Promise<CommerceAgreementRow | null>;
|
|
232
|
+
listByTaskId(taskId: string): Promise<CommerceAgreementRow[]>;
|
|
233
|
+
countByTaskId(taskId: string, opts?: {
|
|
234
|
+
excludeStatuses?: string[];
|
|
235
|
+
}): Promise<number>;
|
|
226
236
|
getByOfferId(offerId: string): Promise<CommerceAgreementRow | null>;
|
|
227
237
|
applyStatus(id: string, expectedFrom: string, to: string, patch?: AgreementStatusPatch): Promise<CommerceAgreementRow | null>;
|
|
228
238
|
}
|
|
@@ -11,6 +11,7 @@ export class InMemoryCommerceTaskStore {
|
|
|
11
11
|
requirements: t.requirements ?? null,
|
|
12
12
|
budget: t.budget ?? null,
|
|
13
13
|
currency: t.currency ?? "USD",
|
|
14
|
+
maxProviders: t.maxProviders ?? 1,
|
|
14
15
|
expiresAtMs: t.expiresAtMs ?? null,
|
|
15
16
|
createdAt: ts,
|
|
16
17
|
updatedAt: ts,
|
|
@@ -81,7 +82,7 @@ export class InMemoryCommerceAgreementStore {
|
|
|
81
82
|
if (this.rows.has(a.id))
|
|
82
83
|
return null;
|
|
83
84
|
for (const x of this.rows.values()) {
|
|
84
|
-
if (x.
|
|
85
|
+
if (x.offerId === a.offerId)
|
|
85
86
|
return null;
|
|
86
87
|
}
|
|
87
88
|
const ts = nowIso();
|
|
@@ -100,7 +101,17 @@ export class InMemoryCommerceAgreementStore {
|
|
|
100
101
|
return this.rows.get(id) ?? null;
|
|
101
102
|
}
|
|
102
103
|
async getByTaskId(taskId) {
|
|
103
|
-
|
|
104
|
+
const all = await this.listByTaskId(taskId);
|
|
105
|
+
return all[0] ?? null;
|
|
106
|
+
}
|
|
107
|
+
async listByTaskId(taskId) {
|
|
108
|
+
return [...this.rows.values()]
|
|
109
|
+
.filter((r) => r.taskId === taskId)
|
|
110
|
+
.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
111
|
+
}
|
|
112
|
+
async countByTaskId(taskId, opts) {
|
|
113
|
+
const ex = new Set(opts?.excludeStatuses ?? []);
|
|
114
|
+
return (await this.listByTaskId(taskId)).filter((r) => !ex.has(r.status)).length;
|
|
104
115
|
}
|
|
105
116
|
async getByOfferId(offerId) {
|
|
106
117
|
return [...this.rows.values()].find((r) => r.offerId === offerId) ?? null;
|
|
@@ -130,6 +141,7 @@ export class InMemoryCommerceSubmissionStore {
|
|
|
130
141
|
const row = {
|
|
131
142
|
...s,
|
|
132
143
|
resultUrl: s.resultUrl ?? null,
|
|
144
|
+
milestoneRef: s.milestoneRef ?? null,
|
|
133
145
|
reviewNote: s.reviewNote ?? null,
|
|
134
146
|
reviewedAtMs: s.reviewedAtMs ?? null,
|
|
135
147
|
createdAt: ts,
|
package/package.json
CHANGED