@better-giving/donation 3.0.15 → 3.0.17
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 +1 -1
- package/dist/donations-db.mjs +8 -6
- package/dist/onhold-db.d.mts +1 -1
- package/dist/onhold-db.mjs +16 -16
- package/package.json +1 -1
- package/src/donations-db.mts +9 -6
- package/src/onhold-db.mts +17 -16
package/dist/donations-db.d.mts
CHANGED
|
@@ -4,10 +4,10 @@ import type { IPageKeyed } from "@better-giving/types/api";
|
|
|
4
4
|
import type { IDonationFinal, IDonationFinalAttr, TExplicit } from "./interfaces.mjs";
|
|
5
5
|
import type { IDonationsSearch, IPageOpts } from "./schema.mjs";
|
|
6
6
|
export declare class DonationsDb extends Db {
|
|
7
|
-
static readonly table = "Donations";
|
|
8
7
|
static readonly gsi_referrer$settled_date = "Referrer-FinalizedDate_Index";
|
|
9
8
|
static readonly gsi_npo$settled_date = "npo-settled_date-gsi";
|
|
10
9
|
static readonly gsi_email$tx_date = "email-tx_date-gsi";
|
|
10
|
+
private get table();
|
|
11
11
|
key(id: string): {
|
|
12
12
|
transactionId: string;
|
|
13
13
|
};
|
package/dist/donations-db.mjs
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { GetCommand, PutCommand, QueryCommand, } from "@aws-sdk/lib-dynamodb";
|
|
2
2
|
import { Db } from "@better-giving/db";
|
|
3
3
|
export class DonationsDb extends Db {
|
|
4
|
-
static table = "Donations";
|
|
5
4
|
static gsi_referrer$settled_date = "Referrer-FinalizedDate_Index";
|
|
6
5
|
static gsi_npo$settled_date = "npo-settled_date-gsi";
|
|
7
6
|
static gsi_email$tx_date = "email-tx_date-gsi";
|
|
7
|
+
get table() {
|
|
8
|
+
return this.env === "production" ? "Donations" : "DonationsDev";
|
|
9
|
+
}
|
|
8
10
|
key(id) {
|
|
9
11
|
return { transactionId: id };
|
|
10
12
|
}
|
|
11
13
|
async item(id) {
|
|
12
14
|
const cmd = new GetCommand({
|
|
13
|
-
TableName:
|
|
15
|
+
TableName: this.table,
|
|
14
16
|
Key: this.key(id),
|
|
15
17
|
});
|
|
16
18
|
return this.client.send(cmd).then((r) => r.Item);
|
|
17
19
|
}
|
|
18
20
|
async put_txi(data) {
|
|
19
21
|
const cmd = new PutCommand({
|
|
20
|
-
TableName:
|
|
22
|
+
TableName: this.table,
|
|
21
23
|
Item: data,
|
|
22
24
|
ConditionExpression: `attribute_not_exists(${"transactionId"})`,
|
|
23
25
|
});
|
|
@@ -25,7 +27,7 @@ export class DonationsDb extends Db {
|
|
|
25
27
|
}
|
|
26
28
|
referred_by_q(referrer, opts) {
|
|
27
29
|
const q = {
|
|
28
|
-
TableName:
|
|
30
|
+
TableName: this.table,
|
|
29
31
|
IndexName: DonationsDb.gsi_referrer$settled_date,
|
|
30
32
|
KeyConditionExpression: "#referrer = :referrer",
|
|
31
33
|
ExpressionAttributeNames: {
|
|
@@ -72,7 +74,7 @@ export class DonationsDb extends Db {
|
|
|
72
74
|
eav[":date_end"] = opts.date_end;
|
|
73
75
|
}
|
|
74
76
|
const cmd = new QueryCommand({
|
|
75
|
-
TableName:
|
|
77
|
+
TableName: this.table,
|
|
76
78
|
IndexName: DonationsDb.gsi_npo$settled_date,
|
|
77
79
|
KeyConditionExpression: kce,
|
|
78
80
|
ExpressionAttributeNames: ean,
|
|
@@ -111,7 +113,7 @@ export class DonationsDb extends Db {
|
|
|
111
113
|
eav[":date_end"] = opts.date_end;
|
|
112
114
|
}
|
|
113
115
|
const cmd = new QueryCommand({
|
|
114
|
-
TableName:
|
|
116
|
+
TableName: this.table,
|
|
115
117
|
IndexName: DonationsDb.gsi_email$tx_date,
|
|
116
118
|
KeyConditionExpression: kce,
|
|
117
119
|
ExpressionAttributeNames: ean,
|
package/dist/onhold-db.d.mts
CHANGED
|
@@ -3,8 +3,8 @@ import type { IPageKeyed } from "@better-giving/types/api";
|
|
|
3
3
|
import type { IDonationOnHold, IDonationOnHoldAttr, TExplicit } from "./interfaces.mjs";
|
|
4
4
|
import type { IDonationsSearch } from "./schema.mjs";
|
|
5
5
|
export declare class OnHoldDonationsDb extends Db {
|
|
6
|
-
static readonly table = "on_hold_donations";
|
|
7
6
|
static readonly gsi_email$tx_date = "email-tx_date-gsi";
|
|
7
|
+
private get table();
|
|
8
8
|
key(id: string): {
|
|
9
9
|
transactionId: string;
|
|
10
10
|
};
|
package/dist/onhold-db.mjs
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { DeleteCommand, GetCommand, PutCommand, QueryCommand, UpdateCommand, } from "@aws-sdk/lib-dynamodb";
|
|
2
2
|
import { Db, UpdateBuilder } from "@better-giving/db";
|
|
3
3
|
export class OnHoldDonationsDb extends Db {
|
|
4
|
-
static table = "on_hold_donations";
|
|
5
4
|
static gsi_email$tx_date = "email-tx_date-gsi";
|
|
5
|
+
get table() {
|
|
6
|
+
return this.env === "production"
|
|
7
|
+
? "on_hold_donations"
|
|
8
|
+
: "on_hold_donations_dev";
|
|
9
|
+
}
|
|
6
10
|
key(id) {
|
|
7
11
|
return { transactionId: id };
|
|
8
12
|
}
|
|
9
13
|
async put(data) {
|
|
10
14
|
const cmd = new PutCommand({
|
|
11
|
-
TableName:
|
|
15
|
+
TableName: this.table,
|
|
12
16
|
Item: data,
|
|
13
17
|
ConditionExpression: `attribute_not_exists(${"transactionId"})`,
|
|
14
18
|
});
|
|
@@ -20,7 +24,7 @@ export class OnHoldDonationsDb extends Db {
|
|
|
20
24
|
upd8.set(k, data[k]);
|
|
21
25
|
}
|
|
22
26
|
const cmd = new UpdateCommand({
|
|
23
|
-
TableName:
|
|
27
|
+
TableName: this.table,
|
|
24
28
|
Key: this.key(id),
|
|
25
29
|
...upd8.collect(),
|
|
26
30
|
});
|
|
@@ -28,25 +32,25 @@ export class OnHoldDonationsDb extends Db {
|
|
|
28
32
|
}
|
|
29
33
|
async item(id) {
|
|
30
34
|
const cmd = new GetCommand({
|
|
31
|
-
TableName:
|
|
35
|
+
TableName: this.table,
|
|
32
36
|
Key: this.key(id),
|
|
33
37
|
});
|
|
34
38
|
return this.client.send(cmd).then((r) => r.Item);
|
|
35
39
|
}
|
|
36
40
|
put_txi(data) {
|
|
37
41
|
const cmd = new PutCommand({
|
|
38
|
-
TableName:
|
|
42
|
+
TableName: this.table,
|
|
39
43
|
Item: data,
|
|
40
44
|
ConditionExpression: `attribute_not_exists(${"transactionId"})`,
|
|
41
45
|
});
|
|
42
46
|
return this.client.send(cmd);
|
|
43
47
|
}
|
|
44
48
|
del_txi(id) {
|
|
45
|
-
return { TableName:
|
|
49
|
+
return { TableName: this.table, Key: this.key(id) };
|
|
46
50
|
}
|
|
47
51
|
async del(id) {
|
|
48
52
|
const cmd = new DeleteCommand({
|
|
49
|
-
TableName:
|
|
53
|
+
TableName: this.table,
|
|
50
54
|
Key: this.key(id),
|
|
51
55
|
});
|
|
52
56
|
return this.client.send(cmd);
|
|
@@ -56,7 +60,7 @@ export class OnHoldDonationsDb extends Db {
|
|
|
56
60
|
let kce = "#email = :email";
|
|
57
61
|
/** expression attribute names */
|
|
58
62
|
const ean = {
|
|
59
|
-
"#email": "
|
|
63
|
+
"#email": "kycEmail",
|
|
60
64
|
};
|
|
61
65
|
/** expression attribute values */
|
|
62
66
|
const eav = {
|
|
@@ -79,15 +83,11 @@ export class OnHoldDonationsDb extends Db {
|
|
|
79
83
|
eav[":date_end"] = opts.date_end;
|
|
80
84
|
}
|
|
81
85
|
const cmd = new QueryCommand({
|
|
82
|
-
TableName:
|
|
86
|
+
TableName: this.table,
|
|
83
87
|
IndexName: OnHoldDonationsDb.gsi_email$tx_date,
|
|
84
|
-
KeyConditionExpression:
|
|
85
|
-
ExpressionAttributeNames:
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
ExpressionAttributeValues: {
|
|
89
|
-
":email": email,
|
|
90
|
-
},
|
|
88
|
+
KeyConditionExpression: kce,
|
|
89
|
+
ExpressionAttributeNames: ean,
|
|
90
|
+
ExpressionAttributeValues: eav,
|
|
91
91
|
ScanIndexForward: false,
|
|
92
92
|
});
|
|
93
93
|
return this.client.send(cmd).then((this.to_page));
|
package/package.json
CHANGED
package/src/donations-db.mts
CHANGED
|
@@ -16,11 +16,14 @@ import type { IDonationsSearch, IPageOpts } from "./schema.mjs";
|
|
|
16
16
|
type K = keyof IDonationFinalAttr;
|
|
17
17
|
|
|
18
18
|
export class DonationsDb extends Db {
|
|
19
|
-
static readonly table = "Donations";
|
|
20
19
|
static readonly gsi_referrer$settled_date = "Referrer-FinalizedDate_Index";
|
|
21
20
|
static readonly gsi_npo$settled_date = "npo-settled_date-gsi";
|
|
22
21
|
static readonly gsi_email$tx_date = "email-tx_date-gsi";
|
|
23
22
|
|
|
23
|
+
private get table() {
|
|
24
|
+
return this.env === "production" ? "Donations" : "DonationsDev";
|
|
25
|
+
}
|
|
26
|
+
|
|
24
27
|
key(id: string) {
|
|
25
28
|
return { transactionId: id } satisfies Pick<
|
|
26
29
|
IDonationFinalAttr,
|
|
@@ -30,7 +33,7 @@ export class DonationsDb extends Db {
|
|
|
30
33
|
|
|
31
34
|
async item(id: string): Promise<IDonationFinal | undefined> {
|
|
32
35
|
const cmd = new GetCommand({
|
|
33
|
-
TableName:
|
|
36
|
+
TableName: this.table,
|
|
34
37
|
Key: this.key(id),
|
|
35
38
|
});
|
|
36
39
|
return this.client.send(cmd).then((r) => r.Item as any);
|
|
@@ -38,7 +41,7 @@ export class DonationsDb extends Db {
|
|
|
38
41
|
|
|
39
42
|
async put_txi(data: TExplicit<IDonationFinalAttr>) {
|
|
40
43
|
const cmd = new PutCommand({
|
|
41
|
-
TableName:
|
|
44
|
+
TableName: this.table,
|
|
42
45
|
Item: data,
|
|
43
46
|
ConditionExpression: `attribute_not_exists(${"transactionId" satisfies keyof IDonationFinalAttr})`,
|
|
44
47
|
});
|
|
@@ -47,7 +50,7 @@ export class DonationsDb extends Db {
|
|
|
47
50
|
|
|
48
51
|
referred_by_q(referrer: string, opts?: IPageOpts) {
|
|
49
52
|
const q: QueryCommandInput = {
|
|
50
|
-
TableName:
|
|
53
|
+
TableName: this.table,
|
|
51
54
|
IndexName: DonationsDb.gsi_referrer$settled_date,
|
|
52
55
|
KeyConditionExpression: "#referrer = :referrer",
|
|
53
56
|
ExpressionAttributeNames: {
|
|
@@ -99,7 +102,7 @@ export class DonationsDb extends Db {
|
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
const cmd = new QueryCommand({
|
|
102
|
-
TableName:
|
|
105
|
+
TableName: this.table,
|
|
103
106
|
IndexName: DonationsDb.gsi_npo$settled_date,
|
|
104
107
|
KeyConditionExpression: kce,
|
|
105
108
|
ExpressionAttributeNames: ean,
|
|
@@ -142,7 +145,7 @@ export class DonationsDb extends Db {
|
|
|
142
145
|
}
|
|
143
146
|
|
|
144
147
|
const cmd = new QueryCommand({
|
|
145
|
-
TableName:
|
|
148
|
+
TableName: this.table,
|
|
146
149
|
IndexName: DonationsDb.gsi_email$tx_date,
|
|
147
150
|
KeyConditionExpression: kce,
|
|
148
151
|
ExpressionAttributeNames: ean,
|
package/src/onhold-db.mts
CHANGED
|
@@ -17,9 +17,14 @@ import type { IDonationsSearch } from "./schema.mjs";
|
|
|
17
17
|
type K = keyof IDonationOnHoldAttr;
|
|
18
18
|
|
|
19
19
|
export class OnHoldDonationsDb extends Db {
|
|
20
|
-
static readonly table = "on_hold_donations";
|
|
21
20
|
static readonly gsi_email$tx_date = "email-tx_date-gsi";
|
|
22
21
|
|
|
22
|
+
private get table() {
|
|
23
|
+
return this.env === "production"
|
|
24
|
+
? "on_hold_donations"
|
|
25
|
+
: "on_hold_donations_dev";
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
key(id: string) {
|
|
24
29
|
return { transactionId: id } satisfies Pick<
|
|
25
30
|
IDonationOnHold,
|
|
@@ -29,7 +34,7 @@ export class OnHoldDonationsDb extends Db {
|
|
|
29
34
|
|
|
30
35
|
async put(data: TExplicit<IDonationOnHoldAttr>) {
|
|
31
36
|
const cmd = new PutCommand({
|
|
32
|
-
TableName:
|
|
37
|
+
TableName: this.table,
|
|
33
38
|
Item: data,
|
|
34
39
|
ConditionExpression: `attribute_not_exists(${"transactionId" satisfies keyof IDonationOnHoldAttr})`,
|
|
35
40
|
});
|
|
@@ -45,7 +50,7 @@ export class OnHoldDonationsDb extends Db {
|
|
|
45
50
|
upd8.set(k as K, (data as any)[k]);
|
|
46
51
|
}
|
|
47
52
|
const cmd = new UpdateCommand({
|
|
48
|
-
TableName:
|
|
53
|
+
TableName: this.table,
|
|
49
54
|
Key: this.key(id),
|
|
50
55
|
...upd8.collect(),
|
|
51
56
|
});
|
|
@@ -54,7 +59,7 @@ export class OnHoldDonationsDb extends Db {
|
|
|
54
59
|
|
|
55
60
|
async item(id: string): Promise<IDonationOnHold | undefined> {
|
|
56
61
|
const cmd = new GetCommand({
|
|
57
|
-
TableName:
|
|
62
|
+
TableName: this.table,
|
|
58
63
|
Key: this.key(id),
|
|
59
64
|
});
|
|
60
65
|
return this.client.send(cmd).then((r) => r.Item as any);
|
|
@@ -62,19 +67,19 @@ export class OnHoldDonationsDb extends Db {
|
|
|
62
67
|
|
|
63
68
|
put_txi(data: TExplicit<IDonationOnHoldAttr>) {
|
|
64
69
|
const cmd = new PutCommand({
|
|
65
|
-
TableName:
|
|
70
|
+
TableName: this.table,
|
|
66
71
|
Item: data,
|
|
67
72
|
ConditionExpression: `attribute_not_exists(${"transactionId" satisfies keyof IDonationOnHoldAttr})`,
|
|
68
73
|
});
|
|
69
74
|
return this.client.send(cmd);
|
|
70
75
|
}
|
|
71
76
|
del_txi(id: string): TxType["Delete"] {
|
|
72
|
-
return { TableName:
|
|
77
|
+
return { TableName: this.table, Key: this.key(id) };
|
|
73
78
|
}
|
|
74
79
|
|
|
75
80
|
async del(id: string) {
|
|
76
81
|
const cmd = new DeleteCommand({
|
|
77
|
-
TableName:
|
|
82
|
+
TableName: this.table,
|
|
78
83
|
Key: this.key(id),
|
|
79
84
|
});
|
|
80
85
|
return this.client.send(cmd);
|
|
@@ -88,7 +93,7 @@ export class OnHoldDonationsDb extends Db {
|
|
|
88
93
|
let kce = "#email = :email";
|
|
89
94
|
/** expression attribute names */
|
|
90
95
|
const ean: Record<string, string> = {
|
|
91
|
-
"#email": "
|
|
96
|
+
"#email": "kycEmail" satisfies K,
|
|
92
97
|
};
|
|
93
98
|
/** expression attribute values */
|
|
94
99
|
const eav: Record<string, any> = {
|
|
@@ -111,15 +116,11 @@ export class OnHoldDonationsDb extends Db {
|
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
const cmd = new QueryCommand({
|
|
114
|
-
TableName:
|
|
119
|
+
TableName: this.table,
|
|
115
120
|
IndexName: OnHoldDonationsDb.gsi_email$tx_date,
|
|
116
|
-
KeyConditionExpression:
|
|
117
|
-
ExpressionAttributeNames:
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
ExpressionAttributeValues: {
|
|
121
|
-
":email": email,
|
|
122
|
-
},
|
|
121
|
+
KeyConditionExpression: kce,
|
|
122
|
+
ExpressionAttributeNames: ean,
|
|
123
|
+
ExpressionAttributeValues: eav,
|
|
123
124
|
ScanIndexForward: false,
|
|
124
125
|
});
|
|
125
126
|
return this.client.send(cmd).then(this.to_page<IDonationOnHold>);
|