@better-giving/endowment 1.0.13 → 1.0.14
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/index.d.mts +1 -1
- package/dist/schema.d.mts +2 -1
- package/dist/schema.mjs +11 -10
- package/package.json +1 -1
- package/src/index.mts +1 -1
- package/src/schema.mts +18 -15
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Fields as FundItem } from "./cloudsearch.mjs";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Endow as NEndow, Media } from "./db.mjs";
|
|
3
3
|
export type { Allocation, DonateMethodId, EndowByEinParams, EndowDesignation, EndowQueryParam, EndowsQueryParams, EndowUpdate, Environment, Increment, Milestone, MilestoneUpdate, NewMilestone, NewProgram, Program, ProgramUpdate, SocialMediaURLs, UnSdgNum, MediaQueryParams, MediaType, MediaUpdate, } from "./schema.mjs";
|
|
4
4
|
export type { FundItem };
|
|
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">;
|
package/dist/schema.d.mts
CHANGED
|
@@ -23,7 +23,8 @@ export declare const donateMethodIds: readonly ["stripe", "crypto", "daf", "stoc
|
|
|
23
23
|
export declare const donateMethodId: import("valibot").PicklistSchema<readonly ["stripe", "crypto", "daf", "stocks"], undefined>;
|
|
24
24
|
export type DonateMethodId = InferOutput<typeof donateMethodId>;
|
|
25
25
|
export declare const _url: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").UrlAction<string, undefined>]>;
|
|
26
|
-
export declare const
|
|
26
|
+
export declare const httpsUrl: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").StartsWithAction<string, "https://", "should start with https://">, import("valibot").CustomSchema<string, "incomplete url">, import("valibot").UrlAction<string, "invalid url">]>;
|
|
27
|
+
export declare const maybeEmptyHttpsUrl: 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").StartsWithAction<string, "https://", "should start with https://">, import("valibot").CustomSchema<string, "incomplete url">, import("valibot").UrlAction<string, "invalid url">]>>;
|
|
27
28
|
export declare const social_media_urls: import("valibot").ObjectSchema<{
|
|
28
29
|
readonly facebook: import("valibot").OptionalSchema<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").StartsWithAction<string, "https://", "should start with https://">, import("valibot").CustomSchema<string, "incomplete url">, import("valibot").UrlAction<string, "invalid url">]>>, never>;
|
|
29
30
|
readonly twitter: import("valibot").OptionalSchema<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").StartsWithAction<string, "https://", "should start with https://">, import("valibot").CustomSchema<string, "incomplete url">, import("valibot").UrlAction<string, "invalid url">]>>, never>;
|
package/dist/schema.mjs
CHANGED
|
@@ -24,19 +24,20 @@ export const reg_number = pipe(str, nonEmpty("required"), regex(/^[a-zA-Z0-9]+$/
|
|
|
24
24
|
export const donateMethodIds = ["stripe", "crypto", "daf", "stocks"];
|
|
25
25
|
export const donateMethodId = picklist(donateMethodIds);
|
|
26
26
|
export const _url = pipe(str, url());
|
|
27
|
-
export const
|
|
27
|
+
export const httpsUrl = pipe(str, startsWith("https://", "should start with https://"), custom((x) => x !== "https://", "incomplete url"), url("invalid url"));
|
|
28
|
+
export const maybeEmptyHttpsUrl = lazy((x) => {
|
|
28
29
|
if (!x)
|
|
29
30
|
return str;
|
|
30
|
-
return
|
|
31
|
+
return httpsUrl;
|
|
31
32
|
});
|
|
32
33
|
export const social_media_urls = object({
|
|
33
|
-
facebook: optional(
|
|
34
|
-
twitter: optional(
|
|
35
|
-
linkedin: optional(
|
|
36
|
-
discord: optional(
|
|
37
|
-
instagram: optional(
|
|
38
|
-
youtube: optional(
|
|
39
|
-
tiktok: optional(
|
|
34
|
+
facebook: optional(maybeEmptyHttpsUrl),
|
|
35
|
+
twitter: optional(maybeEmptyHttpsUrl),
|
|
36
|
+
linkedin: optional(maybeEmptyHttpsUrl),
|
|
37
|
+
discord: optional(maybeEmptyHttpsUrl),
|
|
38
|
+
instagram: optional(maybeEmptyHttpsUrl),
|
|
39
|
+
youtube: optional(maybeEmptyHttpsUrl),
|
|
40
|
+
tiktok: optional(maybeEmptyHttpsUrl),
|
|
40
41
|
});
|
|
41
42
|
export const MAX_RECEIPT_MSG_CHAR = 500;
|
|
42
43
|
export const incrementVal = pipe(str, nonEmpty("required"), transform((x) => +x), number("must be a number"), minValue(0, "must be greater than 0"),
|
|
@@ -66,7 +67,7 @@ export const endowment = object({
|
|
|
66
67
|
street_address: optional(str),
|
|
67
68
|
social_media_urls,
|
|
68
69
|
/** website */
|
|
69
|
-
url: optional(
|
|
70
|
+
url: optional(maybeEmptyHttpsUrl),
|
|
70
71
|
sdgs: pipe(array(unSdgNum), minLength(1)),
|
|
71
72
|
receiptMsg: optional(pipe(str, maxLength(MAX_RECEIPT_MSG_CHAR))),
|
|
72
73
|
//can be optional, default false and need not be explicit
|
package/package.json
CHANGED
package/src/index.mts
CHANGED
package/src/schema.mts
CHANGED
|
@@ -92,24 +92,27 @@ export const donateMethodId = picklist(donateMethodIds);
|
|
|
92
92
|
export type DonateMethodId = InferOutput<typeof donateMethodId>;
|
|
93
93
|
|
|
94
94
|
export const _url = pipe(str, url());
|
|
95
|
-
|
|
95
|
+
|
|
96
|
+
export const httpsUrl = pipe(
|
|
97
|
+
str,
|
|
98
|
+
startsWith("https://", "should start with https://"),
|
|
99
|
+
custom((x) => x !== "https://", "incomplete url"),
|
|
100
|
+
url("invalid url")
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
export const maybeEmptyHttpsUrl = lazy((x) => {
|
|
96
104
|
if (!x) return str;
|
|
97
|
-
return
|
|
98
|
-
str,
|
|
99
|
-
startsWith("https://", "should start with https://"),
|
|
100
|
-
custom((x) => x !== "https://", "incomplete url"),
|
|
101
|
-
url("invalid url")
|
|
102
|
-
);
|
|
105
|
+
return httpsUrl;
|
|
103
106
|
});
|
|
104
107
|
|
|
105
108
|
export const social_media_urls = object({
|
|
106
|
-
facebook: optional(
|
|
107
|
-
twitter: optional(
|
|
108
|
-
linkedin: optional(
|
|
109
|
-
discord: optional(
|
|
110
|
-
instagram: optional(
|
|
111
|
-
youtube: optional(
|
|
112
|
-
tiktok: optional(
|
|
109
|
+
facebook: optional(maybeEmptyHttpsUrl),
|
|
110
|
+
twitter: optional(maybeEmptyHttpsUrl),
|
|
111
|
+
linkedin: optional(maybeEmptyHttpsUrl),
|
|
112
|
+
discord: optional(maybeEmptyHttpsUrl),
|
|
113
|
+
instagram: optional(maybeEmptyHttpsUrl),
|
|
114
|
+
youtube: optional(maybeEmptyHttpsUrl),
|
|
115
|
+
tiktok: optional(maybeEmptyHttpsUrl),
|
|
113
116
|
});
|
|
114
117
|
|
|
115
118
|
export type SocialMediaURLs = InferOutput<typeof social_media_urls>;
|
|
@@ -161,7 +164,7 @@ export const endowment = object({
|
|
|
161
164
|
street_address: optional(str),
|
|
162
165
|
social_media_urls,
|
|
163
166
|
/** website */
|
|
164
|
-
url: optional(
|
|
167
|
+
url: optional(maybeEmptyHttpsUrl),
|
|
165
168
|
sdgs: pipe(array(unSdgNum), minLength(1)),
|
|
166
169
|
receiptMsg: optional(pipe(str, maxLength(MAX_RECEIPT_MSG_CHAR))),
|
|
167
170
|
//can be optional, default false and need not be explicit
|