@stellaris/metrics-shared 0.1.13 → 0.1.15
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/{bff-service.d.ts → dist/bff-service.d.ts} +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +133 -0
- package/dist/schemas/filter.d.ts +39 -0
- package/dist/schemas/metric.d.ts +24 -0
- package/dist/schemas/rpa-event.d.ts +180 -0
- package/dist/schemas/rpa-session.d.ts +62 -0
- package/dist/schemas/time.d.ts +12 -0
- package/package.json +13 -5
- package/index.ts +0 -2
- package/publish.sh +0 -71
- package/schemas/filter.ts +0 -60
- package/schemas/metric.ts +0 -15
- package/schemas/rpa-event.ts +0 -94
- package/schemas/rpa-session.ts +0 -72
- package/schemas/time.ts +0 -11
- /package/{schemas/index.ts → dist/schemas/index.d.ts} +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
export type ReportStatus = "draft" | "published" | "archived";
|
|
4
4
|
export type RpaStage = "queued" | "executing" | "success" | "failed";
|
|
5
5
|
export type RpaActionEventType = "reply-message" | "change-cs-status";
|
|
6
|
-
declare const app: import("hono/hono-base").HonoBase<{}, {
|
|
6
|
+
export declare const app: import("hono/hono-base").HonoBase<{}, {
|
|
7
7
|
"/health": {
|
|
8
8
|
$get: {
|
|
9
9
|
input: {};
|
|
@@ -935,7 +935,7 @@ declare const app: import("hono/hono-base").HonoBase<{}, {
|
|
|
935
935
|
host: string;
|
|
936
936
|
status: 3 | 1 | 2;
|
|
937
937
|
platformCode?: string | undefined;
|
|
938
|
-
|
|
938
|
+
actionId?: string | undefined;
|
|
939
939
|
};
|
|
940
940
|
message?: string | null | undefined;
|
|
941
941
|
timestamp?: number | undefined;
|
|
@@ -2207,7 +2207,7 @@ declare const app: import("hono/hono-base").HonoBase<{}, {
|
|
|
2207
2207
|
host: string;
|
|
2208
2208
|
status: 3 | 1 | 2;
|
|
2209
2209
|
platformCode?: string | undefined;
|
|
2210
|
-
|
|
2210
|
+
actionId?: string | undefined;
|
|
2211
2211
|
};
|
|
2212
2212
|
message?: string | null | undefined;
|
|
2213
2213
|
timestamp?: number | undefined;
|
|
@@ -2280,7 +2280,7 @@ declare const app: import("hono/hono-base").HonoBase<{}, {
|
|
|
2280
2280
|
host: string;
|
|
2281
2281
|
status: 3 | 1 | 2;
|
|
2282
2282
|
platformCode?: string | undefined;
|
|
2283
|
-
|
|
2283
|
+
actionId?: string | undefined;
|
|
2284
2284
|
};
|
|
2285
2285
|
message?: string | null | undefined;
|
|
2286
2286
|
timestamp?: number | undefined;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// metrics-shared/schemas/filter.ts
|
|
2
|
+
import z from "zod";
|
|
3
|
+
var binaryOperatorSchema = z.enum([
|
|
4
|
+
"equals",
|
|
5
|
+
"notEquals",
|
|
6
|
+
"contains",
|
|
7
|
+
"notContains",
|
|
8
|
+
"startsWith",
|
|
9
|
+
"notStartsWith",
|
|
10
|
+
"endsWith",
|
|
11
|
+
"notEndsWith",
|
|
12
|
+
"gt",
|
|
13
|
+
"gte",
|
|
14
|
+
"lt",
|
|
15
|
+
"lte",
|
|
16
|
+
"inDateRange",
|
|
17
|
+
"notInDateRange",
|
|
18
|
+
"beforeDate",
|
|
19
|
+
"beforeOrOnDate",
|
|
20
|
+
"afterDate",
|
|
21
|
+
"afterOrOnDate"
|
|
22
|
+
]);
|
|
23
|
+
var unaryOperatorSchema = z.enum(["set", "notSet"]);
|
|
24
|
+
var baseFilterShape = {
|
|
25
|
+
id: z.string(),
|
|
26
|
+
member: z.string().optional(),
|
|
27
|
+
dimension: z.string().optional()
|
|
28
|
+
};
|
|
29
|
+
var binaryFilterSchema = z.object({
|
|
30
|
+
...baseFilterShape,
|
|
31
|
+
operator: binaryOperatorSchema,
|
|
32
|
+
values: z.array(z.string())
|
|
33
|
+
});
|
|
34
|
+
var unaryFilterSchema = z.object({
|
|
35
|
+
...baseFilterShape,
|
|
36
|
+
operator: unaryOperatorSchema
|
|
37
|
+
});
|
|
38
|
+
var filterSchema = z.lazy(
|
|
39
|
+
() => z.union([binaryFilterSchema, unaryFilterSchema])
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// metrics-shared/schemas/metric.ts
|
|
43
|
+
import { z as z3 } from "zod";
|
|
44
|
+
|
|
45
|
+
// metrics-shared/schemas/time.ts
|
|
46
|
+
import { z as z2 } from "zod";
|
|
47
|
+
var predefinedGrins = ["minute", "hour", "day", "week", "month", "quarter", "year"];
|
|
48
|
+
var timeGrainSchema = z2.enum(predefinedGrins);
|
|
49
|
+
|
|
50
|
+
// metrics-shared/schemas/metric.ts
|
|
51
|
+
var metricQueryConfigSchema = z3.object({
|
|
52
|
+
table: z3.string(),
|
|
53
|
+
value: z3.string(),
|
|
54
|
+
timeDimension: z3.string(),
|
|
55
|
+
dimensions: z3.array(z3.string()),
|
|
56
|
+
filters: z3.array(filterSchema),
|
|
57
|
+
timeGrain: z3.array(timeGrainSchema),
|
|
58
|
+
format: z3.enum(["number", "currency", "percent"])
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// metrics-shared/schemas/rpa-event.ts
|
|
62
|
+
import z4 from "zod";
|
|
63
|
+
var messageSceneTypeSchema = z4.literal("specialSceneTransfer");
|
|
64
|
+
var csStatusSchema = z4.union([
|
|
65
|
+
z4.literal(1),
|
|
66
|
+
z4.literal(2),
|
|
67
|
+
z4.literal(3)
|
|
68
|
+
]);
|
|
69
|
+
var rpaEventBaseSchema = z4.object({
|
|
70
|
+
shopId: z4.string(),
|
|
71
|
+
agentConfigId: z4.string(),
|
|
72
|
+
stage: z4.enum(["queued", "executing", "success", "failed"]),
|
|
73
|
+
message: z4.string().nullable().optional(),
|
|
74
|
+
timestamp: z4.number().optional(),
|
|
75
|
+
sequence: z4.number().int().optional(),
|
|
76
|
+
actionId: z4.string().optional()
|
|
77
|
+
});
|
|
78
|
+
var replyMessageEventSchema = rpaEventBaseSchema.extend({
|
|
79
|
+
eventType: z4.literal("reply-message"),
|
|
80
|
+
payload: z4.looseObject({
|
|
81
|
+
mallId: z4.string(),
|
|
82
|
+
shopId: z4.string(),
|
|
83
|
+
userId: z4.string(),
|
|
84
|
+
uid: z4.string(),
|
|
85
|
+
messageId: z4.string(),
|
|
86
|
+
content: z4.string(),
|
|
87
|
+
aiAgentConfigId: z4.number(),
|
|
88
|
+
host: z4.string(),
|
|
89
|
+
platformCode: z4.string(),
|
|
90
|
+
tbUid: z4.string(),
|
|
91
|
+
msgId: z4.string().optional(),
|
|
92
|
+
procState: z4.string().optional(),
|
|
93
|
+
transferReason: z4.string().optional(),
|
|
94
|
+
messageType: messageSceneTypeSchema.optional(),
|
|
95
|
+
orderRemark: z4.string().optional(),
|
|
96
|
+
ignoreTransferred: z4.boolean().optional()
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
var changeCsStatusEventSchema = rpaEventBaseSchema.extend({
|
|
100
|
+
eventType: z4.literal("change-cs-status"),
|
|
101
|
+
payload: z4.looseObject({
|
|
102
|
+
aiAgentConfigId: z4.number(),
|
|
103
|
+
host: z4.string(),
|
|
104
|
+
status: csStatusSchema,
|
|
105
|
+
platformCode: z4.string().optional(),
|
|
106
|
+
actionId: z4.string().optional()
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
var userMessageEventSchema = rpaEventBaseSchema.extend({
|
|
110
|
+
eventType: z4.literal("user-message"),
|
|
111
|
+
payload: z4.object({
|
|
112
|
+
platform: z4.string(),
|
|
113
|
+
userId: z4.string(),
|
|
114
|
+
uid: z4.string()
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
var rpaEventSchema = z4.discriminatedUnion("eventType", [
|
|
118
|
+
replyMessageEventSchema,
|
|
119
|
+
changeCsStatusEventSchema,
|
|
120
|
+
userMessageEventSchema
|
|
121
|
+
]);
|
|
122
|
+
export {
|
|
123
|
+
changeCsStatusEventSchema,
|
|
124
|
+
csStatusSchema,
|
|
125
|
+
filterSchema,
|
|
126
|
+
messageSceneTypeSchema,
|
|
127
|
+
metricQueryConfigSchema,
|
|
128
|
+
replyMessageEventSchema,
|
|
129
|
+
rpaEventBaseSchema,
|
|
130
|
+
rpaEventSchema,
|
|
131
|
+
timeGrainSchema,
|
|
132
|
+
userMessageEventSchema
|
|
133
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
declare const binaryOperatorSchema: z.ZodEnum<{
|
|
3
|
+
equals: "equals";
|
|
4
|
+
notEquals: "notEquals";
|
|
5
|
+
contains: "contains";
|
|
6
|
+
notContains: "notContains";
|
|
7
|
+
startsWith: "startsWith";
|
|
8
|
+
notStartsWith: "notStartsWith";
|
|
9
|
+
endsWith: "endsWith";
|
|
10
|
+
notEndsWith: "notEndsWith";
|
|
11
|
+
gt: "gt";
|
|
12
|
+
gte: "gte";
|
|
13
|
+
lt: "lt";
|
|
14
|
+
lte: "lte";
|
|
15
|
+
inDateRange: "inDateRange";
|
|
16
|
+
notInDateRange: "notInDateRange";
|
|
17
|
+
beforeDate: "beforeDate";
|
|
18
|
+
beforeOrOnDate: "beforeOrOnDate";
|
|
19
|
+
afterDate: "afterDate";
|
|
20
|
+
afterOrOnDate: "afterOrOnDate";
|
|
21
|
+
}>;
|
|
22
|
+
declare const unaryOperatorSchema: z.ZodEnum<{
|
|
23
|
+
set: "set";
|
|
24
|
+
notSet: "notSet";
|
|
25
|
+
}>;
|
|
26
|
+
export type Filter = {
|
|
27
|
+
id: string;
|
|
28
|
+
member?: string;
|
|
29
|
+
dimension?: string;
|
|
30
|
+
operator: z.infer<typeof binaryOperatorSchema>;
|
|
31
|
+
values: string[];
|
|
32
|
+
} | {
|
|
33
|
+
id: string;
|
|
34
|
+
member?: string;
|
|
35
|
+
dimension?: string;
|
|
36
|
+
operator: z.infer<typeof unaryOperatorSchema>;
|
|
37
|
+
};
|
|
38
|
+
export declare const filterSchema: z.ZodType<Filter>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const metricQueryConfigSchema: z.ZodObject<{
|
|
3
|
+
table: z.ZodString;
|
|
4
|
+
value: z.ZodString;
|
|
5
|
+
timeDimension: z.ZodString;
|
|
6
|
+
dimensions: z.ZodArray<z.ZodString>;
|
|
7
|
+
filters: z.ZodArray<z.ZodType<import("./filter").Filter, unknown, z.core.$ZodTypeInternals<import("./filter").Filter, unknown>>>;
|
|
8
|
+
timeGrain: z.ZodArray<z.ZodEnum<{
|
|
9
|
+
second: "second";
|
|
10
|
+
minute: "minute";
|
|
11
|
+
hour: "hour";
|
|
12
|
+
day: "day";
|
|
13
|
+
week: "week";
|
|
14
|
+
month: "month";
|
|
15
|
+
quarter: "quarter";
|
|
16
|
+
year: "year";
|
|
17
|
+
}>>;
|
|
18
|
+
format: z.ZodEnum<{
|
|
19
|
+
number: "number";
|
|
20
|
+
currency: "currency";
|
|
21
|
+
percent: "percent";
|
|
22
|
+
}>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export type MetricQueryConfig = z.infer<typeof metricQueryConfigSchema>;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* 消息场景类型
|
|
4
|
+
*/
|
|
5
|
+
export declare const messageSceneTypeSchema: z.ZodLiteral<"specialSceneTransfer">;
|
|
6
|
+
export type MessageSceneType = z.infer<typeof messageSceneTypeSchema>;
|
|
7
|
+
/**
|
|
8
|
+
* 客服状态枚举
|
|
9
|
+
*/
|
|
10
|
+
export declare const csStatusSchema: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
11
|
+
export type CsStatus = z.infer<typeof csStatusSchema>;
|
|
12
|
+
export declare const rpaEventBaseSchema: z.ZodObject<{
|
|
13
|
+
shopId: z.ZodString;
|
|
14
|
+
agentConfigId: z.ZodString;
|
|
15
|
+
stage: z.ZodEnum<{
|
|
16
|
+
success: "success";
|
|
17
|
+
queued: "queued";
|
|
18
|
+
executing: "executing";
|
|
19
|
+
failed: "failed";
|
|
20
|
+
}>;
|
|
21
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
22
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
actionId: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export declare const replyMessageEventSchema: z.ZodObject<{
|
|
27
|
+
shopId: z.ZodString;
|
|
28
|
+
agentConfigId: z.ZodString;
|
|
29
|
+
stage: z.ZodEnum<{
|
|
30
|
+
success: "success";
|
|
31
|
+
queued: "queued";
|
|
32
|
+
executing: "executing";
|
|
33
|
+
failed: "failed";
|
|
34
|
+
}>;
|
|
35
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
actionId: z.ZodOptional<z.ZodString>;
|
|
39
|
+
eventType: z.ZodLiteral<"reply-message">;
|
|
40
|
+
payload: z.ZodObject<{
|
|
41
|
+
mallId: z.ZodString;
|
|
42
|
+
shopId: z.ZodString;
|
|
43
|
+
userId: z.ZodString;
|
|
44
|
+
uid: z.ZodString;
|
|
45
|
+
messageId: z.ZodString;
|
|
46
|
+
content: z.ZodString;
|
|
47
|
+
aiAgentConfigId: z.ZodNumber;
|
|
48
|
+
host: z.ZodString;
|
|
49
|
+
platformCode: z.ZodString;
|
|
50
|
+
tbUid: z.ZodString;
|
|
51
|
+
msgId: z.ZodOptional<z.ZodString>;
|
|
52
|
+
procState: z.ZodOptional<z.ZodString>;
|
|
53
|
+
transferReason: z.ZodOptional<z.ZodString>;
|
|
54
|
+
messageType: z.ZodOptional<z.ZodLiteral<"specialSceneTransfer">>;
|
|
55
|
+
orderRemark: z.ZodOptional<z.ZodString>;
|
|
56
|
+
ignoreTransferred: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
}, z.core.$loose>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
export type ReplyMessageEventPayload = z.infer<typeof replyMessageEventSchema>["payload"];
|
|
60
|
+
export type ReplyMessageRpaEvent = z.infer<typeof replyMessageEventSchema>;
|
|
61
|
+
export declare const changeCsStatusEventSchema: z.ZodObject<{
|
|
62
|
+
shopId: z.ZodString;
|
|
63
|
+
agentConfigId: z.ZodString;
|
|
64
|
+
stage: z.ZodEnum<{
|
|
65
|
+
success: "success";
|
|
66
|
+
queued: "queued";
|
|
67
|
+
executing: "executing";
|
|
68
|
+
failed: "failed";
|
|
69
|
+
}>;
|
|
70
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
actionId: z.ZodOptional<z.ZodString>;
|
|
74
|
+
eventType: z.ZodLiteral<"change-cs-status">;
|
|
75
|
+
payload: z.ZodObject<{
|
|
76
|
+
aiAgentConfigId: z.ZodNumber;
|
|
77
|
+
host: z.ZodString;
|
|
78
|
+
status: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
79
|
+
platformCode: z.ZodOptional<z.ZodString>;
|
|
80
|
+
actionId: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$loose>;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
export type ChangeCsStatusEventPayload = z.infer<typeof changeCsStatusEventSchema>["payload"];
|
|
84
|
+
export type ChangeCsStatusRpaEvent = z.infer<typeof changeCsStatusEventSchema>;
|
|
85
|
+
export declare const userMessageEventSchema: z.ZodObject<{
|
|
86
|
+
shopId: z.ZodString;
|
|
87
|
+
agentConfigId: z.ZodString;
|
|
88
|
+
stage: z.ZodEnum<{
|
|
89
|
+
success: "success";
|
|
90
|
+
queued: "queued";
|
|
91
|
+
executing: "executing";
|
|
92
|
+
failed: "failed";
|
|
93
|
+
}>;
|
|
94
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
95
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
actionId: z.ZodOptional<z.ZodString>;
|
|
98
|
+
eventType: z.ZodLiteral<"user-message">;
|
|
99
|
+
payload: z.ZodObject<{
|
|
100
|
+
platform: z.ZodString;
|
|
101
|
+
userId: z.ZodString;
|
|
102
|
+
uid: z.ZodString;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
export type UserMessageEventPayload = z.infer<typeof userMessageEventSchema>["payload"];
|
|
106
|
+
export type UserMessageRpaEvent = z.infer<typeof userMessageEventSchema>;
|
|
107
|
+
export declare const rpaEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
108
|
+
shopId: z.ZodString;
|
|
109
|
+
agentConfigId: z.ZodString;
|
|
110
|
+
stage: z.ZodEnum<{
|
|
111
|
+
success: "success";
|
|
112
|
+
queued: "queued";
|
|
113
|
+
executing: "executing";
|
|
114
|
+
failed: "failed";
|
|
115
|
+
}>;
|
|
116
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
117
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
119
|
+
actionId: z.ZodOptional<z.ZodString>;
|
|
120
|
+
eventType: z.ZodLiteral<"reply-message">;
|
|
121
|
+
payload: z.ZodObject<{
|
|
122
|
+
mallId: z.ZodString;
|
|
123
|
+
shopId: z.ZodString;
|
|
124
|
+
userId: z.ZodString;
|
|
125
|
+
uid: z.ZodString;
|
|
126
|
+
messageId: z.ZodString;
|
|
127
|
+
content: z.ZodString;
|
|
128
|
+
aiAgentConfigId: z.ZodNumber;
|
|
129
|
+
host: z.ZodString;
|
|
130
|
+
platformCode: z.ZodString;
|
|
131
|
+
tbUid: z.ZodString;
|
|
132
|
+
msgId: z.ZodOptional<z.ZodString>;
|
|
133
|
+
procState: z.ZodOptional<z.ZodString>;
|
|
134
|
+
transferReason: z.ZodOptional<z.ZodString>;
|
|
135
|
+
messageType: z.ZodOptional<z.ZodLiteral<"specialSceneTransfer">>;
|
|
136
|
+
orderRemark: z.ZodOptional<z.ZodString>;
|
|
137
|
+
ignoreTransferred: z.ZodOptional<z.ZodBoolean>;
|
|
138
|
+
}, z.core.$loose>;
|
|
139
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
140
|
+
shopId: z.ZodString;
|
|
141
|
+
agentConfigId: z.ZodString;
|
|
142
|
+
stage: z.ZodEnum<{
|
|
143
|
+
success: "success";
|
|
144
|
+
queued: "queued";
|
|
145
|
+
executing: "executing";
|
|
146
|
+
failed: "failed";
|
|
147
|
+
}>;
|
|
148
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
149
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
actionId: z.ZodOptional<z.ZodString>;
|
|
152
|
+
eventType: z.ZodLiteral<"change-cs-status">;
|
|
153
|
+
payload: z.ZodObject<{
|
|
154
|
+
aiAgentConfigId: z.ZodNumber;
|
|
155
|
+
host: z.ZodString;
|
|
156
|
+
status: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
157
|
+
platformCode: z.ZodOptional<z.ZodString>;
|
|
158
|
+
actionId: z.ZodOptional<z.ZodString>;
|
|
159
|
+
}, z.core.$loose>;
|
|
160
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
161
|
+
shopId: z.ZodString;
|
|
162
|
+
agentConfigId: z.ZodString;
|
|
163
|
+
stage: z.ZodEnum<{
|
|
164
|
+
success: "success";
|
|
165
|
+
queued: "queued";
|
|
166
|
+
executing: "executing";
|
|
167
|
+
failed: "failed";
|
|
168
|
+
}>;
|
|
169
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
170
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
171
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
172
|
+
actionId: z.ZodOptional<z.ZodString>;
|
|
173
|
+
eventType: z.ZodLiteral<"user-message">;
|
|
174
|
+
payload: z.ZodObject<{
|
|
175
|
+
platform: z.ZodString;
|
|
176
|
+
userId: z.ZodString;
|
|
177
|
+
uid: z.ZodString;
|
|
178
|
+
}, z.core.$strip>;
|
|
179
|
+
}, z.core.$strip>], "eventType">;
|
|
180
|
+
export type RpaEvent = z.infer<typeof rpaEventSchema>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type RpaStage = "queued" | "executing" | "success" | "failed";
|
|
2
|
+
export type RpaActionEventType = "reply-message" | "change-cs-status";
|
|
3
|
+
export type AgentStatus = "online" | "suspended" | "offline";
|
|
4
|
+
export type SessionUpdateMessage = {
|
|
5
|
+
type: "upsert";
|
|
6
|
+
session: RpaSession;
|
|
7
|
+
shopId: string;
|
|
8
|
+
sequence: number;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
} | {
|
|
11
|
+
type: "remove";
|
|
12
|
+
sessionId: string;
|
|
13
|
+
shopId: string;
|
|
14
|
+
agentConfigId?: string;
|
|
15
|
+
sequence: number;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
};
|
|
18
|
+
export type ActionUpdateMessage = {
|
|
19
|
+
type: "action-upsert";
|
|
20
|
+
action: RpaAction;
|
|
21
|
+
shopId: string;
|
|
22
|
+
sequence: number;
|
|
23
|
+
timestamp: number;
|
|
24
|
+
};
|
|
25
|
+
export type StreamUpdateMessage = SessionUpdateMessage | ActionUpdateMessage;
|
|
26
|
+
export type RpaSession = {
|
|
27
|
+
sessionId: string;
|
|
28
|
+
shopId: string;
|
|
29
|
+
agentConfigId: string;
|
|
30
|
+
platform: string;
|
|
31
|
+
uid: string;
|
|
32
|
+
userId: string;
|
|
33
|
+
status: "active";
|
|
34
|
+
lastEventType: string;
|
|
35
|
+
lastStage: RpaStage;
|
|
36
|
+
lastEventSeq: number;
|
|
37
|
+
lastEventAt: number;
|
|
38
|
+
lastMessage?: string | null;
|
|
39
|
+
lastActionType?: RpaActionEventType;
|
|
40
|
+
lastActionStage?: RpaStage;
|
|
41
|
+
lastActionSeq?: number;
|
|
42
|
+
lastActionAt?: number;
|
|
43
|
+
lastActionMessage?: string | null;
|
|
44
|
+
lastActionId?: string | null;
|
|
45
|
+
};
|
|
46
|
+
export type RpaAction = {
|
|
47
|
+
actionKey: string;
|
|
48
|
+
actionId?: string | null;
|
|
49
|
+
eventType: RpaActionEventType;
|
|
50
|
+
stage: RpaStage;
|
|
51
|
+
message?: string | null;
|
|
52
|
+
timestamp: number;
|
|
53
|
+
sequence: number;
|
|
54
|
+
shopId: string;
|
|
55
|
+
agentConfigId: string;
|
|
56
|
+
uid?: string;
|
|
57
|
+
};
|
|
58
|
+
export type SessionIdentity = {
|
|
59
|
+
platform: string;
|
|
60
|
+
uid: string;
|
|
61
|
+
userId: string;
|
|
62
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const timeGrainSchema: z.ZodEnum<{
|
|
3
|
+
second: "second";
|
|
4
|
+
minute: "minute";
|
|
5
|
+
hour: "hour";
|
|
6
|
+
day: "day";
|
|
7
|
+
week: "week";
|
|
8
|
+
month: "month";
|
|
9
|
+
quarter: "quarter";
|
|
10
|
+
year: "year";
|
|
11
|
+
}>;
|
|
12
|
+
export type TimeGrain = z.infer<typeof timeGrainSchema>;
|
package/package.json
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stellaris/metrics-shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "./index.
|
|
6
|
-
"types": "./index.ts",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"types": "./index.ts",
|
|
10
|
-
"import": "./index.
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
11
12
|
}
|
|
12
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "rm -rf dist && pnpm --dir .. exec tsup metrics-shared/index.ts --format esm --out-dir metrics-shared/dist --clean && pnpm --dir .. exec tsc -p metrics-shared/tsconfig.types.json && cp bff-service.d.ts dist/bff-service.d.ts",
|
|
19
|
+
"prepack": "pnpm --dir .. run db:generate && pnpm --dir .. run build:api-types && pnpm run build"
|
|
20
|
+
},
|
|
13
21
|
"dependencies": {
|
|
14
22
|
"@cubejs-client/core": "^1.6.4",
|
|
15
23
|
"hono": "^4.11.4",
|
package/index.ts
DELETED
package/publish.sh
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# @stellaris/metrics-shared npm 发布脚本
|
|
3
|
-
# 用法: ./metrics-shared/publish.sh [patch|minor|major]
|
|
4
|
-
# 必须在 bff-service 根目录运行!
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
# 颜色输出
|
|
9
|
-
RED='\033[0;31m'
|
|
10
|
-
GREEN='\033[0;32m'
|
|
11
|
-
YELLOW='\033[1;33m'
|
|
12
|
-
NC='\033[0m'
|
|
13
|
-
|
|
14
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
15
|
-
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
16
|
-
cd "$ROOT_DIR"
|
|
17
|
-
|
|
18
|
-
echo -e "${GREEN}📦 @stellaris/metrics-shared 发布脚本${NC}"
|
|
19
|
-
echo ""
|
|
20
|
-
|
|
21
|
-
# 检查是否已登录 npm
|
|
22
|
-
echo -e "${YELLOW}检查 npm 登录状态...${NC}"
|
|
23
|
-
if ! npm whoami > /dev/null 2>&1; then
|
|
24
|
-
echo -e "${RED}❌ 未登录 npm,请先运行 'npm login'${NC}"
|
|
25
|
-
exit 1
|
|
26
|
-
fi
|
|
27
|
-
echo -e "${GREEN}✓ 已登录为: $(npm whoami)${NC}"
|
|
28
|
-
|
|
29
|
-
# 获取版本类型
|
|
30
|
-
VERSION_TYPE=${1:-patch}
|
|
31
|
-
if [[ ! "$VERSION_TYPE" =~ ^(patch|minor|major)$ ]]; then
|
|
32
|
-
echo -e "${RED}❌ 无效的版本类型: $VERSION_TYPE${NC}"
|
|
33
|
-
echo "用法: ./metrics-shared/publish.sh [patch|minor|major]"
|
|
34
|
-
exit 1
|
|
35
|
-
fi
|
|
36
|
-
|
|
37
|
-
# Step 1: 生成类型定义
|
|
38
|
-
echo ""
|
|
39
|
-
echo -e "${YELLOW}[1/4] 生成 Prisma 客户端...${NC}"
|
|
40
|
-
pnpm run db:generate
|
|
41
|
-
|
|
42
|
-
echo ""
|
|
43
|
-
echo -e "${YELLOW}[2/4] 生成 API 类型定义 (dts-bundle-generator)...${NC}"
|
|
44
|
-
npx dts-bundle-generator -o metrics-shared/bff-service.d.ts src/index.ts --no-check
|
|
45
|
-
echo -e "${GREEN}✓ 类型已生成到 metrics-shared/bff-service.d.ts${NC}"
|
|
46
|
-
|
|
47
|
-
# Step 2: 进入包目录
|
|
48
|
-
cd "$SCRIPT_DIR"
|
|
49
|
-
|
|
50
|
-
# 显示当前版本
|
|
51
|
-
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
|
52
|
-
echo ""
|
|
53
|
-
echo -e "当前版本: ${YELLOW}$CURRENT_VERSION${NC}"
|
|
54
|
-
|
|
55
|
-
# Step 3: 更新版本号
|
|
56
|
-
echo -e "${YELLOW}[3/4] 更新版本号 ($VERSION_TYPE)...${NC}"
|
|
57
|
-
NEW_VERSION=$(npm version $VERSION_TYPE --no-git-tag-version)
|
|
58
|
-
echo -e "新版本: ${GREEN}$NEW_VERSION${NC}"
|
|
59
|
-
|
|
60
|
-
# Step 4: 发布到 npm
|
|
61
|
-
echo ""
|
|
62
|
-
echo -e "${YELLOW}[4/4] 发布到 npm...${NC}"
|
|
63
|
-
npm publish --access public
|
|
64
|
-
|
|
65
|
-
echo ""
|
|
66
|
-
echo -e "${GREEN}✅ 发布成功!${NC}"
|
|
67
|
-
echo -e "包名: @stellaris/metrics-shared"
|
|
68
|
-
echo -e "版本: $NEW_VERSION"
|
|
69
|
-
echo ""
|
|
70
|
-
echo -e "${YELLOW}提示: 在 myqa-web 中运行以下命令更新依赖:${NC}"
|
|
71
|
-
echo -e " pnpm update @stellaris/metrics-shared"
|
package/schemas/filter.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import z from "zod";
|
|
2
|
-
|
|
3
|
-
const binaryOperatorSchema = z.enum([
|
|
4
|
-
"equals",
|
|
5
|
-
"notEquals",
|
|
6
|
-
"contains",
|
|
7
|
-
"notContains",
|
|
8
|
-
"startsWith",
|
|
9
|
-
"notStartsWith",
|
|
10
|
-
"endsWith",
|
|
11
|
-
"notEndsWith",
|
|
12
|
-
"gt",
|
|
13
|
-
"gte",
|
|
14
|
-
"lt",
|
|
15
|
-
"lte",
|
|
16
|
-
"inDateRange",
|
|
17
|
-
"notInDateRange",
|
|
18
|
-
"beforeDate",
|
|
19
|
-
"beforeOrOnDate",
|
|
20
|
-
"afterDate",
|
|
21
|
-
"afterOrOnDate",
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
const unaryOperatorSchema = z.enum(["set", "notSet"]);
|
|
25
|
-
|
|
26
|
-
const baseFilterShape = {
|
|
27
|
-
id: z.string(),
|
|
28
|
-
member: z.string().optional(),
|
|
29
|
-
dimension: z.string().optional(),
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const binaryFilterSchema = z.object({
|
|
33
|
-
...baseFilterShape,
|
|
34
|
-
operator: binaryOperatorSchema,
|
|
35
|
-
values: z.array(z.string()),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const unaryFilterSchema = z.object({
|
|
39
|
-
...baseFilterShape,
|
|
40
|
-
operator: unaryOperatorSchema,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export type Filter =
|
|
44
|
-
| {
|
|
45
|
-
id: string;
|
|
46
|
-
member?: string;
|
|
47
|
-
dimension?: string;
|
|
48
|
-
operator: z.infer<typeof binaryOperatorSchema>;
|
|
49
|
-
values: string[];
|
|
50
|
-
}
|
|
51
|
-
| {
|
|
52
|
-
id: string;
|
|
53
|
-
member?: string;
|
|
54
|
-
dimension?: string;
|
|
55
|
-
operator: z.infer<typeof unaryOperatorSchema>;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const filterSchema: z.ZodType<Filter> = z.lazy(() =>
|
|
59
|
-
z.union([binaryFilterSchema, unaryFilterSchema]),
|
|
60
|
-
);
|
package/schemas/metric.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { filterSchema } from "./filter";
|
|
3
|
-
import { timeGrainSchema } from "./time";
|
|
4
|
-
|
|
5
|
-
export const metricQueryConfigSchema = z.object({
|
|
6
|
-
table: z.string(),
|
|
7
|
-
value: z.string(),
|
|
8
|
-
timeDimension: z.string(),
|
|
9
|
-
dimensions: z.array(z.string()),
|
|
10
|
-
filters: z.array(filterSchema),
|
|
11
|
-
timeGrain: z.array(timeGrainSchema),
|
|
12
|
-
format: z.enum(["number", "currency", "percent"]),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export type MetricQueryConfig = z.infer<typeof metricQueryConfigSchema>;
|
package/schemas/rpa-event.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import z from "zod";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 消息场景类型
|
|
5
|
-
*/
|
|
6
|
-
export const messageSceneTypeSchema = z.literal("specialSceneTransfer");
|
|
7
|
-
export type MessageSceneType = z.infer<typeof messageSceneTypeSchema>;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 客服状态枚举
|
|
11
|
-
*/
|
|
12
|
-
export const csStatusSchema = z.union([
|
|
13
|
-
z.literal(1),
|
|
14
|
-
z.literal(2),
|
|
15
|
-
z.literal(3),
|
|
16
|
-
]);
|
|
17
|
-
export type CsStatus = z.infer<typeof csStatusSchema>;
|
|
18
|
-
|
|
19
|
-
// RPA 事件基础字段
|
|
20
|
-
export const rpaEventBaseSchema = z.object({
|
|
21
|
-
shopId: z.string(),
|
|
22
|
-
agentConfigId: z.string(),
|
|
23
|
-
stage: z.enum(["queued", "executing", "success", "failed"]),
|
|
24
|
-
message: z.string().nullable().optional(),
|
|
25
|
-
timestamp: z.number().optional(),
|
|
26
|
-
sequence: z.number().int().optional(),
|
|
27
|
-
actionId: z.string().optional(),
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// 回复消息事件
|
|
31
|
-
export const replyMessageEventSchema = rpaEventBaseSchema.extend({
|
|
32
|
-
eventType: z.literal("reply-message"),
|
|
33
|
-
payload: z.looseObject({
|
|
34
|
-
mallId: z.string(),
|
|
35
|
-
shopId: z.string(),
|
|
36
|
-
userId: z.string(),
|
|
37
|
-
uid: z.string(),
|
|
38
|
-
messageId: z.string(),
|
|
39
|
-
content: z.string(),
|
|
40
|
-
aiAgentConfigId: z.number(),
|
|
41
|
-
host: z.string(),
|
|
42
|
-
platformCode: z.string(),
|
|
43
|
-
tbUid: z.string(),
|
|
44
|
-
msgId: z.string().optional(),
|
|
45
|
-
procState: z.string().optional(),
|
|
46
|
-
transferReason: z.string().optional(),
|
|
47
|
-
messageType: messageSceneTypeSchema.optional(),
|
|
48
|
-
orderRemark: z.string().optional(),
|
|
49
|
-
ignoreTransferred: z.boolean().optional(),
|
|
50
|
-
}),
|
|
51
|
-
});
|
|
52
|
-
export type ReplyMessageEventPayload = z.infer<
|
|
53
|
-
typeof replyMessageEventSchema
|
|
54
|
-
>["payload"];
|
|
55
|
-
export type ReplyMessageRpaEvent = z.infer<typeof replyMessageEventSchema>;
|
|
56
|
-
|
|
57
|
-
// 变更客服状态事件
|
|
58
|
-
export const changeCsStatusEventSchema = rpaEventBaseSchema.extend({
|
|
59
|
-
eventType: z.literal("change-cs-status"),
|
|
60
|
-
payload: z.looseObject({
|
|
61
|
-
aiAgentConfigId: z.number(),
|
|
62
|
-
host: z.string(),
|
|
63
|
-
status: csStatusSchema,
|
|
64
|
-
platformCode: z.string().optional(),
|
|
65
|
-
taskId: z.string().optional(),
|
|
66
|
-
}),
|
|
67
|
-
});
|
|
68
|
-
export type ChangeCsStatusEventPayload = z.infer<
|
|
69
|
-
typeof changeCsStatusEventSchema
|
|
70
|
-
>["payload"];
|
|
71
|
-
export type ChangeCsStatusRpaEvent = z.infer<typeof changeCsStatusEventSchema>;
|
|
72
|
-
|
|
73
|
-
// 用户消息事件
|
|
74
|
-
export const userMessageEventSchema = rpaEventBaseSchema.extend({
|
|
75
|
-
eventType: z.literal("user-message"),
|
|
76
|
-
payload: z.object({
|
|
77
|
-
platform: z.string(),
|
|
78
|
-
userId: z.string(),
|
|
79
|
-
uid: z.string(),
|
|
80
|
-
}),
|
|
81
|
-
});
|
|
82
|
-
export type UserMessageEventPayload = z.infer<
|
|
83
|
-
typeof userMessageEventSchema
|
|
84
|
-
>["payload"];
|
|
85
|
-
export type UserMessageRpaEvent = z.infer<typeof userMessageEventSchema>;
|
|
86
|
-
|
|
87
|
-
// RPA 事件 Schema (Discriminated Union)
|
|
88
|
-
export const rpaEventSchema = z.discriminatedUnion("eventType", [
|
|
89
|
-
replyMessageEventSchema,
|
|
90
|
-
changeCsStatusEventSchema,
|
|
91
|
-
userMessageEventSchema,
|
|
92
|
-
]);
|
|
93
|
-
|
|
94
|
-
export type RpaEvent = z.infer<typeof rpaEventSchema>;
|
package/schemas/rpa-session.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export type RpaStage = "queued" | "executing" | "success" | "failed";
|
|
2
|
-
|
|
3
|
-
export type RpaActionEventType = "reply-message" | "change-cs-status";
|
|
4
|
-
|
|
5
|
-
export type AgentStatus = "online" | "suspended" | "offline";
|
|
6
|
-
|
|
7
|
-
export type SessionUpdateMessage =
|
|
8
|
-
| {
|
|
9
|
-
type: "upsert";
|
|
10
|
-
session: RpaSession;
|
|
11
|
-
shopId: string;
|
|
12
|
-
sequence: number;
|
|
13
|
-
timestamp: number;
|
|
14
|
-
}
|
|
15
|
-
| {
|
|
16
|
-
type: "remove";
|
|
17
|
-
sessionId: string;
|
|
18
|
-
shopId: string;
|
|
19
|
-
agentConfigId?: string;
|
|
20
|
-
sequence: number;
|
|
21
|
-
timestamp: number;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type ActionUpdateMessage = {
|
|
25
|
-
type: "action-upsert";
|
|
26
|
-
action: RpaAction;
|
|
27
|
-
shopId: string;
|
|
28
|
-
sequence: number;
|
|
29
|
-
timestamp: number;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type StreamUpdateMessage = SessionUpdateMessage | ActionUpdateMessage;
|
|
33
|
-
|
|
34
|
-
export type RpaSession = {
|
|
35
|
-
sessionId: string;
|
|
36
|
-
shopId: string;
|
|
37
|
-
agentConfigId: string;
|
|
38
|
-
platform: string;
|
|
39
|
-
uid: string;
|
|
40
|
-
userId: string;
|
|
41
|
-
status: "active";
|
|
42
|
-
lastEventType: string;
|
|
43
|
-
lastStage: RpaStage;
|
|
44
|
-
lastEventSeq: number;
|
|
45
|
-
lastEventAt: number;
|
|
46
|
-
lastMessage?: string | null;
|
|
47
|
-
lastActionType?: RpaActionEventType;
|
|
48
|
-
lastActionStage?: RpaStage;
|
|
49
|
-
lastActionSeq?: number;
|
|
50
|
-
lastActionAt?: number;
|
|
51
|
-
lastActionMessage?: string | null;
|
|
52
|
-
lastActionId?: string | null;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export type RpaAction = {
|
|
56
|
-
actionKey: string;
|
|
57
|
-
actionId?: string | null;
|
|
58
|
-
eventType: RpaActionEventType;
|
|
59
|
-
stage: RpaStage;
|
|
60
|
-
message?: string | null;
|
|
61
|
-
timestamp: number;
|
|
62
|
-
sequence: number;
|
|
63
|
-
shopId: string;
|
|
64
|
-
agentConfigId: string;
|
|
65
|
-
uid?: string;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export type SessionIdentity = {
|
|
69
|
-
platform: string;
|
|
70
|
-
uid: string;
|
|
71
|
-
userId: string;
|
|
72
|
-
};
|
package/schemas/time.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TimeDimensionPredefinedGranularity } from "@cubejs-client/core";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
const predefinedGrins: [
|
|
5
|
-
TimeDimensionPredefinedGranularity,
|
|
6
|
-
...TimeDimensionPredefinedGranularity[],
|
|
7
|
-
] = ["minute", "hour", "day", "week", "month", "quarter", "year"] as const;
|
|
8
|
-
|
|
9
|
-
export const timeGrainSchema = z.enum(predefinedGrins);
|
|
10
|
-
|
|
11
|
-
export type TimeGrain = z.infer<typeof timeGrainSchema>;
|
|
File without changes
|