@better-giving/fundraiser 1.0.0-rc.7 → 1.0.1
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/cloudsearch.d.mts +5 -5
- package/dist/db.d.mts +2 -17
- package/dist/index.d.mts +4 -3
- package/dist/schema.d.mts +31 -22
- package/dist/schema.mjs +4 -8
- package/package.json +3 -5
- package/src/cloudsearch.mts +13 -19
- package/src/db.mts +2 -19
- package/src/index.mts +4 -3
- package/src/schema.mts +34 -10
package/dist/cloudsearch.d.mts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { ToDoc, ToHitFields, ToUpdate } from "@better-giving/types/cloudsearch";
|
|
2
|
-
import type {
|
|
3
|
-
export
|
|
2
|
+
import type { NewFund, FundInternal } from "./schema.mjs";
|
|
3
|
+
export interface CloudsearchFund extends Pick<NewFund, "name" | "description" | "logo" | "featured" | "members" | "target">, Pick<FundInternal, "id" | "env" | "active" | "verified" | "donation_total_usd" | "approvers"> {
|
|
4
4
|
/** iso | "9999-12-31T23:59:59.000Z" year 9999 */
|
|
5
5
|
expiration: string;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
/** uuidv4 */
|
|
8
8
|
type DocId = string;
|
|
9
9
|
type FundDoc = {
|
|
10
10
|
documentId: DocId;
|
|
11
11
|
_score: number;
|
|
12
|
-
} & ToDoc<
|
|
12
|
+
} & ToDoc<CloudsearchFund>;
|
|
13
13
|
export type HitFields = ToHitFields<Omit<FundDoc, "documentId" | "_score">>;
|
|
14
|
-
export type Update = ToUpdate<DocId,
|
|
14
|
+
export type Update = ToUpdate<DocId, CloudsearchFund & {
|
|
15
15
|
/** not returned - query: endow only member */
|
|
16
16
|
members_csv: string;
|
|
17
17
|
}>;
|
package/dist/db.d.mts
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { NewFund } from "./schema.mjs";
|
|
1
|
+
import type { FundInternal, NewFund } from "./schema.mjs";
|
|
3
2
|
export interface Keys {
|
|
4
3
|
/** Fund#${uuid} */
|
|
5
4
|
PK: `Fund#${string}`;
|
|
6
5
|
SK: `Fund#${string}`;
|
|
7
6
|
}
|
|
8
|
-
export interface Attributes extends NewFund {
|
|
9
|
-
/** uuid */
|
|
10
|
-
id: string;
|
|
11
|
-
env: Environment;
|
|
12
|
-
/** fund can be closed before expiration */
|
|
13
|
-
active: boolean;
|
|
14
|
-
verified: boolean;
|
|
15
|
-
/** to date received: initialized to `0` */
|
|
16
|
-
donation_total_usd: number;
|
|
17
|
-
/**
|
|
18
|
-
* approving NPO ids
|
|
19
|
-
* NPOs have a whitelist of fundraisers they support. thus, appears in their NPO profile page
|
|
20
|
-
* @default - [0]
|
|
21
|
-
* */
|
|
22
|
-
approvers: number[];
|
|
7
|
+
export interface Attributes extends NewFund, FundInternal {
|
|
23
8
|
}
|
|
24
9
|
export interface DbRecord extends Keys, Attributes {
|
|
25
10
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { CloudsearchFund as FundItem } from "./cloudsearch.mjs";
|
|
2
|
+
import type { NewFund } from "./schema.mjs";
|
|
3
|
+
export type { Environment } from "./schema.mjs";
|
|
3
4
|
export type { FundItem };
|
|
4
5
|
export interface FundMember {
|
|
5
6
|
id: number;
|
|
6
7
|
name: string;
|
|
7
8
|
card_img?: string;
|
|
8
9
|
}
|
|
9
|
-
export interface SingleFund extends Omit<
|
|
10
|
+
export interface SingleFund extends Omit<NewFund, "members"> {
|
|
10
11
|
members: FundMember[];
|
|
11
12
|
}
|
|
12
13
|
export interface FundsPage {
|
package/dist/schema.d.mts
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
+
import type { Environment } from "@better-giving/types/list";
|
|
2
|
+
export type { Environment } from "@better-giving/types/list";
|
|
1
3
|
import { type InferOutput } from "valibot";
|
|
2
4
|
export declare const fundId: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").UuidAction<string, undefined>]>;
|
|
3
|
-
export declare const settings: import("valibot").ObjectSchema<{
|
|
4
|
-
readonly allowBgTip: import("valibot").BooleanSchema<undefined>;
|
|
5
|
-
}, undefined>;
|
|
6
5
|
export declare const newFund: import("valibot").ObjectSchema<{
|
|
7
6
|
readonly name: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]>;
|
|
8
7
|
readonly description: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]>;
|
|
9
8
|
readonly banner: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").UrlAction<string, undefined>]>;
|
|
10
9
|
readonly logo: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").UrlAction<string, undefined>]>;
|
|
11
10
|
/** endowment ids */
|
|
12
|
-
readonly members: import("valibot").ArraySchema<import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>, undefined>;
|
|
11
|
+
readonly members: import("valibot").SchemaWithPipe<[import("valibot").ArraySchema<import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>, undefined>, import("valibot").NonEmptyAction<number[], undefined>, import("valibot").MaxLengthAction<number[], 10, undefined>]>;
|
|
13
12
|
readonly featured: import("valibot").BooleanSchema<undefined>;
|
|
14
13
|
readonly expiration: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").IsoTimestampAction<string, "invalid date">, import("valibot").MinValueAction<string, string, undefined>]>, never>;
|
|
15
|
-
readonly settings: import("valibot").ObjectSchema<{
|
|
16
|
-
readonly allowBgTip: import("valibot").BooleanSchema<undefined>;
|
|
17
|
-
}, undefined>;
|
|
18
14
|
/** `"0"` - none, {"number"} = fixed */
|
|
19
15
|
readonly target: import("valibot").UnionSchema<[import("valibot").LiteralSchema<"smart", undefined>, import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TransformAction<string, number>, import("valibot").NumberSchema<undefined>, import("valibot").MinValueAction<number, 0, undefined>, import("valibot").TransformAction<number, string>]>], undefined>;
|
|
20
16
|
}, undefined>;
|
|
@@ -24,12 +20,9 @@ export declare const fundUpdate: Omit<Omit<import("valibot").ObjectSchema<{
|
|
|
24
20
|
readonly banner: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").UrlAction<string, undefined>]>;
|
|
25
21
|
readonly logo: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").UrlAction<string, undefined>]>;
|
|
26
22
|
/** endowment ids */
|
|
27
|
-
readonly members: import("valibot").ArraySchema<import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>, undefined>;
|
|
23
|
+
readonly members: import("valibot").SchemaWithPipe<[import("valibot").ArraySchema<import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>, undefined>, import("valibot").NonEmptyAction<number[], undefined>, import("valibot").MaxLengthAction<number[], 10, undefined>]>;
|
|
28
24
|
readonly featured: import("valibot").BooleanSchema<undefined>;
|
|
29
25
|
readonly expiration: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").IsoTimestampAction<string, "invalid date">, import("valibot").MinValueAction<string, string, undefined>]>, never>;
|
|
30
|
-
readonly settings: import("valibot").ObjectSchema<{
|
|
31
|
-
readonly allowBgTip: import("valibot").BooleanSchema<undefined>;
|
|
32
|
-
}, undefined>;
|
|
33
26
|
/** `"0"` - none, {"number"} = fixed */
|
|
34
27
|
readonly target: import("valibot").UnionSchema<[import("valibot").LiteralSchema<"smart", undefined>, import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TransformAction<string, number>, import("valibot").NumberSchema<undefined>, import("valibot").MinValueAction<number, 0, undefined>, import("valibot").TransformAction<number, string>]>], undefined>;
|
|
35
28
|
}, undefined>, "_types" | "_run" | "entries"> & {
|
|
@@ -39,23 +32,20 @@ export declare const fundUpdate: Omit<Omit<import("valibot").ObjectSchema<{
|
|
|
39
32
|
readonly banner: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").UrlAction<string, undefined>]>;
|
|
40
33
|
readonly logo: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").UrlAction<string, undefined>]>;
|
|
41
34
|
/** endowment ids */
|
|
42
|
-
readonly members: import("valibot").ArraySchema<import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>, undefined>;
|
|
35
|
+
readonly members: import("valibot").SchemaWithPipe<[import("valibot").ArraySchema<import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>, undefined>, import("valibot").NonEmptyAction<number[], undefined>, import("valibot").MaxLengthAction<number[], 10, undefined>]>;
|
|
43
36
|
readonly featured: import("valibot").BooleanSchema<undefined>;
|
|
44
37
|
readonly expiration: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").IsoTimestampAction<string, "invalid date">, import("valibot").MinValueAction<string, string, undefined>]>, never>;
|
|
45
|
-
readonly settings: import("valibot").ObjectSchema<{
|
|
46
|
-
readonly allowBgTip: import("valibot").BooleanSchema<undefined>;
|
|
47
|
-
}, undefined>;
|
|
48
38
|
/** `"0"` - none, {"number"} = fixed */
|
|
49
39
|
readonly target: import("valibot").UnionSchema<[import("valibot").LiteralSchema<"smart", undefined>, import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TransformAction<string, number>, import("valibot").NumberSchema<undefined>, import("valibot").MinValueAction<number, 0, undefined>, import("valibot").TransformAction<number, string>]>], undefined>;
|
|
50
40
|
}, "name" | "description" | "banner" | "logo" | "target" | "featured">;
|
|
51
|
-
_run(dataset: import("valibot").Dataset<unknown, never>, config: import("valibot").Config<import("valibot").StringIssue | import("valibot").
|
|
41
|
+
_run(dataset: import("valibot").Dataset<unknown, never>, config: import("valibot").Config<import("valibot").StringIssue | import("valibot").NonEmptyIssue<string> | import("valibot").UrlIssue<string> | import("valibot").NumberIssue | import("valibot").BooleanIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0> | import("valibot").UnionIssue<import("valibot").StringIssue | import("valibot").NumberIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0>> | import("valibot").ObjectIssue>): import("valibot").Dataset<{
|
|
52
42
|
name: string;
|
|
53
43
|
description: string;
|
|
54
44
|
banner: string;
|
|
55
45
|
logo: string;
|
|
56
46
|
target: string;
|
|
57
47
|
featured: boolean;
|
|
58
|
-
}, import("valibot").StringIssue | import("valibot").
|
|
48
|
+
}, import("valibot").StringIssue | import("valibot").NonEmptyIssue<string> | import("valibot").UrlIssue<string> | import("valibot").NumberIssue | import("valibot").BooleanIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0> | import("valibot").UnionIssue<import("valibot").StringIssue | import("valibot").NumberIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0>> | import("valibot").ObjectIssue>;
|
|
59
49
|
readonly _types?: {
|
|
60
50
|
readonly input: {
|
|
61
51
|
name: string;
|
|
@@ -73,7 +63,7 @@ export declare const fundUpdate: Omit<Omit<import("valibot").ObjectSchema<{
|
|
|
73
63
|
target: string;
|
|
74
64
|
featured: boolean;
|
|
75
65
|
};
|
|
76
|
-
readonly issue: import("valibot").StringIssue | import("valibot").
|
|
66
|
+
readonly issue: import("valibot").StringIssue | import("valibot").NonEmptyIssue<string> | import("valibot").UrlIssue<string> | import("valibot").NumberIssue | import("valibot").BooleanIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0> | import("valibot").UnionIssue<import("valibot").StringIssue | import("valibot").NumberIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0>> | import("valibot").ObjectIssue;
|
|
77
67
|
} | undefined;
|
|
78
68
|
}, "_types" | "_run" | "entries"> & {
|
|
79
69
|
readonly entries: {
|
|
@@ -84,14 +74,14 @@ export declare const fundUpdate: Omit<Omit<import("valibot").ObjectSchema<{
|
|
|
84
74
|
readonly target: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").LiteralSchema<"smart", undefined>, import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TransformAction<string, number>, import("valibot").NumberSchema<undefined>, import("valibot").MinValueAction<number, 0, undefined>, import("valibot").TransformAction<number, string>]>], undefined>, never>;
|
|
85
75
|
readonly featured: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
86
76
|
};
|
|
87
|
-
_run(dataset: import("valibot").Dataset<unknown, never>, config: import("valibot").Config<import("valibot").StringIssue | import("valibot").
|
|
77
|
+
_run(dataset: import("valibot").Dataset<unknown, never>, config: import("valibot").Config<import("valibot").StringIssue | import("valibot").NonEmptyIssue<string> | import("valibot").UrlIssue<string> | import("valibot").NumberIssue | import("valibot").BooleanIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0> | import("valibot").UnionIssue<import("valibot").StringIssue | import("valibot").NumberIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0>> | import("valibot").ObjectIssue>): import("valibot").Dataset<{
|
|
88
78
|
name?: string | undefined;
|
|
89
79
|
description?: string | undefined;
|
|
90
80
|
banner?: string | undefined;
|
|
91
81
|
logo?: string | undefined;
|
|
92
82
|
target?: string | undefined;
|
|
93
83
|
featured?: boolean | undefined;
|
|
94
|
-
}, import("valibot").StringIssue | import("valibot").
|
|
84
|
+
}, import("valibot").StringIssue | import("valibot").NonEmptyIssue<string> | import("valibot").UrlIssue<string> | import("valibot").NumberIssue | import("valibot").BooleanIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0> | import("valibot").UnionIssue<import("valibot").StringIssue | import("valibot").NumberIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0>> | import("valibot").ObjectIssue>;
|
|
95
85
|
readonly _types?: {
|
|
96
86
|
readonly input: {
|
|
97
87
|
name?: string | undefined;
|
|
@@ -109,7 +99,7 @@ export declare const fundUpdate: Omit<Omit<import("valibot").ObjectSchema<{
|
|
|
109
99
|
target?: string | undefined;
|
|
110
100
|
featured?: boolean | undefined;
|
|
111
101
|
};
|
|
112
|
-
readonly issue: import("valibot").StringIssue | import("valibot").
|
|
102
|
+
readonly issue: import("valibot").StringIssue | import("valibot").NonEmptyIssue<string> | import("valibot").UrlIssue<string> | import("valibot").NumberIssue | import("valibot").BooleanIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0> | import("valibot").UnionIssue<import("valibot").StringIssue | import("valibot").NumberIssue | import("valibot").LiteralIssue | import("valibot").MinValueIssue<number, 0>> | import("valibot").ObjectIssue;
|
|
113
103
|
} | undefined;
|
|
114
104
|
};
|
|
115
105
|
export declare const fundsParams: import("valibot").ObjectSchema<{
|
|
@@ -119,7 +109,7 @@ export declare const fundsParams: import("valibot").ObjectSchema<{
|
|
|
119
109
|
readonly page: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").TransformAction<string, number>, import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>, never>;
|
|
120
110
|
}, undefined>;
|
|
121
111
|
export declare const fundsEndowMemberOfParams: import("valibot").ObjectSchema<{
|
|
122
|
-
readonly npoProfileFeatured: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").TransformAction<string, boolean>, import("valibot").BooleanSchema<undefined>]>;
|
|
112
|
+
readonly npoProfileFeatured: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").TransformAction<string, boolean>, import("valibot").BooleanSchema<undefined>]>, never>;
|
|
123
113
|
}, undefined>;
|
|
124
114
|
export interface NewFund extends InferOutput<typeof newFund> {
|
|
125
115
|
}
|
|
@@ -129,3 +119,22 @@ export interface FundsParams extends InferOutput<typeof fundsParams> {
|
|
|
129
119
|
}
|
|
130
120
|
export interface FundsEndowMemberOfParams extends InferOutput<typeof fundsEndowMemberOfParams> {
|
|
131
121
|
}
|
|
122
|
+
export interface FundInternal {
|
|
123
|
+
/** uuid */
|
|
124
|
+
id: string;
|
|
125
|
+
env: Environment;
|
|
126
|
+
/** fund can be closed before expiration */
|
|
127
|
+
active: boolean;
|
|
128
|
+
verified: boolean;
|
|
129
|
+
/** to date received: initialized to `0` */
|
|
130
|
+
donation_total_usd: number;
|
|
131
|
+
/**
|
|
132
|
+
* approving NPO ids
|
|
133
|
+
* NPOs have a whitelist of fundraisers they support. thus, appears in their NPO profile page
|
|
134
|
+
* @default - [0]
|
|
135
|
+
* */
|
|
136
|
+
approvers: number[];
|
|
137
|
+
allow_bg_tip: boolean;
|
|
138
|
+
/** user email or better giving (if creator is bg-admin) */
|
|
139
|
+
creator: string;
|
|
140
|
+
}
|
package/dist/schema.mjs
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import { url, array, boolean, integer, isoTimestamp, literal, minValue, nonEmpty, number, object, optional, partial, pick, pipe, string, transform, trim, union, uuid, } from "valibot";
|
|
1
|
+
import { url, array, boolean, integer, isoTimestamp, literal, maxLength, minValue, nonEmpty, number, object, optional, partial, pick, pipe, string, transform, trim, union, uuid, } from "valibot";
|
|
2
2
|
const str = pipe(string(), trim());
|
|
3
3
|
export const fundId = pipe(str, uuid());
|
|
4
|
-
export const settings = object({
|
|
5
|
-
allowBgTip: boolean(),
|
|
6
|
-
});
|
|
7
4
|
export const newFund = object({
|
|
8
5
|
name: pipe(str, nonEmpty("required")),
|
|
9
6
|
description: pipe(str, nonEmpty("required")),
|
|
10
7
|
banner: pipe(str, url()),
|
|
11
8
|
logo: pipe(str, url()),
|
|
12
9
|
/** endowment ids */
|
|
13
|
-
members: array(pipe(number(), integer(), minValue(1))),
|
|
10
|
+
members: pipe(array(pipe(number(), integer(), minValue(1))), nonEmpty(), maxLength(10)),
|
|
14
11
|
featured: boolean(),
|
|
15
12
|
expiration: optional(pipe(str, isoTimestamp("invalid date"), minValue(new Date().toISOString()) //created each parsing
|
|
16
13
|
)),
|
|
17
|
-
settings,
|
|
18
14
|
/** `"0"` - none, {"number"} = fixed */
|
|
19
15
|
target: union([
|
|
20
16
|
literal("smart"),
|
|
@@ -26,7 +22,7 @@ export const fundsParams = object({
|
|
|
26
22
|
/** search text */
|
|
27
23
|
query: optional(str),
|
|
28
24
|
/** input str: from url */
|
|
29
|
-
page: optional(pipe(str, transform(x => +x), number(), integer(), minValue(1))),
|
|
25
|
+
page: optional(pipe(str, transform((x) => +x), number(), integer(), minValue(1))),
|
|
30
26
|
});
|
|
31
27
|
export const fundsEndowMemberOfParams = object({
|
|
32
28
|
/*
|
|
@@ -37,5 +33,5 @@ export const fundsEndowMemberOfParams = object({
|
|
|
37
33
|
*
|
|
38
34
|
* input str: from url
|
|
39
35
|
*/
|
|
40
|
-
npoProfileFeatured: pipe(str, transform(x => x === "true"), boolean()),
|
|
36
|
+
npoProfileFeatured: optional(pipe(str, transform((x) => x === "true"), boolean())),
|
|
41
37
|
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-giving/fundraiser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@better-giving/types": "1.0.
|
|
6
|
-
"valibot": "0.42.0"
|
|
5
|
+
"@better-giving/types": "1.0.1"
|
|
7
6
|
},
|
|
8
7
|
"devDependencies": {
|
|
9
8
|
"@better-giving/config": "workspace:*"
|
|
@@ -20,7 +19,6 @@
|
|
|
20
19
|
},
|
|
21
20
|
"scripts": {
|
|
22
21
|
"publish": "npm publish --access public",
|
|
23
|
-
"build": "tsc --outDir dist"
|
|
24
|
-
"type-chek": "tsc --noEmit"
|
|
22
|
+
"build": "tsc --outDir dist"
|
|
25
23
|
}
|
|
26
24
|
}
|
package/src/cloudsearch.mts
CHANGED
|
@@ -3,39 +3,33 @@ import type {
|
|
|
3
3
|
ToHitFields,
|
|
4
4
|
ToUpdate,
|
|
5
5
|
} from "@better-giving/types/cloudsearch";
|
|
6
|
-
import type {
|
|
6
|
+
import type { FundInternal, NewFund } from "./schema.mjs";
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
| "verified"
|
|
18
|
-
| "donation_total_usd"
|
|
19
|
-
| "members"
|
|
20
|
-
| "target"
|
|
21
|
-
| "approvers"
|
|
22
|
-
> & {
|
|
8
|
+
export interface CloudsearchFund
|
|
9
|
+
extends Pick<
|
|
10
|
+
NewFund,
|
|
11
|
+
"name" | "description" | "logo" | "featured" | "members" | "target"
|
|
12
|
+
>,
|
|
13
|
+
Pick<
|
|
14
|
+
FundInternal,
|
|
15
|
+
"id" | "env" | "active" | "verified" | "donation_total_usd" | "approvers"
|
|
16
|
+
> {
|
|
23
17
|
/** iso | "9999-12-31T23:59:59.000Z" year 9999 */
|
|
24
18
|
expiration: string;
|
|
25
|
-
}
|
|
19
|
+
}
|
|
26
20
|
|
|
27
21
|
/** uuidv4 */
|
|
28
22
|
type DocId = string;
|
|
29
23
|
type FundDoc = {
|
|
30
24
|
documentId: DocId;
|
|
31
25
|
_score: number;
|
|
32
|
-
} & ToDoc<
|
|
26
|
+
} & ToDoc<CloudsearchFund>;
|
|
33
27
|
|
|
34
28
|
export type HitFields = ToHitFields<Omit<FundDoc, "documentId" | "_score">>;
|
|
35
29
|
|
|
36
30
|
export type Update = ToUpdate<
|
|
37
31
|
DocId,
|
|
38
|
-
|
|
32
|
+
CloudsearchFund & {
|
|
39
33
|
/** not returned - query: endow only member */
|
|
40
34
|
members_csv: string;
|
|
41
35
|
}
|
package/src/db.mts
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { NewFund } from "./schema.mjs";
|
|
1
|
+
import type { FundInternal, NewFund } from "./schema.mjs";
|
|
3
2
|
export interface Keys {
|
|
4
3
|
/** Fund#${uuid} */
|
|
5
4
|
PK: `Fund#${string}`;
|
|
6
5
|
SK: `Fund#${string}`;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
|
-
export interface Attributes extends NewFund {
|
|
10
|
-
/** uuid */
|
|
11
|
-
id: string;
|
|
12
|
-
env: Environment;
|
|
13
|
-
/** fund can be closed before expiration */
|
|
14
|
-
active: boolean;
|
|
15
|
-
verified: boolean;
|
|
16
|
-
/** to date received: initialized to `0` */
|
|
17
|
-
donation_total_usd: number;
|
|
18
|
-
/**
|
|
19
|
-
* approving NPO ids
|
|
20
|
-
* NPOs have a whitelist of fundraisers they support. thus, appears in their NPO profile page
|
|
21
|
-
* @default - [0]
|
|
22
|
-
* */
|
|
23
|
-
approvers: number[];
|
|
24
|
-
}
|
|
25
|
-
|
|
8
|
+
export interface Attributes extends NewFund, FundInternal {}
|
|
26
9
|
export interface DbRecord extends Keys, Attributes {}
|
package/src/index.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { CloudsearchFund as FundItem } from "./cloudsearch.mjs";
|
|
2
|
+
import type { NewFund } from "./schema.mjs";
|
|
3
|
+
export type { Environment } from "./schema.mjs";
|
|
3
4
|
export type { FundItem };
|
|
4
5
|
|
|
5
6
|
export interface FundMember {
|
|
@@ -8,7 +9,7 @@ export interface FundMember {
|
|
|
8
9
|
card_img?: string;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export interface SingleFund extends Omit<
|
|
12
|
+
export interface SingleFund extends Omit<NewFund, "members"> {
|
|
12
13
|
members: FundMember[];
|
|
13
14
|
}
|
|
14
15
|
|
package/src/schema.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Environment } from "@better-giving/types/list";
|
|
2
|
+
export type { Environment } from "@better-giving/types/list";
|
|
1
3
|
import {
|
|
2
4
|
url,
|
|
3
5
|
type InferOutput,
|
|
@@ -6,6 +8,7 @@ import {
|
|
|
6
8
|
integer,
|
|
7
9
|
isoTimestamp,
|
|
8
10
|
literal,
|
|
11
|
+
maxLength,
|
|
9
12
|
minValue,
|
|
10
13
|
nonEmpty,
|
|
11
14
|
number,
|
|
@@ -25,17 +28,17 @@ const str = pipe(string(), trim());
|
|
|
25
28
|
|
|
26
29
|
export const fundId = pipe(str, uuid());
|
|
27
30
|
|
|
28
|
-
export const settings = object({
|
|
29
|
-
allowBgTip: boolean(),
|
|
30
|
-
});
|
|
31
|
-
|
|
32
31
|
export const newFund = object({
|
|
33
32
|
name: pipe(str, nonEmpty("required")),
|
|
34
33
|
description: pipe(str, nonEmpty("required")),
|
|
35
34
|
banner: pipe(str, url()),
|
|
36
35
|
logo: pipe(str, url()),
|
|
37
36
|
/** endowment ids */
|
|
38
|
-
members:
|
|
37
|
+
members: pipe(
|
|
38
|
+
array(pipe(number(), integer(), minValue(1))),
|
|
39
|
+
nonEmpty(),
|
|
40
|
+
maxLength(10)
|
|
41
|
+
),
|
|
39
42
|
featured: boolean(),
|
|
40
43
|
expiration: optional(
|
|
41
44
|
pipe(
|
|
@@ -44,7 +47,6 @@ export const newFund = object({
|
|
|
44
47
|
minValue(new Date().toISOString()) //created each parsing
|
|
45
48
|
)
|
|
46
49
|
),
|
|
47
|
-
settings,
|
|
48
50
|
/** `"0"` - none, {"number"} = fixed */
|
|
49
51
|
target: union([
|
|
50
52
|
literal("smart"),
|
|
@@ -86,10 +88,12 @@ export const fundsEndowMemberOfParams = object({
|
|
|
86
88
|
*
|
|
87
89
|
* input str: from url
|
|
88
90
|
*/
|
|
89
|
-
npoProfileFeatured:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
npoProfileFeatured: optional(
|
|
92
|
+
pipe(
|
|
93
|
+
str,
|
|
94
|
+
transform((x) => x === "true"),
|
|
95
|
+
boolean()
|
|
96
|
+
)
|
|
93
97
|
),
|
|
94
98
|
});
|
|
95
99
|
|
|
@@ -98,3 +102,23 @@ export interface FundUpdate extends InferOutput<typeof fundUpdate> {}
|
|
|
98
102
|
export interface FundsParams extends InferOutput<typeof fundsParams> {}
|
|
99
103
|
export interface FundsEndowMemberOfParams
|
|
100
104
|
extends InferOutput<typeof fundsEndowMemberOfParams> {}
|
|
105
|
+
|
|
106
|
+
export interface FundInternal {
|
|
107
|
+
/** uuid */
|
|
108
|
+
id: string;
|
|
109
|
+
env: Environment;
|
|
110
|
+
/** fund can be closed before expiration */
|
|
111
|
+
active: boolean;
|
|
112
|
+
verified: boolean;
|
|
113
|
+
/** to date received: initialized to `0` */
|
|
114
|
+
donation_total_usd: number;
|
|
115
|
+
/**
|
|
116
|
+
* approving NPO ids
|
|
117
|
+
* NPOs have a whitelist of fundraisers they support. thus, appears in their NPO profile page
|
|
118
|
+
* @default - [0]
|
|
119
|
+
* */
|
|
120
|
+
approvers: number[];
|
|
121
|
+
allow_bg_tip: boolean;
|
|
122
|
+
/** user email or better giving (if creator is bg-admin) */
|
|
123
|
+
creator: string;
|
|
124
|
+
}
|