@better-giving/donation 1.0.0
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 +400 -0
- package/dist/donation.mjs +1 -0
- package/dist/final-recorder.d.mts +18 -0
- package/dist/final-recorder.mjs +1 -0
- package/dist/get-min-fee-allowance.d.mts +7 -0
- package/dist/get-min-fee-allowance.mjs +16 -0
- package/dist/intent.d.mts +110 -0
- package/dist/intent.mjs +64 -0
- package/dist/subscription.d.mts +32 -0
- package/dist/subscription.mjs +1 -0
- package/package.json +23 -0
- package/src/donation.mts +535 -0
- package/src/final-recorder.mts +48 -0
- package/src/get-min-fee-allowance.mts +20 -0
- package/src/intent.mts +100 -0
- package/src/subscription.mts +34 -0
package/src/intent.mts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
|
|
3
|
+
const str = v.pipe(v.string(), v.trim(), v.nonEmpty());
|
|
4
|
+
|
|
5
|
+
export const frequencies = ["one-time", "recurring"] as const;
|
|
6
|
+
export const frequency = v.picklist(frequencies);
|
|
7
|
+
|
|
8
|
+
export type Frequency = v.InferOutput<typeof frequency>;
|
|
9
|
+
|
|
10
|
+
export const donationSources = [
|
|
11
|
+
"bg-marketplace",
|
|
12
|
+
"bg-widget",
|
|
13
|
+
"tester-app",
|
|
14
|
+
] as const;
|
|
15
|
+
|
|
16
|
+
export const donationSource = v.picklist(donationSources);
|
|
17
|
+
export type DonationSource = v.InferOutput<typeof donationSource>;
|
|
18
|
+
|
|
19
|
+
export const donorTitles = ["Mr", "Mrs", "Ms", "Mx"] as const;
|
|
20
|
+
export const donorTitle = v.picklist(donorTitles);
|
|
21
|
+
|
|
22
|
+
export type DonorTitle = v.InferOutput<typeof donorTitle>;
|
|
23
|
+
|
|
24
|
+
export const donorAddress = v.object({
|
|
25
|
+
street: str,
|
|
26
|
+
city: str,
|
|
27
|
+
state: v.optional(str),
|
|
28
|
+
zipCode: v.optional(str),
|
|
29
|
+
/** country name */
|
|
30
|
+
country: str,
|
|
31
|
+
ukGiftAid: v.optional(v.boolean()),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export type DonorAddress = v.InferOutput<typeof donorAddress>;
|
|
35
|
+
|
|
36
|
+
export const donor = v.object({
|
|
37
|
+
title: donorTitle,
|
|
38
|
+
firstName: str,
|
|
39
|
+
lastName: str,
|
|
40
|
+
email: v.pipe(str, v.email()),
|
|
41
|
+
address: v.optional(donorAddress),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export type Donor = v.InferOutput<typeof donor>;
|
|
45
|
+
|
|
46
|
+
const money = v.pipe(v.number(), v.minValue(0));
|
|
47
|
+
|
|
48
|
+
export const amount = v.object({
|
|
49
|
+
amount: money,
|
|
50
|
+
currency: str,
|
|
51
|
+
tip: money,
|
|
52
|
+
feeAllowance: money,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export type Amount = v.InferOutput<typeof amount>;
|
|
56
|
+
|
|
57
|
+
export const endowId = v.pipe(v.number(), v.integer(), v.minValue(1));
|
|
58
|
+
export const uuid = v.pipe(str, v.uuid());
|
|
59
|
+
|
|
60
|
+
export const program = v.object({
|
|
61
|
+
id: uuid,
|
|
62
|
+
name: str,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export type Program = v.InferOutput<typeof program>;
|
|
66
|
+
|
|
67
|
+
export const recipient = v.union([endowId, uuid]);
|
|
68
|
+
|
|
69
|
+
export type Recipient = v.InferOutput<typeof recipient>;
|
|
70
|
+
|
|
71
|
+
export const tributeNotif = v.object({
|
|
72
|
+
toEmail: v.pipe(str, v.email()),
|
|
73
|
+
toFullName: str,
|
|
74
|
+
fromMsg: v.optional(v.pipe(v.string(), v.maxLength(250))),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export type TributeNotif = v.InferOutput<typeof tributeNotif>;
|
|
78
|
+
|
|
79
|
+
export const tribute = v.object({
|
|
80
|
+
fullName: str,
|
|
81
|
+
notif: v.optional(tributeNotif),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export type Tribute = v.InferOutput<typeof tribute>;
|
|
85
|
+
|
|
86
|
+
export const intent = v.object({
|
|
87
|
+
amount,
|
|
88
|
+
recipient,
|
|
89
|
+
program: v.optional(program),
|
|
90
|
+
donor,
|
|
91
|
+
source: donationSource,
|
|
92
|
+
tribute: v.optional(tribute),
|
|
93
|
+
frequency,
|
|
94
|
+
/** chain name, etc. */
|
|
95
|
+
viaName: str,
|
|
96
|
+
/** chain id, workflow-session-id, etc. */
|
|
97
|
+
viaId: str,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export type DonationIntent = v.InferOutput<typeof intent>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Environment } from "@better-giving/types/list";
|
|
2
|
+
import type { Donation } from "./donation.mjs";
|
|
3
|
+
|
|
4
|
+
export declare namespace Subscription {
|
|
5
|
+
interface PrimaryKey {
|
|
6
|
+
subscription_id: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface NonKeyAttributes {
|
|
10
|
+
app_used: Donation.App;
|
|
11
|
+
charity_name: string;
|
|
12
|
+
customer_id: string;
|
|
13
|
+
email: string;
|
|
14
|
+
endowment_id: number;
|
|
15
|
+
fiat_ramp: "STRIPE";
|
|
16
|
+
fiscal_sponsored: boolean;
|
|
17
|
+
hide_bg_tip: boolean;
|
|
18
|
+
/** URL link to latest invoice */
|
|
19
|
+
latest_invoice?: string;
|
|
20
|
+
network: Environment;
|
|
21
|
+
product_id: string;
|
|
22
|
+
/**
|
|
23
|
+
* Determines overall price the user has to pay
|
|
24
|
+
* For example, we have a recurring subscription plan of $1 per month.
|
|
25
|
+
* If quantity is set to 2 then the user pays $2 per month
|
|
26
|
+
*/
|
|
27
|
+
quantity: number;
|
|
28
|
+
split_liq: string;
|
|
29
|
+
/** @link https://docs.stripe.com/billing/subscriptions/overview#payment-status */
|
|
30
|
+
status: "active" | "incomplete";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface DBRecord extends PrimaryKey, NonKeyAttributes {}
|
|
34
|
+
}
|