@ttt-productions/ttt-core 0.79.69 → 0.79.70
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.
|
@@ -6,9 +6,22 @@ export declare const PLEDGE_PAYMENT_SUMMED_AMOUNT_FIELDS: readonly ["amount", "n
|
|
|
6
6
|
export type PledgePaymentAmountSums = Pick<PledgePayment, (typeof PLEDGE_PAYMENT_SUMMED_AMOUNT_FIELDS)[number]>;
|
|
7
7
|
/**
|
|
8
8
|
* The counters from the summed pledge amounts. `totalRefunded` is money that left the platform:
|
|
9
|
-
* refunds plus funds withdrawn by a lost dispute.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* refunds plus funds withdrawn by a lost dispute. `pledgeCount` is the number of those pledges that
|
|
10
|
+
* still count (`isPledgePaymentCounted`) — a sum cannot say how many pledges kept money, so the
|
|
11
|
+
* caller counts them. The money formula is linear, so it gives the whole ledger's totals from the
|
|
12
|
+
* ledger's sums; one pledge's share is `pledgePaymentContributionOf`.
|
|
12
13
|
*/
|
|
13
14
|
export declare function pledgePaymentTotalsOf(sums: PledgePaymentAmountSums, pledgeCount: number): PledgePaymentTotals;
|
|
15
|
+
/**
|
|
16
|
+
* A pledge counts — in the pledge count and toward the Supporter badge — while it still holds money:
|
|
17
|
+
* a full refund or a lost dispute that leaves its net at 0 stops it counting, and a refund that
|
|
18
|
+
* fails restores it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isPledgePaymentCounted(pledge: Pick<PledgePayment, 'netAmount'>): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* One pledge's contribution to the totals: its amounts, and 1 toward `pledgeCount` while it counts.
|
|
23
|
+
* The webhook's increment for an event is the pledge's contribution after it minus its contribution
|
|
24
|
+
* before, so a refund that ends the pledge's money also takes it out of the count.
|
|
25
|
+
*/
|
|
26
|
+
export declare function pledgePaymentContributionOf(pledge: PledgePaymentAmountSums): PledgePaymentTotals;
|
|
14
27
|
//# sourceMappingURL=pledge-totals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pledge-totals.d.ts","sourceRoot":"","sources":["../../src/utils/pledge-totals.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,iFAAiF;AACjF,eAAO,MAAM,mCAAmC,yEAKK,CAAC;AAEtD,4EAA4E;AAC5E,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,OAAO,mCAAmC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEhH
|
|
1
|
+
{"version":3,"file":"pledge-totals.d.ts","sourceRoot":"","sources":["../../src/utils/pledge-totals.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,iFAAiF;AACjF,eAAO,MAAM,mCAAmC,yEAKK,CAAC;AAEtD,4EAA4E;AAC5E,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,OAAO,mCAAmC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEhH;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,GAAG,mBAAmB,CAO7G;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,GAAG,OAAO,CAExF;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,uBAAuB,GAAG,mBAAmB,CAEhG"}
|
|
@@ -10,9 +10,10 @@ export const PLEDGE_PAYMENT_SUMMED_AMOUNT_FIELDS = [
|
|
|
10
10
|
];
|
|
11
11
|
/**
|
|
12
12
|
* The counters from the summed pledge amounts. `totalRefunded` is money that left the platform:
|
|
13
|
-
* refunds plus funds withdrawn by a lost dispute.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* refunds plus funds withdrawn by a lost dispute. `pledgeCount` is the number of those pledges that
|
|
14
|
+
* still count (`isPledgePaymentCounted`) — a sum cannot say how many pledges kept money, so the
|
|
15
|
+
* caller counts them. The money formula is linear, so it gives the whole ledger's totals from the
|
|
16
|
+
* ledger's sums; one pledge's share is `pledgePaymentContributionOf`.
|
|
16
17
|
*/
|
|
17
18
|
export function pledgePaymentTotalsOf(sums, pledgeCount) {
|
|
18
19
|
return {
|
|
@@ -22,4 +23,20 @@ export function pledgePaymentTotalsOf(sums, pledgeCount) {
|
|
|
22
23
|
pledgeCount,
|
|
23
24
|
};
|
|
24
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* A pledge counts — in the pledge count and toward the Supporter badge — while it still holds money:
|
|
28
|
+
* a full refund or a lost dispute that leaves its net at 0 stops it counting, and a refund that
|
|
29
|
+
* fails restores it.
|
|
30
|
+
*/
|
|
31
|
+
export function isPledgePaymentCounted(pledge) {
|
|
32
|
+
return pledge.netAmount > 0;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* One pledge's contribution to the totals: its amounts, and 1 toward `pledgeCount` while it counts.
|
|
36
|
+
* The webhook's increment for an event is the pledge's contribution after it minus its contribution
|
|
37
|
+
* before, so a refund that ends the pledge's money also takes it out of the count.
|
|
38
|
+
*/
|
|
39
|
+
export function pledgePaymentContributionOf(pledge) {
|
|
40
|
+
return pledgePaymentTotalsOf(pledge, isPledgePaymentCounted(pledge) ? 1 : 0);
|
|
41
|
+
}
|
|
25
42
|
//# sourceMappingURL=pledge-totals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pledge-totals.js","sourceRoot":"","sources":["../../src/utils/pledge-totals.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,6FAA6F;AAC7F,oFAAoF;AAKpF,iFAAiF;AACjF,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,QAAQ;IACR,WAAW;IACX,gBAAgB;IAChB,mBAAmB;CACgC,CAAC;AAKtD
|
|
1
|
+
{"version":3,"file":"pledge-totals.js","sourceRoot":"","sources":["../../src/utils/pledge-totals.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,6FAA6F;AAC7F,oFAAoF;AAKpF,iFAAiF;AACjF,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,QAAQ;IACR,WAAW;IACX,gBAAgB;IAChB,mBAAmB;CACgC,CAAC;AAKtD;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAA6B,EAAE,WAAmB;IACtF,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,WAAW,EAAE,IAAI,CAAC,MAAM;QACxB,aAAa,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,iBAAiB;QAC3D,WAAW;KACZ,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAwC;IAC7E,OAAO,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAA+B;IACzE,OAAO,qBAAqB,CAAC,MAAM,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["// The ONE formula for the pledge-totals counters (`pledgePaymentTotals/summary` and the Ops\n// snapshot's `pledge`). The webhook's increments, the repair script's recompute, and the Ops\n// aggregate all derive from it, so the three can never count a counter differently.\n\nimport type { PledgePayment } from '../doc-schemas/payments.js';\nimport type { PledgePaymentTotals } from '../types/payments.js';\n\n/** The pledge fields the totals are built from — each summed over the ledger. */\nexport const PLEDGE_PAYMENT_SUMMED_AMOUNT_FIELDS = [\n 'amount',\n 'netAmount',\n 'refundedAmount',\n 'disputeLostAmount',\n] as const satisfies readonly (keyof PledgePayment)[];\n\n/** Those fields' values for one pledge, or their sums over many (cents). */\nexport type PledgePaymentAmountSums = Pick<PledgePayment, (typeof PLEDGE_PAYMENT_SUMMED_AMOUNT_FIELDS)[number]>;\n\n/**\n * The counters from the summed pledge amounts. `totalRefunded` is money that left the platform:\n * refunds plus funds withdrawn by a lost dispute. `pledgeCount` is the number of those pledges that\n * still count (`isPledgePaymentCounted`) — a sum cannot say how many pledges kept money, so the\n * caller counts them. The money formula is linear, so it gives the whole ledger's totals from the\n * ledger's sums; one pledge's share is `pledgePaymentContributionOf`.\n */\nexport function pledgePaymentTotalsOf(sums: PledgePaymentAmountSums, pledgeCount: number): PledgePaymentTotals {\n return {\n netRaised: sums.netAmount,\n grossRaised: sums.amount,\n totalRefunded: sums.refundedAmount + sums.disputeLostAmount,\n pledgeCount,\n };\n}\n\n/**\n * A pledge counts — in the pledge count and toward the Supporter badge — while it still holds money:\n * a full refund or a lost dispute that leaves its net at 0 stops it counting, and a refund that\n * fails restores it.\n */\nexport function isPledgePaymentCounted(pledge: Pick<PledgePayment, 'netAmount'>): boolean {\n return pledge.netAmount > 0;\n}\n\n/**\n * One pledge's contribution to the totals: its amounts, and 1 toward `pledgeCount` while it counts.\n * The webhook's increment for an event is the pledge's contribution after it minus its contribution\n * before, so a refund that ends the pledge's money also takes it out of the count.\n */\nexport function pledgePaymentContributionOf(pledge: PledgePaymentAmountSums): PledgePaymentTotals {\n return pledgePaymentTotalsOf(pledge, isPledgePaymentCounted(pledge) ? 1 : 0);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttt-productions/ttt-core",
|
|
3
|
-
"version": "0.79.
|
|
3
|
+
"version": "0.79.70",
|
|
4
4
|
"description": "Core types, Firestore path constants, and shared constants for TTT Productions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"@ttt-productions/chat-schemas": "^0.10.5",
|
|
118
118
|
"@ttt-productions/edge-protocol-core": "^0.1.12",
|
|
119
119
|
"@ttt-productions/input-format-core": "^0.1.1",
|
|
120
|
-
"@ttt-productions/media-schemas": "^0.14.
|
|
120
|
+
"@ttt-productions/media-schemas": "^0.14.9",
|
|
121
121
|
"@ttt-productions/notification-core": "^0.15.9",
|
|
122
122
|
"@ttt-productions/report-core": "^0.16.14",
|
|
123
123
|
"zod": "^4.4.3"
|