hypha-rpc 0.20.0 → 0.20.2

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.
@@ -55,20 +55,26 @@ function indexObject(obj, is) {
55
55
  else return indexObject(obj[is[0]], is.slice(1));
56
56
  }
57
57
 
58
- function _get_schema(obj, prefix = "") {
58
+ function _get_schema(obj, prefix = "", skipContext = false) {
59
59
  if (obj instanceof Object) {
60
60
  let schema = {};
61
61
  for (let k in obj) {
62
- schema[k] = _get_schema(obj[k], prefix + "." + k);
62
+ schema[k] = _get_schema(obj[k], prefix + "." + k, skipContext);
63
63
  }
64
64
  return schema;
65
65
  }
66
66
  if (obj instanceof Array) {
67
- return obj.map((v, i) => _get_schema(v, prefix + "." + i));
67
+ return obj.map((v, i) => _get_schema(v, prefix + "." + i, skipContext));
68
68
  }
69
69
  if (typeof obj === "function") {
70
70
  if (obj.__schema__) {
71
- return { type: "function", function: obj.__schema__ };
71
+ const schema = JSON.parse(JSON.stringify(obj.__schema__));
72
+ if (skipContext) {
73
+ if (schema.parameters && schema.parameters.properties) {
74
+ delete schema.parameters.properties["context"];
75
+ }
76
+ }
77
+ return { type: "function", function: schema };
72
78
  } else {
73
79
  return { type: "function" };
74
80
  }
@@ -616,7 +622,8 @@ class RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
616
622
  }
617
623
 
618
624
  _extract_service_info(service) {
619
- const serviceInfo = _get_schema(service);
625
+ const skipContext = service.config.require_context;
626
+ const serviceInfo = _get_schema(service, "", skipContext);
620
627
  (serviceInfo.id = `${this._client_id}:${service["id"]}`),
621
628
  (serviceInfo.description = service["description"] || ""),
622
629
  (serviceInfo.app_id = this._app_id);