@better-giving/endowment 4.0.6 → 4.0.7

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.
@@ -1,7 +1,7 @@
1
1
  import { $int_gte1, org_designation, unsdg_num } from "@better-giving/schemas";
2
2
  import { array, boolean, keyof, mapItems, number, object, optional, pick, pipe, } from "valibot";
3
- import { $, csvStrs, npo } from "./schema.mjs";
4
- const boolCsv = pipe(csvStrs, mapItems((x) => x === "true"), array(boolean()));
3
+ import { $, csv_strs, npo } from "./schema.mjs";
4
+ const boolCsv = pipe(csv_strs, mapItems((x) => x === "true"), array(boolean()));
5
5
  export const cloudsearchEndowFields = object({
6
6
  contributions_total: number(),
7
7
  contributions_count: number(),
@@ -31,11 +31,11 @@ export const cloudSearchEndowFields = keyof(cloudsearchEndow);
31
31
  export const endowsQueryParams = object({
32
32
  query: optional($),
33
33
  page: optional($int_gte1),
34
- endow_designation: optional(pipe(csvStrs, array(org_designation))),
35
- sdgs: optional(pipe(csvStrs, mapItems((x) => +x), array(unsdg_num))),
34
+ endow_designation: optional(pipe(csv_strs, array(org_designation))),
35
+ sdgs: optional(pipe(csv_strs, mapItems((x) => +x), array(unsdg_num))),
36
36
  kyc_only: optional(boolCsv),
37
37
  fund_opt_in: optional(boolCsv),
38
38
  claimed: optional(boolCsv),
39
- countries: optional(pipe(csvStrs, array($))),
40
- fields: optional(pipe(csvStrs, array(cloudSearchEndowFields))),
39
+ countries: optional(pipe(csv_strs, array($))),
40
+ fields: optional(pipe(csv_strs, array(cloudSearchEndowFields))),
41
41
  });
package/dist/schema.d.mts CHANGED
@@ -1,9 +1,8 @@
1
- import { $, $int_gte1, $req, $req_num_gt0, donate_method_id, donate_method_ids, env, https_url, int_gte1, org_designation, slug, unsdg_num } from "@better-giving/schemas";
2
- export { org_designation as endow_designation, env, unsdg_num, donate_method_id, donate_method_ids, $int_gte1, int_gte1, $, $req_num_gt0, $req, slug, https_url };
1
+ export { $, $req, $req_num_gt0, donate_method_id, env, https_url, int_gte1, $int_gte1, org_designation, slug, unsdg_num, } from "@better-giving/schemas";
3
2
  import * as v from "valibot";
4
3
  export declare const min_payout_amount = 50;
5
4
  export declare const csv: v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.RegexAction<string, "invalid csv">]>>;
6
- export declare const csvStrs: v.SchemaWithPipe<[v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.RegexAction<string, "invalid csv">]>>, v.TransformAction<string, string[]>, v.FilterItemsAction<string[]>]>;
5
+ export declare const csv_strs: v.SchemaWithPipe<[v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.RegexAction<string, "invalid csv">]>>, v.TransformAction<string, string[]>, v.FilterItemsAction<string[]>]>;
7
6
  export declare const allocation: v.SchemaWithPipe<[v.ObjectSchema<{
8
7
  readonly cash: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
9
8
  readonly liq: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
@@ -810,7 +809,7 @@ export declare const media_search: v.ObjectSchema<{
810
809
  readonly type: v.OptionalSchema<v.PicklistSchema<readonly ["album", "article", "video"], undefined>, never>;
811
810
  readonly next: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.Base64Action<string, undefined>]>, never>;
812
811
  readonly featured: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.TransformAction<string, boolean>, v.BooleanSchema<undefined>]>, never>;
813
- readonly limit: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TransformAction<string, number>, v.SchemaWithPipe<[v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>]>, never>;
812
+ readonly limit: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.TransformAction<string, number>, v.SchemaWithPipe<[v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>]>, never>;
814
813
  }, undefined>;
815
814
  export interface IMediaSearch extends v.InferInput<typeof media_search> {
816
815
  }
package/dist/schema.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { $, $int_gte1, $req, $req_num_gt0, donate_method_id, donate_method_ids, env, https_url, int_gte1, org_designation, slug, unsdg_num, } from "@better-giving/schemas";
2
- export { org_designation as endow_designation, env, unsdg_num, donate_method_id, donate_method_ids, $int_gte1, int_gte1, $, $req_num_gt0, $req, slug, https_url };
1
+ import { $, $req, $req_num_gt0, donate_method_id, env, https_url, int_gte1, $int_gte1, org_designation, slug, unsdg_num, } from "@better-giving/schemas";
2
+ export { $, $req, $req_num_gt0, donate_method_id, env, https_url, int_gte1, $int_gte1, org_designation, slug, unsdg_num, } from "@better-giving/schemas";
3
3
  import * as v from "valibot";
4
4
  export const min_payout_amount = 50;
5
5
  export const csv = v.lazy((x) => {
@@ -7,7 +7,7 @@ export const csv = v.lazy((x) => {
7
7
  return $;
8
8
  return v.pipe($, v.regex(/^[^,]+(?:,[^,]+)*$/, "invalid csv"));
9
9
  });
10
- export const csvStrs = v.pipe(csv, v.transform((x) => x.split(",")), v.filterItems((x) => x.length > 0));
10
+ export const csv_strs = v.pipe(csv, v.transform((x) => x.split(",")), v.filterItems((x) => x.length > 0));
11
11
  const pct = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(100));
12
12
  export const allocation = v.pipe(v.object({
13
13
  cash: pct,
@@ -85,7 +85,7 @@ export const npo_update = v.partial(v.omit(npo, ["id", "claimed", "kyc_donors_on
85
85
  export const npo_fields = v.keyof(npo);
86
86
  /** for ein path, only fields in reg-num/env gsi is available */
87
87
  export const npo_search = v.object({
88
- fields: v.optional(v.pipe(csvStrs, v.array(npo_fields))),
88
+ fields: v.optional(v.pipe(csv_strs, v.array(npo_fields))),
89
89
  });
90
90
  const amnt = v.pipe(v.number(), v.minValue(0));
91
91
  export const program_id = v.pipe($, v.uuid());
@@ -132,5 +132,5 @@ export const media_search = v.object({
132
132
  type: v.optional(media_type),
133
133
  next: v.optional(v.pipe($, v.base64())),
134
134
  featured: v.optional(v.pipe($, v.transform((x) => Boolean(x)), v.boolean())),
135
- limit: v.optional(v.pipe(v.string(), v.transform((x) => +x), int_gte1)),
135
+ limit: v.optional($int_gte1),
136
136
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-giving/endowment",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "dependencies": {
5
5
  "ksuid": "3.0.0"
6
6
  },
@@ -18,10 +18,10 @@ import {
18
18
  pick,
19
19
  pipe,
20
20
  } from "valibot";
21
- import { $, csvStrs, npo } from "./schema.mjs";
21
+ import { $, csv_strs, npo } from "./schema.mjs";
22
22
 
23
23
  const boolCsv = pipe(
24
- csvStrs,
24
+ csv_strs,
25
25
  mapItems((x) => x === "true"),
26
26
  array(boolean())
27
27
  );
@@ -58,10 +58,10 @@ export const cloudSearchEndowFields = keyof(cloudsearchEndow);
58
58
  export const endowsQueryParams = object({
59
59
  query: optional($),
60
60
  page: optional($int_gte1),
61
- endow_designation: optional(pipe(csvStrs, array(org_designation))),
61
+ endow_designation: optional(pipe(csv_strs, array(org_designation))),
62
62
  sdgs: optional(
63
63
  pipe(
64
- csvStrs,
64
+ csv_strs,
65
65
  mapItems((x) => +x),
66
66
  array(unsdg_num)
67
67
  )
@@ -69,8 +69,8 @@ export const endowsQueryParams = object({
69
69
  kyc_only: optional(boolCsv),
70
70
  fund_opt_in: optional(boolCsv),
71
71
  claimed: optional(boolCsv),
72
- countries: optional(pipe(csvStrs, array($))),
73
- fields: optional(pipe(csvStrs, array(cloudSearchEndowFields))),
72
+ countries: optional(pipe(csv_strs, array($))),
73
+ fields: optional(pipe(csv_strs, array(cloudSearchEndowFields))),
74
74
  });
75
75
 
76
76
  export interface CloudsearchEndowsQueryParamsObj
package/src/schema.mts CHANGED
@@ -1,31 +1,29 @@
1
1
  import {
2
2
  $,
3
- $int_gte1,
4
3
  $req,
5
4
  $req_num_gt0,
6
5
  donate_method_id,
7
- donate_method_ids,
8
6
  env,
9
7
  https_url,
10
8
  int_gte1,
9
+ $int_gte1,
11
10
  org_designation,
12
11
  slug,
13
12
  unsdg_num,
14
13
  } from "@better-giving/schemas";
15
14
  export {
16
- org_designation as endow_designation,
17
- env,
18
- unsdg_num,
19
- donate_method_id,
20
- donate_method_ids,
21
- $int_gte1,
22
- int_gte1,
23
15
  $,
24
- $req_num_gt0,
25
16
  $req,
17
+ $req_num_gt0,
18
+ donate_method_id,
19
+ env,
20
+ https_url,
21
+ int_gte1,
22
+ $int_gte1,
23
+ org_designation,
26
24
  slug,
27
- https_url
28
- };
25
+ unsdg_num,
26
+ } from "@better-giving/schemas";
29
27
  import * as v from "valibot";
30
28
 
31
29
  export const min_payout_amount = 50;
@@ -34,7 +32,7 @@ export const csv = v.lazy((x) => {
34
32
  if (!x) return $;
35
33
  return v.pipe($, v.regex(/^[^,]+(?:,[^,]+)*$/, "invalid csv"));
36
34
  });
37
- export const csvStrs = v.pipe(
35
+ export const csv_strs = v.pipe(
38
36
  csv,
39
37
  v.transform((x) => x.split(",")),
40
38
  v.filterItems((x) => x.length > 0)
@@ -166,7 +164,7 @@ export type INpoFields = v.InferOutput<typeof npo_fields>;
166
164
 
167
165
  /** for ein path, only fields in reg-num/env gsi is available */
168
166
  export const npo_search = v.object({
169
- fields: v.optional(v.pipe(csvStrs, v.array(npo_fields))),
167
+ fields: v.optional(v.pipe(csv_strs, v.array(npo_fields))),
170
168
  });
171
169
 
172
170
  export interface INposSearch extends v.InferInput<typeof npo_search> {}
@@ -244,13 +242,7 @@ export const media_search = v.object({
244
242
  v.boolean()
245
243
  )
246
244
  ),
247
- limit: v.optional(
248
- v.pipe(
249
- v.string(),
250
- v.transform((x) => +x),
251
- int_gte1
252
- )
253
- ),
245
+ limit: v.optional($int_gte1),
254
246
  });
255
247
  export interface IMediaSearch extends v.InferInput<typeof media_search> {}
256
248
  export interface IMediaSearchObj extends v.InferOutput<typeof media_search> {}