@vsaas/remoting 10.0.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.
Files changed (109) hide show
  1. package/LICENSE.md +202 -0
  2. package/README.md +78 -0
  3. package/dist/_virtual/_rolldown/runtime.js +32 -0
  4. package/dist/ext/meta.d.ts +1 -0
  5. package/dist/ext/meta.js +39 -0
  6. package/dist/ext/meta.js.map +1 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +20 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/lib/context-base.d.ts +1 -0
  11. package/dist/lib/context-base.js +30 -0
  12. package/dist/lib/context-base.js.map +1 -0
  13. package/dist/lib/deprecate.d.ts +1 -0
  14. package/dist/lib/deprecate.js +34 -0
  15. package/dist/lib/deprecate.js.map +1 -0
  16. package/dist/lib/escape-regexp.d.ts +1 -0
  17. package/dist/lib/escape-regexp.js +12 -0
  18. package/dist/lib/escape-regexp.js.map +1 -0
  19. package/dist/lib/exports-helper.d.ts +1 -0
  20. package/dist/lib/exports-helper.js +101 -0
  21. package/dist/lib/exports-helper.js.map +1 -0
  22. package/dist/lib/http-context.d.ts +1 -0
  23. package/dist/lib/http-context.js +484 -0
  24. package/dist/lib/http-context.js.map +1 -0
  25. package/dist/lib/http-invocation.d.ts +1 -0
  26. package/dist/lib/http-invocation.js +254 -0
  27. package/dist/lib/http-invocation.js.map +1 -0
  28. package/dist/lib/jsonrpc-adapter.d.ts +1 -0
  29. package/dist/lib/jsonrpc-adapter.js +187 -0
  30. package/dist/lib/jsonrpc-adapter.js.map +1 -0
  31. package/dist/lib/looks-like-json.d.ts +1 -0
  32. package/dist/lib/looks-like-json.js +22 -0
  33. package/dist/lib/looks-like-json.js.map +1 -0
  34. package/dist/lib/messages.d.ts +1 -0
  35. package/dist/lib/messages.js +24 -0
  36. package/dist/lib/messages.js.map +1 -0
  37. package/dist/lib/number-checks.d.ts +1 -0
  38. package/dist/lib/number-checks.js +18 -0
  39. package/dist/lib/number-checks.js.map +1 -0
  40. package/dist/lib/phases/merge-phase-name-lists.d.ts +5 -0
  41. package/dist/lib/phases/merge-phase-name-lists.d.ts.map +1 -0
  42. package/dist/lib/phases/merge-phase-name-lists.js +39 -0
  43. package/dist/lib/phases/merge-phase-name-lists.js.map +1 -0
  44. package/dist/lib/phases/phase-list.d.ts +27 -0
  45. package/dist/lib/phases/phase-list.d.ts.map +1 -0
  46. package/dist/lib/phases/phase-list.js +154 -0
  47. package/dist/lib/phases/phase-list.js.map +1 -0
  48. package/dist/lib/phases/phase.d.ts +24 -0
  49. package/dist/lib/phases/phase.d.ts.map +1 -0
  50. package/dist/lib/phases/phase.js +144 -0
  51. package/dist/lib/phases/phase.js.map +1 -0
  52. package/dist/lib/remote-objects.d.ts +1 -0
  53. package/dist/lib/remote-objects.js +642 -0
  54. package/dist/lib/remote-objects.js.map +1 -0
  55. package/dist/lib/rest-adapter-browser.d.ts +1 -0
  56. package/dist/lib/rest-adapter-browser.js +302 -0
  57. package/dist/lib/rest-adapter-browser.js.map +1 -0
  58. package/dist/lib/rest-adapter.d.ts +1 -0
  59. package/dist/lib/rest-adapter.js +519 -0
  60. package/dist/lib/rest-adapter.js.map +1 -0
  61. package/dist/lib/server-sent-events.d.ts +1 -0
  62. package/dist/lib/server-sent-events.js +61 -0
  63. package/dist/lib/server-sent-events.js.map +1 -0
  64. package/dist/lib/shared-class.d.ts +1 -0
  65. package/dist/lib/shared-class.js +207 -0
  66. package/dist/lib/shared-class.js.map +1 -0
  67. package/dist/lib/shared-method.d.ts +1 -0
  68. package/dist/lib/shared-method.js +469 -0
  69. package/dist/lib/shared-method.js.map +1 -0
  70. package/dist/lib/socket-io-adapter.d.ts +1 -0
  71. package/dist/lib/socket-io-adapter.js +93 -0
  72. package/dist/lib/socket-io-adapter.js.map +1 -0
  73. package/dist/lib/socket-io-context.d.ts +1 -0
  74. package/dist/lib/socket-io-context.js +94 -0
  75. package/dist/lib/socket-io-context.js.map +1 -0
  76. package/dist/lib/type-registry.d.ts +1 -0
  77. package/dist/lib/type-registry.js +99 -0
  78. package/dist/lib/type-registry.js.map +1 -0
  79. package/dist/lib/types/any.d.ts +1 -0
  80. package/dist/lib/types/any.js +44 -0
  81. package/dist/lib/types/any.js.map +1 -0
  82. package/dist/lib/types/array.d.ts +1 -0
  83. package/dist/lib/types/array.js +99 -0
  84. package/dist/lib/types/array.js.map +1 -0
  85. package/dist/lib/types/boolean.d.ts +1 -0
  86. package/dist/lib/types/boolean.js +37 -0
  87. package/dist/lib/types/boolean.js.map +1 -0
  88. package/dist/lib/types/date.d.ts +1 -0
  89. package/dist/lib/types/date.js +37 -0
  90. package/dist/lib/types/date.js.map +1 -0
  91. package/dist/lib/types/geopoint.d.ts +1 -0
  92. package/dist/lib/types/geopoint.js +68 -0
  93. package/dist/lib/types/geopoint.js.map +1 -0
  94. package/dist/lib/types/integer.d.ts +1 -0
  95. package/dist/lib/types/integer.js +36 -0
  96. package/dist/lib/types/integer.js.map +1 -0
  97. package/dist/lib/types/number.d.ts +1 -0
  98. package/dist/lib/types/number.js +30 -0
  99. package/dist/lib/types/number.js.map +1 -0
  100. package/dist/lib/types/object.d.ts +1 -0
  101. package/dist/lib/types/object.js +57 -0
  102. package/dist/lib/types/object.js.map +1 -0
  103. package/dist/lib/types/string.d.ts +1 -0
  104. package/dist/lib/types/string.js +29 -0
  105. package/dist/lib/types/string.js.map +1 -0
  106. package/dist/phases.d.ts +4 -0
  107. package/dist/phases.js +35 -0
  108. package/dist/phases.js.map +1 -0
  109. package/package.json +96 -0
@@ -0,0 +1,469 @@
1
+ "use strict";
2
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
3
+ const require_lib_messages = require("./messages.js");
4
+ const require_lib_number_checks = require("./number-checks.js");
5
+ require("./context-base.js");
6
+ //#region src/lib/shared-method.ts
7
+ var require_shared_method = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, module) => {
8
+ const g = require_lib_messages;
9
+ /*!
10
+ * Expose `SharedMethod`.
11
+ */
12
+ module.exports = SharedMethod;
13
+ const debug = require("debug")("strong-remoting:shared-method");
14
+ require("util");
15
+ const assert = require("assert");
16
+ const numberChecks = require_lib_number_checks;
17
+ const isInteger = numberChecks.isSafeInteger;
18
+ const isSafeInteger = numberChecks.isSafeInteger;
19
+ /**
20
+ * Create a new `SharedMethod` (remote method) with the given `fn`.
21
+ * See also [Remote methods](http://docs.strongloop.com/display/LB/Remote+methods).
22
+ *
23
+ * @property {String} name The method name.
24
+ * @property {String[]} aliases An array of method aliases.
25
+ * @property {Boolean} isStatic Whether the method is static; from `options.isStatic`.
26
+ * Default is `true`.
27
+ * @property {Array|Object} accepts See `options.accepts`.
28
+ * @property {Array|Object} returns See `options.returns`.
29
+ * @property {Array|Object} errors See `options.errors`.
30
+ * @property {String} description Text description of the method.
31
+ * @property {String} notes Additional notes, used by API documentation generators like
32
+ * Swagger.
33
+ * @property {String} http
34
+ * @property {Object} rest
35
+ * @property {Boolean} shared
36
+ * @property {Boolean} [documented] Default: true. Set to `false` to exclude the method
37
+ * from Swagger metadata.
38
+ *
39
+ * @param {Function} fn The `Function` to be invoked when the method is invoked.
40
+ * @param {String} name The name of the `SharedMethod`.
41
+ * @param {SharedClass} sharedClass The `SharedClass` to which the method will be attached.
42
+ *
43
+ * @options {Object} options See below.
44
+ * @property {Array|Object} [accepts] Defines either a single argument as an object or an
45
+ * ordered set of arguments as an array.
46
+ * @property {String} [accepts.arg] The name of the argument.
47
+ * @property {String} [accepts.description] Text description of the argument, used by API
48
+ * documentation generators like Swagger.
49
+ * @property {String} [accepts.http] HTTP mapping for the argument. See argument mapping in
50
+ * [the docs](http://docs.strongloop.com/x/-Yw6#Remotemethods-HTTPmappingofinputarguments).
51
+ * @property {String} [accepts.http.source] The HTTP source for the argument. May be one
52
+ * of the following:
53
+ *
54
+ * - `req` - the Express `Request` object.
55
+ * - `res` - the Express `Response` object.
56
+ * - `body` - the `req.body` value.
57
+ * - `form` - `req.body[argumentName]`.
58
+ * - `query` - `req.query[argumentName]`.
59
+ * - `path` - `req.params[argumentName]`.
60
+ * - `header` - `req.headers[argumentName]`.
61
+ * - `context` - the current `HttpContext`.
62
+ * @property {Object} [accepts.rest] The REST mapping / settings for the argument.
63
+ * @property {String} [accepts.type] Argument datatype; must be a
64
+ * [Loopback type](http://docs.strongloop.com/display/LB/LoopBack+types).
65
+ * @property {Array} [aliases] A list of aliases for the method.
66
+ * @property {Array|Object} [errors] Object or `Array` containing error definitions.
67
+ * @property {Array} [http] HTTP-only options.
68
+ * @property {Number} [http.errorStatus] Default error status code.
69
+ * @property {String} [http.path] HTTP path (relative to the model) at which the method is
70
+ * exposed.
71
+ * @property {Number} [http.status] Default status code when the callback is called
72
+ * _without_ an error.
73
+ * @property {String} [http.verb] HTTP method (verb) at which the method is available.
74
+ * One of: get, post (default), put, del, or all
75
+ * @property {Boolean} [isStatic] Whether the method is a static method or a prototype
76
+ * method.
77
+ * @property {Array|Object} [returns] Specifies the remote method's callback arguments;
78
+ * either a single argument as an object or an ordered set of arguments as an array.
79
+ * The `err` argument is assumed; do not specify. NOTE: Can have the same properties as
80
+ * `accepts`, except for `http.target`.
81
+ *
82
+ * Additionally, one of the callback arguments can have `type: 'file'` and
83
+ * `root:true`, in which case this argument is sent in the raw form as
84
+ * a response body. Allowed values: `String`, `Buffer` or `ReadableStream`
85
+ * @property {Boolean} [shared] Whether the method is shared. Default is `true`.
86
+ * @property {Number} [status] The default status code.
87
+ * @end
88
+ *
89
+ * @class
90
+ */
91
+ function SharedMethod(fn, name, sc, options) {
92
+ if (typeof options === "boolean") options = { isStatic: options };
93
+ this.fn = fn;
94
+ fn = fn || {};
95
+ this.name = name;
96
+ assert(typeof name === "string", "The method name must be a string");
97
+ options = options || {};
98
+ this.aliases = options.aliases || [];
99
+ const isStatic = this.isStatic = options.isStatic || false;
100
+ this.accepts = options.accepts || fn.accepts || [];
101
+ this.returns = options.returns || fn.returns || [];
102
+ this.errors = options.errors || fn.errors || [];
103
+ this.description = options.description || fn.description;
104
+ this.accessType = options.accessType || fn.accessType;
105
+ this.notes = options.notes || fn.notes;
106
+ this.documented = options.documented !== false && fn.documented !== false;
107
+ this.http = options.http || fn.http || {};
108
+ this.rest = options.rest || fn.rest || {};
109
+ this.shared = options.shared;
110
+ if (this.shared === void 0) this.shared = true;
111
+ if (fn.shared === false) this.shared = false;
112
+ this.sharedClass = sc;
113
+ if (sc) {
114
+ this.ctor = sc.ctor;
115
+ this.sharedCtor = sc.sharedCtor;
116
+ }
117
+ if (name === "sharedCtor") this.isSharedCtor = true;
118
+ if (this.accepts && !Array.isArray(this.accepts)) this.accepts = [this.accepts];
119
+ this.accepts.forEach(normalizeArgumentDescriptor);
120
+ if (this.returns && !Array.isArray(this.returns)) this.returns = [this.returns];
121
+ this.returns.forEach(normalizeArgumentDescriptor);
122
+ const firstReturns = this.returns[0];
123
+ if (firstReturns && firstReturns.type && [
124
+ "ReadableStream",
125
+ "WriteableStream",
126
+ "DuplexStream"
127
+ ].indexOf(firstReturns.type) > -1) this.streams = { returns: firstReturns };
128
+ if (this.errors && !Array.isArray(this.errors)) this.errors = [this.errors];
129
+ if (/^prototype\./.test(name)) throw new Error("Incorrect API usage. Shared methods on prototypes should be created via `new SharedMethod(fn, \"name\", { isStatic: false })`");
130
+ this.stringName = (sc ? sc.name : "") + (isStatic ? "." : ".prototype.") + name;
131
+ for (const key in options) {
132
+ if (this[key]) continue;
133
+ this[key] = options[key];
134
+ }
135
+ }
136
+ function normalizeArgumentDescriptor(desc) {
137
+ if (desc.type === "array") desc.type = ["any"];
138
+ }
139
+ /**
140
+ * Create a new `SharedMethod` with the given `fn`. The function should include
141
+ * all the method options.
142
+ *
143
+ * @param {Function} fn
144
+ * @param {String} name
145
+ * @param {SharedClass} SharedClass
146
+ * @param {Boolean} isStatic
147
+ */
148
+ SharedMethod.fromFunction = function(fn, name, sharedClass, isStatic) {
149
+ return new SharedMethod(fn, name, sharedClass, {
150
+ isStatic,
151
+ accepts: fn.accepts,
152
+ returns: fn.returns,
153
+ errors: fn.errors,
154
+ description: fn.description,
155
+ notes: fn.notes,
156
+ http: fn.http,
157
+ rest: fn.rest
158
+ });
159
+ };
160
+ SharedMethod.prototype.getReturnArgDescByName = function(name) {
161
+ const returns = this.returns;
162
+ let desc;
163
+ for (let i = 0; i < returns.length; i++) {
164
+ desc = returns[i];
165
+ if (desc && (desc.arg || desc.name) === name) return desc;
166
+ }
167
+ };
168
+ /**
169
+ * Execute the remote method using the given arg data.
170
+ *
171
+ * @param {Object} scope `this` parameter for the invocation
172
+ * @param {Object} args containing named argument data
173
+ * @param {Object=} remotingOptions remote-objects options
174
+ * @param {Function} cb callback `fn(err, result)` containing named result data
175
+ */
176
+ SharedMethod.prototype.invoke = function(scope, args, remotingOptions, ctx, cb) {
177
+ assert(ctx, "invocation context is required");
178
+ const accepts = this.accepts;
179
+ const returns = this.returns;
180
+ this.errors;
181
+ const method = this.getFunction();
182
+ const sharedMethod = this;
183
+ const argCount = accepts ? accepts.length : 0;
184
+ const formattedArgs = new Array(argCount + 1);
185
+ let completed = false;
186
+ if (accepts) for (let i = 0; i < accepts.length; i++) {
187
+ const desc = accepts[i];
188
+ const name = desc.name || desc.arg;
189
+ let uarg = SharedMethod.convertArg(desc, args[name]);
190
+ const conversionOptions = SharedMethod.getConversionOptionsForArg(desc);
191
+ try {
192
+ uarg = validateInputArgument(uarg, desc, ctx, conversionOptions);
193
+ } catch (e) {
194
+ debug("- %s - " + e.message, sharedMethod.name);
195
+ return cb(e);
196
+ }
197
+ formattedArgs[i] = uarg;
198
+ }
199
+ function complete(err, rawArgs) {
200
+ if (completed) return;
201
+ completed = true;
202
+ if (err) return cb(err);
203
+ const result = SharedMethod.toResult(returns, rawArgs, ctx);
204
+ debug("- %s - result %j", sharedMethod.name, result);
205
+ cb(null, result);
206
+ }
207
+ function callback(err) {
208
+ const rawArgsLength = arguments.length > 0 ? arguments.length - 1 : 0;
209
+ const rawArgs = new Array(rawArgsLength);
210
+ for (let i = 1; i < arguments.length; i++) rawArgs[i - 1] = arguments[i];
211
+ return complete(err, rawArgs);
212
+ }
213
+ formattedArgs[argCount] = callback;
214
+ debug("- %s - invoke with", this.name, formattedArgs);
215
+ try {
216
+ const retval = method.apply(scope, formattedArgs);
217
+ if (retval && typeof retval.then === "function") return retval.then(function(args) {
218
+ if (returns.length === 1) args = [args];
219
+ debug("- %s - promise result %j", sharedMethod.name, args);
220
+ complete(null, args);
221
+ }, function(err) {
222
+ complete(err);
223
+ });
224
+ return retval;
225
+ } catch (err) {
226
+ debug("error caught during the invocation of %s: %s", this.name, err.stack || err);
227
+ return cb(err);
228
+ }
229
+ };
230
+ function badArgumentError(msg) {
231
+ const err = new Error(msg);
232
+ err.statusCode = 400;
233
+ return err;
234
+ }
235
+ function internalServerError(msg) {
236
+ const err = new Error(msg);
237
+ err.statusCode = 500;
238
+ return err;
239
+ }
240
+ /**
241
+ * Coerce an 'accepts' value into its final type.
242
+ * If using HTTP, some coercion is already done in http-context.
243
+ *
244
+ * This should only do very simple coercion.
245
+ *
246
+ * @param {*} uarg Argument value.
247
+ * @param {Object} desc Argument description.
248
+ * @param {Context} ctx Remoting request context.
249
+ * @return {*} Coerced argument.
250
+ */
251
+ function validateInputArgument(uarg, desc, ctx, conversionOptions) {
252
+ const name = desc.name || desc.arg;
253
+ if (desc.required) {
254
+ if (uarg === null || uarg === void 0 || uarg === "") throw badArgumentError(g.f("%s is a required argument", name));
255
+ }
256
+ const err = ctx.typeRegistry.getConverter(desc.type).validate(ctx, uarg, conversionOptions);
257
+ if (err) {
258
+ err.message = g.f("Invalid argument %j. ", name) + err.message;
259
+ throw err;
260
+ }
261
+ return uarg;
262
+ }
263
+ /**
264
+ * Returns an appropriate type based on a type specifier from remoting
265
+ * metadata.
266
+ * @param {Object} type A type specifier from remoting metadata,
267
+ * e.g. "[Number]" or "MyModel" from `accepts[0].type`.
268
+ * @returns {String} A type name compatible with the values returned by
269
+ * `SharedMethod.getType()`, e.g. "string" or "array".
270
+ */
271
+ function convertToBasicRemotingType(type) {
272
+ if (Array.isArray(type)) return type.map(convertToBasicRemotingType);
273
+ if (typeof type === "object") type = type.modelName || type.name;
274
+ type = String(type).toLowerCase();
275
+ switch (type) {
276
+ case "string":
277
+ case "number":
278
+ case "integer":
279
+ case "date":
280
+ case "boolean":
281
+ case "buffer":
282
+ case "object":
283
+ case "file":
284
+ case "any": return type;
285
+ case "array": return ["any"];
286
+ default: return "object";
287
+ }
288
+ }
289
+ /**
290
+ * Returns an appropriate type based on `val`.
291
+ * @param {*} val The value to determine the type for
292
+ * @returns {String} The type name
293
+ */
294
+ SharedMethod.getType = function(val, targetType) {
295
+ const type = typeof val;
296
+ switch (type) {
297
+ case "undefined":
298
+ case "boolean":
299
+ case "function":
300
+ case "string": return type;
301
+ case "number": return isInteger(val) && targetType === "integer" ? "integer" : "number";
302
+ case "object":
303
+ if (val === null) return "null";
304
+ if (Buffer.isBuffer(val)) return "buffer";
305
+ if (Array.isArray(val)) return "array";
306
+ if (val instanceof Date) return "date";
307
+ return "object";
308
+ }
309
+ };
310
+ /**
311
+ * Returns a reformatted Object valid for consumption as remoting function
312
+ * arguments
313
+ */
314
+ SharedMethod.convertArg = function(accept, raw) {
315
+ if (accept.http && (typeof accept.http === "function" || accept.http.source === "req" || accept.http.source === "res" || accept.http.source === "context")) return raw;
316
+ if (raw === null || typeof raw !== "object") return raw;
317
+ if (typeof raw === "object" && raw.constructor !== Object && raw.constructor !== Array) return raw;
318
+ return convertSpecialObjects(raw);
319
+ };
320
+ function convertSpecialObjects(value) {
321
+ if (value === null || typeof value !== "object") return value;
322
+ if (Array.isArray(value)) {
323
+ const result = new Array(value.length);
324
+ for (let i = 0; i < value.length; i++) result[i] = convertSpecialObjects(value[i]);
325
+ return result;
326
+ }
327
+ if (value.constructor !== Object) return value;
328
+ if (value.$type === "base64") return Buffer.from(value.$data, "base64");
329
+ if (value.$type === "date") return new Date(value.$data);
330
+ const result = {};
331
+ for (const key in value) result[key] = convertSpecialObjects(value[key]);
332
+ return result;
333
+ }
334
+ /**
335
+ * Returns a reformatted Object valid for consumption as JSON from an Array of
336
+ * results from a remoting function, based on `returns`.
337
+ */
338
+ SharedMethod.toResult = function(returns, raw, ctx) {
339
+ if (!returns.length) return;
340
+ let result = {};
341
+ const rawLength = raw.length;
342
+ for (let index = 0; index < returns.length && index < rawLength; index++) {
343
+ const item = returns[index];
344
+ const name = item.name || item.arg;
345
+ const value = raw[index];
346
+ if (ctx && ctx.setReturnArgByName(name, value)) continue;
347
+ const targetType = convertToBasicRemotingType(item.type);
348
+ if (item.root) {
349
+ result = targetType === "file" ? value : convert(value, targetType, item.name);
350
+ continue;
351
+ }
352
+ if (targetType === "file") {
353
+ g.warn("%s: discarded non-root return argument %s of type \"{{file}}\"", this.stringName, name);
354
+ continue;
355
+ }
356
+ result[name] = convert(value, targetType, name);
357
+ }
358
+ return result;
359
+ function convert(val, targetType, argName) {
360
+ if (Array.isArray(targetType) && targetType.length === 1 && targetType[0] === "integer" && Array.isArray(val)) {
361
+ const arrayTargetType = targetType[0];
362
+ return val.map(function(intVal) {
363
+ return convert(intVal, arrayTargetType, argName);
364
+ });
365
+ }
366
+ switch (SharedMethod.getType(val, targetType)) {
367
+ case "date": return {
368
+ $type: "date",
369
+ $data: val.toJSON ? val.toJSON() : val.toString()
370
+ };
371
+ case "buffer": return {
372
+ $type: "base64",
373
+ $data: val.toString("base64")
374
+ };
375
+ default:
376
+ if (targetType === "integer") {
377
+ let message;
378
+ if (!isInteger(val)) {
379
+ message = g.f("Invalid return value for argument '%s' of type '%s': %s. Received type was %s.", argName, targetType, val, typeof val);
380
+ throw internalServerError(message);
381
+ }
382
+ if (!isSafeInteger(val)) {
383
+ message = g.f("Unsafe integer value returned for argument '%s' of type '%s': %s.", argName, targetType, val);
384
+ throw internalServerError(message);
385
+ }
386
+ return val;
387
+ }
388
+ return val;
389
+ }
390
+ }
391
+ };
392
+ /**
393
+ * Get the function the `SharedMethod` will `invoke()`.
394
+ */
395
+ SharedMethod.prototype.getFunction = function() {
396
+ let fn;
397
+ if (!this.ctor) return this.fn;
398
+ if (this.isStatic) fn = this.ctor[this.name];
399
+ else fn = this.ctor.prototype[this.name];
400
+ return fn || this.fn;
401
+ };
402
+ /**
403
+ * Determine if this shared method invokes the given "suspect" function.
404
+ *
405
+ * @example
406
+ * ```js
407
+ * sharedMethod.isDelegateFor(myClass.myMethod); // pass a function
408
+ * sharedMethod.isDelegateFor(myClass.prototype.myInstMethod);
409
+ * sharedMethod.isDelegateFor('myMethod', true); // check for a static method by name
410
+ * sharedMethod.isDelegateFor('myInstMethod', false); // instance method by name
411
+ * ```
412
+ *
413
+ * @param {String|Function} suspect The name of the suspected function
414
+ * or a `Function`.
415
+ * @returns Boolean True if the shared method invokes the given function; false otherwise.
416
+ */
417
+ SharedMethod.prototype.isDelegateFor = function(suspect, isStatic) {
418
+ const type = typeof suspect;
419
+ isStatic = isStatic || false;
420
+ if (suspect) switch (type) {
421
+ case "function": return this.getFunction() === suspect;
422
+ case "string":
423
+ if (this.isStatic !== isStatic) return false;
424
+ return this.name === suspect || this.aliases.indexOf(suspect) !== -1;
425
+ }
426
+ return false;
427
+ };
428
+ /**
429
+ * Determine if this shared method invokes the given "suspect" function.
430
+ *
431
+ * @example
432
+ * ```js
433
+ * sharedMethod.isDelegateForName('myMethod'); // check for a static method by name
434
+ * sharedMethod.isDelegateForName('prototype.myInstMethod'); // instance method by name
435
+ * ```
436
+ *
437
+ * @returns Boolean True if the shared method invokes the given function; false otherwise.
438
+ */
439
+ SharedMethod.prototype.isDelegateForName = function(suspect) {
440
+ assert(typeof suspect === "string", "argument of isDelegateForName should be string");
441
+ const m = suspect.match(/^prototype\.(.*)$/);
442
+ const isStatic = !m;
443
+ const baseName = isStatic ? suspect : m[1];
444
+ return this.isDelegateFor(baseName, isStatic);
445
+ };
446
+ /**
447
+ * Add an alias
448
+ *
449
+ * @param {String} alias Alias method name.
450
+ */
451
+ SharedMethod.prototype.addAlias = function(alias) {
452
+ if (this.aliases.indexOf(alias) === -1) this.aliases.push(alias);
453
+ };
454
+ /**
455
+ * build conversion options from remote's' args
456
+ *
457
+ * @param {Object} arg Definition of accepts/returns argument.
458
+ * @returns {Object} Options object to pass to type-converter methods, e.g `validate` or `fromTypedValue`.
459
+ */
460
+ SharedMethod.getConversionOptionsForArg = function(arg) {
461
+ const options = {};
462
+ if (arg.allowArray) options.allowArray = arg.allowArray;
463
+ return options;
464
+ };
465
+ }));
466
+ //#endregion
467
+ module.exports = require_shared_method();
468
+
469
+ //# sourceMappingURL=shared-method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-method.js","names":[],"sources":["../../src/lib/shared-method.ts"],"sourcesContent":["// Copyright IBM Corp. 2013,2018. All Rights Reserved.\n// Node module: strong-remoting\n// This file is licensed under the Artistic License 2.0.\n// License text available at https://opensource.org/licenses/Artistic-2.0\n\n// @ts-nocheck\n'use strict';\n\nconst g = require('./messages');\n\n/*!\n * Expose `SharedMethod`.\n */\nmodule.exports = SharedMethod;\n\nconst debug = require('debug')('strong-remoting:shared-method');\nconst util = require('util');\nconst assert = require('assert');\nconst Context = require('./context-base');\nconst numberChecks = require('./number-checks');\n\nconst isInteger = numberChecks.isSafeInteger;\nconst isSafeInteger = numberChecks.isSafeInteger;\n\n/**\n * Create a new `SharedMethod` (remote method) with the given `fn`.\n * See also [Remote methods](http://docs.strongloop.com/display/LB/Remote+methods).\n *\n * @property {String} name The method name.\n * @property {String[]} aliases An array of method aliases.\n * @property {Boolean} isStatic Whether the method is static; from `options.isStatic`.\n * Default is `true`.\n * @property {Array|Object} accepts See `options.accepts`.\n * @property {Array|Object} returns See `options.returns`.\n * @property {Array|Object} errors See `options.errors`.\n * @property {String} description Text description of the method.\n * @property {String} notes Additional notes, used by API documentation generators like\n * Swagger.\n * @property {String} http\n * @property {Object} rest\n * @property {Boolean} shared\n * @property {Boolean} [documented] Default: true. Set to `false` to exclude the method\n * from Swagger metadata.\n *\n * @param {Function} fn The `Function` to be invoked when the method is invoked.\n * @param {String} name The name of the `SharedMethod`.\n * @param {SharedClass} sharedClass The `SharedClass` to which the method will be attached.\n *\n * @options {Object} options See below.\n * @property {Array|Object} [accepts] Defines either a single argument as an object or an\n * ordered set of arguments as an array.\n * @property {String} [accepts.arg] The name of the argument.\n * @property {String} [accepts.description] Text description of the argument, used by API\n * documentation generators like Swagger.\n * @property {String} [accepts.http] HTTP mapping for the argument. See argument mapping in\n * [the docs](http://docs.strongloop.com/x/-Yw6#Remotemethods-HTTPmappingofinputarguments).\n * @property {String} [accepts.http.source] The HTTP source for the argument. May be one\n * of the following:\n *\n * - `req` - the Express `Request` object.\n * - `res` - the Express `Response` object.\n * - `body` - the `req.body` value.\n * - `form` - `req.body[argumentName]`.\n * - `query` - `req.query[argumentName]`.\n * - `path` - `req.params[argumentName]`.\n * - `header` - `req.headers[argumentName]`.\n * - `context` - the current `HttpContext`.\n * @property {Object} [accepts.rest] The REST mapping / settings for the argument.\n * @property {String} [accepts.type] Argument datatype; must be a\n * [Loopback type](http://docs.strongloop.com/display/LB/LoopBack+types).\n * @property {Array} [aliases] A list of aliases for the method.\n * @property {Array|Object} [errors] Object or `Array` containing error definitions.\n * @property {Array} [http] HTTP-only options.\n * @property {Number} [http.errorStatus] Default error status code.\n * @property {String} [http.path] HTTP path (relative to the model) at which the method is\n * exposed.\n * @property {Number} [http.status] Default status code when the callback is called\n * _without_ an error.\n * @property {String} [http.verb] HTTP method (verb) at which the method is available.\n * One of: get, post (default), put, del, or all\n * @property {Boolean} [isStatic] Whether the method is a static method or a prototype\n * method.\n * @property {Array|Object} [returns] Specifies the remote method's callback arguments;\n * either a single argument as an object or an ordered set of arguments as an array.\n * The `err` argument is assumed; do not specify. NOTE: Can have the same properties as\n * `accepts`, except for `http.target`.\n *\n * Additionally, one of the callback arguments can have `type: 'file'` and\n * `root:true`, in which case this argument is sent in the raw form as\n * a response body. Allowed values: `String`, `Buffer` or `ReadableStream`\n * @property {Boolean} [shared] Whether the method is shared. Default is `true`.\n * @property {Number} [status] The default status code.\n * @end\n *\n * @class\n */\n\nfunction SharedMethod(fn, name, sc, options) {\n if (typeof options === 'boolean') {\n options = { isStatic: options };\n }\n\n this.fn = fn;\n fn = fn || {};\n this.name = name;\n assert(typeof name === 'string', 'The method name must be a string');\n options = options || {};\n this.aliases = options.aliases || [];\n const isStatic = (this.isStatic = options.isStatic || false);\n this.accepts = options.accepts || fn.accepts || [];\n this.returns = options.returns || fn.returns || [];\n this.errors = options.errors || fn.errors || [];\n this.description = options.description || fn.description;\n this.accessType = options.accessType || fn.accessType;\n this.notes = options.notes || fn.notes;\n this.documented = options.documented !== false && fn.documented !== false;\n this.http = options.http || fn.http || {};\n this.rest = options.rest || fn.rest || {};\n this.shared = options.shared;\n if (this.shared === undefined) {\n this.shared = true;\n }\n if (fn.shared === false) {\n this.shared = false;\n }\n this.sharedClass = sc;\n\n if (sc) {\n this.ctor = sc.ctor;\n this.sharedCtor = sc.sharedCtor;\n }\n if (name === 'sharedCtor') {\n this.isSharedCtor = true;\n }\n\n if (this.accepts && !Array.isArray(this.accepts)) {\n this.accepts = [this.accepts];\n }\n this.accepts.forEach(normalizeArgumentDescriptor);\n\n if (this.returns && !Array.isArray(this.returns)) {\n this.returns = [this.returns];\n }\n this.returns.forEach(normalizeArgumentDescriptor);\n\n const firstReturns = this.returns[0];\n const streamTypes = ['ReadableStream', 'WriteableStream', 'DuplexStream'];\n\n if (firstReturns && firstReturns.type && streamTypes.indexOf(firstReturns.type) > -1) {\n this.streams = { returns: firstReturns };\n }\n\n if (this.errors && !Array.isArray(this.errors)) {\n this.errors = [this.errors];\n }\n\n if (/^prototype\\./.test(name)) {\n const msg =\n 'Incorrect API usage. Shared methods on prototypes should be ' +\n 'created via `new SharedMethod(fn, \"name\", { isStatic: false })`';\n throw new Error(msg);\n }\n\n this.stringName = (sc ? sc.name : '') + (isStatic ? '.' : '.prototype.') + name;\n\n // Include any remaining metadata to support custom user-defined extensions\n for (const key in options) {\n if (this[key]) continue;\n this[key] = options[key];\n }\n}\n\nfunction normalizeArgumentDescriptor(desc) {\n if (desc.type === 'array') desc.type = ['any'];\n}\n\n/**\n * Create a new `SharedMethod` with the given `fn`. The function should include\n * all the method options.\n *\n * @param {Function} fn\n * @param {String} name\n * @param {SharedClass} SharedClass\n * @param {Boolean} isStatic\n */\n\nSharedMethod.fromFunction = function (fn, name, sharedClass, isStatic) {\n return new SharedMethod(fn, name, sharedClass, {\n isStatic: isStatic,\n accepts: fn.accepts,\n returns: fn.returns,\n errors: fn.errors,\n description: fn.description,\n notes: fn.notes,\n http: fn.http,\n rest: fn.rest,\n });\n};\n\nSharedMethod.prototype.getReturnArgDescByName = function (name) {\n const returns = this.returns;\n let desc;\n for (let i = 0; i < returns.length; i++) {\n desc = returns[i];\n if (desc && (desc.arg || desc.name) === name) {\n return desc;\n }\n }\n};\n\n/**\n * Execute the remote method using the given arg data.\n *\n * @param {Object} scope `this` parameter for the invocation\n * @param {Object} args containing named argument data\n * @param {Object=} remotingOptions remote-objects options\n * @param {Function} cb callback `fn(err, result)` containing named result data\n */\n\nSharedMethod.prototype.invoke = function (scope, args, remotingOptions, ctx, cb) {\n assert(ctx, 'invocation context is required');\n\n const accepts = this.accepts;\n const returns = this.returns;\n const errors = this.errors;\n const method = this.getFunction();\n const sharedMethod = this;\n const argCount = accepts ? accepts.length : 0;\n const formattedArgs = new Array(argCount + 1);\n let completed = false;\n\n // map the given arg data in order they are expected in\n if (accepts) {\n for (let i = 0; i < accepts.length; i++) {\n const desc = accepts[i];\n const name = desc.name || desc.arg;\n let uarg = SharedMethod.convertArg(desc, args[name]);\n const conversionOptions = SharedMethod.getConversionOptionsForArg(desc);\n\n try {\n uarg = validateInputArgument(uarg, desc, ctx, conversionOptions);\n } catch (e) {\n debug('- %s - ' + e.message, sharedMethod.name);\n return cb(e);\n }\n // Add the argument even if it's undefined to stick with the accepts\n formattedArgs[i] = uarg;\n }\n }\n\n // define the callback\n function complete(err, rawArgs) {\n if (completed) {\n return;\n }\n\n completed = true;\n\n if (err) {\n return cb(err);\n }\n\n const result = SharedMethod.toResult(returns, rawArgs, ctx);\n\n debug('- %s - result %j', sharedMethod.name, result);\n\n cb(null, result);\n }\n\n // define the callback\n function callback(err) {\n // args without err\n const rawArgsLength = arguments.length > 0 ? arguments.length - 1 : 0;\n const rawArgs = new Array(rawArgsLength);\n for (let i = 1; i < arguments.length; i++) {\n rawArgs[i - 1] = arguments[i];\n }\n return complete(err, rawArgs);\n }\n\n // add in the required callback\n formattedArgs[argCount] = callback;\n\n debug('- %s - invoke with', this.name, formattedArgs);\n\n // invoke\n try {\n const retval = method.apply(scope, formattedArgs);\n if (retval && typeof retval.then === 'function') {\n return retval.then(\n function (args) {\n if (returns.length === 1) args = [args];\n debug('- %s - promise result %j', sharedMethod.name, args);\n complete(null, args);\n },\n function (err) {\n complete(err);\n },\n );\n }\n return retval;\n } catch (err) {\n debug('error caught during the invocation of %s: %s', this.name, err.stack || err);\n return cb(err);\n }\n};\n\nfunction badArgumentError(msg) {\n const err = new Error(msg);\n err.statusCode = 400;\n return err;\n}\n\nfunction internalServerError(msg) {\n const err = new Error(msg);\n err.statusCode = 500;\n return err;\n}\n\nfunction escapeRegex(d) {\n // see http://stackoverflow.com/a/6969486/69868\n return d.replace(/[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, '\\\\$&');\n}\n\n/**\n * Coerce an 'accepts' value into its final type.\n * If using HTTP, some coercion is already done in http-context.\n *\n * This should only do very simple coercion.\n *\n * @param {*} uarg Argument value.\n * @param {Object} desc Argument description.\n * @param {Context} ctx Remoting request context.\n * @return {*} Coerced argument.\n */\nfunction validateInputArgument(uarg, desc, ctx, conversionOptions) {\n const name = desc.name || desc.arg;\n\n // Verify that a required argument has a value\n if (desc.required) {\n const argIsNotSet = uarg === null || uarg === undefined || uarg === '';\n if (argIsNotSet) {\n throw badArgumentError(g.f('%s is a required argument', name));\n }\n }\n\n const converter = ctx.typeRegistry.getConverter(desc.type);\n const err = converter.validate(ctx, uarg, conversionOptions);\n if (err) {\n err.message = g.f('Invalid argument %j. ', name) + err.message;\n throw err;\n }\n\n return uarg;\n}\n\n/**\n * Returns an appropriate type based on a type specifier from remoting\n * metadata.\n * @param {Object} type A type specifier from remoting metadata,\n * e.g. \"[Number]\" or \"MyModel\" from `accepts[0].type`.\n * @returns {String} A type name compatible with the values returned by\n * `SharedMethod.getType()`, e.g. \"string\" or \"array\".\n */\nfunction convertToBasicRemotingType(type) {\n if (Array.isArray(type)) {\n return type.map(convertToBasicRemotingType);\n }\n\n if (typeof type === 'object') {\n type = type.modelName || type.name;\n }\n\n type = String(type).toLowerCase();\n\n switch (type) {\n case 'string':\n case 'number':\n case 'integer':\n case 'date':\n case 'boolean':\n case 'buffer':\n case 'object':\n case 'file':\n case 'any':\n return type;\n case 'array':\n return ['any'];\n default:\n // custom types like MyModel\n return 'object';\n }\n}\n\n/**\n * Returns an appropriate type based on `val`.\n * @param {*} val The value to determine the type for\n * @returns {String} The type name\n */\n\nSharedMethod.getType = function (val, targetType) {\n const type = typeof val;\n\n switch (type) {\n case 'undefined':\n case 'boolean':\n case 'function':\n case 'string':\n return type;\n case 'number':\n return isInteger(val) && targetType === 'integer' ? 'integer' : 'number';\n case 'object':\n // null\n if (val === null) {\n return 'null';\n }\n\n // buffer\n if (Buffer.isBuffer(val)) {\n return 'buffer';\n }\n\n // array\n if (Array.isArray(val)) {\n return 'array';\n }\n\n // date\n if (val instanceof Date) {\n return 'date';\n }\n\n // object\n return 'object';\n }\n};\n\n/**\n * Returns a reformatted Object valid for consumption as remoting function\n * arguments\n */\n\nSharedMethod.convertArg = function (accept, raw) {\n const isComputedArgument =\n accept.http &&\n (typeof accept.http === 'function' ||\n accept.http.source === 'req' ||\n accept.http.source === 'res' ||\n accept.http.source === 'context');\n\n if (isComputedArgument) {\n return raw;\n }\n\n if (raw === null || typeof raw !== 'object') {\n return raw;\n }\n if (typeof raw === 'object' && raw.constructor !== Object && raw.constructor !== Array) {\n // raw is not plain\n return raw;\n }\n\n return convertSpecialObjects(raw);\n};\n\nfunction convertSpecialObjects(value) {\n if (value === null || typeof value !== 'object') {\n return value;\n }\n\n if (Array.isArray(value)) {\n const result = new Array(value.length);\n for (let i = 0; i < value.length; i++) {\n result[i] = convertSpecialObjects(value[i]);\n }\n return result;\n }\n\n if (value.constructor !== Object) {\n return value;\n }\n\n if (value.$type === 'base64') {\n return Buffer.from(value.$data, 'base64');\n }\n\n if (value.$type === 'date') {\n return new Date(value.$data);\n }\n\n const result = {};\n for (const key in value) {\n result[key] = convertSpecialObjects(value[key]);\n }\n\n return result;\n}\n\n/**\n * Returns a reformatted Object valid for consumption as JSON from an Array of\n * results from a remoting function, based on `returns`.\n */\n\nSharedMethod.toResult = function (returns, raw, ctx) {\n if (!returns.length) {\n return;\n }\n\n let result = {};\n const rawLength = raw.length;\n\n for (let index = 0; index < returns.length && index < rawLength; index++) {\n const item = returns[index];\n const name = item.name || item.arg;\n const value = raw[index];\n\n if (ctx && ctx.setReturnArgByName(name, value)) {\n continue;\n }\n\n const targetType = convertToBasicRemotingType(item.type);\n if (item.root) {\n const isFile = targetType === 'file';\n result = isFile ? value : convert(value, targetType, item.name);\n continue;\n }\n\n if (targetType === 'file') {\n g.warn('%s: discarded non-root return argument %s of type \"{{file}}\"', this.stringName, name);\n continue;\n }\n\n result[name] = convert(value, targetType, name);\n }\n\n return result;\n\n function convert(val, targetType, argName) {\n const targetTypeIsIntegerArray =\n Array.isArray(targetType) && targetType.length === 1 && targetType[0] === 'integer';\n\n if (targetTypeIsIntegerArray && Array.isArray(val)) {\n const arrayTargetType = targetType[0];\n return val.map(function (intVal) {\n return convert(intVal, arrayTargetType, argName);\n });\n }\n\n const actualType = SharedMethod.getType(val, targetType);\n\n switch (actualType) {\n case 'date':\n return {\n $type: 'date',\n $data: val.toJSON ? val.toJSON() : val.toString(),\n };\n case 'buffer':\n return {\n $type: 'base64',\n $data: val.toString('base64'),\n };\n default:\n if (targetType === 'integer') {\n let message;\n\n if (!isInteger(val)) {\n message = g.f(\n \"Invalid return value for argument '%s' of type \" + \"'%s': %s. Received type was %s.\",\n argName,\n targetType,\n val,\n typeof val,\n );\n throw internalServerError(message);\n }\n\n if (!isSafeInteger(val)) {\n message = g.f(\n \"Unsafe integer value returned for argument '%s' of type \" + \"'%s': %s.\",\n argName,\n targetType,\n val,\n );\n throw internalServerError(message);\n }\n return val;\n }\n return val;\n }\n }\n};\n\n/**\n * Get the function the `SharedMethod` will `invoke()`.\n */\n\nSharedMethod.prototype.getFunction = function () {\n let fn;\n\n if (!this.ctor) return this.fn;\n\n if (this.isStatic) {\n fn = this.ctor[this.name];\n } else {\n fn = this.ctor.prototype[this.name];\n }\n\n return fn || this.fn;\n};\n\n/**\n * Determine if this shared method invokes the given \"suspect\" function.\n *\n * @example\n * ```js\n * sharedMethod.isDelegateFor(myClass.myMethod); // pass a function\n * sharedMethod.isDelegateFor(myClass.prototype.myInstMethod);\n * sharedMethod.isDelegateFor('myMethod', true); // check for a static method by name\n * sharedMethod.isDelegateFor('myInstMethod', false); // instance method by name\n * ```\n *\n * @param {String|Function} suspect The name of the suspected function\n * or a `Function`.\n * @returns Boolean True if the shared method invokes the given function; false otherwise.\n */\n\nSharedMethod.prototype.isDelegateFor = function (suspect, isStatic) {\n const type = typeof suspect;\n isStatic = isStatic || false;\n\n if (suspect) {\n switch (type) {\n case 'function':\n return this.getFunction() === suspect;\n case 'string':\n if (this.isStatic !== isStatic) return false;\n return this.name === suspect || this.aliases.indexOf(suspect) !== -1;\n }\n }\n\n return false;\n};\n\n/**\n * Determine if this shared method invokes the given \"suspect\" function.\n *\n * @example\n * ```js\n * sharedMethod.isDelegateForName('myMethod'); // check for a static method by name\n * sharedMethod.isDelegateForName('prototype.myInstMethod'); // instance method by name\n * ```\n *\n * @returns Boolean True if the shared method invokes the given function; false otherwise.\n */\n\nSharedMethod.prototype.isDelegateForName = function (suspect) {\n assert(typeof suspect === 'string', 'argument of isDelegateForName should be string');\n\n const m = suspect.match(/^prototype\\.(.*)$/);\n const isStatic = !m;\n const baseName = isStatic ? suspect : m[1];\n return this.isDelegateFor(baseName, isStatic);\n};\n\n/**\n * Add an alias\n *\n * @param {String} alias Alias method name.\n */\n\nSharedMethod.prototype.addAlias = function (alias) {\n if (this.aliases.indexOf(alias) === -1) {\n this.aliases.push(alias);\n }\n};\n\n/**\n * build conversion options from remote's' args\n *\n * @param {Object} arg Definition of accepts/returns argument.\n * @returns {Object} Options object to pass to type-converter methods, e.g `validate` or `fromTypedValue`.\n */\nSharedMethod.getConversionOptionsForArg = function (arg) {\n const options = {};\n\n // option for object coercion to allow Array of objects as well as objects\n if (arg.allowArray) {\n options.allowArray = arg.allowArray;\n }\n return options;\n};\n"],"mappings":";;;;;;;CAQA,MAAM,IAAA;;;;AAKN,QAAO,UAAU;CAEjB,MAAM,QAAQ,QAAQ,QAAQ,CAAC,gCAAgC;AAClD,SAAQ,OAAO;CAC5B,MAAM,SAAS,QAAQ,SAAS;CAEhC,MAAM,eAAA;CAEN,MAAM,YAAY,aAAa;CAC/B,MAAM,gBAAgB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2EnC,SAAS,aAAa,IAAI,MAAM,IAAI,SAAS;AAC3C,MAAI,OAAO,YAAY,UACrB,WAAU,EAAE,UAAU,SAAS;AAGjC,OAAK,KAAK;AACV,OAAK,MAAM,EAAE;AACb,OAAK,OAAO;AACZ,SAAO,OAAO,SAAS,UAAU,mCAAmC;AACpE,YAAU,WAAW,EAAE;AACvB,OAAK,UAAU,QAAQ,WAAW,EAAE;EACpC,MAAM,WAAY,KAAK,WAAW,QAAQ,YAAY;AACtD,OAAK,UAAU,QAAQ,WAAW,GAAG,WAAW,EAAE;AAClD,OAAK,UAAU,QAAQ,WAAW,GAAG,WAAW,EAAE;AAClD,OAAK,SAAS,QAAQ,UAAU,GAAG,UAAU,EAAE;AAC/C,OAAK,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;;;;;;;;;;;;AAeT,cAAa,UAAU,oBAAoB,SAAU,SAAS;AAC5D,SAAO,OAAO,YAAY,UAAU,iDAAiD;EAErF,MAAM,IAAI,QAAQ,MAAM,oBAAoB;EAC5C,MAAM,WAAW,CAAC;EAClB,MAAM,WAAW,WAAW,UAAU,EAAE;AACxC,SAAO,KAAK,cAAc,UAAU,SAAS;;;;;;;AAS/C,cAAa,UAAU,WAAW,SAAU,OAAO;AACjD,MAAI,KAAK,QAAQ,QAAQ,MAAM,KAAK,GAClC,MAAK,QAAQ,KAAK,MAAM;;;;;;;;AAU5B,cAAa,6BAA6B,SAAU,KAAK;EACvD,MAAM,UAAU,EAAE;AAGlB,MAAI,IAAI,WACN,SAAQ,aAAa,IAAI;AAE3B,SAAO"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ const require_lib_messages = require("./messages.js");
3
+ const require_lib_socket_io_context = require("./socket-io-context.js");
4
+ //#region src/lib/socket-io-adapter.ts
5
+ const g = require_lib_messages;
6
+ /**
7
+ * Expose `SocketIOAdapter`.
8
+ */
9
+ module.exports = SocketIOAdapter;
10
+ /**
11
+ * Module dependencies.
12
+ */
13
+ const EventEmitter = require("events").EventEmitter;
14
+ const inherits = require("util").inherits;
15
+ const { Server } = require("socket.io");
16
+ const SocketIOContext = require_lib_socket_io_context;
17
+ /**
18
+ * Create a new `RestAdapter` with the given `options`.
19
+ *
20
+ * @param {Object} options
21
+ * @return {RestAdapter}
22
+ */
23
+ function SocketIOAdapter(remotes, server) {
24
+ EventEmitter.apply(this, arguments);
25
+ this.remotes = remotes;
26
+ this.server = server;
27
+ this.Context = SocketIOContext;
28
+ }
29
+ /**
30
+ * Inherit from `EventEmitter`.
31
+ */
32
+ inherits(SocketIOAdapter, EventEmitter);
33
+ /*!
34
+ * Simplified APIs
35
+ */
36
+ SocketIOAdapter.create = function(remotes) {
37
+ return new SocketIOAdapter(remotes);
38
+ };
39
+ SocketIOAdapter.prototype.createHandler = function() {
40
+ const adapter = this;
41
+ const remotes = this.remotes;
42
+ const Context = this.Context;
43
+ this.remotes.classes();
44
+ new Server(this.server).on("connection", function(socket) {
45
+ socket.on("invoke", function(methodString, ctorArgs, args, id) {
46
+ const method = remotes.findMethod(methodString);
47
+ if (method) {
48
+ const ctx = new Context(socket.request, ctorArgs, args);
49
+ adapter.invoke(ctx, method, args, function(err, result) {
50
+ socket.emit("result", {
51
+ data: result,
52
+ id,
53
+ methodString,
54
+ __types__: method.returns
55
+ });
56
+ });
57
+ } else socket.emit("result", {
58
+ err: g.f("method does not exist"),
59
+ id,
60
+ methodString
61
+ });
62
+ });
63
+ });
64
+ };
65
+ SocketIOAdapter.prototype.invoke = function(ctx, method, args, callback) {
66
+ const remotes = this.remotes;
67
+ if (method.isStatic) remotes.execHooks("before", method, method.ctor, ctx, function(err) {
68
+ if (err) return callback(err);
69
+ ctx.invoke(method.ctor, method, function(err, result) {
70
+ if (err) return callback(err);
71
+ ctx.result = result;
72
+ remotes.execHooks("after", method, method.ctor, ctx, function(err) {
73
+ callback(err, ctx.result);
74
+ });
75
+ });
76
+ });
77
+ else ctx.invoke(method, method.sharedCtor, function(err, inst) {
78
+ if (err) return callback(err);
79
+ remotes.execHooks("before", method, inst, ctx, function(err) {
80
+ if (err) callback(err);
81
+ else ctx.invoke(inst, method, function(err, result) {
82
+ if (err) return callback(err);
83
+ ctx.result = result;
84
+ remotes.execHooks("after", method, inst, ctx, function(err) {
85
+ callback(err, ctx.result);
86
+ });
87
+ });
88
+ });
89
+ });
90
+ };
91
+ //#endregion
92
+
93
+ //# sourceMappingURL=socket-io-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket-io-adapter.js","names":[],"sources":["../../src/lib/socket-io-adapter.ts"],"sourcesContent":["// Copyright IBM Corp. 2013,2017. All Rights Reserved.\n// Node module: strong-remoting\n// This file is licensed under the Artistic License 2.0.\n// License text available at https://opensource.org/licenses/Artistic-2.0\n\n// @ts-nocheck\n'use strict';\n\nconst g = require('./messages');\n/**\n * Expose `SocketIOAdapter`.\n */\nmodule.exports = SocketIOAdapter;\n\n/**\n * Module dependencies.\n */\n\nconst EventEmitter = require('events').EventEmitter;\nconst util = require('util');\nconst inherits = util.inherits;\nconst { Server } = require('socket.io');\nconst SocketIOContext = require('./socket-io-context');\n\n/**\n * Create a new `RestAdapter` with the given `options`.\n *\n * @param {Object} options\n * @return {RestAdapter}\n */\n\nfunction SocketIOAdapter(remotes, server) {\n EventEmitter.apply(this, arguments);\n\n // throw an error if args are not supplied\n // assert(typeof options === 'object',\n // 'RestAdapter requires an options object');\n\n this.remotes = remotes;\n this.server = server;\n this.Context = SocketIOContext;\n}\n\n/**\n * Inherit from `EventEmitter`.\n */\n\ninherits(SocketIOAdapter, EventEmitter);\n\n/*!\n * Simplified APIs\n */\n\nSocketIOAdapter.create = function (remotes) {\n // add simplified construction / sugar here\n return new SocketIOAdapter(remotes);\n};\n\nSocketIOAdapter.prototype.createHandler = function () {\n const adapter = this;\n const remotes = this.remotes;\n const Context = this.Context;\n const classes = this.remotes.classes();\n const io = new Server(this.server);\n\n io.on('connection', function (socket) {\n socket.on('invoke', function (methodString, ctorArgs, args, id) {\n const method = remotes.findMethod(methodString);\n\n if (method) {\n // create context NEED ARGS\n const ctx = new Context(socket.request, ctorArgs, args);\n\n adapter.invoke(ctx, method, args, function (err, result) {\n socket.emit('result', {\n data: result,\n id: id,\n methodString: methodString,\n __types__: method.returns,\n });\n });\n } else {\n socket.emit('result', {\n err: g.f('method does not exist'),\n id: id,\n methodString: methodString,\n });\n }\n });\n });\n};\n\nSocketIOAdapter.prototype.invoke = function (ctx, method, args, callback) {\n const remotes = this.remotes;\n\n if (method.isStatic) {\n remotes.execHooks('before', method, method.ctor, ctx, function (err) {\n if (err) return callback(err);\n\n // invoke the static method on the actual constructor\n ctx.invoke(method.ctor, method, function (err, result) {\n if (err) return callback(err);\n ctx.result = result;\n remotes.execHooks('after', method, method.ctor, ctx, function (err) {\n // send the result\n callback(err, ctx.result);\n });\n });\n });\n } else {\n // invoke the shared constructor to get an instance\n ctx.invoke(method, method.sharedCtor, function (err, inst) {\n if (err) return callback(err);\n remotes.execHooks('before', method, inst, ctx, function (err) {\n if (err) {\n callback(err);\n } else {\n // invoke the instance method\n ctx.invoke(inst, method, function (err, result) {\n if (err) return callback(err);\n\n ctx.result = result;\n remotes.execHooks('after', method, inst, ctx, function (err) {\n // send the result\n callback(err, ctx.result);\n });\n });\n }\n });\n });\n }\n};\n"],"mappings":";;;;AAQA,MAAM,IAAA;;;;AAIN,OAAO,UAAU;;;;AAMjB,MAAM,eAAe,QAAQ,SAAS,CAAC;AAEvC,MAAM,WADO,QAAQ,OAAO,CACN;AACtB,MAAM,EAAE,WAAW,QAAQ,YAAY;AACvC,MAAM,kBAAA;;;;;;;AASN,SAAS,gBAAgB,SAAS,QAAQ;AACxC,cAAa,MAAM,MAAM,UAAU;AAMnC,MAAK,UAAU;AACf,MAAK,SAAS;AACd,MAAK,UAAU;;;;;AAOjB,SAAS,iBAAiB,aAAa;;;;AAMvC,gBAAgB,SAAS,SAAU,SAAS;AAE1C,QAAO,IAAI,gBAAgB,QAAQ;;AAGrC,gBAAgB,UAAU,gBAAgB,WAAY;CACpD,MAAM,UAAU;CAChB,MAAM,UAAU,KAAK;CACrB,MAAM,UAAU,KAAK;AACL,MAAK,QAAQ,SAAS;AAC3B,KAAI,OAAO,KAAK,OAAO,CAE/B,GAAG,cAAc,SAAU,QAAQ;AACpC,SAAO,GAAG,UAAU,SAAU,cAAc,UAAU,MAAM,IAAI;GAC9D,MAAM,SAAS,QAAQ,WAAW,aAAa;AAE/C,OAAI,QAAQ;IAEV,MAAM,MAAM,IAAI,QAAQ,OAAO,SAAS,UAAU,KAAK;AAEvD,YAAQ,OAAO,KAAK,QAAQ,MAAM,SAAU,KAAK,QAAQ;AACvD,YAAO,KAAK,UAAU;MACpB,MAAM;MACF;MACU;MACd,WAAW,OAAO;MACnB,CAAC;MACF;SAEF,QAAO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