@better-giving/donation 3.0.8 → 3.0.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.
- package/dist/donations-db.d.mts +3 -2
- package/dist/donations-db.mjs +8 -1
- package/package.json +1 -1
- package/src/donations-db.mts +10 -2
package/dist/donations-db.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { type QueryCommandInput } from "@aws-sdk/lib-dynamodb";
|
|
|
2
2
|
import { Db } from "@better-giving/db";
|
|
3
3
|
import type { IPageKeyed } from "@better-giving/types/api";
|
|
4
4
|
import type { IDonationFinal, IDonationFinalAttr, TExplicit } from "./interfaces.mjs";
|
|
5
|
-
import type { IDonationsSearch } from "./schema.mjs";
|
|
5
|
+
import type { IDonationsSearch, IPageOpts } from "./schema.mjs";
|
|
6
6
|
export declare class DonationsDb extends Db {
|
|
7
7
|
static readonly table = "Donations";
|
|
8
8
|
static readonly gsi_referrer$settled_date = "Referrer-FinalizedDate_index";
|
|
@@ -13,7 +13,8 @@ export declare class DonationsDb extends Db {
|
|
|
13
13
|
};
|
|
14
14
|
item(id: string): Promise<IDonationFinal | undefined>;
|
|
15
15
|
put_txi(data: TExplicit<IDonationFinalAttr>): Promise<import("@aws-sdk/lib-dynamodb").PutCommandOutput>;
|
|
16
|
-
referred_by_q(referrer: string): QueryCommandInput;
|
|
16
|
+
referred_by_q(referrer: string, opts?: IPageOpts): QueryCommandInput;
|
|
17
|
+
referred_by(referrer: string, opts?: IPageOpts): Promise<IPageKeyed<IDonationFinal>>;
|
|
17
18
|
list_to_npo(npo: number, opts?: IDonationsSearch & {
|
|
18
19
|
date_start?: string;
|
|
19
20
|
date_end?: string;
|
package/dist/donations-db.mjs
CHANGED
|
@@ -23,7 +23,7 @@ export class DonationsDb extends Db {
|
|
|
23
23
|
});
|
|
24
24
|
return this.client.send(cmd);
|
|
25
25
|
}
|
|
26
|
-
referred_by_q(referrer) {
|
|
26
|
+
referred_by_q(referrer, opts) {
|
|
27
27
|
const q = {
|
|
28
28
|
TableName: DonationsDb.table,
|
|
29
29
|
IndexName: DonationsDb.gsi_referrer$settled_date,
|
|
@@ -34,9 +34,16 @@ export class DonationsDb extends Db {
|
|
|
34
34
|
ExpressionAttributeValues: {
|
|
35
35
|
":referrer": referrer,
|
|
36
36
|
},
|
|
37
|
+
Limit: opts?.limit,
|
|
38
|
+
ExclusiveStartKey: this.key_to_obj(opts?.next),
|
|
39
|
+
ScanIndexForward: false,
|
|
37
40
|
};
|
|
38
41
|
return q;
|
|
39
42
|
}
|
|
43
|
+
async referred_by(referrer, opts) {
|
|
44
|
+
const cmd = new QueryCommand(this.referred_by_q(referrer, opts));
|
|
45
|
+
return this.client.send(cmd).then((this.to_page));
|
|
46
|
+
}
|
|
40
47
|
async list_to_npo(npo, opts) {
|
|
41
48
|
/** key condition expression */
|
|
42
49
|
let kce = "#npo = :npo";
|
package/package.json
CHANGED
package/src/donations-db.mts
CHANGED
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
IDonationFinalAttr,
|
|
12
12
|
TExplicit,
|
|
13
13
|
} from "./interfaces.mjs";
|
|
14
|
-
import type { IDonationsSearch } from "./schema.mjs";
|
|
14
|
+
import type { IDonationsSearch, IPageOpts } from "./schema.mjs";
|
|
15
15
|
|
|
16
16
|
type K = keyof IDonationFinalAttr;
|
|
17
17
|
|
|
@@ -45,7 +45,7 @@ export class DonationsDb extends Db {
|
|
|
45
45
|
return this.client.send(cmd);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
referred_by_q(referrer: string) {
|
|
48
|
+
referred_by_q(referrer: string, opts?: IPageOpts) {
|
|
49
49
|
const q: QueryCommandInput = {
|
|
50
50
|
TableName: DonationsDb.table,
|
|
51
51
|
IndexName: DonationsDb.gsi_referrer$settled_date,
|
|
@@ -56,10 +56,18 @@ export class DonationsDb extends Db {
|
|
|
56
56
|
ExpressionAttributeValues: {
|
|
57
57
|
":referrer": referrer,
|
|
58
58
|
},
|
|
59
|
+
Limit: opts?.limit,
|
|
60
|
+
ExclusiveStartKey: this.key_to_obj(opts?.next),
|
|
61
|
+
ScanIndexForward: false,
|
|
59
62
|
};
|
|
60
63
|
return q;
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
async referred_by(referrer: string, opts?: IPageOpts) {
|
|
67
|
+
const cmd = new QueryCommand(this.referred_by_q(referrer, opts));
|
|
68
|
+
return this.client.send(cmd).then(this.to_page<IDonationFinal>);
|
|
69
|
+
}
|
|
70
|
+
|
|
63
71
|
async list_to_npo(
|
|
64
72
|
npo: number,
|
|
65
73
|
opts?: IDonationsSearch & { date_start?: string; date_end?: string }
|