@irpclib/irpc 1.2.4 → 1.2.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/dist/adapter.d.ts +38 -35
- package/dist/adapter.js +40 -38
- package/dist/call.d.ts +1 -1
- package/dist/driver.d.ts +16 -0
- package/dist/driver.js +8 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +3 -3
- package/dist/module.d.ts +2 -2
- package/dist/reader.d.ts +1 -1
- package/dist/resolver.d.ts +1 -1
- package/dist/router.d.ts +1 -1
- package/dist/store.d.ts +1 -1
- package/dist/transport.d.ts +2 -2
- package/dist/types.d.ts +6 -14
- package/dist/types.js +1 -8
- package/package.json +2 -2
package/dist/adapter.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IRPCCrudMeta, IRPCData, IRPCDriver, IRPCStub } from "./types.js";
|
|
2
1
|
import { IRPCPackage } from "./module.js";
|
|
2
|
+
import { IRPCCrudMeta, IRPCData, IRPCMeta, IRPCStub } from "./types.js";
|
|
3
|
+
import { IRPCDriver } from "./driver.js";
|
|
3
4
|
|
|
4
5
|
//#region src/adapter.d.ts
|
|
5
6
|
declare class NextDriver extends Error {
|
|
@@ -8,39 +9,10 @@ declare class NextDriver extends Error {
|
|
|
8
9
|
/** Extracts operational method names from an adapter, excluding its own API. */
|
|
9
10
|
type AttachableMethod<T> = string & keyof Omit<T, 'attach' | 'use' | 'dispatch'>;
|
|
10
11
|
type AnyStub = IRPCStub<any, any[], any>;
|
|
11
|
-
/**
|
|
12
|
-
* Attaches handlers to IRPC stubs and bridges them to drivers.
|
|
13
|
-
* Dispatches calls through the registered driver chain.
|
|
14
|
-
*/
|
|
15
12
|
declare class IRPCAdapter {
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
protected module: IRPCPackage;
|
|
14
|
+
protected drivers: Set<Partial<Omit<this, "use" | "attach" | "dispatch" | "drivers" | "module">>>;
|
|
18
15
|
constructor(module: IRPCPackage);
|
|
19
|
-
/**
|
|
20
|
-
* Runs a get operation through the driver chain
|
|
21
|
-
* @param meta - Resolved entity metadata
|
|
22
|
-
* @param id - The entity identifier
|
|
23
|
-
*/
|
|
24
|
-
get(meta: IRPCCrudMeta, id: IRPCData): Promise<IRPCData> | IRPCData;
|
|
25
|
-
/**
|
|
26
|
-
* Runs a create operation through the driver chain
|
|
27
|
-
* @param meta - Resolved entity metadata
|
|
28
|
-
* @param data - The entity data to create
|
|
29
|
-
*/
|
|
30
|
-
create(meta: IRPCCrudMeta, data: IRPCData): Promise<IRPCData> | IRPCData;
|
|
31
|
-
/**
|
|
32
|
-
* Runs an update operation through the driver chain
|
|
33
|
-
* @param meta - Resolved entity metadata
|
|
34
|
-
* @param id - The entity identifier
|
|
35
|
-
* @param data - The entity data to update
|
|
36
|
-
*/
|
|
37
|
-
update(meta: IRPCCrudMeta, id: IRPCData, data: IRPCData): Promise<IRPCData> | IRPCData;
|
|
38
|
-
/**
|
|
39
|
-
* Runs a delete operation through the driver chain
|
|
40
|
-
* @param meta - Resolved entity metadata
|
|
41
|
-
* @param id - The entity identifier
|
|
42
|
-
*/
|
|
43
|
-
delete(meta: IRPCCrudMeta, id: IRPCData): Promise<IRPCData> | IRPCData;
|
|
44
16
|
/**
|
|
45
17
|
* Dispatches a method call through each registered driver in order
|
|
46
18
|
* @param method - The method name to dispatch
|
|
@@ -48,7 +20,7 @@ declare class IRPCAdapter {
|
|
|
48
20
|
* @param args - Arguments forwarded to the driver method
|
|
49
21
|
* @throws CrudError.notImplemented if no driver handles the method
|
|
50
22
|
*/
|
|
51
|
-
protected dispatch(method: string, meta:
|
|
23
|
+
protected dispatch<O>(method: string, meta: IRPCMeta, ...args: unknown[]): Promise<O> | O;
|
|
52
24
|
/**
|
|
53
25
|
* Attaches a single stub to a specific method on this adapter
|
|
54
26
|
* @param stub - The stub function to attach
|
|
@@ -66,11 +38,42 @@ declare class IRPCAdapter {
|
|
|
66
38
|
* Registers a driver to handle dispatched operations
|
|
67
39
|
* @param driver - The driver implementation
|
|
68
40
|
*/
|
|
69
|
-
use(driver: IRPCDriver): this;
|
|
41
|
+
use(driver: IRPCDriver<this>): this;
|
|
70
42
|
/**
|
|
71
43
|
* Signals the current driver to pass execution to the next driver in the chain
|
|
72
44
|
*/
|
|
73
45
|
static next(): NextDriver;
|
|
74
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Attaches handlers to IRPC stubs and bridges them to drivers.
|
|
49
|
+
* Dispatches calls through the registered driver chain.
|
|
50
|
+
*/
|
|
51
|
+
declare class IRPCCrudAdapter extends IRPCAdapter {
|
|
52
|
+
/**
|
|
53
|
+
* Runs a get operation through the driver chain
|
|
54
|
+
* @param meta - Resolved entity metadata
|
|
55
|
+
* @param id - The entity identifier
|
|
56
|
+
*/
|
|
57
|
+
get(meta: IRPCCrudMeta, id: string): Promise<IRPCData> | IRPCData;
|
|
58
|
+
/**
|
|
59
|
+
* Runs a create operation through the driver chain
|
|
60
|
+
* @param meta - Resolved entity metadata
|
|
61
|
+
* @param data - The entity data to create
|
|
62
|
+
*/
|
|
63
|
+
create<D extends IRPCData>(meta: IRPCCrudMeta, data: D): Promise<IRPCData> | IRPCData;
|
|
64
|
+
/**
|
|
65
|
+
* Runs an update operation through the driver chain
|
|
66
|
+
* @param meta - Resolved entity metadata
|
|
67
|
+
* @param id - The entity identifier
|
|
68
|
+
* @param data - The entity data to update
|
|
69
|
+
*/
|
|
70
|
+
update(meta: IRPCCrudMeta, id: string, data: IRPCData): Promise<IRPCData> | IRPCData;
|
|
71
|
+
/**
|
|
72
|
+
* Runs a delete operation through the driver chain
|
|
73
|
+
* @param meta - Resolved entity metadata
|
|
74
|
+
* @param id - The entity identifier
|
|
75
|
+
*/
|
|
76
|
+
delete(meta: IRPCCrudMeta, id: string): Promise<IRPCData> | IRPCData;
|
|
77
|
+
}
|
|
75
78
|
//#endregion
|
|
76
|
-
export { IRPCAdapter };
|
|
79
|
+
export { IRPCAdapter, IRPCCrudAdapter };
|
package/dist/adapter.js
CHANGED
|
@@ -6,49 +6,12 @@ var NextDriver = class extends Error {
|
|
|
6
6
|
super("Next driver");
|
|
7
7
|
}
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
10
|
-
* Attaches handlers to IRPC stubs and bridges them to drivers.
|
|
11
|
-
* Dispatches calls through the registered driver chain.
|
|
12
|
-
*/
|
|
13
9
|
var IRPCAdapter = class {
|
|
14
10
|
drivers = /* @__PURE__ */ new Set();
|
|
15
11
|
constructor(module) {
|
|
16
12
|
this.module = module;
|
|
17
13
|
}
|
|
18
14
|
/**
|
|
19
|
-
* Runs a get operation through the driver chain
|
|
20
|
-
* @param meta - Resolved entity metadata
|
|
21
|
-
* @param id - The entity identifier
|
|
22
|
-
*/
|
|
23
|
-
get(meta, id) {
|
|
24
|
-
return this.dispatch("get", meta, id);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Runs a create operation through the driver chain
|
|
28
|
-
* @param meta - Resolved entity metadata
|
|
29
|
-
* @param data - The entity data to create
|
|
30
|
-
*/
|
|
31
|
-
create(meta, data) {
|
|
32
|
-
return this.dispatch("create", meta, data);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Runs an update operation through the driver chain
|
|
36
|
-
* @param meta - Resolved entity metadata
|
|
37
|
-
* @param id - The entity identifier
|
|
38
|
-
* @param data - The entity data to update
|
|
39
|
-
*/
|
|
40
|
-
update(meta, id, data) {
|
|
41
|
-
return this.dispatch("update", meta, id, data);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Runs a delete operation through the driver chain
|
|
45
|
-
* @param meta - Resolved entity metadata
|
|
46
|
-
* @param id - The entity identifier
|
|
47
|
-
*/
|
|
48
|
-
delete(meta, id) {
|
|
49
|
-
return this.dispatch("delete", meta, id);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
15
|
* Dispatches a method call through each registered driver in order
|
|
53
16
|
* @param method - The method name to dispatch
|
|
54
17
|
* @param meta - Resolved entity metadata
|
|
@@ -104,6 +67,45 @@ var IRPCAdapter = class {
|
|
|
104
67
|
return new NextDriver();
|
|
105
68
|
}
|
|
106
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Attaches handlers to IRPC stubs and bridges them to drivers.
|
|
72
|
+
* Dispatches calls through the registered driver chain.
|
|
73
|
+
*/
|
|
74
|
+
var IRPCCrudAdapter = class extends IRPCAdapter {
|
|
75
|
+
/**
|
|
76
|
+
* Runs a get operation through the driver chain
|
|
77
|
+
* @param meta - Resolved entity metadata
|
|
78
|
+
* @param id - The entity identifier
|
|
79
|
+
*/
|
|
80
|
+
get(meta, id) {
|
|
81
|
+
return this.dispatch("get", meta, id);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Runs a create operation through the driver chain
|
|
85
|
+
* @param meta - Resolved entity metadata
|
|
86
|
+
* @param data - The entity data to create
|
|
87
|
+
*/
|
|
88
|
+
create(meta, data) {
|
|
89
|
+
return this.dispatch("create", meta, data);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Runs an update operation through the driver chain
|
|
93
|
+
* @param meta - Resolved entity metadata
|
|
94
|
+
* @param id - The entity identifier
|
|
95
|
+
* @param data - The entity data to update
|
|
96
|
+
*/
|
|
97
|
+
update(meta, id, data) {
|
|
98
|
+
return this.dispatch("update", meta, id, data);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Runs a delete operation through the driver chain
|
|
102
|
+
* @param meta - Resolved entity metadata
|
|
103
|
+
* @param id - The entity identifier
|
|
104
|
+
*/
|
|
105
|
+
delete(meta, id) {
|
|
106
|
+
return this.dispatch("delete", meta, id);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
107
109
|
|
|
108
110
|
//#endregion
|
|
109
|
-
export { IRPCAdapter };
|
|
111
|
+
export { IRPCAdapter, IRPCCrudAdapter };
|
package/dist/call.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { IRPCReader } from "./reader.js";
|
|
1
2
|
import { IRPCTransport } from "./transport.js";
|
|
2
3
|
import { IRPCCallConfig, IRPCData, IRPCPacketStream, IRPCPayload, IRPCStatus } from "./types.js";
|
|
3
|
-
import { IRPCReader } from "./reader.js";
|
|
4
4
|
|
|
5
5
|
//#region src/call.d.ts
|
|
6
6
|
declare const DEFAULT_RETRY_MODE = "exponential";
|
package/dist/driver.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IRPCCrudMeta, IRPCData } from "./types.js";
|
|
2
|
+
import { IRPCAdapter } from "./adapter.js";
|
|
3
|
+
|
|
4
|
+
//#region src/driver.d.ts
|
|
5
|
+
type IRPCDriver<Adapter extends IRPCAdapter> = Partial<Omit<Adapter, 'use' | 'attach' | 'dispatch' | 'drivers' | 'module'>>;
|
|
6
|
+
/**
|
|
7
|
+
* Base class for CRUD drivers that receive per-method resolved metadata on every call
|
|
8
|
+
*/
|
|
9
|
+
declare abstract class IRPCCrudDriver {
|
|
10
|
+
get?(meta: IRPCCrudMeta, id: string): Promise<IRPCData> | IRPCData;
|
|
11
|
+
create?(meta: IRPCCrudMeta, data: IRPCData): Promise<IRPCData> | IRPCData;
|
|
12
|
+
update?(meta: IRPCCrudMeta, id: string, data: IRPCData): Promise<IRPCData> | IRPCData;
|
|
13
|
+
delete?(meta: IRPCCrudMeta, id: string): Promise<IRPCData> | IRPCData;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { IRPCCrudDriver, IRPCDriver };
|
package/dist/driver.js
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { IRPC_BASE_CONTEXT, IRPC_FILE_STATUS, IRPC_PACKET_TYPE, IRPC_STATUS, IRPC_STORE_EVENT } from "./enum.js";
|
|
2
2
|
import { IRPCBlob, IRPCFile, IRPCFileMeta, IRPCFilePipe, IRPCFileState, IRPCFileStatus, IRPCFileStream, IRPCFileUnpipe } from "./file.js";
|
|
3
3
|
import { IRPCBlobPointer, IRPCFilePointer, IRPCFileQueue, IRPCPacketJson, IRPCPacketQueues, IRPC_BLOB_IDENTIFIER, IRPC_FILE_IDENTIFIER, PacketStream, decode, decodeBlobs, encode, encodeBlobs, isBlobPointer, isFilePointer } from "./packet.js";
|
|
4
|
-
import { DEFAULT_RETRY_DELAY, DEFAULT_RETRY_MODE, IRPCCall } from "./call.js";
|
|
5
|
-
import { IRPCTransport } from "./transport.js";
|
|
6
|
-
import { IRPCArraySchema, IRPCCallConfig, IRPCContext, IRPCContextProvider, IRPCCredentials, IRPCCredentialsFactory, IRPCCrudField, IRPCCrudMeta, IRPCCrudMethod, IRPCCrudOptions, IRPCCrudStubs, IRPCData, IRPCDataSchema, IRPCDeclareConfig, IRPCDeclareInit, IRPCDefined, IRPCDriver, IRPCEntityId, IRPCFunction, IRPCHandler, IRPCInferInit, IRPCInit, IRPCInputs, IRPCObject, IRPCObjectSchema, IRPCOutput, IRPCPackageConfig, IRPCPackageInfo, IRPCPacketAnswer, IRPCPacketBase, IRPCPacketCall, IRPCPacketClose, IRPCPacketError, IRPCPacketEvent, IRPCPacketStream, IRPCPacketType, IRPCParseResult, IRPCPayload, IRPCPrimitive, IRPCPrimitiveSchema, IRPCReadable, IRPCRequest, IRPCRequests, IRPCResponse, IRPCReturnOf, IRPCSchema, IRPCSpec, IRPCSpecStore, IRPCStatus, IRPCStreamInit, IRPCStub, IRPCStubStore, StreamCleanup, StreamConstructor, TransportConfig } from "./types.js";
|
|
7
4
|
import { RemoteState, stream } from "./state.js";
|
|
8
5
|
import { IRPCReader } from "./reader.js";
|
|
6
|
+
import { DEFAULT_RETRY_DELAY, DEFAULT_RETRY_MODE, IRPCCall } from "./call.js";
|
|
9
7
|
import { IRPCHookArgs, IRPCPackage, IRPCSpecHook, createPackage, intercept } from "./module.js";
|
|
10
|
-
import {
|
|
8
|
+
import { IRPCTransport } from "./transport.js";
|
|
9
|
+
import { IRPCArraySchema, IRPCCallConfig, IRPCContext, IRPCContextProvider, IRPCCredentials, IRPCCredentialsFactory, IRPCCrudField, IRPCCrudMeta, IRPCCrudMethod, IRPCCrudOptions, IRPCCrudStubs, IRPCData, IRPCDataSchema, IRPCDeclareConfig, IRPCDeclareInit, IRPCDefined, IRPCEntityId, IRPCFunction, IRPCHandler, IRPCInferInit, IRPCInit, IRPCInputs, IRPCMeta, IRPCObject, IRPCObjectSchema, IRPCOutput, IRPCPackageConfig, IRPCPackageInfo, IRPCPacketAnswer, IRPCPacketBase, IRPCPacketCall, IRPCPacketClose, IRPCPacketError, IRPCPacketEvent, IRPCPacketStream, IRPCPacketType, IRPCParseResult, IRPCPayload, IRPCPrimitive, IRPCPrimitiveSchema, IRPCReadable, IRPCRequest, IRPCRequests, IRPCResponse, IRPCReturnOf, IRPCSchema, IRPCSpec, IRPCSpecStore, IRPCStatus, IRPCStreamInit, IRPCStub, IRPCStubStore, StreamCleanup, StreamConstructor, TransportConfig } from "./types.js";
|
|
10
|
+
import { IRPCCrudDriver, IRPCDriver } from "./driver.js";
|
|
11
|
+
import { IRPCAdapter, IRPCCrudAdapter } from "./adapter.js";
|
|
11
12
|
import { IRPCCacheEntry, IRPCCacher } from "./cache.js";
|
|
12
13
|
import { createContext, createContextStore, getAbortController, getAbortSignal, getContext, setContext, setContextProvider, withContext } from "./context.js";
|
|
13
14
|
import { createCredentials, credential, getCredentials } from "./credential.js";
|
|
@@ -17,4 +18,4 @@ import { IRPCHook, IRPCRouter } from "./router.js";
|
|
|
17
18
|
import { IRPCStream } from "./stream.js";
|
|
18
19
|
import { IRPCStore, IRPCStoreEvent, IRPCStoreSubscriber, IRPC_STORE } from "./store.js";
|
|
19
20
|
import { plan } from "@anchorlib/core";
|
|
20
|
-
export { CALL_ERROR, CRUD_ERROR, CallError, CrudError, DEFAULT_RETRY_DELAY, DEFAULT_RETRY_MODE, HANDLER_ERROR, HOOK_ERROR, HandlerError, HookError, IRPCAdapter, IRPCArraySchema, IRPCBlob, IRPCBlobPointer, IRPCCacheEntry, IRPCCacher, IRPCCall, IRPCCallConfig, IRPCContext, IRPCContextProvider, IRPCCredentials, IRPCCredentialsFactory, IRPCCrudField, IRPCCrudMeta, IRPCCrudMethod, IRPCCrudOptions, IRPCCrudStubs, IRPCData, IRPCDataSchema, IRPCDeclareConfig, IRPCDeclareInit, IRPCDefined, IRPCDriver, IRPCEntityId, IRPCError, IRPCErrorType, IRPCFile, IRPCFileMeta, IRPCFilePipe, IRPCFilePointer, IRPCFileQueue, IRPCFileState, IRPCFileStatus, IRPCFileStream, IRPCFileUnpipe, IRPCFunction, IRPCHandler, IRPCHook, IRPCHookArgs, IRPCInferInit, IRPCInit, IRPCInputs, IRPCObject, IRPCObjectSchema, IRPCOutput, IRPCPackage, IRPCPackageConfig, IRPCPackageInfo, IRPCPacketAnswer, IRPCPacketBase, IRPCPacketCall, IRPCPacketClose, IRPCPacketError, IRPCPacketEvent, IRPCPacketJson, IRPCPacketQueues, IRPCPacketStream, IRPCPacketType, IRPCParseResult, IRPCPayload, IRPCPrimitive, IRPCPrimitiveSchema, IRPCReadable, IRPCReader, IRPCRequest, IRPCRequests, IRPCResolver, IRPCResponse, IRPCReturnOf, IRPCRouter, IRPCSchema, IRPCSpec, IRPCSpecHook, IRPCSpecStore, IRPCStatus, IRPCStore, IRPCStoreEvent, IRPCStoreSubscriber, IRPCStream, IRPCStreamInit, IRPCStub, IRPCStubStore, IRPCTransport, IRPC_BASE_CONTEXT, IRPC_BLOB_IDENTIFIER, IRPC_ERROR_TYPE, IRPC_FILE_IDENTIFIER, IRPC_FILE_STATUS, IRPC_PACKET_TYPE, IRPC_STATUS, IRPC_STORE, IRPC_STORE_EVENT, PacketStream, RESOLVE_ERROR, RemoteState, ResolveError, STUB_ERROR, StreamCleanup, StreamConstructor, StubError, TRANSPORT_ERROR, TransportConfig, TransportError, createContext, createContextStore, createCredentials, createPackage, credential, decode, decodeBlobs, encode, encodeBlobs, getAbortController, getAbortSignal, getContext, getCredentials, intercept, isBlobPointer, isFilePointer, plan, setContext, setContextProvider, stream, withContext };
|
|
21
|
+
export { CALL_ERROR, CRUD_ERROR, CallError, CrudError, DEFAULT_RETRY_DELAY, DEFAULT_RETRY_MODE, HANDLER_ERROR, HOOK_ERROR, HandlerError, HookError, IRPCAdapter, IRPCArraySchema, IRPCBlob, IRPCBlobPointer, IRPCCacheEntry, IRPCCacher, IRPCCall, IRPCCallConfig, IRPCContext, IRPCContextProvider, IRPCCredentials, IRPCCredentialsFactory, IRPCCrudAdapter, IRPCCrudDriver, IRPCCrudField, IRPCCrudMeta, IRPCCrudMethod, IRPCCrudOptions, IRPCCrudStubs, IRPCData, IRPCDataSchema, IRPCDeclareConfig, IRPCDeclareInit, IRPCDefined, IRPCDriver, IRPCEntityId, IRPCError, IRPCErrorType, IRPCFile, IRPCFileMeta, IRPCFilePipe, IRPCFilePointer, IRPCFileQueue, IRPCFileState, IRPCFileStatus, IRPCFileStream, IRPCFileUnpipe, IRPCFunction, IRPCHandler, IRPCHook, IRPCHookArgs, IRPCInferInit, IRPCInit, IRPCInputs, IRPCMeta, IRPCObject, IRPCObjectSchema, IRPCOutput, IRPCPackage, IRPCPackageConfig, IRPCPackageInfo, IRPCPacketAnswer, IRPCPacketBase, IRPCPacketCall, IRPCPacketClose, IRPCPacketError, IRPCPacketEvent, IRPCPacketJson, IRPCPacketQueues, IRPCPacketStream, IRPCPacketType, IRPCParseResult, IRPCPayload, IRPCPrimitive, IRPCPrimitiveSchema, IRPCReadable, IRPCReader, IRPCRequest, IRPCRequests, IRPCResolver, IRPCResponse, IRPCReturnOf, IRPCRouter, IRPCSchema, IRPCSpec, IRPCSpecHook, IRPCSpecStore, IRPCStatus, IRPCStore, IRPCStoreEvent, IRPCStoreSubscriber, IRPCStream, IRPCStreamInit, IRPCStub, IRPCStubStore, IRPCTransport, IRPC_BASE_CONTEXT, IRPC_BLOB_IDENTIFIER, IRPC_ERROR_TYPE, IRPC_FILE_IDENTIFIER, IRPC_FILE_STATUS, IRPC_PACKET_TYPE, IRPC_STATUS, IRPC_STORE, IRPC_STORE_EVENT, PacketStream, RESOLVE_ERROR, RemoteState, ResolveError, STUB_ERROR, StreamCleanup, StreamConstructor, StubError, TRANSPORT_ERROR, TransportConfig, TransportError, createContext, createContextStore, createCredentials, createPackage, credential, decode, decodeBlobs, encode, encodeBlobs, getAbortController, getAbortSignal, getContext, getCredentials, intercept, isBlobPointer, isFilePointer, plan, setContext, setContextProvider, stream, withContext };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CALL_ERROR, CRUD_ERROR, CallError, CrudError, HANDLER_ERROR, HOOK_ERROR, HandlerError, HookError, IRPCError, IRPC_ERROR_TYPE, RESOLVE_ERROR, ResolveError, STUB_ERROR, StubError, TRANSPORT_ERROR, TransportError } from "./error.js";
|
|
2
|
-
import { IRPCAdapter } from "./adapter.js";
|
|
2
|
+
import { IRPCAdapter, IRPCCrudAdapter } from "./adapter.js";
|
|
3
3
|
import { IRPCCacher } from "./cache.js";
|
|
4
4
|
import { IRPC_BASE_CONTEXT, IRPC_FILE_STATUS, IRPC_PACKET_TYPE, IRPC_STATUS, IRPC_STORE_EVENT } from "./enum.js";
|
|
5
5
|
import { createContext, createContextStore, getAbortController, getAbortSignal, getContext, setContext, setContextProvider, withContext } from "./context.js";
|
|
@@ -14,8 +14,8 @@ import { IRPCStream } from "./stream.js";
|
|
|
14
14
|
import { IRPCStore, IRPC_STORE } from "./store.js";
|
|
15
15
|
import { DEFAULT_RETRY_DELAY, DEFAULT_RETRY_MODE, IRPCCall } from "./call.js";
|
|
16
16
|
import { createCredentials, credential, getCredentials } from "./credential.js";
|
|
17
|
+
import { IRPCCrudDriver } from "./driver.js";
|
|
17
18
|
import { IRPCResolver } from "./resolver.js";
|
|
18
|
-
import { IRPCDriver } from "./types.js";
|
|
19
19
|
import { plan } from "@anchorlib/core";
|
|
20
20
|
|
|
21
|
-
export { CALL_ERROR, CRUD_ERROR, CallError, CrudError, DEFAULT_RETRY_DELAY, DEFAULT_RETRY_MODE, HANDLER_ERROR, HOOK_ERROR, HandlerError, HookError, IRPCAdapter, IRPCBlob, IRPCCacher, IRPCCall,
|
|
21
|
+
export { CALL_ERROR, CRUD_ERROR, CallError, CrudError, DEFAULT_RETRY_DELAY, DEFAULT_RETRY_MODE, HANDLER_ERROR, HOOK_ERROR, HandlerError, HookError, IRPCAdapter, IRPCBlob, IRPCCacher, IRPCCall, IRPCCrudAdapter, IRPCCrudDriver, IRPCError, IRPCFile, IRPCFileStream, IRPCPackage, IRPCReader, IRPCResolver, IRPCRouter, IRPCStore, IRPCStream, IRPCTransport, IRPC_BASE_CONTEXT, IRPC_BLOB_IDENTIFIER, IRPC_ERROR_TYPE, IRPC_FILE_IDENTIFIER, IRPC_FILE_STATUS, IRPC_PACKET_TYPE, IRPC_STATUS, IRPC_STORE, IRPC_STORE_EVENT, RESOLVE_ERROR, RemoteState, ResolveError, STUB_ERROR, StubError, TRANSPORT_ERROR, TransportError, createContext, createContextStore, createCredentials, createPackage, credential, decode, decodeBlobs, encode, encodeBlobs, getAbortController, getAbortSignal, getContext, getCredentials, intercept, isBlobPointer, isFilePointer, plan, setContext, setContextProvider, stream, withContext };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IRPCTransport } from "./transport.js";
|
|
2
|
-
import { IRPCCrudMethod, IRPCCrudOptions, IRPCCrudStubs, IRPCData, IRPCDeclareConfig, IRPCDeclareInit, IRPCFunction, IRPCHandler, IRPCInferInit, IRPCInputs, IRPCObject, IRPCOutput, IRPCPackageConfig, IRPCPackageInfo, IRPCRequest, IRPCReturnOf, IRPCSpec, IRPCStub } from "./types.js";
|
|
3
1
|
import { RemoteState } from "./state.js";
|
|
4
2
|
import { IRPCReader } from "./reader.js";
|
|
3
|
+
import { IRPCTransport } from "./transport.js";
|
|
4
|
+
import { IRPCCrudMethod, IRPCCrudOptions, IRPCCrudStubs, IRPCData, IRPCDeclareConfig, IRPCDeclareInit, IRPCFunction, IRPCHandler, IRPCInferInit, IRPCInputs, IRPCObject, IRPCOutput, IRPCPackageConfig, IRPCPackageInfo, IRPCRequest, IRPCReturnOf, IRPCSpec, IRPCStub } from "./types.js";
|
|
5
5
|
|
|
6
6
|
//#region src/module.d.ts
|
|
7
7
|
type IRPCHookArgs<F$1> = F$1 extends ((...args: infer A) => unknown) ? {
|
package/dist/reader.d.ts
CHANGED
package/dist/resolver.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IRPCDataSchema, IRPCInputs, IRPCOutput, IRPCRequest, IRPCResponse, IRPCSpec } from "./types.js";
|
|
2
1
|
import { IRPCPackage } from "./module.js";
|
|
2
|
+
import { IRPCDataSchema, IRPCInputs, IRPCOutput, IRPCRequest, IRPCResponse, IRPCSpec } from "./types.js";
|
|
3
3
|
|
|
4
4
|
//#region src/resolver.d.ts
|
|
5
5
|
|
package/dist/router.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { IRPCPackage } from "./module.js";
|
|
1
2
|
import { IRPCTransport } from "./transport.js";
|
|
2
3
|
import { IRPCPacketError, IRPCRequest } from "./types.js";
|
|
3
|
-
import { IRPCPackage } from "./module.js";
|
|
4
4
|
|
|
5
5
|
//#region src/router.d.ts
|
|
6
6
|
type IRPCHook = () => void | Promise<void>;
|
package/dist/store.d.ts
CHANGED
package/dist/transport.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IRPCCall } from "./call.js";
|
|
2
|
-
import { IRPCCallConfig, IRPCCredentials, IRPCCredentialsFactory, IRPCData, IRPCInputs, IRPCOutput, IRPCSpec, TransportConfig } from "./types.js";
|
|
3
1
|
import { IRPCReader } from "./reader.js";
|
|
2
|
+
import { IRPCCall } from "./call.js";
|
|
4
3
|
import { IRPCPackage } from "./module.js";
|
|
4
|
+
import { IRPCCallConfig, IRPCCredentials, IRPCCredentialsFactory, IRPCData, IRPCInputs, IRPCOutput, IRPCSpec, TransportConfig } from "./types.js";
|
|
5
5
|
|
|
6
6
|
//#region src/transport.d.ts
|
|
7
7
|
|
package/dist/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IRPC_PACKET_TYPE, IRPC_STATUS } from "./enum.js";
|
|
2
2
|
import { IRPCBlob, IRPCFile } from "./file.js";
|
|
3
3
|
import { IRPCFilePointer } from "./packet.js";
|
|
4
|
-
import { IRPCTransport } from "./transport.js";
|
|
5
4
|
import { RemoteState } from "./state.js";
|
|
6
5
|
import { IRPCReader } from "./reader.js";
|
|
6
|
+
import { IRPCTransport } from "./transport.js";
|
|
7
7
|
import { AsyncValue, StateChange } from "@anchorlib/core";
|
|
8
|
-
import { ZodArray, ZodBoolean, ZodNull, ZodNumber, ZodObject, ZodSafeParseResult, ZodString, ZodUndefined } from "zod/v4";
|
|
8
|
+
import { ZodArray, ZodBoolean, ZodCustom, ZodNull, ZodNumber, ZodObject, ZodOptional, ZodSafeParseResult, ZodString, ZodUndefined } from "zod/v4";
|
|
9
9
|
|
|
10
10
|
//#region src/types.d.ts
|
|
11
11
|
|
|
@@ -123,7 +123,7 @@ type IRPCDefined = string | number | boolean | IRPCObject | IRPCFile | IRPCBlob
|
|
|
123
123
|
/**
|
|
124
124
|
* Union type of all primitive Zod schema types used for validation.
|
|
125
125
|
*/
|
|
126
|
-
type IRPCPrimitiveSchema = ZodString | ZodNumber | ZodBoolean | ZodNull | ZodUndefined;
|
|
126
|
+
type IRPCPrimitiveSchema = ZodString | ZodNumber | ZodBoolean | ZodNull | ZodUndefined | ZodOptional | ZodCustom;
|
|
127
127
|
/**
|
|
128
128
|
* Zod object schema type used for validating structured data.
|
|
129
129
|
*/
|
|
@@ -295,7 +295,7 @@ type IRPCCrudStubs<T extends IRPCObject, K$1 extends string, I extends IRPCObjec
|
|
|
295
295
|
* Per-method resolved metadata — discriminated fields flattened,
|
|
296
296
|
* method-specific options applied. Passed to driver on every call.
|
|
297
297
|
*/
|
|
298
|
-
type
|
|
298
|
+
type IRPCMeta = {
|
|
299
299
|
/** Entity/table name. */
|
|
300
300
|
name: string;
|
|
301
301
|
/** Primary key field name. */
|
|
@@ -307,15 +307,7 @@ type IRPCCrudMeta = {
|
|
|
307
307
|
maxAge?: number;
|
|
308
308
|
coalesce?: boolean;
|
|
309
309
|
} & IRPCCallConfig;
|
|
310
|
-
|
|
311
|
-
* Base class for CRUD drivers that receive per-method resolved metadata on every call
|
|
312
|
-
*/
|
|
313
|
-
declare abstract class IRPCDriver {
|
|
314
|
-
get?(meta: IRPCCrudMeta, id: IRPCData): Promise<IRPCData> | IRPCData;
|
|
315
|
-
create?(meta: IRPCCrudMeta, data: IRPCData): Promise<IRPCData> | IRPCData;
|
|
316
|
-
update?(meta: IRPCCrudMeta, id: IRPCData, data: IRPCData): Promise<IRPCData> | IRPCData;
|
|
317
|
-
delete?(meta: IRPCCrudMeta, id: IRPCData): Promise<IRPCData> | IRPCData;
|
|
318
|
-
}
|
|
310
|
+
type IRPCCrudMeta = IRPCMeta;
|
|
319
311
|
/**
|
|
320
312
|
* Complete specification for an RPC function including its implementation.
|
|
321
313
|
* Extends IRPCInit with the actual handler function.
|
|
@@ -419,4 +411,4 @@ type StreamCleanup = () => void;
|
|
|
419
411
|
*/
|
|
420
412
|
type StreamConstructor<T> = (state: IRPCReadable<T>, resolve: (value?: T) => void, reject: (error: Error) => void) => StreamCleanup | void | Promise<StreamCleanup | void>;
|
|
421
413
|
//#endregion
|
|
422
|
-
export { IRPCArraySchema, IRPCCallConfig, IRPCContext, IRPCContextProvider, IRPCCredentials, IRPCCredentialsFactory, IRPCCrudField, IRPCCrudMeta, IRPCCrudMethod, IRPCCrudOptions, IRPCCrudStubs, IRPCData, IRPCDataSchema, IRPCDeclareConfig, IRPCDeclareInit, IRPCDefined,
|
|
414
|
+
export { IRPCArraySchema, IRPCCallConfig, IRPCContext, IRPCContextProvider, IRPCCredentials, IRPCCredentialsFactory, IRPCCrudField, IRPCCrudMeta, IRPCCrudMethod, IRPCCrudOptions, IRPCCrudStubs, IRPCData, IRPCDataSchema, IRPCDeclareConfig, IRPCDeclareInit, IRPCDefined, IRPCEntityId, IRPCFunction, IRPCHandler, IRPCInferInit, IRPCInit, IRPCInputs, IRPCMeta, IRPCObject, IRPCObjectSchema, IRPCOutput, IRPCPackageConfig, IRPCPackageInfo, IRPCPacketAnswer, IRPCPacketBase, IRPCPacketCall, IRPCPacketClose, IRPCPacketError, IRPCPacketEvent, IRPCPacketStream, IRPCPacketType, IRPCParseResult, IRPCPayload, IRPCPrimitive, IRPCPrimitiveSchema, IRPCReadable, IRPCRequest, IRPCRequests, IRPCResponse, IRPCReturnOf, IRPCSchema, IRPCSpec, IRPCSpecStore, IRPCStatus, IRPCStreamInit, IRPCStub, IRPCStubStore, StreamCleanup, StreamConstructor, TransportConfig };
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@irpclib/irpc",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.6",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"zod": "^4.1.5"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@anchorlib/core": "1.2.
|
|
39
|
+
"@anchorlib/core": "1.2.6",
|
|
40
40
|
"typescript": "^5.9.3"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|