@better-giving/endowment 4.0.24 → 4.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 +16 -16
- package/dist/db.d.mts +1 -1
- package/dist/db.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +0 -1
- package/dist/interfaces.d.mts +3 -5
- package/dist/schema.d.mts +215 -177
- package/dist/schema.mjs +35 -0
- package/package.json +1 -1
- package/src/db.mts +2 -5
- package/src/index.mts +22 -5
- package/src/interfaces.mts +3 -26
- package/src/schema.mts +54 -0
- package/src/cloudsearch.mts +0 -98
package/dist/schema.mjs
CHANGED
|
@@ -134,3 +134,38 @@ export const media_search = v.object({
|
|
|
134
134
|
featured: v.optional(v.pipe($, v.transform((x) => Boolean(x)), v.boolean())),
|
|
135
135
|
limit: v.optional($int_gte1),
|
|
136
136
|
});
|
|
137
|
+
export const bool_csv = v.pipe(csv_strs, v.mapItems((x) => x === "true"), v.array(v.boolean()));
|
|
138
|
+
export const npo_item = v.object({
|
|
139
|
+
...v.pick(npo, [
|
|
140
|
+
"card_img",
|
|
141
|
+
"name",
|
|
142
|
+
"tagline",
|
|
143
|
+
"hq_country",
|
|
144
|
+
"sdgs",
|
|
145
|
+
"active_in_countries",
|
|
146
|
+
"endow_designation",
|
|
147
|
+
"registration_number",
|
|
148
|
+
"kyc_donors_only",
|
|
149
|
+
"claimed",
|
|
150
|
+
//filters
|
|
151
|
+
"env",
|
|
152
|
+
"id",
|
|
153
|
+
"published",
|
|
154
|
+
"fund_opt_in",
|
|
155
|
+
"target",
|
|
156
|
+
]).entries,
|
|
157
|
+
contributions_total: v.number(),
|
|
158
|
+
contributions_count: v.number(),
|
|
159
|
+
});
|
|
160
|
+
export const npo_item_fields = v.keyof(npo_item);
|
|
161
|
+
export const npos_search = v.object({
|
|
162
|
+
query: v.optional($),
|
|
163
|
+
page: v.optional($int_gte1),
|
|
164
|
+
endow_designation: v.optional(v.pipe(csv_strs, v.array(org_designation))),
|
|
165
|
+
sdgs: v.optional(v.pipe(csv_strs, v.mapItems((x) => +x), v.array(unsdg_num))),
|
|
166
|
+
kyc_only: v.optional(bool_csv),
|
|
167
|
+
fund_opt_in: v.optional(bool_csv),
|
|
168
|
+
claimed: v.optional(bool_csv),
|
|
169
|
+
countries: v.optional(v.pipe(csv_strs, v.array($))),
|
|
170
|
+
fields: v.optional(v.pipe(csv_strs, v.array(npo_item_fields))),
|
|
171
|
+
});
|
package/package.json
CHANGED
package/src/db.mts
CHANGED
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
} from "@aws-sdk/lib-dynamodb";
|
|
10
10
|
import {
|
|
11
11
|
Db,
|
|
12
|
+
type TxType,
|
|
12
13
|
Txs,
|
|
13
14
|
UpdateBuilder,
|
|
14
|
-
type TxType,
|
|
15
15
|
type UpdateComps,
|
|
16
16
|
} from "@better-giving/db";
|
|
17
17
|
import KSUID from "ksuid";
|
|
@@ -379,10 +379,7 @@ export class NpoDb extends Db {
|
|
|
379
379
|
});
|
|
380
380
|
return this.client.send(cmd);
|
|
381
381
|
}
|
|
382
|
-
|
|
383
|
-
id: number,
|
|
384
|
-
update: INpoUpdate
|
|
385
|
-
): Promise<TxType["Update"]> {
|
|
382
|
+
npo_update_txi(id: number, update: INpoUpdate): TxType["Update"] {
|
|
386
383
|
const upd8 = this.npo_update_comps(update);
|
|
387
384
|
return {
|
|
388
385
|
TableName: NpoDb.table,
|
package/src/index.mts
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
export * from "./interfaces.mjs";
|
|
1
|
+
export type * from "./interfaces.mjs";
|
|
2
2
|
export { NpoDb } from "./db.mjs";
|
|
3
3
|
export type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
IAllocation,
|
|
5
|
+
IIncrement,
|
|
6
|
+
IMediaSearch,
|
|
7
|
+
IMediaSearchObj,
|
|
8
|
+
IMediaUpdate,
|
|
9
|
+
IMilestone,
|
|
10
|
+
IMilestoneNew,
|
|
11
|
+
IMilestoneUpdate,
|
|
12
|
+
INpo,
|
|
13
|
+
INpoFields,
|
|
14
|
+
INpoItem,
|
|
15
|
+
INpoUpdate,
|
|
16
|
+
IProgram,
|
|
17
|
+
IProgramDb,
|
|
18
|
+
IProgramNew,
|
|
19
|
+
IProgramUpdate,
|
|
20
|
+
ISocialMediaURLs,
|
|
21
|
+
TMediaType,
|
|
22
|
+
INposSearch,
|
|
23
|
+
INposSearchObj,
|
|
24
|
+
} from "./schema.mjs";
|
package/src/interfaces.mts
CHANGED
|
@@ -1,27 +1,6 @@
|
|
|
1
1
|
import type { IPageKeyed } from "@better-giving/types/api";
|
|
2
2
|
import type { Ensure } from "@better-giving/types/utils";
|
|
3
|
-
import type {
|
|
4
|
-
import type { IMediaUpdate, INpo, TMediaType } from "./schema.mjs";
|
|
5
|
-
export type {
|
|
6
|
-
IAllocation,
|
|
7
|
-
INpo,
|
|
8
|
-
INpoFields,
|
|
9
|
-
INposSearch,
|
|
10
|
-
INpoUpdate,
|
|
11
|
-
IIncrement,
|
|
12
|
-
IMediaSearch,
|
|
13
|
-
IMediaSearchObj,
|
|
14
|
-
TMediaType,
|
|
15
|
-
IMediaUpdate,
|
|
16
|
-
IMilestone,
|
|
17
|
-
IMilestoneUpdate,
|
|
18
|
-
IMilestoneNew,
|
|
19
|
-
IProgram,
|
|
20
|
-
IProgramDb,
|
|
21
|
-
IProgramNew,
|
|
22
|
-
IProgramUpdate,
|
|
23
|
-
ISocialMediaURLs,
|
|
24
|
-
} from "./schema.mjs";
|
|
3
|
+
import type { IMediaUpdate, INpo, INpoItem, TMediaType } from "./schema.mjs";
|
|
25
4
|
|
|
26
5
|
export {
|
|
27
6
|
type OrgDesignation as EndowDesignation,
|
|
@@ -72,10 +51,8 @@ export type TNpoDbProjectedTo<T> = T extends TNpoDbKeys[]
|
|
|
72
51
|
/** 0 - true, 1 - false, 0 is lexicographically first */
|
|
73
52
|
export type TBinFlag = "0" | "1";
|
|
74
53
|
|
|
75
|
-
export interface INposPage<
|
|
76
|
-
|
|
77
|
-
> {
|
|
78
|
-
items: Pick<CloudsearchEndow, T>[];
|
|
54
|
+
export interface INposPage<T extends keyof INpoItem = keyof INpoItem> {
|
|
55
|
+
items: Pick<INpoItem, T>[];
|
|
79
56
|
page: number;
|
|
80
57
|
pages: number;
|
|
81
58
|
}
|
package/src/schema.mts
CHANGED
|
@@ -246,3 +246,57 @@ export const media_search = v.object({
|
|
|
246
246
|
});
|
|
247
247
|
export interface IMediaSearch extends v.InferInput<typeof media_search> {}
|
|
248
248
|
export interface IMediaSearchObj extends v.InferOutput<typeof media_search> {}
|
|
249
|
+
|
|
250
|
+
export const bool_csv = v.pipe(
|
|
251
|
+
csv_strs,
|
|
252
|
+
v.mapItems((x) => x === "true"),
|
|
253
|
+
v.array(v.boolean())
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
export const npo_item = v.object({
|
|
257
|
+
...v.pick(npo, [
|
|
258
|
+
"card_img",
|
|
259
|
+
"name",
|
|
260
|
+
"tagline",
|
|
261
|
+
"hq_country",
|
|
262
|
+
"sdgs",
|
|
263
|
+
"active_in_countries",
|
|
264
|
+
"endow_designation",
|
|
265
|
+
"registration_number",
|
|
266
|
+
"kyc_donors_only",
|
|
267
|
+
"claimed",
|
|
268
|
+
//filters
|
|
269
|
+
"env",
|
|
270
|
+
"id",
|
|
271
|
+
"published",
|
|
272
|
+
"fund_opt_in",
|
|
273
|
+
"target",
|
|
274
|
+
]).entries,
|
|
275
|
+
contributions_total: v.number(),
|
|
276
|
+
contributions_count: v.number(),
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
export interface INpoItem extends v.InferOutput<typeof npo_item> {}
|
|
280
|
+
|
|
281
|
+
export const npo_item_fields = v.keyof(npo_item);
|
|
282
|
+
|
|
283
|
+
export const npos_search = v.object({
|
|
284
|
+
query: v.optional($),
|
|
285
|
+
page: v.optional($int_gte1),
|
|
286
|
+
endow_designation: v.optional(v.pipe(csv_strs, v.array(org_designation))),
|
|
287
|
+
sdgs: v.optional(
|
|
288
|
+
v.pipe(
|
|
289
|
+
csv_strs,
|
|
290
|
+
v.mapItems((x) => +x),
|
|
291
|
+
v.array(unsdg_num)
|
|
292
|
+
)
|
|
293
|
+
),
|
|
294
|
+
kyc_only: v.optional(bool_csv),
|
|
295
|
+
fund_opt_in: v.optional(bool_csv),
|
|
296
|
+
claimed: v.optional(bool_csv),
|
|
297
|
+
countries: v.optional(v.pipe(csv_strs, v.array($))),
|
|
298
|
+
fields: v.optional(v.pipe(csv_strs, v.array(npo_item_fields))),
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
export interface INposSearch extends v.InferInput<typeof npos_search> {}
|
|
302
|
+
export interface INposSearchObj extends v.InferOutput<typeof npos_search> {}
|
package/src/cloudsearch.mts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { $int_gte1, org_designation, unsdg_num } from "@better-giving/schemas";
|
|
2
|
-
import type {
|
|
3
|
-
ToDoc,
|
|
4
|
-
ToHitFields,
|
|
5
|
-
ToUpdate,
|
|
6
|
-
} from "@better-giving/types/cloudsearch";
|
|
7
|
-
import type { Environment } from "@better-giving/types/list";
|
|
8
|
-
import {
|
|
9
|
-
type InferInput,
|
|
10
|
-
type InferOutput,
|
|
11
|
-
array,
|
|
12
|
-
boolean,
|
|
13
|
-
keyof,
|
|
14
|
-
mapItems,
|
|
15
|
-
number,
|
|
16
|
-
object,
|
|
17
|
-
optional,
|
|
18
|
-
pick,
|
|
19
|
-
pipe,
|
|
20
|
-
} from "valibot";
|
|
21
|
-
import { $, csv_strs, npo } from "./schema.mjs";
|
|
22
|
-
|
|
23
|
-
const boolCsv = pipe(
|
|
24
|
-
csv_strs,
|
|
25
|
-
mapItems((x) => x === "true"),
|
|
26
|
-
array(boolean())
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
export const cloudsearchEndowFields = object({
|
|
30
|
-
contributions_total: number(),
|
|
31
|
-
contributions_count: number(),
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
export const cloudsearchEndow = object({
|
|
35
|
-
...pick(npo, [
|
|
36
|
-
"card_img",
|
|
37
|
-
"name",
|
|
38
|
-
"tagline",
|
|
39
|
-
"hq_country",
|
|
40
|
-
"sdgs",
|
|
41
|
-
"active_in_countries",
|
|
42
|
-
"endow_designation",
|
|
43
|
-
"registration_number",
|
|
44
|
-
"kyc_donors_only",
|
|
45
|
-
"claimed",
|
|
46
|
-
//filters
|
|
47
|
-
"env",
|
|
48
|
-
"id",
|
|
49
|
-
"published",
|
|
50
|
-
"fund_opt_in",
|
|
51
|
-
"target",
|
|
52
|
-
]).entries,
|
|
53
|
-
...cloudsearchEndowFields.entries,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export const cloudSearchEndowFields = keyof(cloudsearchEndow);
|
|
57
|
-
|
|
58
|
-
export const endowsQueryParams = object({
|
|
59
|
-
query: optional($),
|
|
60
|
-
page: optional($int_gte1),
|
|
61
|
-
endow_designation: optional(pipe(csv_strs, array(org_designation))),
|
|
62
|
-
sdgs: optional(
|
|
63
|
-
pipe(
|
|
64
|
-
csv_strs,
|
|
65
|
-
mapItems((x) => +x),
|
|
66
|
-
array(unsdg_num)
|
|
67
|
-
)
|
|
68
|
-
),
|
|
69
|
-
kyc_only: optional(boolCsv),
|
|
70
|
-
fund_opt_in: optional(boolCsv),
|
|
71
|
-
claimed: optional(boolCsv),
|
|
72
|
-
countries: optional(pipe(csv_strs, array($))),
|
|
73
|
-
fields: optional(pipe(csv_strs, array(cloudSearchEndowFields))),
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
export interface CloudsearchEndowsQueryParamsObj
|
|
77
|
-
extends InferInput<typeof endowsQueryParams> {}
|
|
78
|
-
|
|
79
|
-
export interface CloudsearchEndowsQueryParams
|
|
80
|
-
extends InferInput<typeof endowsQueryParams> {}
|
|
81
|
-
|
|
82
|
-
export interface CloudsearchEndowsQueryParamsParsed
|
|
83
|
-
extends InferOutput<typeof endowsQueryParams> {}
|
|
84
|
-
|
|
85
|
-
export interface CloudsearchEndow
|
|
86
|
-
extends InferOutput<typeof cloudsearchEndow> {}
|
|
87
|
-
|
|
88
|
-
export type DocId = `${Environment}-${number}`;
|
|
89
|
-
|
|
90
|
-
interface Doc extends ToDoc<CloudsearchEndow> {
|
|
91
|
-
documentId: DocId;
|
|
92
|
-
_score: number;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface HitFields
|
|
96
|
-
extends ToHitFields<Omit<Doc, "documentId" | "_score">> {}
|
|
97
|
-
|
|
98
|
-
export type Update = ToUpdate<DocId, CloudsearchEndow>;
|