@open-core/framework 1.0.5 → 1.0.6
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 +2 -8
- package/dist/adapters/contracts/transport/index.d.ts +1 -0
- package/dist/adapters/contracts/transport/index.js +1 -0
- package/dist/adapters/contracts/transport/rpc-error.d.ts +17 -0
- package/dist/adapters/contracts/transport/rpc-error.js +28 -0
- package/dist/runtime/server/system/processors/onRpc.processor.js +14 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
[](https://opencorejs.dev)
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
# OpenCore Framework -
|
|
9
|
+
# OpenCore Framework - Stable v1
|
|
10
10
|
|
|
11
|
-
OpenCore is a TypeScript multiplayer runtime framework targeting CitizenFX runtimes (Cfx) via adapters.
|
|
11
|
+
OpenCore is a TypeScript multiplayer runtime framework targeting CitizenFX runtimes (Cfx/RageMP) via adapters.
|
|
12
12
|
|
|
13
13
|
It is not a gamemode or RP framework. It provides:
|
|
14
14
|
|
|
@@ -277,12 +277,6 @@ pnpm lint:fix
|
|
|
277
277
|
pnpm format
|
|
278
278
|
```
|
|
279
279
|
|
|
280
|
-
## Ecosystem
|
|
281
|
-
|
|
282
|
-
OpenCore is designed to be extended via separate packages/resources.
|
|
283
|
-
|
|
284
|
-
- `@open-core/identity`: identity and permission system
|
|
285
|
-
|
|
286
280
|
## License
|
|
287
281
|
|
|
288
282
|
MPL-2.0. See `LICENSE`.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const PUBLIC_RPC_ERROR_MESSAGE = "An internal server error occurred";
|
|
2
|
+
export type RpcErrorInfo = {
|
|
3
|
+
message: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
};
|
|
6
|
+
type ExposedRpcError = {
|
|
7
|
+
message: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
expose: true;
|
|
10
|
+
};
|
|
11
|
+
export declare class RpcPublicError extends Error {
|
|
12
|
+
readonly expose = true;
|
|
13
|
+
constructor(message: string, name?: string);
|
|
14
|
+
}
|
|
15
|
+
export declare function isExposedRpcError(error: unknown): error is ExposedRpcError;
|
|
16
|
+
export declare function serializeRpcError(error: unknown): RpcErrorInfo;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const PUBLIC_RPC_ERROR_MESSAGE = 'An internal server error occurred';
|
|
2
|
+
export class RpcPublicError extends Error {
|
|
3
|
+
expose = true;
|
|
4
|
+
constructor(message, name) {
|
|
5
|
+
super(message);
|
|
6
|
+
if (name) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
}
|
|
9
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function isExposedRpcError(error) {
|
|
13
|
+
return (typeof error === 'object' &&
|
|
14
|
+
error !== null &&
|
|
15
|
+
'message' in error &&
|
|
16
|
+
typeof error.message === 'string' &&
|
|
17
|
+
'expose' in error &&
|
|
18
|
+
error.expose === true);
|
|
19
|
+
}
|
|
20
|
+
export function serializeRpcError(error) {
|
|
21
|
+
if (isExposedRpcError(error)) {
|
|
22
|
+
return {
|
|
23
|
+
message: error.message,
|
|
24
|
+
name: 'name' in error && typeof error.name === 'string' ? error.name : undefined,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return { message: PUBLIC_RPC_ERROR_MESSAGE };
|
|
28
|
+
}
|
|
@@ -124,10 +124,21 @@ let OnRpcProcessor = class OnRpcProcessor {
|
|
|
124
124
|
});
|
|
125
125
|
throw error;
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
try {
|
|
128
|
+
if (hasNoDeclaredParams) {
|
|
129
|
+
return await handler();
|
|
130
|
+
}
|
|
131
|
+
return await handler(player, ...validatedArgs);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
loggers.netEvent.error(`Handler error in RPC`, {
|
|
135
|
+
event: metadata.eventName,
|
|
136
|
+
handler: handlerName,
|
|
137
|
+
playerId: player.clientID,
|
|
138
|
+
accountId: player.accountID,
|
|
139
|
+
}, error);
|
|
140
|
+
throw error;
|
|
129
141
|
}
|
|
130
|
-
return handler(player, ...validatedArgs);
|
|
131
142
|
});
|
|
132
143
|
loggers.netEvent.debug(`Registered RPC: ${metadata.eventName} -> ${handlerName}`);
|
|
133
144
|
}
|