@nmtjs/protocol 0.11.9 → 0.12.1
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/server/api.js +1 -1
- package/dist/server/api.js.map +1 -1
- package/package.json +7 -7
- package/src/server/api.ts +2 -7
package/dist/server/api.js
CHANGED
|
@@ -2,7 +2,7 @@ import { kIterableResponse } from "./constants.js";
|
|
|
2
2
|
export function isIterableResult(value) {
|
|
3
3
|
return value && value[kIterableResponse] === true;
|
|
4
4
|
}
|
|
5
|
-
export function createStreamResponse(iterable,
|
|
5
|
+
export function createStreamResponse(iterable, output = undefined, onFinish) {
|
|
6
6
|
return {
|
|
7
7
|
[kIterableResponse]: true,
|
|
8
8
|
iterable,
|
package/dist/server/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAEA,SAAS,yBAAyB,gBAAgB;AAmClD,OAAO,SAAS,iBACdA,OACwC;AACxC,QAAO,SAAS,MAAM,uBAAuB;AAC9C;AAED,OAAO,SAAS,qBACdC,UACA,
|
|
1
|
+
{"mappings":"AAEA,SAAS,yBAAyB,gBAAgB;AAmClD,OAAO,SAAS,iBACdA,OACwC;AACxC,QAAO,SAAS,MAAM,uBAAuB;AAC9C;AAED,OAAO,SAAS,qBACdC,UACA,SAAS,WACTC,UACqC;AACrC,QAAO;GACJ,oBAAoB;EACrB;EACA;EACA;CACD;AACF","names":["value: any","iterable: ProtocolAnyIterable<Y>","onFinish?: () => void"],"sources":["../../src/server/api.ts"],"sourcesContent":["import type { Container, Hook, MetadataStore } from '@nmtjs/core'\nimport type { Connection } from './connection.ts'\nimport { kIterableResponse } from './constants.ts'\n\nexport type ProtocolApiCallOptions = {\n connection: Connection\n namespace: string\n procedure: string\n container: Container\n payload: any\n signal: AbortSignal\n metadata?: (metadata: MetadataStore) => void\n}\n\nexport type ProtocolAnyIterable<T> =\n | ((signal: AbortSignal) => AsyncIterable<T>)\n | AsyncIterable<T>\n\nexport interface ProtocolApiCallBaseResult<T = unknown> {\n output: T\n}\n\nexport interface ProtocolApiCallIterableResult<Y = unknown, O = unknown>\n extends ProtocolApiCallBaseResult<O> {\n [kIterableResponse]: true\n iterable: ProtocolAnyIterable<Y>\n onFinish?: () => void\n}\n\nexport type ProtocolApiCallResult =\n | ProtocolApiCallBaseResult\n | ProtocolApiCallIterableResult\n\nexport interface ProtocolApi {\n call(options: ProtocolApiCallOptions): Promise<ProtocolApiCallResult>\n}\n\nexport function isIterableResult(\n value: any,\n): value is ProtocolApiCallIterableResult {\n return value && value[kIterableResponse] === true\n}\n\nexport function createStreamResponse<Y, O>(\n iterable: ProtocolAnyIterable<Y>,\n output = undefined as O,\n onFinish?: () => void,\n): ProtocolApiCallIterableResult<Y, O> {\n return {\n [kIterableResponse]: true as const,\n iterable,\n output,\n onFinish,\n }\n}\n\ndeclare module '@nmtjs/core' {\n export interface HookType {\n [Hook.OnConnect]: (connection: Connection) => any\n [Hook.OnDisconnect]: (connection: Connection) => any\n }\n}\n"],"version":3,"file":"api.js"}
|
package/package.json
CHANGED
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@nmtjs/
|
|
20
|
-
"@nmtjs/
|
|
21
|
-
"@nmtjs/core": "0.
|
|
19
|
+
"@nmtjs/type": "0.12.1",
|
|
20
|
+
"@nmtjs/common": "0.12.1",
|
|
21
|
+
"@nmtjs/core": "0.12.1"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@nmtjs/common": "0.
|
|
25
|
-
"@nmtjs/type": "0.
|
|
26
|
-
"@nmtjs/core": "0.
|
|
24
|
+
"@nmtjs/common": "0.12.1",
|
|
25
|
+
"@nmtjs/type": "0.12.1",
|
|
26
|
+
"@nmtjs/core": "0.12.1"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"src",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"LICENSE.md",
|
|
32
32
|
"README.md"
|
|
33
33
|
],
|
|
34
|
-
"version": "0.
|
|
34
|
+
"version": "0.12.1",
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "neemata-build --root=./src './**/*.ts'",
|
|
37
37
|
"type-check": "tsc --noEmit"
|
package/src/server/api.ts
CHANGED
|
@@ -43,13 +43,8 @@ export function isIterableResult(
|
|
|
43
43
|
|
|
44
44
|
export function createStreamResponse<Y, O>(
|
|
45
45
|
iterable: ProtocolAnyIterable<Y>,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
output = undefined as O,
|
|
49
|
-
}: {
|
|
50
|
-
output?: O
|
|
51
|
-
onFinish?: () => void
|
|
52
|
-
},
|
|
46
|
+
output = undefined as O,
|
|
47
|
+
onFinish?: () => void,
|
|
53
48
|
): ProtocolApiCallIterableResult<Y, O> {
|
|
54
49
|
return {
|
|
55
50
|
[kIterableResponse]: true as const,
|