@rsdk/grpc.common 5.12.0-next.2 → 5.12.0-next.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/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export * from './grpc-address.parser';
1
+ export { GrpcAddressParser } from './grpc-address.parser';
2
+ export { metadata } from './metadata';
package/dist/index.js CHANGED
@@ -1,18 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./grpc-address.parser"), exports);
3
+ exports.metadata = exports.GrpcAddressParser = void 0;
4
+ var grpc_address_parser_1 = require("./grpc-address.parser");
5
+ Object.defineProperty(exports, "GrpcAddressParser", { enumerable: true, get: function () { return grpc_address_parser_1.GrpcAddressParser; } });
6
+ var metadata_1 = require("./metadata");
7
+ Object.defineProperty(exports, "metadata", { enumerable: true, get: function () { return metadata_1.metadata; } });
18
8
  //# 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,wDAAsC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAAjD,wHAAA,iBAAiB,OAAA;AAC1B,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA"}
@@ -0,0 +1,12 @@
1
+ import { Metadata } from 'nice-grpc';
2
+ /**
3
+ * Utility function that helps build grpc metadata from object.
4
+ *
5
+ * Object property name will be taken as metadata key.
6
+ * Object property value will be passed as metadata value.
7
+ * If value is string then value will be passed as string
8
+ * otherwise value will be passed as JSON.
9
+ *
10
+ * @param context
11
+ */
12
+ export declare const metadata: (context: object) => Metadata;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.metadata = void 0;
4
+ const nice_grpc_1 = require("nice-grpc");
5
+ /**
6
+ * Utility function that helps build grpc metadata from object.
7
+ *
8
+ * Object property name will be taken as metadata key.
9
+ * Object property value will be passed as metadata value.
10
+ * If value is string then value will be passed as string
11
+ * otherwise value will be passed as JSON.
12
+ *
13
+ * @param context
14
+ */
15
+ const metadata = (context) => {
16
+ return Object.entries(context).reduce((ctx, [key, value]) => {
17
+ ctx.append(key, typeof value === 'string' ? value : JSON.stringify(value));
18
+ return ctx;
19
+ }, new nice_grpc_1.Metadata());
20
+ };
21
+ exports.metadata = metadata;
22
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AAErC;;;;;;;;;GASG;AACI,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAY,EAAE;IACpD,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC1D,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3E,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,IAAI,oBAAQ,EAAE,CAAC,CAAC;AACrB,CAAC,CAAC;AALW,QAAA,QAAQ,YAKnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdk/grpc.common",
3
- "version": "5.12.0-next.2",
3
+ "version": "5.12.0-next.4",
4
4
  "description": "Common grpc stuff",
5
5
  "license": "Apache License 2.0",
6
6
  "publishConfig": {
@@ -12,7 +12,8 @@
12
12
  "main": "dist/index.js",
13
13
  "peerDependencies": {
14
14
  "@rsdk/common": "*",
15
- "@rsdk/core": "*"
15
+ "@rsdk/core": "*",
16
+ "nice-grpc": "^2.1.10"
16
17
  },
17
- "gitHead": "6b51ee3aab82a0fe8684112b2571331da8fae4e4"
18
+ "gitHead": "7d42d139bc812ac8526d6d9848d24165f8e15a20"
18
19
  }
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
- export * from './grpc-address.parser';
1
+ export { GrpcAddressParser } from './grpc-address.parser';
2
+ export { metadata } from './metadata';
@@ -0,0 +1,18 @@
1
+ import { Metadata } from 'nice-grpc';
2
+
3
+ /**
4
+ * Utility function that helps build grpc metadata from object.
5
+ *
6
+ * Object property name will be taken as metadata key.
7
+ * Object property value will be passed as metadata value.
8
+ * If value is string then value will be passed as string
9
+ * otherwise value will be passed as JSON.
10
+ *
11
+ * @param context
12
+ */
13
+ export const metadata = (context: object): Metadata => {
14
+ return Object.entries(context).reduce((ctx, [key, value]) => {
15
+ ctx.append(key, typeof value === 'string' ? value : JSON.stringify(value));
16
+ return ctx;
17
+ }, new Metadata());
18
+ };