@wavemaker/variables 11.15.2-dev.5 → 11.15.2-rc.249

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.
@@ -1,104 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- var __generator = (this && this.__generator) || function (thisArg, body) {
26
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
- function verb(n) { return function (v) { return step([n, v]); }; }
29
- function step(op) {
30
- if (f) throw new TypeError("Generator is already executing.");
31
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
- if (y = 0, t) op = [op[0] & 2, t.value];
34
- switch (op[0]) {
35
- case 0: case 1: t = op; break;
36
- case 4: _.label++; return { value: op[1], done: false };
37
- case 5: _.label++; y = op[1]; op = [0]; continue;
38
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
- default:
40
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
- if (t[2]) _.ops.pop();
45
- _.trys.pop(); continue;
46
- }
47
- op = body.call(thisArg, _);
48
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
- }
51
- };
52
- import { BaseInterceptor } from "./interceptor";
53
- var DEFAULT_CACHE_TIMEOUT = 5 * 60 * 1000;
54
- var CacheInterceptor = /** @class */ (function (_super) {
55
- __extends(CacheInterceptor, _super);
56
- function CacheInterceptor(interceptor, cacheType, cacheTimeout, passThrough) {
57
- if (cacheType === void 0) { cacheType = 'session'; }
58
- if (cacheTimeout === void 0) { cacheTimeout = DEFAULT_CACHE_TIMEOUT; }
59
- if (passThrough === void 0) { passThrough = false; }
60
- var _this = _super.call(this, {}) || this;
61
- _this.interceptor = interceptor;
62
- _this.cacheType = cacheType;
63
- _this.cacheTimeout = cacheTimeout;
64
- _this.passThrough = passThrough;
65
- return _this;
66
- }
67
- CacheInterceptor.prototype.match = function (context) {
68
- var _a, _b;
69
- return !!((_b = (_a = this.interceptor) === null || _a === void 0 ? void 0 : _a.match) === null || _b === void 0 ? void 0 : _b.call(_a, context));
70
- };
71
- CacheInterceptor.prototype.intercept = function (context) {
72
- return __awaiter(this, void 0, void 0, function () {
73
- var store, cacheData, data;
74
- return __generator(this, function (_a) {
75
- switch (_a.label) {
76
- case 0:
77
- store = context.stores.session;
78
- if (this.cacheType === 'persistent') {
79
- store = context.stores.persistent;
80
- }
81
- return [4 /*yield*/, store.getItem("response")];
82
- case 1:
83
- cacheData = _a.sent();
84
- if (cacheData) {
85
- context.variable.dataSet = cacheData;
86
- if (!this.passThrough) {
87
- return [2 /*return*/, cacheData];
88
- }
89
- }
90
- return [4 /*yield*/, this.interceptor.intercept(context)];
91
- case 2:
92
- data = _a.sent();
93
- return [4 /*yield*/, store.setItem("response", data, this.cacheTimeout)];
94
- case 3:
95
- _a.sent();
96
- return [2 /*return*/, data];
97
- }
98
- });
99
- });
100
- };
101
- return CacheInterceptor;
102
- }(BaseInterceptor));
103
- export { CacheInterceptor };
104
- //# sourceMappingURL=cache-interceptor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache-interceptor.js","sourceRoot":"./","sources":["src/interceptor/cache-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,eAAe,EAAe,MAAM,eAAe,CAAC;AAE7D,IAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE5C;IAAwE,oCAAmB;IAEvF,0BACY,WAA4B,EAC5B,SAA+C,EAC/C,YAAoC,EACpC,WAAmB;QAFnB,0BAAA,EAAA,qBAA+C;QAC/C,6BAAA,EAAA,oCAAoC;QACpC,4BAAA,EAAA,mBAAmB;QAE3B,YAAA,MAAK,YAAC,EAAE,CAAC,SAAC;QALF,iBAAW,GAAX,WAAW,CAAiB;QAC5B,eAAS,GAAT,SAAS,CAAsC;QAC/C,kBAAY,GAAZ,YAAY,CAAwB;QACpC,iBAAW,GAAX,WAAW,CAAQ;;IAG/B,CAAC;IAED,gCAAK,GAAL,UAAM,OAAW;;QACb,OAAO,CAAC,CAAC,CAAA,MAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,KAAK,mDAAG,OAAO,CAAC,CAAA,CAAC;IAChD,CAAC;IAEK,oCAAS,GAAf,UAAgB,OAAW;;;;;;wBACnB,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;wBACnC,IAAG,IAAI,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;4BACjC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;wBACtC,CAAC;wBACiB,qBAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAA;;wBAA3C,SAAS,GAAG,SAA+B;wBACjD,IAAI,SAAS,EAAE,CAAC;4BACZ,OAAO,CAAC,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC;4BACrC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gCACpB,sBAAO,SAAS,EAAC;4BACrB,CAAC;wBACL,CAAC;wBACY,qBAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,EAAA;;wBAAhD,IAAI,GAAG,SAAyC;wBACtD,qBAAM,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,EAAA;;wBAAxD,SAAwD,CAAC;wBACzD,sBAAO,IAAI,EAAC;;;;KACf;IACL,uBAAC;AAAD,CAAC,AA/BD,CAAwE,eAAe,GA+BtF","sourcesContent":["import { InterceptContext } from \"./intercept-context\";\nimport { BaseInterceptor, Interceptor } from \"./interceptor\";\n\nconst DEFAULT_CACHE_TIMEOUT = 5 * 60 * 1000;\n\nexport class CacheInterceptor<IC extends InterceptContext<any>> extends BaseInterceptor<IC> {\n \n constructor(\n private interceptor: Interceptor<IC>, \n private cacheType: 'session' | 'persistent' = 'session',\n private cacheTimeout = DEFAULT_CACHE_TIMEOUT,\n private passThrough = false\n ) {\n super({});\n }\n\n match(context: IC) {\n return !!this.interceptor?.match?.(context);\n }\n \n async intercept(context: IC) {\n let store = context.stores.session;\n if(this.cacheType === 'persistent') {\n store = context.stores.persistent;\n }\n const cacheData = await store.getItem(\"response\");\n if (cacheData) {\n context.variable.dataSet = cacheData;\n if (!this.passThrough) {\n return cacheData;\n }\n }\n const data = await this.interceptor.intercept(context);\n await store.setItem(\"response\", data, this.cacheTimeout);\n return data;\n }\n}\n"]}
@@ -1,9 +0,0 @@
1
- export * from "./interceptor";
2
- export * from "./cache-interceptor";
3
- export * from "./storage";
4
- export * from "./intercept-context";
5
- import { InterceptorManager } from "./interceptor.manager";
6
- import { InterceptService } from "./intercept.service";
7
- declare const interceptorManager: InterceptorManager;
8
- declare const interceptService: InterceptService;
9
- export { interceptorManager, interceptService, };
@@ -1,10 +0,0 @@
1
- export * from "./interceptor";
2
- export * from "./cache-interceptor";
3
- export * from "./storage";
4
- export * from "./intercept-context";
5
- import { InterceptorManager } from "./interceptor.manager";
6
- import { InterceptService } from "./intercept.service";
7
- var interceptorManager = new InterceptorManager();
8
- var interceptService = new InterceptService(interceptorManager);
9
- export { interceptorManager, interceptService, };
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"./","sources":["src/interceptor/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,IAAM,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC;AACpD,IAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;AAElE,OAAO,EACH,kBAAkB,EAClB,gBAAgB,GACnB,CAAC","sourcesContent":["export * from \"./interceptor\";\nexport * from \"./cache-interceptor\";\nexport * from \"./storage\";\nexport * from \"./intercept-context\";\n\nimport { InterceptorManager } from \"./interceptor.manager\";\nimport { InterceptService } from \"./intercept.service\";\n\nconst interceptorManager = new InterceptorManager();\nconst interceptService = new InterceptService(interceptorManager);\n\nexport { \n interceptorManager, \n interceptService,\n};"]}
@@ -1,15 +0,0 @@
1
- import { StorageService } from "./storage";
2
- export declare abstract class InterceptContext<V> {
3
- variable: V;
4
- readonly stores: {
5
- temp: StorageService;
6
- session: StorageService;
7
- persistent: StorageService;
8
- };
9
- constructor(variable: V, stores: {
10
- temp: StorageService;
11
- session: StorageService;
12
- persistent: StorageService;
13
- });
14
- abstract proceed(): Promise<any>;
15
- }
@@ -1,9 +0,0 @@
1
- var InterceptContext = /** @class */ (function () {
2
- function InterceptContext(variable, stores) {
3
- this.variable = variable;
4
- this.stores = stores;
5
- }
6
- return InterceptContext;
7
- }());
8
- export { InterceptContext };
9
- //# sourceMappingURL=intercept-context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intercept-context.js","sourceRoot":"./","sources":["src/interceptor/intercept-context.ts"],"names":[],"mappings":"AAEA;IAEI,0BAAmB,QAAW,EAAkB,MAI/C;QAJkB,aAAQ,GAAR,QAAQ,CAAG;QAAkB,WAAM,GAAN,MAAM,CAIrD;IAAG,CAAC;IAGT,uBAAC;AAAD,CAAC,AATD,IASC","sourcesContent":["import { StorageService } from \"./storage\";\n\nexport abstract class InterceptContext<V> {\n\n constructor(public variable: V, public readonly stores: {\n temp: StorageService,\n session: StorageService,\n persistent: StorageService\n }) {}\n\n abstract proceed(): Promise<any>;\n}\n"]}
@@ -1,6 +0,0 @@
1
- import { InterceptorManager } from "./interceptor.manager";
2
- export declare class InterceptService {
3
- private interceptorManager;
4
- constructor(interceptorManager: InterceptorManager);
5
- intercept(context: any): Promise<any>;
6
- }
@@ -1,69 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- var InterceptService = /** @class */ (function () {
38
- function InterceptService(interceptorManager) {
39
- this.interceptorManager = interceptorManager;
40
- }
41
- InterceptService.prototype.intercept = function (context) {
42
- return __awaiter(this, void 0, void 0, function () {
43
- var matchingInterceptors;
44
- var _this = this;
45
- return __generator(this, function (_a) {
46
- switch (_a.label) {
47
- case 0:
48
- matchingInterceptors = this.interceptorManager.filter(context);
49
- if (matchingInterceptors.length === 0) {
50
- return [2 /*return*/, context.proceed()];
51
- }
52
- return [4 /*yield*/, Promise.all(matchingInterceptors
53
- .map(function (interceptor) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
54
- switch (_a.label) {
55
- case 0: return [4 /*yield*/, interceptor.intercept(context)];
56
- case 1: return [2 /*return*/, _a.sent()];
57
- }
58
- }); }); }))];
59
- case 1:
60
- _a.sent();
61
- return [2 /*return*/, context.variable.dataSet];
62
- }
63
- });
64
- });
65
- };
66
- return InterceptService;
67
- }());
68
- export { InterceptService };
69
- //# sourceMappingURL=intercept.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intercept.service.js","sourceRoot":"./","sources":["src/interceptor/intercept.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;IAEI,0BAAoB,kBAAsC;QAAtC,uBAAkB,GAAlB,kBAAkB,CAAoB;IAE1D,CAAC;IAEK,oCAAS,GAAf,UAAgB,OAAY;;;;;;;wBAClB,oBAAoB,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;wBACrE,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;4BACpC,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;wBAC7B,CAAC;wBACD,qBAAM,OAAO,CAAC,GAAG,CAAC,oBAAoB;iCACjC,GAAG,CAAC,UAAM,WAAW;;4CAAI,qBAAM,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,EAAA;4CAApC,sBAAA,SAAoC,EAAA;;qCAAA,CAAC,CAAC,EAAA;;wBADpE,SACoE,CAAC;wBACrE,sBAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAC;;;;KACnC;IACL,uBAAC;AAAD,CAAC,AAfD,IAeC","sourcesContent":["import { InterceptorManager } from \"./interceptor.manager\";\n\nexport class InterceptService {\n \n constructor(private interceptorManager: InterceptorManager) {\n\n }\n\n async intercept(context: any) {\n const matchingInterceptors = this.interceptorManager.filter(context);\n if (matchingInterceptors.length === 0) {\n return context.proceed();\n }\n await Promise.all(matchingInterceptors\n .map(async interceptor => await interceptor.intercept(context)));\n return context.variable.dataSet;\n }\n}"]}
@@ -1,17 +0,0 @@
1
- import { InterceptContext } from "./intercept-context";
2
- export interface Interceptor<IC extends InterceptContext<any>> {
3
- match: (context: IC) => boolean;
4
- intercept: (context: IC) => Promise<any>;
5
- }
6
- export declare abstract class BaseInterceptor<IC extends InterceptContext<any>> implements Interceptor<IC> {
7
- protected options: {
8
- match?: (context: IC) => boolean;
9
- intercept?: (context: IC) => Promise<any>;
10
- };
11
- constructor(options: {
12
- match?: (context: IC) => boolean;
13
- intercept?: (context: IC) => Promise<any>;
14
- });
15
- match(context: IC): boolean;
16
- abstract intercept(context: IC): Promise<any>;
17
- }
@@ -1,12 +0,0 @@
1
- var BaseInterceptor = /** @class */ (function () {
2
- function BaseInterceptor(options) {
3
- this.options = options;
4
- }
5
- BaseInterceptor.prototype.match = function (context) {
6
- var _a, _b;
7
- return !!((_b = (_a = this.options).match) === null || _b === void 0 ? void 0 : _b.call(_a, context));
8
- };
9
- return BaseInterceptor;
10
- }());
11
- export { BaseInterceptor };
12
- //# sourceMappingURL=interceptor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interceptor.js","sourceRoot":"./","sources":["src/interceptor/interceptor.ts"],"names":[],"mappings":"AAOA;IAEE,yBAAsB,OAGrB;QAHqB,YAAO,GAAP,OAAO,CAG5B;IACD,CAAC;IAED,+BAAK,GAAL,UAAM,OAAW;;QACf,OAAO,CAAC,CAAC,CAAA,MAAA,MAAA,IAAI,CAAC,OAAO,EAAC,KAAK,mDAAG,OAAO,CAAC,CAAA,CAAC;IACzC,CAAC;IAGH,sBAAC;AAAD,CAAC,AAbD,IAaC","sourcesContent":["import { InterceptContext } from \"./intercept-context\";\n\nexport interface Interceptor<IC extends InterceptContext<any>> {\n match: (context: IC) => boolean;\n intercept: (context: IC) => Promise<any>;\n}\n\nexport abstract class BaseInterceptor<IC extends InterceptContext<any>> implements Interceptor<IC> {\n\n constructor(protected options: {\n match?: (context: IC) => boolean;\n intercept?: (context: IC) => Promise<any>;\n }) {\n }\n\n match(context: IC) {\n return !!this.options.match?.(context);\n }\n\n abstract intercept(context: IC): Promise<any>;\n}\n"]}
@@ -1,8 +0,0 @@
1
- import { InterceptContext } from "./intercept-context";
2
- import { Interceptor } from "./interceptor";
3
- export declare class InterceptorManager {
4
- private interceptors;
5
- add(interceptor: Interceptor<any>): void;
6
- remove(interceptor: Interceptor<any>): void;
7
- filter(contextToMatch: InterceptContext<any>): Interceptor<any>[];
8
- }
@@ -1,17 +0,0 @@
1
- var InterceptorManager = /** @class */ (function () {
2
- function InterceptorManager() {
3
- this.interceptors = [];
4
- }
5
- InterceptorManager.prototype.add = function (interceptor) {
6
- this.interceptors.push(interceptor);
7
- };
8
- InterceptorManager.prototype.remove = function (interceptor) {
9
- this.interceptors = this.interceptors.filter(function (i) { return i !== interceptor; });
10
- };
11
- InterceptorManager.prototype.filter = function (contextToMatch) {
12
- return this.interceptors.filter(function (i) { return i.match(contextToMatch); });
13
- };
14
- return InterceptorManager;
15
- }());
16
- export { InterceptorManager };
17
- //# sourceMappingURL=interceptor.manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interceptor.manager.js","sourceRoot":"./","sources":["src/interceptor/interceptor.manager.ts"],"names":[],"mappings":"AAGA;IAAA;QAEY,iBAAY,GAAuB,EAAE,CAAC;IAalD,CAAC;IAXG,gCAAG,GAAH,UAAI,WAA6B;QAC7B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IAED,mCAAM,GAAN,UAAO,WAA6B;QAChC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,KAAK,WAAW,EAAjB,CAAiB,CAAC,CAAC;IACzE,CAAC;IAED,mCAAM,GAAN,UAAO,cAAqC;QACxC,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,EAAvB,CAAuB,CAAC,CAAC;IAClE,CAAC;IACL,yBAAC;AAAD,CAAC,AAfD,IAeC","sourcesContent":["import { InterceptContext } from \"./intercept-context\";\nimport { Interceptor } from \"./interceptor\";\n\nexport class InterceptorManager {\n\n private interceptors: Interceptor<any>[] = [];\n\n add(interceptor: Interceptor<any>) {\n this.interceptors.push(interceptor);\n }\n\n remove(interceptor: Interceptor<any>) {\n this.interceptors = this.interceptors.filter(i => i !== interceptor);\n }\n\n filter(contextToMatch: InterceptContext<any>) {\n return this.interceptors.filter(i => i.match(contextToMatch));\n }\n}"]}
@@ -1,28 +0,0 @@
1
- export interface StorageService {
2
- setItem(key: string, value: any, ttl: number): Promise<void>;
3
- getItem(key: string): Promise<any>;
4
- removeItem(key: string): Promise<void>;
5
- clear(): Promise<any>;
6
- }
7
- declare class SimpleStorageService implements StorageService {
8
- private cache;
9
- private keyPrefix;
10
- constructor(cache: any, keyPrefix: string);
11
- getKey(key: string): string;
12
- getTtlKey(key: string): string;
13
- setItem(key: string, value: any, ttl: number): Promise<void>;
14
- getItem(key: string): Promise<any>;
15
- removeItem(key: string): Promise<void>;
16
- clear(): Promise<void>;
17
- }
18
- export declare class SessionStorageService extends SimpleStorageService {
19
- static cache: any;
20
- static inerval: NodeJS.Timeout | null;
21
- private constructor();
22
- static getInstance(keyPrefix: string): SessionStorageService;
23
- }
24
- export declare class TemporaryStorageService extends SimpleStorageService {
25
- private constructor();
26
- static getInstance(keyPrefix: string): TemporaryStorageService;
27
- }
28
- export {};
@@ -1,144 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- var __generator = (this && this.__generator) || function (thisArg, body) {
26
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
- function verb(n) { return function (v) { return step([n, v]); }; }
29
- function step(op) {
30
- if (f) throw new TypeError("Generator is already executing.");
31
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
- if (y = 0, t) op = [op[0] & 2, t.value];
34
- switch (op[0]) {
35
- case 0: case 1: t = op; break;
36
- case 4: _.label++; return { value: op[1], done: false };
37
- case 5: _.label++; y = op[1]; op = [0]; continue;
38
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
- default:
40
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
- if (t[2]) _.ops.pop();
45
- _.trys.pop(); continue;
46
- }
47
- op = body.call(thisArg, _);
48
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
- }
51
- };
52
- var TTL_KEY_SUFFIX = '_ttl';
53
- var SimpleStorageService = /** @class */ (function () {
54
- function SimpleStorageService(cache, keyPrefix) {
55
- this.cache = cache;
56
- this.keyPrefix = keyPrefix;
57
- this.keyPrefix = keyPrefix;
58
- }
59
- SimpleStorageService.prototype.getKey = function (key) {
60
- return this.keyPrefix + key;
61
- };
62
- SimpleStorageService.prototype.getTtlKey = function (key) {
63
- return this.getKey(key) + TTL_KEY_SUFFIX;
64
- };
65
- SimpleStorageService.prototype.setItem = function (key, value, ttl) {
66
- return __awaiter(this, void 0, void 0, function () {
67
- return __generator(this, function (_a) {
68
- this.cache[this.getKey(key)] = value;
69
- if (ttl && ttl > 0) {
70
- this.cache[this.getTtlKey(key)] = Date.now() + ttl;
71
- }
72
- return [2 /*return*/];
73
- });
74
- });
75
- };
76
- SimpleStorageService.prototype.getItem = function (key) {
77
- return __awaiter(this, void 0, void 0, function () {
78
- var value, ttl;
79
- return __generator(this, function (_a) {
80
- switch (_a.label) {
81
- case 0:
82
- value = this.cache[this.getKey(key)];
83
- if (!value) return [3 /*break*/, 2];
84
- ttl = this.cache[this.getTtlKey(key)];
85
- if (!(ttl && ttl < Date.now())) return [3 /*break*/, 2];
86
- return [4 /*yield*/, this.removeItem(key)];
87
- case 1:
88
- _a.sent();
89
- return [2 /*return*/, null];
90
- case 2: return [2 /*return*/, value];
91
- }
92
- });
93
- });
94
- };
95
- SimpleStorageService.prototype.removeItem = function (key) {
96
- return __awaiter(this, void 0, void 0, function () {
97
- return __generator(this, function (_a) {
98
- delete this.cache[this.getKey(key)];
99
- delete this.cache[this.getTtlKey(key)];
100
- return [2 /*return*/];
101
- });
102
- });
103
- };
104
- SimpleStorageService.prototype.clear = function () {
105
- return __awaiter(this, void 0, void 0, function () {
106
- return __generator(this, function (_a) {
107
- // For SessionStorageService, clear the static cache
108
- if (this.cache === SessionStorageService.cache) {
109
- SessionStorageService.cache = {};
110
- }
111
- else {
112
- this.cache = {};
113
- }
114
- return [2 /*return*/];
115
- });
116
- });
117
- };
118
- return SimpleStorageService;
119
- }());
120
- var SessionStorageService = /** @class */ (function (_super) {
121
- __extends(SessionStorageService, _super);
122
- function SessionStorageService(keyPrefix) {
123
- return _super.call(this, SessionStorageService.cache, keyPrefix) || this;
124
- }
125
- SessionStorageService.getInstance = function (keyPrefix) {
126
- return new SessionStorageService(keyPrefix);
127
- };
128
- SessionStorageService.cache = {};
129
- SessionStorageService.inerval = null;
130
- return SessionStorageService;
131
- }(SimpleStorageService));
132
- export { SessionStorageService };
133
- var TemporaryStorageService = /** @class */ (function (_super) {
134
- __extends(TemporaryStorageService, _super);
135
- function TemporaryStorageService(keyPrefix) {
136
- return _super.call(this, {}, keyPrefix) || this;
137
- }
138
- TemporaryStorageService.getInstance = function (keyPrefix) {
139
- return new TemporaryStorageService(keyPrefix);
140
- };
141
- return TemporaryStorageService;
142
- }(SimpleStorageService));
143
- export { TemporaryStorageService };
144
- //# sourceMappingURL=storage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"./","sources":["src/interceptor/storage.ts"],"names":[],"mappings":"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","sourcesContent":["export interface StorageService {\n setItem(key: string, value: any, ttl: number): Promise<void>;\n getItem(key: string): Promise<any>;\n removeItem(key: string): Promise<void>;\n clear(): Promise<any>;\n}\n\nconst TTL_KEY_SUFFIX = '_ttl';\n\nclass SimpleStorageService implements StorageService {\n\n constructor(private cache: any, private keyPrefix: string) {\n this.keyPrefix = keyPrefix;\n }\n\n getKey(key: string) {\n return this.keyPrefix + key;\n }\n\n getTtlKey(key: string) {\n return this.getKey(key) + TTL_KEY_SUFFIX;\n }\n\n public async setItem(key: string, value: any, ttl: number) {\n this.cache[this.getKey(key)] = value;\n if (ttl && ttl > 0) {\n this.cache[this.getTtlKey(key)] = Date.now() + ttl;\n }\n }\n\n public async getItem(key: string) {\n const value = this.cache[this.getKey(key)];\n if (value) {\n const ttl = this.cache[this.getTtlKey(key)];\n if (ttl && ttl < Date.now()) {\n await this.removeItem(key);\n return null;\n }\n }\n return value;\n }\n\n public async removeItem(key: string) {\n delete this.cache[this.getKey(key)];\n delete this.cache[this.getTtlKey(key)];\n }\n\n public async clear() {\n // For SessionStorageService, clear the static cache\n if (this.cache === SessionStorageService.cache) {\n SessionStorageService.cache = {} as any;\n } else {\n this.cache = {} as any;\n }\n }\n}\n\nexport class SessionStorageService extends SimpleStorageService {\n static cache = {} as any;\n static inerval: NodeJS.Timeout | null = null;\n\n private constructor(keyPrefix: string) {\n super(SessionStorageService.cache, keyPrefix);\n }\n\n static getInstance(keyPrefix: string) {\n return new SessionStorageService(keyPrefix);\n }\n}\n\nexport class TemporaryStorageService extends SimpleStorageService {\n private constructor(keyPrefix: string) {\n super({}, keyPrefix);\n }\n\n static getInstance(keyPrefix: string) {\n return new TemporaryStorageService(keyPrefix);\n }\n}"]}