proto.io 0.0.156 → 0.0.157

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.mjs CHANGED
@@ -266,6 +266,32 @@ const proxy = (x) => {
266
266
  return proxy;
267
267
  };
268
268
 
269
+ //
270
+ // options.ts
271
+ //
272
+ // The MIT License
273
+ // Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.
274
+ //
275
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
276
+ // of this software and associated documentation files (the "Software"), to deal
277
+ // in the Software without restriction, including without limitation the rights
278
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
279
+ // copies of the Software, and to permit persons to whom the Software is
280
+ // furnished to do so, subject to the following conditions:
281
+ //
282
+ // The above copyright notice and this permission notice shall be included in
283
+ // all copies or substantial portions of the Software.
284
+ //
285
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
286
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
287
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
288
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
289
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
290
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
291
+ // THE SOFTWARE.
292
+ //
293
+ const _serviceOf = (options) => options?.session instanceof ProtoService ? options?.session : undefined;
294
+
269
295
  //
270
296
  // methods.ts
271
297
  //
@@ -310,7 +336,7 @@ class ProtoQuery extends TQuery {
310
336
  if (options?.master !== true)
311
337
  throw Error('No permission');
312
338
  }
313
- return dispatcher(options?.session ?? this._proto, options ?? {}, !!this._opts.insecure);
339
+ return dispatcher(_serviceOf(options) ?? this._proto, options ?? {}, !!this._opts.insecure);
314
340
  }
315
341
  explain(options) {
316
342
  return this._dispatcher(options).explain(this._queryOptions);
@@ -1066,7 +1092,7 @@ class ProtoInternal {
1066
1092
  async refs(proto, object, options) {
1067
1093
  const roles = options?.master ? [] : await this._perms(proto);
1068
1094
  const classNames = options?.master ? _.keys(this.options.schema) : _.filter(_.keys(this.options.schema), x => proto[PVK].validateCLPs(x, roles, ['find']));
1069
- const storage = options?.session?.storage ?? this.options.storage;
1095
+ const storage = _serviceOf(options)?.storage ?? this.options.storage;
1070
1096
  return storage.refs(object, classNames, options?.master ? undefined : roles);
1071
1097
  }
1072
1098
  }