@rsdk/grpc.clients 5.11.0-next.9 → 5.11.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 +4 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/subscription/abortable.d.ts +2 -0
- package/dist/subscription/abortable.js +9 -0
- package/dist/subscription/abortable.js.map +1 -0
- package/dist/subscription/is-abort-error.d.ts +1 -0
- package/dist/subscription/is-abort-error.js +7 -0
- package/dist/subscription/is-abort-error.js.map +1 -0
- package/dist/subscription/subscribed-async-iterable.d.ts +3 -0
- package/dist/subscription/subscribed-async-iterable.js +49 -0
- package/dist/subscription/subscribed-async-iterable.js.map +1 -0
- package/package.json +3 -2
- package/src/index.ts +3 -0
- package/src/subscription/abortable.ts +9 -0
- package/src/subscription/is-abort-error.ts +3 -0
- package/src/subscription/subscribed-async-iterable.ts +59 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.11.0](https://github.com/R-Vision/rsdk/compare/v5.11.0-next.10...v5.11.0) (2025-12-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @rsdk/grpc.clients
|
|
9
|
+
|
|
6
10
|
## [5.10.0](https://github.com/R-Vision/rsdk/compare/v5.10.0-next.2...v5.10.0) (2025-10-16)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @rsdk/grpc.clients
|
package/dist/index.d.ts
CHANGED
|
@@ -4,3 +4,6 @@ export * from './decorators/inject-client.decorator';
|
|
|
4
4
|
export * from './decorators/inject-client-factory.decorator';
|
|
5
5
|
export { getClientToken, getFactoryToken, getChannelToken, getPropertyKey, } from './token.factories';
|
|
6
6
|
export * from './plugin';
|
|
7
|
+
export { subscribedAsyncIterable } from './subscription/subscribed-async-iterable';
|
|
8
|
+
export { isAbortError } from './subscription/is-abort-error';
|
|
9
|
+
export { abortable } from './subscription/abortable';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getPropertyKey = exports.getChannelToken = exports.getFactoryToken = exports.getClientToken = exports.GrpcServers = exports.exceptionMapperMiddleware = void 0;
|
|
17
|
+
exports.abortable = exports.isAbortError = exports.subscribedAsyncIterable = exports.getPropertyKey = exports.getChannelToken = exports.getFactoryToken = exports.getClientToken = exports.GrpcServers = exports.exceptionMapperMiddleware = void 0;
|
|
18
18
|
var exception_mapper_middleware_1 = require("./middleware/exception-mapper.middleware");
|
|
19
19
|
Object.defineProperty(exports, "exceptionMapperMiddleware", { enumerable: true, get: function () { return exception_mapper_middleware_1.exceptionMapperMiddleware; } });
|
|
20
20
|
var grpc_servers_1 = require("./servers/grpc.servers");
|
|
@@ -27,4 +27,10 @@ Object.defineProperty(exports, "getFactoryToken", { enumerable: true, get: funct
|
|
|
27
27
|
Object.defineProperty(exports, "getChannelToken", { enumerable: true, get: function () { return token_factories_1.getChannelToken; } });
|
|
28
28
|
Object.defineProperty(exports, "getPropertyKey", { enumerable: true, get: function () { return token_factories_1.getPropertyKey; } });
|
|
29
29
|
__exportStar(require("./plugin"), exports);
|
|
30
|
+
var subscribed_async_iterable_1 = require("./subscription/subscribed-async-iterable");
|
|
31
|
+
Object.defineProperty(exports, "subscribedAsyncIterable", { enumerable: true, get: function () { return subscribed_async_iterable_1.subscribedAsyncIterable; } });
|
|
32
|
+
var is_abort_error_1 = require("./subscription/is-abort-error");
|
|
33
|
+
Object.defineProperty(exports, "isAbortError", { enumerable: true, get: function () { return is_abort_error_1.isAbortError; } });
|
|
34
|
+
var abortable_1 = require("./subscription/abortable");
|
|
35
|
+
Object.defineProperty(exports, "abortable", { enumerable: true, get: function () { return abortable_1.abortable; } });
|
|
30
36
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wFAAqF;AAA5E,wIAAA,yBAAyB,OAAA;AAElC,uDAAqD;AAA5C,2GAAA,WAAW,OAAA;AAEpB,uEAAqD;AACrD,+EAA6D;AAC7D,qDAK2B;AAJzB,iHAAA,cAAc,OAAA;AACd,kHAAA,eAAe,OAAA;AACf,kHAAA,eAAe,OAAA;AACf,iHAAA,cAAc,OAAA;AAEhB,2CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wFAAqF;AAA5E,wIAAA,yBAAyB,OAAA;AAElC,uDAAqD;AAA5C,2GAAA,WAAW,OAAA;AAEpB,uEAAqD;AACrD,+EAA6D;AAC7D,qDAK2B;AAJzB,iHAAA,cAAc,OAAA;AACd,kHAAA,eAAe,OAAA;AACf,kHAAA,eAAe,OAAA;AACf,iHAAA,cAAc,OAAA;AAEhB,2CAAyB;AACzB,sFAAmF;AAA1E,oIAAA,uBAAuB,OAAA;AAChC,gEAA6D;AAApD,8GAAA,YAAY,OAAA;AACrB,sDAAqD;AAA5C,sGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.abortable = abortable;
|
|
4
|
+
function abortable(callOptions) {
|
|
5
|
+
const abortController = new AbortController();
|
|
6
|
+
callOptions.signal = abortController.signal;
|
|
7
|
+
return abortController.abort.bind(abortController);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=abortable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abortable.js","sourceRoot":"","sources":["../../src/subscription/abortable.ts"],"names":[],"mappings":";;AAEA,8BAMC;AAND,SAAgB,SAAS,CAAC,WAAwB;IAChD,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAE9C,WAAW,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;IAE5C,OAAO,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isAbortError(error: unknown): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAbortError = isAbortError;
|
|
4
|
+
function isAbortError(error) {
|
|
5
|
+
return error instanceof DOMException && error.name === 'AbortError';
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=is-abort-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-abort-error.js","sourceRoot":"","sources":["../../src/subscription/is-abort-error.ts"],"names":[],"mappings":";;AAAA,oCAEC;AAFD,SAAgB,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,YAAY,YAAY,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subscribedAsyncIterable = void 0;
|
|
4
|
+
const actx_1 = require("@rsdk/actx");
|
|
5
|
+
const is_abort_error_1 = require("./is-abort-error");
|
|
6
|
+
const subscribedAsyncIterable = (iterable, subscriptionName, map, abort) => {
|
|
7
|
+
const asyncIterator = iterable[Symbol.asyncIterator]();
|
|
8
|
+
return {
|
|
9
|
+
[Symbol.asyncIterator]: (0, actx_1.continuedRsdkAsyncContext)(() => {
|
|
10
|
+
return {
|
|
11
|
+
next: (0, actx_1.continuedRsdkAsyncContext)(async (args) => {
|
|
12
|
+
const result = await (async () => {
|
|
13
|
+
try {
|
|
14
|
+
return await asyncIterator.next(args);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (error instanceof Error && (0, is_abort_error_1.isAbortError)(error)) {
|
|
18
|
+
return { done: true, value: undefined };
|
|
19
|
+
}
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
})();
|
|
23
|
+
const value = map?.(result.value) ?? result.value;
|
|
24
|
+
return {
|
|
25
|
+
done: result.done,
|
|
26
|
+
value: { [subscriptionName]: value },
|
|
27
|
+
};
|
|
28
|
+
}),
|
|
29
|
+
return: (0, actx_1.continuedRsdkAsyncContext)(async (val) => {
|
|
30
|
+
abort && abort();
|
|
31
|
+
const result = asyncIterator.return && (await asyncIterator.return(val));
|
|
32
|
+
if (result) {
|
|
33
|
+
const value = map?.(result.value) ?? result.value;
|
|
34
|
+
return {
|
|
35
|
+
done: result.done,
|
|
36
|
+
value: { [subscriptionName]: value },
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}),
|
|
41
|
+
throw: (0, actx_1.continuedRsdkAsyncContext)((e) => {
|
|
42
|
+
return asyncIterator.throw?.(e);
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.subscribedAsyncIterable = subscribedAsyncIterable;
|
|
49
|
+
//# sourceMappingURL=subscribed-async-iterable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribed-async-iterable.js","sourceRoot":"","sources":["../../src/subscription/subscribed-async-iterable.ts"],"names":[],"mappings":";;;AAAA,qCAAuD;AAEvD,qDAAgD;AAEzC,MAAM,uBAAuB,GAAG,CACrC,QAA8B,EAC9B,gBAA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MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC;wBAElD,OAAO;4BACL,IAAI,EAAE,MAAM,CAAC,IAAI;4BACjB,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE;yBACrC,CAAC;oBACJ,CAAC;oBACD,OAAO,MAAM,CAAC;gBAChB,CAAC,CAAC;gBACF,KAAK,EAAE,IAAA,gCAAyB,EAAC,CAAC,CAAU,EAAE,EAAE;oBAC9C,OAAO,aAAa,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;gBAClC,CAAC,CAAC;aACH,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC;AAtDW,QAAA,uBAAuB,2BAsDlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/grpc.clients",
|
|
3
|
-
"version": "5.11.0
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"description": "Grpc clients infrastructure",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"@nestjs/common": "^10.4.20",
|
|
16
16
|
"@nestjs/core": "^10.4.20",
|
|
17
17
|
"@nestjs/microservices": "^10.4.20",
|
|
18
|
+
"@rsdk/actx": "*",
|
|
18
19
|
"@rsdk/autodoc.protocol": "*",
|
|
19
20
|
"@rsdk/builtin-contract": "*",
|
|
20
21
|
"@rsdk/common": "*",
|
|
@@ -26,5 +27,5 @@
|
|
|
26
27
|
"reflect-metadata": "^0.1.12 || ^0.2.0",
|
|
27
28
|
"rxjs": "^7.1.0"
|
|
28
29
|
},
|
|
29
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "d8e12d8a65395fd0023db77febbf11c9b3c340bc"
|
|
30
31
|
}
|
package/src/index.ts
CHANGED
|
@@ -11,3 +11,6 @@ export {
|
|
|
11
11
|
getPropertyKey,
|
|
12
12
|
} from './token.factories';
|
|
13
13
|
export * from './plugin';
|
|
14
|
+
export { subscribedAsyncIterable } from './subscription/subscribed-async-iterable';
|
|
15
|
+
export { isAbortError } from './subscription/is-abort-error';
|
|
16
|
+
export { abortable } from './subscription/abortable';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CallOptions } from 'nice-grpc';
|
|
2
|
+
|
|
3
|
+
export function abortable(callOptions: CallOptions): (reason?: string) => void {
|
|
4
|
+
const abortController = new AbortController();
|
|
5
|
+
|
|
6
|
+
callOptions.signal = abortController.signal;
|
|
7
|
+
|
|
8
|
+
return abortController.abort.bind(abortController);
|
|
9
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { continuedRsdkAsyncContext } from '@rsdk/actx';
|
|
2
|
+
|
|
3
|
+
import { isAbortError } from './is-abort-error';
|
|
4
|
+
|
|
5
|
+
export const subscribedAsyncIterable = <Input, Output>(
|
|
6
|
+
iterable: AsyncIterable<Input>,
|
|
7
|
+
subscriptionName: string,
|
|
8
|
+
map?: (value?: Input) => Output,
|
|
9
|
+
abort?: () => void,
|
|
10
|
+
): { [Symbol.asyncIterator]: (...args: any[]) => any } => {
|
|
11
|
+
const asyncIterator = iterable[Symbol.asyncIterator]();
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
[Symbol.asyncIterator]: continuedRsdkAsyncContext(() => {
|
|
15
|
+
return {
|
|
16
|
+
next: continuedRsdkAsyncContext(async (args: any) => {
|
|
17
|
+
const result: IteratorResult<Input, any> = await (async (): Promise<
|
|
18
|
+
IteratorResult<Input, any>
|
|
19
|
+
> => {
|
|
20
|
+
try {
|
|
21
|
+
return await asyncIterator.next(args);
|
|
22
|
+
} catch (error: unknown) {
|
|
23
|
+
if (error instanceof Error && isAbortError(error)) {
|
|
24
|
+
return { done: true, value: undefined };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
})();
|
|
30
|
+
|
|
31
|
+
const value = map?.(result.value) ?? result.value;
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
done: result.done,
|
|
35
|
+
value: { [subscriptionName]: value },
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
return: continuedRsdkAsyncContext(async (val: any) => {
|
|
39
|
+
abort && abort();
|
|
40
|
+
|
|
41
|
+
const result =
|
|
42
|
+
asyncIterator.return && (await asyncIterator.return(val));
|
|
43
|
+
if (result) {
|
|
44
|
+
const value = map?.(result.value) ?? result.value;
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
done: result.done,
|
|
48
|
+
value: { [subscriptionName]: value },
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}),
|
|
53
|
+
throw: continuedRsdkAsyncContext((e: unknown) => {
|
|
54
|
+
return asyncIterator.throw?.(e);
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
};
|