@agentbadge/database 0.6.8 → 0.6.9
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.
|
@@ -26,7 +26,7 @@ export declare class EntitlementRepository implements EntitlementStore {
|
|
|
26
26
|
limit?: number;
|
|
27
27
|
}): Promise<EntitlementRow[]>;
|
|
28
28
|
listExpiring(nowMs: number, limit?: number): Promise<EntitlementRow[]>;
|
|
29
|
-
listActiveWithSource(limit?: number,
|
|
29
|
+
listActiveWithSource(limit?: number, afterKey?: string): Promise<EntitlementRow[]>;
|
|
30
30
|
applyStatus(id: string, expectedFrom: string, to: string, payloadPatch?: Record<string, JsonValue | undefined>): Promise<EntitlementRow | null>;
|
|
31
31
|
}
|
|
32
32
|
export declare class ReputationFactRepository implements ReputationFactStore {
|
|
@@ -163,7 +163,7 @@ export class EntitlementRepository {
|
|
|
163
163
|
.filter((r) => r.validUntilMs != null && r.validUntilMs <= nowMs);
|
|
164
164
|
return rows.slice(0, need);
|
|
165
165
|
}
|
|
166
|
-
async listActiveWithSource(limit,
|
|
166
|
+
async listActiveWithSource(limit, afterKey) {
|
|
167
167
|
const rows = await this.orm
|
|
168
168
|
.where({ status: "ACTIVE" })
|
|
169
169
|
.orderBy((t) => t.createdAt.asc())
|
|
@@ -173,9 +173,11 @@ export class EntitlementRepository {
|
|
|
173
173
|
.filter((r) => r.sourcePaymentId != null);
|
|
174
174
|
out = out.sort((a, b) => a.createdAt.localeCompare(b.createdAt) ||
|
|
175
175
|
a.id.localeCompare(b.id));
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
178
|
-
|
|
176
|
+
if (afterKey !== undefined) {
|
|
177
|
+
const sep = afterKey.indexOf("|");
|
|
178
|
+
const cAt = afterKey.slice(0, sep);
|
|
179
|
+
const cId = afterKey.slice(sep + 1);
|
|
180
|
+
out = out.filter((r) => r.createdAt > cAt || (r.createdAt === cAt && r.id > cId));
|
|
179
181
|
}
|
|
180
182
|
if (limit !== undefined)
|
|
181
183
|
out = out.slice(0, limit);
|
|
@@ -48,7 +48,7 @@ export interface EntitlementStore {
|
|
|
48
48
|
limit?: number;
|
|
49
49
|
}): Promise<EntitlementRow[]>;
|
|
50
50
|
listExpiring(nowMs: number, limit?: number): Promise<EntitlementRow[]>;
|
|
51
|
-
listActiveWithSource(limit?: number,
|
|
51
|
+
listActiveWithSource(limit?: number, afterKey?: string): Promise<EntitlementRow[]>;
|
|
52
52
|
applyStatus(id: string, expectedFrom: string, to: string, payloadPatch?: Record<string, JsonValue | undefined>): Promise<EntitlementRow | null>;
|
|
53
53
|
}
|
|
54
54
|
export interface ReputationFactInsert {
|
|
@@ -100,7 +100,7 @@ export declare class InMemoryEntitlementStore implements EntitlementStore {
|
|
|
100
100
|
limit?: number;
|
|
101
101
|
}): Promise<EntitlementRow[]>;
|
|
102
102
|
listExpiring(nowMs: number, limit?: number): Promise<EntitlementRow[]>;
|
|
103
|
-
listActiveWithSource(limit?: number,
|
|
103
|
+
listActiveWithSource(limit?: number, afterKey?: string): Promise<EntitlementRow[]>;
|
|
104
104
|
applyStatus(id: string, expectedFrom: string, to: string, payloadPatch?: Record<string, JsonValue | undefined>): Promise<EntitlementRow | null>;
|
|
105
105
|
}
|
|
106
106
|
export declare class InMemoryReputationFactStore implements ReputationFactStore {
|
|
@@ -85,13 +85,15 @@ export class InMemoryEntitlementStore {
|
|
|
85
85
|
out = out.slice(0, limit);
|
|
86
86
|
return out;
|
|
87
87
|
}
|
|
88
|
-
async listActiveWithSource(limit,
|
|
88
|
+
async listActiveWithSource(limit, afterKey) {
|
|
89
89
|
let out = [...this.rows.values()].filter((r) => r.status === "ACTIVE" && r.sourcePaymentId != null);
|
|
90
90
|
out = out.sort((a, b) => a.createdAt.localeCompare(b.createdAt) ||
|
|
91
91
|
a.id.localeCompare(b.id));
|
|
92
|
-
if (
|
|
93
|
-
const
|
|
94
|
-
|
|
92
|
+
if (afterKey !== undefined) {
|
|
93
|
+
const sep = afterKey.indexOf("|");
|
|
94
|
+
const cAt = afterKey.slice(0, sep);
|
|
95
|
+
const cId = afterKey.slice(sep + 1);
|
|
96
|
+
out = out.filter((r) => r.createdAt > cAt || (r.createdAt === cAt && r.id > cId));
|
|
95
97
|
}
|
|
96
98
|
if (limit !== undefined)
|
|
97
99
|
out = out.slice(0, limit);
|