@cloudnux/cloud-sdk 0.18.0 → 0.20.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/dist/index.js CHANGED
@@ -1,36 +1,17 @@
1
1
  // src/provider.ts
2
- var provider = null;
3
- function getCloudProvider() {
4
- if (!provider) {
5
- throw new Error("Cloud provider is not defined. Please set a valid cloud provider using useProvider.");
6
- }
7
- return provider;
8
- }
9
- function useCloudProvider(cloudProvider) {
10
- if (!cloudProvider) {
11
- throw new Error("Cloud provider is not defined. Please set a valid cloud provider using useProvider.");
12
- }
13
- provider = cloudProvider;
14
- }
2
+ import { registerServices } from "@cloudnux/core-cloud-provider";
15
3
 
16
- // src/services/event-broker.ts
17
- var _cloudEventBroker = null;
18
- var cloudEventBroker = () => {
19
- if (_cloudEventBroker) {
20
- return _cloudEventBroker;
4
+ // src/services/logger.ts
5
+ var _loggingService = null;
6
+ var cloudLogger = () => {
7
+ if (_loggingService) {
8
+ return _loggingService;
21
9
  }
22
- _cloudEventBroker = getCloudProvider().createEventBrokerService();
23
- return _cloudEventBroker;
10
+ _loggingService = getCloudProvider().createLoggerService();
11
+ return _loggingService;
24
12
  };
25
-
26
- // src/services/invoke.ts
27
- var _cloudInvoke = null;
28
- var cloudInvoke = () => {
29
- if (_cloudInvoke) {
30
- return _cloudInvoke;
31
- }
32
- _cloudInvoke = getCloudProvider().createInvokeService();
33
- return _cloudInvoke;
13
+ var resetCloudLogger = () => {
14
+ _loggingService = null;
34
15
  };
35
16
 
36
17
  // src/services/storage.ts
@@ -42,6 +23,9 @@ var cloudStorage = () => {
42
23
  _cloudStorageService = getCloudProvider().createStorageService();
43
24
  return _cloudStorageService;
44
25
  };
26
+ var resetCloudStorage = () => {
27
+ _cloudStorageService = null;
28
+ };
45
29
 
46
30
  // src/services/locations.ts
47
31
  var _cloudLocationService = null;
@@ -52,974 +36,105 @@ var cloudLocations = () => {
52
36
  _cloudLocationService = getCloudProvider().createLocationService();
53
37
  return _cloudLocationService;
54
38
  };
55
-
56
- // ../../node_modules/lodash-es/_freeGlobal.js
57
- var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
58
- var freeGlobal_default = freeGlobal;
59
-
60
- // ../../node_modules/lodash-es/_root.js
61
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
62
- var root = freeGlobal_default || freeSelf || Function("return this")();
63
- var root_default = root;
64
-
65
- // ../../node_modules/lodash-es/_Symbol.js
66
- var Symbol = root_default.Symbol;
67
- var Symbol_default = Symbol;
68
-
69
- // ../../node_modules/lodash-es/_getRawTag.js
70
- var objectProto = Object.prototype;
71
- var hasOwnProperty = objectProto.hasOwnProperty;
72
- var nativeObjectToString = objectProto.toString;
73
- var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
74
- function getRawTag(value) {
75
- var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
76
- try {
77
- value[symToStringTag] = void 0;
78
- var unmasked = true;
79
- } catch (e) {
80
- }
81
- var result = nativeObjectToString.call(value);
82
- if (unmasked) {
83
- if (isOwn) {
84
- value[symToStringTag] = tag;
85
- } else {
86
- delete value[symToStringTag];
87
- }
88
- }
89
- return result;
90
- }
91
- var getRawTag_default = getRawTag;
92
-
93
- // ../../node_modules/lodash-es/_objectToString.js
94
- var objectProto2 = Object.prototype;
95
- var nativeObjectToString2 = objectProto2.toString;
96
- function objectToString(value) {
97
- return nativeObjectToString2.call(value);
98
- }
99
- var objectToString_default = objectToString;
100
-
101
- // ../../node_modules/lodash-es/_baseGetTag.js
102
- var nullTag = "[object Null]";
103
- var undefinedTag = "[object Undefined]";
104
- var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
105
- function baseGetTag(value) {
106
- if (value == null) {
107
- return value === void 0 ? undefinedTag : nullTag;
108
- }
109
- return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
110
- }
111
- var baseGetTag_default = baseGetTag;
112
-
113
- // ../../node_modules/lodash-es/isObjectLike.js
114
- function isObjectLike(value) {
115
- return value != null && typeof value == "object";
116
- }
117
- var isObjectLike_default = isObjectLike;
118
-
119
- // ../../node_modules/lodash-es/isSymbol.js
120
- var symbolTag = "[object Symbol]";
121
- function isSymbol(value) {
122
- return typeof value == "symbol" || isObjectLike_default(value) && baseGetTag_default(value) == symbolTag;
123
- }
124
- var isSymbol_default = isSymbol;
125
-
126
- // ../../node_modules/lodash-es/_arrayMap.js
127
- function arrayMap(array2, iteratee) {
128
- var index = -1, length = array2 == null ? 0 : array2.length, result = Array(length);
129
- while (++index < length) {
130
- result[index] = iteratee(array2[index], index, array2);
131
- }
132
- return result;
133
- }
134
- var arrayMap_default = arrayMap;
135
-
136
- // ../../node_modules/lodash-es/isArray.js
137
- var isArray = Array.isArray;
138
- var isArray_default = isArray;
139
-
140
- // ../../node_modules/lodash-es/_baseToString.js
141
- var INFINITY = 1 / 0;
142
- var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
143
- var symbolToString = symbolProto ? symbolProto.toString : void 0;
144
- function baseToString(value) {
145
- if (typeof value == "string") {
146
- return value;
147
- }
148
- if (isArray_default(value)) {
149
- return arrayMap_default(value, baseToString) + "";
150
- }
151
- if (isSymbol_default(value)) {
152
- return symbolToString ? symbolToString.call(value) : "";
153
- }
154
- var result = value + "";
155
- return result == "0" && 1 / value == -INFINITY ? "-0" : result;
156
- }
157
- var baseToString_default = baseToString;
158
-
159
- // ../../node_modules/lodash-es/_trimmedEndIndex.js
160
- var reWhitespace = /\s/;
161
- function trimmedEndIndex(string) {
162
- var index = string.length;
163
- while (index-- && reWhitespace.test(string.charAt(index))) {
164
- }
165
- return index;
166
- }
167
- var trimmedEndIndex_default = trimmedEndIndex;
168
-
169
- // ../../node_modules/lodash-es/_baseTrim.js
170
- var reTrimStart = /^\s+/;
171
- function baseTrim(string) {
172
- return string ? string.slice(0, trimmedEndIndex_default(string) + 1).replace(reTrimStart, "") : string;
173
- }
174
- var baseTrim_default = baseTrim;
175
-
176
- // ../../node_modules/lodash-es/isObject.js
177
- function isObject(value) {
178
- var type = typeof value;
179
- return value != null && (type == "object" || type == "function");
180
- }
181
- var isObject_default = isObject;
182
-
183
- // ../../node_modules/lodash-es/isFunction.js
184
- var asyncTag = "[object AsyncFunction]";
185
- var funcTag = "[object Function]";
186
- var genTag = "[object GeneratorFunction]";
187
- var proxyTag = "[object Proxy]";
188
- function isFunction(value) {
189
- if (!isObject_default(value)) {
190
- return false;
191
- }
192
- var tag = baseGetTag_default(value);
193
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
194
- }
195
- var isFunction_default = isFunction;
196
-
197
- // ../../node_modules/lodash-es/_coreJsData.js
198
- var coreJsData = root_default["__core-js_shared__"];
199
- var coreJsData_default = coreJsData;
200
-
201
- // ../../node_modules/lodash-es/_isMasked.js
202
- var maskSrcKey = function() {
203
- var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
204
- return uid ? "Symbol(src)_1." + uid : "";
205
- }();
206
- function isMasked(func) {
207
- return !!maskSrcKey && maskSrcKey in func;
208
- }
209
- var isMasked_default = isMasked;
210
-
211
- // ../../node_modules/lodash-es/_toSource.js
212
- var funcProto = Function.prototype;
213
- var funcToString = funcProto.toString;
214
- function toSource(func) {
215
- if (func != null) {
216
- try {
217
- return funcToString.call(func);
218
- } catch (e) {
219
- }
220
- try {
221
- return func + "";
222
- } catch (e) {
223
- }
224
- }
225
- return "";
226
- }
227
- var toSource_default = toSource;
228
-
229
- // ../../node_modules/lodash-es/_baseIsNative.js
230
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
231
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
232
- var funcProto2 = Function.prototype;
233
- var objectProto3 = Object.prototype;
234
- var funcToString2 = funcProto2.toString;
235
- var hasOwnProperty2 = objectProto3.hasOwnProperty;
236
- var reIsNative = RegExp(
237
- "^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
238
- );
239
- function baseIsNative(value) {
240
- if (!isObject_default(value) || isMasked_default(value)) {
241
- return false;
242
- }
243
- var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
244
- return pattern.test(toSource_default(value));
245
- }
246
- var baseIsNative_default = baseIsNative;
247
-
248
- // ../../node_modules/lodash-es/_getValue.js
249
- function getValue(object, key) {
250
- return object == null ? void 0 : object[key];
251
- }
252
- var getValue_default = getValue;
253
-
254
- // ../../node_modules/lodash-es/_getNative.js
255
- function getNative(object, key) {
256
- var value = getValue_default(object, key);
257
- return baseIsNative_default(value) ? value : void 0;
258
- }
259
- var getNative_default = getNative;
260
-
261
- // ../../node_modules/lodash-es/_baseFindIndex.js
262
- function baseFindIndex(array2, predicate, fromIndex, fromRight) {
263
- var length = array2.length, index = fromIndex + (fromRight ? 1 : -1);
264
- while (fromRight ? index-- : ++index < length) {
265
- if (predicate(array2[index], index, array2)) {
266
- return index;
267
- }
268
- }
269
- return -1;
270
- }
271
- var baseFindIndex_default = baseFindIndex;
272
-
273
- // ../../node_modules/lodash-es/_baseIsNaN.js
274
- function baseIsNaN(value) {
275
- return value !== value;
276
- }
277
- var baseIsNaN_default = baseIsNaN;
278
-
279
- // ../../node_modules/lodash-es/_strictIndexOf.js
280
- function strictIndexOf(array2, value, fromIndex) {
281
- var index = fromIndex - 1, length = array2.length;
282
- while (++index < length) {
283
- if (array2[index] === value) {
284
- return index;
285
- }
286
- }
287
- return -1;
288
- }
289
- var strictIndexOf_default = strictIndexOf;
290
-
291
- // ../../node_modules/lodash-es/_baseIndexOf.js
292
- function baseIndexOf(array2, value, fromIndex) {
293
- return value === value ? strictIndexOf_default(array2, value, fromIndex) : baseFindIndex_default(array2, baseIsNaN_default, fromIndex);
294
- }
295
- var baseIndexOf_default = baseIndexOf;
296
-
297
- // ../../node_modules/lodash-es/_isIndex.js
298
- var MAX_SAFE_INTEGER = 9007199254740991;
299
- var reIsUint = /^(?:0|[1-9]\d*)$/;
300
- function isIndex(value, length) {
301
- var type = typeof value;
302
- length = length == null ? MAX_SAFE_INTEGER : length;
303
- return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
304
- }
305
- var isIndex_default = isIndex;
306
-
307
- // ../../node_modules/lodash-es/eq.js
308
- function eq(value, other) {
309
- return value === other || value !== value && other !== other;
310
- }
311
- var eq_default = eq;
312
-
313
- // ../../node_modules/lodash-es/isLength.js
314
- var MAX_SAFE_INTEGER2 = 9007199254740991;
315
- function isLength(value) {
316
- return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
317
- }
318
- var isLength_default = isLength;
319
-
320
- // ../../node_modules/lodash-es/_baseIsArguments.js
321
- var argsTag = "[object Arguments]";
322
- function baseIsArguments(value) {
323
- return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
324
- }
325
- var baseIsArguments_default = baseIsArguments;
326
-
327
- // ../../node_modules/lodash-es/isArguments.js
328
- var objectProto4 = Object.prototype;
329
- var hasOwnProperty3 = objectProto4.hasOwnProperty;
330
- var propertyIsEnumerable = objectProto4.propertyIsEnumerable;
331
- var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
332
- return arguments;
333
- }()) ? baseIsArguments_default : function(value) {
334
- return isObjectLike_default(value) && hasOwnProperty3.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
39
+ var resetCloudLocations = () => {
40
+ _cloudLocationService = null;
335
41
  };
336
- var isArguments_default = isArguments;
337
-
338
- // ../../node_modules/lodash-es/_isKey.js
339
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
340
- var reIsPlainProp = /^\w*$/;
341
- function isKey(value, object) {
342
- if (isArray_default(value)) {
343
- return false;
344
- }
345
- var type = typeof value;
346
- if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol_default(value)) {
347
- return true;
348
- }
349
- return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
350
- }
351
- var isKey_default = isKey;
352
-
353
- // ../../node_modules/lodash-es/_nativeCreate.js
354
- var nativeCreate = getNative_default(Object, "create");
355
- var nativeCreate_default = nativeCreate;
356
-
357
- // ../../node_modules/lodash-es/_hashClear.js
358
- function hashClear() {
359
- this.__data__ = nativeCreate_default ? nativeCreate_default(null) : {};
360
- this.size = 0;
361
- }
362
- var hashClear_default = hashClear;
363
-
364
- // ../../node_modules/lodash-es/_hashDelete.js
365
- function hashDelete(key) {
366
- var result = this.has(key) && delete this.__data__[key];
367
- this.size -= result ? 1 : 0;
368
- return result;
369
- }
370
- var hashDelete_default = hashDelete;
371
-
372
- // ../../node_modules/lodash-es/_hashGet.js
373
- var HASH_UNDEFINED = "__lodash_hash_undefined__";
374
- var objectProto5 = Object.prototype;
375
- var hasOwnProperty4 = objectProto5.hasOwnProperty;
376
- function hashGet(key) {
377
- var data = this.__data__;
378
- if (nativeCreate_default) {
379
- var result = data[key];
380
- return result === HASH_UNDEFINED ? void 0 : result;
381
- }
382
- return hasOwnProperty4.call(data, key) ? data[key] : void 0;
383
- }
384
- var hashGet_default = hashGet;
385
-
386
- // ../../node_modules/lodash-es/_hashHas.js
387
- var objectProto6 = Object.prototype;
388
- var hasOwnProperty5 = objectProto6.hasOwnProperty;
389
- function hashHas(key) {
390
- var data = this.__data__;
391
- return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty5.call(data, key);
392
- }
393
- var hashHas_default = hashHas;
394
-
395
- // ../../node_modules/lodash-es/_hashSet.js
396
- var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
397
- function hashSet(key, value) {
398
- var data = this.__data__;
399
- this.size += this.has(key) ? 0 : 1;
400
- data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value;
401
- return this;
402
- }
403
- var hashSet_default = hashSet;
404
-
405
- // ../../node_modules/lodash-es/_Hash.js
406
- function Hash(entries) {
407
- var index = -1, length = entries == null ? 0 : entries.length;
408
- this.clear();
409
- while (++index < length) {
410
- var entry = entries[index];
411
- this.set(entry[0], entry[1]);
412
- }
413
- }
414
- Hash.prototype.clear = hashClear_default;
415
- Hash.prototype["delete"] = hashDelete_default;
416
- Hash.prototype.get = hashGet_default;
417
- Hash.prototype.has = hashHas_default;
418
- Hash.prototype.set = hashSet_default;
419
- var Hash_default = Hash;
420
-
421
- // ../../node_modules/lodash-es/_listCacheClear.js
422
- function listCacheClear() {
423
- this.__data__ = [];
424
- this.size = 0;
425
- }
426
- var listCacheClear_default = listCacheClear;
427
-
428
- // ../../node_modules/lodash-es/_assocIndexOf.js
429
- function assocIndexOf(array2, key) {
430
- var length = array2.length;
431
- while (length--) {
432
- if (eq_default(array2[length][0], key)) {
433
- return length;
434
- }
435
- }
436
- return -1;
437
- }
438
- var assocIndexOf_default = assocIndexOf;
439
-
440
- // ../../node_modules/lodash-es/_listCacheDelete.js
441
- var arrayProto = Array.prototype;
442
- var splice = arrayProto.splice;
443
- function listCacheDelete(key) {
444
- var data = this.__data__, index = assocIndexOf_default(data, key);
445
- if (index < 0) {
446
- return false;
447
- }
448
- var lastIndex = data.length - 1;
449
- if (index == lastIndex) {
450
- data.pop();
451
- } else {
452
- splice.call(data, index, 1);
453
- }
454
- --this.size;
455
- return true;
456
- }
457
- var listCacheDelete_default = listCacheDelete;
458
-
459
- // ../../node_modules/lodash-es/_listCacheGet.js
460
- function listCacheGet(key) {
461
- var data = this.__data__, index = assocIndexOf_default(data, key);
462
- return index < 0 ? void 0 : data[index][1];
463
- }
464
- var listCacheGet_default = listCacheGet;
465
-
466
- // ../../node_modules/lodash-es/_listCacheHas.js
467
- function listCacheHas(key) {
468
- return assocIndexOf_default(this.__data__, key) > -1;
469
- }
470
- var listCacheHas_default = listCacheHas;
471
42
 
472
- // ../../node_modules/lodash-es/_listCacheSet.js
473
- function listCacheSet(key, value) {
474
- var data = this.__data__, index = assocIndexOf_default(data, key);
475
- if (index < 0) {
476
- ++this.size;
477
- data.push([key, value]);
478
- } else {
479
- data[index][1] = value;
480
- }
481
- return this;
482
- }
483
- var listCacheSet_default = listCacheSet;
484
-
485
- // ../../node_modules/lodash-es/_ListCache.js
486
- function ListCache(entries) {
487
- var index = -1, length = entries == null ? 0 : entries.length;
488
- this.clear();
489
- while (++index < length) {
490
- var entry = entries[index];
491
- this.set(entry[0], entry[1]);
492
- }
493
- }
494
- ListCache.prototype.clear = listCacheClear_default;
495
- ListCache.prototype["delete"] = listCacheDelete_default;
496
- ListCache.prototype.get = listCacheGet_default;
497
- ListCache.prototype.has = listCacheHas_default;
498
- ListCache.prototype.set = listCacheSet_default;
499
- var ListCache_default = ListCache;
500
-
501
- // ../../node_modules/lodash-es/_Map.js
502
- var Map = getNative_default(root_default, "Map");
503
- var Map_default = Map;
504
-
505
- // ../../node_modules/lodash-es/_mapCacheClear.js
506
- function mapCacheClear() {
507
- this.size = 0;
508
- this.__data__ = {
509
- "hash": new Hash_default(),
510
- "map": new (Map_default || ListCache_default)(),
511
- "string": new Hash_default()
512
- };
513
- }
514
- var mapCacheClear_default = mapCacheClear;
515
-
516
- // ../../node_modules/lodash-es/_isKeyable.js
517
- function isKeyable(value) {
518
- var type = typeof value;
519
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
520
- }
521
- var isKeyable_default = isKeyable;
522
-
523
- // ../../node_modules/lodash-es/_getMapData.js
524
- function getMapData(map, key) {
525
- var data = map.__data__;
526
- return isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
527
- }
528
- var getMapData_default = getMapData;
529
-
530
- // ../../node_modules/lodash-es/_mapCacheDelete.js
531
- function mapCacheDelete(key) {
532
- var result = getMapData_default(this, key)["delete"](key);
533
- this.size -= result ? 1 : 0;
534
- return result;
535
- }
536
- var mapCacheDelete_default = mapCacheDelete;
537
-
538
- // ../../node_modules/lodash-es/_mapCacheGet.js
539
- function mapCacheGet(key) {
540
- return getMapData_default(this, key).get(key);
541
- }
542
- var mapCacheGet_default = mapCacheGet;
543
-
544
- // ../../node_modules/lodash-es/_mapCacheHas.js
545
- function mapCacheHas(key) {
546
- return getMapData_default(this, key).has(key);
547
- }
548
- var mapCacheHas_default = mapCacheHas;
549
-
550
- // ../../node_modules/lodash-es/_mapCacheSet.js
551
- function mapCacheSet(key, value) {
552
- var data = getMapData_default(this, key), size = data.size;
553
- data.set(key, value);
554
- this.size += data.size == size ? 0 : 1;
555
- return this;
556
- }
557
- var mapCacheSet_default = mapCacheSet;
558
-
559
- // ../../node_modules/lodash-es/_MapCache.js
560
- function MapCache(entries) {
561
- var index = -1, length = entries == null ? 0 : entries.length;
562
- this.clear();
563
- while (++index < length) {
564
- var entry = entries[index];
565
- this.set(entry[0], entry[1]);
566
- }
567
- }
568
- MapCache.prototype.clear = mapCacheClear_default;
569
- MapCache.prototype["delete"] = mapCacheDelete_default;
570
- MapCache.prototype.get = mapCacheGet_default;
571
- MapCache.prototype.has = mapCacheHas_default;
572
- MapCache.prototype.set = mapCacheSet_default;
573
- var MapCache_default = MapCache;
574
-
575
- // ../../node_modules/lodash-es/memoize.js
576
- var FUNC_ERROR_TEXT = "Expected a function";
577
- function memoize(func, resolver) {
578
- if (typeof func != "function" || resolver != null && typeof resolver != "function") {
579
- throw new TypeError(FUNC_ERROR_TEXT);
580
- }
581
- var memoized = function() {
582
- var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
583
- if (cache.has(key)) {
584
- return cache.get(key);
585
- }
586
- var result = func.apply(this, args);
587
- memoized.cache = cache.set(key, result) || cache;
588
- return result;
589
- };
590
- memoized.cache = new (memoize.Cache || MapCache_default)();
591
- return memoized;
592
- }
593
- memoize.Cache = MapCache_default;
594
- var memoize_default = memoize;
595
-
596
- // ../../node_modules/lodash-es/_memoizeCapped.js
597
- var MAX_MEMOIZE_SIZE = 500;
598
- function memoizeCapped(func) {
599
- var result = memoize_default(func, function(key) {
600
- if (cache.size === MAX_MEMOIZE_SIZE) {
601
- cache.clear();
602
- }
603
- return key;
604
- });
605
- var cache = result.cache;
606
- return result;
607
- }
608
- var memoizeCapped_default = memoizeCapped;
609
-
610
- // ../../node_modules/lodash-es/_stringToPath.js
611
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
612
- var reEscapeChar = /\\(\\)?/g;
613
- var stringToPath = memoizeCapped_default(function(string) {
614
- var result = [];
615
- if (string.charCodeAt(0) === 46) {
616
- result.push("");
617
- }
618
- string.replace(rePropName, function(match, number, quote, subString) {
619
- result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
620
- });
621
- return result;
622
- });
623
- var stringToPath_default = stringToPath;
624
-
625
- // ../../node_modules/lodash-es/toString.js
626
- function toString(value) {
627
- return value == null ? "" : baseToString_default(value);
628
- }
629
- var toString_default = toString;
630
-
631
- // ../../node_modules/lodash-es/_castPath.js
632
- function castPath(value, object) {
633
- if (isArray_default(value)) {
634
- return value;
635
- }
636
- return isKey_default(value, object) ? [value] : stringToPath_default(toString_default(value));
637
- }
638
- var castPath_default = castPath;
639
-
640
- // ../../node_modules/lodash-es/_toKey.js
641
- var INFINITY2 = 1 / 0;
642
- function toKey(value) {
643
- if (typeof value == "string" || isSymbol_default(value)) {
644
- return value;
645
- }
646
- var result = value + "";
647
- return result == "0" && 1 / value == -INFINITY2 ? "-0" : result;
648
- }
649
- var toKey_default = toKey;
650
-
651
- // ../../node_modules/lodash-es/_baseSlice.js
652
- function baseSlice(array2, start, end) {
653
- var index = -1, length = array2.length;
654
- if (start < 0) {
655
- start = -start > length ? 0 : length + start;
656
- }
657
- end = end > length ? length : end;
658
- if (end < 0) {
659
- end += length;
660
- }
661
- length = start > end ? 0 : end - start >>> 0;
662
- start >>>= 0;
663
- var result = Array(length);
664
- while (++index < length) {
665
- result[index] = array2[index + start];
666
- }
667
- return result;
668
- }
669
- var baseSlice_default = baseSlice;
670
-
671
- // ../../node_modules/lodash-es/_castSlice.js
672
- function castSlice(array2, start, end) {
673
- var length = array2.length;
674
- end = end === void 0 ? length : end;
675
- return !start && end >= length ? array2 : baseSlice_default(array2, start, end);
676
- }
677
- var castSlice_default = castSlice;
678
-
679
- // ../../node_modules/lodash-es/_hasUnicode.js
680
- var rsAstralRange = "\\ud800-\\udfff";
681
- var rsComboMarksRange = "\\u0300-\\u036f";
682
- var reComboHalfMarksRange = "\\ufe20-\\ufe2f";
683
- var rsComboSymbolsRange = "\\u20d0-\\u20ff";
684
- var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
685
- var rsVarRange = "\\ufe0e\\ufe0f";
686
- var rsZWJ = "\\u200d";
687
- var reHasUnicode = RegExp("[" + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + "]");
688
- function hasUnicode(string) {
689
- return reHasUnicode.test(string);
690
- }
691
- var hasUnicode_default = hasUnicode;
692
-
693
- // ../../node_modules/lodash-es/_asciiToArray.js
694
- function asciiToArray(string) {
695
- return string.split("");
696
- }
697
- var asciiToArray_default = asciiToArray;
698
-
699
- // ../../node_modules/lodash-es/_unicodeToArray.js
700
- var rsAstralRange2 = "\\ud800-\\udfff";
701
- var rsComboMarksRange2 = "\\u0300-\\u036f";
702
- var reComboHalfMarksRange2 = "\\ufe20-\\ufe2f";
703
- var rsComboSymbolsRange2 = "\\u20d0-\\u20ff";
704
- var rsComboRange2 = rsComboMarksRange2 + reComboHalfMarksRange2 + rsComboSymbolsRange2;
705
- var rsVarRange2 = "\\ufe0e\\ufe0f";
706
- var rsAstral = "[" + rsAstralRange2 + "]";
707
- var rsCombo = "[" + rsComboRange2 + "]";
708
- var rsFitz = "\\ud83c[\\udffb-\\udfff]";
709
- var rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")";
710
- var rsNonAstral = "[^" + rsAstralRange2 + "]";
711
- var rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}";
712
- var rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]";
713
- var rsZWJ2 = "\\u200d";
714
- var reOptMod = rsModifier + "?";
715
- var rsOptVar = "[" + rsVarRange2 + "]?";
716
- var rsOptJoin = "(?:" + rsZWJ2 + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*";
717
- var rsSeq = rsOptVar + reOptMod + rsOptJoin;
718
- var rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
719
- var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
720
- function unicodeToArray(string) {
721
- return string.match(reUnicode) || [];
722
- }
723
- var unicodeToArray_default = unicodeToArray;
724
-
725
- // ../../node_modules/lodash-es/_stringToArray.js
726
- function stringToArray(string) {
727
- return hasUnicode_default(string) ? unicodeToArray_default(string) : asciiToArray_default(string);
728
- }
729
- var stringToArray_default = stringToArray;
730
-
731
- // ../../node_modules/lodash-es/_hasPath.js
732
- function hasPath(object, path, hasFunc) {
733
- path = castPath_default(path, object);
734
- var index = -1, length = path.length, result = false;
735
- while (++index < length) {
736
- var key = toKey_default(path[index]);
737
- if (!(result = object != null && hasFunc(object, key))) {
738
- break;
739
- }
740
- object = object[key];
741
- }
742
- if (result || ++index != length) {
743
- return result;
744
- }
745
- length = object == null ? 0 : object.length;
746
- return !!length && isLength_default(length) && isIndex_default(key, length) && (isArray_default(object) || isArguments_default(object));
747
- }
748
- var hasPath_default = hasPath;
749
-
750
- // ../../node_modules/lodash-es/_baseHas.js
751
- var objectProto7 = Object.prototype;
752
- var hasOwnProperty6 = objectProto7.hasOwnProperty;
753
- function baseHas(object, key) {
754
- return object != null && hasOwnProperty6.call(object, key);
755
- }
756
- var baseHas_default = baseHas;
757
-
758
- // ../../node_modules/lodash-es/has.js
759
- function has(object, path) {
760
- return object != null && hasPath_default(object, path, baseHas_default);
761
- }
762
- var has_default = has;
763
-
764
- // ../../node_modules/lodash-es/_charsEndIndex.js
765
- function charsEndIndex(strSymbols, chrSymbols) {
766
- var index = strSymbols.length;
767
- while (index-- && baseIndexOf_default(chrSymbols, strSymbols[index], 0) > -1) {
768
- }
769
- return index;
770
- }
771
- var charsEndIndex_default = charsEndIndex;
772
-
773
- // ../../node_modules/lodash-es/_charsStartIndex.js
774
- function charsStartIndex(strSymbols, chrSymbols) {
775
- var index = -1, length = strSymbols.length;
776
- while (++index < length && baseIndexOf_default(chrSymbols, strSymbols[index], 0) > -1) {
777
- }
778
- return index;
779
- }
780
- var charsStartIndex_default = charsStartIndex;
781
-
782
- // ../../node_modules/lodash-es/trim.js
783
- function trim(string, chars, guard) {
784
- string = toString_default(string);
785
- if (string && (guard || chars === void 0)) {
786
- return baseTrim_default(string);
787
- }
788
- if (!string || !(chars = baseToString_default(chars))) {
789
- return string;
790
- }
791
- var strSymbols = stringToArray_default(string), chrSymbols = stringToArray_default(chars), start = charsStartIndex_default(strSymbols, chrSymbols), end = charsEndIndex_default(strSymbols, chrSymbols) + 1;
792
- return castSlice_default(strSymbols, start, end).join("");
793
- }
794
- var trim_default = trim;
795
-
796
- // ../utils/src/config/env.ts
797
- function _env(key, defaultValue) {
798
- return has_default(process.env, key) ? process.env[key] ?? "" : defaultValue ?? "";
799
- }
800
- function int(key, defaultValue) {
801
- if (!has_default(process.env, key)) {
802
- return defaultValue ?? 0;
803
- }
804
- const value = process.env[key] ?? "0";
805
- return parseInt(value, 10);
806
- }
807
- function float(key, defaultValue) {
808
- if (!has_default(process.env, key)) {
809
- return defaultValue ?? 0;
810
- }
811
- const value = process.env[key] ?? "0";
812
- return parseFloat(value);
813
- }
814
- function bool(key, defaultValue) {
815
- if (!has_default(process.env, key)) {
816
- return defaultValue ?? false;
817
- }
818
- const value = process.env[key];
819
- return value === "true";
820
- }
821
- function json(key, defaultValue) {
822
- if (!has_default(process.env, key)) {
823
- return defaultValue ?? {};
824
- }
825
- const value = process.env[key] ?? "{}";
826
- try {
827
- return JSON.parse(value);
828
- } catch (error) {
829
- throw new Error(`Invalid json environment variable ${key}: ${error.message}`);
830
- }
831
- }
832
- function array(key, defaultValue) {
833
- if (!has_default(process.env, key)) {
834
- return defaultValue ?? [];
835
- }
836
- let value = process.env[key] ?? "";
837
- if (value.startsWith("[") && value.endsWith("]")) {
838
- value = value.substring(1, value.length - 1);
839
- }
840
- return value.split(",").map((v) => {
841
- return trim_default(trim_default(v, " "), '"');
842
- });
843
- }
844
- function date(key, defaultValue) {
845
- if (!has_default(process.env, key)) {
846
- return defaultValue ?? /* @__PURE__ */ new Date();
847
- }
848
- const value = process.env[key] ?? Date();
849
- return new Date(value);
850
- }
851
- var utils = {
852
- int,
853
- float,
854
- bool,
855
- json,
856
- array,
857
- date,
858
- /**
859
- * Gets a value from env that matches oneOf provided values
860
- * @param {string} key
861
- * @param {string[]} expectedValues
862
- * @param {string|undefined} defaultValue
863
- * @returns {string|undefined}
864
- */
865
- oneOf(key, expectedValues, defaultValue) {
866
- if (!expectedValues) {
867
- throw new Error(`env.oneOf requires expectedValues`);
868
- }
869
- if (defaultValue && !expectedValues.includes(defaultValue)) {
870
- throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
871
- }
872
- const rawValue = env(key, defaultValue);
873
- return expectedValues.includes(rawValue) ? rawValue : defaultValue ?? "";
43
+ // src/services/functions/cloud-functions.ts
44
+ var _cloudFunctionsService = null;
45
+ var cloudFunctions = () => {
46
+ if (_cloudFunctionsService) {
47
+ return _cloudFunctionsService;
874
48
  }
49
+ _cloudFunctionsService = getCloudProvider().createFunctionsService();
50
+ return _cloudFunctionsService;
875
51
  };
876
- var env = Object.assign(_env, utils);
877
-
878
- // ../utils/src/logging/types.ts
879
- var logLevels = {
880
- fatal: -1,
881
- error: 0,
882
- warn: 1,
883
- info: 2,
884
- debug: 3,
885
- trace: 4
52
+ var resetCloudFunctions = () => {
53
+ _cloudFunctionsService = null;
886
54
  };
887
55
 
888
- // ../utils/src/logging/error-to-string.ts
889
- var safeJsonStringify = (value) => {
890
- const seen = /* @__PURE__ */ new WeakSet();
891
- return JSON.stringify(value, (key, currentValue) => {
892
- if (key === "constructor") return void 0;
893
- if (typeof currentValue === "object" && currentValue !== null) {
894
- if (seen.has(currentValue)) return "[Circular]";
895
- seen.add(currentValue);
896
- }
897
- return currentValue;
898
- });
56
+ // src/services/websocket.ts
57
+ var _cloudWebSocket = null;
58
+ var cloudWebSocket = () => {
59
+ if (_cloudWebSocket) {
60
+ return _cloudWebSocket;
61
+ }
62
+ _cloudWebSocket = getCloudProvider().createWebSocketService();
63
+ return _cloudWebSocket;
899
64
  };
900
- var hasOwnConstructorProp = (value) => {
901
- if (typeof value !== "object" || value === null) return false;
902
- return Object.prototype.hasOwnProperty.call(value, "constructor");
65
+ var resetCloudWebSocket = () => {
66
+ _cloudWebSocket = null;
903
67
  };
904
- var errorToString = (error) => {
905
- if (error === null) return "Null error";
906
- if (error === void 0) return "Undefined error";
907
- if (error instanceof Error) {
908
- return [
909
- `Name: ${error.name}`,
910
- `Message: ${error.message}`,
911
- `Stack: ${error.stack || "No stack trace available"}`,
912
- // Handle additional properties that might exist on custom errors
913
- ...Object.entries(error).filter(
914
- ([key, value]) => !["name", "message", "stack"].includes(key) && !hasOwnConstructorProp(value)
915
- ).map(([key, value]) => `${key}: ${safeJsonStringify(value)}`)
916
- ].join("\n");
917
- }
918
- if (typeof error === "string") return error;
919
- if (typeof error === "object") {
920
- try {
921
- return JSON.stringify(
922
- error,
923
- (key, value) => {
924
- if (key === "constructor") return void 0;
925
- return value;
926
- },
927
- 2
928
- );
929
- } catch {
930
- return `[Object that cannot be stringified: ${Object.prototype.toString.call(error)}]`;
931
- }
68
+
69
+ // src/services/invoke.ts
70
+ var _cloudInvoke = null;
71
+ var cloudInvoke = () => {
72
+ if (_cloudInvoke) {
73
+ return _cloudInvoke;
932
74
  }
933
- return String(error);
75
+ _cloudInvoke = getCloudProvider().createInvokeService();
76
+ return _cloudInvoke;
934
77
  };
935
-
936
- // ../utils/src/logging/writer.ts
937
- import { EOL } from "os";
938
- var jsonWriter = (entry) => {
939
- process.stdout.write(JSON.stringify(entry) + EOL);
78
+ var resetCloudInvoke = () => {
79
+ _cloudInvoke = null;
940
80
  };
941
- var _writer = jsonWriter;
942
- function getWriter() {
943
- return _writer;
944
- }
945
81
 
946
- // ../utils/src/logging/index.ts
947
- var levelValues = {
948
- fatal: 70,
949
- error: 60,
950
- warn: 50,
951
- info: 40,
952
- debug: 30,
953
- trace: 20
954
- };
955
- var currentLogLevel = 2;
956
- var _module = "default";
957
- var _requestId = "";
958
- function writeLine(level, mergeObject, msg, bindings) {
959
- getWriter()({
960
- level: levelValues[level],
961
- levelName: level,
962
- time: Date.now(),
963
- module: bindings.module || _module,
964
- reqId: bindings.reqId || _requestId,
965
- msg: level === "error" || level === "fatal" ? errorToString(msg) : msg,
966
- ...mergeObject ? { meta: mergeObject } : {}
967
- });
82
+ // src/provider.ts
83
+ var provider = null;
84
+ function getCloudProvider() {
85
+ if (!provider) {
86
+ throw new Error("Cloud provider is not defined. Please set a valid cloud provider using useProvider.");
87
+ }
88
+ return provider;
968
89
  }
969
- function createLogger(bindings = {}) {
970
- const currentLogLevelName = env("LOG_LEVEL")?.toLowerCase() ?? "info";
971
- currentLogLevel = logLevels[currentLogLevelName] ?? logLevels.info;
972
- return {
973
- level: currentLogLevelName,
974
- fatal: (mergeObject, msg) => {
975
- if (currentLogLevel >= logLevels.fatal) {
976
- typeof mergeObject === "string" || mergeObject instanceof Error ? writeLine("fatal", null, mergeObject, bindings) : writeLine("fatal", mergeObject, msg ?? "", bindings);
977
- }
978
- },
979
- error: (mergeObject, msg) => {
980
- if (currentLogLevel >= logLevels.error) {
981
- typeof mergeObject === "string" || mergeObject instanceof Error ? writeLine("error", null, mergeObject, bindings) : writeLine("error", mergeObject, msg ?? "", bindings);
982
- }
983
- },
984
- warn: (mergeObject, msg) => {
985
- if (currentLogLevel >= logLevels.warn) {
986
- typeof mergeObject === "string" ? writeLine("warn", null, mergeObject, bindings) : writeLine("warn", mergeObject, msg ?? "", bindings);
987
- }
988
- },
989
- info: (mergeObject, msg) => {
990
- if (currentLogLevel >= logLevels.info) {
991
- typeof mergeObject === "string" ? writeLine("info", null, mergeObject, bindings) : writeLine("info", mergeObject, msg ?? "", bindings);
992
- }
993
- },
994
- debug: (mergeObject, msg) => {
995
- if (currentLogLevel >= logLevels.debug) {
996
- typeof mergeObject === "string" ? writeLine("debug", null, mergeObject, bindings) : writeLine("debug", mergeObject, msg ?? "", bindings);
997
- }
998
- },
999
- trace: (mergeObject, msg) => {
1000
- if (currentLogLevel >= logLevels.trace) {
1001
- typeof mergeObject === "string" ? writeLine("trace", null, mergeObject, bindings) : writeLine("trace", mergeObject, msg ?? "", bindings);
1002
- }
1003
- },
1004
- silent: () => {
1005
- },
1006
- child: (childBindings) => createLogger({ ...bindings, ...childBindings })
90
+ function useCloudProvider(cloudProvider, options) {
91
+ if (!cloudProvider) {
92
+ throw new Error("Cloud provider is not defined. Please set a valid cloud provider using useProvider.");
93
+ }
94
+ const services = {
95
+ "logger": cloudLogger,
96
+ "event-broker": cloudEventBroker,
97
+ "storage": cloudStorage,
98
+ "location": cloudLocations,
99
+ "functions": cloudFunctions,
100
+ "websocket": cloudWebSocket,
101
+ "invoke": cloudInvoke
102
+ };
103
+ registerServices(services);
104
+ provider = {
105
+ ...cloudProvider,
106
+ createLoggerService: options?.serviceFactories?.logger || cloudProvider.createLoggerService,
107
+ createEventBrokerService: options?.serviceFactories?.["event-broker"] || cloudProvider.createEventBrokerService,
108
+ createStorageService: options?.serviceFactories?.storage || cloudProvider.createStorageService,
109
+ createLocationService: options?.serviceFactories?.location || cloudProvider.createLocationService,
110
+ createFunctionsService: options?.serviceFactories?.functions || cloudProvider.createFunctionsService,
111
+ createWebSocketService: options?.serviceFactories?.websocket || cloudProvider.createWebSocketService,
112
+ createInvokeService: options?.serviceFactories?.invoke || cloudProvider.createInvokeService
1007
113
  };
114
+ resetCloudLogger();
115
+ resetCloudEventBroker();
116
+ resetCloudStorage();
117
+ resetCloudLocations();
118
+ resetCloudFunctions();
119
+ resetCloudWebSocket();
120
+ resetCloudInvoke();
1008
121
  }
1009
- var logger = createLogger();
1010
122
 
1011
- // src/services/functions/cloud-functions.ts
1012
- var _cloudFunctionsService = null;
1013
- var cloudFunctions = () => {
1014
- if (_cloudFunctionsService) {
1015
- return _cloudFunctionsService;
123
+ // src/services/event-broker.ts
124
+ var _cloudEventBroker = null;
125
+ var cloudEventBroker = () => {
126
+ if (_cloudEventBroker) {
127
+ return _cloudEventBroker;
1016
128
  }
1017
- _cloudFunctionsService = getCloudProvider().createFunctionsService();
1018
- return _cloudFunctionsService;
129
+ _cloudEventBroker = getCloudProvider().createEventBrokerService();
130
+ return _cloudEventBroker;
131
+ };
132
+ var resetCloudEventBroker = () => {
133
+ _cloudEventBroker = null;
1019
134
  };
1020
135
 
1021
136
  // src/services/functions/event-broker/create-event-context.ts
1022
- function createEventContext(request) {
137
+ function createEventContext(request, logger) {
1023
138
  const response = {
1024
139
  status: "success",
1025
140
  body: {}
@@ -1030,6 +145,7 @@ function createEventContext(request) {
1030
145
  type: "Event",
1031
146
  response,
1032
147
  request,
148
+ logger,
1033
149
  message() {
1034
150
  if (typeof request.body === "string")
1035
151
  return JSON.parse(request.body || "{}");
@@ -1063,25 +179,27 @@ function createEventContext(request) {
1063
179
 
1064
180
  // src/services/functions/event-broker/handler.ts
1065
181
  async function eventBrokerHandler(handler, ...args) {
182
+ const log = cloudLogger();
1066
183
  try {
1067
- logger.debug({ args }, "Executing Event Broker handler with args");
184
+ log.debug({ args }, "Executing Event Broker handler with args");
1068
185
  const [eventRequest] = cloudFunctions().createEventRequest(...args);
1069
- logger.debug({
186
+ log.setBindings({ reqId: eventRequest.requestId ?? "", module: eventRequest.moduleName ?? "" });
187
+ log.debug({
1070
188
  request: eventRequest
1071
189
  }, "Created Event Broker request ");
1072
- const context = createEventContext(eventRequest);
190
+ const context = createEventContext(eventRequest, log);
1073
191
  await handler(context);
1074
- logger.debug({ response: context.response }, "Event Broker Handler executed successfully, building response");
192
+ log.debug({ response: context.response }, "Event Broker Handler executed successfully, building response");
1075
193
  return await cloudFunctions().buildEventResponse(context);
1076
194
  } catch (error) {
1077
- logger.error({ error }, "Error in Event Broker handler");
195
+ log.error({ error }, "Error in Event Broker handler");
1078
196
  throw error;
1079
197
  }
1080
198
  }
1081
199
 
1082
200
  // src/services/functions/http/create-http-context.ts
1083
201
  import querystring from "querystring";
1084
- function createHttpContext(request, auth) {
202
+ function createHttpContext(request, auth, logger) {
1085
203
  const response = {
1086
204
  body: void 0,
1087
205
  headers: {},
@@ -1119,6 +237,7 @@ function createHttpContext(request, auth) {
1119
237
  request,
1120
238
  auth,
1121
239
  response,
240
+ logger,
1122
241
  model() {
1123
242
  return JSON.parse(request.body || "{}");
1124
243
  },
@@ -1252,23 +371,25 @@ function createHttpContext(request, auth) {
1252
371
 
1253
372
  // src/services/functions/http/handler.ts
1254
373
  async function httpHandler(handler, ...args) {
374
+ const log = cloudLogger();
1255
375
  try {
1256
- logger.debug({ args }, "Executing HTTP handler with args");
376
+ log.debug({ args }, "Executing HTTP handler with args");
1257
377
  const [httpRequest, httpAuth] = cloudFunctions().createHttRequest(...args);
1258
- logger.debug({ httpRequest, httpAuth }, "Created HTTP request and auth");
1259
- const context = createHttpContext(httpRequest, httpAuth);
378
+ log.setBindings({ reqId: httpRequest.requestId ?? "", module: httpRequest.moduleName ?? "" });
379
+ log.debug({ httpRequest, httpAuth }, "Created HTTP request and auth");
380
+ const context = createHttpContext(httpRequest, httpAuth, log);
1260
381
  await handler(context);
1261
- logger.debug({ response: context.response }, "Handler executed successfully, building HTTP response");
382
+ log.debug({ response: context.response }, "Handler executed successfully, building HTTP response");
1262
383
  return cloudFunctions().buildHttpResponse(context, ...args);
1263
384
  } catch (error) {
1264
- logger.error({ error }, "Error in HTTP handler");
385
+ log.error({ error }, "Error in HTTP handler");
1265
386
  throw error;
1266
387
  }
1267
388
  }
1268
389
 
1269
390
  // src/services/functions/invoke/create-invoke-context.ts
1270
391
  import { ErrorCode as ErrorCode2 } from "@cloudnux/core-cloud-provider";
1271
- function createInvokeContext(request) {
392
+ function createInvokeContext(request, logger) {
1272
393
  const response = {
1273
394
  status: "success"
1274
395
  };
@@ -1276,6 +397,7 @@ function createInvokeContext(request) {
1276
397
  type: "Invoke",
1277
398
  request,
1278
399
  response,
400
+ logger,
1279
401
  payload() {
1280
402
  return request.payload;
1281
403
  },
@@ -1303,22 +425,24 @@ function createInvokeContext(request) {
1303
425
 
1304
426
  // src/services/functions/invoke/handler.ts
1305
427
  async function invokeHandler(handler, ...args) {
428
+ const log = cloudLogger();
1306
429
  try {
1307
- logger.debug({ args }, "Executing Invoke handler with args");
430
+ log.debug({ args }, "Executing Invoke handler with args");
1308
431
  const [invokeRequest] = cloudFunctions().createInvokeRequest(...args);
1309
- logger.debug({ request: invokeRequest }, "Created Invoke request");
1310
- const context = createInvokeContext(invokeRequest);
432
+ log.setBindings({ reqId: invokeRequest.requestId ?? "", module: invokeRequest.calledModule ?? "" });
433
+ log.debug({ request: invokeRequest }, "Created Invoke request");
434
+ const context = createInvokeContext(invokeRequest, log);
1311
435
  await handler(context);
1312
- logger.debug({ response: context.response }, "Invoke Handler executed successfully, building response");
436
+ log.debug({ response: context.response }, "Invoke Handler executed successfully, building response");
1313
437
  return cloudFunctions().buildInvokeResponse(context, ...args);
1314
438
  } catch (error) {
1315
- logger.error({ error }, "Error in Invoke handler");
439
+ log.error({ error }, "Error in Invoke handler");
1316
440
  throw error;
1317
441
  }
1318
442
  }
1319
443
 
1320
444
  // src/services/functions/schedule/create-schedule-context.ts
1321
- function createScheduleContext(request) {
445
+ function createScheduleContext(request, logger) {
1322
446
  const response = {
1323
447
  status: "error",
1324
448
  body: null
@@ -1327,6 +451,7 @@ function createScheduleContext(request) {
1327
451
  type: "Schedule",
1328
452
  request,
1329
453
  response,
454
+ logger,
1330
455
  success: (body) => {
1331
456
  response.status = "success";
1332
457
  response.body = body;
@@ -1348,25 +473,27 @@ function createScheduleContext(request) {
1348
473
 
1349
474
  // src/services/functions/schedule/handler.ts
1350
475
  async function scheduleHandler(handler, ...args) {
476
+ const log = cloudLogger();
1351
477
  try {
1352
- logger.debug({ args }, "Executing Schedule handler with args");
478
+ log.debug({ args }, "Executing Schedule handler with args");
1353
479
  const [scheduleRequest] = cloudFunctions().createScheduleRequest(...args);
1354
- logger.debug({
480
+ log.setBindings({ reqId: scheduleRequest.requestId ?? "", module: scheduleRequest.moduleName ?? "" });
481
+ log.debug({
1355
482
  request: scheduleRequest
1356
483
  }, "Created Schedule request ");
1357
- const context = createScheduleContext(scheduleRequest);
484
+ const context = createScheduleContext(scheduleRequest, log);
1358
485
  await handler(context);
1359
- logger.debug({ response: context.response }, "Schedule Handler executed successfully, building response");
486
+ log.debug({ response: context.response }, "Schedule Handler executed successfully, building response");
1360
487
  return cloudFunctions().buildScheduleResponse(context);
1361
488
  } catch (error) {
1362
- logger.error({ error }, "Error in Schedule handler");
489
+ log.error({ error }, "Error in Schedule handler");
1363
490
  throw error;
1364
491
  }
1365
492
  }
1366
493
 
1367
494
  // src/services/functions/websocket/create-websocket-context.ts
1368
495
  import { ErrorCode as ErrorCode3 } from "@cloudnux/core-cloud-provider";
1369
- function createWebSocketContext(request) {
496
+ function createWebSocketContext(request, logger) {
1370
497
  const response = {
1371
498
  status: "success",
1372
499
  body: {},
@@ -1383,6 +510,7 @@ function createWebSocketContext(request) {
1383
510
  event: request.event,
1384
511
  request,
1385
512
  response,
513
+ logger,
1386
514
  message() {
1387
515
  if (typeof request.body === "string")
1388
516
  return JSON.parse(request.body || "{}");
@@ -1422,61 +550,49 @@ function createWebSocketContext(request) {
1422
550
 
1423
551
  // src/services/functions/websocket/handler.ts
1424
552
  async function websocketHandler(handler, ...args) {
553
+ const log = cloudLogger();
1425
554
  try {
1426
- logger.debug({ args }, "Executing WebSocket handler with args");
555
+ log.debug({ args }, "Executing WebSocket handler with args");
1427
556
  const [wsRequest] = cloudFunctions().createWebSocketRequest(...args);
1428
- logger.debug({
557
+ log.setBindings({ reqId: wsRequest.requestId ?? "", module: wsRequest.moduleName ?? "" });
558
+ log.debug({
1429
559
  request: wsRequest
1430
560
  }, "Created WebSocket request");
1431
- const context = createWebSocketContext(wsRequest);
561
+ const context = createWebSocketContext(wsRequest, log);
1432
562
  await handler(context);
1433
- logger.debug({ response: context.response }, "WebSocket Handler executed successfully, building response");
563
+ log.debug({ response: context.response }, "WebSocket Handler executed successfully, building response");
1434
564
  return cloudFunctions().buildWebSocketResponse(context, ...args);
1435
565
  } catch (error) {
1436
- logger.error(error);
566
+ log.error(error);
1437
567
  throw error;
1438
568
  }
1439
569
  }
1440
570
 
1441
- // src/services/websocket.ts
1442
- var _cloudWebSocket = null;
1443
- var cloudWebSocket = () => {
1444
- if (_cloudWebSocket) {
1445
- return _cloudWebSocket;
1446
- }
1447
- _cloudWebSocket = getCloudProvider().createWebSocketService();
1448
- return _cloudWebSocket;
1449
- };
1450
-
1451
571
  // src/index.ts
1452
572
  import { ErrorCode as ErrorCode4, WebSocketConnectionGoneError } from "@cloudnux/core-cloud-provider";
1453
573
  export {
1454
574
  ErrorCode4 as ErrorCode,
1455
575
  WebSocketConnectionGoneError,
1456
576
  cloudEventBroker,
577
+ cloudFunctions,
1457
578
  cloudInvoke,
1458
579
  cloudLocations,
580
+ cloudLogger,
1459
581
  cloudStorage,
1460
582
  cloudWebSocket,
1461
583
  eventBrokerHandler,
1462
584
  getCloudProvider,
1463
585
  httpHandler,
1464
586
  invokeHandler,
587
+ resetCloudEventBroker,
588
+ resetCloudFunctions,
589
+ resetCloudInvoke,
590
+ resetCloudLocations,
591
+ resetCloudLogger,
592
+ resetCloudStorage,
593
+ resetCloudWebSocket,
1465
594
  scheduleHandler,
1466
595
  useCloudProvider,
1467
596
  websocketHandler
1468
597
  };
1469
- /*! Bundled license information:
1470
-
1471
- lodash-es/lodash.js:
1472
- (**
1473
- * @license
1474
- * Lodash (Custom Build) <https://lodash.com/>
1475
- * Build: `lodash modularize exports="es" -o ./`
1476
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
1477
- * Released under MIT license <https://lodash.com/license>
1478
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1479
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1480
- *)
1481
- */
1482
598
  //# sourceMappingURL=index.js.map