@better-giving/donation 3.0.30 → 3.0.32

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.
@@ -1,7 +1,7 @@
1
1
  import { type QueryCommandInput } from "@aws-sdk/lib-dynamodb";
2
2
  import { Db, type TxType } from "@better-giving/db";
3
3
  import type { IPageKeyed } from "@better-giving/types/api";
4
- import type { IDonationFinal, IDonationFinalAttr } from "./interfaces.mjs";
4
+ import type { IDonationFinal, IDonationFinalAttr, IDonationFinalUpdate } from "./interfaces.mjs";
5
5
  import type { IDonationsSearch, IPageOpts } from "./schema.mjs";
6
6
  export declare class DonationsDb extends Db {
7
7
  static readonly gsi_referrer$settled_date = "Referrer-FinalizedDate_Index";
@@ -13,8 +13,8 @@ export declare class DonationsDb extends Db {
13
13
  };
14
14
  item(id: string): Promise<IDonationFinal | undefined>;
15
15
  put_txi(data: IDonationFinalAttr): TxType["Put"];
16
- update(id: string, data: Partial<Omit<IDonationFinalAttr, "transactionId">>): Promise<IDonationFinal>;
17
- update_txi(id: string, data: Partial<Omit<IDonationFinalAttr, "transactionId">>): TxType["Update"];
16
+ update(id: string, data: IDonationFinalUpdate): Promise<IDonationFinal>;
17
+ update_txi(id: string, data: IDonationFinalUpdate): TxType["Update"];
18
18
  referred_by_q(referrer: string, opts?: IPageOpts): QueryCommandInput;
19
19
  referred_by(referrer: string, opts?: IPageOpts): Promise<IPageKeyed<IDonationFinal>>;
20
20
  list_to_npo(npo: number, opts?: IDonationsSearch & {
@@ -32,6 +32,8 @@ export class DonationsDb extends Db {
32
32
  const cmd = new UpdateCommand({
33
33
  TableName: this.table,
34
34
  Key: this.key(id),
35
+ ReturnValues: "ALL_NEW",
36
+ ConditionExpression: `attribute_exists(${"transactionId"})`,
35
37
  ...upd8.collect(),
36
38
  });
37
39
  return this.client.send(cmd).then((r) => r.Attributes);
@@ -44,6 +46,7 @@ export class DonationsDb extends Db {
44
46
  return {
45
47
  TableName: this.table,
46
48
  Key: this.key(id),
49
+ ConditionExpression: `attribute_exists(${"transactionId"})`,
47
50
  ...upd8.collect(),
48
51
  };
49
52
  }
package/dist/index.d.mts CHANGED
@@ -1,7 +1,5 @@
1
1
  export type { IAllocation, TDonationSource, TDonorTitle, TFrequency, IDonationsSearch, IPageOpts, } from "./schema.mjs";
2
- export type * from "./paypal.mjs";
3
2
  export type * from "./interfaces.mjs";
4
3
  export { DonationsDb } from "./donations-db.mjs";
5
4
  export { OnHoldDonationsDb } from "./onhold-db.mjs";
6
- export { SubsDb } from "./subscriptions-db.mjs";
7
5
  export { DonationDonorsDb } from "./donation-msgs-db.mjs";
package/dist/index.mjs CHANGED
@@ -1,4 +1,3 @@
1
1
  export { DonationsDb } from "./donations-db.mjs";
2
2
  export { OnHoldDonationsDb } from "./onhold-db.mjs";
3
- export { SubsDb } from "./subscriptions-db.mjs";
4
3
  export { DonationDonorsDb } from "./donation-msgs-db.mjs";
@@ -99,6 +99,8 @@ export interface IDonationOnHoldAttr {
99
99
  inHonorOf?: string;
100
100
  tributeNotif?: ITributeNotif;
101
101
  }
102
+ export interface IDonationOnholdUpdate extends Partial<Omit<IDonationOnHoldAttr, "transactionId">> {
103
+ }
102
104
  export interface IDonationOnHold extends IDonationOnHoldAttr, IDonationOnHoldAttrLegacy {
103
105
  }
104
106
  export interface IDonationFinalAttrLegacy {
@@ -266,6 +268,8 @@ export interface IDonationFinalAttr {
266
268
  referrer?: string;
267
269
  taxReceiptId?: string;
268
270
  }
271
+ export interface IDonationFinalUpdate extends Partial<Omit<IDonationFinalAttr, "transactionId">> {
272
+ }
269
273
  export interface IDonationFinal extends IDonationFinalAttr, IDonationFinalAttrLegacy {
270
274
  }
271
275
  export interface IPublicDonor {
@@ -1,6 +1,6 @@
1
1
  import { Db, type TxType } from "@better-giving/db";
2
2
  import type { IPageKeyed } from "@better-giving/types/api";
3
- import type { IDonationOnHold, IDonationOnHoldAttr } from "./interfaces.mjs";
3
+ import type { IDonationOnHold, IDonationOnHoldAttr, IDonationOnholdUpdate } from "./interfaces.mjs";
4
4
  import type { IDonationsSearch } from "./schema.mjs";
5
5
  export declare class OnHoldDonationsDb extends Db {
6
6
  static readonly gsi_email$tx_date = "email-tx_date-gsi";
@@ -9,8 +9,8 @@ export declare class OnHoldDonationsDb extends Db {
9
9
  transactionId: string;
10
10
  };
11
11
  put(data: IDonationOnHoldAttr): Promise<import("@aws-sdk/lib-dynamodb").PutCommandOutput>;
12
- update(id: string, data: Partial<Omit<IDonationOnHoldAttr, "transactionId">>): Promise<IDonationOnHold>;
13
- update_txi(id: string, data: Partial<Omit<IDonationOnHoldAttr, "transactionId">>): TxType["Update"];
12
+ update(id: string, data: IDonationOnholdUpdate): Promise<IDonationOnHold>;
13
+ update_txi(id: string, data: IDonationOnholdUpdate): TxType["Update"];
14
14
  item(id: string): Promise<IDonationOnHold | undefined>;
15
15
  put_txi(data: IDonationOnHoldAttr): Promise<import("@aws-sdk/lib-dynamodb").PutCommandOutput>;
16
16
  del_txi(id: string): TxType["Delete"];
@@ -26,6 +26,8 @@ export class OnHoldDonationsDb extends Db {
26
26
  const cmd = new UpdateCommand({
27
27
  TableName: this.table,
28
28
  Key: this.key(id),
29
+ ReturnValues: "ALL_NEW",
30
+ ConditionExpression: `attribute_exists(${"transactionId"})`,
29
31
  ...upd8.collect(),
30
32
  });
31
33
  return this.client.send(cmd).then((r) => r.Attributes);
@@ -38,6 +40,7 @@ export class OnHoldDonationsDb extends Db {
38
40
  return {
39
41
  TableName: this.table,
40
42
  Key: this.key(id),
43
+ ConditionExpression: `attribute_exists(${"transactionId"})`,
41
44
  ...upd8.collect(),
42
45
  };
43
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-giving/donation",
3
- "version": "3.0.30",
3
+ "version": "3.0.32",
4
4
  "devDependencies": {
5
5
  "@better-giving/config": "1.1.2"
6
6
  },
@@ -6,7 +6,11 @@ import {
6
6
  } from "@aws-sdk/lib-dynamodb";
7
7
  import { Db, type TxType, UpdateBuilder } from "@better-giving/db";
8
8
  import type { IPageKeyed } from "@better-giving/types/api";
9
- import type { IDonationFinal, IDonationFinalAttr } from "./interfaces.mjs";
9
+ import type {
10
+ IDonationFinal,
11
+ IDonationFinalAttr,
12
+ IDonationFinalUpdate,
13
+ } from "./interfaces.mjs";
10
14
  import type { IDonationsSearch, IPageOpts } from "./schema.mjs";
11
15
 
12
16
  type K = keyof IDonationFinalAttr;
@@ -45,7 +49,7 @@ export class DonationsDb extends Db {
45
49
 
46
50
  async update(
47
51
  id: string,
48
- data: Partial<Omit<IDonationFinalAttr, "transactionId">>
52
+ data: IDonationFinalUpdate
49
53
  ): Promise<IDonationFinal> {
50
54
  const upd8 = new UpdateBuilder();
51
55
  for (const k in data) {
@@ -54,15 +58,14 @@ export class DonationsDb extends Db {
54
58
  const cmd = new UpdateCommand({
55
59
  TableName: this.table,
56
60
  Key: this.key(id),
61
+ ReturnValues: "ALL_NEW",
62
+ ConditionExpression: `attribute_exists(${"transactionId" satisfies K})`,
57
63
  ...upd8.collect(),
58
64
  });
59
65
  return this.client.send(cmd).then((r) => r.Attributes as any);
60
66
  }
61
67
 
62
- update_txi(
63
- id: string,
64
- data: Partial<Omit<IDonationFinalAttr, "transactionId">>
65
- ): TxType["Update"] {
68
+ update_txi(id: string, data: IDonationFinalUpdate): TxType["Update"] {
66
69
  const upd8 = new UpdateBuilder();
67
70
  for (const k in data) {
68
71
  upd8.set(k as K, (data as any)[k]);
@@ -70,6 +73,7 @@ export class DonationsDb extends Db {
70
73
  return {
71
74
  TableName: this.table,
72
75
  Key: this.key(id),
76
+ ConditionExpression: `attribute_exists(${"transactionId" satisfies K})`,
73
77
  ...upd8.collect(),
74
78
  };
75
79
  }
package/src/index.mts CHANGED
@@ -7,10 +7,8 @@ export type {
7
7
  IPageOpts,
8
8
  } from "./schema.mjs";
9
9
 
10
- export type * from "./paypal.mjs";
11
10
  export type * from "./interfaces.mjs";
12
11
 
13
12
  export { DonationsDb } from "./donations-db.mjs";
14
13
  export { OnHoldDonationsDb } from "./onhold-db.mjs";
15
- export { SubsDb } from "./subscriptions-db.mjs";
16
14
  export { DonationDonorsDb } from "./donation-msgs-db.mjs";
@@ -115,6 +115,9 @@ export interface IDonationOnHoldAttr {
115
115
  tributeNotif?: ITributeNotif;
116
116
  }
117
117
 
118
+ export interface IDonationOnholdUpdate
119
+ extends Partial<Omit<IDonationOnHoldAttr, "transactionId">> {}
120
+
118
121
  export interface IDonationOnHold
119
122
  extends IDonationOnHoldAttr,
120
123
  IDonationOnHoldAttrLegacy {}
@@ -300,6 +303,9 @@ export interface IDonationFinalAttr {
300
303
  taxReceiptId?: string;
301
304
  }
302
305
 
306
+ export interface IDonationFinalUpdate
307
+ extends Partial<Omit<IDonationFinalAttr, "transactionId">> {}
308
+
303
309
  export interface IDonationFinal
304
310
  extends IDonationFinalAttr,
305
311
  IDonationFinalAttrLegacy {}
package/src/onhold-db.mts CHANGED
@@ -7,7 +7,11 @@ import {
7
7
  } from "@aws-sdk/lib-dynamodb";
8
8
  import { Db, type TxType, UpdateBuilder } from "@better-giving/db";
9
9
  import type { IPageKeyed } from "@better-giving/types/api";
10
- import type { IDonationOnHold, IDonationOnHoldAttr } from "./interfaces.mjs";
10
+ import type {
11
+ IDonationOnHold,
12
+ IDonationOnHoldAttr,
13
+ IDonationOnholdUpdate,
14
+ } from "./interfaces.mjs";
11
15
  import type { IDonationsSearch } from "./schema.mjs";
12
16
 
13
17
  type K = keyof IDonationOnHoldAttr;
@@ -39,7 +43,7 @@ export class OnHoldDonationsDb extends Db {
39
43
 
40
44
  async update(
41
45
  id: string,
42
- data: Partial<Omit<IDonationOnHoldAttr, "transactionId">>
46
+ data: IDonationOnholdUpdate
43
47
  ): Promise<IDonationOnHold> {
44
48
  const upd8 = new UpdateBuilder();
45
49
  for (const k in data) {
@@ -48,15 +52,14 @@ export class OnHoldDonationsDb extends Db {
48
52
  const cmd = new UpdateCommand({
49
53
  TableName: this.table,
50
54
  Key: this.key(id),
55
+ ReturnValues: "ALL_NEW",
56
+ ConditionExpression: `attribute_exists(${"transactionId" satisfies K})`,
51
57
  ...upd8.collect(),
52
58
  });
53
59
  return this.client.send(cmd).then((r) => r.Attributes as any);
54
60
  }
55
61
 
56
- update_txi(
57
- id: string,
58
- data: Partial<Omit<IDonationOnHoldAttr, "transactionId">>
59
- ): TxType["Update"] {
62
+ update_txi(id: string, data: IDonationOnholdUpdate): TxType["Update"] {
60
63
  const upd8 = new UpdateBuilder();
61
64
  for (const k in data) {
62
65
  upd8.set(k as K, (data as any)[k]);
@@ -64,6 +67,7 @@ export class OnHoldDonationsDb extends Db {
64
67
  return {
65
68
  TableName: this.table,
66
69
  Key: this.key(id),
70
+ ConditionExpression: `attribute_exists(${"transactionId" satisfies K})`,
67
71
  ...upd8.collect(),
68
72
  };
69
73
  }
package/src/paypal.mts DELETED
@@ -1,85 +0,0 @@
1
- export declare namespace FiatDonations {
2
- type Currency = {
3
- /** lowercase ISO 4217 code */
4
- currency_code: string;
5
- minimum_amount: number;
6
- rate: number;
7
- timestamp: string;
8
- };
9
- }
10
-
11
- export declare namespace PayPalDonation {
12
- type CreateOrder = {
13
- purchase_units: PurchaseUnit[];
14
- intent: Intent;
15
- payment_source?: PaymentSource;
16
- };
17
-
18
- // see Response object description in official docs
19
- // https://developer.paypal.com/docs/api/orders/v2/#orders_create
20
- type Order = {
21
- id: string;
22
- status: Status;
23
- intent: Intent;
24
- payment_source: PaymentSource;
25
- purchase_units: PurchaseUnit[];
26
- payer: Payer;
27
- create_time: Date;
28
- links: Link[];
29
- };
30
-
31
- type Link = {
32
- href: string;
33
- rel: string;
34
- method: string;
35
- };
36
-
37
- type Payer = {
38
- name: Name;
39
- email_address: string;
40
- payer_id: string;
41
- };
42
-
43
- type PaymentSource = {
44
- paypal: {
45
- name: Name;
46
- email_address: string;
47
- account_id: string;
48
- };
49
- };
50
-
51
- type Name = {
52
- given_name: string;
53
- surname: string;
54
- };
55
-
56
- type PurchaseUnit = {
57
- // don't need 'reference_id'
58
- amount: {
59
- /** Three-character ISO-4217 code. */
60
- currency_code: string;
61
- value: string;
62
- };
63
- /** @link https://developer.paypal.com/docs/api/orders/v2/#orders_get */
64
- payments?: {
65
- captures: CapturedPayment[];
66
- };
67
- };
68
-
69
- type CapturedPayment = {
70
- seller_receivable_breakdown: {
71
- gross_amount: { value: number };
72
- paypal_fee: { value: number };
73
- net_amount: { value: number };
74
- };
75
- };
76
-
77
- type Intent = "CAPTURE" | "AUTHORIZE";
78
- type Status =
79
- | "CREATED"
80
- | "SAVED"
81
- | "APPROVED"
82
- | "VOIDED"
83
- | "COMPLETED"
84
- | "PAYER_ACTION_REQUIRED";
85
- }
@@ -1,50 +0,0 @@
1
- import {
2
- DeleteCommand,
3
- PutCommand,
4
- UpdateCommand,
5
- } from "@aws-sdk/lib-dynamodb";
6
- import { Db, UpdateBuilder } from "@better-giving/db";
7
- import type { ISubscription } from "./interfaces.mjs";
8
-
9
- type K = keyof ISubscription;
10
- export class SubsDb extends Db {
11
- static readonly table = "subscriptions";
12
-
13
- key(id: string) {
14
- return { subscription_id: id } satisfies Pick<
15
- ISubscription,
16
- "subscription_id"
17
- >;
18
- }
19
- async put(data: ISubscription) {
20
- const cmd = new PutCommand({
21
- TableName: SubsDb.table,
22
- Item: data,
23
- ConditionExpression: `attribute_not_exists(${"subscription_id" satisfies K})`,
24
- });
25
- return this.client.send(cmd);
26
- }
27
- async update(
28
- id: string,
29
- data: Partial<Omit<ISubscription, "subscription_id">>
30
- ): Promise<ISubscription> {
31
- const upd8 = new UpdateBuilder();
32
- for (const k in data) {
33
- upd8.set(k as K, (data as any)[k]);
34
- }
35
- const cmd = new UpdateCommand({
36
- TableName: SubsDb.table,
37
- Key: this.key(id),
38
- ...upd8.collect(),
39
- });
40
- return this.client.send(cmd).then((r) => r.Attributes as any);
41
- }
42
-
43
- async del(id: string) {
44
- const cmd = new DeleteCommand({
45
- TableName: SubsDb.table,
46
- Key: this.key(id),
47
- });
48
- return this.client.send(cmd);
49
- }
50
- }