@better-giving/donation 3.0.21 → 3.0.23
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/donation-msgs-db.d.mts +18 -1
- package/dist/donation-msgs-db.mjs +13 -0
- package/package.json +2 -2
- package/src/donation-msgs-db.mts +16 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Db } from "@better-giving/db";
|
|
1
|
+
import { Db, type TxType } from "@better-giving/db";
|
|
2
2
|
import type { ISODate } from "@better-giving/types/alias";
|
|
3
3
|
import type { IPageKeyed } from "@better-giving/types/api";
|
|
4
|
+
import type { Environment } from "@better-giving/types/list";
|
|
4
5
|
import type { IPublicDonor } from "./interfaces.mjs";
|
|
5
6
|
import type { IPageOpts } from "./schema.mjs";
|
|
6
7
|
export type DMKey = `DM#${string}`;
|
|
@@ -15,5 +16,21 @@ export declare class DonationDonorsDb extends Db {
|
|
|
15
16
|
readonly gsi1PK: `Recipient#${string}#staging` | `Recipient#${string}#production`;
|
|
16
17
|
readonly gsi1SK: ISODate;
|
|
17
18
|
};
|
|
19
|
+
record(data: IPublicDonor): {
|
|
20
|
+
amount: number;
|
|
21
|
+
date: string;
|
|
22
|
+
donation_id: string;
|
|
23
|
+
donor_id: string;
|
|
24
|
+
donor_message: string;
|
|
25
|
+
donor_name: string;
|
|
26
|
+
env: Environment;
|
|
27
|
+
id: string;
|
|
28
|
+
recipient_id: string;
|
|
29
|
+
gsi1PK: `Recipient#${string}#staging` | `Recipient#${string}#production`;
|
|
30
|
+
gsi1SK: ISODate;
|
|
31
|
+
PK: `DM#${string}`;
|
|
32
|
+
SK: `DM#${string}`;
|
|
33
|
+
};
|
|
34
|
+
put_txi(data: IPublicDonor): TxType["Put"];
|
|
18
35
|
list(recipient: string, opts?: IPageOpts): Promise<IPageKeyed<IPublicDonor>>;
|
|
19
36
|
}
|
|
@@ -12,6 +12,19 @@ export class DonationDonorsDb extends Db {
|
|
|
12
12
|
gsi1SK: date,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
record(data) {
|
|
16
|
+
return {
|
|
17
|
+
...this.key(data.id),
|
|
18
|
+
...this.gsi1_by_recipient(data.recipient_id, data.date),
|
|
19
|
+
...data,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
put_txi(data) {
|
|
23
|
+
return {
|
|
24
|
+
TableName: DonationDonorsDb.table,
|
|
25
|
+
Item: this.record(data),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
15
28
|
list(recipient, opts) {
|
|
16
29
|
const cmd = new QueryCommand({
|
|
17
30
|
TableName: DonationDonorsDb.table,
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-giving/donation",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.23",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@better-giving/config": "1.1.2"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@better-giving/types": "1.1.8",
|
|
9
9
|
"@better-giving/db": "2.0.6",
|
|
10
|
-
"@better-giving/schemas": "2.0.
|
|
10
|
+
"@better-giving/schemas": "2.0.4",
|
|
11
11
|
"@aws-sdk/lib-dynamodb": "3.485.0",
|
|
12
12
|
"valibot": "0.42.0",
|
|
13
13
|
"date-fns": "4.1.0"
|
package/src/donation-msgs-db.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryCommand } from "@aws-sdk/lib-dynamodb";
|
|
2
|
-
import { Db } from "@better-giving/db";
|
|
2
|
+
import { Db, type TxType } from "@better-giving/db";
|
|
3
3
|
import type { ISODate } from "@better-giving/types/alias";
|
|
4
4
|
import type { IPageKeyed } from "@better-giving/types/api";
|
|
5
5
|
import type { Environment } from "@better-giving/types/list";
|
|
@@ -21,6 +21,21 @@ export class DonationDonorsDb extends Db {
|
|
|
21
21
|
} as const;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
record(data: IPublicDonor) {
|
|
25
|
+
return {
|
|
26
|
+
...this.key(data.id),
|
|
27
|
+
...this.gsi1_by_recipient(data.recipient_id, data.date),
|
|
28
|
+
...data,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
put_txi(data: IPublicDonor): TxType["Put"] {
|
|
33
|
+
return {
|
|
34
|
+
TableName: DonationDonorsDb.table,
|
|
35
|
+
Item: this.record(data),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
24
39
|
list(recipient: string, opts?: IPageOpts): Promise<IPageKeyed<IPublicDonor>> {
|
|
25
40
|
const cmd = new QueryCommand({
|
|
26
41
|
TableName: DonationDonorsDb.table,
|