@better-giving/donation 2.0.0 → 2.0.2
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/donation.d.mts +5 -4
- package/dist/final-recorder.d.mts +0 -3
- package/dist/intent.d.mts +38 -43
- package/dist/intent.mjs +30 -34
- package/dist/old-intent.mjs +3 -3
- package/dist/schema.d.mts +20 -0
- package/dist/schema.mjs +17 -0
- package/package.json +2 -2
- package/src/donation.mts +5 -5
- package/src/schema.mts +34 -0
- package/src/intent.mts +0 -111
package/dist/donation.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ISODate } from "@better-giving/types/alias";
|
|
2
2
|
import type { ChainID, Environment } from "@better-giving/types/list";
|
|
3
3
|
import type { EmptyObject, OrStr } from "@better-giving/types/utils";
|
|
4
|
+
import type { Allocation, DonorTitle, Frequency } from "./schema.mjs";
|
|
4
5
|
export declare namespace Donation {
|
|
5
6
|
type Index = "AppUsed_Index" | "Checked-8283_Index" | "Email_Index" | "EndowmentId_Index" | "FundDeposits_Index" | "Tax-Receipt-Sent_Index" | "Network-FinalizedDate_Index" | "WalletAddress_Index" | "Referrer-FinalizedDate_index";
|
|
6
7
|
type App = "aging" | "angel-protocol" | "bg-marketplace" | "bg-widget" | "black-history-month" | "make-whole" | "mental-health" | "restore-earth" | "tester-app" | "ukraine-portal";
|
|
@@ -53,7 +54,6 @@ export declare namespace Donation {
|
|
|
53
54
|
type WalletAddress_Index = {
|
|
54
55
|
walletAddress?: string;
|
|
55
56
|
};
|
|
56
|
-
type DonorTitle = "Mr" | "Ms" | "Mrs" | "Mx";
|
|
57
57
|
type DonorBasicInfo = {
|
|
58
58
|
/** may be empty */
|
|
59
59
|
title?: DonorTitle;
|
|
@@ -136,6 +136,7 @@ export declare namespace Donation {
|
|
|
136
136
|
fund_name?: string;
|
|
137
137
|
fund_tx?: string;
|
|
138
138
|
company_name?: string;
|
|
139
|
+
allocation?: Allocation;
|
|
139
140
|
};
|
|
140
141
|
type NonKeyAttributes = {
|
|
141
142
|
addressComplement?: " ";
|
|
@@ -272,6 +273,7 @@ export declare namespace OnHoldDonation {
|
|
|
272
273
|
msg_to_npo?: string;
|
|
273
274
|
donor_public?: boolean;
|
|
274
275
|
company_name?: string;
|
|
276
|
+
allocation?: Allocation;
|
|
275
277
|
} & (ApesAttributes | EmptyObject) & (Donation.WithKYC | Donation.WithoutKYC);
|
|
276
278
|
type CryptoDBRecord = PrimaryKey & NonKeyAttributes & CryptoAttributes & Donation.EmailIndexKey;
|
|
277
279
|
type FiatDBRecord = PrimaryKey & Required<Donation.FiatRamp_IndexKey> & NonKeyAttributes & FiatAttributes & Required<Donation.EmailIndexKey>;
|
|
@@ -286,7 +288,6 @@ export declare namespace FiatDonations {
|
|
|
286
288
|
rate: number;
|
|
287
289
|
timestamp: string;
|
|
288
290
|
};
|
|
289
|
-
type Frequency = "one-time" | "subscription";
|
|
290
291
|
}
|
|
291
292
|
export declare namespace PayPalDonation {
|
|
292
293
|
type CreateOrder = {
|
|
@@ -356,7 +357,7 @@ export declare namespace StripeDonation {
|
|
|
356
357
|
/** DEPRECATED - can be removed eventually as existing records will eventually "expire" */
|
|
357
358
|
type LegacyMetadata = {
|
|
358
359
|
/** This attr will help in identifying PaymentIntents made for one-time donations only */
|
|
359
|
-
donation_type: Extract<
|
|
360
|
+
donation_type: Extract<Frequency, "one-time">;
|
|
360
361
|
/** This attr will link the received webhook event to a donation intent */
|
|
361
362
|
intent_tx_id: string;
|
|
362
363
|
};
|
|
@@ -367,7 +368,7 @@ export declare namespace StripeDonation {
|
|
|
367
368
|
type Metadata = {
|
|
368
369
|
[K in keyof OnHoldDonation.FiatDBRecord]: string;
|
|
369
370
|
} & {
|
|
370
|
-
title?:
|
|
371
|
+
title?: DonorTitle;
|
|
371
372
|
fullName: string;
|
|
372
373
|
ukGiftAid: string;
|
|
373
374
|
streetAddress?: string;
|
|
@@ -14,8 +14,5 @@ export type FinalRecorderPayload = {
|
|
|
14
14
|
/** intent to delete */
|
|
15
15
|
intentId?: string;
|
|
16
16
|
hideBgTip: boolean;
|
|
17
|
-
/** donation message */
|
|
18
|
-
donor_message?: string;
|
|
19
|
-
donor_public?: boolean;
|
|
20
17
|
} & FinalRecord & SettledAmounts & Fund & (Donation.WithKYC | Donation.WithoutKYC);
|
|
21
18
|
export {};
|
package/dist/intent.d.mts
CHANGED
|
@@ -2,47 +2,46 @@ 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
|
|
6
|
-
export declare const
|
|
7
|
-
export type DonationSource = v.InferOutput<typeof
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export type DonorTitle = v.InferOutput<typeof
|
|
11
|
-
export declare const
|
|
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<{
|
|
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
|
|
15
|
+
readonly zipCode: 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
|
|
18
|
+
readonly ukGiftAid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
19
19
|
}, undefined>;
|
|
20
|
-
export type DonorAddress = v.InferOutput<typeof
|
|
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
|
|
24
|
-
readonly
|
|
25
|
-
readonly last_name: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<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>]>;
|
|
26
25
|
readonly email: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.EmailAction<string, undefined>]>;
|
|
27
26
|
readonly address: v.OptionalSchema<v.ObjectSchema<{
|
|
28
27
|
readonly street: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
|
|
29
28
|
readonly city: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
|
|
30
29
|
readonly state: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
|
|
31
|
-
readonly
|
|
30
|
+
readonly zipCode: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
|
|
32
31
|
/** country name */
|
|
33
32
|
readonly country: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
|
|
34
|
-
readonly
|
|
33
|
+
readonly ukGiftAid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
35
34
|
}, undefined>, never>;
|
|
36
35
|
}, undefined>;
|
|
37
36
|
export type Donor = v.InferOutput<typeof donor>;
|
|
38
37
|
export declare const amount: v.ObjectSchema<{
|
|
39
38
|
readonly amount: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
40
|
-
readonly currency: v.SchemaWithPipe<[v.SchemaWithPipe<[v.
|
|
39
|
+
readonly currency: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
|
|
41
40
|
readonly tip: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
42
|
-
readonly
|
|
41
|
+
readonly feeAllowance: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
43
42
|
}, undefined>;
|
|
44
43
|
export type Amount = v.InferOutput<typeof amount>;
|
|
45
|
-
export declare const
|
|
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>]>;
|
|
46
45
|
export declare const uuid: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.UuidAction<string, undefined>]>;
|
|
47
46
|
export declare const program: v.ObjectSchema<{
|
|
48
47
|
readonly id: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.UuidAction<string, undefined>]>;
|
|
@@ -51,27 +50,27 @@ export declare const program: v.ObjectSchema<{
|
|
|
51
50
|
export type Program = v.InferOutput<typeof program>;
|
|
52
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>;
|
|
53
52
|
export type Recipient = v.InferOutput<typeof recipient>;
|
|
54
|
-
export declare const
|
|
55
|
-
readonly
|
|
56
|
-
readonly
|
|
57
|
-
readonly
|
|
53
|
+
export declare const tributeNotif: v.ObjectSchema<{
|
|
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>]>;
|
|
58
57
|
}, undefined>;
|
|
59
|
-
export type TributeNotif = v.InferOutput<typeof
|
|
58
|
+
export type TributeNotif = v.InferOutput<typeof tributeNotif>;
|
|
60
59
|
export declare const tribute: v.ObjectSchema<{
|
|
61
|
-
readonly
|
|
60
|
+
readonly fullName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
|
|
62
61
|
readonly notif: v.OptionalSchema<v.ObjectSchema<{
|
|
63
|
-
readonly
|
|
64
|
-
readonly
|
|
65
|
-
readonly
|
|
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>]>;
|
|
66
65
|
}, undefined>, never>;
|
|
67
66
|
}, undefined>;
|
|
68
67
|
export type Tribute = v.InferOutput<typeof tribute>;
|
|
69
68
|
export declare const intent: v.ObjectSchema<{
|
|
70
69
|
readonly amount: v.ObjectSchema<{
|
|
71
70
|
readonly amount: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
72
|
-
readonly currency: v.SchemaWithPipe<[v.SchemaWithPipe<[v.
|
|
71
|
+
readonly currency: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
|
|
73
72
|
readonly tip: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
74
|
-
readonly
|
|
73
|
+
readonly feeAllowance: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
75
74
|
}, undefined>;
|
|
76
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>;
|
|
77
76
|
readonly program: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -80,36 +79,32 @@ export declare const intent: v.ObjectSchema<{
|
|
|
80
79
|
}, undefined>, never>;
|
|
81
80
|
readonly donor: v.ObjectSchema<{
|
|
82
81
|
readonly title: v.PicklistSchema<readonly ["Mr", "Mrs", "Ms", "Mx", ""], undefined>;
|
|
83
|
-
readonly
|
|
84
|
-
readonly
|
|
85
|
-
readonly last_name: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<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>]>;
|
|
86
84
|
readonly email: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.EmailAction<string, undefined>]>;
|
|
87
85
|
readonly address: v.OptionalSchema<v.ObjectSchema<{
|
|
88
86
|
readonly street: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
|
|
89
87
|
readonly city: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
|
|
90
88
|
readonly state: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
|
|
91
|
-
readonly
|
|
89
|
+
readonly zipCode: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, never>;
|
|
92
90
|
/** country name */
|
|
93
91
|
readonly country: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
|
|
94
|
-
readonly
|
|
92
|
+
readonly ukGiftAid: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
95
93
|
}, undefined>, never>;
|
|
96
94
|
}, undefined>;
|
|
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>;
|
|
98
|
-
readonly donor_public: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
99
|
-
readonly msg_to_npo: v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>, v.MaxLengthAction<string, 500, undefined>]>, never>;
|
|
100
95
|
readonly source: v.PicklistSchema<readonly ["bg-marketplace", "bg-widget", "tester-app"], undefined>;
|
|
101
96
|
readonly tribute: v.OptionalSchema<v.ObjectSchema<{
|
|
102
|
-
readonly
|
|
97
|
+
readonly fullName: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, undefined>]>;
|
|
103
98
|
readonly notif: v.OptionalSchema<v.ObjectSchema<{
|
|
104
|
-
readonly
|
|
105
|
-
readonly
|
|
106
|
-
readonly
|
|
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>]>;
|
|
107
102
|
}, undefined>, never>;
|
|
108
103
|
}, undefined>, never>;
|
|
109
104
|
readonly frequency: v.PicklistSchema<readonly ["one-time", "recurring"], undefined>;
|
|
110
105
|
/** chain name, etc. */
|
|
111
|
-
readonly
|
|
106
|
+
readonly viaName: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>;
|
|
112
107
|
/** chain id, workflow-session-id, etc. */
|
|
113
|
-
readonly
|
|
108
|
+
readonly viaId: v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>;
|
|
114
109
|
}, undefined>;
|
|
115
110
|
export type DonationIntent = v.InferOutput<typeof intent>;
|
package/dist/intent.mjs
CHANGED
|
@@ -1,69 +1,65 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
const str = v.pipe(v.string(), v.trim());
|
|
3
|
-
const
|
|
3
|
+
const requiredStr = v.pipe(str, v.nonEmpty());
|
|
4
4
|
export const frequencies = ["one-time", "recurring"];
|
|
5
5
|
export const frequency = v.picklist(frequencies);
|
|
6
|
-
export const
|
|
6
|
+
export const donationSources = [
|
|
7
7
|
"bg-marketplace",
|
|
8
8
|
"bg-widget",
|
|
9
9
|
"tester-app",
|
|
10
10
|
];
|
|
11
|
-
export const
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
15
|
-
street:
|
|
16
|
-
city:
|
|
17
|
-
state: v.optional(
|
|
18
|
-
|
|
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),
|
|
19
19
|
/** country name */
|
|
20
|
-
country:
|
|
21
|
-
|
|
20
|
+
country: requiredStr,
|
|
21
|
+
ukGiftAid: v.optional(v.boolean()),
|
|
22
22
|
});
|
|
23
23
|
export const donor = v.object({
|
|
24
|
-
title:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
last_name: required_str,
|
|
24
|
+
title: donorTitle,
|
|
25
|
+
firstName: requiredStr,
|
|
26
|
+
lastName: requiredStr,
|
|
28
27
|
email: v.pipe(str, v.email()),
|
|
29
|
-
address: v.optional(
|
|
28
|
+
address: v.optional(donorAddress),
|
|
30
29
|
});
|
|
31
30
|
const money = v.pipe(v.number(), v.minValue(0));
|
|
32
31
|
export const amount = v.object({
|
|
33
32
|
amount: money,
|
|
34
|
-
currency:
|
|
33
|
+
currency: requiredStr,
|
|
35
34
|
tip: money,
|
|
36
|
-
|
|
35
|
+
feeAllowance: money,
|
|
37
36
|
});
|
|
38
|
-
export const
|
|
37
|
+
export const endowId = v.pipe(str, v.transform((x) => +x), v.number(), v.integer(), v.minValue(1));
|
|
39
38
|
export const uuid = v.pipe(str, v.uuid());
|
|
40
39
|
export const program = v.object({
|
|
41
40
|
id: uuid,
|
|
42
|
-
name:
|
|
41
|
+
name: requiredStr,
|
|
43
42
|
});
|
|
44
|
-
export const recipient = v.union([
|
|
45
|
-
export const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
export const recipient = v.union([endowId, uuid]);
|
|
44
|
+
export const tributeNotif = v.object({
|
|
45
|
+
toEmail: v.pipe(str, v.email()),
|
|
46
|
+
toFullName: v.pipe(str, v.nonEmpty()),
|
|
47
|
+
fromMsg: v.pipe(str, v.maxLength(250)),
|
|
49
48
|
});
|
|
50
49
|
export const tribute = v.object({
|
|
51
|
-
|
|
52
|
-
notif: v.optional(
|
|
50
|
+
fullName: requiredStr,
|
|
51
|
+
notif: v.optional(tributeNotif),
|
|
53
52
|
});
|
|
54
53
|
export const intent = v.object({
|
|
55
54
|
amount,
|
|
56
55
|
recipient,
|
|
57
56
|
program: v.optional(program),
|
|
58
57
|
donor,
|
|
59
|
-
|
|
60
|
-
donor_public: v.optional(v.boolean()),
|
|
61
|
-
msg_to_npo: v.optional(v.pipe(required_str, v.maxLength(500))),
|
|
62
|
-
source: donation_source,
|
|
58
|
+
source: donationSource,
|
|
63
59
|
tribute: v.optional(tribute),
|
|
64
60
|
frequency,
|
|
65
61
|
/** chain name, etc. */
|
|
66
|
-
|
|
62
|
+
viaName: str,
|
|
67
63
|
/** chain id, workflow-session-id, etc. */
|
|
68
|
-
|
|
64
|
+
viaId: str,
|
|
69
65
|
});
|
package/dist/old-intent.mjs
CHANGED
|
@@ -41,7 +41,7 @@ export const oldIntent = v.pipe(v.object({
|
|
|
41
41
|
}), v.transform((input) => ({
|
|
42
42
|
amount: {
|
|
43
43
|
amount: input.amount,
|
|
44
|
-
currency: input.currency ? input.currency :
|
|
44
|
+
currency: input.currency ? input.currency : input.denomination ?? "",
|
|
45
45
|
tip: input.tipAmount,
|
|
46
46
|
feeAllowance: input.feeAllowance,
|
|
47
47
|
},
|
|
@@ -83,7 +83,7 @@ export const oldIntent = v.pipe(v.object({
|
|
|
83
83
|
: undefined,
|
|
84
84
|
frequency: (input.type === "subscription"
|
|
85
85
|
? "recurring"
|
|
86
|
-
:
|
|
86
|
+
: input.type ?? "one-time"),
|
|
87
87
|
viaName: input.chainName ?? "fiat",
|
|
88
|
-
viaId: input.chainId ? input.chainId :
|
|
88
|
+
viaId: input.chainId ? input.chainId : input.transactionId ?? "fiat",
|
|
89
89
|
})));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const frequencies: readonly ["one-time", "recurring"];
|
|
3
|
+
export declare const frequency: v.PicklistSchema<readonly ["one-time", "recurring"], "Please select donation frequency">;
|
|
4
|
+
export type Frequency = v.InferOutput<typeof frequency>;
|
|
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 allocation: v.SchemaWithPipe<[v.ObjectSchema<{
|
|
12
|
+
readonly liq: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
|
|
13
|
+
readonly lock: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
|
|
14
|
+
readonly cash: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
|
|
15
|
+
}, undefined>, v.CheckAction<{
|
|
16
|
+
liq: number;
|
|
17
|
+
lock: number;
|
|
18
|
+
cash: number;
|
|
19
|
+
}, "Allocation must sum to 100%">]>;
|
|
20
|
+
export type Allocation = v.InferOutput<typeof allocation>;
|
package/dist/schema.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const frequencies = ["one-time", "recurring"];
|
|
3
|
+
export const frequency = v.picklist(frequencies, "Please select donation frequency");
|
|
4
|
+
export const donation_sources = [
|
|
5
|
+
"bg-marketplace",
|
|
6
|
+
"bg-widget",
|
|
7
|
+
"tester-app",
|
|
8
|
+
];
|
|
9
|
+
export const donation_source = v.picklist(donation_sources);
|
|
10
|
+
export const donor_titles = ["Mr", "Mrs", "Ms", "Mx", ""];
|
|
11
|
+
export const donor_title = v.picklist(donor_titles);
|
|
12
|
+
const pct = v.pipe(v.number(), v.minValue(0), v.maxValue(100));
|
|
13
|
+
export const allocation = v.pipe(v.object({
|
|
14
|
+
liq: pct,
|
|
15
|
+
lock: pct,
|
|
16
|
+
cash: pct,
|
|
17
|
+
}), v.check((x) => x.liq + x.lock + x.cash === 100, "Allocation must sum to 100%"));
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-giving/donation",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@better-giving/config": "1.1.2"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@better-giving/types": "1.1.7",
|
|
9
|
-
"@better-giving/schemas": "1.2.
|
|
9
|
+
"@better-giving/schemas": "1.2.2",
|
|
10
10
|
"valibot": "0.42.0"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
package/src/donation.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ISODate } from "@better-giving/types/alias";
|
|
2
2
|
import type { ChainID, Environment } from "@better-giving/types/list";
|
|
3
3
|
import type { EmptyObject, OrStr } from "@better-giving/types/utils";
|
|
4
|
+
import type { Allocation, DonorTitle, Frequency } from "./schema.mjs";
|
|
4
5
|
|
|
5
6
|
export declare namespace Donation {
|
|
6
7
|
type Index =
|
|
@@ -91,7 +92,6 @@ export declare namespace Donation {
|
|
|
91
92
|
walletAddress?: string; //PK
|
|
92
93
|
};
|
|
93
94
|
|
|
94
|
-
type DonorTitle = "Mr" | "Ms" | "Mrs" | "Mx";
|
|
95
95
|
type DonorBasicInfo = {
|
|
96
96
|
/** may be empty */
|
|
97
97
|
title?: DonorTitle;
|
|
@@ -186,6 +186,7 @@ export declare namespace Donation {
|
|
|
186
186
|
fund_tx?: string;
|
|
187
187
|
|
|
188
188
|
company_name?: string;
|
|
189
|
+
allocation?: Allocation;
|
|
189
190
|
};
|
|
190
191
|
|
|
191
192
|
type NonKeyAttributes = {
|
|
@@ -375,6 +376,7 @@ export declare namespace OnHoldDonation {
|
|
|
375
376
|
msg_to_npo?: string;
|
|
376
377
|
donor_public?: boolean;
|
|
377
378
|
company_name?: string;
|
|
379
|
+
allocation?: Allocation;
|
|
378
380
|
} & (ApesAttributes | EmptyObject) &
|
|
379
381
|
(Donation.WithKYC | Donation.WithoutKYC);
|
|
380
382
|
|
|
@@ -402,8 +404,6 @@ export declare namespace FiatDonations {
|
|
|
402
404
|
rate: number;
|
|
403
405
|
timestamp: string;
|
|
404
406
|
};
|
|
405
|
-
|
|
406
|
-
type Frequency = "one-time" | "subscription";
|
|
407
407
|
}
|
|
408
408
|
|
|
409
409
|
export declare namespace PayPalDonation {
|
|
@@ -486,7 +486,7 @@ export declare namespace StripeDonation {
|
|
|
486
486
|
/** DEPRECATED - can be removed eventually as existing records will eventually "expire" */
|
|
487
487
|
type LegacyMetadata = {
|
|
488
488
|
/** This attr will help in identifying PaymentIntents made for one-time donations only */
|
|
489
|
-
donation_type: Extract<
|
|
489
|
+
donation_type: Extract<Frequency, "one-time">;
|
|
490
490
|
/** This attr will link the received webhook event to a donation intent */
|
|
491
491
|
intent_tx_id: string;
|
|
492
492
|
};
|
|
@@ -499,7 +499,7 @@ export declare namespace StripeDonation {
|
|
|
499
499
|
[K in keyof OnHoldDonation.FiatDBRecord]: string;
|
|
500
500
|
} & {
|
|
501
501
|
// KYC fields
|
|
502
|
-
title?:
|
|
502
|
+
title?: DonorTitle;
|
|
503
503
|
fullName: string;
|
|
504
504
|
ukGiftAid: string;
|
|
505
505
|
streetAddress?: string;
|
package/src/schema.mts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const frequencies = ["one-time", "recurring"] as const;
|
|
3
|
+
export const frequency = v.picklist(
|
|
4
|
+
frequencies,
|
|
5
|
+
"Please select donation frequency"
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export type Frequency = v.InferOutput<typeof frequency>;
|
|
9
|
+
|
|
10
|
+
export const donation_sources = [
|
|
11
|
+
"bg-marketplace",
|
|
12
|
+
"bg-widget",
|
|
13
|
+
"tester-app",
|
|
14
|
+
] as const;
|
|
15
|
+
|
|
16
|
+
export const donation_source = v.picklist(donation_sources);
|
|
17
|
+
export type DonationSource = v.InferOutput<typeof donation_source>;
|
|
18
|
+
|
|
19
|
+
export const donor_titles = ["Mr", "Mrs", "Ms", "Mx", ""] as const;
|
|
20
|
+
export const donor_title = v.picklist(donor_titles);
|
|
21
|
+
|
|
22
|
+
export type DonorTitle = v.InferOutput<typeof donor_title>;
|
|
23
|
+
|
|
24
|
+
const pct = v.pipe(v.number(), v.minValue(0), v.maxValue(100));
|
|
25
|
+
export const allocation = v.pipe(
|
|
26
|
+
v.object({
|
|
27
|
+
liq: pct,
|
|
28
|
+
lock: pct,
|
|
29
|
+
cash: pct,
|
|
30
|
+
}),
|
|
31
|
+
v.check((x) => x.liq + x.lock + x.cash === 100, "Allocation must sum to 100%")
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export type Allocation = v.InferOutput<typeof allocation>;
|
package/src/intent.mts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
|
|
3
|
-
const str = v.pipe(v.string(), v.trim());
|
|
4
|
-
const required_str = v.pipe(str, v.nonEmpty());
|
|
5
|
-
|
|
6
|
-
export const frequencies = ["one-time", "recurring"] as const;
|
|
7
|
-
export const frequency = v.picklist(frequencies);
|
|
8
|
-
|
|
9
|
-
export type Frequency = v.InferOutput<typeof frequency>;
|
|
10
|
-
|
|
11
|
-
export const donation_sources = [
|
|
12
|
-
"bg-marketplace",
|
|
13
|
-
"bg-widget",
|
|
14
|
-
"tester-app",
|
|
15
|
-
] as const;
|
|
16
|
-
|
|
17
|
-
export const donation_source = v.picklist(donation_sources);
|
|
18
|
-
export type DonationSource = v.InferOutput<typeof donation_source>;
|
|
19
|
-
|
|
20
|
-
export const donor_titles = ["Mr", "Mrs", "Ms", "Mx", ""] as const;
|
|
21
|
-
export const donor_title = v.picklist(donor_titles);
|
|
22
|
-
|
|
23
|
-
export type DonorTitle = v.InferOutput<typeof donor_title>;
|
|
24
|
-
|
|
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
|
-
/** country name */
|
|
31
|
-
country: required_str,
|
|
32
|
-
uk_gift_aid: v.optional(v.boolean()),
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
export type DonorAddress = v.InferOutput<typeof donor_address>;
|
|
36
|
-
|
|
37
|
-
export const donor = v.object({
|
|
38
|
-
title: donor_title,
|
|
39
|
-
first_name: required_str,
|
|
40
|
-
company_name: v.optional(str),
|
|
41
|
-
last_name: required_str,
|
|
42
|
-
email: v.pipe(str, v.email()),
|
|
43
|
-
address: v.optional(donor_address),
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export type Donor = v.InferOutput<typeof donor>;
|
|
47
|
-
|
|
48
|
-
const money = v.pipe(v.number(), v.minValue(0));
|
|
49
|
-
|
|
50
|
-
export const amount = v.object({
|
|
51
|
-
amount: money,
|
|
52
|
-
currency: v.pipe(required_str, v.toUpperCase()),
|
|
53
|
-
tip: money,
|
|
54
|
-
fee_allowance: money,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
export type Amount = v.InferOutput<typeof amount>;
|
|
58
|
-
|
|
59
|
-
export const endow_id = v.pipe(
|
|
60
|
-
str,
|
|
61
|
-
v.transform((x) => +x),
|
|
62
|
-
v.number(),
|
|
63
|
-
v.integer(),
|
|
64
|
-
v.minValue(1)
|
|
65
|
-
);
|
|
66
|
-
export const uuid = v.pipe(str, v.uuid());
|
|
67
|
-
|
|
68
|
-
export const program = v.object({
|
|
69
|
-
id: uuid,
|
|
70
|
-
name: required_str,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
export type Program = v.InferOutput<typeof program>;
|
|
74
|
-
|
|
75
|
-
export const recipient = v.union([endow_id, uuid]);
|
|
76
|
-
|
|
77
|
-
export type Recipient = v.InferOutput<typeof recipient>;
|
|
78
|
-
|
|
79
|
-
export const tribute_notif = v.object({
|
|
80
|
-
to_email: v.pipe(str, v.email()),
|
|
81
|
-
to_fullname: v.pipe(str, v.nonEmpty()),
|
|
82
|
-
from_msg: v.pipe(str, v.maxLength(250)),
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
export type TributeNotif = v.InferOutput<typeof tribute_notif>;
|
|
86
|
-
|
|
87
|
-
export const tribute = v.object({
|
|
88
|
-
full_name: required_str,
|
|
89
|
-
notif: v.optional(tribute_notif),
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
export type Tribute = v.InferOutput<typeof tribute>;
|
|
93
|
-
|
|
94
|
-
export const intent = v.object({
|
|
95
|
-
amount,
|
|
96
|
-
recipient,
|
|
97
|
-
program: v.optional(program),
|
|
98
|
-
donor,
|
|
99
|
-
donor_message: v.optional(v.pipe(required_str, v.maxLength(500))),
|
|
100
|
-
donor_public: v.optional(v.boolean()),
|
|
101
|
-
msg_to_npo: v.optional(v.pipe(required_str, v.maxLength(500))),
|
|
102
|
-
source: donation_source,
|
|
103
|
-
tribute: v.optional(tribute),
|
|
104
|
-
frequency,
|
|
105
|
-
/** chain name, etc. */
|
|
106
|
-
via_name: str,
|
|
107
|
-
/** chain id, workflow-session-id, etc. */
|
|
108
|
-
via_id: str,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
export type DonationIntent = v.InferOutput<typeof intent>;
|