@better-giving/donation 1.0.1 → 1.0.3

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/intent.d.mts CHANGED
@@ -9,102 +9,102 @@ export declare const donorTitles: readonly ["Mr", "Mrs", "Ms", "Mx", ""];
9
9
  export declare const donorTitle: v.PicklistSchema<readonly ["Mr", "Mrs", "Ms", "Mx", ""], undefined>;
10
10
  export type DonorTitle = v.InferOutput<typeof donorTitle>;
11
11
  export declare const donorAddress: v.ObjectSchema<{
12
- readonly street: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
13
- readonly city: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
14
- readonly state: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, never>;
15
- readonly zipCode: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, never>;
12
+ readonly street: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
13
+ readonly city: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
14
+ readonly state: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
15
+ readonly zipCode: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
16
16
  /** country name */
17
- readonly country: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
17
+ readonly country: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
18
18
  readonly ukGiftAid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
19
19
  }, undefined>;
20
20
  export type DonorAddress = v.InferOutput<typeof donorAddress>;
21
21
  export declare const donor: v.ObjectSchema<{
22
22
  readonly title: v.PicklistSchema<readonly ["Mr", "Mrs", "Ms", "Mx", ""], undefined>;
23
- readonly firstName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
24
- readonly lastName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
25
- readonly email: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, v.EmailAction<string, undefined>]>;
23
+ readonly firstName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
24
+ readonly lastName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
25
+ readonly email: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.EmailAction<string, undefined>]>;
26
26
  readonly address: v.OptionalSchema<v.ObjectSchema<{
27
- readonly street: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
28
- readonly city: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
29
- readonly state: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, never>;
30
- readonly zipCode: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, never>;
27
+ readonly street: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
28
+ readonly city: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
29
+ readonly state: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
30
+ readonly zipCode: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
31
31
  /** country name */
32
- readonly country: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
32
+ readonly country: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
33
33
  readonly ukGiftAid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
34
34
  }, undefined>, never>;
35
35
  }, undefined>;
36
36
  export type Donor = v.InferOutput<typeof donor>;
37
37
  export declare const amount: v.ObjectSchema<{
38
38
  readonly amount: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
39
- readonly currency: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
39
+ readonly currency: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
40
40
  readonly tip: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
41
41
  readonly feeAllowance: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
42
42
  }, undefined>;
43
43
  export type Amount = v.InferOutput<typeof amount>;
44
- export declare const endowId: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
45
- export declare const uuid: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, v.UuidAction<string, undefined>]>;
44
+ export declare const endowId: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.TransformAction<string, number>, v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
45
+ export declare const uuid: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.UuidAction<string, undefined>]>;
46
46
  export declare const program: v.ObjectSchema<{
47
- readonly id: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, v.UuidAction<string, undefined>]>;
48
- readonly name: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
47
+ readonly id: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.UuidAction<string, undefined>]>;
48
+ readonly name: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
49
49
  }, undefined>;
50
50
  export type Program = v.InferOutput<typeof program>;
51
- export declare const recipient: v.UnionSchema<[v.SchemaWithPipe<[v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, v.UuidAction<string, undefined>]>], undefined>;
51
+ export declare const recipient: v.UnionSchema<[v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.TransformAction<string, number>, v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.UuidAction<string, undefined>]>], undefined>;
52
52
  export type Recipient = v.InferOutput<typeof recipient>;
53
53
  export declare const tributeNotif: v.ObjectSchema<{
54
- readonly toEmail: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, v.EmailAction<string, undefined>]>;
55
- readonly toFullName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
56
- readonly fromMsg: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.MaxLengthAction<string, 250, undefined>]>, never>;
54
+ readonly toEmail: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.EmailAction<string, undefined>]>;
55
+ readonly toFullName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
56
+ readonly fromMsg: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 250, undefined>]>;
57
57
  }, undefined>;
58
58
  export type TributeNotif = v.InferOutput<typeof tributeNotif>;
59
59
  export declare const tribute: v.ObjectSchema<{
60
- readonly fullName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
60
+ readonly fullName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
61
61
  readonly notif: v.OptionalSchema<v.ObjectSchema<{
62
- readonly toEmail: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, v.EmailAction<string, undefined>]>;
63
- readonly toFullName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
64
- readonly fromMsg: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.MaxLengthAction<string, 250, undefined>]>, never>;
62
+ readonly toEmail: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.EmailAction<string, undefined>]>;
63
+ readonly toFullName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
64
+ readonly fromMsg: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 250, undefined>]>;
65
65
  }, undefined>, never>;
66
66
  }, undefined>;
67
67
  export type Tribute = v.InferOutput<typeof tribute>;
68
68
  export declare const intent: v.ObjectSchema<{
69
69
  readonly amount: v.ObjectSchema<{
70
70
  readonly amount: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
71
- readonly currency: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
71
+ readonly currency: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
72
72
  readonly tip: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
73
73
  readonly feeAllowance: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
74
74
  }, undefined>;
75
- readonly recipient: v.UnionSchema<[v.SchemaWithPipe<[v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, v.UuidAction<string, undefined>]>], undefined>;
75
+ readonly recipient: v.UnionSchema<[v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.TransformAction<string, number>, v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.UuidAction<string, undefined>]>], undefined>;
76
76
  readonly program: v.OptionalSchema<v.ObjectSchema<{
77
- readonly id: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, v.UuidAction<string, undefined>]>;
78
- readonly name: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
77
+ readonly id: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.UuidAction<string, undefined>]>;
78
+ readonly name: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
79
79
  }, undefined>, never>;
80
80
  readonly donor: v.ObjectSchema<{
81
81
  readonly title: v.PicklistSchema<readonly ["Mr", "Mrs", "Ms", "Mx", ""], undefined>;
82
- readonly firstName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
83
- readonly lastName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
84
- readonly email: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, v.EmailAction<string, undefined>]>;
82
+ readonly firstName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
83
+ readonly lastName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
84
+ readonly email: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.EmailAction<string, undefined>]>;
85
85
  readonly address: v.OptionalSchema<v.ObjectSchema<{
86
- readonly street: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
87
- readonly city: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
88
- readonly state: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, never>;
89
- readonly zipCode: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, never>;
86
+ readonly street: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
87
+ readonly city: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
88
+ readonly state: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
89
+ readonly zipCode: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
90
90
  /** country name */
91
- readonly country: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
91
+ readonly country: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
92
92
  readonly ukGiftAid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
93
93
  }, undefined>, never>;
94
94
  }, undefined>;
95
95
  readonly source: v.PicklistSchema<readonly ["bg-marketplace", "bg-widget", "tester-app"], undefined>;
96
96
  readonly tribute: v.OptionalSchema<v.ObjectSchema<{
97
- readonly fullName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
97
+ readonly fullName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
98
98
  readonly notif: v.OptionalSchema<v.ObjectSchema<{
99
- readonly toEmail: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>, v.EmailAction<string, undefined>]>;
100
- readonly toFullName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
101
- readonly fromMsg: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.MaxLengthAction<string, 250, undefined>]>, never>;
99
+ readonly toEmail: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.EmailAction<string, undefined>]>;
100
+ readonly toFullName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
101
+ readonly fromMsg: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 250, undefined>]>;
102
102
  }, undefined>, never>;
103
103
  }, undefined>, never>;
104
104
  readonly frequency: v.PicklistSchema<readonly ["one-time", "recurring"], undefined>;
105
105
  /** chain name, etc. */
106
- readonly viaName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
106
+ readonly viaName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>;
107
107
  /** chain id, workflow-session-id, etc. */
108
- readonly viaId: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>]>;
108
+ readonly viaId: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>;
109
109
  }, undefined>;
110
110
  export type DonationIntent = v.InferOutput<typeof intent>;
package/dist/intent.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as v from "valibot";
2
- const str = v.pipe(v.string(), v.trim(), v.nonEmpty());
2
+ const str = v.pipe(v.string(), v.trim());
3
+ const requiredStr = v.pipe(str, v.nonEmpty());
3
4
  export const frequencies = ["one-time", "recurring"];
4
5
  export const frequency = v.picklist(frequencies);
5
6
  export const donationSources = [
@@ -11,42 +12,42 @@ export const donationSource = v.picklist(donationSources);
11
12
  export const donorTitles = ["Mr", "Mrs", "Ms", "Mx", ""];
12
13
  export const donorTitle = v.picklist(donorTitles);
13
14
  export const donorAddress = v.object({
14
- street: str,
15
- city: str,
16
- state: v.optional(str),
17
- zipCode: v.optional(str),
15
+ street: requiredStr,
16
+ city: requiredStr,
17
+ state: v.optional(requiredStr),
18
+ zipCode: v.optional(requiredStr),
18
19
  /** country name */
19
- country: str,
20
+ country: requiredStr,
20
21
  ukGiftAid: v.optional(v.boolean()),
21
22
  });
22
23
  export const donor = v.object({
23
24
  title: donorTitle,
24
- firstName: str,
25
- lastName: str,
25
+ firstName: requiredStr,
26
+ lastName: requiredStr,
26
27
  email: v.pipe(str, v.email()),
27
28
  address: v.optional(donorAddress),
28
29
  });
29
30
  const money = v.pipe(v.number(), v.minValue(0));
30
31
  export const amount = v.object({
31
32
  amount: money,
32
- currency: str,
33
+ currency: requiredStr,
33
34
  tip: money,
34
35
  feeAllowance: money,
35
36
  });
36
- export const endowId = v.pipe(v.number(), v.integer(), v.minValue(1));
37
+ export const endowId = v.pipe(str, v.transform((x) => +x), v.number(), v.integer(), v.minValue(1));
37
38
  export const uuid = v.pipe(str, v.uuid());
38
39
  export const program = v.object({
39
40
  id: uuid,
40
- name: str,
41
+ name: requiredStr,
41
42
  });
42
43
  export const recipient = v.union([endowId, uuid]);
43
44
  export const tributeNotif = v.object({
44
45
  toEmail: v.pipe(str, v.email()),
45
- toFullName: str,
46
- fromMsg: v.optional(v.pipe(v.string(), v.maxLength(250))),
46
+ toFullName: v.pipe(str, v.nonEmpty()),
47
+ fromMsg: v.pipe(str, v.maxLength(250)),
47
48
  });
48
49
  export const tribute = v.object({
49
- fullName: str,
50
+ fullName: requiredStr,
50
51
  notif: v.optional(tributeNotif),
51
52
  });
52
53
  export const intent = v.object({
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@better-giving/donation",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "devDependencies": {
5
5
  "@better-giving/config": "workspace:*"
6
6
  },
7
7
  "peerDependencies": {
8
- "@better-giving/types": "1.0.1",
8
+ "@better-giving/types": "1.0.2",
9
9
  "valibot": "0.42.0"
10
10
  },
11
11
  "files": [
package/src/intent.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as v from "valibot";
2
2
 
3
- const str = v.pipe(v.string(), v.trim(), v.nonEmpty());
3
+ const str = v.pipe(v.string(), v.trim());
4
+ const requiredStr = v.pipe(str, v.nonEmpty());
4
5
 
5
6
  export const frequencies = ["one-time", "recurring"] as const;
6
7
  export const frequency = v.picklist(frequencies);
@@ -22,12 +23,12 @@ export const donorTitle = v.picklist(donorTitles);
22
23
  export type DonorTitle = v.InferOutput<typeof donorTitle>;
23
24
 
24
25
  export const donorAddress = v.object({
25
- street: str,
26
- city: str,
27
- state: v.optional(str),
28
- zipCode: v.optional(str),
26
+ street: requiredStr,
27
+ city: requiredStr,
28
+ state: v.optional(requiredStr),
29
+ zipCode: v.optional(requiredStr),
29
30
  /** country name */
30
- country: str,
31
+ country: requiredStr,
31
32
  ukGiftAid: v.optional(v.boolean()),
32
33
  });
33
34
 
@@ -35,8 +36,8 @@ export type DonorAddress = v.InferOutput<typeof donorAddress>;
35
36
 
36
37
  export const donor = v.object({
37
38
  title: donorTitle,
38
- firstName: str,
39
- lastName: str,
39
+ firstName: requiredStr,
40
+ lastName: requiredStr,
40
41
  email: v.pipe(str, v.email()),
41
42
  address: v.optional(donorAddress),
42
43
  });
@@ -47,19 +48,25 @@ const money = v.pipe(v.number(), v.minValue(0));
47
48
 
48
49
  export const amount = v.object({
49
50
  amount: money,
50
- currency: str,
51
+ currency: requiredStr,
51
52
  tip: money,
52
53
  feeAllowance: money,
53
54
  });
54
55
 
55
56
  export type Amount = v.InferOutput<typeof amount>;
56
57
 
57
- export const endowId = v.pipe(v.number(), v.integer(), v.minValue(1));
58
+ export const endowId = v.pipe(
59
+ str,
60
+ v.transform((x) => +x),
61
+ v.number(),
62
+ v.integer(),
63
+ v.minValue(1)
64
+ );
58
65
  export const uuid = v.pipe(str, v.uuid());
59
66
 
60
67
  export const program = v.object({
61
68
  id: uuid,
62
- name: str,
69
+ name: requiredStr,
63
70
  });
64
71
 
65
72
  export type Program = v.InferOutput<typeof program>;
@@ -70,14 +77,14 @@ export type Recipient = v.InferOutput<typeof recipient>;
70
77
 
71
78
  export const tributeNotif = v.object({
72
79
  toEmail: v.pipe(str, v.email()),
73
- toFullName: str,
74
- fromMsg: v.optional(v.pipe(v.string(), v.maxLength(250))),
80
+ toFullName: v.pipe(str, v.nonEmpty()),
81
+ fromMsg: v.pipe(str, v.maxLength(250)),
75
82
  });
76
83
 
77
84
  export type TributeNotif = v.InferOutput<typeof tributeNotif>;
78
85
 
79
86
  export const tribute = v.object({
80
- fullName: str,
87
+ fullName: requiredStr,
81
88
  notif: v.optional(tributeNotif),
82
89
  });
83
90