@pluto-khronos/types 3.5.1 → 3.6.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/README.md +11 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -1
- package/dist/odds.d.ts +41 -0
- package/dist/odds.d.ts.map +1 -0
- package/dist/odds.js +83 -0
- package/dist/odds.js.map +1 -0
- package/dist/schemas/betting.d.ts +130 -6
- package/dist/schemas/betting.d.ts.map +1 -1
- package/dist/schemas/betting.js +86 -4
- package/dist/schemas/betting.js.map +1 -1
- package/dist/schemas/delivery.d.ts +202 -0
- package/dist/schemas/delivery.d.ts.map +1 -0
- package/dist/schemas/delivery.js +180 -0
- package/dist/schemas/delivery.js.map +1 -0
- package/dist/schemas/notifications/index.d.ts +13 -0
- package/dist/schemas/notifications/index.d.ts.map +1 -0
- package/dist/schemas/notifications/index.js +23 -0
- package/dist/schemas/notifications/index.js.map +1 -0
- package/dist/schemas/parlay-notifications.d.ts +74 -0
- package/dist/schemas/parlay-notifications.d.ts.map +1 -0
- package/dist/schemas/parlay-notifications.js +50 -0
- package/dist/schemas/parlay-notifications.js.map +1 -0
- package/dist/schemas/props.d.ts +28 -0
- package/dist/schemas/props.d.ts.map +1 -0
- package/dist/schemas/props.js +29 -0
- package/dist/schemas/props.js.map +1 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ import { channelCreationEventSchema, type ChannelCreationEvent } from '@pluto-kh
|
|
|
18
18
|
const parsed = channelCreationEventSchema.parse(payload)
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
American odds are the canonical wire format. The package also exports pure
|
|
22
|
+
conversion and parlay helpers so producers and consumers share one rounding
|
|
23
|
+
policy:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { americanToDecimal, combineAmericanOdds } from '@pluto-khronos/types'
|
|
27
|
+
|
|
28
|
+
americanToDecimal(-110) // 1.909090...
|
|
29
|
+
combineAmericanOdds([-110, +150]) // { american: 377, decimal: 4.772727... }
|
|
30
|
+
```
|
|
31
|
+
|
|
21
32
|
## Local development
|
|
22
33
|
|
|
23
34
|
If you're iterating on this package alongside changes in a consuming repo (e.g. Pluto), use [yalc](https://github.com/wclr/yalc) — see the root [CLAUDE.md](../../CLAUDE.md) for the loop.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
export * from './odds';
|
|
1
2
|
export * from './schemas/betting';
|
|
2
3
|
export * from './schemas/channels';
|
|
3
4
|
export * from './schemas/colors';
|
|
5
|
+
export * from './schemas/delivery';
|
|
4
6
|
export * from './schemas/guilds';
|
|
7
|
+
export * from './schemas/parlay-notifications';
|
|
8
|
+
export * as notifications from './schemas/notifications';
|
|
5
9
|
export * from './schemas/shared';
|
|
6
10
|
export * from './schemas/sports';
|
|
11
|
+
export * from './schemas/props';
|
|
7
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAA;AACtB,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gCAAgC,CAAA;AAC9C,OAAO,KAAK,aAAa,MAAM,yBAAyB,CAAA;AACxD,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -10,15 +10,43 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
16
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.notifications = void 0;
|
|
17
40
|
// Export all schemas and types
|
|
41
|
+
__exportStar(require("./odds"), exports);
|
|
18
42
|
__exportStar(require("./schemas/betting"), exports);
|
|
19
43
|
__exportStar(require("./schemas/channels"), exports);
|
|
20
44
|
__exportStar(require("./schemas/colors"), exports);
|
|
45
|
+
__exportStar(require("./schemas/delivery"), exports);
|
|
21
46
|
__exportStar(require("./schemas/guilds"), exports);
|
|
47
|
+
__exportStar(require("./schemas/parlay-notifications"), exports);
|
|
48
|
+
exports.notifications = __importStar(require("./schemas/notifications"));
|
|
22
49
|
__exportStar(require("./schemas/shared"), exports);
|
|
23
50
|
__exportStar(require("./schemas/sports"), exports);
|
|
51
|
+
__exportStar(require("./schemas/props"), exports);
|
|
24
52
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,yCAAsB;AACtB,oDAAiC;AACjC,qDAAkC;AAClC,mDAAgC;AAChC,qDAAkC;AAClC,mDAAgC;AAChC,iEAA8C;AAC9C,yEAAwD;AACxD,mDAAgC;AAChC,mDAAgC;AAChC,kDAA+B"}
|
package/dist/odds.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* American odds conversion and parlay math.
|
|
3
|
+
*
|
|
4
|
+
* American odds are canonical integer wire values. Even money can be written
|
|
5
|
+
* as either +100 or -100; conversion to American uses +100 as the canonical
|
|
6
|
+
* representation. Decimal odds are payout multipliers (stake included), so
|
|
7
|
+
* every valid value is greater than 1.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Convert canonical American odds to decimal payout odds.
|
|
11
|
+
*
|
|
12
|
+
* Positive odds use 1 + odds / 100; negative odds use 1 + 100 / |odds|.
|
|
13
|
+
* ±100 therefore both represent 2.0 decimal odds.
|
|
14
|
+
*/
|
|
15
|
+
export declare function americanToDecimal(americanOdds: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Convert decimal payout odds to canonical integer American odds.
|
|
18
|
+
*
|
|
19
|
+
* Values below 2.0 are favorites and values at or above 2.0 are underdogs.
|
|
20
|
+
* The resulting American value is rounded to the nearest integer, with exact
|
|
21
|
+
* half-points rounded away from zero.
|
|
22
|
+
*/
|
|
23
|
+
export declare function decimalToAmerican(decimalOdds: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Return implied probability as a fraction between 0 and 1.
|
|
26
|
+
*/
|
|
27
|
+
export declare function impliedProbability(americanOdds: number): number;
|
|
28
|
+
export interface CombinedAmericanOdds {
|
|
29
|
+
american: number;
|
|
30
|
+
decimal: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Combine American odds for a parlay.
|
|
34
|
+
*
|
|
35
|
+
* Each leg is converted to decimal odds, decimal multipliers are multiplied
|
|
36
|
+
* without intermediate rounding, then the combined multiplier is converted
|
|
37
|
+
* back to integer American odds using the rounding policy above. Callers that
|
|
38
|
+
* need neutral push/void legs should omit them before calling this function.
|
|
39
|
+
*/
|
|
40
|
+
export declare function combineAmericanOdds(legs: readonly number[]): CombinedAmericanOdds;
|
|
41
|
+
//# sourceMappingURL=odds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"odds.d.ts","sourceRoot":"","sources":["../src/odds.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAsBH;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAM9D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAU7D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,SAAS,MAAM,EAAE,GACrB,oBAAoB,CAkBtB"}
|
package/dist/odds.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* American odds conversion and parlay math.
|
|
4
|
+
*
|
|
5
|
+
* American odds are canonical integer wire values. Even money can be written
|
|
6
|
+
* as either +100 or -100; conversion to American uses +100 as the canonical
|
|
7
|
+
* representation. Decimal odds are payout multipliers (stake included), so
|
|
8
|
+
* every valid value is greater than 1.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.americanToDecimal = americanToDecimal;
|
|
12
|
+
exports.decimalToAmerican = decimalToAmerican;
|
|
13
|
+
exports.impliedProbability = impliedProbability;
|
|
14
|
+
exports.combineAmericanOdds = combineAmericanOdds;
|
|
15
|
+
const MIN_AMERICAN_ODDS = 100;
|
|
16
|
+
function assertAmericanOdds(americanOdds) {
|
|
17
|
+
if (!Number.isFinite(americanOdds) ||
|
|
18
|
+
!Number.isInteger(americanOdds) ||
|
|
19
|
+
(americanOdds > -MIN_AMERICAN_ODDS && americanOdds < MIN_AMERICAN_ODDS)) {
|
|
20
|
+
throw new RangeError(`American odds must be a finite integer at or outside ±${MIN_AMERICAN_ODDS}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function roundAmericanOdds(value) {
|
|
24
|
+
// Round half away from zero. This keeps positive and negative American
|
|
25
|
+
// values symmetric at exact half-point boundaries.
|
|
26
|
+
return Math.sign(value) * Math.round(Math.abs(value));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Convert canonical American odds to decimal payout odds.
|
|
30
|
+
*
|
|
31
|
+
* Positive odds use 1 + odds / 100; negative odds use 1 + 100 / |odds|.
|
|
32
|
+
* ±100 therefore both represent 2.0 decimal odds.
|
|
33
|
+
*/
|
|
34
|
+
function americanToDecimal(americanOdds) {
|
|
35
|
+
assertAmericanOdds(americanOdds);
|
|
36
|
+
return americanOdds >= 0
|
|
37
|
+
? 1 + americanOdds / 100
|
|
38
|
+
: 1 + 100 / Math.abs(americanOdds);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Convert decimal payout odds to canonical integer American odds.
|
|
42
|
+
*
|
|
43
|
+
* Values below 2.0 are favorites and values at or above 2.0 are underdogs.
|
|
44
|
+
* The resulting American value is rounded to the nearest integer, with exact
|
|
45
|
+
* half-points rounded away from zero.
|
|
46
|
+
*/
|
|
47
|
+
function decimalToAmerican(decimalOdds) {
|
|
48
|
+
if (!Number.isFinite(decimalOdds) || decimalOdds <= 1) {
|
|
49
|
+
throw new RangeError('Decimal odds must be finite and greater than 1');
|
|
50
|
+
}
|
|
51
|
+
if (decimalOdds >= 2) {
|
|
52
|
+
return roundAmericanOdds((decimalOdds - 1) * 100);
|
|
53
|
+
}
|
|
54
|
+
return roundAmericanOdds(-100 / (decimalOdds - 1));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Return implied probability as a fraction between 0 and 1.
|
|
58
|
+
*/
|
|
59
|
+
function impliedProbability(americanOdds) {
|
|
60
|
+
return 1 / americanToDecimal(americanOdds);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Combine American odds for a parlay.
|
|
64
|
+
*
|
|
65
|
+
* Each leg is converted to decimal odds, decimal multipliers are multiplied
|
|
66
|
+
* without intermediate rounding, then the combined multiplier is converted
|
|
67
|
+
* back to integer American odds using the rounding policy above. Callers that
|
|
68
|
+
* need neutral push/void legs should omit them before calling this function.
|
|
69
|
+
*/
|
|
70
|
+
function combineAmericanOdds(legs) {
|
|
71
|
+
if (legs.length === 0) {
|
|
72
|
+
throw new RangeError('At least one leg is required');
|
|
73
|
+
}
|
|
74
|
+
const decimal = legs.reduce((combined, leg) => combined * americanToDecimal(leg), 1);
|
|
75
|
+
if (!Number.isFinite(decimal)) {
|
|
76
|
+
throw new RangeError('Combined decimal odds must be finite');
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
american: decimalToAmerican(decimal),
|
|
80
|
+
decimal,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//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IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,iBAAiB,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,iBAAiB,CAAC,CAAC,GAAG,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAA;AACnD,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,YAAoB;IACtD,OAAO,CAAC,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAA;AAC3C,CAAC;AAOD;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAClC,IAAuB;IAEvB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,UAAU,CAAC,8BAA8B,CAAC,CAAA;IACrD,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAC1B,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,EACpD,CAAC,CACD,CAAA;IAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,UAAU,CAAC,sCAAsC,CAAC,CAAA;IAC7D,CAAC;IAED,OAAO;QACN,QAAQ,EAAE,iBAAiB,CAAC,OAAO,CAAC;QACpC,OAAO;KACP,CAAA;AACF,CAAC"}
|
|
@@ -24,18 +24,142 @@ export declare const betslipPushSchema: z.ZodObject<{
|
|
|
24
24
|
team: z.ZodString;
|
|
25
25
|
}, z.core.$strip>;
|
|
26
26
|
export type IBetslipPush = z.infer<typeof betslipPushSchema>;
|
|
27
|
+
/**
|
|
28
|
+
* @group Notifications
|
|
29
|
+
* Winner notification entry sent to Pluto.
|
|
30
|
+
*/
|
|
31
|
+
export declare const betNotificationWonSchema: z.ZodObject<{
|
|
32
|
+
userId: z.ZodString;
|
|
33
|
+
betId: z.ZodNumber;
|
|
34
|
+
result: z.ZodObject<{
|
|
35
|
+
team: z.ZodString;
|
|
36
|
+
betAmount: z.ZodNumber;
|
|
37
|
+
payout: z.ZodNumber;
|
|
38
|
+
profit: z.ZodNumber;
|
|
39
|
+
newBalance: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
oldBalance: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
/**
|
|
44
|
+
* @group Notifications
|
|
45
|
+
* Loser notification entry sent to Pluto.
|
|
46
|
+
*/
|
|
47
|
+
export declare const betNotificationLostSchema: z.ZodObject<{
|
|
48
|
+
userId: z.ZodString;
|
|
49
|
+
betId: z.ZodNumber;
|
|
50
|
+
result: z.ZodObject<{
|
|
51
|
+
team: z.ZodString;
|
|
52
|
+
betAmount: z.ZodNumber;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
/**
|
|
56
|
+
* @group Notifications
|
|
57
|
+
* Push/refund notification entry sent to Pluto.
|
|
58
|
+
*/
|
|
59
|
+
export declare const betNotificationPushSchema: z.ZodObject<{
|
|
60
|
+
userId: z.ZodString;
|
|
61
|
+
betId: z.ZodNumber;
|
|
62
|
+
result: z.ZodObject<{
|
|
63
|
+
team: z.ZodString;
|
|
64
|
+
betAmount: z.ZodNumber;
|
|
65
|
+
refunded: z.ZodNumber;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
export type BetNotificationWon = z.infer<typeof betNotificationWonSchema>;
|
|
69
|
+
export type BetNotificationLost = z.infer<typeof betNotificationLostSchema>;
|
|
70
|
+
export type BetNotificationPush = z.infer<typeof betNotificationPushSchema>;
|
|
71
|
+
/**
|
|
72
|
+
* @group Notifications
|
|
73
|
+
* A paired prop and its event context for POST /props/daily.
|
|
74
|
+
*/
|
|
75
|
+
export declare const dailyPropSchema: z.ZodObject<{
|
|
76
|
+
event_id: z.ZodString;
|
|
77
|
+
commence_time: z.ZodString;
|
|
78
|
+
home_team: z.ZodString;
|
|
79
|
+
away_team: z.ZodString;
|
|
80
|
+
sport_title: z.ZodString;
|
|
81
|
+
market_key: z.ZodString;
|
|
82
|
+
bookmaker_key: z.ZodString;
|
|
83
|
+
description: z.ZodString;
|
|
84
|
+
point: z.ZodNumber;
|
|
85
|
+
over: z.ZodObject<{
|
|
86
|
+
outcome_uuid: z.ZodString;
|
|
87
|
+
outcome_name: z.ZodString;
|
|
88
|
+
price: z.ZodNumber;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
under: z.ZodObject<{
|
|
91
|
+
outcome_uuid: z.ZodString;
|
|
92
|
+
outcome_name: z.ZodString;
|
|
93
|
+
price: z.ZodNumber;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
/**
|
|
97
|
+
* @group Notifications
|
|
98
|
+
* Validated Khronos -> Pluto payload for daily prop posting.
|
|
99
|
+
*/
|
|
100
|
+
export declare const dailyPropsPayloadSchema: z.ZodObject<{
|
|
101
|
+
props: z.ZodArray<z.ZodObject<{
|
|
102
|
+
event_id: z.ZodString;
|
|
103
|
+
commence_time: z.ZodString;
|
|
104
|
+
home_team: z.ZodString;
|
|
105
|
+
away_team: z.ZodString;
|
|
106
|
+
sport_title: z.ZodString;
|
|
107
|
+
market_key: z.ZodString;
|
|
108
|
+
bookmaker_key: z.ZodString;
|
|
109
|
+
description: z.ZodString;
|
|
110
|
+
point: z.ZodNumber;
|
|
111
|
+
over: z.ZodObject<{
|
|
112
|
+
outcome_uuid: z.ZodString;
|
|
113
|
+
outcome_name: z.ZodString;
|
|
114
|
+
price: z.ZodNumber;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
under: z.ZodObject<{
|
|
117
|
+
outcome_uuid: z.ZodString;
|
|
118
|
+
outcome_name: z.ZodString;
|
|
119
|
+
price: z.ZodNumber;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
}, z.core.$strip>>;
|
|
122
|
+
guilds: z.ZodArray<z.ZodObject<{
|
|
123
|
+
guild_id: z.ZodString;
|
|
124
|
+
channel_id: z.ZodString;
|
|
125
|
+
sport: z.ZodString;
|
|
126
|
+
}, z.core.$strip>>;
|
|
127
|
+
}, z.core.$strip>;
|
|
128
|
+
export type DailyProp = z.infer<typeof dailyPropSchema>;
|
|
129
|
+
export type DailyPropsPayload = z.infer<typeof dailyPropsPayloadSchema>;
|
|
27
130
|
/**
|
|
28
131
|
* Schema for bet result notification payload
|
|
29
132
|
* @group Betting
|
|
30
133
|
*/
|
|
31
134
|
export declare const notificationBetResultsSchema: z.ZodObject<{
|
|
32
|
-
winners: z.ZodNullable<z.ZodArray<z.
|
|
33
|
-
|
|
135
|
+
winners: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
136
|
+
userId: z.ZodString;
|
|
137
|
+
betId: z.ZodNumber;
|
|
138
|
+
result: z.ZodObject<{
|
|
139
|
+
team: z.ZodString;
|
|
140
|
+
betAmount: z.ZodNumber;
|
|
141
|
+
payout: z.ZodNumber;
|
|
142
|
+
profit: z.ZodNumber;
|
|
143
|
+
newBalance: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
oldBalance: z.ZodOptional<z.ZodNumber>;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
}, z.core.$strip>>>;
|
|
147
|
+
losers: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
148
|
+
userId: z.ZodString;
|
|
149
|
+
betId: z.ZodNumber;
|
|
150
|
+
result: z.ZodObject<{
|
|
151
|
+
team: z.ZodString;
|
|
152
|
+
betAmount: z.ZodNumber;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
}, z.core.$strip>>>;
|
|
34
155
|
pushes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
156
|
+
userId: z.ZodString;
|
|
157
|
+
betId: z.ZodNumber;
|
|
158
|
+
result: z.ZodObject<{
|
|
159
|
+
team: z.ZodString;
|
|
160
|
+
betAmount: z.ZodNumber;
|
|
161
|
+
refunded: z.ZodNumber;
|
|
162
|
+
}, z.core.$strip>;
|
|
39
163
|
}, z.core.$strip>>>;
|
|
40
164
|
}, z.core.$strip>;
|
|
41
165
|
export type INotificationBetResults = z.infer<typeof notificationBetResultsSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"betting.d.ts","sourceRoot":"","sources":["../../src/schemas/betting.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;iBAMgB,CAAC;AAE7C,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;iBAOyC,CAAC;AAExE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"betting.d.ts","sourceRoot":"","sources":["../../src/schemas/betting.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;iBAMgB,CAAC;AAE7C,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;iBAOyC,CAAC;AAExE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AA2B7D;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;iBAEU,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;iBAEQ,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;iBAEQ,CAAC;AAE/C,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAQ5E;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;iBAY1B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;iBASlC,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAeoC,CAAC;AAE9E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,4BAA4B,CACnC,CAAC"}
|
package/dist/schemas/betting.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.notificationBetResultsSchema = exports.betslipPushSchema = exports.matchOddsSchema = void 0;
|
|
3
|
+
exports.notificationBetResultsSchema = exports.dailyPropsPayloadSchema = exports.dailyPropSchema = exports.betNotificationPushSchema = exports.betNotificationLostSchema = exports.betNotificationWonSchema = exports.betslipPushSchema = exports.matchOddsSchema = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @group Betting
|
|
6
6
|
* Schemas for betting and odds-related data
|
|
@@ -29,16 +29,98 @@ exports.betslipPushSchema = zod_1.z
|
|
|
29
29
|
team: zod_1.z.string().describe('Team the user bet on'),
|
|
30
30
|
})
|
|
31
31
|
.describe('Information about a bet that was pushed due to a tie game');
|
|
32
|
+
const notificationBetBaseSchema = zod_1.z.object({
|
|
33
|
+
userId: zod_1.z.string().min(1).describe('Discord user ID'),
|
|
34
|
+
betId: zod_1.z.number().int().nonnegative().describe('Unique bet identifier'),
|
|
35
|
+
});
|
|
36
|
+
const notificationWinnerResultSchema = zod_1.z.object({
|
|
37
|
+
team: zod_1.z.string().min(1),
|
|
38
|
+
betAmount: zod_1.z.number().nonnegative(),
|
|
39
|
+
payout: zod_1.z.number().finite().nonnegative(),
|
|
40
|
+
profit: zod_1.z.number().finite(),
|
|
41
|
+
newBalance: zod_1.z.number().finite().optional(),
|
|
42
|
+
oldBalance: zod_1.z.number().finite().optional(),
|
|
43
|
+
});
|
|
44
|
+
const notificationLoserResultSchema = zod_1.z.object({
|
|
45
|
+
team: zod_1.z.string().min(1),
|
|
46
|
+
betAmount: zod_1.z.number().nonnegative(),
|
|
47
|
+
});
|
|
48
|
+
const notificationPushResultSchema = zod_1.z.object({
|
|
49
|
+
team: zod_1.z.string().min(1),
|
|
50
|
+
betAmount: zod_1.z.number().nonnegative(),
|
|
51
|
+
refunded: zod_1.z.number().finite().nonnegative(),
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* @group Notifications
|
|
55
|
+
* Winner notification entry sent to Pluto.
|
|
56
|
+
*/
|
|
57
|
+
exports.betNotificationWonSchema = notificationBetBaseSchema
|
|
58
|
+
.extend({ result: notificationWinnerResultSchema })
|
|
59
|
+
.describe('A winning single-bet notification');
|
|
60
|
+
/**
|
|
61
|
+
* @group Notifications
|
|
62
|
+
* Loser notification entry sent to Pluto.
|
|
63
|
+
*/
|
|
64
|
+
exports.betNotificationLostSchema = notificationBetBaseSchema
|
|
65
|
+
.extend({ result: notificationLoserResultSchema })
|
|
66
|
+
.describe('A losing single-bet notification');
|
|
67
|
+
/**
|
|
68
|
+
* @group Notifications
|
|
69
|
+
* Push/refund notification entry sent to Pluto.
|
|
70
|
+
*/
|
|
71
|
+
exports.betNotificationPushSchema = notificationBetBaseSchema
|
|
72
|
+
.extend({ result: notificationPushResultSchema })
|
|
73
|
+
.describe('A pushed single-bet notification');
|
|
74
|
+
const dailyPropOutcomeSchema = zod_1.z.object({
|
|
75
|
+
outcome_uuid: zod_1.z.string().uuid(),
|
|
76
|
+
outcome_name: zod_1.z.string().min(1),
|
|
77
|
+
price: zod_1.z.number().int().describe('American odds'),
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* @group Notifications
|
|
81
|
+
* A paired prop and its event context for POST /props/daily.
|
|
82
|
+
*/
|
|
83
|
+
exports.dailyPropSchema = zod_1.z.object({
|
|
84
|
+
event_id: zod_1.z.string().min(1),
|
|
85
|
+
commence_time: zod_1.z.string().min(1),
|
|
86
|
+
home_team: zod_1.z.string().min(1),
|
|
87
|
+
away_team: zod_1.z.string().min(1),
|
|
88
|
+
sport_title: zod_1.z.string().min(1),
|
|
89
|
+
market_key: zod_1.z.string().min(1),
|
|
90
|
+
bookmaker_key: zod_1.z.string().min(1),
|
|
91
|
+
description: zod_1.z.string().min(1),
|
|
92
|
+
point: zod_1.z.number(),
|
|
93
|
+
over: dailyPropOutcomeSchema,
|
|
94
|
+
under: dailyPropOutcomeSchema,
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* @group Notifications
|
|
98
|
+
* Validated Khronos -> Pluto payload for daily prop posting.
|
|
99
|
+
*/
|
|
100
|
+
exports.dailyPropsPayloadSchema = zod_1.z.object({
|
|
101
|
+
props: zod_1.z.array(exports.dailyPropSchema),
|
|
102
|
+
guilds: zod_1.z.array(zod_1.z.object({
|
|
103
|
+
guild_id: zod_1.z.string().min(1),
|
|
104
|
+
channel_id: zod_1.z.string().min(1),
|
|
105
|
+
sport: zod_1.z.string().min(1),
|
|
106
|
+
})),
|
|
107
|
+
});
|
|
32
108
|
/**
|
|
33
109
|
* Schema for bet result notification payload
|
|
34
110
|
* @group Betting
|
|
35
111
|
*/
|
|
36
112
|
exports.notificationBetResultsSchema = zod_1.z
|
|
37
113
|
.object({
|
|
38
|
-
winners: zod_1.z
|
|
39
|
-
|
|
114
|
+
winners: zod_1.z
|
|
115
|
+
.array(exports.betNotificationWonSchema)
|
|
116
|
+
.nullable()
|
|
117
|
+
.describe('Array of winning bets'),
|
|
118
|
+
losers: zod_1.z
|
|
119
|
+
.array(exports.betNotificationLostSchema)
|
|
120
|
+
.nullable()
|
|
121
|
+
.describe('Array of losing bets'),
|
|
40
122
|
pushes: zod_1.z
|
|
41
|
-
.array(exports.
|
|
123
|
+
.array(exports.betNotificationPushSchema)
|
|
42
124
|
.optional()
|
|
43
125
|
.describe('Array of pushed bets from tie games'),
|
|
44
126
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"betting.js","sourceRoot":"","sources":["../../src/schemas/betting.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,6BAAwB;AAExB;;;GAGG;AACU,QAAA,eAAe,GAAG,OAAC;KAC9B,MAAM,CAAC;IACP,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACnD,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IACjE,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;CACjE,CAAC;KACD,QAAQ,CAAC,gCAAgC,CAAC,CAAC;AAI7C;;;GAGG;AACU,QAAA,iBAAiB,GAAG,OAAC;KAChC,MAAM,CAAC;IACP,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IACzD,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;IACtD,KAAK,EAAE,OAAC,CAAC,MAAM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M,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,sBAAsB;IAC5B,KAAK,EAAE,sBAAsB;CAC7B,CAAC,CAAC;AAEH;;;GAGG;AACU,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/C,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,uBAAe,CAAC;IAC/B,MAAM,EAAE,OAAC,CAAC,KAAK,CACd,OAAC,CAAC,MAAM,CAAC;QACR,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3B,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KACxB,CAAC,CACF;CACD,CAAC,CAAC;AAKH;;;GAGG;AACU,QAAA,4BAA4B,GAAG,OAAC;KAC3C,MAAM,CAAC;IACP,OAAO,EAAE,OAAC;SACR,KAAK,CAAC,gCAAwB,CAAC;SAC/B,QAAQ,EAAE;SACV,QAAQ,CAAC,uBAAuB,CAAC;IACnC,MAAM,EAAE,OAAC;SACP,KAAK,CAAC,iCAAyB,CAAC;SAChC,QAAQ,EAAE;SACV,QAAQ,CAAC,sBAAsB,CAAC;IAClC,MAAM,EAAE,OAAC;SACP,KAAK,CAAC,iCAAyB,CAAC;SAChC,QAAQ,EAAE;SACV,QAAQ,CAAC,qCAAqC,CAAC;CACjD,CAAC;KACD,QAAQ,CAAC,iEAAiE,CAAC,CAAC"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type DailyPropsPayload } from './betting';
|
|
3
|
+
/** Versioned Khronos-to-Pluto delivery kinds. */
|
|
4
|
+
export declare const deliveryKindSchema: z.ZodEnum<{
|
|
5
|
+
parlay_result: "parlay_result";
|
|
6
|
+
prop_settled: "prop_settled";
|
|
7
|
+
prop_post: "prop_post";
|
|
8
|
+
}>;
|
|
9
|
+
export type DeliveryKind = z.infer<typeof deliveryKindSchema>;
|
|
10
|
+
/** Durable message receipt returned for a posted prop destination. */
|
|
11
|
+
export declare const propPostReceiptSchema: z.ZodObject<{
|
|
12
|
+
outcome_uuid: z.ZodString;
|
|
13
|
+
guild_id: z.ZodString;
|
|
14
|
+
channel_id: z.ZodString;
|
|
15
|
+
message_id: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type PropPostReceipt = z.infer<typeof propPostReceiptSchema>;
|
|
18
|
+
/**
|
|
19
|
+
* Versioned, idempotent delivery contract. Producers keep `delivery_id`
|
|
20
|
+
* stable across every retry; consumers must reject changed payloads for an
|
|
21
|
+
* existing id.
|
|
22
|
+
*/
|
|
23
|
+
export declare const deliveryEnvelopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
24
|
+
delivery_id: z.ZodString;
|
|
25
|
+
schema_version: z.ZodLiteral<1>;
|
|
26
|
+
occurred_at: z.ZodString;
|
|
27
|
+
kind: z.ZodLiteral<"parlay_result">;
|
|
28
|
+
payload: z.ZodObject<{
|
|
29
|
+
kind: z.ZodEnum<{
|
|
30
|
+
won: "won";
|
|
31
|
+
lost: "lost";
|
|
32
|
+
push_refunded: "push_refunded";
|
|
33
|
+
busted: "busted";
|
|
34
|
+
}>;
|
|
35
|
+
parlay_id: z.ZodString;
|
|
36
|
+
user_id: z.ZodString;
|
|
37
|
+
guild_id: z.ZodOptional<z.ZodString>;
|
|
38
|
+
stake: z.ZodNumber;
|
|
39
|
+
combined_odds_american: z.ZodNumber;
|
|
40
|
+
payout: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
actual_payout: z.ZodNullable<z.ZodNumber>;
|
|
42
|
+
refund_amount: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
old_balance: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
new_balance: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
event_id: z.ZodString;
|
|
48
|
+
outcome_uuid: z.ZodString;
|
|
49
|
+
selection_display: z.ZodString;
|
|
50
|
+
market_key: z.ZodString;
|
|
51
|
+
odds_american: z.ZodNumber;
|
|
52
|
+
point: z.ZodNullable<z.ZodNumber>;
|
|
53
|
+
commence_time: z.ZodCoercedDate<unknown>;
|
|
54
|
+
result: z.ZodEnum<{
|
|
55
|
+
void: "void";
|
|
56
|
+
pending: "pending";
|
|
57
|
+
won: "won";
|
|
58
|
+
lost: "lost";
|
|
59
|
+
push: "push";
|
|
60
|
+
}>;
|
|
61
|
+
home_team: z.ZodOptional<z.ZodString>;
|
|
62
|
+
away_team: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
+
delivery_id: z.ZodString;
|
|
67
|
+
schema_version: z.ZodLiteral<1>;
|
|
68
|
+
occurred_at: z.ZodString;
|
|
69
|
+
kind: z.ZodLiteral<"prop_settled">;
|
|
70
|
+
payload: z.ZodObject<{
|
|
71
|
+
outcome_uuid: z.ZodString;
|
|
72
|
+
result: z.ZodEnum<{
|
|
73
|
+
void: "void";
|
|
74
|
+
won: "won";
|
|
75
|
+
lost: "lost";
|
|
76
|
+
push: "push";
|
|
77
|
+
}>;
|
|
78
|
+
winning_side_display: z.ZodOptional<z.ZodString>;
|
|
79
|
+
actual_value: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
80
|
+
market_key: z.ZodString;
|
|
81
|
+
description: z.ZodString;
|
|
82
|
+
point: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
83
|
+
tallies: z.ZodObject<{
|
|
84
|
+
correct: z.ZodNumber;
|
|
85
|
+
incorrect: z.ZodNumber;
|
|
86
|
+
total: z.ZodNumber;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
89
|
+
guild_id: z.ZodString;
|
|
90
|
+
channel_id: z.ZodString;
|
|
91
|
+
message_id: z.ZodString;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
95
|
+
delivery_id: z.ZodString;
|
|
96
|
+
schema_version: z.ZodLiteral<1>;
|
|
97
|
+
occurred_at: z.ZodString;
|
|
98
|
+
kind: z.ZodLiteral<"prop_post">;
|
|
99
|
+
payload: z.ZodObject<{
|
|
100
|
+
props: z.ZodArray<z.ZodObject<{
|
|
101
|
+
event_id: z.ZodString;
|
|
102
|
+
commence_time: z.ZodString;
|
|
103
|
+
home_team: z.ZodString;
|
|
104
|
+
away_team: z.ZodString;
|
|
105
|
+
sport_title: z.ZodString;
|
|
106
|
+
market_key: z.ZodString;
|
|
107
|
+
bookmaker_key: z.ZodString;
|
|
108
|
+
description: z.ZodString;
|
|
109
|
+
point: z.ZodNumber;
|
|
110
|
+
over: z.ZodObject<{
|
|
111
|
+
outcome_uuid: z.ZodString;
|
|
112
|
+
outcome_name: z.ZodString;
|
|
113
|
+
price: z.ZodNumber;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
under: z.ZodObject<{
|
|
116
|
+
outcome_uuid: z.ZodString;
|
|
117
|
+
outcome_name: z.ZodString;
|
|
118
|
+
price: z.ZodNumber;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
}, z.core.$strip>>;
|
|
121
|
+
guilds: z.ZodArray<z.ZodObject<{
|
|
122
|
+
guild_id: z.ZodString;
|
|
123
|
+
channel_id: z.ZodString;
|
|
124
|
+
sport: z.ZodString;
|
|
125
|
+
}, z.core.$strip>>;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
}, z.core.$strip>], "kind">;
|
|
128
|
+
export type DeliveryEnvelope = z.infer<typeof deliveryEnvelopeSchema>;
|
|
129
|
+
export declare const deliveryStateSchema: z.ZodEnum<{
|
|
130
|
+
queued: "queued";
|
|
131
|
+
processing: "processing";
|
|
132
|
+
delivered: "delivered";
|
|
133
|
+
retryable_failed: "retryable_failed";
|
|
134
|
+
permanent_failed: "permanent_failed";
|
|
135
|
+
}>;
|
|
136
|
+
export type DeliveryState = z.infer<typeof deliveryStateSchema>;
|
|
137
|
+
/** Durable status returned from `GET /deliveries/:delivery_id`. */
|
|
138
|
+
export declare const deliveryStatusSchema: z.ZodObject<{
|
|
139
|
+
delivery_id: z.ZodString;
|
|
140
|
+
kind: z.ZodEnum<{
|
|
141
|
+
parlay_result: "parlay_result";
|
|
142
|
+
prop_settled: "prop_settled";
|
|
143
|
+
prop_post: "prop_post";
|
|
144
|
+
}>;
|
|
145
|
+
status: z.ZodEnum<{
|
|
146
|
+
queued: "queued";
|
|
147
|
+
processing: "processing";
|
|
148
|
+
delivered: "delivered";
|
|
149
|
+
retryable_failed: "retryable_failed";
|
|
150
|
+
permanent_failed: "permanent_failed";
|
|
151
|
+
}>;
|
|
152
|
+
receipts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
153
|
+
outcome_uuid: z.ZodString;
|
|
154
|
+
guild_id: z.ZodString;
|
|
155
|
+
channel_id: z.ZodString;
|
|
156
|
+
message_id: z.ZodString;
|
|
157
|
+
}, z.core.$strip>>>;
|
|
158
|
+
error_classification: z.ZodOptional<z.ZodString>;
|
|
159
|
+
}, z.core.$strip>;
|
|
160
|
+
export type DeliveryStatus = z.infer<typeof deliveryStatusSchema>;
|
|
161
|
+
/** Response returned only after the receiver has durably accepted a delivery. */
|
|
162
|
+
export declare const deliveryAcceptedSchema: z.ZodObject<{
|
|
163
|
+
delivery_id: z.ZodString;
|
|
164
|
+
kind: z.ZodEnum<{
|
|
165
|
+
parlay_result: "parlay_result";
|
|
166
|
+
prop_settled: "prop_settled";
|
|
167
|
+
prop_post: "prop_post";
|
|
168
|
+
}>;
|
|
169
|
+
status: z.ZodEnum<{
|
|
170
|
+
queued: "queued";
|
|
171
|
+
processing: "processing";
|
|
172
|
+
delivered: "delivered";
|
|
173
|
+
retryable_failed: "retryable_failed";
|
|
174
|
+
permanent_failed: "permanent_failed";
|
|
175
|
+
}>;
|
|
176
|
+
receipts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
177
|
+
outcome_uuid: z.ZodString;
|
|
178
|
+
guild_id: z.ZodString;
|
|
179
|
+
channel_id: z.ZodString;
|
|
180
|
+
message_id: z.ZodString;
|
|
181
|
+
}, z.core.$strip>>>;
|
|
182
|
+
error_classification: z.ZodOptional<z.ZodString>;
|
|
183
|
+
accepted: z.ZodLiteral<true>;
|
|
184
|
+
duplicate: z.ZodBoolean;
|
|
185
|
+
}, z.core.$strip>;
|
|
186
|
+
export type DeliveryAccepted = z.infer<typeof deliveryAcceptedSchema>;
|
|
187
|
+
/**
|
|
188
|
+
* Verifies a completed prop-post delivery against its original payload. The
|
|
189
|
+
* result must include every expected outcome/guild/channel destination once.
|
|
190
|
+
*/
|
|
191
|
+
export declare function hasExactPropPostReceipts(payload: DailyPropsPayload, receipts: readonly PropPostReceipt[]): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Stable normalized input for a receiver-owned SHA-256 payload hash. This
|
|
194
|
+
* package deliberately does not select a runtime crypto implementation.
|
|
195
|
+
*/
|
|
196
|
+
export declare function deliveryPayloadFingerprint(envelope: DeliveryEnvelope): string;
|
|
197
|
+
/**
|
|
198
|
+
* Classifies a duplicate delivery request. Receivers translate
|
|
199
|
+
* `payload_mismatch` into HTTP 409 before queueing or sending anything.
|
|
200
|
+
*/
|
|
201
|
+
export declare function classifyDeliveryReplay(existing: DeliveryEnvelope, incoming: DeliveryEnvelope): 'duplicate' | 'payload_mismatch';
|
|
202
|
+
//# sourceMappingURL=delivery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../../src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E,GAClC,OAAO,CA8BT;AA6CD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAS7E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACxB,WAAW,GAAG,kBAAkB,CAWlC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deliveryAcceptedSchema = exports.deliveryStatusSchema = exports.deliveryStateSchema = exports.deliveryEnvelopeSchema = exports.propPostReceiptSchema = exports.deliveryKindSchema = void 0;
|
|
4
|
+
exports.hasExactPropPostReceipts = hasExactPropPostReceipts;
|
|
5
|
+
exports.deliveryPayloadFingerprint = deliveryPayloadFingerprint;
|
|
6
|
+
exports.classifyDeliveryReplay = classifyDeliveryReplay;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const betting_1 = require("./betting");
|
|
9
|
+
const parlay_notifications_1 = require("./parlay-notifications");
|
|
10
|
+
const props_1 = require("./props");
|
|
11
|
+
/** Versioned Khronos-to-Pluto delivery kinds. */
|
|
12
|
+
exports.deliveryKindSchema = zod_1.z.enum([
|
|
13
|
+
'parlay_result',
|
|
14
|
+
'prop_settled',
|
|
15
|
+
'prop_post',
|
|
16
|
+
]);
|
|
17
|
+
/** Durable message receipt returned for a posted prop destination. */
|
|
18
|
+
exports.propPostReceiptSchema = zod_1.z.object({
|
|
19
|
+
outcome_uuid: zod_1.z.string().uuid(),
|
|
20
|
+
guild_id: zod_1.z.string().min(1),
|
|
21
|
+
channel_id: zod_1.z.string().min(1),
|
|
22
|
+
message_id: zod_1.z.string().min(1),
|
|
23
|
+
});
|
|
24
|
+
const deliveryEnvelopeBaseSchema = zod_1.z.object({
|
|
25
|
+
delivery_id: zod_1.z.string().uuid(),
|
|
26
|
+
schema_version: zod_1.z.literal(1),
|
|
27
|
+
occurred_at: zod_1.z.string().datetime({ offset: true }),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Versioned, idempotent delivery contract. Producers keep `delivery_id`
|
|
31
|
+
* stable across every retry; consumers must reject changed payloads for an
|
|
32
|
+
* existing id.
|
|
33
|
+
*/
|
|
34
|
+
exports.deliveryEnvelopeSchema = zod_1.z.discriminatedUnion('kind', [
|
|
35
|
+
deliveryEnvelopeBaseSchema.extend({
|
|
36
|
+
kind: zod_1.z.literal('parlay_result'),
|
|
37
|
+
payload: parlay_notifications_1.parlayResultNotificationSchema,
|
|
38
|
+
}),
|
|
39
|
+
deliveryEnvelopeBaseSchema.extend({
|
|
40
|
+
kind: zod_1.z.literal('prop_settled'),
|
|
41
|
+
payload: props_1.propSettledNotificationSchema,
|
|
42
|
+
}),
|
|
43
|
+
deliveryEnvelopeBaseSchema.extend({
|
|
44
|
+
kind: zod_1.z.literal('prop_post'),
|
|
45
|
+
payload: betting_1.dailyPropsPayloadSchema,
|
|
46
|
+
}),
|
|
47
|
+
]);
|
|
48
|
+
exports.deliveryStateSchema = zod_1.z.enum([
|
|
49
|
+
'queued',
|
|
50
|
+
'processing',
|
|
51
|
+
'delivered',
|
|
52
|
+
'retryable_failed',
|
|
53
|
+
'permanent_failed',
|
|
54
|
+
]);
|
|
55
|
+
const deliveryResponseBaseSchema = zod_1.z.object({
|
|
56
|
+
delivery_id: zod_1.z.string().uuid(),
|
|
57
|
+
kind: exports.deliveryKindSchema,
|
|
58
|
+
status: exports.deliveryStateSchema,
|
|
59
|
+
receipts: zod_1.z.array(exports.propPostReceiptSchema).optional(),
|
|
60
|
+
error_classification: zod_1.z.string().min(1).optional(),
|
|
61
|
+
});
|
|
62
|
+
function requirePropPostReceipts(value, ctx) {
|
|
63
|
+
if (value.kind === 'prop_post' &&
|
|
64
|
+
value.status === 'delivered' &&
|
|
65
|
+
(!value.receipts || value.receipts.length === 0)) {
|
|
66
|
+
ctx.addIssue({
|
|
67
|
+
code: 'custom',
|
|
68
|
+
path: ['receipts'],
|
|
69
|
+
message: 'Delivered prop posts require at least one durable message receipt',
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (value.kind !== 'prop_post' && value.receipts !== undefined) {
|
|
73
|
+
ctx.addIssue({
|
|
74
|
+
code: 'custom',
|
|
75
|
+
path: ['receipts'],
|
|
76
|
+
message: 'Only prop-post deliveries may include message receipts',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (value.kind === 'prop_post' && value.receipts !== undefined) {
|
|
80
|
+
const receiptKeys = new Set();
|
|
81
|
+
for (const [index, receipt] of value.receipts.entries()) {
|
|
82
|
+
const key = `${receipt.outcome_uuid}:${receipt.guild_id}`;
|
|
83
|
+
if (receiptKeys.has(key)) {
|
|
84
|
+
ctx.addIssue({
|
|
85
|
+
code: 'custom',
|
|
86
|
+
path: ['receipts', index],
|
|
87
|
+
message: 'Prop-post receipts must be unique by outcome_uuid and guild_id',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
receiptKeys.add(key);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** Durable status returned from `GET /deliveries/:delivery_id`. */
|
|
95
|
+
exports.deliveryStatusSchema = deliveryResponseBaseSchema.superRefine(requirePropPostReceipts);
|
|
96
|
+
/** Response returned only after the receiver has durably accepted a delivery. */
|
|
97
|
+
exports.deliveryAcceptedSchema = deliveryResponseBaseSchema
|
|
98
|
+
.extend({
|
|
99
|
+
accepted: zod_1.z.literal(true),
|
|
100
|
+
duplicate: zod_1.z.boolean(),
|
|
101
|
+
})
|
|
102
|
+
.superRefine(requirePropPostReceipts);
|
|
103
|
+
/**
|
|
104
|
+
* Verifies a completed prop-post delivery against its original payload. The
|
|
105
|
+
* result must include every expected outcome/guild/channel destination once.
|
|
106
|
+
*/
|
|
107
|
+
function hasExactPropPostReceipts(payload, receipts) {
|
|
108
|
+
const expected = new Set();
|
|
109
|
+
for (const prop of payload.props) {
|
|
110
|
+
for (const outcomeUuid of [
|
|
111
|
+
prop.over.outcome_uuid,
|
|
112
|
+
prop.under.outcome_uuid,
|
|
113
|
+
]) {
|
|
114
|
+
for (const guild of payload.guilds) {
|
|
115
|
+
expected.add(`${outcomeUuid}:${guild.guild_id}:${guild.channel_id}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (receipts.length !== expected.size) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const actual = new Set();
|
|
123
|
+
for (const receipt of receipts) {
|
|
124
|
+
const key = `${receipt.outcome_uuid}:${receipt.guild_id}:${receipt.channel_id}`;
|
|
125
|
+
if (actual.has(key) || !expected.has(key)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
actual.add(key);
|
|
129
|
+
}
|
|
130
|
+
return actual.size === expected.size;
|
|
131
|
+
}
|
|
132
|
+
function canonicalize(value) {
|
|
133
|
+
if (value === null ||
|
|
134
|
+
typeof value === 'boolean' ||
|
|
135
|
+
typeof value === 'string') {
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
if (typeof value === 'number') {
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
if (value instanceof Date) {
|
|
142
|
+
return value.toISOString();
|
|
143
|
+
}
|
|
144
|
+
if (Array.isArray(value)) {
|
|
145
|
+
return value.map(canonicalize);
|
|
146
|
+
}
|
|
147
|
+
if (typeof value === 'object') {
|
|
148
|
+
const object = value;
|
|
149
|
+
return Object.fromEntries(Object.keys(object)
|
|
150
|
+
.sort()
|
|
151
|
+
.map((key) => [key, canonicalize(object[key])]));
|
|
152
|
+
}
|
|
153
|
+
throw new TypeError('Delivery payloads must be JSON values');
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Stable normalized input for a receiver-owned SHA-256 payload hash. This
|
|
157
|
+
* package deliberately does not select a runtime crypto implementation.
|
|
158
|
+
*/
|
|
159
|
+
function deliveryPayloadFingerprint(envelope) {
|
|
160
|
+
return JSON.stringify(canonicalize({
|
|
161
|
+
schema_version: envelope.schema_version,
|
|
162
|
+
kind: envelope.kind,
|
|
163
|
+
occurred_at: envelope.occurred_at,
|
|
164
|
+
payload: envelope.payload,
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Classifies a duplicate delivery request. Receivers translate
|
|
169
|
+
* `payload_mismatch` into HTTP 409 before queueing or sending anything.
|
|
170
|
+
*/
|
|
171
|
+
function classifyDeliveryReplay(existing, incoming) {
|
|
172
|
+
if (existing.delivery_id !== incoming.delivery_id) {
|
|
173
|
+
throw new RangeError('Delivery replay comparison requires the same delivery_id');
|
|
174
|
+
}
|
|
175
|
+
return deliveryPayloadFingerprint(existing) ===
|
|
176
|
+
deliveryPayloadFingerprint(incoming)
|
|
177
|
+
? 'duplicate'
|
|
178
|
+
: 'payload_mismatch';
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=delivery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery.js","sourceRoot":"","sources":["../../src/schemas/delivery.ts"],"names":[],"mappings":";;;AA2IA,4DAiCC;AAiDD,gEASC;AAMD,wDAcC;AA1PD,6BAAuB;AAEvB,uCAA2E;AAC3E,iEAAuE;AACvE,mCAAuD;AAEvD,iDAAiD;AACpC,QAAA,kBAAkB,GAAG,OAAC,CAAC,IAAI,CAAC;IACxC,eAAe;IACf,cAAc;IACd,WAAW;CACX,CAAC,CAAA;AAIF,sEAAsE;AACzD,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC/B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,UAAU,EAAE,OAA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Ac;QACvC,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,OAAO,EAAE,QAAQ,CAAC,OAAO;KACzB,CAAC,CACF,CAAA;AACF,CAAC;AAED;;;GAGG;AACH,SAAgB,sBAAsB,CACrC,QAA0B,EAC1B,QAA0B;IAE1B,IAAI,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAC;QACnD,MAAM,IAAI,UAAU,CACnB,0DAA0D,CAC1D,CAAA;IACF,CAAC;IAED,OAAO,0BAA0B,CAAC,QAAQ,CAAC;QAC1C,0BAA0B,CAAC,QAAQ,CAAC;QACpC,CAAC,CAAC,WAAW;QACb,CAAC,CAAC,kBAAkB,CAAA;AACtB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification schema barrel.
|
|
3
|
+
*
|
|
4
|
+
* Concrete contracts live in their domain modules. This barrel re-exports them
|
|
5
|
+
* under a stable `notifications` namespace for consumers that prefer a single
|
|
6
|
+
* import surface. Root star-exports remain the primary public API.
|
|
7
|
+
*/
|
|
8
|
+
export { betNotificationLostSchema, betNotificationPushSchema, betNotificationWonSchema, dailyPropSchema, dailyPropsPayloadSchema, notificationBetResultsSchema, } from '../betting';
|
|
9
|
+
export { parlayLegNotificationSchema, parlayResultNotificationSchema, } from '../parlay-notifications';
|
|
10
|
+
export type { ParlayLegNotification, ParlayResultNotification, } from '../parlay-notifications';
|
|
11
|
+
export { propSettledNotificationSchema } from '../props';
|
|
12
|
+
export type { PropSettledNotification } from '../props';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schemas/notifications/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACN,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,eAAe,EACf,uBAAuB,EACvB,4BAA4B,GAC5B,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,2BAA2B,EAC3B,8BAA8B,GAC9B,MAAM,yBAAyB,CAAA;AAChC,YAAY,EACX,qBAAqB,EACrB,wBAAwB,GACxB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAA;AACxD,YAAY,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.propSettledNotificationSchema = exports.parlayResultNotificationSchema = exports.parlayLegNotificationSchema = exports.notificationBetResultsSchema = exports.dailyPropsPayloadSchema = exports.dailyPropSchema = exports.betNotificationWonSchema = exports.betNotificationPushSchema = exports.betNotificationLostSchema = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Notification schema barrel.
|
|
6
|
+
*
|
|
7
|
+
* Concrete contracts live in their domain modules. This barrel re-exports them
|
|
8
|
+
* under a stable `notifications` namespace for consumers that prefer a single
|
|
9
|
+
* import surface. Root star-exports remain the primary public API.
|
|
10
|
+
*/
|
|
11
|
+
var betting_1 = require("../betting");
|
|
12
|
+
Object.defineProperty(exports, "betNotificationLostSchema", { enumerable: true, get: function () { return betting_1.betNotificationLostSchema; } });
|
|
13
|
+
Object.defineProperty(exports, "betNotificationPushSchema", { enumerable: true, get: function () { return betting_1.betNotificationPushSchema; } });
|
|
14
|
+
Object.defineProperty(exports, "betNotificationWonSchema", { enumerable: true, get: function () { return betting_1.betNotificationWonSchema; } });
|
|
15
|
+
Object.defineProperty(exports, "dailyPropSchema", { enumerable: true, get: function () { return betting_1.dailyPropSchema; } });
|
|
16
|
+
Object.defineProperty(exports, "dailyPropsPayloadSchema", { enumerable: true, get: function () { return betting_1.dailyPropsPayloadSchema; } });
|
|
17
|
+
Object.defineProperty(exports, "notificationBetResultsSchema", { enumerable: true, get: function () { return betting_1.notificationBetResultsSchema; } });
|
|
18
|
+
var parlay_notifications_1 = require("../parlay-notifications");
|
|
19
|
+
Object.defineProperty(exports, "parlayLegNotificationSchema", { enumerable: true, get: function () { return parlay_notifications_1.parlayLegNotificationSchema; } });
|
|
20
|
+
Object.defineProperty(exports, "parlayResultNotificationSchema", { enumerable: true, get: function () { return parlay_notifications_1.parlayResultNotificationSchema; } });
|
|
21
|
+
var props_1 = require("../props");
|
|
22
|
+
Object.defineProperty(exports, "propSettledNotificationSchema", { enumerable: true, get: function () { return props_1.propSettledNotificationSchema; } });
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemas/notifications/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,sCAOmB;AANlB,oHAAA,yBAAyB,OAAA;AACzB,oHAAA,yBAAyB,OAAA;AACzB,mHAAA,wBAAwB,OAAA;AACxB,0GAAA,eAAe,OAAA;AACf,kHAAA,uBAAuB,OAAA;AACvB,uHAAA,4BAA4B,OAAA;AAE7B,gEAGgC;AAF/B,mIAAA,2BAA2B,OAAA;AAC3B,sIAAA,8BAA8B,OAAA;AAM/B,kCAAwD;AAA/C,sHAAA,6BAA6B,OAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* A leg included in a resolved-parlay notification.
|
|
4
|
+
*
|
|
5
|
+
* `commence_time` is the event date supplied by Khronos. Team names are
|
|
6
|
+
* optional because the parlay ledger stores the selected display text and
|
|
7
|
+
* event identifier, while callers with richer event context may include them.
|
|
8
|
+
*/
|
|
9
|
+
export declare const parlayLegNotificationSchema: z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
event_id: z.ZodString;
|
|
12
|
+
outcome_uuid: z.ZodString;
|
|
13
|
+
selection_display: z.ZodString;
|
|
14
|
+
market_key: z.ZodString;
|
|
15
|
+
odds_american: z.ZodNumber;
|
|
16
|
+
point: z.ZodNullable<z.ZodNumber>;
|
|
17
|
+
commence_time: z.ZodCoercedDate<unknown>;
|
|
18
|
+
result: z.ZodEnum<{
|
|
19
|
+
void: "void";
|
|
20
|
+
pending: "pending";
|
|
21
|
+
won: "won";
|
|
22
|
+
lost: "lost";
|
|
23
|
+
push: "push";
|
|
24
|
+
}>;
|
|
25
|
+
home_team: z.ZodOptional<z.ZodString>;
|
|
26
|
+
away_team: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export type ParlayLegNotification = z.infer<typeof parlayLegNotificationSchema>;
|
|
29
|
+
/**
|
|
30
|
+
* Validated Khronos -> Pluto payload for parlay resolution DMs.
|
|
31
|
+
*
|
|
32
|
+
* `busted` is emitted as soon as a leg loses; `won` and `push_refunded` are
|
|
33
|
+
* emitted once the remaining legs are terminal. `lost` remains accepted for
|
|
34
|
+
* forward compatibility with older producers.
|
|
35
|
+
*/
|
|
36
|
+
export declare const parlayResultNotificationSchema: z.ZodObject<{
|
|
37
|
+
kind: z.ZodEnum<{
|
|
38
|
+
won: "won";
|
|
39
|
+
lost: "lost";
|
|
40
|
+
push_refunded: "push_refunded";
|
|
41
|
+
busted: "busted";
|
|
42
|
+
}>;
|
|
43
|
+
parlay_id: z.ZodString;
|
|
44
|
+
user_id: z.ZodString;
|
|
45
|
+
guild_id: z.ZodOptional<z.ZodString>;
|
|
46
|
+
stake: z.ZodNumber;
|
|
47
|
+
combined_odds_american: z.ZodNumber;
|
|
48
|
+
payout: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
actual_payout: z.ZodNullable<z.ZodNumber>;
|
|
50
|
+
refund_amount: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
old_balance: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
new_balance: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
event_id: z.ZodString;
|
|
56
|
+
outcome_uuid: z.ZodString;
|
|
57
|
+
selection_display: z.ZodString;
|
|
58
|
+
market_key: z.ZodString;
|
|
59
|
+
odds_american: z.ZodNumber;
|
|
60
|
+
point: z.ZodNullable<z.ZodNumber>;
|
|
61
|
+
commence_time: z.ZodCoercedDate<unknown>;
|
|
62
|
+
result: z.ZodEnum<{
|
|
63
|
+
void: "void";
|
|
64
|
+
pending: "pending";
|
|
65
|
+
won: "won";
|
|
66
|
+
lost: "lost";
|
|
67
|
+
push: "push";
|
|
68
|
+
}>;
|
|
69
|
+
home_team: z.ZodOptional<z.ZodString>;
|
|
70
|
+
away_team: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
export type ParlayResultNotification = z.infer<typeof parlayResultNotificationSchema>;
|
|
74
|
+
//# sourceMappingURL=parlay-notifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parlay-notifications.d.ts","sourceRoot":"","sources":["../../src/schemas/parlay-notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;iBAc4B,CAAA;AAEpE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,2BAA2B,CAClC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAea,CAAA;AAExD,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,8BAA8B,CACrC,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parlayResultNotificationSchema = exports.parlayLegNotificationSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* A leg included in a resolved-parlay notification.
|
|
7
|
+
*
|
|
8
|
+
* `commence_time` is the event date supplied by Khronos. Team names are
|
|
9
|
+
* optional because the parlay ledger stores the selected display text and
|
|
10
|
+
* event identifier, while callers with richer event context may include them.
|
|
11
|
+
*/
|
|
12
|
+
exports.parlayLegNotificationSchema = zod_1.z
|
|
13
|
+
.object({
|
|
14
|
+
id: zod_1.z.string().min(1),
|
|
15
|
+
event_id: zod_1.z.string().min(1),
|
|
16
|
+
outcome_uuid: zod_1.z.string().min(1),
|
|
17
|
+
selection_display: zod_1.z.string().min(1),
|
|
18
|
+
market_key: zod_1.z.string().min(1),
|
|
19
|
+
odds_american: zod_1.z.number().int(),
|
|
20
|
+
point: zod_1.z.number().nullable(),
|
|
21
|
+
commence_time: zod_1.z.coerce.date(),
|
|
22
|
+
result: zod_1.z.enum(['pending', 'won', 'lost', 'push', 'void']),
|
|
23
|
+
home_team: zod_1.z.string().min(1).optional(),
|
|
24
|
+
away_team: zod_1.z.string().min(1).optional(),
|
|
25
|
+
})
|
|
26
|
+
.describe('A resolved parlay leg included in a Pluto notification');
|
|
27
|
+
/**
|
|
28
|
+
* Validated Khronos -> Pluto payload for parlay resolution DMs.
|
|
29
|
+
*
|
|
30
|
+
* `busted` is emitted as soon as a leg loses; `won` and `push_refunded` are
|
|
31
|
+
* emitted once the remaining legs are terminal. `lost` remains accepted for
|
|
32
|
+
* forward compatibility with older producers.
|
|
33
|
+
*/
|
|
34
|
+
exports.parlayResultNotificationSchema = zod_1.z
|
|
35
|
+
.object({
|
|
36
|
+
kind: zod_1.z.enum(['won', 'lost', 'push_refunded', 'busted']),
|
|
37
|
+
parlay_id: zod_1.z.string().uuid(),
|
|
38
|
+
user_id: zod_1.z.string().min(1),
|
|
39
|
+
guild_id: zod_1.z.string().min(1).optional(),
|
|
40
|
+
stake: zod_1.z.number().finite().nonnegative(),
|
|
41
|
+
combined_odds_american: zod_1.z.number().int(),
|
|
42
|
+
payout: zod_1.z.number().finite().nonnegative().optional(),
|
|
43
|
+
actual_payout: zod_1.z.number().finite().nonnegative().nullable(),
|
|
44
|
+
refund_amount: zod_1.z.number().finite().nonnegative().optional(),
|
|
45
|
+
old_balance: zod_1.z.number().finite().optional(),
|
|
46
|
+
new_balance: zod_1.z.number().finite().optional(),
|
|
47
|
+
legs: zod_1.z.array(exports.parlayLegNotificationSchema).min(1),
|
|
48
|
+
})
|
|
49
|
+
.describe('Notification payload for a resolved parlay');
|
|
50
|
+
//# sourceMappingURL=parlay-notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parlay-notifications.js","sourceRoot":"","sources":["../../src/schemas/parlay-notifications.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAEvB;;;;;;GAMG;AACU,QAAA,2BAA2B,GAAG,OAAC;KAC1C,MAAM,CAAC;IACP,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,iBAAiB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC/B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,aAAa,EAAE,OAAC,CAAC,MAAM,CAAC,IAAI,EAAE;IAC9B,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MA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EAAE,CAAC,QAAQ,EAAE;IAC3C,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,mCAA2B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACjD,CAAC;KACD,QAAQ,CAAC,4CAA4C,CAAC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Validated Khronos -> Pluto payload for in-channel prop settlement edits. */
|
|
3
|
+
export declare const propSettledNotificationSchema: z.ZodObject<{
|
|
4
|
+
outcome_uuid: z.ZodString;
|
|
5
|
+
result: z.ZodEnum<{
|
|
6
|
+
void: "void";
|
|
7
|
+
won: "won";
|
|
8
|
+
lost: "lost";
|
|
9
|
+
push: "push";
|
|
10
|
+
}>;
|
|
11
|
+
winning_side_display: z.ZodOptional<z.ZodString>;
|
|
12
|
+
actual_value: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
13
|
+
market_key: z.ZodString;
|
|
14
|
+
description: z.ZodString;
|
|
15
|
+
point: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
16
|
+
tallies: z.ZodObject<{
|
|
17
|
+
correct: z.ZodNumber;
|
|
18
|
+
incorrect: z.ZodNumber;
|
|
19
|
+
total: z.ZodNumber;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
22
|
+
guild_id: z.ZodString;
|
|
23
|
+
channel_id: z.ZodString;
|
|
24
|
+
message_id: z.ZodString;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type PropSettledNotification = z.infer<typeof propSettledNotificationSchema>;
|
|
28
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/schemas/props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAcvB,+EAA+E;AAC/E,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;iBAY2C,CAAA;AAErF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,6BAA6B,CACpC,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.propSettledNotificationSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const propSettlementMessageSchema = zod_1.z.object({
|
|
6
|
+
guild_id: zod_1.z.string().min(1),
|
|
7
|
+
channel_id: zod_1.z.string().min(1),
|
|
8
|
+
message_id: zod_1.z.string().min(1),
|
|
9
|
+
});
|
|
10
|
+
const propSettlementTalliesSchema = zod_1.z.object({
|
|
11
|
+
correct: zod_1.z.number().int().nonnegative(),
|
|
12
|
+
incorrect: zod_1.z.number().int().nonnegative(),
|
|
13
|
+
total: zod_1.z.number().int().nonnegative(),
|
|
14
|
+
});
|
|
15
|
+
/** Validated Khronos -> Pluto payload for in-channel prop settlement edits. */
|
|
16
|
+
exports.propSettledNotificationSchema = zod_1.z
|
|
17
|
+
.object({
|
|
18
|
+
outcome_uuid: zod_1.z.string().uuid(),
|
|
19
|
+
result: zod_1.z.enum(['won', 'lost', 'push', 'void']),
|
|
20
|
+
winning_side_display: zod_1.z.string().optional(),
|
|
21
|
+
actual_value: zod_1.z.number().nullable().optional(),
|
|
22
|
+
market_key: zod_1.z.string().min(1),
|
|
23
|
+
description: zod_1.z.string().min(1),
|
|
24
|
+
point: zod_1.z.number().nullable().optional(),
|
|
25
|
+
tallies: propSettlementTalliesSchema,
|
|
26
|
+
messages: zod_1.z.array(propSettlementMessageSchema).min(1),
|
|
27
|
+
})
|
|
28
|
+
.describe('Notification for updating original Discord prop embeds after settlement');
|
|
29
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","source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,EAAE,CAAC,QAAQ,EAAE;IACvC,OAAO,EAAE,2BAA2B;IACpC,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACrD,CAAC;KACD,QAAQ,CAAC,yEAAyE,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluto-khronos/types",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Shared TypeScript types & Zod schemas for the Khronos ↔ Pluto contract. Published from the Khronos monorepo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "fenix <fenixcoding@gmail.com>",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsc",
|
|
29
|
+
"test": "pnpm build && node --test test/*.test.mjs",
|
|
29
30
|
"dev:push": "pnpm build && yalc push --no-scripts",
|
|
30
31
|
"prepublishOnly": "pnpm build"
|
|
31
32
|
},
|