@better-giving/endowment 1.0.21 → 1.0.23
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/cloudsearch.mjs +4 -4
- package/dist/index.d.mts +1 -1
- package/dist/schema.d.mts +14 -19
- package/dist/schema.mjs +11 -19
- package/package.json +1 -1
- package/src/cloudsearch.mts +12 -2
- package/src/index.mts +0 -1
- package/src/schema.mts +22 -31
package/dist/cloudsearch.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ToDoc, ToHitFields, ToUpdate } from "@better-giving/types/cloudsearch";
|
|
2
|
+
import { type InferInput, type InferOutput } from "valibot";
|
|
2
3
|
import { type Environment } from "./schema.mjs";
|
|
3
|
-
import { type InferOutput, type InferInput } from "valibot";
|
|
4
4
|
export declare const cloudsearchEndowFields: import("valibot").ObjectSchema<{
|
|
5
5
|
readonly contributions_total: import("valibot").NumberSchema<undefined>;
|
|
6
6
|
readonly contributions_count: import("valibot").NumberSchema<undefined>;
|
|
@@ -16,14 +16,14 @@ export declare const cloudsearchEndow: import("valibot").ObjectSchema<{
|
|
|
16
16
|
readonly sdgs: import("valibot").SchemaWithPipe<[import("valibot").ArraySchema<import("valibot").PicklistSchema<readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], undefined>, undefined>, import("valibot").MinLengthAction<(2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17)[], 1, undefined>]>;
|
|
17
17
|
readonly published: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
18
18
|
readonly fund_opt_in: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
19
|
-
readonly claimed: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
20
|
-
readonly kyc_donors_only: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
21
19
|
readonly id: import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>;
|
|
22
20
|
readonly env: import("valibot").PicklistSchema<readonly ["staging", "production"], undefined>;
|
|
23
21
|
readonly registration_number: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">, import("valibot").RegexAction<string, "must only contain letters and numbers">]>;
|
|
24
22
|
readonly endow_designation: import("valibot").PicklistSchema<readonly ["Charity", "Religious Organization", "University", "Hospital", "Other"], undefined>;
|
|
23
|
+
readonly claimed: import("valibot").BooleanSchema<undefined>;
|
|
24
|
+
readonly kyc_donors_only: import("valibot").BooleanSchema<undefined>;
|
|
25
25
|
}, undefined>;
|
|
26
|
-
export declare const cloudSearchEndowFields: import("valibot").PicklistSchema<["name", "tagline", "card_img", "hq_country", "active_in_countries", "sdgs", "published", "fund_opt_in", "
|
|
26
|
+
export declare const cloudSearchEndowFields: import("valibot").PicklistSchema<["name", "tagline", "card_img", "hq_country", "active_in_countries", "sdgs", "published", "fund_opt_in", "id", "env", "registration_number", "endow_designation", "claimed", "kyc_donors_only", "contributions_total", "contributions_count"], undefined>;
|
|
27
27
|
export declare const endowsQueryParams: import("valibot").ObjectSchema<{
|
|
28
28
|
readonly query: import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>;
|
|
29
29
|
readonly page: import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TransformAction<string, number>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>;
|
|
@@ -33,7 +33,7 @@ export declare const endowsQueryParams: import("valibot").ObjectSchema<{
|
|
|
33
33
|
readonly fund_opt_in: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").RegexAction<string, "invalid csv">]>>, import("valibot").TransformAction<string, string[]>, import("valibot").FilterItemsAction<string[]>]>, import("valibot").MapItemsAction<string[], boolean>, import("valibot").ArraySchema<import("valibot").BooleanSchema<undefined>, undefined>]>, never>;
|
|
34
34
|
readonly claimed: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").RegexAction<string, "invalid csv">]>>, import("valibot").TransformAction<string, string[]>, import("valibot").FilterItemsAction<string[]>]>, import("valibot").MapItemsAction<string[], boolean>, import("valibot").ArraySchema<import("valibot").BooleanSchema<undefined>, undefined>]>, never>;
|
|
35
35
|
readonly countries: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").RegexAction<string, "invalid csv">]>>, import("valibot").TransformAction<string, string[]>, import("valibot").FilterItemsAction<string[]>]>, import("valibot").ArraySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, undefined>]>, never>;
|
|
36
|
-
readonly fields: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").RegexAction<string, "invalid csv">]>>, import("valibot").TransformAction<string, string[]>, import("valibot").FilterItemsAction<string[]>]>, import("valibot").ArraySchema<import("valibot").PicklistSchema<["name", "tagline", "card_img", "hq_country", "active_in_countries", "sdgs", "published", "fund_opt_in", "
|
|
36
|
+
readonly fields: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").RegexAction<string, "invalid csv">]>>, import("valibot").TransformAction<string, string[]>, import("valibot").FilterItemsAction<string[]>]>, import("valibot").ArraySchema<import("valibot").PicklistSchema<["name", "tagline", "card_img", "hq_country", "active_in_countries", "sdgs", "published", "fund_opt_in", "id", "env", "registration_number", "endow_designation", "claimed", "kyc_donors_only", "contributions_total", "contributions_count"], undefined>, undefined>]>, never>;
|
|
37
37
|
}, undefined>;
|
|
38
38
|
export type CloudsearchEndowsQueryParams = InferInput<typeof endowsQueryParams>;
|
|
39
39
|
export type CloudsearchEndow = InferOutput<typeof cloudsearchEndow>;
|
package/dist/cloudsearch.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { csvStrs, endowment, str } from "./schema.mjs";
|
|
2
|
-
import { object, number, pick, keyof, pipe, string, transform, integer, minValue, optional, mapItems, array, boolean, } from "valibot";
|
|
3
1
|
import { orgDesignation, unSdgNum } from "@better-giving/schemas";
|
|
4
|
-
|
|
2
|
+
import { array, boolean, integer, keyof, mapItems, minValue, number, object, optional, pick, pipe, string, transform, } from "valibot";
|
|
3
|
+
import { csvStrs, endowment, str } from "./schema.mjs";
|
|
4
|
+
const boolCsv = pipe(csvStrs, mapItems((x) => x === "true"), array(boolean()));
|
|
5
5
|
export const cloudsearchEndowFields = object({
|
|
6
6
|
contributions_total: number(),
|
|
7
7
|
contributions_count: number(),
|
|
@@ -31,7 +31,7 @@ export const endowsQueryParams = object({
|
|
|
31
31
|
query: str,
|
|
32
32
|
page: pipe(string(), transform((x) => +x), integer(), minValue(1)),
|
|
33
33
|
endow_designation: optional(pipe(csvStrs, array(orgDesignation))),
|
|
34
|
-
sdgs: optional(pipe(csvStrs, mapItems(
|
|
34
|
+
sdgs: optional(pipe(csvStrs, mapItems((x) => +x), array(unSdgNum))),
|
|
35
35
|
kyc_only: optional(boolCsv),
|
|
36
36
|
fund_opt_in: optional(boolCsv),
|
|
37
37
|
claimed: optional(boolCsv),
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Endow as NEndow, Media, Program as NProgram } from "./db.mjs";
|
|
2
2
|
import type { Milestone } from "./schema.mjs";
|
|
3
|
-
export type { Allocation, DonateMethodId,
|
|
3
|
+
export type { Allocation, DonateMethodId, EndowDesignation, EndowQueryParam, EndowUpdate, Environment, Increment, Milestone, MilestoneUpdate, NewMilestone, NewProgram, ProgramUpdate, SocialMediaURLs, UnSdgNum, MediaQueryParams, MediaQueryParamsObj, MediaType, MediaUpdate, } from "./schema.mjs";
|
|
4
4
|
export type { CloudsearchEndow as EndowItem, CloudsearchEndowsQueryParams as EndowsQueryParams, } from "./cloudsearch.mjs";
|
|
5
5
|
export type Endow = Pick<NEndow.DbRecord, "id" | "slug" | "active_in_countries" | "endow_designation" | "fiscal_sponsored" | "hide_bg_tip" | "hq_country" | "image" | "card_img" | "kyc_donors_only" | "logo" | "name" | "overview" | "published" | "registration_number" | "sdgs" | "social_media_urls" | "street_address" | "tagline" | "url" | "claimed" | "progDonationsAllowed" | "donateMethods" | "allocation" | "increments" | "receiptMsg">;
|
|
6
6
|
export type Program = Omit<NProgram.DbRecord, "PK" | "SK"> & {
|
package/dist/schema.d.mts
CHANGED
|
@@ -19,7 +19,8 @@ export declare const endowId: import("valibot").SchemaWithPipe<[import("valibot"
|
|
|
19
19
|
export type EndowId = InferOutput<typeof endowId>;
|
|
20
20
|
export declare const endowIdParam: import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TransformAction<string, number>, import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>]>;
|
|
21
21
|
export declare const segmentMaxChars = 30;
|
|
22
|
-
export declare const segment: import("valibot").
|
|
22
|
+
export declare const segment: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").MaxLengthAction<string, 30, ({ requirement: r }: import("valibot").MaxLengthIssue<string, 30>) => string>, import("valibot").RegexAction<string, "should not be an id">, import("valibot").RegexAction<string, "allowed: numbers | letters | - | . | _ | ~">, import("valibot").ExcludesAction<string, "..", "should not contain double periods">, import("valibot").CustomSchema<string, "should not start with dot">, import("valibot").CustomSchema<string, "should not end with dot">]>;
|
|
23
|
+
export declare const slug: import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").MaxLengthAction<string, 30, ({ requirement: r }: import("valibot").MaxLengthIssue<string, 30>) => string>, import("valibot").RegexAction<string, "should not be an id">, import("valibot").RegexAction<string, "allowed: numbers | letters | - | . | _ | ~">, import("valibot").ExcludesAction<string, "..", "should not contain double periods">, import("valibot").CustomSchema<string, "should not start with dot">, import("valibot").CustomSchema<string, "should not end with dot">]>>;
|
|
23
24
|
export declare const reg_number: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">, import("valibot").RegexAction<string, "must only contain letters and numbers">]>;
|
|
24
25
|
export declare const donateMethodIds: readonly ["stripe", "crypto", "daf", "stocks"];
|
|
25
26
|
export declare const donateMethodId: import("valibot").PicklistSchema<readonly ["stripe", "crypto", "daf", "stocks"], undefined>;
|
|
@@ -99,8 +100,8 @@ export declare const endowment: import("valibot").ObjectSchema<{
|
|
|
99
100
|
}[], 4, undefined>]>, never>;
|
|
100
101
|
readonly fund_opt_in: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
101
102
|
/** endowment is not claimed if `false` only */
|
|
102
|
-
readonly claimed: import("valibot").
|
|
103
|
-
readonly kyc_donors_only: import("valibot").
|
|
103
|
+
readonly claimed: import("valibot").BooleanSchema<undefined>;
|
|
104
|
+
readonly kyc_donors_only: import("valibot").BooleanSchema<undefined>;
|
|
104
105
|
}, undefined>;
|
|
105
106
|
export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
|
|
106
107
|
readonly id: import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>;
|
|
@@ -153,8 +154,8 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
|
|
|
153
154
|
}[], 4, undefined>]>, never>;
|
|
154
155
|
readonly fund_opt_in: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
155
156
|
/** endowment is not claimed if `false` only */
|
|
156
|
-
readonly claimed: import("valibot").
|
|
157
|
-
readonly kyc_donors_only: import("valibot").
|
|
157
|
+
readonly claimed: import("valibot").BooleanSchema<undefined>;
|
|
158
|
+
readonly kyc_donors_only: import("valibot").BooleanSchema<undefined>;
|
|
158
159
|
}, undefined>, "_types" | "_run" | "entries"> & {
|
|
159
160
|
readonly entries: Omit<{
|
|
160
161
|
readonly id: import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>;
|
|
@@ -207,9 +208,9 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
|
|
|
207
208
|
}[], 4, undefined>]>, never>;
|
|
208
209
|
readonly fund_opt_in: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
209
210
|
/** endowment is not claimed if `false` only */
|
|
210
|
-
readonly claimed: import("valibot").
|
|
211
|
-
readonly kyc_donors_only: import("valibot").
|
|
212
|
-
}, "
|
|
211
|
+
readonly claimed: import("valibot").BooleanSchema<undefined>;
|
|
212
|
+
readonly kyc_donors_only: import("valibot").BooleanSchema<undefined>;
|
|
213
|
+
}, "id" | "env" | "claimed" | "kyc_donors_only">;
|
|
213
214
|
_run(dataset: import("valibot").Dataset<unknown, never>, config: import("valibot").Config<import("valibot").StringIssue | import("valibot").RegexIssue<string> | import("valibot").NumberIssue | import("valibot").IntegerIssue<number> | import("valibot").MinValueIssue<number, 0> | import("valibot").MaxValueIssue<number, 100> | import("valibot").ObjectIssue | import("valibot").CheckIssue<{
|
|
214
215
|
cash: number;
|
|
215
216
|
liq: number;
|
|
@@ -547,21 +548,15 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
|
|
|
547
548
|
}[], 4>;
|
|
548
549
|
} | undefined;
|
|
549
550
|
};
|
|
550
|
-
export declare const endowFields: import("valibot").PicklistSchema<["url", "slug", "name", "overview", "tagline", "image", "logo", "card_img", "hq_country", "active_in_countries", "street_address", "sdgs", "receiptMsg", "hide_bg_tip", "published", "progDonationsAllowed", "allocation", "donateMethods", "increments", "fund_opt_in", "
|
|
551
|
+
export declare const endowFields: import("valibot").PicklistSchema<["url", "slug", "name", "overview", "tagline", "image", "logo", "card_img", "hq_country", "active_in_countries", "street_address", "sdgs", "receiptMsg", "hide_bg_tip", "published", "progDonationsAllowed", "allocation", "donateMethods", "increments", "fund_opt_in", "id", "env", "registration_number", "endow_designation", "social_media_urls", "claimed", "kyc_donors_only"], undefined>;
|
|
551
552
|
export type Endowment = InferOutput<typeof endowment>;
|
|
552
553
|
export type EndowUpdate = InferOutput<typeof endowUpdate>;
|
|
553
554
|
export type EndowmentFields = InferOutput<typeof endowFields>;
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
readonly
|
|
557
|
-
readonly env: import("valibot").PicklistSchema<readonly ["staging", "production"], undefined>;
|
|
558
|
-
}, undefined>;
|
|
559
|
-
export type EndowQueryParam = InferInput<typeof endowQueryParam>;
|
|
560
|
-
export declare const endowByEinParams: import("valibot").ObjectSchema<{
|
|
561
|
-
readonly env: import("valibot").PicklistSchema<readonly ["staging", "production"], undefined>;
|
|
562
|
-
readonly ein: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">, import("valibot").RegexAction<string, "must only contain letters and numbers">]>;
|
|
555
|
+
/** for ein path, only fields in reg-num/env gsi is available */
|
|
556
|
+
export declare const endowQueryParams: import("valibot").ObjectSchema<{
|
|
557
|
+
readonly fields: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").RegexAction<string, "invalid csv">]>>, import("valibot").TransformAction<string, string[]>, import("valibot").FilterItemsAction<string[]>]>, import("valibot").ArraySchema<import("valibot").PicklistSchema<["url", "slug", "name", "overview", "tagline", "image", "logo", "card_img", "hq_country", "active_in_countries", "street_address", "sdgs", "receiptMsg", "hide_bg_tip", "published", "progDonationsAllowed", "allocation", "donateMethods", "increments", "fund_opt_in", "id", "env", "registration_number", "endow_designation", "social_media_urls", "claimed", "kyc_donors_only"], undefined>, undefined>]>, never>;
|
|
563
558
|
}, undefined>;
|
|
564
|
-
export type
|
|
559
|
+
export type EndowQueryParam = InferInput<typeof endowQueryParams>;
|
|
565
560
|
export declare const programId: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").UuidAction<string, undefined>]>;
|
|
566
561
|
export type ProgramId = InferOutput<typeof programId>;
|
|
567
562
|
export declare const milestoneId: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").UuidAction<string, undefined>]>;
|
package/dist/schema.mjs
CHANGED
|
@@ -17,15 +17,12 @@ export const allocation = pipe(object({
|
|
|
17
17
|
export const endowId = pipe(number(), integer(), minValue(1));
|
|
18
18
|
export const endowIdParam = pipe(string(), transform((x) => +x), endowId);
|
|
19
19
|
export const segmentMaxChars = 30;
|
|
20
|
-
export const segment =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//valid characters
|
|
27
|
-
regex(/^[a-zA-Z0-9-._~]+$/, "allowed: numbers | letters | - | . | _ | ~"), excludes("..", "should not contain double periods"), custom((x) => !x.startsWith("."), "should not start with dot"), custom((x) => !x.endsWith("."), "should not end with dot"));
|
|
28
|
-
});
|
|
20
|
+
export const segment = pipe(str, maxLength(segmentMaxChars, ({ requirement: r }) => `cannot exceed ${r} chars`),
|
|
21
|
+
//must not be id-like
|
|
22
|
+
regex(/^(?!^\d+$)/, "should not be an id"),
|
|
23
|
+
//valid characters
|
|
24
|
+
regex(/^[a-zA-Z0-9-._~]+$/, "allowed: numbers | letters | - | . | _ | ~"), excludes("..", "should not contain double periods"), custom((x) => !x.startsWith("."), "should not start with dot"), custom((x) => !x.endsWith("."), "should not end with dot"));
|
|
25
|
+
export const slug = lazy((x) => (x ? segment : str));
|
|
29
26
|
export const reg_number = pipe(str, nonEmpty("required"), regex(/^[a-zA-Z0-9]+$/, "must only contain letters and numbers"));
|
|
30
27
|
export const donateMethodIds = ["stripe", "crypto", "daf", "stocks"];
|
|
31
28
|
export const donateMethodId = picklist(donateMethodIds);
|
|
@@ -60,7 +57,7 @@ export const increment = object({
|
|
|
60
57
|
export const endowment = object({
|
|
61
58
|
id: endowId,
|
|
62
59
|
env,
|
|
63
|
-
slug: optional(
|
|
60
|
+
slug: optional(slug),
|
|
64
61
|
registration_number: reg_number,
|
|
65
62
|
name: pipe(str, nonEmpty("required")),
|
|
66
63
|
endow_designation: orgDesignation,
|
|
@@ -87,19 +84,14 @@ export const endowment = object({
|
|
|
87
84
|
increments: optional(pipe(array(increment), maxLength(MAX_NUM_INCREMENTS))),
|
|
88
85
|
fund_opt_in: optional(boolean()),
|
|
89
86
|
/** endowment is not claimed if `false` only */
|
|
90
|
-
claimed:
|
|
91
|
-
kyc_donors_only:
|
|
87
|
+
claimed: boolean(),
|
|
88
|
+
kyc_donors_only: boolean(),
|
|
92
89
|
});
|
|
93
90
|
export const endowUpdate = partial(omit(endowment, ["id", "claimed", "kyc_donors_only", "env"]));
|
|
94
91
|
export const endowFields = keyof(endowment);
|
|
95
|
-
|
|
92
|
+
/** for ein path, only fields in reg-num/env gsi is available */
|
|
93
|
+
export const endowQueryParams = object({
|
|
96
94
|
fields: optional(pipe(csvStrs, array(endowFields))),
|
|
97
|
-
slug: optional(segment),
|
|
98
|
-
env,
|
|
99
|
-
});
|
|
100
|
-
export const endowByEinParams = object({
|
|
101
|
-
env,
|
|
102
|
-
ein: reg_number,
|
|
103
95
|
});
|
|
104
96
|
const amnt = pipe(number(), minValue(0));
|
|
105
97
|
export const programId = pipe(str, uuid());
|
package/package.json
CHANGED
package/src/cloudsearch.mts
CHANGED
|
@@ -23,7 +23,11 @@ import {
|
|
|
23
23
|
} from "valibot";
|
|
24
24
|
import { type Environment, csvStrs, endowment, str } from "./schema.mjs";
|
|
25
25
|
|
|
26
|
-
const boolCsv = pipe(
|
|
26
|
+
const boolCsv = pipe(
|
|
27
|
+
csvStrs,
|
|
28
|
+
mapItems((x) => x === "true"),
|
|
29
|
+
array(boolean())
|
|
30
|
+
);
|
|
27
31
|
|
|
28
32
|
export const cloudsearchEndowFields = object({
|
|
29
33
|
contributions_total: number(),
|
|
@@ -62,7 +66,13 @@ export const endowsQueryParams = object({
|
|
|
62
66
|
minValue(1)
|
|
63
67
|
),
|
|
64
68
|
endow_designation: optional(pipe(csvStrs, array(orgDesignation))),
|
|
65
|
-
sdgs: optional(
|
|
69
|
+
sdgs: optional(
|
|
70
|
+
pipe(
|
|
71
|
+
csvStrs,
|
|
72
|
+
mapItems((x) => +x),
|
|
73
|
+
array(unSdgNum)
|
|
74
|
+
)
|
|
75
|
+
),
|
|
66
76
|
kyc_only: optional(boolCsv),
|
|
67
77
|
fund_opt_in: optional(boolCsv),
|
|
68
78
|
claimed: optional(boolCsv),
|
package/src/index.mts
CHANGED
package/src/schema.mts
CHANGED
|
@@ -73,23 +73,22 @@ export const endowIdParam = pipe(
|
|
|
73
73
|
);
|
|
74
74
|
|
|
75
75
|
export const segmentMaxChars = 30;
|
|
76
|
-
export const segment =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
76
|
+
export const segment = pipe(
|
|
77
|
+
str,
|
|
78
|
+
maxLength(
|
|
79
|
+
segmentMaxChars,
|
|
80
|
+
({ requirement: r }) => `cannot exceed ${r} chars`
|
|
81
|
+
),
|
|
82
|
+
//must not be id-like
|
|
83
|
+
regex(/^(?!^\d+$)/, "should not be an id"),
|
|
84
|
+
//valid characters
|
|
85
|
+
regex(/^[a-zA-Z0-9-._~]+$/, "allowed: numbers | letters | - | . | _ | ~"),
|
|
86
|
+
excludes("..", "should not contain double periods"),
|
|
87
|
+
custom((x) => !(x as string).startsWith("."), "should not start with dot"),
|
|
88
|
+
custom((x) => !(x as string).endsWith("."), "should not end with dot")
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
export const slug = lazy((x) => (x ? segment : str));
|
|
93
92
|
|
|
94
93
|
export const reg_number = pipe(
|
|
95
94
|
str,
|
|
@@ -161,7 +160,7 @@ export type Increment = InferOutput<typeof increment>;
|
|
|
161
160
|
export const endowment = object({
|
|
162
161
|
id: endowId,
|
|
163
162
|
env,
|
|
164
|
-
slug: optional(
|
|
163
|
+
slug: optional(slug),
|
|
165
164
|
registration_number: reg_number,
|
|
166
165
|
name: pipe(str, nonEmpty("required")),
|
|
167
166
|
endow_designation: orgDesignation,
|
|
@@ -190,8 +189,8 @@ export const endowment = object({
|
|
|
190
189
|
fund_opt_in: optional(boolean()),
|
|
191
190
|
|
|
192
191
|
/** endowment is not claimed if `false` only */
|
|
193
|
-
claimed:
|
|
194
|
-
kyc_donors_only:
|
|
192
|
+
claimed: boolean(),
|
|
193
|
+
kyc_donors_only: boolean(),
|
|
195
194
|
});
|
|
196
195
|
|
|
197
196
|
export const endowUpdate = partial(
|
|
@@ -203,20 +202,12 @@ export type Endowment = InferOutput<typeof endowment>;
|
|
|
203
202
|
export type EndowUpdate = InferOutput<typeof endowUpdate>;
|
|
204
203
|
export type EndowmentFields = InferOutput<typeof endowFields>;
|
|
205
204
|
|
|
206
|
-
|
|
205
|
+
/** for ein path, only fields in reg-num/env gsi is available */
|
|
206
|
+
export const endowQueryParams = object({
|
|
207
207
|
fields: optional(pipe(csvStrs, array(endowFields))),
|
|
208
|
-
slug: optional(segment),
|
|
209
|
-
env,
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
export type EndowQueryParam = InferInput<typeof endowQueryParam>;
|
|
213
|
-
|
|
214
|
-
export const endowByEinParams = object({
|
|
215
|
-
env,
|
|
216
|
-
ein: reg_number,
|
|
217
208
|
});
|
|
218
209
|
|
|
219
|
-
export type
|
|
210
|
+
export type EndowQueryParam = InferInput<typeof endowQueryParams>;
|
|
220
211
|
|
|
221
212
|
const amnt = pipe(number(), minValue(0));
|
|
222
213
|
export const programId = pipe(str, uuid());
|