@richie-rpc/core 1.2.3 → 1.2.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/dist/cjs/package.json +1 -1
- package/dist/cjs/websocket.cjs +41 -0
- package/dist/cjs/websocket.cjs.map +10 -0
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/websocket.mjs +10 -0
- package/dist/mjs/websocket.mjs.map +10 -0
- package/package.json +1 -1
package/dist/cjs/package.json
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// @bun @bun-cjs
|
|
2
|
+
(function(exports, require, module, __filename, __dirname) {var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// packages/core/websocket.ts
|
|
31
|
+
var exports_websocket = {};
|
|
32
|
+
__export(exports_websocket, {
|
|
33
|
+
defineWebSocketContract: () => defineWebSocketContract
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(exports_websocket);
|
|
36
|
+
function defineWebSocketContract(contract) {
|
|
37
|
+
return contract;
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
//# debugId=CF5F38370DDE9B5964756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../websocket.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { z } from 'zod';\n\n/**\n * Definition for a single message type in WebSocket communication\n */\nexport interface WebSocketMessageDefinition {\n payload: z.ZodTypeAny;\n}\n\n/**\n * Definition for a WebSocket endpoint contract\n */\nexport interface WebSocketContractDefinition {\n path: string;\n params?: z.ZodTypeAny;\n query?: z.ZodTypeAny;\n headers?: z.ZodTypeAny;\n\n /** Messages client sends to server (validated with Zod on server) */\n clientMessages: Record<string, WebSocketMessageDefinition>;\n\n /** Messages server sends to client (type inference only, NOT validated) */\n serverMessages: Record<string, WebSocketMessageDefinition>;\n}\n\n/**\n * A collection of named WebSocket endpoints\n */\nexport type WebSocketContract = Record<string, WebSocketContractDefinition>;\n\n/**\n * Extract the union type of all client messages for a WebSocket endpoint\n */\nexport type ExtractClientMessage<T extends WebSocketContractDefinition> = {\n [K in keyof T['clientMessages']]: {\n type: K;\n payload: z.infer<T['clientMessages'][K]['payload']>;\n };\n}[keyof T['clientMessages']];\n\n/**\n * Extract the union type of all server messages for a WebSocket endpoint\n */\nexport type ExtractServerMessage<T extends WebSocketContractDefinition> = {\n [K in keyof T['serverMessages']]: {\n type: K;\n payload: z.infer<T['serverMessages'][K]['payload']>;\n };\n}[keyof T['serverMessages']];\n\n/**\n * Extract the payload type for a specific client message\n */\nexport type ExtractClientMessagePayload<\n T extends WebSocketContractDefinition,\n K extends keyof T['clientMessages'],\n> = z.infer<T['clientMessages'][K]['payload']>;\n\n/**\n * Extract the payload type for a specific server message\n */\nexport type ExtractServerMessagePayload<\n T extends WebSocketContractDefinition,\n K extends keyof T['serverMessages'],\n> = z.infer<T['serverMessages'][K]['payload']>;\n\n/**\n * Extract params type from WebSocket endpoint\n */\nexport type ExtractWSParams<T extends WebSocketContractDefinition> =\n T['params'] extends z.ZodTypeAny ? z.infer<T['params']> : never;\n\n/**\n * Extract query type from WebSocket endpoint\n */\nexport type ExtractWSQuery<T extends WebSocketContractDefinition> = T['query'] extends z.ZodTypeAny\n ? z.infer<T['query']>\n : never;\n\n/**\n * Extract headers type from WebSocket endpoint\n */\nexport type ExtractWSHeaders<T extends WebSocketContractDefinition> =\n T['headers'] extends z.ZodTypeAny ? z.infer<T['headers']> : never;\n\n/**\n * Type helper to ensure a value is a valid WebSocket contract\n */\nexport function defineWebSocketContract<T extends WebSocketContract>(contract: T): T {\n return contract;\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFO,SAAS,uBAAoD,CAAC,UAAgB;AAAA,EACnF,OAAO;AAAA;",
|
|
8
|
+
"debugId": "CF5F38370DDE9B5964756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/mjs/package.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../websocket.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { z } from 'zod';\n\n/**\n * Definition for a single message type in WebSocket communication\n */\nexport interface WebSocketMessageDefinition {\n payload: z.ZodTypeAny;\n}\n\n/**\n * Definition for a WebSocket endpoint contract\n */\nexport interface WebSocketContractDefinition {\n path: string;\n params?: z.ZodTypeAny;\n query?: z.ZodTypeAny;\n headers?: z.ZodTypeAny;\n\n /** Messages client sends to server (validated with Zod on server) */\n clientMessages: Record<string, WebSocketMessageDefinition>;\n\n /** Messages server sends to client (type inference only, NOT validated) */\n serverMessages: Record<string, WebSocketMessageDefinition>;\n}\n\n/**\n * A collection of named WebSocket endpoints\n */\nexport type WebSocketContract = Record<string, WebSocketContractDefinition>;\n\n/**\n * Extract the union type of all client messages for a WebSocket endpoint\n */\nexport type ExtractClientMessage<T extends WebSocketContractDefinition> = {\n [K in keyof T['clientMessages']]: {\n type: K;\n payload: z.infer<T['clientMessages'][K]['payload']>;\n };\n}[keyof T['clientMessages']];\n\n/**\n * Extract the union type of all server messages for a WebSocket endpoint\n */\nexport type ExtractServerMessage<T extends WebSocketContractDefinition> = {\n [K in keyof T['serverMessages']]: {\n type: K;\n payload: z.infer<T['serverMessages'][K]['payload']>;\n };\n}[keyof T['serverMessages']];\n\n/**\n * Extract the payload type for a specific client message\n */\nexport type ExtractClientMessagePayload<\n T extends WebSocketContractDefinition,\n K extends keyof T['clientMessages'],\n> = z.infer<T['clientMessages'][K]['payload']>;\n\n/**\n * Extract the payload type for a specific server message\n */\nexport type ExtractServerMessagePayload<\n T extends WebSocketContractDefinition,\n K extends keyof T['serverMessages'],\n> = z.infer<T['serverMessages'][K]['payload']>;\n\n/**\n * Extract params type from WebSocket endpoint\n */\nexport type ExtractWSParams<T extends WebSocketContractDefinition> =\n T['params'] extends z.ZodTypeAny ? z.infer<T['params']> : never;\n\n/**\n * Extract query type from WebSocket endpoint\n */\nexport type ExtractWSQuery<T extends WebSocketContractDefinition> = T['query'] extends z.ZodTypeAny\n ? z.infer<T['query']>\n : never;\n\n/**\n * Extract headers type from WebSocket endpoint\n */\nexport type ExtractWSHeaders<T extends WebSocketContractDefinition> =\n T['headers'] extends z.ZodTypeAny ? z.infer<T['headers']> : never;\n\n/**\n * Type helper to ensure a value is a valid WebSocket contract\n */\nexport function defineWebSocketContract<T extends WebSocketContract>(contract: T): T {\n return contract;\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AAwFO,SAAS,uBAAoD,CAAC,UAAgB;AAAA,EACnF,OAAO;AAAA;",
|
|
8
|
+
"debugId": "74D9972511B45B2164756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|