@better-giving/endowment 1.0.13 → 1.0.16

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Fields as FundItem } from "./cloudsearch.mjs";
2
- import type { Media, Endow as NEndow } from "./db.mjs";
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";
2
+ import type { Endow as NEndow, Media } from "./db.mjs";
3
+ export type { Allocation, DonateMethodId, EndowByEinParams, EndowDesignation, EndowQueryParam, EndowsQueryParams, EndowUpdate, Environment, Increment, Milestone, MilestoneUpdate, NewMilestone, NewProgram, Program, ProgramUpdate, SocialMediaURLs, UnSdgNum, MediaQueryParams, MediaQueryParamsObj, 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">;
6
6
  /** web-app format */
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 userInputUrl: 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">]>>;
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>;
@@ -749,3 +750,4 @@ export declare const mediaQueryParams: import("valibot").ObjectSchema<{
749
750
  readonly limit: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TransformAction<string, number>, import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>, never>;
750
751
  }, undefined>;
751
752
  export type MediaQueryParams = InferInput<typeof mediaQueryParams>;
753
+ export type MediaQueryParamsObj = InferOutput<typeof mediaQueryParams>;
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 userInputUrl = lazy((x) => {
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 pipe(str, startsWith("https://", "should start with https://"), custom((x) => x !== "https://", "incomplete url"), url("invalid url"));
31
+ return httpsUrl;
31
32
  });
32
33
  export const social_media_urls = object({
33
- facebook: optional(userInputUrl),
34
- twitter: optional(userInputUrl),
35
- linkedin: optional(userInputUrl),
36
- discord: optional(userInputUrl),
37
- instagram: optional(userInputUrl),
38
- youtube: optional(userInputUrl),
39
- tiktok: optional(userInputUrl),
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(userInputUrl),
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-giving/endowment",
3
- "version": "1.0.13",
3
+ "version": "1.0.16",
4
4
  "peerDependencies": {
5
5
  "@better-giving/schemas": "1.0.1",
6
6
  "@better-giving/types": "1.0.1"
package/src/index.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Fields as FundItem } from "./cloudsearch.mjs";
2
- import type { Media, Endow as NEndow } from "./db.mjs";
2
+ import type { Endow as NEndow, Media } from "./db.mjs";
3
3
  export type {
4
4
  Allocation,
5
5
  DonateMethodId,
@@ -19,6 +19,7 @@ export type {
19
19
  SocialMediaURLs,
20
20
  UnSdgNum,
21
21
  MediaQueryParams,
22
+ MediaQueryParamsObj,
22
23
  MediaType,
23
24
  MediaUpdate,
24
25
  } from "./schema.mjs";
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
- export const userInputUrl = lazy((x) => {
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 pipe(
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(userInputUrl),
107
- twitter: optional(userInputUrl),
108
- linkedin: optional(userInputUrl),
109
- discord: optional(userInputUrl),
110
- instagram: optional(userInputUrl),
111
- youtube: optional(userInputUrl),
112
- tiktok: optional(userInputUrl),
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(userInputUrl),
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
@@ -331,3 +334,4 @@ export const mediaQueryParams = object({
331
334
  ),
332
335
  });
333
336
  export type MediaQueryParams = InferInput<typeof mediaQueryParams>;
337
+ export type MediaQueryParamsObj = InferOutput<typeof mediaQueryParams>;