@better-giving/endowment 1.0.24 → 1.0.26
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 +50 -0
- package/dist/db.d.mts +97 -0
- package/dist/index.d.mts +15 -0
- package/dist/schema.d.mts +770 -0
- package/dist/schema.mjs +10 -1
- package/package.json +7 -22
- package/src/cloudsearch.mts +8 -5
- package/src/db.mts +25 -31
- package/src/index.mts +17 -44
- package/src/schema.mts +28 -17
package/dist/schema.mjs
CHANGED
|
@@ -86,8 +86,15 @@ export const endowment = object({
|
|
|
86
86
|
/** endowment is not claimed if `false` only */
|
|
87
87
|
claimed: boolean(),
|
|
88
88
|
kyc_donors_only: boolean(),
|
|
89
|
+
fiscal_sponsored: boolean(),
|
|
89
90
|
});
|
|
90
|
-
export const endowUpdate = partial(omit(endowment, [
|
|
91
|
+
export const endowUpdate = partial(omit(endowment, [
|
|
92
|
+
"id",
|
|
93
|
+
"claimed",
|
|
94
|
+
"kyc_donors_only",
|
|
95
|
+
"env",
|
|
96
|
+
"fiscal_sponsored",
|
|
97
|
+
]));
|
|
91
98
|
export const endowFields = keyof(endowment);
|
|
92
99
|
/** for ein path, only fields in reg-num/env gsi is available */
|
|
93
100
|
export const endowQueryParams = object({
|
|
@@ -114,6 +121,8 @@ export const newProgram = object({
|
|
|
114
121
|
});
|
|
115
122
|
export const program = object({
|
|
116
123
|
...omit(newProgram, ["milestones"]).entries,
|
|
124
|
+
/** in USD */
|
|
125
|
+
totalDonations: optional(number()),
|
|
117
126
|
id: programId,
|
|
118
127
|
});
|
|
119
128
|
export const programUpdate = partial(omit(newProgram, ["milestones"]));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-giving/endowment",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@better-giving/schemas": "1.0.1",
|
|
6
6
|
"@better-giving/types": "1.0.1",
|
|
@@ -9,30 +9,15 @@
|
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@better-giving/config": "workspace:*"
|
|
11
11
|
},
|
|
12
|
-
"files": [
|
|
13
|
-
"src",
|
|
14
|
-
"dist"
|
|
15
|
-
],
|
|
12
|
+
"files": ["src", "dist"],
|
|
16
13
|
"exports": {
|
|
17
|
-
".":
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"./schema": {
|
|
22
|
-
"types": "./src/schema.mts",
|
|
23
|
-
"default": "./dist/schema.mjs"
|
|
24
|
-
},
|
|
25
|
-
"./db": {
|
|
26
|
-
"types": "./src/db.mts",
|
|
27
|
-
"default": "./dist/db.mjs"
|
|
28
|
-
},
|
|
29
|
-
"./cloudsearch": {
|
|
30
|
-
"types": "./src/cloudsearch.mts",
|
|
31
|
-
"default": "./dist/cloudsearch.mjs"
|
|
32
|
-
}
|
|
14
|
+
".": "./dist/index.mjs",
|
|
15
|
+
"./schema": "./dist/schema.mjs",
|
|
16
|
+
"./db": "./dist/db.mjs",
|
|
17
|
+
"./cloudsearch": "./dist/cloudsearch.mjs"
|
|
33
18
|
},
|
|
34
19
|
"scripts": {
|
|
35
20
|
"publish": "npm publish --access public",
|
|
36
|
-
"build": "tsc --outDir dist
|
|
21
|
+
"build": "tsc --outDir dist"
|
|
37
22
|
}
|
|
38
23
|
}
|
package/src/cloudsearch.mts
CHANGED
|
@@ -80,17 +80,20 @@ export const endowsQueryParams = object({
|
|
|
80
80
|
fields: optional(pipe(csvStrs, array(cloudSearchEndowFields))),
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
export
|
|
83
|
+
export interface CloudsearchEndowsQueryParams
|
|
84
|
+
extends InferInput<typeof endowsQueryParams> {}
|
|
84
85
|
|
|
85
|
-
export
|
|
86
|
+
export interface CloudsearchEndow
|
|
87
|
+
extends InferOutput<typeof cloudsearchEndow> {}
|
|
86
88
|
|
|
87
89
|
type DocId = `${Environment}-${number}`;
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
interface Doc extends ToDoc<CloudsearchEndow> {
|
|
90
92
|
documentId: DocId;
|
|
91
93
|
_score: number;
|
|
92
|
-
}
|
|
94
|
+
}
|
|
93
95
|
|
|
94
|
-
export
|
|
96
|
+
export interface HitFields
|
|
97
|
+
extends ToHitFields<Omit<Doc, "documentId" | "_score">> {}
|
|
95
98
|
|
|
96
99
|
export type Update = ToUpdate<DocId, CloudsearchEndow>;
|
package/src/db.mts
CHANGED
|
@@ -41,8 +41,6 @@ export namespace Endow {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
export type NonKeyAttributes = EndowmentShape & {
|
|
44
|
-
fiscal_sponsored: boolean;
|
|
45
|
-
|
|
46
44
|
/** in USD @deprecated */
|
|
47
45
|
payout_minimum?: number;
|
|
48
46
|
/** @deprecated */
|
|
@@ -53,77 +51,73 @@ export namespace Endow {
|
|
|
53
51
|
sfCompounded?: boolean;
|
|
54
52
|
};
|
|
55
53
|
|
|
56
|
-
export
|
|
54
|
+
export interface DbRecord extends Keys, NonKeyAttributes {}
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
export namespace RegNumEnvGsi {
|
|
60
58
|
export type Name = typeof endowGsi.regnumEnv;
|
|
61
|
-
export
|
|
62
|
-
Endow.NonKeyAttributes,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Pick<Endow.NonKeyAttributes, "claimed" | "name" | "hq_country" | "id">;
|
|
59
|
+
export interface Keys
|
|
60
|
+
extends Pick<Endow.NonKeyAttributes, "registration_number" | "env"> {}
|
|
61
|
+
export interface DbRecord
|
|
62
|
+
extends Keys,
|
|
63
|
+
Endow.Keys,
|
|
64
|
+
Pick<Endow.NonKeyAttributes, "claimed" | "name" | "hq_country" | "id"> {}
|
|
68
65
|
}
|
|
69
66
|
|
|
70
67
|
export namespace SlugEnvGsi {
|
|
71
68
|
export type Name = typeof endowGsi.slugEnv;
|
|
72
|
-
export
|
|
73
|
-
export
|
|
69
|
+
export interface Keys extends Pick<Endow.NonKeyAttributes, "slug" | "env"> {}
|
|
70
|
+
export interface DbRecord extends Endow.DbRecord {} //all attributes are copied to this index
|
|
74
71
|
}
|
|
75
72
|
|
|
76
73
|
export namespace Program {
|
|
77
|
-
export
|
|
74
|
+
export interface Keys {
|
|
78
75
|
PK: `Endow#${number}#${Environment}`;
|
|
79
76
|
SK: `Prog#${ProgramId}`;
|
|
80
|
-
}
|
|
77
|
+
}
|
|
81
78
|
|
|
82
|
-
export
|
|
83
|
-
|
|
84
|
-
totalDonations?: number;
|
|
85
|
-
};
|
|
86
|
-
export type DbRecord = Keys & NonKeyAttributes;
|
|
79
|
+
export interface NonKeyAttributes extends ProgramShape {}
|
|
80
|
+
export interface DbRecord extends Keys, NonKeyAttributes {}
|
|
87
81
|
}
|
|
88
82
|
|
|
89
83
|
export namespace Milestone {
|
|
90
|
-
export
|
|
84
|
+
export interface Keys {
|
|
91
85
|
PK: `Prog#${string}#${Environment}`;
|
|
92
86
|
SK: `Mile#${MilestoneId}`;
|
|
93
|
-
}
|
|
94
|
-
export
|
|
87
|
+
}
|
|
88
|
+
export interface DbRecord extends Keys, MilestoneShape {}
|
|
95
89
|
}
|
|
96
90
|
|
|
97
91
|
export const mediaGsi = {
|
|
98
92
|
1: "gsi1",
|
|
99
93
|
} as const;
|
|
100
94
|
export namespace Media {
|
|
101
|
-
export
|
|
95
|
+
export interface Keys {
|
|
102
96
|
PK: `Endow#${EndowId}#${Environment}`;
|
|
103
97
|
SK: `Media#${MediaId}`;
|
|
104
|
-
}
|
|
98
|
+
}
|
|
105
99
|
|
|
106
100
|
/** "0" - featured (goes before 1), "1" - not-featured */
|
|
107
101
|
export type FeaturedFlag = "0" | "1";
|
|
108
|
-
export
|
|
102
|
+
export interface NonKeyAttributes {
|
|
109
103
|
id: MediaId;
|
|
110
104
|
gsi1PK: Keys["PK"];
|
|
111
105
|
gsi1SK: `MediaList#${FeaturedFlag}#${MediaId}#${MediaType}`;
|
|
112
106
|
/** iso string */
|
|
113
107
|
dateCreated: string;
|
|
114
|
-
}
|
|
108
|
+
}
|
|
115
109
|
|
|
116
|
-
export
|
|
110
|
+
export interface VideoAttributes extends NonKeyAttributes {
|
|
117
111
|
type: Extract<MediaType, "video">;
|
|
118
112
|
url: string;
|
|
119
|
-
}
|
|
113
|
+
}
|
|
120
114
|
|
|
121
|
-
export
|
|
115
|
+
export interface VideoDbRecord extends Keys, VideoAttributes {}
|
|
122
116
|
export type DbRecord = VideoDbRecord; // | album | article
|
|
123
117
|
|
|
124
118
|
export namespace Gsi1 {
|
|
125
119
|
export type Name = (typeof mediaGsi)[1];
|
|
126
|
-
export
|
|
127
|
-
export
|
|
120
|
+
export interface Keys extends Pick<NonKeyAttributes, "gsi1PK" | "gsi1SK"> {}
|
|
121
|
+
export interface DbRecord extends Keys, NonKeyAttributes {}
|
|
128
122
|
}
|
|
129
123
|
}
|
package/src/index.mts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Milestone } from "./schema.mjs";
|
|
1
|
+
import type { Media } from "./db.mjs";
|
|
2
|
+
import type { Milestone, Program as ProgramShape } from "./schema.mjs";
|
|
3
3
|
export type {
|
|
4
4
|
Allocation,
|
|
5
5
|
DonateMethodId,
|
|
6
6
|
EndowDesignation,
|
|
7
|
-
|
|
7
|
+
Endowment as Endow,
|
|
8
|
+
EndowFields,
|
|
9
|
+
EndowQueryParams,
|
|
8
10
|
EndowUpdate,
|
|
9
11
|
Environment,
|
|
10
12
|
Increment,
|
|
13
|
+
MediaQueryParams,
|
|
14
|
+
MediaQueryParamsObj,
|
|
15
|
+
MediaType,
|
|
16
|
+
MediaUpdate,
|
|
11
17
|
Milestone,
|
|
12
18
|
MilestoneUpdate,
|
|
13
19
|
NewMilestone,
|
|
@@ -15,56 +21,23 @@ export type {
|
|
|
15
21
|
ProgramUpdate,
|
|
16
22
|
SocialMediaURLs,
|
|
17
23
|
UnSdgNum,
|
|
18
|
-
MediaQueryParams,
|
|
19
|
-
MediaQueryParamsObj,
|
|
20
|
-
MediaType,
|
|
21
|
-
MediaUpdate,
|
|
22
24
|
} from "./schema.mjs";
|
|
23
25
|
export type {
|
|
24
26
|
CloudsearchEndow as EndowItem,
|
|
25
27
|
CloudsearchEndowsQueryParams as EndowsQueryParams,
|
|
26
28
|
} from "./cloudsearch.mjs";
|
|
27
29
|
|
|
28
|
-
export
|
|
29
|
-
NEndow.DbRecord,
|
|
30
|
-
| "id"
|
|
31
|
-
| "slug"
|
|
32
|
-
| "active_in_countries"
|
|
33
|
-
| "endow_designation"
|
|
34
|
-
| "fiscal_sponsored"
|
|
35
|
-
| "hide_bg_tip"
|
|
36
|
-
| "hq_country"
|
|
37
|
-
| "image"
|
|
38
|
-
| "card_img"
|
|
39
|
-
| "kyc_donors_only"
|
|
40
|
-
| "logo"
|
|
41
|
-
| "name"
|
|
42
|
-
| "overview"
|
|
43
|
-
| "published"
|
|
44
|
-
| "registration_number"
|
|
45
|
-
| "sdgs"
|
|
46
|
-
| "social_media_urls"
|
|
47
|
-
| "street_address"
|
|
48
|
-
| "tagline"
|
|
49
|
-
| "url"
|
|
50
|
-
| "claimed"
|
|
51
|
-
| "progDonationsAllowed"
|
|
52
|
-
| "donateMethods"
|
|
53
|
-
| "allocation"
|
|
54
|
-
| "increments"
|
|
55
|
-
| "receiptMsg"
|
|
56
|
-
>;
|
|
57
|
-
|
|
58
|
-
export type Program = Omit<NProgram.DbRecord, "PK" | "SK"> & {
|
|
30
|
+
export interface Program extends ProgramShape {
|
|
59
31
|
milestones: Milestone[];
|
|
60
|
-
}
|
|
32
|
+
}
|
|
61
33
|
|
|
62
34
|
/** web-app format */
|
|
63
|
-
export
|
|
35
|
+
export interface IMedia
|
|
36
|
+
extends Omit<Media.DbRecord, "PK" | "SK" | "gsi1PK" | "gsi1SK"> {
|
|
64
37
|
featured: boolean;
|
|
65
|
-
}
|
|
38
|
+
}
|
|
66
39
|
|
|
67
|
-
export
|
|
68
|
-
items:
|
|
40
|
+
export interface MediaPage {
|
|
41
|
+
items: IMedia[];
|
|
69
42
|
nextPageKey?: string;
|
|
70
|
-
}
|
|
43
|
+
}
|
package/src/schema.mts
CHANGED
|
@@ -62,7 +62,7 @@ export const allocation = pipe(
|
|
|
62
62
|
check((x) => x.cash + x.liq + x.lock === 100, "must total to 100")
|
|
63
63
|
);
|
|
64
64
|
|
|
65
|
-
export
|
|
65
|
+
export interface Allocation extends InferOutput<typeof allocation> {}
|
|
66
66
|
|
|
67
67
|
export const endowId = pipe(number(), integer(), minValue(1));
|
|
68
68
|
export type EndowId = InferOutput<typeof endowId>;
|
|
@@ -124,7 +124,8 @@ export const social_media_urls = object({
|
|
|
124
124
|
tiktok: optional(maybeEmptyHttpsUrl),
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
-
export
|
|
127
|
+
export interface SocialMediaURLs
|
|
128
|
+
extends InferOutput<typeof social_media_urls> {}
|
|
128
129
|
|
|
129
130
|
export const MAX_RECEIPT_MSG_CHAR = 500;
|
|
130
131
|
|
|
@@ -155,7 +156,7 @@ export const increment = object({
|
|
|
155
156
|
label: incrementLabel,
|
|
156
157
|
});
|
|
157
158
|
|
|
158
|
-
export
|
|
159
|
+
export interface Increment extends InferOutput<typeof increment> {}
|
|
159
160
|
|
|
160
161
|
export const endowment = object({
|
|
161
162
|
id: endowId,
|
|
@@ -191,23 +192,30 @@ export const endowment = object({
|
|
|
191
192
|
/** endowment is not claimed if `false` only */
|
|
192
193
|
claimed: boolean(),
|
|
193
194
|
kyc_donors_only: boolean(),
|
|
195
|
+
fiscal_sponsored: boolean(),
|
|
194
196
|
});
|
|
195
197
|
|
|
196
198
|
export const endowUpdate = partial(
|
|
197
|
-
omit(endowment, [
|
|
199
|
+
omit(endowment, [
|
|
200
|
+
"id",
|
|
201
|
+
"claimed",
|
|
202
|
+
"kyc_donors_only",
|
|
203
|
+
"env",
|
|
204
|
+
"fiscal_sponsored",
|
|
205
|
+
])
|
|
198
206
|
);
|
|
199
207
|
|
|
200
208
|
export const endowFields = keyof(endowment);
|
|
201
|
-
export
|
|
202
|
-
export
|
|
203
|
-
export type
|
|
209
|
+
export interface Endowment extends InferOutput<typeof endowment> {}
|
|
210
|
+
export interface EndowUpdate extends InferOutput<typeof endowUpdate> {}
|
|
211
|
+
export type EndowFields = InferOutput<typeof endowFields>;
|
|
204
212
|
|
|
205
213
|
/** for ein path, only fields in reg-num/env gsi is available */
|
|
206
214
|
export const endowQueryParams = object({
|
|
207
215
|
fields: optional(pipe(csvStrs, array(endowFields))),
|
|
208
216
|
});
|
|
209
217
|
|
|
210
|
-
export
|
|
218
|
+
export interface EndowQueryParams extends InferInput<typeof endowQueryParams> {}
|
|
211
219
|
|
|
212
220
|
const amnt = pipe(number(), minValue(0));
|
|
213
221
|
export const programId = pipe(str, uuid());
|
|
@@ -223,11 +231,11 @@ export const newMilestone = object({
|
|
|
223
231
|
});
|
|
224
232
|
|
|
225
233
|
export const milestoneUpdate = partial(newMilestone, ["date"]);
|
|
226
|
-
export
|
|
234
|
+
export interface MilestoneUpdate extends InferOutput<typeof milestoneUpdate> {}
|
|
227
235
|
|
|
228
|
-
export
|
|
236
|
+
export interface NewMilestone extends InferOutput<typeof newMilestone> {}
|
|
229
237
|
export const milestone = object({ ...newMilestone.entries, id: milestoneId });
|
|
230
|
-
export
|
|
238
|
+
export interface Milestone extends InferOutput<typeof milestone> {}
|
|
231
239
|
|
|
232
240
|
export const newProgram = object({
|
|
233
241
|
title: str,
|
|
@@ -240,14 +248,16 @@ export const newProgram = object({
|
|
|
240
248
|
|
|
241
249
|
export const program = object({
|
|
242
250
|
...omit(newProgram, ["milestones"]).entries,
|
|
251
|
+
/** in USD */
|
|
252
|
+
totalDonations: optional(number()),
|
|
243
253
|
id: programId,
|
|
244
254
|
});
|
|
245
255
|
|
|
246
256
|
export const programUpdate = partial(omit(newProgram, ["milestones"]));
|
|
247
257
|
|
|
248
|
-
export
|
|
249
|
-
export
|
|
250
|
-
export
|
|
258
|
+
export interface NewProgram extends InferOutput<typeof newProgram> {}
|
|
259
|
+
export interface Program extends InferOutput<typeof program> {}
|
|
260
|
+
export interface ProgramUpdate extends InferOutput<typeof programUpdate> {}
|
|
251
261
|
|
|
252
262
|
export const mediaUrl = pipe(str, url());
|
|
253
263
|
/**
|
|
@@ -263,7 +273,7 @@ export const mediaUpdate = object({
|
|
|
263
273
|
url: optional(mediaUrl),
|
|
264
274
|
featured: optional(boolean()),
|
|
265
275
|
});
|
|
266
|
-
export
|
|
276
|
+
export interface MediaUpdate extends InferOutput<typeof mediaUpdate> {}
|
|
267
277
|
|
|
268
278
|
export type MediaId = InferOutput<typeof mediaKsuid>;
|
|
269
279
|
|
|
@@ -287,5 +297,6 @@ export const mediaQueryParams = object({
|
|
|
287
297
|
)
|
|
288
298
|
),
|
|
289
299
|
});
|
|
290
|
-
export
|
|
291
|
-
export
|
|
300
|
+
export interface MediaQueryParams extends InferInput<typeof mediaQueryParams> {}
|
|
301
|
+
export interface MediaQueryParamsObj
|
|
302
|
+
extends InferOutput<typeof mediaQueryParams> {}
|