@better-giving/donation 1.1.15 → 1.1.17

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.
@@ -134,6 +134,7 @@ export declare namespace Donation {
134
134
  fund_id?: string;
135
135
  fund_name?: string;
136
136
  fund_tx?: string;
137
+ company_name?: string;
137
138
  };
138
139
  type NonKeyAttributes = {
139
140
  addressComplement?: " ";
@@ -190,44 +191,6 @@ export declare namespace Donation {
190
191
  /** may be empty `""` */
191
192
  fromMsg: string;
192
193
  };
193
- namespace Intent {
194
- interface Donor {
195
- /** may be empty `''` */
196
- title?: DonorTitle;
197
- firstName: string;
198
- lastName: string;
199
- email: string;
200
- address?: DonorAddress;
201
- /** signifies eligibility to UK Gift Aid, defaults to `false` for crypto donations */
202
- ukGiftAid: boolean;
203
- }
204
- interface Attr {
205
- transactionId?: string;
206
- amount: number;
207
- tipAmount: number;
208
- feeAllowance: number;
209
- endowmentId: number;
210
- /** program donation: may be empty `""`*/
211
- programId?: string;
212
- programName?: string;
213
- splitLiq: number;
214
- donor: Donor;
215
- /** honorary full name */
216
- inHonorOf?: string;
217
- /** only allowed if honoree is provided */
218
- tributeNotif?: TributeNotif;
219
- source: Source;
220
- }
221
- interface Crypto extends Attr {
222
- denomination: string;
223
- chainId: ChainID.V2CryptoChainID;
224
- walletAddress?: string;
225
- chainName: string;
226
- }
227
- interface Fiat extends Attr {
228
- currency: string;
229
- }
230
- }
231
194
  /** web-app determinant: show signup page or not*/
232
195
  type GuestDonor = {
233
196
  email: string;
@@ -306,6 +269,7 @@ export declare namespace OnHoldDonation {
306
269
  tributeNotif?: Donation.TributeNotif;
307
270
  donor_message?: string;
308
271
  donor_public?: boolean;
272
+ company_name?: string;
309
273
  } & (ApesAttributes | EmptyObject) & (Donation.WithKYC | Donation.WithoutKYC);
310
274
  type CryptoDBRecord = PrimaryKey & NonKeyAttributes & CryptoAttributes & Donation.EmailIndexKey;
311
275
  type FiatDBRecord = PrimaryKey & Required<Donation.FiatRamp_IndexKey> & NonKeyAttributes & FiatAttributes & Required<Donation.EmailIndexKey>;
package/dist/intent.d.mts CHANGED
@@ -2,36 +2,36 @@ import * as v from "valibot";
2
2
  export declare const frequencies: readonly ["one-time", "recurring"];
3
3
  export declare const frequency: v.PicklistSchema<readonly ["one-time", "recurring"], undefined>;
4
4
  export type Frequency = v.InferOutput<typeof frequency>;
5
- export declare const donationSources: readonly ["bg-marketplace", "bg-widget", "tester-app"];
6
- export declare const donationSource: v.PicklistSchema<readonly ["bg-marketplace", "bg-widget", "tester-app"], undefined>;
7
- export type DonationSource = v.InferOutput<typeof donationSource>;
8
- export declare const donorTitles: readonly ["Mr", "Mrs", "Ms", "Mx", ""];
9
- export declare const donorTitle: v.PicklistSchema<readonly ["Mr", "Mrs", "Ms", "Mx", ""], undefined>;
10
- export type DonorTitle = v.InferOutput<typeof donorTitle>;
11
- export declare const donorAddress: v.ObjectSchema<{
5
+ export declare const donation_sources: readonly ["bg-marketplace", "bg-widget", "tester-app"];
6
+ export declare const donation_source: v.PicklistSchema<readonly ["bg-marketplace", "bg-widget", "tester-app"], undefined>;
7
+ export type DonationSource = v.InferOutput<typeof donation_source>;
8
+ export declare const donor_titles: readonly ["Mr", "Mrs", "Ms", "Mx", ""];
9
+ export declare const donor_title: v.PicklistSchema<readonly ["Mr", "Mrs", "Ms", "Mx", ""], undefined>;
10
+ export type DonorTitle = v.InferOutput<typeof donor_title>;
11
+ export declare const donor_address: v.ObjectSchema<{
12
12
  readonly street: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
13
13
  readonly city: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
14
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>;
15
+ readonly zip_code: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
16
16
  /** country name */
17
17
  readonly country: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
18
- readonly ukGiftAid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
18
+ readonly uk_gift_aid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
19
19
  }, undefined>;
20
- export type DonorAddress = v.InferOutput<typeof donorAddress>;
20
+ export type DonorAddress = v.InferOutput<typeof donor_address>;
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.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
24
- readonly companyName: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, never>;
25
- readonly lastName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
23
+ readonly first_name: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
24
+ readonly company_name: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, never>;
25
+ readonly last_name: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
26
26
  readonly email: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.EmailAction<string, undefined>]>;
27
27
  readonly address: v.OptionalSchema<v.ObjectSchema<{
28
28
  readonly street: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
29
29
  readonly city: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
30
30
  readonly state: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
31
- readonly zipCode: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
31
+ readonly zip_code: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
32
32
  /** country name */
33
33
  readonly country: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
34
- readonly ukGiftAid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
34
+ readonly uk_gift_aid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
35
35
  }, undefined>, never>;
36
36
  }, undefined>;
37
37
  export type Donor = v.InferOutput<typeof donor>;
@@ -39,10 +39,10 @@ export declare const amount: v.ObjectSchema<{
39
39
  readonly amount: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
40
40
  readonly currency: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
41
41
  readonly tip: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
42
- readonly feeAllowance: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
42
+ readonly fee_allowance: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
43
43
  }, undefined>;
44
44
  export type Amount = v.InferOutput<typeof amount>;
45
- 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 endow_id: 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>]>;
46
46
  export declare const uuid: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.UuidAction<string, undefined>]>;
47
47
  export declare const program: v.ObjectSchema<{
48
48
  readonly id: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.UuidAction<string, undefined>]>;
@@ -51,12 +51,12 @@ export declare const program: v.ObjectSchema<{
51
51
  export type Program = v.InferOutput<typeof program>;
52
52
  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>;
53
53
  export type Recipient = v.InferOutput<typeof recipient>;
54
- export declare const tributeNotif: v.ObjectSchema<{
54
+ export declare const tribute_notif: v.ObjectSchema<{
55
55
  readonly toEmail: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.EmailAction<string, undefined>]>;
56
56
  readonly toFullName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
57
57
  readonly fromMsg: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 250, undefined>]>;
58
58
  }, undefined>;
59
- export type TributeNotif = v.InferOutput<typeof tributeNotif>;
59
+ export type TributeNotif = v.InferOutput<typeof tribute_notif>;
60
60
  export declare const tribute: v.ObjectSchema<{
61
61
  readonly fullName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
62
62
  readonly notif: v.OptionalSchema<v.ObjectSchema<{
@@ -71,7 +71,7 @@ export declare const intent: v.ObjectSchema<{
71
71
  readonly amount: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
72
72
  readonly currency: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
73
73
  readonly tip: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
74
- readonly feeAllowance: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
74
+ readonly fee_allowance: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
75
75
  }, undefined>;
76
76
  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>;
77
77
  readonly program: v.OptionalSchema<v.ObjectSchema<{
@@ -80,18 +80,18 @@ export declare const intent: v.ObjectSchema<{
80
80
  }, undefined>, never>;
81
81
  readonly donor: v.ObjectSchema<{
82
82
  readonly title: v.PicklistSchema<readonly ["Mr", "Mrs", "Ms", "Mx", ""], undefined>;
83
- readonly firstName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
84
- readonly companyName: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, never>;
85
- readonly lastName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
83
+ readonly first_name: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
84
+ readonly company_name: v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, never>;
85
+ readonly last_name: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
86
86
  readonly email: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.EmailAction<string, undefined>]>;
87
87
  readonly address: v.OptionalSchema<v.ObjectSchema<{
88
88
  readonly street: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
89
89
  readonly city: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
90
90
  readonly state: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
91
- readonly zipCode: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
91
+ readonly zip_code: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
92
92
  /** country name */
93
93
  readonly country: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
94
- readonly ukGiftAid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
94
+ readonly uk_gift_aid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
95
95
  }, undefined>, never>;
96
96
  }, undefined>;
97
97
  readonly donor_message: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, v.MaxLengthAction<string, 500, undefined>]>, never>;
package/dist/intent.mjs CHANGED
@@ -1,64 +1,64 @@
1
1
  import * as v from "valibot";
2
2
  const str = v.pipe(v.string(), v.trim());
3
- const requiredStr = v.pipe(str, v.nonEmpty());
3
+ const required_str = v.pipe(str, v.nonEmpty());
4
4
  export const frequencies = ["one-time", "recurring"];
5
5
  export const frequency = v.picklist(frequencies);
6
- export const donationSources = [
6
+ export const donation_sources = [
7
7
  "bg-marketplace",
8
8
  "bg-widget",
9
9
  "tester-app",
10
10
  ];
11
- export const donationSource = v.picklist(donationSources);
12
- export const donorTitles = ["Mr", "Mrs", "Ms", "Mx", ""];
13
- export const donorTitle = v.picklist(donorTitles);
14
- export const donorAddress = v.object({
15
- street: requiredStr,
16
- city: requiredStr,
17
- state: v.optional(requiredStr),
18
- zipCode: v.optional(requiredStr),
11
+ export const donation_source = v.picklist(donation_sources);
12
+ export const donor_titles = ["Mr", "Mrs", "Ms", "Mx", ""];
13
+ export const donor_title = v.picklist(donor_titles);
14
+ export const donor_address = v.object({
15
+ street: required_str,
16
+ city: required_str,
17
+ state: v.optional(required_str),
18
+ zip_code: v.optional(required_str),
19
19
  /** country name */
20
- country: requiredStr,
21
- ukGiftAid: v.optional(v.boolean()),
20
+ country: required_str,
21
+ uk_gift_aid: v.optional(v.boolean()),
22
22
  });
23
23
  export const donor = v.object({
24
- title: donorTitle,
25
- firstName: requiredStr,
26
- companyName: v.optional(str),
27
- lastName: requiredStr,
24
+ title: donor_title,
25
+ first_name: required_str,
26
+ company_name: v.optional(str),
27
+ last_name: required_str,
28
28
  email: v.pipe(str, v.email()),
29
- address: v.optional(donorAddress),
29
+ address: v.optional(donor_address),
30
30
  });
31
31
  const money = v.pipe(v.number(), v.minValue(0));
32
32
  export const amount = v.object({
33
33
  amount: money,
34
- currency: requiredStr,
34
+ currency: required_str,
35
35
  tip: money,
36
- feeAllowance: money,
36
+ fee_allowance: money,
37
37
  });
38
- export const endowId = v.pipe(str, v.transform((x) => +x), v.number(), v.integer(), v.minValue(1));
38
+ export const endow_id = v.pipe(str, v.transform((x) => +x), v.number(), v.integer(), v.minValue(1));
39
39
  export const uuid = v.pipe(str, v.uuid());
40
40
  export const program = v.object({
41
41
  id: uuid,
42
- name: requiredStr,
42
+ name: required_str,
43
43
  });
44
- export const recipient = v.union([endowId, uuid]);
45
- export const tributeNotif = v.object({
44
+ export const recipient = v.union([endow_id, uuid]);
45
+ export const tribute_notif = v.object({
46
46
  toEmail: v.pipe(str, v.email()),
47
47
  toFullName: v.pipe(str, v.nonEmpty()),
48
48
  fromMsg: v.pipe(str, v.maxLength(250)),
49
49
  });
50
50
  export const tribute = v.object({
51
- fullName: requiredStr,
52
- notif: v.optional(tributeNotif),
51
+ fullName: required_str,
52
+ notif: v.optional(tribute_notif),
53
53
  });
54
54
  export const intent = v.object({
55
55
  amount,
56
56
  recipient,
57
57
  program: v.optional(program),
58
58
  donor,
59
- donor_message: v.optional(v.pipe(requiredStr, v.maxLength(500))),
59
+ donor_message: v.optional(v.pipe(required_str, v.maxLength(500))),
60
60
  donor_public: v.optional(v.boolean()),
61
- source: donationSource,
61
+ source: donation_source,
62
62
  tribute: v.optional(tribute),
63
63
  frequency,
64
64
  /** chain name, etc. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-giving/donation",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "devDependencies": {
5
5
  "@better-giving/config": "1.1.2"
6
6
  },
package/src/donation.mts CHANGED
@@ -183,6 +183,8 @@ export declare namespace Donation {
183
183
  fund_id?: string;
184
184
  fund_name?: string;
185
185
  fund_tx?: string;
186
+
187
+ company_name?: string;
186
188
  };
187
189
 
188
190
  type NonKeyAttributes = {
@@ -286,48 +288,6 @@ export declare namespace Donation {
286
288
  fromMsg: string;
287
289
  };
288
290
 
289
- export namespace Intent {
290
- interface Donor {
291
- /** may be empty `''` */
292
- title?: DonorTitle;
293
- firstName: string;
294
- lastName: string;
295
- email: string;
296
- address?: DonorAddress;
297
- /** signifies eligibility to UK Gift Aid, defaults to `false` for crypto donations */
298
- ukGiftAid: boolean;
299
- }
300
-
301
- interface Attr {
302
- transactionId?: string;
303
- amount: number;
304
- tipAmount: number;
305
- feeAllowance: number;
306
- endowmentId: number;
307
- /** program donation: may be empty `""`*/
308
- programId?: string;
309
- programName?: string;
310
- splitLiq: number;
311
- donor: Donor;
312
- /** honorary full name */
313
- inHonorOf?: string;
314
- /** only allowed if honoree is provided */
315
- tributeNotif?: TributeNotif;
316
- source: Source;
317
- }
318
-
319
- interface Crypto extends Attr {
320
- denomination: string;
321
- chainId: ChainID.V2CryptoChainID;
322
- walletAddress?: string;
323
- chainName: string;
324
- }
325
-
326
- interface Fiat extends Attr {
327
- currency: string;
328
- }
329
- }
330
-
331
291
  /** web-app determinant: show signup page or not*/
332
292
  type GuestDonor = {
333
293
  email: string;
@@ -412,6 +372,7 @@ export declare namespace OnHoldDonation {
412
372
  tributeNotif?: Donation.TributeNotif;
413
373
  donor_message?: string;
414
374
  donor_public?: boolean;
375
+ company_name?: string;
415
376
  } & (ApesAttributes | EmptyObject) &
416
377
  (Donation.WithKYC | Donation.WithoutKYC);
417
378
 
package/src/intent.mts CHANGED
@@ -1,46 +1,46 @@
1
1
  import * as v from "valibot";
2
2
 
3
3
  const str = v.pipe(v.string(), v.trim());
4
- const requiredStr = v.pipe(str, v.nonEmpty());
4
+ const required_str = v.pipe(str, v.nonEmpty());
5
5
 
6
6
  export const frequencies = ["one-time", "recurring"] as const;
7
7
  export const frequency = v.picklist(frequencies);
8
8
 
9
9
  export type Frequency = v.InferOutput<typeof frequency>;
10
10
 
11
- export const donationSources = [
11
+ export const donation_sources = [
12
12
  "bg-marketplace",
13
13
  "bg-widget",
14
14
  "tester-app",
15
15
  ] as const;
16
16
 
17
- export const donationSource = v.picklist(donationSources);
18
- export type DonationSource = v.InferOutput<typeof donationSource>;
17
+ export const donation_source = v.picklist(donation_sources);
18
+ export type DonationSource = v.InferOutput<typeof donation_source>;
19
19
 
20
- export const donorTitles = ["Mr", "Mrs", "Ms", "Mx", ""] as const;
21
- export const donorTitle = v.picklist(donorTitles);
20
+ export const donor_titles = ["Mr", "Mrs", "Ms", "Mx", ""] as const;
21
+ export const donor_title = v.picklist(donor_titles);
22
22
 
23
- export type DonorTitle = v.InferOutput<typeof donorTitle>;
23
+ export type DonorTitle = v.InferOutput<typeof donor_title>;
24
24
 
25
- export const donorAddress = v.object({
26
- street: requiredStr,
27
- city: requiredStr,
28
- state: v.optional(requiredStr),
29
- zipCode: v.optional(requiredStr),
25
+ export const donor_address = v.object({
26
+ street: required_str,
27
+ city: required_str,
28
+ state: v.optional(required_str),
29
+ zip_code: v.optional(required_str),
30
30
  /** country name */
31
- country: requiredStr,
32
- ukGiftAid: v.optional(v.boolean()),
31
+ country: required_str,
32
+ uk_gift_aid: v.optional(v.boolean()),
33
33
  });
34
34
 
35
- export type DonorAddress = v.InferOutput<typeof donorAddress>;
35
+ export type DonorAddress = v.InferOutput<typeof donor_address>;
36
36
 
37
37
  export const donor = v.object({
38
- title: donorTitle,
39
- firstName: requiredStr,
40
- companyName: v.optional(str),
41
- lastName: requiredStr,
38
+ title: donor_title,
39
+ first_name: required_str,
40
+ company_name: v.optional(str),
41
+ last_name: required_str,
42
42
  email: v.pipe(str, v.email()),
43
- address: v.optional(donorAddress),
43
+ address: v.optional(donor_address),
44
44
  });
45
45
 
46
46
  export type Donor = v.InferOutput<typeof donor>;
@@ -49,14 +49,14 @@ const money = v.pipe(v.number(), v.minValue(0));
49
49
 
50
50
  export const amount = v.object({
51
51
  amount: money,
52
- currency: requiredStr,
52
+ currency: required_str,
53
53
  tip: money,
54
- feeAllowance: money,
54
+ fee_allowance: money,
55
55
  });
56
56
 
57
57
  export type Amount = v.InferOutput<typeof amount>;
58
58
 
59
- export const endowId = v.pipe(
59
+ export const endow_id = v.pipe(
60
60
  str,
61
61
  v.transform((x) => +x),
62
62
  v.number(),
@@ -67,26 +67,26 @@ export const uuid = v.pipe(str, v.uuid());
67
67
 
68
68
  export const program = v.object({
69
69
  id: uuid,
70
- name: requiredStr,
70
+ name: required_str,
71
71
  });
72
72
 
73
73
  export type Program = v.InferOutput<typeof program>;
74
74
 
75
- export const recipient = v.union([endowId, uuid]);
75
+ export const recipient = v.union([endow_id, uuid]);
76
76
 
77
77
  export type Recipient = v.InferOutput<typeof recipient>;
78
78
 
79
- export const tributeNotif = v.object({
79
+ export const tribute_notif = v.object({
80
80
  toEmail: v.pipe(str, v.email()),
81
81
  toFullName: v.pipe(str, v.nonEmpty()),
82
82
  fromMsg: v.pipe(str, v.maxLength(250)),
83
83
  });
84
84
 
85
- export type TributeNotif = v.InferOutput<typeof tributeNotif>;
85
+ export type TributeNotif = v.InferOutput<typeof tribute_notif>;
86
86
 
87
87
  export const tribute = v.object({
88
- fullName: requiredStr,
89
- notif: v.optional(tributeNotif),
88
+ fullName: required_str,
89
+ notif: v.optional(tribute_notif),
90
90
  });
91
91
 
92
92
  export type Tribute = v.InferOutput<typeof tribute>;
@@ -96,9 +96,9 @@ export const intent = v.object({
96
96
  recipient,
97
97
  program: v.optional(program),
98
98
  donor,
99
- donor_message: v.optional(v.pipe(requiredStr, v.maxLength(500))),
99
+ donor_message: v.optional(v.pipe(required_str, v.maxLength(500))),
100
100
  donor_public: v.optional(v.boolean()),
101
- source: donationSource,
101
+ source: donation_source,
102
102
  tribute: v.optional(tribute),
103
103
  frequency,
104
104
  /** chain name, etc. */
@@ -1,54 +0,0 @@
1
- import type { Donation } from "./donation.mjs";
2
-
3
- type FinalRecord = Pick<
4
- Donation.V2DBRecord,
5
- | "amount"
6
- | "appUsed"
7
- | "chainName"
8
- | "charityName"
9
- | "claimed"
10
- | "denomination"
11
- | "email"
12
- | "endowmentId"
13
- | "feeAllowance"
14
- | "fiatRamp"
15
- | "fiscalSponsored"
16
- | "inHonorOf"
17
- | "isRecurring"
18
- | "network"
19
- | "nonProfitMsg"
20
- | "paymentMethod"
21
- | "programId"
22
- | "programName"
23
- | "splitLiq"
24
- | "tipAmount"
25
- | "transactionDate"
26
- | "transactionId"
27
- | "tributeNotif"
28
- | "usdValue"
29
- >;
30
-
31
- interface SettledAmounts {
32
- settledFee: number;
33
- settledNet: number;
34
- }
35
-
36
- /** donation is to fund */
37
- interface Fund {
38
- fund_id?: string;
39
- fund_name?: string;
40
- fund_members?: number[];
41
- }
42
-
43
- export type FinalRecorderPayload = {
44
- /** intent to delete */
45
- intentId?: string;
46
- hideBgTip: boolean;
47
-
48
- /** donation message */
49
- donor_message?: string;
50
- donor_public?: boolean;
51
- } & FinalRecord &
52
- SettledAmounts &
53
- Fund &
54
- (Donation.WithKYC | Donation.WithoutKYC);
@@ -1,20 +0,0 @@
1
- /**
2
- * @param amount endow amount + tip
3
- * @param rate 0-1, to be applied to amount @example `amount * rate`
4
- * @param flat flat amount added to `amount * rate`. NOTE: make sure that this is in the same unit as `amount`
5
- * @returns number
6
- */
7
- export const getMinFeeAllowance = (
8
- amount: number,
9
- rate: number,
10
- flat = 0
11
- ): number => {
12
- /**
13
- * fee(1) = amount * rate + flat
14
- * fee(2) = (amount + fee(1)) * rate + flat
15
- * fee(3) = (amount + fee(2)) * rate + flat
16
- * i.e. F₍ₙ₎ = a · ∑ᵏ⁼¹ⁿ (rᵏ) + f · ∑ᵏ⁼⁰ⁿ⁻¹ (rᵏ)
17
- * which converges to this formula: n approaches infinity
18
- */
19
- return (amount * rate + flat) / (1 - rate);
20
- };
@@ -1,104 +0,0 @@
1
- import * as v from "valibot";
2
- import {
3
- type Frequency,
4
- donationSource,
5
- donorTitle,
6
- tributeNotif,
7
- uuid,
8
- } from "./intent.mjs";
9
-
10
- const str = v.pipe(v.string(), v.trim());
11
- const requiredStr = v.pipe(str, v.nonEmpty());
12
-
13
- const int = v.pipe(v.number(), v.integer());
14
- const money = v.pipe(v.number(), v.minValue(0));
15
-
16
- const donorAddress = v.object({
17
- streetAddress: requiredStr,
18
- city: str,
19
- state: str,
20
- zipCode: requiredStr,
21
- /** country name */
22
- country: requiredStr,
23
- });
24
-
25
- const donor = v.object({
26
- title: donorTitle,
27
- firstName: requiredStr,
28
- lastName: requiredStr,
29
- email: v.pipe(str, v.email()),
30
- address: v.optional(donorAddress),
31
- ukGiftAid: v.optional(v.boolean()),
32
- });
33
-
34
- export const oldIntent = v.pipe(
35
- v.object({
36
- transactionId: v.optional(str),
37
- type: v.optional(v.picklist(["one-time", "subscription"])),
38
- amount: money,
39
- tipAmount: money,
40
- feeAllowance: money,
41
- currency: v.optional(str),
42
- endowmentId: v.pipe(int, v.minValue(1)),
43
- programId: v.optional(uuid),
44
- programName: v.optional(str),
45
- splitLiq: v.pipe(int, v.minValue(0), v.maxValue(100)),
46
- donor,
47
- inHonorOf: v.optional(str),
48
- tributeNotif: v.optional(tributeNotif),
49
- source: donationSource,
50
- denomination: v.optional(str),
51
- chainId: v.optional(str),
52
- chainName: v.optional(str),
53
- }),
54
- v.transform((input) => ({
55
- amount: {
56
- amount: input.amount,
57
- currency: input.currency ? input.currency : (input.denomination ?? ""),
58
- tip: input.tipAmount,
59
- feeAllowance: input.feeAllowance,
60
- },
61
- recipient: input.endowmentId,
62
- program:
63
- input.programId && input.programName
64
- ? {
65
- id: input.programId,
66
- name: input.programName,
67
- }
68
- : undefined,
69
- donor: {
70
- title: input.donor.title,
71
- firstName: input.donor.firstName,
72
- lastName: input.donor.lastName,
73
- email: input.donor.email,
74
- address: input.donor.address
75
- ? {
76
- street: input.donor.address.streetAddress,
77
- city: input.donor.address.city,
78
- state: input.donor.address.state,
79
- zipCode: input.donor.address.zipCode,
80
- country: input.donor.address.country,
81
- ukGiftAid: input.donor.ukGiftAid,
82
- }
83
- : undefined,
84
- },
85
- source: input.source,
86
- tribute: input.inHonorOf
87
- ? {
88
- fullName: input.inHonorOf,
89
- notif: input.tributeNotif
90
- ? {
91
- toEmail: input.tributeNotif.toEmail,
92
- toFullName: input.tributeNotif.toFullName,
93
- fromMsg: input.tributeNotif.fromMsg,
94
- }
95
- : undefined,
96
- }
97
- : undefined,
98
- frequency: (input.type === "subscription"
99
- ? "recurring"
100
- : (input.type ?? "one-time")) as Frequency,
101
- viaName: input.chainName ?? "fiat",
102
- viaId: input.chainId ? input.chainId : (input.transactionId ?? "fiat"),
103
- }))
104
- );