convex-vapi 0.0.1
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/LICENSE +201 -0
- package/README.md +437 -0
- package/dist/client/_generated/_ignore.d.ts +1 -0
- package/dist/client/_generated/_ignore.d.ts.map +1 -0
- package/dist/client/_generated/_ignore.js +3 -0
- package/dist/client/_generated/_ignore.js.map +1 -0
- package/dist/client/index.d.ts +115 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +172 -0
- package/dist/client/index.js.map +1 -0
- package/dist/component/_generated/api.d.ts +34 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +125 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +133 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +80 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +4 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/lib.d.ts +101 -0
- package/dist/component/lib.d.ts.map +1 -0
- package/dist/component/lib.js +177 -0
- package/dist/component/lib.js.map +1 -0
- package/dist/component/schema.d.ts +53 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +30 -0
- package/dist/component/schema.js.map +1 -0
- package/package.json +105 -0
- package/src/client/_generated/_ignore.ts +1 -0
- package/src/client/index.ts +250 -0
- package/src/client/setup.test.ts +26 -0
- package/src/component/_generated/api.ts +50 -0
- package/src/component/_generated/component.ts +159 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +169 -0
- package/src/component/convex.config.ts +5 -0
- package/src/component/lib.test.ts +167 -0
- package/src/component/lib.ts +193 -0
- package/src/component/schema.ts +31 -0
- package/src/component/setup.test.ts +11 -0
- package/src/test.ts +18 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
3
|
+
*
|
|
4
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
5
|
+
*
|
|
6
|
+
* To regenerate, run `npx convex dev`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { ActionBuilder, HttpActionBuilder, MutationBuilder, QueryBuilder, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter } from "convex/server";
|
|
10
|
+
import type { DataModel } from "./dataModel.js";
|
|
11
|
+
/**
|
|
12
|
+
* Typesafe environment variables.
|
|
13
|
+
*
|
|
14
|
+
* This includes platform-provided env vars and any variables declared in
|
|
15
|
+
* `convex.config.ts`.
|
|
16
|
+
*/
|
|
17
|
+
type Env = {
|
|
18
|
+
readonly CONVEX_CLOUD_URL: string;
|
|
19
|
+
readonly CONVEX_SITE_URL: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Define a query in this Convex app's public API.
|
|
23
|
+
*
|
|
24
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
25
|
+
*
|
|
26
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
27
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
28
|
+
*/
|
|
29
|
+
export declare const query: QueryBuilder<DataModel, "public">;
|
|
30
|
+
/**
|
|
31
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
32
|
+
*
|
|
33
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
34
|
+
*
|
|
35
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
36
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
37
|
+
*/
|
|
38
|
+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
|
39
|
+
/**
|
|
40
|
+
* Define a mutation in this Convex app's public API.
|
|
41
|
+
*
|
|
42
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
43
|
+
*
|
|
44
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
45
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
46
|
+
*/
|
|
47
|
+
export declare const mutation: MutationBuilder<DataModel, "public">;
|
|
48
|
+
/**
|
|
49
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
50
|
+
*
|
|
51
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
52
|
+
*
|
|
53
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
54
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
55
|
+
*/
|
|
56
|
+
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
|
57
|
+
/**
|
|
58
|
+
* Define an action in this Convex app's public API.
|
|
59
|
+
*
|
|
60
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
61
|
+
* code and code with side-effects, like calling third-party services.
|
|
62
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
63
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
64
|
+
*
|
|
65
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
66
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
67
|
+
*/
|
|
68
|
+
export declare const action: ActionBuilder<DataModel, "public">;
|
|
69
|
+
/**
|
|
70
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
71
|
+
*
|
|
72
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
73
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
74
|
+
*/
|
|
75
|
+
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
|
76
|
+
/**
|
|
77
|
+
* Define an HTTP action.
|
|
78
|
+
*
|
|
79
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
80
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
81
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
82
|
+
*
|
|
83
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
84
|
+
* and a Fetch API `Request` object as its second.
|
|
85
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
86
|
+
*/
|
|
87
|
+
export declare const httpAction: HttpActionBuilder;
|
|
88
|
+
export declare const env: Env;
|
|
89
|
+
/**
|
|
90
|
+
* A set of services for use within Convex query functions.
|
|
91
|
+
*
|
|
92
|
+
* The query context is passed as the first argument to any Convex query
|
|
93
|
+
* function run on the server.
|
|
94
|
+
*
|
|
95
|
+
* If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
|
|
96
|
+
*/
|
|
97
|
+
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
98
|
+
/**
|
|
99
|
+
* A set of services for use within Convex mutation functions.
|
|
100
|
+
*
|
|
101
|
+
* The mutation context is passed as the first argument to any Convex mutation
|
|
102
|
+
* function run on the server.
|
|
103
|
+
*
|
|
104
|
+
* If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
|
|
105
|
+
*/
|
|
106
|
+
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
107
|
+
/**
|
|
108
|
+
* A set of services for use within Convex action functions.
|
|
109
|
+
*
|
|
110
|
+
* The action context is passed as the first argument to any Convex action
|
|
111
|
+
* function run on the server.
|
|
112
|
+
*/
|
|
113
|
+
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
114
|
+
/**
|
|
115
|
+
* An interface to read from the database within Convex query functions.
|
|
116
|
+
*
|
|
117
|
+
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
|
118
|
+
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
|
119
|
+
* building a query.
|
|
120
|
+
*/
|
|
121
|
+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
122
|
+
/**
|
|
123
|
+
* An interface to read from and write to the database within Convex mutation
|
|
124
|
+
* functions.
|
|
125
|
+
*
|
|
126
|
+
* Convex guarantees that all writes within a single mutation are
|
|
127
|
+
* executed atomically, so you never have to worry about partial writes leaving
|
|
128
|
+
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
|
129
|
+
* for the guarantees Convex provides your functions.
|
|
130
|
+
*/
|
|
131
|
+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
|
132
|
+
export {};
|
|
133
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,eAAe,CAAC;AAUvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;GAKG;AACH,KAAK,GAAG,GAAG;IACT,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAgB,CAAC;AAErE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,SAAS,EAAE,UAAU,CACxC,CAAC;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAmB,CAAC;AAE9E;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,SAAS,EAAE,UAAU,CAC3C,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,EAAE,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAiB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC,SAAS,EAAE,UAAU,CACzC,CAAC;AAExB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,iBAAqC,CAAC;AAC/D,eAAO,MAAM,GAAG,EAAE,GACJ,CAAC;AAEf;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAExD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { actionGeneric, httpActionGeneric, queryGeneric, mutationGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, } from "convex/server";
|
|
11
|
+
/**
|
|
12
|
+
* Define a query in this Convex app's public API.
|
|
13
|
+
*
|
|
14
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
15
|
+
*
|
|
16
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
17
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
18
|
+
*/
|
|
19
|
+
export const query = queryGeneric;
|
|
20
|
+
/**
|
|
21
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
22
|
+
*
|
|
23
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
24
|
+
*
|
|
25
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
26
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
27
|
+
*/
|
|
28
|
+
export const internalQuery = internalQueryGeneric;
|
|
29
|
+
/**
|
|
30
|
+
* Define a mutation in this Convex app's public API.
|
|
31
|
+
*
|
|
32
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
33
|
+
*
|
|
34
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
35
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
36
|
+
*/
|
|
37
|
+
export const mutation = mutationGeneric;
|
|
38
|
+
/**
|
|
39
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
40
|
+
*
|
|
41
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
42
|
+
*
|
|
43
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
44
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
45
|
+
*/
|
|
46
|
+
export const internalMutation = internalMutationGeneric;
|
|
47
|
+
/**
|
|
48
|
+
* Define an action in this Convex app's public API.
|
|
49
|
+
*
|
|
50
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
51
|
+
* code and code with side-effects, like calling third-party services.
|
|
52
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
53
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
54
|
+
*
|
|
55
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
56
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
57
|
+
*/
|
|
58
|
+
export const action = actionGeneric;
|
|
59
|
+
/**
|
|
60
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
61
|
+
*
|
|
62
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
63
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
64
|
+
*/
|
|
65
|
+
export const internalAction = internalActionGeneric;
|
|
66
|
+
/**
|
|
67
|
+
* Define an HTTP action.
|
|
68
|
+
*
|
|
69
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
70
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
71
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
72
|
+
*
|
|
73
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
74
|
+
* and a Fetch API `Request` object as its second.
|
|
75
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
76
|
+
*/
|
|
77
|
+
export const httpAction = httpActionGeneric;
|
|
78
|
+
export const env = globalThis
|
|
79
|
+
.process.env;
|
|
80
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAaH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAcvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAsC,YAAY,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,oBAAoB,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAyC,eAAe,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAC3B,uBAAuB,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,MAAM,GAAuC,aAAa,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GACzB,qBAAqB,CAAC;AAExB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsB,iBAAiB,CAAC;AAC/D,MAAM,CAAC,MAAM,GAAG,GAAS,UAAmD;KACzE,OAAO,CAAC,GAAG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,SAAS,sDAAgC,CAAC;AAEhD,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.js","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,SAAS,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;AAEhD,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export declare const getCall: import("convex/server").RegisteredQuery<"public", {
|
|
2
|
+
callId: string;
|
|
3
|
+
}, Promise<{
|
|
4
|
+
_id: import("convex/values").GenericId<"calls">;
|
|
5
|
+
_creationTime: number;
|
|
6
|
+
assistantId?: string | undefined;
|
|
7
|
+
cost?: number | undefined;
|
|
8
|
+
customerNumber?: string | undefined;
|
|
9
|
+
endedAt?: number | undefined;
|
|
10
|
+
endedReason?: string | undefined;
|
|
11
|
+
phoneNumberId?: string | undefined;
|
|
12
|
+
recordingUrl?: string | undefined;
|
|
13
|
+
startedAt?: number | undefined;
|
|
14
|
+
summary?: string | undefined;
|
|
15
|
+
transcript?: string | undefined;
|
|
16
|
+
callId: string;
|
|
17
|
+
status: string;
|
|
18
|
+
createdAt: number;
|
|
19
|
+
updatedAt: number;
|
|
20
|
+
} | null>>;
|
|
21
|
+
export declare const listCallsByAssistant: import("convex/server").RegisteredQuery<"public", {
|
|
22
|
+
limit?: number | undefined;
|
|
23
|
+
assistantId: string;
|
|
24
|
+
}, Promise<{
|
|
25
|
+
_id: import("convex/values").GenericId<"calls">;
|
|
26
|
+
_creationTime: number;
|
|
27
|
+
assistantId?: string | undefined;
|
|
28
|
+
cost?: number | undefined;
|
|
29
|
+
customerNumber?: string | undefined;
|
|
30
|
+
endedAt?: number | undefined;
|
|
31
|
+
endedReason?: string | undefined;
|
|
32
|
+
phoneNumberId?: string | undefined;
|
|
33
|
+
recordingUrl?: string | undefined;
|
|
34
|
+
startedAt?: number | undefined;
|
|
35
|
+
summary?: string | undefined;
|
|
36
|
+
transcript?: string | undefined;
|
|
37
|
+
callId: string;
|
|
38
|
+
status: string;
|
|
39
|
+
createdAt: number;
|
|
40
|
+
updatedAt: number;
|
|
41
|
+
}[]>>;
|
|
42
|
+
export declare const recordCall: import("convex/server").RegisteredMutation<"public", {
|
|
43
|
+
assistantId?: string | undefined;
|
|
44
|
+
cost?: number | undefined;
|
|
45
|
+
customerNumber?: string | undefined;
|
|
46
|
+
endedAt?: number | undefined;
|
|
47
|
+
endedReason?: string | undefined;
|
|
48
|
+
phoneNumberId?: string | undefined;
|
|
49
|
+
recordingUrl?: string | undefined;
|
|
50
|
+
startedAt?: number | undefined;
|
|
51
|
+
summary?: string | undefined;
|
|
52
|
+
transcript?: string | undefined;
|
|
53
|
+
callId: string;
|
|
54
|
+
status: string;
|
|
55
|
+
}, Promise<import("convex/values").GenericId<"calls">>>;
|
|
56
|
+
export declare const checkAndRecordEvent: import("convex/server").RegisteredMutation<"public", {
|
|
57
|
+
callId?: string | undefined;
|
|
58
|
+
eventId: string;
|
|
59
|
+
eventType: string;
|
|
60
|
+
payload: string;
|
|
61
|
+
}, Promise<{
|
|
62
|
+
alreadyProcessed: boolean;
|
|
63
|
+
}>>;
|
|
64
|
+
export declare const getStats: import("convex/server").RegisteredQuery<"public", {}, Promise<{
|
|
65
|
+
callCount: number;
|
|
66
|
+
endedCount: number;
|
|
67
|
+
liveCount: number;
|
|
68
|
+
webhookEventCount: number;
|
|
69
|
+
}>>;
|
|
70
|
+
export declare const listRecentCalls: import("convex/server").RegisteredQuery<"public", {
|
|
71
|
+
limit?: number | undefined;
|
|
72
|
+
}, Promise<{
|
|
73
|
+
_id: import("convex/values").GenericId<"calls">;
|
|
74
|
+
_creationTime: number;
|
|
75
|
+
assistantId?: string | undefined;
|
|
76
|
+
cost?: number | undefined;
|
|
77
|
+
customerNumber?: string | undefined;
|
|
78
|
+
endedAt?: number | undefined;
|
|
79
|
+
endedReason?: string | undefined;
|
|
80
|
+
phoneNumberId?: string | undefined;
|
|
81
|
+
recordingUrl?: string | undefined;
|
|
82
|
+
startedAt?: number | undefined;
|
|
83
|
+
summary?: string | undefined;
|
|
84
|
+
transcript?: string | undefined;
|
|
85
|
+
callId: string;
|
|
86
|
+
status: string;
|
|
87
|
+
createdAt: number;
|
|
88
|
+
updatedAt: number;
|
|
89
|
+
}[]>>;
|
|
90
|
+
export declare const listRecentWebhookEvents: import("convex/server").RegisteredQuery<"public", {
|
|
91
|
+
limit?: number | undefined;
|
|
92
|
+
}, Promise<{
|
|
93
|
+
_id: import("convex/values").GenericId<"webhookEvents">;
|
|
94
|
+
_creationTime: number;
|
|
95
|
+
callId?: string | undefined;
|
|
96
|
+
eventId: string;
|
|
97
|
+
eventType: string;
|
|
98
|
+
payload: string;
|
|
99
|
+
receivedAt: number;
|
|
100
|
+
}[]>>;
|
|
101
|
+
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/component/lib.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;UASlB,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;KAU/B,CAAC;AAIH,eAAO,MAAM,UAAU;;;;;;;;;;;;;uDA6DrB,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;GAmB9B,CAAC;AAOH,eAAO,MAAM,QAAQ;;;;;GAsBnB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;KAS1B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;KAmBlC,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { mutation, query } from "./_generated/server.js";
|
|
3
|
+
const callValidator = v.object({
|
|
4
|
+
_id: v.id("calls"),
|
|
5
|
+
_creationTime: v.number(),
|
|
6
|
+
callId: v.string(),
|
|
7
|
+
assistantId: v.optional(v.string()),
|
|
8
|
+
phoneNumberId: v.optional(v.string()),
|
|
9
|
+
customerNumber: v.optional(v.string()),
|
|
10
|
+
status: v.string(),
|
|
11
|
+
endedReason: v.optional(v.string()),
|
|
12
|
+
transcript: v.optional(v.string()),
|
|
13
|
+
summary: v.optional(v.string()),
|
|
14
|
+
recordingUrl: v.optional(v.string()),
|
|
15
|
+
cost: v.optional(v.number()),
|
|
16
|
+
startedAt: v.optional(v.number()),
|
|
17
|
+
endedAt: v.optional(v.number()),
|
|
18
|
+
createdAt: v.number(),
|
|
19
|
+
updatedAt: v.number(),
|
|
20
|
+
});
|
|
21
|
+
// ─── Queries ────────────────────────────────────────────────────────────────
|
|
22
|
+
export const getCall = query({
|
|
23
|
+
args: { callId: v.string() },
|
|
24
|
+
returns: v.union(v.null(), callValidator),
|
|
25
|
+
handler: async (ctx, args) => {
|
|
26
|
+
return await ctx.db
|
|
27
|
+
.query("calls")
|
|
28
|
+
.withIndex("by_callId", (q) => q.eq("callId", args.callId))
|
|
29
|
+
.first();
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
export const listCallsByAssistant = query({
|
|
33
|
+
args: { assistantId: v.string(), limit: v.optional(v.number()) },
|
|
34
|
+
returns: v.array(callValidator),
|
|
35
|
+
handler: async (ctx, args) => {
|
|
36
|
+
return await ctx.db
|
|
37
|
+
.query("calls")
|
|
38
|
+
.withIndex("by_assistantId", (q) => q.eq("assistantId", args.assistantId))
|
|
39
|
+
.order("desc")
|
|
40
|
+
.take(args.limit ?? 50);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
// ─── Mutations ──────────────────────────────────────────────────────────────
|
|
44
|
+
export const recordCall = mutation({
|
|
45
|
+
args: {
|
|
46
|
+
callId: v.string(),
|
|
47
|
+
assistantId: v.optional(v.string()),
|
|
48
|
+
phoneNumberId: v.optional(v.string()),
|
|
49
|
+
customerNumber: v.optional(v.string()),
|
|
50
|
+
status: v.string(),
|
|
51
|
+
endedReason: v.optional(v.string()),
|
|
52
|
+
transcript: v.optional(v.string()),
|
|
53
|
+
summary: v.optional(v.string()),
|
|
54
|
+
recordingUrl: v.optional(v.string()),
|
|
55
|
+
cost: v.optional(v.number()),
|
|
56
|
+
startedAt: v.optional(v.number()),
|
|
57
|
+
endedAt: v.optional(v.number()),
|
|
58
|
+
},
|
|
59
|
+
returns: v.id("calls"),
|
|
60
|
+
handler: async (ctx, args) => {
|
|
61
|
+
const now = Date.now();
|
|
62
|
+
const existing = await ctx.db
|
|
63
|
+
.query("calls")
|
|
64
|
+
.withIndex("by_callId", (q) => q.eq("callId", args.callId))
|
|
65
|
+
.first();
|
|
66
|
+
if (existing) {
|
|
67
|
+
// Merge rather than blanket-overwrite: a later, sparser event (e.g. a
|
|
68
|
+
// status-update with no transcript yet) must never erase fields an
|
|
69
|
+
// earlier, richer event (e.g. end-of-call-report) already recorded.
|
|
70
|
+
//
|
|
71
|
+
// status is a special case: Vapi's webhook deliveries carry no
|
|
72
|
+
// timestamp or sequence number, and delivery order is never
|
|
73
|
+
// guaranteed by any webhook provider, so a status-update that
|
|
74
|
+
// arrives late could otherwise regress a call backward (e.g. from
|
|
75
|
+
// "ended" back to "ringing"). "ended" is the one status Vapi never
|
|
76
|
+
// revises once sent, so once we've recorded it, later events are
|
|
77
|
+
// treated as stragglers and can't downgrade it back.
|
|
78
|
+
const status = existing.status === "ended" ? existing.status : args.status;
|
|
79
|
+
const merged = {
|
|
80
|
+
callId: args.callId,
|
|
81
|
+
assistantId: args.assistantId ?? existing.assistantId,
|
|
82
|
+
phoneNumberId: args.phoneNumberId ?? existing.phoneNumberId,
|
|
83
|
+
customerNumber: args.customerNumber ?? existing.customerNumber,
|
|
84
|
+
status,
|
|
85
|
+
endedReason: args.endedReason ?? existing.endedReason,
|
|
86
|
+
transcript: args.transcript ?? existing.transcript,
|
|
87
|
+
summary: args.summary ?? existing.summary,
|
|
88
|
+
recordingUrl: args.recordingUrl ?? existing.recordingUrl,
|
|
89
|
+
cost: args.cost ?? existing.cost,
|
|
90
|
+
startedAt: args.startedAt ?? existing.startedAt,
|
|
91
|
+
endedAt: args.endedAt ?? existing.endedAt,
|
|
92
|
+
};
|
|
93
|
+
await ctx.db.patch(existing._id, { ...merged, updatedAt: now });
|
|
94
|
+
return existing._id;
|
|
95
|
+
}
|
|
96
|
+
return await ctx.db.insert("calls", {
|
|
97
|
+
...args,
|
|
98
|
+
createdAt: now,
|
|
99
|
+
updatedAt: now,
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
export const checkAndRecordEvent = mutation({
|
|
104
|
+
args: {
|
|
105
|
+
eventId: v.string(),
|
|
106
|
+
eventType: v.string(),
|
|
107
|
+
callId: v.optional(v.string()),
|
|
108
|
+
payload: v.string(),
|
|
109
|
+
},
|
|
110
|
+
returns: v.object({ alreadyProcessed: v.boolean() }),
|
|
111
|
+
handler: async (ctx, args) => {
|
|
112
|
+
const existing = await ctx.db
|
|
113
|
+
.query("webhookEvents")
|
|
114
|
+
.withIndex("by_eventId", (q) => q.eq("eventId", args.eventId))
|
|
115
|
+
.first();
|
|
116
|
+
if (existing) {
|
|
117
|
+
return { alreadyProcessed: true };
|
|
118
|
+
}
|
|
119
|
+
await ctx.db.insert("webhookEvents", { ...args, receivedAt: Date.now() });
|
|
120
|
+
return { alreadyProcessed: false };
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
// ─── Dashboard queries ──────────────────────────────────────────────────────
|
|
124
|
+
// These do full, un-indexed scans across every call/event the component has
|
|
125
|
+
// ever recorded, on purpose — they power a demo's stats bar and activity
|
|
126
|
+
// history, not high-volume production use.
|
|
127
|
+
export const getStats = query({
|
|
128
|
+
args: {},
|
|
129
|
+
returns: v.object({
|
|
130
|
+
callCount: v.number(),
|
|
131
|
+
endedCount: v.number(),
|
|
132
|
+
liveCount: v.number(),
|
|
133
|
+
webhookEventCount: v.number(),
|
|
134
|
+
}),
|
|
135
|
+
handler: async (ctx) => {
|
|
136
|
+
const [calls, webhookEvents] = await Promise.all([
|
|
137
|
+
ctx.db.query("calls").collect(),
|
|
138
|
+
ctx.db.query("webhookEvents").collect(),
|
|
139
|
+
]);
|
|
140
|
+
const live = (status) => status === "queued" || status === "ringing" || status === "in-progress";
|
|
141
|
+
return {
|
|
142
|
+
callCount: calls.length,
|
|
143
|
+
endedCount: calls.filter((c) => c.status === "ended").length,
|
|
144
|
+
liveCount: calls.filter((c) => live(c.status)).length,
|
|
145
|
+
webhookEventCount: webhookEvents.length,
|
|
146
|
+
};
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
export const listRecentCalls = query({
|
|
150
|
+
args: { limit: v.optional(v.number()) },
|
|
151
|
+
returns: v.array(callValidator),
|
|
152
|
+
handler: async (ctx, args) => {
|
|
153
|
+
const calls = await ctx.db.query("calls").collect();
|
|
154
|
+
return calls
|
|
155
|
+
.sort((a, b) => b.updatedAt - a.updatedAt)
|
|
156
|
+
.slice(0, args.limit ?? 20);
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
export const listRecentWebhookEvents = query({
|
|
160
|
+
args: { limit: v.optional(v.number()) },
|
|
161
|
+
returns: v.array(v.object({
|
|
162
|
+
_id: v.id("webhookEvents"),
|
|
163
|
+
_creationTime: v.number(),
|
|
164
|
+
eventId: v.string(),
|
|
165
|
+
eventType: v.string(),
|
|
166
|
+
callId: v.optional(v.string()),
|
|
167
|
+
payload: v.string(),
|
|
168
|
+
receivedAt: v.number(),
|
|
169
|
+
})),
|
|
170
|
+
handler: async (ctx, args) => {
|
|
171
|
+
const events = await ctx.db.query("webhookEvents").collect();
|
|
172
|
+
return events
|
|
173
|
+
.sort((a, b) => b.receivedAt - a.receivedAt)
|
|
174
|
+
.slice(0, args.limit ?? 20);
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
//# sourceMappingURL=lib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/component/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC;IAClB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACnC,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC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,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE;IACvC,OAAO,EAAE,CAAC,CAAC,KAAK,CACd,CAAC,CAAC,MAAM,CAAC;QACP,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC;QAC1B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;QACzB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC9B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;KACvB,CAAC,CACH;IACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,OAAO,EAAE,CAAC;QAC7D,OAAO,MAAM;aACV,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;aAC3C,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAChC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
declare const _default: import("convex/server").SchemaDefinition<{
|
|
2
|
+
calls: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3
|
+
assistantId?: string | undefined;
|
|
4
|
+
cost?: number | undefined;
|
|
5
|
+
customerNumber?: string | undefined;
|
|
6
|
+
endedAt?: number | undefined;
|
|
7
|
+
endedReason?: string | undefined;
|
|
8
|
+
phoneNumberId?: string | undefined;
|
|
9
|
+
recordingUrl?: string | undefined;
|
|
10
|
+
startedAt?: number | undefined;
|
|
11
|
+
summary?: string | undefined;
|
|
12
|
+
transcript?: string | undefined;
|
|
13
|
+
callId: string;
|
|
14
|
+
status: string;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
updatedAt: number;
|
|
17
|
+
}, {
|
|
18
|
+
callId: import("convex/values").VString<string, "required">;
|
|
19
|
+
assistantId: import("convex/values").VString<string | undefined, "optional">;
|
|
20
|
+
phoneNumberId: import("convex/values").VString<string | undefined, "optional">;
|
|
21
|
+
customerNumber: import("convex/values").VString<string | undefined, "optional">;
|
|
22
|
+
status: import("convex/values").VString<string, "required">;
|
|
23
|
+
endedReason: import("convex/values").VString<string | undefined, "optional">;
|
|
24
|
+
transcript: import("convex/values").VString<string | undefined, "optional">;
|
|
25
|
+
summary: import("convex/values").VString<string | undefined, "optional">;
|
|
26
|
+
recordingUrl: import("convex/values").VString<string | undefined, "optional">;
|
|
27
|
+
cost: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
28
|
+
startedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
29
|
+
endedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
30
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
31
|
+
updatedAt: import("convex/values").VFloat64<number, "required">;
|
|
32
|
+
}, "required", "callId" | "assistantId" | "cost" | "customerNumber" | "endedAt" | "endedReason" | "phoneNumberId" | "recordingUrl" | "startedAt" | "status" | "summary" | "transcript" | "createdAt" | "updatedAt">, {
|
|
33
|
+
by_callId: ["callId", "_creationTime"];
|
|
34
|
+
by_assistantId: ["assistantId", "_creationTime"];
|
|
35
|
+
}, {}, {}>;
|
|
36
|
+
webhookEvents: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
37
|
+
callId?: string | undefined;
|
|
38
|
+
eventId: string;
|
|
39
|
+
eventType: string;
|
|
40
|
+
payload: string;
|
|
41
|
+
receivedAt: number;
|
|
42
|
+
}, {
|
|
43
|
+
eventId: import("convex/values").VString<string, "required">;
|
|
44
|
+
eventType: import("convex/values").VString<string, "required">;
|
|
45
|
+
callId: import("convex/values").VString<string | undefined, "optional">;
|
|
46
|
+
payload: import("convex/values").VString<string, "required">;
|
|
47
|
+
receivedAt: import("convex/values").VFloat64<number, "required">;
|
|
48
|
+
}, "required", "callId" | "eventId" | "eventType" | "payload" | "receivedAt">, {
|
|
49
|
+
by_eventId: ["eventId", "_creationTime"];
|
|
50
|
+
}, {}, {}>;
|
|
51
|
+
}, true>;
|
|
52
|
+
export default _default;
|
|
53
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wBA2BG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineSchema, defineTable } from "convex/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
export default defineSchema({
|
|
4
|
+
calls: defineTable({
|
|
5
|
+
callId: v.string(), // Vapi's call id
|
|
6
|
+
assistantId: v.optional(v.string()),
|
|
7
|
+
phoneNumberId: v.optional(v.string()),
|
|
8
|
+
customerNumber: v.optional(v.string()),
|
|
9
|
+
status: v.string(), // "queued" | "ringing" | "in-progress" | "forwarding" | "ended" | ...
|
|
10
|
+
endedReason: v.optional(v.string()),
|
|
11
|
+
transcript: v.optional(v.string()),
|
|
12
|
+
summary: v.optional(v.string()),
|
|
13
|
+
recordingUrl: v.optional(v.string()),
|
|
14
|
+
cost: v.optional(v.number()),
|
|
15
|
+
startedAt: v.optional(v.number()),
|
|
16
|
+
endedAt: v.optional(v.number()),
|
|
17
|
+
createdAt: v.number(),
|
|
18
|
+
updatedAt: v.number(),
|
|
19
|
+
})
|
|
20
|
+
.index("by_callId", ["callId"])
|
|
21
|
+
.index("by_assistantId", ["assistantId"]),
|
|
22
|
+
webhookEvents: defineTable({
|
|
23
|
+
eventId: v.string(), // sha256 hex of the raw body — Vapi sends no per-delivery id
|
|
24
|
+
eventType: v.string(), // message.type
|
|
25
|
+
callId: v.optional(v.string()),
|
|
26
|
+
payload: v.string(),
|
|
27
|
+
receivedAt: v.number(),
|
|
28
|
+
}).index("by_eventId", ["eventId"]),
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,eAAe,YAAY,CAAC;IAC1B,KAAK,EAAE,WAAW,CAAC;QACjB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,iBAAiB;QACrC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACnC,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACrC,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,sEAAsE;QAC1F,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACnC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAClC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/B,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACpC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5B,SAAS,EAAE,CAAC,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