@pear-protocol/types 1.0.0 → 1.1.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/bundle.d.ts +1 -0
- package/dist/bundle.js +1 -0
- package/dist/notification/entities.d.ts +108 -0
- package/dist/notification/entities.js +61 -0
- package/dist/notification/index.d.ts +4 -0
- package/dist/notification/index.js +4 -0
- package/dist/notification/payloads.d.ts +20 -0
- package/dist/notification/payloads.js +9 -0
- package/dist/notification/queries.d.ts +13 -0
- package/dist/notification/queries.js +25 -0
- package/dist/notification/responses.d.ts +67 -0
- package/dist/notification/responses.js +20 -0
- package/package.json +1 -1
package/dist/bundle.d.ts
CHANGED
package/dist/bundle.js
CHANGED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const NotificationCategory: z.ZodEnum<{
|
|
3
|
+
TAKE_PROFIT_HIT: "TAKE_PROFIT_HIT";
|
|
4
|
+
STOP_LOSS_HIT: "STOP_LOSS_HIT";
|
|
5
|
+
TRIGGER_ORDER_HIT: "TRIGGER_ORDER_HIT";
|
|
6
|
+
}>;
|
|
7
|
+
export type NotificationCategory = z.infer<typeof NotificationCategory>;
|
|
8
|
+
export declare const NotificationParameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
|
+
type: z.ZodLiteral<"take_profit">;
|
|
10
|
+
triggerId: z.ZodUUID;
|
|
11
|
+
positionId: z.ZodUUID;
|
|
12
|
+
connector: z.ZodEnum<{
|
|
13
|
+
hyperliquid: "hyperliquid";
|
|
14
|
+
binance: "binance";
|
|
15
|
+
bybit: "bybit";
|
|
16
|
+
okx: "okx";
|
|
17
|
+
lighter: "lighter";
|
|
18
|
+
}>;
|
|
19
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<"stop_loss">;
|
|
21
|
+
triggerId: z.ZodUUID;
|
|
22
|
+
positionId: z.ZodUUID;
|
|
23
|
+
connector: z.ZodEnum<{
|
|
24
|
+
hyperliquid: "hyperliquid";
|
|
25
|
+
binance: "binance";
|
|
26
|
+
bybit: "bybit";
|
|
27
|
+
okx: "okx";
|
|
28
|
+
lighter: "lighter";
|
|
29
|
+
}>;
|
|
30
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<"trigger_order">;
|
|
32
|
+
triggerId: z.ZodUUID;
|
|
33
|
+
positionId: z.ZodUUID;
|
|
34
|
+
connector: z.ZodEnum<{
|
|
35
|
+
hyperliquid: "hyperliquid";
|
|
36
|
+
binance: "binance";
|
|
37
|
+
bybit: "bybit";
|
|
38
|
+
okx: "okx";
|
|
39
|
+
lighter: "lighter";
|
|
40
|
+
}>;
|
|
41
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
42
|
+
type: z.ZodLiteral<"default_trigger">;
|
|
43
|
+
triggerId: z.ZodUUID;
|
|
44
|
+
connector: z.ZodEnum<{
|
|
45
|
+
hyperliquid: "hyperliquid";
|
|
46
|
+
binance: "binance";
|
|
47
|
+
bybit: "bybit";
|
|
48
|
+
okx: "okx";
|
|
49
|
+
lighter: "lighter";
|
|
50
|
+
}>;
|
|
51
|
+
}, z.core.$strip>], "type">;
|
|
52
|
+
export type NotificationParameters = z.output<typeof NotificationParameters>;
|
|
53
|
+
export declare const Notification: z.ZodObject<{
|
|
54
|
+
id: z.ZodUUID;
|
|
55
|
+
category: z.ZodEnum<{
|
|
56
|
+
TAKE_PROFIT_HIT: "TAKE_PROFIT_HIT";
|
|
57
|
+
STOP_LOSS_HIT: "STOP_LOSS_HIT";
|
|
58
|
+
TRIGGER_ORDER_HIT: "TRIGGER_ORDER_HIT";
|
|
59
|
+
}>;
|
|
60
|
+
parameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
61
|
+
type: z.ZodLiteral<"take_profit">;
|
|
62
|
+
triggerId: z.ZodUUID;
|
|
63
|
+
positionId: z.ZodUUID;
|
|
64
|
+
connector: z.ZodEnum<{
|
|
65
|
+
hyperliquid: "hyperliquid";
|
|
66
|
+
binance: "binance";
|
|
67
|
+
bybit: "bybit";
|
|
68
|
+
okx: "okx";
|
|
69
|
+
lighter: "lighter";
|
|
70
|
+
}>;
|
|
71
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
72
|
+
type: z.ZodLiteral<"stop_loss">;
|
|
73
|
+
triggerId: z.ZodUUID;
|
|
74
|
+
positionId: z.ZodUUID;
|
|
75
|
+
connector: z.ZodEnum<{
|
|
76
|
+
hyperliquid: "hyperliquid";
|
|
77
|
+
binance: "binance";
|
|
78
|
+
bybit: "bybit";
|
|
79
|
+
okx: "okx";
|
|
80
|
+
lighter: "lighter";
|
|
81
|
+
}>;
|
|
82
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
83
|
+
type: z.ZodLiteral<"trigger_order">;
|
|
84
|
+
triggerId: z.ZodUUID;
|
|
85
|
+
positionId: z.ZodUUID;
|
|
86
|
+
connector: z.ZodEnum<{
|
|
87
|
+
hyperliquid: "hyperliquid";
|
|
88
|
+
binance: "binance";
|
|
89
|
+
bybit: "bybit";
|
|
90
|
+
okx: "okx";
|
|
91
|
+
lighter: "lighter";
|
|
92
|
+
}>;
|
|
93
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
94
|
+
type: z.ZodLiteral<"default_trigger">;
|
|
95
|
+
triggerId: z.ZodUUID;
|
|
96
|
+
connector: z.ZodEnum<{
|
|
97
|
+
hyperliquid: "hyperliquid";
|
|
98
|
+
binance: "binance";
|
|
99
|
+
bybit: "bybit";
|
|
100
|
+
okx: "okx";
|
|
101
|
+
lighter: "lighter";
|
|
102
|
+
}>;
|
|
103
|
+
}, z.core.$strip>], "type">;
|
|
104
|
+
isRead: z.ZodBoolean;
|
|
105
|
+
createdAt: z.ZodString;
|
|
106
|
+
updatedAt: z.ZodString;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
export type Notification = z.output<typeof Notification>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Connector } from '../connector';
|
|
3
|
+
|
|
4
|
+
const NotificationCategory = z.enum(["TAKE_PROFIT_HIT", "STOP_LOSS_HIT", "TRIGGER_ORDER_HIT"]);
|
|
5
|
+
const TakeProfitNotificationParameters = z.object({
|
|
6
|
+
type: z.literal("take_profit"),
|
|
7
|
+
triggerId: z.uuid(),
|
|
8
|
+
positionId: z.uuid(),
|
|
9
|
+
connector: Connector
|
|
10
|
+
});
|
|
11
|
+
const StopLossNotificationParameters = z.object({
|
|
12
|
+
type: z.literal("stop_loss"),
|
|
13
|
+
triggerId: z.uuid(),
|
|
14
|
+
positionId: z.uuid(),
|
|
15
|
+
connector: Connector
|
|
16
|
+
});
|
|
17
|
+
const TriggerOrderNotificationParameters = z.object({
|
|
18
|
+
type: z.literal("trigger_order"),
|
|
19
|
+
triggerId: z.uuid(),
|
|
20
|
+
positionId: z.uuid(),
|
|
21
|
+
connector: Connector
|
|
22
|
+
});
|
|
23
|
+
const DefaultTriggerNotificationParameters = z.object({
|
|
24
|
+
type: z.literal("default_trigger"),
|
|
25
|
+
triggerId: z.uuid(),
|
|
26
|
+
connector: Connector
|
|
27
|
+
});
|
|
28
|
+
const NotificationParameters = z.discriminatedUnion("type", [
|
|
29
|
+
TakeProfitNotificationParameters,
|
|
30
|
+
StopLossNotificationParameters,
|
|
31
|
+
TriggerOrderNotificationParameters,
|
|
32
|
+
DefaultTriggerNotificationParameters
|
|
33
|
+
]);
|
|
34
|
+
const Notification = z.object({
|
|
35
|
+
/**
|
|
36
|
+
* Notification UUID
|
|
37
|
+
*/
|
|
38
|
+
id: z.uuid(),
|
|
39
|
+
/**
|
|
40
|
+
* What kind of notification this is
|
|
41
|
+
*/
|
|
42
|
+
category: NotificationCategory,
|
|
43
|
+
/**
|
|
44
|
+
* Category-specific display payload
|
|
45
|
+
*/
|
|
46
|
+
parameters: NotificationParameters,
|
|
47
|
+
/**
|
|
48
|
+
* Whether the user has read it
|
|
49
|
+
*/
|
|
50
|
+
isRead: z.boolean(),
|
|
51
|
+
/**
|
|
52
|
+
* Created at timestamp
|
|
53
|
+
*/
|
|
54
|
+
createdAt: z.string(),
|
|
55
|
+
/**
|
|
56
|
+
* Updated at timestamp
|
|
57
|
+
*/
|
|
58
|
+
updatedAt: z.string()
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export { Notification, NotificationCategory, NotificationParameters };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Mark notifications as read. Provide exactly one selector: a single `id`, or a
|
|
4
|
+
* `timestamp` (epoch ms) to mark every notification created at or before it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const MarkNotificationsReadPayload: z.ZodUnion<readonly [z.ZodObject<{
|
|
7
|
+
id: z.ZodUUID;
|
|
8
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
9
|
+
timestamp: z.ZodCoercedNumber<number>;
|
|
10
|
+
}, z.core.$strict>]>;
|
|
11
|
+
export type MarkNotificationsReadPayloadInput = z.input<typeof MarkNotificationsReadPayload>;
|
|
12
|
+
export type MarkNotificationsReadPayload = z.output<typeof MarkNotificationsReadPayload>;
|
|
13
|
+
/**
|
|
14
|
+
* Mark a single notification unread again.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MarkNotificationUnreadPayload: z.ZodObject<{
|
|
17
|
+
id: z.ZodUUID;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
export type MarkNotificationUnreadPayloadInput = z.input<typeof MarkNotificationUnreadPayload>;
|
|
20
|
+
export type MarkNotificationUnreadPayload = z.output<typeof MarkNotificationUnreadPayload>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const MarkNotificationsReadPayload = z.union([
|
|
4
|
+
z.strictObject({ id: z.uuid() }),
|
|
5
|
+
z.strictObject({ timestamp: z.coerce.number().int().positive() })
|
|
6
|
+
]);
|
|
7
|
+
const MarkNotificationUnreadPayload = z.strictObject({ id: z.uuid() });
|
|
8
|
+
|
|
9
|
+
export { MarkNotificationUnreadPayload, MarkNotificationsReadPayload };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const NotificationListParams: z.ZodObject<{
|
|
3
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>;
|
|
4
|
+
startDate: z.ZodOptional<z.ZodCoercedDate<Date>>;
|
|
5
|
+
endDate: z.ZodOptional<z.ZodCoercedDate<Date>>;
|
|
6
|
+
scope: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
all: "all";
|
|
8
|
+
read: "read";
|
|
9
|
+
unread: "unread";
|
|
10
|
+
}>>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type NotificationListParamsInput = z.input<typeof NotificationListParams>;
|
|
13
|
+
export type NotificationListParams = z.output<typeof NotificationListParams>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const NotificationListParams = z.object({
|
|
4
|
+
/**
|
|
5
|
+
* The maximum number of notifications to retrieve (newest first).
|
|
6
|
+
* Matches the V2 engine: max and default are both 100.
|
|
7
|
+
*/
|
|
8
|
+
limit: z.coerce.number().int().positive().max(100).optional().default(100),
|
|
9
|
+
/**
|
|
10
|
+
* Only return notifications created at or after this date.
|
|
11
|
+
*/
|
|
12
|
+
startDate: z.coerce.date().optional(),
|
|
13
|
+
/**
|
|
14
|
+
* Only return notifications created at or before this date.
|
|
15
|
+
*/
|
|
16
|
+
endDate: z.coerce.date().optional(),
|
|
17
|
+
/**
|
|
18
|
+
* Filter by read state: `all` (default), only `read`, or only `unread`.
|
|
19
|
+
*/
|
|
20
|
+
scope: z.enum(["all", "read", "unread"]).optional().default("all")
|
|
21
|
+
}).refine((data) => !data.startDate || !data.endDate || data.startDate < data.endDate, {
|
|
22
|
+
message: "startDate must be before endDate"
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { NotificationListParams };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const NotificationListResponse: z.ZodObject<{
|
|
3
|
+
notifications: z.ZodArray<z.ZodObject<{
|
|
4
|
+
id: z.ZodUUID;
|
|
5
|
+
category: z.ZodEnum<{
|
|
6
|
+
TAKE_PROFIT_HIT: "TAKE_PROFIT_HIT";
|
|
7
|
+
STOP_LOSS_HIT: "STOP_LOSS_HIT";
|
|
8
|
+
TRIGGER_ORDER_HIT: "TRIGGER_ORDER_HIT";
|
|
9
|
+
}>;
|
|
10
|
+
parameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
11
|
+
type: z.ZodLiteral<"take_profit">;
|
|
12
|
+
triggerId: z.ZodUUID;
|
|
13
|
+
positionId: z.ZodUUID;
|
|
14
|
+
connector: z.ZodEnum<{
|
|
15
|
+
hyperliquid: "hyperliquid";
|
|
16
|
+
binance: "binance";
|
|
17
|
+
bybit: "bybit";
|
|
18
|
+
okx: "okx";
|
|
19
|
+
lighter: "lighter";
|
|
20
|
+
}>;
|
|
21
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
22
|
+
type: z.ZodLiteral<"stop_loss">;
|
|
23
|
+
triggerId: z.ZodUUID;
|
|
24
|
+
positionId: z.ZodUUID;
|
|
25
|
+
connector: z.ZodEnum<{
|
|
26
|
+
hyperliquid: "hyperliquid";
|
|
27
|
+
binance: "binance";
|
|
28
|
+
bybit: "bybit";
|
|
29
|
+
okx: "okx";
|
|
30
|
+
lighter: "lighter";
|
|
31
|
+
}>;
|
|
32
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
33
|
+
type: z.ZodLiteral<"trigger_order">;
|
|
34
|
+
triggerId: z.ZodUUID;
|
|
35
|
+
positionId: z.ZodUUID;
|
|
36
|
+
connector: z.ZodEnum<{
|
|
37
|
+
hyperliquid: "hyperliquid";
|
|
38
|
+
binance: "binance";
|
|
39
|
+
bybit: "bybit";
|
|
40
|
+
okx: "okx";
|
|
41
|
+
lighter: "lighter";
|
|
42
|
+
}>;
|
|
43
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
44
|
+
type: z.ZodLiteral<"default_trigger">;
|
|
45
|
+
triggerId: z.ZodUUID;
|
|
46
|
+
connector: z.ZodEnum<{
|
|
47
|
+
hyperliquid: "hyperliquid";
|
|
48
|
+
binance: "binance";
|
|
49
|
+
bybit: "bybit";
|
|
50
|
+
okx: "okx";
|
|
51
|
+
lighter: "lighter";
|
|
52
|
+
}>;
|
|
53
|
+
}, z.core.$strip>], "type">;
|
|
54
|
+
isRead: z.ZodBoolean;
|
|
55
|
+
createdAt: z.ZodString;
|
|
56
|
+
updatedAt: z.ZodString;
|
|
57
|
+
}, z.core.$strip>>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
export type NotificationListResponse = z.output<typeof NotificationListResponse>;
|
|
60
|
+
export declare const MarkNotificationsReadResponse: z.ZodObject<{
|
|
61
|
+
updated: z.ZodNumber;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
export type MarkNotificationsReadResponse = z.output<typeof MarkNotificationsReadResponse>;
|
|
64
|
+
export declare const MarkNotificationUnreadResponse: z.ZodObject<{
|
|
65
|
+
updated: z.ZodNumber;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type MarkNotificationUnreadResponse = z.output<typeof MarkNotificationUnreadResponse>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Notification } from './entities';
|
|
3
|
+
|
|
4
|
+
const NotificationListResponse = z.object({
|
|
5
|
+
notifications: z.array(Notification)
|
|
6
|
+
});
|
|
7
|
+
const MarkNotificationsReadResponse = z.object({
|
|
8
|
+
/**
|
|
9
|
+
* How many notifications were flipped from unread to read.
|
|
10
|
+
*/
|
|
11
|
+
updated: z.number().int()
|
|
12
|
+
});
|
|
13
|
+
const MarkNotificationUnreadResponse = z.object({
|
|
14
|
+
/**
|
|
15
|
+
* How many notifications were flipped from read to unread.
|
|
16
|
+
*/
|
|
17
|
+
updated: z.number().int()
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export { MarkNotificationUnreadResponse, MarkNotificationsReadResponse, NotificationListResponse };
|