@better-giving/fundraiser 3.0.32 → 3.0.33

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/db.d.mts CHANGED
@@ -40,6 +40,7 @@ export declare class FundDb extends Db {
40
40
  fund(id: string): Promise<IFund | undefined>;
41
41
  funds_get(ids: string[]): Promise<IFund[]>;
42
42
  fund_update(id: string, { target, slug, ...update }: IFundUpdate): Promise<Record<string, any>>;
43
+ fund_contrib_update_txi(id: string, amount: number): TxType["Update"];
43
44
  fund_close(fund: string): Promise<import("@aws-sdk/lib-dynamodb").UpdateCommandOutput>;
44
45
  }
45
46
  export interface IFundDb extends ReturnType<FundDb["fund_record"]> {
package/dist/db.mjs CHANGED
@@ -80,6 +80,20 @@ export class FundDb extends Db {
80
80
  });
81
81
  return this.client.send(command).then((res) => res.Attributes ?? {});
82
82
  }
83
+ fund_contrib_update_txi(id, amount) {
84
+ return {
85
+ TableName: FundDb.table,
86
+ Key: this.key_fund(id),
87
+ UpdateExpression: "SET #x = if_not_exists(#x, :zero) + :inc",
88
+ ExpressionAttributeValues: {
89
+ ":inc": amount,
90
+ ":zero": 0,
91
+ },
92
+ ExpressionAttributeNames: {
93
+ "#x": "donation_total_usd",
94
+ },
95
+ };
96
+ }
83
97
  async fund_close(fund) {
84
98
  const updates = new UpdateBuilder();
85
99
  updates.set("active", false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-giving/fundraiser",
3
- "version": "3.0.32",
3
+ "version": "3.0.33",
4
4
  "peerDependencies": {
5
5
  "valibot": "0.42.0",
6
6
  "@better-giving/schemas": "2.0.4",
package/src/db.mts CHANGED
@@ -96,6 +96,21 @@ export class FundDb extends Db {
96
96
  return this.client.send(command).then((res) => res.Attributes ?? {});
97
97
  }
98
98
 
99
+ fund_contrib_update_txi(id: string, amount: number): TxType["Update"] {
100
+ return {
101
+ TableName: FundDb.table,
102
+ Key: this.key_fund(id),
103
+ UpdateExpression: "SET #x = if_not_exists(#x, :zero) + :inc",
104
+ ExpressionAttributeValues: {
105
+ ":inc": amount,
106
+ ":zero": 0,
107
+ },
108
+ ExpressionAttributeNames: {
109
+ "#x": "donation_total_usd" satisfies keyof IFund,
110
+ },
111
+ };
112
+ }
113
+
99
114
  async fund_close(fund: string) {
100
115
  const updates = new UpdateBuilder();
101
116
  updates.set("active", false);
@@ -1,19 +0,0 @@
1
- import type { ToDoc, ToHitFields, ToUpdate } from "@better-giving/types/cloudsearch";
2
- import type { IFundInternal } from "./interfaces.mjs";
3
- import type { IFundNew } from "./schema.mjs";
4
- export interface CloudsearchFund extends Pick<IFundNew, "name" | "description" | "logo" | "banner" | "featured" | "members" | "target">, Pick<IFundInternal, "id" | "env" | "active" | "verified" | "donation_total_usd" | "creator_id" | "creator_name"> {
5
- /** iso | "9999-12-31T23:59:59Z" year 9999 */
6
- expiration: string;
7
- }
8
- /** uuidv4 */
9
- type DocId = string;
10
- type FundDoc = {
11
- documentId: DocId;
12
- _score: number;
13
- } & ToDoc<CloudsearchFund>;
14
- export type HitFields = ToHitFields<Omit<FundDoc, "documentId" | "_score">>;
15
- export type Update = ToUpdate<DocId, CloudsearchFund & {
16
- /** not returned - query: endow only member */
17
- members_csv: string;
18
- }>;
19
- export {};
@@ -1 +0,0 @@
1
- export {};