@better-giving/fundraiser 3.0.31 → 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 +27 -24
- package/dist/db.mjs +15 -4
- package/dist/index.d.mts +1 -1
- package/package.json +1 -1
- package/src/db.mts +19 -5
- package/src/index.mts +1 -1
- package/dist/cloudsearch.d.mts +0 -19
- package/dist/cloudsearch.mjs +0 -1
package/dist/db.d.mts
CHANGED
|
@@ -5,40 +5,43 @@ export declare class FundDb extends Db {
|
|
|
5
5
|
static readonly table = "funds";
|
|
6
6
|
static readonly slug_env_gsi = "slug-env-gsi";
|
|
7
7
|
key_fund(id: string): {
|
|
8
|
-
PK: string
|
|
9
|
-
SK: string
|
|
8
|
+
readonly PK: `Fund#${string}`;
|
|
9
|
+
readonly SK: `Fund#${string}`;
|
|
10
10
|
};
|
|
11
11
|
fund_record(data: IFund): {
|
|
12
|
-
name: string;
|
|
13
|
-
description: string;
|
|
14
|
-
banner: string;
|
|
15
|
-
logo: string;
|
|
16
|
-
members: number[];
|
|
17
|
-
videos: string[];
|
|
18
|
-
featured: boolean;
|
|
19
|
-
target: string;
|
|
20
|
-
npo_owner: number;
|
|
21
|
-
expiration?: string | undefined;
|
|
22
|
-
increments?: {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
readonly banner: string;
|
|
15
|
+
readonly logo: string;
|
|
16
|
+
readonly members: number[];
|
|
17
|
+
readonly videos: string[];
|
|
18
|
+
readonly featured: boolean;
|
|
19
|
+
readonly target: string;
|
|
20
|
+
readonly npo_owner: number;
|
|
21
|
+
readonly expiration?: string | undefined;
|
|
22
|
+
readonly increments?: {
|
|
23
23
|
value: string;
|
|
24
24
|
label: string;
|
|
25
25
|
}[] | undefined;
|
|
26
|
-
slug?: string | undefined;
|
|
27
|
-
id: string;
|
|
28
|
-
env: import("@better-giving/schemas").Environment;
|
|
29
|
-
active: boolean;
|
|
30
|
-
verified: boolean;
|
|
31
|
-
donation_total_usd: number;
|
|
32
|
-
settings: import("./interfaces.mjs").IFundSettings;
|
|
33
|
-
creator_id: string;
|
|
34
|
-
creator_name: string;
|
|
35
|
-
PK: string
|
|
36
|
-
SK: string
|
|
26
|
+
readonly slug?: string | undefined;
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly env: import("@better-giving/schemas").Environment;
|
|
29
|
+
readonly active: boolean;
|
|
30
|
+
readonly verified: boolean;
|
|
31
|
+
readonly donation_total_usd: number;
|
|
32
|
+
readonly settings: import("./interfaces.mjs").IFundSettings;
|
|
33
|
+
readonly creator_id: string;
|
|
34
|
+
readonly creator_name: string;
|
|
35
|
+
readonly PK: `Fund#${string}`;
|
|
36
|
+
readonly SK: `Fund#${string}`;
|
|
37
37
|
};
|
|
38
38
|
fund_put_txi(data: IFund): TxType["Put"];
|
|
39
39
|
/**@param id - slug or uuid */
|
|
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
|
}
|
|
46
|
+
export interface IFundDb extends ReturnType<FundDb["fund_record"]> {
|
|
47
|
+
}
|
package/dist/db.mjs
CHANGED
|
@@ -5,10 +5,7 @@ export class FundDb extends Db {
|
|
|
5
5
|
static table = "funds";
|
|
6
6
|
static slug_env_gsi = "slug-env-gsi";
|
|
7
7
|
key_fund(id) {
|
|
8
|
-
return {
|
|
9
|
-
PK: `Fund#${id}`,
|
|
10
|
-
SK: `Fund#${id}`,
|
|
11
|
-
};
|
|
8
|
+
return { PK: `Fund#${id}`, SK: `Fund#${id}` };
|
|
12
9
|
}
|
|
13
10
|
fund_record(data) {
|
|
14
11
|
return {
|
|
@@ -83,6 +80,20 @@ export class FundDb extends Db {
|
|
|
83
80
|
});
|
|
84
81
|
return this.client.send(command).then((res) => res.Attributes ?? {});
|
|
85
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
|
+
}
|
|
86
97
|
async fund_close(fund) {
|
|
87
98
|
const updates = new UpdateBuilder();
|
|
88
99
|
updates.set("active", false);
|
package/dist/index.d.mts
CHANGED
package/package.json
CHANGED
package/src/db.mts
CHANGED
|
@@ -18,16 +18,13 @@ export class FundDb extends Db {
|
|
|
18
18
|
static readonly table = "funds";
|
|
19
19
|
static readonly slug_env_gsi = "slug-env-gsi";
|
|
20
20
|
key_fund(id: string) {
|
|
21
|
-
return {
|
|
22
|
-
PK: `Fund#${id}`,
|
|
23
|
-
SK: `Fund#${id}`,
|
|
24
|
-
};
|
|
21
|
+
return { PK: `Fund#${id}`, SK: `Fund#${id}` } as const;
|
|
25
22
|
}
|
|
26
23
|
fund_record(data: IFund) {
|
|
27
24
|
return {
|
|
28
25
|
...this.key_fund(data.id),
|
|
29
26
|
...data,
|
|
30
|
-
};
|
|
27
|
+
} as const;
|
|
31
28
|
}
|
|
32
29
|
fund_put_txi(data: IFund): TxType["Put"] {
|
|
33
30
|
return {
|
|
@@ -99,6 +96,21 @@ export class FundDb extends Db {
|
|
|
99
96
|
return this.client.send(command).then((res) => res.Attributes ?? {});
|
|
100
97
|
}
|
|
101
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
|
+
|
|
102
114
|
async fund_close(fund: string) {
|
|
103
115
|
const updates = new UpdateBuilder();
|
|
104
116
|
updates.set("active", false);
|
|
@@ -112,3 +124,5 @@ export class FundDb extends Db {
|
|
|
112
124
|
return this.client.send(command);
|
|
113
125
|
}
|
|
114
126
|
}
|
|
127
|
+
|
|
128
|
+
export interface IFundDb extends ReturnType<FundDb["fund_record"]> {}
|
package/src/index.mts
CHANGED
package/dist/cloudsearch.d.mts
DELETED
|
@@ -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 {};
|
package/dist/cloudsearch.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|