@kibinrpc/server 0.0.3 → 0.0.4
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 +161 -0
- package/dist/index.d.mts +4 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +8 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# @kibinrpc/server
|
|
2
|
+
|
|
3
|
+
Server router for [kibinrpc](../../README.md) — register actions, mount a single handler.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @kibinrpc/server
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { ServerAction, defineActions, createRouter, KibinError } from '@kibinrpc/server'
|
|
15
|
+
|
|
16
|
+
class UserActions {
|
|
17
|
+
@ServerAction()
|
|
18
|
+
async getUser(id: string) {
|
|
19
|
+
const user = await db.users.find(id)
|
|
20
|
+
if (!user) throw new KibinError('NOT_FOUND', 'User not found')
|
|
21
|
+
return user
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const postActions = defineActions({
|
|
26
|
+
async listPosts() {
|
|
27
|
+
return db.posts.findAll()
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
export const router = createRouter({
|
|
32
|
+
user: new UserActions(),
|
|
33
|
+
post: postActions,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export type AppRouter = typeof router
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Mount on any framework that supports the Web `Request`/`Response` API:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// Hono
|
|
43
|
+
app.post('/api/rpc', (c) => router.handler(c.req.raw))
|
|
44
|
+
|
|
45
|
+
// Next.js App Router
|
|
46
|
+
export const POST = router.handler
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The handler automatically detects single vs. batched requests — no second endpoint needed.
|
|
50
|
+
|
|
51
|
+
## Registering actions
|
|
52
|
+
|
|
53
|
+
Only explicitly registered functions are callable. Everything else is rejected with `METHOD_NOT_FOUND`.
|
|
54
|
+
|
|
55
|
+
### Class decorator
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { ServerAction } from '@kibinrpc/server'
|
|
59
|
+
|
|
60
|
+
class UserActions {
|
|
61
|
+
@ServerAction()
|
|
62
|
+
async listUsers() { ... }
|
|
63
|
+
|
|
64
|
+
// Not callable from the client — not decorated
|
|
65
|
+
private helper() { ... }
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Functional
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { defineActions, serverAction } from '@kibinrpc/server'
|
|
73
|
+
|
|
74
|
+
// Register a whole namespace at once
|
|
75
|
+
const postActions = defineActions({
|
|
76
|
+
async listPosts() { ... },
|
|
77
|
+
async createPost(data: NewPost) { ... },
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
// Or mark individual functions
|
|
81
|
+
const deletePost = serverAction(async (id: string) => { ... })
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Interceptors
|
|
85
|
+
|
|
86
|
+
Interceptors run for every call — including each item inside a batched request.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
const router = createRouter({ user, post }, {
|
|
90
|
+
beforeAction({ namespace, method, args, request }) {
|
|
91
|
+
const token = request.headers.get('Authorization')
|
|
92
|
+
if (!token) throw new KibinError('UNAUTHORIZED', 'Missing token')
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
afterAction({ namespace, method, result }) {
|
|
96
|
+
return result // optionally transform the result
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
onError({ namespace, method, error }) {
|
|
100
|
+
console.error(`[RPC] ${namespace}.${method} failed`, error)
|
|
101
|
+
},
|
|
102
|
+
})
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Error handling
|
|
106
|
+
|
|
107
|
+
Throw `KibinError` to send a structured error to the client:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { KibinError } from '@kibinrpc/server'
|
|
111
|
+
|
|
112
|
+
throw new KibinError('NOT_FOUND', 'User not found')
|
|
113
|
+
throw new KibinError('UNAUTHORIZED', 'Invalid token')
|
|
114
|
+
throw new KibinError('BAD_REQUEST', 'Invalid input')
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Any other thrown error becomes `{ code: 'INTERNAL_ERROR' }` — the original message is not leaked.
|
|
118
|
+
|
|
119
|
+
## HTTP status codes
|
|
120
|
+
|
|
121
|
+
| Error code | HTTP status |
|
|
122
|
+
|---|---|
|
|
123
|
+
| `NOT_FOUND`, `METHOD_NOT_FOUND` | 404 |
|
|
124
|
+
| `BAD_REQUEST` | 400 |
|
|
125
|
+
| everything else | 500 |
|
|
126
|
+
|
|
127
|
+
For batched requests, each item carries its own `status` field. The overall HTTP status is `200` if all items succeed, `207 Multi-Status` for partial failures.
|
|
128
|
+
|
|
129
|
+
## API
|
|
130
|
+
|
|
131
|
+
### `createRouter(services, interceptors?)`
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
const router = createRouter(
|
|
135
|
+
{ user: new UserActions(), post: postActions },
|
|
136
|
+
{ beforeAction, afterAction, onError },
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
router.handler // (request: Request) => Promise<Response>
|
|
140
|
+
router.services // the original services object
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### `KibinError`
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
new KibinError(code: string, message: string)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Exported types
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import type {
|
|
153
|
+
RouterInterceptors,
|
|
154
|
+
ActionCtx,
|
|
155
|
+
AfterActionCtx,
|
|
156
|
+
ActionErrorCtx,
|
|
157
|
+
RpcRequest,
|
|
158
|
+
RpcResponse,
|
|
159
|
+
RpcBatchItemResponse,
|
|
160
|
+
} from '@kibinrpc/server'
|
|
161
|
+
```
|
package/dist/index.d.mts
CHANGED
|
@@ -25,6 +25,9 @@ interface RpcResponse<T = unknown> {
|
|
|
25
25
|
message: string;
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
interface RpcBatchItemResponse extends RpcResponse {
|
|
29
|
+
status: number;
|
|
30
|
+
}
|
|
28
31
|
interface ActionCtx {
|
|
29
32
|
namespace: string;
|
|
30
33
|
method: string;
|
|
@@ -48,8 +51,7 @@ type Services = Record<string, object>;
|
|
|
48
51
|
declare function createRouter<T extends Services>(services: T, interceptors?: RouterInterceptors): {
|
|
49
52
|
services: T;
|
|
50
53
|
handler: (request: Request) => Promise<Response>;
|
|
51
|
-
batchHandler: (request: Request) => Promise<Response>;
|
|
52
54
|
};
|
|
53
55
|
//#endregion
|
|
54
|
-
export { type ActionCtx, type ActionErrorCtx, type AfterActionCtx, KibinError, type RouterInterceptors, type RpcRequest, type RpcResponse, ServerAction, createRouter, defineActions, serverAction };
|
|
56
|
+
export { type ActionCtx, type ActionErrorCtx, type AfterActionCtx, KibinError, type RouterInterceptors, type RpcBatchItemResponse, type RpcRequest, type RpcResponse, ServerAction, createRouter, defineActions, serverAction };
|
|
55
57
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/decorator.ts","../src/errors.ts","../src/fn.ts","../src/types.ts","../src/router.ts"],"mappings":";iBAEgB,YAAA,CAAA,0CAEd,MAAA,GAAS,IAAA,EAAM,IAAA,KAAS,IAAA,EAAM,IAAA,KAAS,MAAA,EACvC,OAAA,EAAS,2BAAA,CAA4B,IAAA,GAAO,IAAA,EAAM,IAAA,KAAS,IAAA,EAAM,IAA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,KAAK;EAAA,SAC3B,IAAA;EAAA,SACA,UAAA;cAEG,IAAA,UAAc,OAAA,UAAiB,UAAA;AAAA;;;iBCF5B,YAAA,eAA2B,IAAA,sBAAA,CAA2B,EAAA,EAAI,CAAA,GAAI,CAAC;AAAA,iBAK/D,aAAA,WAAwB,MAAA,aAAmB,IAAA,uBAAA,CAC1D,OAAA,EAAS,CAAA,GACP,CAAA;;;UCTc,UAAA;EAChB,SAAA;EACA,MAAA;EACA,IAAA;AAAA;AAAA,UAGgB,WAAA;EAChB,IAAA,GAAO,CAAC;EACR,KAAA;IAAU,IAAA;IAAc,OAAA;EAAA;AAAA;AAAA,UAGR,oBAAA,SAA6B,WAAW;EACxD,MAAM;AAAA;AAAA,UAGU,SAAA;EAChB,SAAA;EACA,MAAA;EACA,IAAA;EACA,OAAA,EAAS,OAAO;AAAA;AAAA,UAGA,cAAA,SAAuB,SAAS;EAChD,MAAM;AAAA;AAAA,UAGU,cAAA,SAAuB,SAAS;EAChD,KAAK;AAAA;AAAA,UAGW,kBAAA;EAChB,YAAA,IAAgB,GAAA,EAAK,SAAA,YAAqB,OAAA;EAC1C,WAAA,IAAe,GAAA,EAAK,cAAA,eAA6B,OAAA;EACjD,OAAA,IAAW,GAAA,EAAK,cAAA,YAA0B,OAAA;AAAA;;;KC7BtC,QAAA,GAAW,MAAM;AAAA,iBAwEN,YAAA,WAAuB,QAAA,CAAA,CAAU,QAAA,EAAU,CAAA,EAAG,YAAA,GAAe,kBAAA;;qBAC5C,OAAA,KAAU,OAAA,CAAQ,QAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -114,25 +114,19 @@ function createRouter(services, interceptors) {
|
|
|
114
114
|
message: "Invalid JSON body"
|
|
115
115
|
} }, 400);
|
|
116
116
|
}
|
|
117
|
+
if (Array.isArray(body)) {
|
|
118
|
+
const responses = (await Promise.all(body.map((b) => executeRpcCall(b, request, services, interceptors)))).map((r) => ({
|
|
119
|
+
...r,
|
|
120
|
+
status: statusFromResponse(r)
|
|
121
|
+
}));
|
|
122
|
+
return jsonResponse(responses, responses.every((r) => r.status === 200) ? 200 : 207);
|
|
123
|
+
}
|
|
117
124
|
const result = await executeRpcCall(body, request, services, interceptors);
|
|
118
125
|
return jsonResponse(result, statusFromResponse(result));
|
|
119
126
|
}
|
|
120
|
-
async function batchHandler(request) {
|
|
121
|
-
let bodies;
|
|
122
|
-
try {
|
|
123
|
-
bodies = await request.json();
|
|
124
|
-
} catch {
|
|
125
|
-
return jsonResponse({ error: {
|
|
126
|
-
code: "BAD_REQUEST",
|
|
127
|
-
message: "Invalid JSON body"
|
|
128
|
-
} }, 400);
|
|
129
|
-
}
|
|
130
|
-
return jsonResponse(await Promise.all(bodies.map((body) => executeRpcCall(body, request, services, interceptors))), 200);
|
|
131
|
-
}
|
|
132
127
|
return {
|
|
133
128
|
services,
|
|
134
|
-
handler
|
|
135
|
-
batchHandler
|
|
129
|
+
handler
|
|
136
130
|
};
|
|
137
131
|
}
|
|
138
132
|
//#endregion
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/registry.ts","../src/decorator.ts","../src/errors.ts","../src/fn.ts","../src/router.ts"],"sourcesContent":["export const SERVER_ACTIONS_KEY = Symbol('serverActions');\nexport const FUNCTION_ACTION_KEY = Symbol('functionAction');\n\nexport function getRegisteredActions(instance: object): Set<string> {\n\treturn (Reflect.get(instance, SERVER_ACTIONS_KEY) as Set<string> | undefined) ?? new Set();\n}\n\nexport function isBrandedAction(fn: unknown): boolean {\n\treturn typeof fn === 'function' && Reflect.get(fn, FUNCTION_ACTION_KEY) === true;\n}\n","import { SERVER_ACTIONS_KEY } from './registry.js';\n\nexport function ServerAction() {\n\treturn <This, Args extends unknown[], Return>(\n\t\ttarget: (this: This, ...args: Args) => Return,\n\t\tcontext: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>,\n\t) => {\n\t\tcontext.addInitializer(function (this: This) {\n\t\t\tif (!Reflect.has(this as object, SERVER_ACTIONS_KEY)) {\n\t\t\t\tReflect.set(this as object, SERVER_ACTIONS_KEY, new Set<string>());\n\t\t\t}\n\t\t\t(Reflect.get(this as object, SERVER_ACTIONS_KEY) as Set<string>).add(String(context.name));\n\t\t});\n\t\treturn target;\n\t};\n}\n","export class KibinError extends Error {\n\treadonly code: string;\n\treadonly statusCode: number;\n\n\tconstructor(code: string, message: string, statusCode = 400) {\n\t\tsuper(message);\n\t\tthis.name = 'KibinError';\n\t\tthis.code = code;\n\t\tthis.statusCode = statusCode;\n\t}\n}\n","import { FUNCTION_ACTION_KEY } from './registry.js';\n\nexport function serverAction<T extends (...args: never[]) => unknown>(fn: T): T {\n\tReflect.set(fn, FUNCTION_ACTION_KEY, true);\n\treturn fn;\n}\n\nexport function defineActions<T extends Record<string, (...args: never[]) => unknown>>(\n\tactions: T,\n): T {\n\tfor (const key of Object.keys(actions)) {\n\t\tserverAction(actions[key]);\n\t}\n\treturn actions;\n}\n","import { KibinError } from './errors.js';\nimport { getRegisteredActions, isBrandedAction } from './registry.js';\nimport type { RouterInterceptors, RpcRequest, RpcResponse } from './types.js';\n\ntype Services = Record<string, object>;\n\nfunction jsonResponse(body: RpcResponse |
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/registry.ts","../src/decorator.ts","../src/errors.ts","../src/fn.ts","../src/router.ts"],"sourcesContent":["export const SERVER_ACTIONS_KEY = Symbol('serverActions');\nexport const FUNCTION_ACTION_KEY = Symbol('functionAction');\n\nexport function getRegisteredActions(instance: object): Set<string> {\n\treturn (Reflect.get(instance, SERVER_ACTIONS_KEY) as Set<string> | undefined) ?? new Set();\n}\n\nexport function isBrandedAction(fn: unknown): boolean {\n\treturn typeof fn === 'function' && Reflect.get(fn, FUNCTION_ACTION_KEY) === true;\n}\n","import { SERVER_ACTIONS_KEY } from './registry.js';\n\nexport function ServerAction() {\n\treturn <This, Args extends unknown[], Return>(\n\t\ttarget: (this: This, ...args: Args) => Return,\n\t\tcontext: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>,\n\t) => {\n\t\tcontext.addInitializer(function (this: This) {\n\t\t\tif (!Reflect.has(this as object, SERVER_ACTIONS_KEY)) {\n\t\t\t\tReflect.set(this as object, SERVER_ACTIONS_KEY, new Set<string>());\n\t\t\t}\n\t\t\t(Reflect.get(this as object, SERVER_ACTIONS_KEY) as Set<string>).add(String(context.name));\n\t\t});\n\t\treturn target;\n\t};\n}\n","export class KibinError extends Error {\n\treadonly code: string;\n\treadonly statusCode: number;\n\n\tconstructor(code: string, message: string, statusCode = 400) {\n\t\tsuper(message);\n\t\tthis.name = 'KibinError';\n\t\tthis.code = code;\n\t\tthis.statusCode = statusCode;\n\t}\n}\n","import { FUNCTION_ACTION_KEY } from './registry.js';\n\nexport function serverAction<T extends (...args: never[]) => unknown>(fn: T): T {\n\tReflect.set(fn, FUNCTION_ACTION_KEY, true);\n\treturn fn;\n}\n\nexport function defineActions<T extends Record<string, (...args: never[]) => unknown>>(\n\tactions: T,\n): T {\n\tfor (const key of Object.keys(actions)) {\n\t\tserverAction(actions[key]);\n\t}\n\treturn actions;\n}\n","import { KibinError } from './errors.js';\nimport { getRegisteredActions, isBrandedAction } from './registry.js';\nimport type { RouterInterceptors, RpcBatchItemResponse, RpcRequest, RpcResponse } from './types.js';\n\ntype Services = Record<string, object>;\n\nfunction jsonResponse(body: RpcResponse | RpcBatchItemResponse[], status: number): Response {\n\treturn new Response(JSON.stringify(body), {\n\t\tstatus,\n\t\theaders: { 'Content-Type': 'application/json' },\n\t});\n}\n\nfunction statusFromResponse(result: RpcResponse): number {\n\tif (!result.error) return 200;\n\tif (result.error.code === 'NOT_FOUND' || result.error.code === 'METHOD_NOT_FOUND') return 404;\n\tif (result.error.code === 'BAD_REQUEST') return 400;\n\treturn 500;\n}\n\nasync function executeRpcCall(\n\tbody: RpcRequest,\n\trequest: Request,\n\tservices: Services,\n\tinterceptors: RouterInterceptors | undefined,\n): Promise<RpcResponse> {\n\tconst { namespace, method, args } = body;\n\n\tconst service = services[namespace];\n\tif (!service) {\n\t\treturn { error: { code: 'NOT_FOUND', message: `Namespace \"${namespace}\" not found` } };\n\t}\n\n\tconst fn = (service as Record<string, unknown>)[method];\n\tconst isAllowed = getRegisteredActions(service).has(method) || isBrandedAction(fn);\n\tif (!isAllowed) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\tcode: 'METHOD_NOT_FOUND',\n\t\t\t\tmessage: `\"${method}\" is not a registered server action`,\n\t\t\t},\n\t\t};\n\t}\n\n\tif (typeof fn !== 'function') {\n\t\treturn { error: { code: 'METHOD_NOT_FOUND', message: `Method \"${method}\" not found` } };\n\t}\n\n\tconst ctx = { namespace, method, args, request };\n\n\ttry {\n\t\tif (interceptors?.beforeAction) {\n\t\t\tawait interceptors.beforeAction(ctx);\n\t\t}\n\n\t\tconst result = await fn.apply(service, args);\n\n\t\tlet finalResult = result;\n\t\tif (interceptors?.afterAction) {\n\t\t\tconst transformed = await interceptors.afterAction({ ...ctx, result });\n\t\t\tif (transformed !== undefined) finalResult = transformed;\n\t\t}\n\n\t\treturn { data: finalResult };\n\t} catch (error) {\n\t\tif (interceptors?.onError) {\n\t\t\tawait interceptors.onError({ ...ctx, error });\n\t\t}\n\n\t\tif (error instanceof KibinError) {\n\t\t\treturn { error: { code: error.code, message: error.message } };\n\t\t}\n\t\treturn { error: { code: 'INTERNAL_ERROR', message: 'Internal server error' } };\n\t}\n}\n\nexport function createRouter<T extends Services>(services: T, interceptors?: RouterInterceptors) {\n\tasync function handler(request: Request): Promise<Response> {\n\t\tlet body: RpcRequest | RpcRequest[];\n\t\ttry {\n\t\t\tbody = (await request.json()) as RpcRequest | RpcRequest[];\n\t\t} catch {\n\t\t\treturn jsonResponse({ error: { code: 'BAD_REQUEST', message: 'Invalid JSON body' } }, 400);\n\t\t}\n\n\t\tif (Array.isArray(body)) {\n\t\t\tconst results = await Promise.all(\n\t\t\t\tbody.map((b) => executeRpcCall(b, request, services, interceptors)),\n\t\t\t);\n\t\t\tconst responses: RpcBatchItemResponse[] = results.map((r) => ({\n\t\t\t\t...r,\n\t\t\t\tstatus: statusFromResponse(r),\n\t\t\t}));\n\t\t\tconst httpStatus = responses.every((r) => r.status === 200) ? 200 : 207;\n\t\t\treturn jsonResponse(responses, httpStatus);\n\t\t}\n\n\t\tconst result = await executeRpcCall(body, request, services, interceptors);\n\t\treturn jsonResponse(result, statusFromResponse(result));\n\t}\n\n\treturn { services, handler };\n}\n"],"mappings":";AAAA,MAAa,qBAAqB,OAAO,eAAe;AACxD,MAAa,sBAAsB,OAAO,gBAAgB;AAE1D,SAAgB,qBAAqB,UAA+B;CACnE,OAAQ,QAAQ,IAAI,UAAU,kBAAkB,qBAAiC,IAAI,IAAI;AAC1F;AAEA,SAAgB,gBAAgB,IAAsB;CACrD,OAAO,OAAO,OAAO,cAAc,QAAQ,IAAI,IAAI,mBAAmB,MAAM;AAC7E;;;ACPA,SAAgB,eAAe;CAC9B,QACC,QACA,YACI;EACJ,QAAQ,eAAe,WAAsB;GAC5C,IAAI,CAAC,QAAQ,IAAI,MAAgB,kBAAkB,GAClD,QAAQ,IAAI,MAAgB,oCAAoB,IAAI,IAAY,CAAC;GAElE,QAAS,IAAI,MAAgB,kBAAkB,EAAkB,IAAI,OAAO,QAAQ,IAAI,CAAC;EAC1F,CAAC;EACD,OAAO;CACR;AACD;;;ACfA,IAAa,aAAb,cAAgC,MAAM;CACrC;CACA;CAEA,YAAY,MAAc,SAAiB,aAAa,KAAK;EAC5D,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,aAAa;CACnB;AACD;;;ACRA,SAAgB,aAAsD,IAAU;CAC/E,QAAQ,IAAI,IAAI,qBAAqB,IAAI;CACzC,OAAO;AACR;AAEA,SAAgB,cACf,SACI;CACJ,KAAK,MAAM,OAAO,OAAO,KAAK,OAAO,GACpC,aAAa,QAAQ,IAAI;CAE1B,OAAO;AACR;;;ACRA,SAA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