@feasibleone/blong 1.17.0 → 1.18.0
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/CHANGELOG.md +13 -0
- package/dist/types.d.ts +94 -86
- package/dist/types.js +18 -7
- package/dist/types.js.map +1 -1
- package/package.json +2 -1
- package/types.ts +162 -99
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.18.0](https://github.com/feasibleone/blong/compare/blong-v1.17.0...blong-v1.18.0) (2026-04-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* rename blong-int-sql → blong-int-adapter with full adapter integration test suite ([#135](https://github.com/feasibleone/blong/issues/135)) ([ee2b0f6](https://github.com/feasibleone/blong/commit/ee2b0f64b181f787a71c404e08fd62959a7f0e8e))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* type errors ([2f105bd](https://github.com/feasibleone/blong/commit/2f105bd3546b30ad1505ccde63ba43f3ccd575a8))
|
|
14
|
+
* type errors ([#133](https://github.com/feasibleone/blong/issues/133)) ([5b33e54](https://github.com/feasibleone/blong/commit/5b33e54b6b57eb561748a72f400a48f70af7f311))
|
|
15
|
+
|
|
3
16
|
## [1.17.0](https://github.com/feasibleone/blong/compare/blong-v1.16.1...blong-v1.17.0) (2026-04-26)
|
|
4
17
|
|
|
5
18
|
|
package/dist/types.d.ts
CHANGED
|
@@ -17968,37 +17968,32 @@ export interface IGateway {
|
|
|
17968
17968
|
export type Handlers = ((params: {
|
|
17969
17969
|
remote: unknown;
|
|
17970
17970
|
lib: object;
|
|
17971
|
-
port: object;
|
|
17971
|
+
port: object | undefined;
|
|
17972
17972
|
local: object;
|
|
17973
17973
|
literals: object[];
|
|
17974
17974
|
gateway: IGateway;
|
|
17975
17975
|
apiSchema: IApiSchema;
|
|
17976
|
+
attachCheckpoint?: (meta: IMeta) => void;
|
|
17976
17977
|
}) => void)[];
|
|
17977
17978
|
export interface IRegistry {
|
|
17978
|
-
start: (configOverride
|
|
17979
|
+
start: (configOverride: object) => Promise<IRegistry>;
|
|
17979
17980
|
test: (tester?: unknown) => Promise<void>;
|
|
17980
17981
|
stop: () => Promise<IRegistry>;
|
|
17981
|
-
ports: Map<string,
|
|
17982
|
+
ports: Map<string, IAdapterRegistry>;
|
|
17982
17983
|
methods: Map<string, Handlers>;
|
|
17983
17984
|
modules: Map<string | symbol, IRegistry[]>;
|
|
17984
|
-
createPort: (id: string) => Promise<
|
|
17985
|
-
getPort: (id: string) =>
|
|
17986
|
-
replaceHandlers: (id: string, handlers:
|
|
17985
|
+
createPort: (id: string) => Promise<Adapter | undefined>;
|
|
17986
|
+
getPort: (id: string) => Adapter | undefined;
|
|
17987
|
+
replaceHandlers: (id: string, handlers: Handlers) => Promise<void>;
|
|
17987
17988
|
loadApi: (id: string, def: {
|
|
17988
17989
|
namespace: Record<string, string | string[]>;
|
|
17989
|
-
}, source
|
|
17990
|
+
}, source: string) => Promise<void>;
|
|
17990
17991
|
connected: () => Promise<boolean>;
|
|
17991
17992
|
}
|
|
17992
17993
|
export interface IApi {
|
|
17993
17994
|
id?: string;
|
|
17994
17995
|
type: typeof Type;
|
|
17995
|
-
adapter: (id: string) =>
|
|
17996
|
-
utError: IError;
|
|
17997
|
-
remote: IRemote;
|
|
17998
|
-
rpc: IRpcServer;
|
|
17999
|
-
local: ILocal;
|
|
18000
|
-
registry: IRegistry;
|
|
18001
|
-
}) => object;
|
|
17996
|
+
adapter: (id: string) => IAdapterRegistry | undefined;
|
|
18002
17997
|
utError: IError;
|
|
18003
17998
|
errors: IErrorFactory;
|
|
18004
17999
|
gateway: unknown;
|
|
@@ -18018,7 +18013,13 @@ export interface IApi {
|
|
|
18018
18013
|
methodId: (name: string) => string;
|
|
18019
18014
|
getPath: (name: string) => string;
|
|
18020
18015
|
importMethod: (methodName: string, options?: object) => (...params: unknown[]) => Promise<unknown>;
|
|
18021
|
-
attachHandlers: (target:
|
|
18016
|
+
attachHandlers: (target: {
|
|
18017
|
+
importedMap?: Map<string, object>;
|
|
18018
|
+
imported: object;
|
|
18019
|
+
config: {
|
|
18020
|
+
namespace?: string | string[];
|
|
18021
|
+
};
|
|
18022
|
+
}, patterns: (string | RegExp)[] | string | RegExp, adapter?: boolean) => unknown;
|
|
18022
18023
|
createLog: ILog["logger"];
|
|
18023
18024
|
attachCheckpoint?: (meta: IMeta) => void;
|
|
18024
18025
|
handlers?: (api: {
|
|
@@ -18042,6 +18043,7 @@ export interface IErrorMap {
|
|
|
18042
18043
|
statusCode?: number;
|
|
18043
18044
|
};
|
|
18044
18045
|
}
|
|
18046
|
+
export type Adapter<T = Record<string, unknown>, C = Record<string, unknown>> = IAdapter<T, C> & Pick<Required<IAdapter<T, C>>, "init" | "start" | "stop" | "ready" | "config" | "imported" | "errors" | "error" | "findValidation" | "getConversion" | "dispatch">;
|
|
18045
18047
|
export interface IAdapter<T, C> {
|
|
18046
18048
|
validation?: TSchema;
|
|
18047
18049
|
config?: Config<T, C>;
|
|
@@ -18049,55 +18051,50 @@ export interface IAdapter<T, C> {
|
|
|
18049
18051
|
configBase?: string;
|
|
18050
18052
|
log?: ILogger;
|
|
18051
18053
|
errors?: Errors<IErrorMap>;
|
|
18052
|
-
imported?:
|
|
18054
|
+
imported?: Record<string, PortHandlerBound>;
|
|
18053
18055
|
importedMap?: Map<string, IRemoteHandler>;
|
|
18054
18056
|
extends?: object | `adapter.${string}` | `orchestrator.${string}`;
|
|
18055
|
-
activeConfig
|
|
18056
|
-
init
|
|
18057
|
-
start
|
|
18058
|
-
ready
|
|
18059
|
-
stop
|
|
18060
|
-
|
|
18061
|
-
|
|
18062
|
-
|
|
18063
|
-
|
|
18064
|
-
|
|
18065
|
-
|
|
18066
|
-
|
|
18067
|
-
|
|
18068
|
-
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
|
|
18072
|
-
|
|
18073
|
-
|
|
18074
|
-
|
|
18075
|
-
|
|
18076
|
-
|
|
18077
|
-
|
|
18078
|
-
|
|
18079
|
-
getConversion?: (this: ReturnType<IAdapterFactory<T, C>>, $meta: IMeta, type: "send" | "receive") => {
|
|
18057
|
+
activeConfig?(this: Adapter<T, C>): Partial<Config<T, C>>;
|
|
18058
|
+
init?(this: Adapter<T, C>, ...config: unknown[]): Promise<unknown>;
|
|
18059
|
+
start?(this: Adapter<T, C>, ...params: unknown[]): Promise<unknown>;
|
|
18060
|
+
ready?(this: Adapter<T, C>): Promise<unknown>;
|
|
18061
|
+
stop?(this: Adapter<T, C>, ...params: unknown[]): Promise<unknown>;
|
|
18062
|
+
link?(this: Adapter<T, C>, patterns: (string | RegExp)[] | string | RegExp, target: object): Promise<{
|
|
18063
|
+
importedMap?: Map<string, object>;
|
|
18064
|
+
imported?: object;
|
|
18065
|
+
config?: {
|
|
18066
|
+
namespace?: string | string[];
|
|
18067
|
+
};
|
|
18068
|
+
}>;
|
|
18069
|
+
connected?(this: Adapter<T, C>): Promise<boolean>;
|
|
18070
|
+
error?(error: unknown, $meta: unknown): void;
|
|
18071
|
+
pack?(this: Adapter<T, C>, ...params: unknown[]): unknown;
|
|
18072
|
+
unpackSize?(this: Adapter<T, C>, ...params: unknown[]): unknown;
|
|
18073
|
+
unpack?(this: Adapter<T, C>, ...params: unknown[]): unknown;
|
|
18074
|
+
encode?(data: unknown, $meta: unknown, context: unknown, log: unknown): Promise<string | Buffer>;
|
|
18075
|
+
decode?(buff: string | Buffer, $meta: unknown, context: unknown, log: unknown): Promise<object[]>;
|
|
18076
|
+
request?(...params: unknown[]): Promise<unknown>;
|
|
18077
|
+
publish?(): Promise<unknown>;
|
|
18078
|
+
drain?(): void;
|
|
18079
|
+
findValidation?(this: Adapter<T, C>, $meta: unknown): (...params: unknown[]) => object;
|
|
18080
|
+
getConversion?(this: Adapter<T, C>, $meta: unknown, type: string): {
|
|
18080
18081
|
name: string;
|
|
18081
|
-
fn: () => object
|
|
18082
|
+
fn: (...params: unknown[]) => Promise<object>;
|
|
18082
18083
|
};
|
|
18083
|
-
findHandler
|
|
18084
|
-
handles
|
|
18085
|
-
forNamespaces
|
|
18086
|
-
methodPath
|
|
18087
|
-
dispatch
|
|
18088
|
-
exec
|
|
18089
|
-
bytesSent
|
|
18090
|
-
bytesReceived
|
|
18091
|
-
msgSent
|
|
18092
|
-
msgReceived
|
|
18084
|
+
findHandler?(this: Adapter<T, C>, name: string): () => unknown;
|
|
18085
|
+
handles?(this: Adapter<T, C>, name: string): boolean;
|
|
18086
|
+
forNamespaces?<U>(reducer: (prev: U, current: unknown) => U, initial: U): U;
|
|
18087
|
+
methodPath?(name: string): string;
|
|
18088
|
+
dispatch?(...params: unknown[]): Promise<unknown>;
|
|
18089
|
+
exec?(this: Adapter<T, C>, ...params: unknown[]): Promise<unknown>;
|
|
18090
|
+
bytesSent?(count: number): void;
|
|
18091
|
+
bytesReceived?(count: number): void;
|
|
18092
|
+
msgSent?(count: number): void;
|
|
18093
|
+
msgReceived?(count: number): void;
|
|
18093
18094
|
isConnected?: Promise<boolean>;
|
|
18094
|
-
event
|
|
18095
|
-
handle
|
|
18096
|
-
connect
|
|
18097
|
-
requests: unknown;
|
|
18098
|
-
waiting: unknown;
|
|
18099
|
-
buffer: unknown;
|
|
18100
|
-
}) => void;
|
|
18095
|
+
event?(name: string, params?: unknown): Promise<object>;
|
|
18096
|
+
handle?(...params: unknown[]): Promise<unknown>;
|
|
18097
|
+
connect?(what: unknown, context: unknown): void;
|
|
18101
18098
|
/**
|
|
18102
18099
|
* Optional lifecycle hook called when configuration changes.
|
|
18103
18100
|
* When present, the framework calls this instead of a full stop+start cycle.
|
|
@@ -18109,15 +18106,24 @@ export interface IAdapter<T, C> {
|
|
|
18109
18106
|
* @param next The full new effective config snapshot (via proxy)
|
|
18110
18107
|
* @param prev The full previous effective config snapshot
|
|
18111
18108
|
*/
|
|
18112
|
-
configChanged
|
|
18113
|
-
|
|
18114
|
-
|
|
18115
|
-
}>, next: object, prev: object) => Promise<void>;
|
|
18109
|
+
configChanged?(this: Adapter<T, C>, diff: unknown, next: unknown, prev?: unknown): Promise<void>;
|
|
18110
|
+
/** Allow arbitrary extra methods on adapter definitions (e.g. authenticate) */
|
|
18111
|
+
[key: string]: unknown;
|
|
18116
18112
|
}
|
|
18117
18113
|
export interface IAdapterFactory<T = Record<string, unknown>, C = Record<string, unknown>> {
|
|
18118
18114
|
config?: Config<T, C> | false;
|
|
18119
18115
|
(api: IApi): IAdapter<T, C>;
|
|
18120
18116
|
}
|
|
18117
|
+
export interface IAdapterRegistry {
|
|
18118
|
+
config: unknown;
|
|
18119
|
+
(api: {
|
|
18120
|
+
utError: IError;
|
|
18121
|
+
remote: IRemote;
|
|
18122
|
+
rpc: IRpcServer;
|
|
18123
|
+
local: ILocal;
|
|
18124
|
+
registry: IRegistry;
|
|
18125
|
+
}): Promise<Adapter>;
|
|
18126
|
+
}
|
|
18121
18127
|
export interface IMeta {
|
|
18122
18128
|
mtid?: "request" | "response" | "error" | "notification" | "discard" | "event";
|
|
18123
18129
|
request?: IMeta;
|
|
@@ -18129,7 +18135,7 @@ export interface IMeta {
|
|
|
18129
18135
|
expect?: string[] | string;
|
|
18130
18136
|
opcode?: string;
|
|
18131
18137
|
source?: string;
|
|
18132
|
-
forward?:
|
|
18138
|
+
forward?: Record<string, string>;
|
|
18133
18139
|
httpResponse?: {
|
|
18134
18140
|
type?: string;
|
|
18135
18141
|
redirect?: string;
|
|
@@ -18178,14 +18184,14 @@ export interface IMeta {
|
|
|
18178
18184
|
deviceId?: string | string[];
|
|
18179
18185
|
latitude?: string | string[];
|
|
18180
18186
|
longitude?: string | string[];
|
|
18181
|
-
conId?: number;
|
|
18187
|
+
conId?: string | number;
|
|
18182
18188
|
dispatch?: (msg?: object, $meta?: IMeta) => [
|
|
18183
18189
|
msg: object,
|
|
18184
18190
|
$meta: IMeta
|
|
18185
18191
|
] | boolean | void | Promise<boolean>;
|
|
18186
18192
|
reply?: unknown;
|
|
18187
|
-
timeout?:
|
|
18188
|
-
timer?: (name?: string, newTime?: HRTime |
|
|
18193
|
+
timeout?: HRTime;
|
|
18194
|
+
timer?: (name?: string, newTime?: HRTime | undefined) => {
|
|
18189
18195
|
[name: string]: number;
|
|
18190
18196
|
};
|
|
18191
18197
|
gateway?: object;
|
|
@@ -18199,19 +18205,19 @@ export interface IMeta {
|
|
|
18199
18205
|
}>;
|
|
18200
18206
|
}
|
|
18201
18207
|
export interface IContext {
|
|
18202
|
-
trace: number;
|
|
18203
18208
|
session?: {
|
|
18204
18209
|
[name: string]: unknown;
|
|
18205
18210
|
};
|
|
18206
|
-
conId?: string;
|
|
18211
|
+
conId?: string | number;
|
|
18207
18212
|
requests: Map<string, {
|
|
18208
18213
|
$meta: IMeta;
|
|
18209
|
-
end
|
|
18214
|
+
end?: (error: Error) => {
|
|
18210
18215
|
local: object;
|
|
18211
18216
|
literals: object[];
|
|
18212
18217
|
};
|
|
18213
18218
|
}>;
|
|
18214
18219
|
waiting: Set<(error: Error) => void>;
|
|
18220
|
+
buffer?: Buffer;
|
|
18215
18221
|
}
|
|
18216
18222
|
export interface ITypedError extends Error {
|
|
18217
18223
|
type: string;
|
|
@@ -18265,7 +18271,7 @@ export interface IModuleConfig<T extends TSchema = TNever> {
|
|
|
18265
18271
|
url: string;
|
|
18266
18272
|
config?: IActivationConfig<Partial<Static<T>> & Partial<Static<IBaseConfig>>>;
|
|
18267
18273
|
validation?: T;
|
|
18268
|
-
children?: (string | (() => Promise<object>))[] | ((layer: ModuleApi) => unknown)[]
|
|
18274
|
+
children?: (string | (() => Promise<object>))[] | ((layer: ModuleApi) => unknown)[] | Record<string, () => Promise<unknown>>;
|
|
18269
18275
|
glob?: Record<string, () => Promise<object>>;
|
|
18270
18276
|
}
|
|
18271
18277
|
export interface ILogger {
|
|
@@ -18366,8 +18372,10 @@ export type ApiDefinition = (blong: IValidationProxy) => {
|
|
|
18366
18372
|
} | {
|
|
18367
18373
|
url: string;
|
|
18368
18374
|
};
|
|
18369
|
-
export type PortHandler<T, C> = <R>(this:
|
|
18370
|
-
export type PortHandlerBound = <T>(params:
|
|
18375
|
+
export type PortHandler<T, C> = <R>(this: Adapter<T, C>, params: object, $meta: IMeta, context?: IContext) => Promise<R> | R;
|
|
18376
|
+
export type PortHandlerBound = (<T>(params: object, $meta: IMeta, context?: IContext) => Promise<T> | T) & {
|
|
18377
|
+
[name: string]: PortHandlerBound;
|
|
18378
|
+
};
|
|
18371
18379
|
export type LibFn = <T>(...params: unknown[]) => T;
|
|
18372
18380
|
export interface IRemoteHandler {
|
|
18373
18381
|
[name: string]: PortHandlerBound;
|
|
@@ -18430,11 +18438,11 @@ export declare abstract class Internal {
|
|
|
18430
18438
|
#private;
|
|
18431
18439
|
protected log?: ReturnType<ILog["logger"]>;
|
|
18432
18440
|
constructor(api?: {
|
|
18433
|
-
log
|
|
18441
|
+
log?: ILog;
|
|
18434
18442
|
});
|
|
18435
18443
|
protected merge: ILib["merge"];
|
|
18436
18444
|
stop(): Promise<unknown>;
|
|
18437
|
-
start(...
|
|
18445
|
+
start(..._args: unknown[]): Promise<unknown>;
|
|
18438
18446
|
}
|
|
18439
18447
|
export declare const handler: <T = Record<string, unknown>, C = AdapterContext>(definition: Definition<T, C>) => Definition<T, C>;
|
|
18440
18448
|
/**
|
|
@@ -18496,12 +18504,12 @@ export declare const fixture: <T extends IMock>(definition: () => T) => (() => T
|
|
|
18496
18504
|
export declare const validationHandlers: (handlers: Record<string, TFunction<[
|
|
18497
18505
|
ApiSchema
|
|
18498
18506
|
]>>) => ValidationDefinition;
|
|
18499
|
-
export declare const realm: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T
|
|
18500
|
-
export declare const server: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T
|
|
18501
|
-
export declare const browser: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T
|
|
18502
|
-
export declare const layer: (activation: Record<string, boolean | object>) => Record<string, boolean | object
|
|
18503
|
-
export declare const adapter: <T, C = AdapterContext>(definition: IAdapterFactory<T, C>) => IAdapterFactory<T, C
|
|
18504
|
-
export declare const orchestrator: <T, C = AdapterContext>(definition: IAdapterFactory<T, C>) => IAdapterFactory<T, C
|
|
18507
|
+
export declare const realm: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T> & {};
|
|
18508
|
+
export declare const server: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T> & {};
|
|
18509
|
+
export declare const browser: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T> & {};
|
|
18510
|
+
export declare const layer: (activation: Record<string, boolean | object>) => Record<string, boolean | object> & {};
|
|
18511
|
+
export declare const adapter: <T, C = AdapterContext>(definition: IAdapterFactory<T, C>) => IAdapterFactory<T, C> & {};
|
|
18512
|
+
export declare const orchestrator: <T, C = AdapterContext>(definition: IAdapterFactory<T, C>) => IAdapterFactory<T, C> & {};
|
|
18505
18513
|
export type Kinds = "lib" | "validation" | "api" | "solution" | "server" | "browser" | "adapter" | "orchestrator" | "handler" | "model" | "fixture" | "";
|
|
18506
18514
|
export declare const kind: (what: {}) => Kinds;
|
|
18507
18515
|
declare const _default: {
|
|
@@ -18510,11 +18518,11 @@ declare const _default: {
|
|
|
18510
18518
|
library: <T = Record<string, unknown>>(definition: Lib<T>) => Lib<T>;
|
|
18511
18519
|
validation: (validation: ValidationDefinition) => ValidationDefinition;
|
|
18512
18520
|
api: (api: ApiDefinition) => ApiDefinition;
|
|
18513
|
-
realm: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T
|
|
18514
|
-
server: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T
|
|
18515
|
-
browser: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T
|
|
18516
|
-
adapter: <T, C = AdapterContext>(definition: IAdapterFactory<T, C>) => IAdapterFactory<T, C
|
|
18517
|
-
orchestrator: <T, C = AdapterContext>(definition: IAdapterFactory<T, C>) => IAdapterFactory<T, C
|
|
18521
|
+
realm: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T> & {};
|
|
18522
|
+
server: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T> & {};
|
|
18523
|
+
browser: <T extends TObject>(definition: SolutionFactory<T>) => SolutionFactory<T> & {};
|
|
18524
|
+
adapter: <T, C = AdapterContext>(definition: IAdapterFactory<T, C>) => IAdapterFactory<T, C> & {};
|
|
18525
|
+
orchestrator: <T, C = AdapterContext>(definition: IAdapterFactory<T, C>) => IAdapterFactory<T, C> & {};
|
|
18518
18526
|
fixture: <T extends IMock>(definition: () => T) => (() => T);
|
|
18519
18527
|
kind: (what: {}) => Kinds;
|
|
18520
18528
|
};
|
package/dist/types.js
CHANGED
|
@@ -16,7 +16,8 @@ export class Internal {
|
|
|
16
16
|
async stop() {
|
|
17
17
|
return this;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
+
async start(..._args) {
|
|
20
21
|
return this;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
@@ -40,7 +41,7 @@ export const handler = (definition) => Object.defineProperty(definition, Kind, {
|
|
|
40
41
|
* });
|
|
41
42
|
* ```
|
|
42
43
|
*/
|
|
43
|
-
export const defineActions = (actions) => Object.defineProperty((
|
|
44
|
+
export const defineActions = (actions) => Object.defineProperty(() => Object.fromEntries(Object.entries(actions).map(([key, value]) => [key, () => value])), Kind, { value: 'handler' });
|
|
44
45
|
export const library = (definition) => Object.defineProperty(definition, Kind, { value: 'lib' });
|
|
45
46
|
export const validation = (validation) => Object.defineProperty(validation, Kind, { value: 'validation' });
|
|
46
47
|
export const api = (api) => Object.defineProperty(api, Kind, { value: 'api' });
|
|
@@ -54,12 +55,22 @@ export const validationHandlers = handlers => validation(() => Object.fromEntrie
|
|
|
54
55
|
description: 'description' in handler ? handler.description : undefined,
|
|
55
56
|
}), 'name', { value: name }),
|
|
56
57
|
])));
|
|
57
|
-
export const realm = (definition) => Object.defineProperty(definition, Kind, {
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
export const realm = (definition) => Object.defineProperty(definition, Kind, {
|
|
59
|
+
value: 'solution',
|
|
60
|
+
});
|
|
61
|
+
export const server = (definition) => Object.defineProperty(definition, Kind, {
|
|
62
|
+
value: 'server',
|
|
63
|
+
});
|
|
64
|
+
export const browser = (definition) => Object.defineProperty(definition, Kind, {
|
|
65
|
+
value: 'browser',
|
|
66
|
+
});
|
|
60
67
|
export const layer = (activation) => Object.defineProperty(activation, Kind, { value: 'layer' });
|
|
61
|
-
export const adapter = (definition) => Object.defineProperty(definition, Kind, {
|
|
62
|
-
|
|
68
|
+
export const adapter = (definition) => Object.defineProperty(definition, Kind, {
|
|
69
|
+
value: 'adapter',
|
|
70
|
+
});
|
|
71
|
+
export const orchestrator = (definition) => Object.defineProperty(definition, Kind, {
|
|
72
|
+
value: 'orchestrator',
|
|
73
|
+
});
|
|
63
74
|
export const kind = (what) => what[Kind] || '';
|
|
64
75
|
export default {
|
|
65
76
|
handler,
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,IAAI,GAWP,MAAM,SAAS,CAAC;AAQjB,OAAO,KAAK,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,IAAI,GAWP,MAAM,SAAS,CAAC;AAQjB,OAAO,KAAK,MAAM,mBAAmB,CAAC;AA2wBtC,MAAM,IAAI,GAAW,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAG9C,MAAM,OAAgB,QAAQ;IAC1B,IAAI,CAAoB;IACd,GAAG,CAA8B;IAC3C,YAAmB,GAAkB;QACjC,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE,GAAG,C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AO;IACP,OAAO;IACP,YAAY;IACZ,OAAO;IACP,IAAI;CACP,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feasibleone/blong",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "API and DRY focused RAD framework https://feasibleone.github.io/blong-docs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"blong",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "heft build --clean;dts-bundle-generator --config dts-gen.config.json",
|
|
51
|
+
"ci-lint": "tsc --noEmit",
|
|
51
52
|
"ci-publish": "node ../../common/scripts/install-run-rush-pnpm.js publish --access public --provenance"
|
|
52
53
|
}
|
|
53
54
|
}
|
package/types.ts
CHANGED
|
@@ -266,29 +266,30 @@ export interface IGateway {
|
|
|
266
266
|
export type Handlers = ((params: {
|
|
267
267
|
remote: unknown;
|
|
268
268
|
lib: object;
|
|
269
|
-
port: object;
|
|
269
|
+
port: object | undefined;
|
|
270
270
|
local: object;
|
|
271
271
|
literals: object[];
|
|
272
272
|
gateway: IGateway;
|
|
273
273
|
apiSchema: IApiSchema;
|
|
274
|
+
attachCheckpoint?: (meta: IMeta) => void;
|
|
274
275
|
}) => void)[];
|
|
275
276
|
|
|
276
277
|
export interface IRegistry {
|
|
277
|
-
start: (configOverride
|
|
278
|
+
start: (configOverride: object) => Promise<IRegistry>;
|
|
278
279
|
test: (tester?: unknown) => Promise<void>;
|
|
279
280
|
stop: () => Promise<IRegistry>;
|
|
280
|
-
ports: Map<string,
|
|
281
|
+
ports: Map<string, IAdapterRegistry>;
|
|
281
282
|
methods: Map<string, Handlers>;
|
|
282
283
|
modules: Map<string | symbol, IRegistry[]>;
|
|
283
|
-
createPort: (id: string) => Promise<
|
|
284
|
-
getPort: (id: string) =>
|
|
285
|
-
replaceHandlers: (id: string, handlers:
|
|
284
|
+
createPort: (id: string) => Promise<Adapter | undefined>;
|
|
285
|
+
getPort: (id: string) => Adapter | undefined;
|
|
286
|
+
replaceHandlers: (id: string, handlers: Handlers) => Promise<void>;
|
|
286
287
|
loadApi: (
|
|
287
288
|
id: string,
|
|
288
289
|
def: {
|
|
289
290
|
namespace: Record<string, string | string[]>;
|
|
290
291
|
},
|
|
291
|
-
source
|
|
292
|
+
source: string,
|
|
292
293
|
) => Promise<void>;
|
|
293
294
|
connected: () => Promise<boolean>;
|
|
294
295
|
}
|
|
@@ -296,15 +297,7 @@ export interface IRegistry {
|
|
|
296
297
|
export interface IApi {
|
|
297
298
|
id?: string;
|
|
298
299
|
type: typeof Type;
|
|
299
|
-
adapter: (
|
|
300
|
-
id: string,
|
|
301
|
-
) => (api: {
|
|
302
|
-
utError: IError;
|
|
303
|
-
remote: IRemote;
|
|
304
|
-
rpc: IRpcServer;
|
|
305
|
-
local: ILocal;
|
|
306
|
-
registry: IRegistry;
|
|
307
|
-
}) => object;
|
|
300
|
+
adapter: (id: string) => IAdapterRegistry | undefined;
|
|
308
301
|
utError: IError;
|
|
309
302
|
errors: IErrorFactory;
|
|
310
303
|
gateway: unknown;
|
|
@@ -323,7 +316,15 @@ export interface IApi {
|
|
|
323
316
|
methodName: string,
|
|
324
317
|
options?: object,
|
|
325
318
|
) => (...params: unknown[]) => Promise<unknown>;
|
|
326
|
-
attachHandlers: (
|
|
319
|
+
attachHandlers: (
|
|
320
|
+
target: {
|
|
321
|
+
importedMap?: Map<string, object>;
|
|
322
|
+
imported: object;
|
|
323
|
+
config: {namespace?: string | string[]};
|
|
324
|
+
},
|
|
325
|
+
patterns: (string | RegExp)[] | string | RegExp,
|
|
326
|
+
adapter?: boolean,
|
|
327
|
+
) => unknown;
|
|
327
328
|
createLog: ILog['logger'];
|
|
328
329
|
attachCheckpoint?: (meta: IMeta) => void;
|
|
329
330
|
handlers?: (api: {utError: IError; remote: IRemote; type: typeof Type}) => {
|
|
@@ -349,6 +350,21 @@ export interface IErrorMap {
|
|
|
349
350
|
};
|
|
350
351
|
}
|
|
351
352
|
|
|
353
|
+
export type Adapter<T = Record<string, unknown>, C = Record<string, unknown>> = IAdapter<T, C> &
|
|
354
|
+
Pick<
|
|
355
|
+
Required<IAdapter<T, C>>,
|
|
356
|
+
| 'init'
|
|
357
|
+
| 'start'
|
|
358
|
+
| 'stop'
|
|
359
|
+
| 'ready'
|
|
360
|
+
| 'config'
|
|
361
|
+
| 'imported'
|
|
362
|
+
| 'errors'
|
|
363
|
+
| 'error'
|
|
364
|
+
| 'findValidation'
|
|
365
|
+
| 'getConversion'
|
|
366
|
+
| 'dispatch'
|
|
367
|
+
>;
|
|
352
368
|
export interface IAdapter<T, C> {
|
|
353
369
|
validation?: TSchema;
|
|
354
370
|
config?: Config<T, C>;
|
|
@@ -356,60 +372,63 @@ export interface IAdapter<T, C> {
|
|
|
356
372
|
configBase?: string;
|
|
357
373
|
log?: ILogger;
|
|
358
374
|
errors?: Errors<IErrorMap>;
|
|
359
|
-
imported?:
|
|
375
|
+
imported?: Record<string, PortHandlerBound>;
|
|
360
376
|
importedMap?: Map<string, IRemoteHandler>;
|
|
361
377
|
extends?: object | `adapter.${string}` | `orchestrator.${string}`;
|
|
362
|
-
activeConfig
|
|
363
|
-
init
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
)
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
unpack
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
)
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
378
|
+
activeConfig?(this: Adapter<T, C>): Partial<Config<T, C>>;
|
|
379
|
+
init?(this: Adapter<T, C>, ...config: unknown[]): Promise<unknown>;
|
|
380
|
+
start?(this: Adapter<T, C>, ...params: unknown[]): Promise<unknown>;
|
|
381
|
+
ready?(this: Adapter<T, C>): Promise<unknown>;
|
|
382
|
+
stop?(this: Adapter<T, C>, ...params: unknown[]): Promise<unknown>;
|
|
383
|
+
link?(
|
|
384
|
+
this: Adapter<T, C>,
|
|
385
|
+
patterns: (string | RegExp)[] | string | RegExp,
|
|
386
|
+
target: object,
|
|
387
|
+
): Promise<{
|
|
388
|
+
importedMap?: Map<string, object>;
|
|
389
|
+
imported?: object;
|
|
390
|
+
config?: {namespace?: string | string[]};
|
|
391
|
+
}>;
|
|
392
|
+
connected?(this: Adapter<T, C>): Promise<boolean>;
|
|
393
|
+
error?(error: unknown, $meta: unknown): void;
|
|
394
|
+
pack?(this: Adapter<T, C>, ...params: unknown[]): unknown;
|
|
395
|
+
unpackSize?(this: Adapter<T, C>, ...params: unknown[]): unknown;
|
|
396
|
+
unpack?(this: Adapter<T, C>, ...params: unknown[]): unknown;
|
|
397
|
+
encode?(
|
|
398
|
+
data: unknown,
|
|
399
|
+
$meta: unknown,
|
|
400
|
+
context: unknown,
|
|
401
|
+
log: unknown,
|
|
402
|
+
): Promise<string | Buffer>;
|
|
403
|
+
decode?(
|
|
404
|
+
buff: string | Buffer,
|
|
405
|
+
$meta: unknown,
|
|
406
|
+
context: unknown,
|
|
407
|
+
log: unknown,
|
|
408
|
+
): Promise<object[]>;
|
|
409
|
+
request?(...params: unknown[]): Promise<unknown>;
|
|
410
|
+
publish?(): Promise<unknown>;
|
|
411
|
+
drain?(): void;
|
|
412
|
+
findValidation?(this: Adapter<T, C>, $meta: unknown): (...params: unknown[]) => object;
|
|
413
|
+
getConversion?(
|
|
414
|
+
this: Adapter<T, C>,
|
|
415
|
+
$meta: unknown,
|
|
416
|
+
type: string,
|
|
417
|
+
): {name: string; fn: (...params: unknown[]) => Promise<object>};
|
|
418
|
+
findHandler?(this: Adapter<T, C>, name: string): () => unknown;
|
|
419
|
+
handles?(this: Adapter<T, C>, name: string): boolean;
|
|
420
|
+
forNamespaces?<U>(reducer: (prev: U, current: unknown) => U, initial: U): U;
|
|
421
|
+
methodPath?(name: string): string;
|
|
422
|
+
dispatch?(...params: unknown[]): Promise<unknown>;
|
|
423
|
+
exec?(this: Adapter<T, C>, ...params: unknown[]): Promise<unknown>;
|
|
424
|
+
bytesSent?(count: number): void;
|
|
425
|
+
bytesReceived?(count: number): void;
|
|
426
|
+
msgSent?(count: number): void;
|
|
427
|
+
msgReceived?(count: number): void;
|
|
406
428
|
isConnected?: Promise<boolean>;
|
|
407
|
-
event
|
|
408
|
-
handle
|
|
409
|
-
connect
|
|
410
|
-
what: unknown,
|
|
411
|
-
context: {requests: unknown; waiting: unknown; buffer: unknown},
|
|
412
|
-
) => void;
|
|
429
|
+
event?(name: string, params?: unknown): Promise<object>;
|
|
430
|
+
handle?(...params: unknown[]): Promise<unknown>;
|
|
431
|
+
connect?(what: unknown, context: unknown): void;
|
|
413
432
|
/**
|
|
414
433
|
* Optional lifecycle hook called when configuration changes.
|
|
415
434
|
* When present, the framework calls this instead of a full stop+start cycle.
|
|
@@ -421,11 +440,14 @@ export interface IAdapter<T, C> {
|
|
|
421
440
|
* @param next The full new effective config snapshot (via proxy)
|
|
422
441
|
* @param prev The full previous effective config snapshot
|
|
423
442
|
*/
|
|
424
|
-
configChanged
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
443
|
+
configChanged?(
|
|
444
|
+
this: Adapter<T, C>,
|
|
445
|
+
diff: unknown,
|
|
446
|
+
next: unknown,
|
|
447
|
+
prev?: unknown,
|
|
448
|
+
): Promise<void>;
|
|
449
|
+
/** Allow arbitrary extra methods on adapter definitions (e.g. authenticate) */
|
|
450
|
+
[key: string]: unknown;
|
|
429
451
|
}
|
|
430
452
|
|
|
431
453
|
export interface IAdapterFactory<T = Record<string, unknown>, C = Record<string, unknown>> {
|
|
@@ -433,6 +455,17 @@ export interface IAdapterFactory<T = Record<string, unknown>, C = Record<string,
|
|
|
433
455
|
(api: IApi): IAdapter<T, C>;
|
|
434
456
|
}
|
|
435
457
|
|
|
458
|
+
export interface IAdapterRegistry {
|
|
459
|
+
config: unknown;
|
|
460
|
+
(api: {
|
|
461
|
+
utError: IError;
|
|
462
|
+
remote: IRemote;
|
|
463
|
+
rpc: IRpcServer;
|
|
464
|
+
local: ILocal;
|
|
465
|
+
registry: IRegistry;
|
|
466
|
+
}): Promise<Adapter>;
|
|
467
|
+
}
|
|
468
|
+
|
|
436
469
|
export interface IMeta {
|
|
437
470
|
mtid?: 'request' | 'response' | 'error' | 'notification' | 'discard' | 'event';
|
|
438
471
|
request?: IMeta;
|
|
@@ -444,7 +477,7 @@ export interface IMeta {
|
|
|
444
477
|
expect?: string[] | string;
|
|
445
478
|
opcode?: string;
|
|
446
479
|
source?: string;
|
|
447
|
-
forward?:
|
|
480
|
+
forward?: Record<string, string>;
|
|
448
481
|
httpResponse?: {
|
|
449
482
|
type?: string;
|
|
450
483
|
redirect?: string;
|
|
@@ -490,16 +523,16 @@ export interface IMeta {
|
|
|
490
523
|
deviceId?: string | string[];
|
|
491
524
|
latitude?: string | string[];
|
|
492
525
|
longitude?: string | string[];
|
|
493
|
-
conId?: number;
|
|
526
|
+
conId?: string | number;
|
|
494
527
|
dispatch?: (
|
|
495
528
|
msg?: object,
|
|
496
529
|
$meta?: IMeta,
|
|
497
530
|
) => [msg: object, $meta: IMeta] | boolean | void | Promise<boolean>;
|
|
498
531
|
reply?: unknown;
|
|
499
|
-
timeout?:
|
|
532
|
+
timeout?: HRTime;
|
|
500
533
|
timer?: (
|
|
501
534
|
name?: string,
|
|
502
|
-
newTime?: HRTime |
|
|
535
|
+
newTime?: HRTime | undefined,
|
|
503
536
|
) => {
|
|
504
537
|
[name: string]: number;
|
|
505
538
|
};
|
|
@@ -511,16 +544,17 @@ export interface IMeta {
|
|
|
511
544
|
}
|
|
512
545
|
|
|
513
546
|
export interface IContext {
|
|
514
|
-
trace: number;
|
|
547
|
+
// trace: number;
|
|
515
548
|
session?: {
|
|
516
549
|
[name: string]: unknown;
|
|
517
550
|
};
|
|
518
|
-
conId?: string;
|
|
551
|
+
conId?: string | number;
|
|
519
552
|
requests: Map<
|
|
520
553
|
string,
|
|
521
|
-
{$meta: IMeta; end
|
|
554
|
+
{$meta: IMeta; end?: (error: Error) => {local: object; literals: object[]}}
|
|
522
555
|
>;
|
|
523
556
|
waiting: Set<(error: Error) => void>;
|
|
557
|
+
buffer?: Buffer;
|
|
524
558
|
}
|
|
525
559
|
|
|
526
560
|
export interface ITypedError extends Error {
|
|
@@ -578,7 +612,10 @@ export interface IModuleConfig<T extends TSchema = TNever> {
|
|
|
578
612
|
url: string;
|
|
579
613
|
config?: IActivationConfig<Partial<Static<T>> & Partial<Static<IBaseConfig>>>;
|
|
580
614
|
validation?: T;
|
|
581
|
-
children?:
|
|
615
|
+
children?:
|
|
616
|
+
| (string | (() => Promise<object>))[]
|
|
617
|
+
| ((layer: ModuleApi) => unknown)[]
|
|
618
|
+
| Record<string, () => Promise<unknown>>;
|
|
582
619
|
glob?: Record<string, () => Promise<object>>;
|
|
583
620
|
}
|
|
584
621
|
|
|
@@ -702,17 +739,24 @@ export type ApiDefinition = (blong: IValidationProxy) =>
|
|
|
702
739
|
};
|
|
703
740
|
|
|
704
741
|
export type PortHandler<T, C> = <R>(
|
|
705
|
-
this:
|
|
706
|
-
params:
|
|
742
|
+
this: Adapter<T, C>,
|
|
743
|
+
params: object,
|
|
707
744
|
$meta: IMeta,
|
|
708
745
|
context?: IContext,
|
|
709
746
|
) => Promise<R> | R;
|
|
710
|
-
export type PortHandlerBound = <T>(
|
|
747
|
+
export type PortHandlerBound = (<T>(
|
|
748
|
+
params: object,
|
|
749
|
+
$meta: IMeta,
|
|
750
|
+
context?: IContext,
|
|
751
|
+
) => Promise<T> | T) & {
|
|
752
|
+
[name: string]: PortHandlerBound;
|
|
753
|
+
};
|
|
711
754
|
export type LibFn = <T>(...params: unknown[]) => T;
|
|
712
755
|
export interface IRemoteHandler {
|
|
713
756
|
[name: string]: PortHandlerBound;
|
|
714
757
|
}
|
|
715
|
-
|
|
758
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
759
|
+
export interface ISchema {} // this is being extended via ambient declarations in ~.schema.ts
|
|
716
760
|
export interface IHandlerProxy<T> {
|
|
717
761
|
config: T;
|
|
718
762
|
handler: {
|
|
@@ -769,9 +813,9 @@ const Kind: symbol = Symbol.for('blong:kind');
|
|
|
769
813
|
export type Kind = typeof Kind;
|
|
770
814
|
|
|
771
815
|
export abstract class Internal {
|
|
772
|
-
#log?: ILog;
|
|
816
|
+
#log?: ILog | undefined;
|
|
773
817
|
protected log?: ReturnType<ILog['logger']>;
|
|
774
|
-
public constructor(api?: {log
|
|
818
|
+
public constructor(api?: {log?: ILog}) {
|
|
775
819
|
this.#log = api?.log;
|
|
776
820
|
}
|
|
777
821
|
protected merge: ILib['merge'] = (...args: Parameters<ILib['merge']>) => {
|
|
@@ -783,7 +827,8 @@ export abstract class Internal {
|
|
|
783
827
|
public async stop(): Promise<unknown> {
|
|
784
828
|
return this;
|
|
785
829
|
}
|
|
786
|
-
|
|
830
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
831
|
+
public async start(..._args: unknown[]): Promise<unknown> {
|
|
787
832
|
return this;
|
|
788
833
|
}
|
|
789
834
|
}
|
|
@@ -850,8 +895,7 @@ export const defineActions = (
|
|
|
850
895
|
actions: Record<string, IActionDef>,
|
|
851
896
|
): ((_blong: unknown) => Record<string, () => IActionDef>) =>
|
|
852
897
|
Object.defineProperty(
|
|
853
|
-
(
|
|
854
|
-
Object.fromEntries(Object.entries(actions).map(([key, value]) => [key, () => value])),
|
|
898
|
+
() => Object.fromEntries(Object.entries(actions).map(([key, value]) => [key, () => value])),
|
|
855
899
|
Kind,
|
|
856
900
|
{value: 'handler'},
|
|
857
901
|
);
|
|
@@ -888,21 +932,40 @@ export const validationHandlers: (
|
|
|
888
932
|
),
|
|
889
933
|
);
|
|
890
934
|
|
|
891
|
-
export const realm = <T extends TObject>(
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
Object.defineProperty(definition
|
|
895
|
-
|
|
896
|
-
|
|
935
|
+
export const realm = <T extends TObject>(
|
|
936
|
+
definition: SolutionFactory<T>,
|
|
937
|
+
): SolutionFactory<T> & {[Kind]: 'solution'} =>
|
|
938
|
+
Object.defineProperty(definition as SolutionFactory<T> & {[Kind]: 'solution'}, Kind, {
|
|
939
|
+
value: 'solution',
|
|
940
|
+
});
|
|
941
|
+
export const server = <T extends TObject>(
|
|
942
|
+
definition: SolutionFactory<T>,
|
|
943
|
+
): SolutionFactory<T> & {[Kind]: 'server'} =>
|
|
944
|
+
Object.defineProperty(definition as SolutionFactory<T> & {[Kind]: 'server'}, Kind, {
|
|
945
|
+
value: 'server',
|
|
946
|
+
});
|
|
947
|
+
export const browser = <T extends TObject>(
|
|
948
|
+
definition: SolutionFactory<T>,
|
|
949
|
+
): SolutionFactory<T> & {[Kind]: 'browser'} =>
|
|
950
|
+
Object.defineProperty(definition as SolutionFactory<T> & {[Kind]: 'browser'}, Kind, {
|
|
951
|
+
value: 'browser',
|
|
952
|
+
});
|
|
897
953
|
export const layer = (
|
|
898
954
|
activation: Record<string, boolean | object>,
|
|
899
|
-
): Record<string, boolean | object>
|
|
955
|
+
): Record<string, boolean | object> & {[Kind]: 'layer'} =>
|
|
956
|
+
Object.defineProperty(activation, Kind, {value: 'layer'});
|
|
900
957
|
export const adapter = <T, C = AdapterContext>(
|
|
901
958
|
definition: IAdapterFactory<T, C>,
|
|
902
|
-
): IAdapterFactory<T, C>
|
|
959
|
+
): IAdapterFactory<T, C> & {[Kind]: 'adapter'} =>
|
|
960
|
+
Object.defineProperty(definition as IAdapterFactory<T, C> & {[Kind]: 'adapter'}, Kind, {
|
|
961
|
+
value: 'adapter',
|
|
962
|
+
});
|
|
903
963
|
export const orchestrator = <T, C = AdapterContext>(
|
|
904
964
|
definition: IAdapterFactory<T, C>,
|
|
905
|
-
): IAdapterFactory<T, C>
|
|
965
|
+
): IAdapterFactory<T, C> & {[Kind]: 'orchestrator'} =>
|
|
966
|
+
Object.defineProperty(definition as IAdapterFactory<T, C> & {[Kind]: 'orchestrator'}, Kind, {
|
|
967
|
+
value: 'orchestrator',
|
|
968
|
+
});
|
|
906
969
|
|
|
907
970
|
export type Kinds =
|
|
908
971
|
| 'lib'
|