@appconda/nextjs 1.0.26 → 1.0.27

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,14 +1,4 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
1
  import { ServiceClient } from "../service-client";
11
- import { Cache } from '../decorators/Cache';
12
2
  export class Subscription extends ServiceClient {
13
3
  getServiceName() {
14
4
  return 'com.appconda.service.subscription';
@@ -37,9 +27,3 @@ export class Subscription extends ServiceClient {
37
27
  return await this.actionCall('GetAllTenantSubscriptionProducts', payload);
38
28
  }
39
29
  }
40
- __decorate([
41
- Cache(),
42
- __metadata("design:type", Function),
43
- __metadata("design:paramtypes", [Object, Object]),
44
- __metadata("design:returntype", Promise)
45
- ], Subscription.prototype, "getAllTenantSubscriptionProducts", null);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@appconda/nextjs",
3
3
  "homepage": "https://appconda.io/support",
4
4
  "description": "Appconda is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "1.0.26",
5
+ "version": "1.0.27",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
@@ -11,7 +11,6 @@
11
11
  "url": "https://github.com/appconda/sdk-for-console"
12
12
  },
13
13
  "scripts": {
14
- "build": "npm run build:types && npm run build:libs",
15
14
  "tsc-build": "tsc"
16
15
  },
17
16
  "devDependencies": {
package/publish.sh CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  npm version patch -m "Upgrade to new version"
3
- npm run build
3
+ npm run tsc-build
4
4
  npm publish --access public
@@ -1,6 +1,5 @@
1
1
  import { Payload } from "../client";
2
2
  import { ServiceClient } from "../service-client";
3
- import { Cache } from '../decorators/Cache'
4
3
 
5
4
 
6
5
 
@@ -30,7 +29,7 @@ export class Subscription extends ServiceClient {
30
29
  return await this.actionCall('GetSubscriptionProduct', payload);
31
30
  }
32
31
 
33
- @Cache()
32
+
34
33
  public async getAllTenantSubscriptionProducts(filters?: any, pagination?: { page: number; pageSize: number }): Promise<{ items: any[]; pagination: any }> {
35
34
  const payload: Payload = {};
36
35
  payload['filters'] = filters;
@@ -1,11 +0,0 @@
1
-
2
- export interface Adapter {
3
- load(key: string, ttl: number, hash?: string): Promise<any>;
4
- save(key: string, data: any, hash?: string): Promise<boolean | string | any[]>;
5
- list(key: string): Promise<string[]>;
6
- purge(key: string, hash?: string): Promise<boolean>;
7
- flush(): Promise<boolean>;
8
- ping(): Promise<boolean>;
9
- getSize(): Promise<number>;
10
- delWithStart(pattern: string): Promise<number>;
11
- }
@@ -1,126 +0,0 @@
1
- import { Adapter } from "../Adapter";
2
- const fs = require('fs');
3
- const path = require('path');
4
- const glob = require('glob');
5
-
6
- export class Filesystem implements Adapter {
7
- protected path: string = '';
8
-
9
- constructor(path: string) {
10
- this.path = path;
11
- }
12
- delWithStart(pattern: string): Promise<number> {
13
- throw new Error("Method not implemented.");
14
- }
15
-
16
- async load(key: string, ttl: number, hash: string = ''): Promise<any> {
17
- const file = this.getPath(key);
18
-
19
- if (fs.existsSync(file) && (fs.statSync(file).mtime.getTime() + ttl * 1000 > Date.now())) {
20
- return fs.readFileSync(file, 'utf8');
21
- }
22
-
23
- return false;
24
- }
25
-
26
- async save(key: string, data: any, hash: string = ''): Promise<boolean | string | any[]> {
27
- if (!data) {
28
- return false;
29
- }
30
-
31
- const file = this.getPath(key);
32
- const dir = path.dirname(file);
33
-
34
- try {
35
- if (!fs.existsSync(dir)) {
36
- fs.mkdirSync(dir, { recursive: true });
37
- }
38
-
39
- fs.writeFileSync(file, data, { flag: 'w' });
40
- return data;
41
- } catch (e: any) {
42
- throw new Error(e.message);
43
- }
44
- }
45
-
46
- async list(key: string): Promise<string[]> {
47
- return [];
48
- }
49
-
50
- async purge(key: string, hash: string = ''): Promise<boolean> {
51
- const file = this.getPath(key);
52
-
53
- if (fs.existsSync(file)) {
54
- fs.unlinkSync(file);
55
- return true;
56
- }
57
-
58
- return false;
59
- }
60
-
61
- async flush(): Promise<boolean> {
62
- return this.deleteDirectory(this.path);
63
- }
64
-
65
- async ping(): Promise<boolean> {
66
- return fs.existsSync(this.path) && fs.accessSync(this.path, fs.constants.W_OK | fs.constants.R_OK);
67
- }
68
-
69
- async getSize(): Promise<number> {
70
- try {
71
- return this.getDirectorySize(path.dirname(this.path));
72
- } catch {
73
- return 0;
74
- }
75
- }
76
-
77
- private getDirectorySize(dir: string): number {
78
- let size = 0;
79
- const normalizedPath = path.join(dir, '*');
80
-
81
- const paths = glob.sync(normalizedPath, { nodir: false });
82
- if (!paths) {
83
- return size;
84
- }
85
-
86
- for (const p of paths) {
87
- if (fs.statSync(p).isFile()) {
88
- size += fs.statSync(p).size;
89
- } else if (fs.statSync(p).isDirectory()) {
90
- size += this.getDirectorySize(p);
91
- }
92
- }
93
-
94
- return size;
95
- }
96
-
97
- getPath(filename: string): string {
98
- return path.join(this.path, filename);
99
- }
100
-
101
- protected deleteDirectory(dirPath: string): boolean {
102
- if (!fs.statSync(dirPath).isDirectory()) {
103
- throw new Error(`${dirPath} must be a directory`);
104
- }
105
-
106
- if (!dirPath.endsWith('/')) {
107
- dirPath += '/';
108
- }
109
-
110
- const files = glob.sync(dirPath + '*', { mark: true });
111
-
112
- if (!files) {
113
- throw new Error('Error happened during glob');
114
- }
115
-
116
- for (const file of files) {
117
- if (fs.statSync(file).isDirectory()) {
118
- this.deleteDirectory(file);
119
- } else {
120
- fs.unlinkSync(file);
121
- }
122
- }
123
-
124
- return fs.rmdirSync(dirPath);
125
- }
126
- }
@@ -1,57 +0,0 @@
1
- import { Adapter } from "../Adapter";
2
-
3
- export class Memory implements Adapter {
4
- public store: { [key: string]: { time: number, data: any } } = {};
5
-
6
- constructor() {}
7
- delWithStart(pattern: string): Promise<number> {
8
- throw new Error("Method not implemented.");
9
- }
10
-
11
- async load(key: string, ttl: number, hash: string = ''): Promise<any> {
12
- if (key && this.store[key]) {
13
- const saved = this.store[key];
14
- return (saved.time + ttl > Date.now() / 1000) ? saved.data : false;
15
- }
16
- return false;
17
- }
18
-
19
- async save(key: string, data: any, hash: string = ''): Promise<boolean | string | any[]> {
20
- if (!key || !data) {
21
- return false;
22
- }
23
-
24
- const saved = {
25
- time: Date.now() / 1000,
26
- data: data,
27
- };
28
-
29
- this.store[key] = saved;
30
- return data;
31
- }
32
-
33
- async list(key: string): Promise<string[]> {
34
- return [];
35
- }
36
-
37
- async purge(key: string, hash: string = ''): Promise<boolean> {
38
- if (key && this.store[key]) {
39
- delete this.store[key];
40
- return true;
41
- }
42
- return false;
43
- }
44
-
45
- async flush(): Promise<boolean> {
46
- this.store = {};
47
- return true;
48
- }
49
-
50
- async ping(): Promise<boolean> {
51
- return true;
52
- }
53
-
54
- async getSize(): Promise<number> {
55
- return Object.keys(this.store).length;
56
- }
57
- }
@@ -1,36 +0,0 @@
1
- import { Adapter } from "../Adapter";
2
-
3
- export class None implements Adapter {
4
- constructor() {}
5
- delWithStart(pattern: string): Promise<number> {
6
- throw new Error("Method not implemented.");
7
- }
8
-
9
- async load(key: string, ttl: number, hash: string = ''): Promise<any> {
10
- return false;
11
- }
12
-
13
- async save(key: string, data: any, hash: string = ''): Promise<boolean | string | any[]> {
14
- return false;
15
- }
16
-
17
- async list(key: string): Promise<string[]> {
18
- return [];
19
- }
20
-
21
- async purge(key: string, hash: string = ''): Promise<boolean> {
22
- return true;
23
- }
24
-
25
- async flush(): Promise<boolean> {
26
- return true;
27
- }
28
-
29
- async ping(): Promise<boolean> {
30
- return true;
31
- }
32
-
33
- async getSize(): Promise<number> {
34
- return 0;
35
- }
36
- }
@@ -1,106 +0,0 @@
1
- import { RedisClientType, } from 'redis';
2
- import { Adapter } from "../Adapter";
3
-
4
-
5
- export class Redis implements Adapter {
6
- protected redis: RedisClientType;
7
-
8
- constructor(redis: RedisClientType) {
9
- this.redis = redis;
10
- }
11
-
12
- async load(key: string, ttl: number, hash: string = ''): Promise<any> {
13
- if (!hash) {
14
- hash = key;
15
- }
16
-
17
- return new Promise((resolve) => {
18
- try {
19
- this.redis.get(key).then((redisString) => {
20
- if (!redisString) {
21
- resolve(null);
22
- }
23
-
24
- const cache = JSON.parse(redisString);
25
- if (cache != null && cache.time + ttl > Date.now() / 1000) {
26
- resolve(cache.data);
27
- } else {
28
- resolve(null);
29
- }
30
- })
31
- .catch((e) => {
32
- console.error('redis error');
33
- })
34
- }
35
- catch (e) {
36
- console.error('redis error');
37
- }
38
- })
39
- }
40
-
41
- async save(key: string, data: any, hash: string = ''): Promise<boolean | string | any[]> {
42
- if (!key || !data) {
43
- return Promise.resolve(false);
44
- }
45
-
46
- if (!hash) {
47
- hash = key;
48
- }
49
-
50
- const value = JSON.stringify({
51
- time: Date.now() / 1000,
52
- data: data,
53
- });
54
-
55
- return this.redis.set(key, value).then(() => data).catch(() => false);
56
- }
57
-
58
- list(key: string): Promise<string[]> {
59
-
60
- return this.redis.hKeys(key).then((keys) => keys || []);
61
- }
62
-
63
- async purge(key: string, hash: string = ''): Promise<boolean> {
64
- if (hash) {
65
- return this.redis.del(key).then((result) => !!result);
66
- }
67
-
68
- const result = await this.redis.del(key);
69
-
70
- return !!result;
71
- }
72
-
73
- flush(): Promise<boolean> {
74
- //@ts-ignore
75
- return this.redis.flushall().then(() => true);
76
- }
77
-
78
- ping(): Promise<boolean> {
79
- return this.redis.ping().then(() => true).catch(() => false);
80
- }
81
-
82
- getSize(): Promise<number> {
83
- //@ts-ignore
84
- return this.redis.dbsize();
85
- }
86
-
87
- async delWithStart(pattern: string): Promise<number> {
88
-
89
- let cur = 0;
90
- let totalDeleted = 0;
91
-
92
- do {
93
- const {cursor, keys} = await this.redis.scan(cur, {
94
- MATCH: `${pattern}:*`,
95
- COUNT: 100, // Her taramada maksimum 100 anahtar döndür
96
- }) as any;
97
-
98
-
99
- cur = Number(cursor);
100
-
101
- await Promise.all(keys.map ((key: string) => this.redis.del(key)))
102
- } while (cur !== 0);
103
-
104
- return totalDeleted;
105
- }
106
- }
@@ -1,87 +0,0 @@
1
- import { Adapter } from "../Adapter";
2
-
3
- export class Sharding implements Adapter {
4
- protected adapters: Adapter[];
5
- protected count: number = 0;
6
-
7
- constructor(adapters: Adapter[]) {
8
- if (adapters.length === 0) {
9
- throw new Error('No adapters provided');
10
- }
11
-
12
- this.count = adapters.length;
13
- this.adapters = adapters;
14
- }
15
- delWithStart(pattern: string): Promise<number> {
16
- throw new Error("Method not implemented.");
17
- }
18
-
19
- async load(key: string, ttl: number, hash: string = ''): Promise<any> {
20
- const adapter = this.getAdapter(key);
21
- return await adapter.load(key, ttl, hash);
22
- }
23
-
24
- async save(key: string, data: any, hash: string = ''): Promise<boolean | string | any[]> {
25
- return this.getAdapter(key).save(key, data, hash);
26
- }
27
-
28
- async list(key: string): Promise<string[]> {
29
- return this.getAdapter(key).list(key);
30
- }
31
-
32
- async purge(key: string, hash: string = ''): Promise<boolean> {
33
- return this.getAdapter(key).purge(key, hash);
34
- }
35
-
36
- async flush(): Promise<boolean> {
37
- let result = true;
38
- for (const adapter of this.adapters) {
39
- result = await adapter.flush() ? result : false;
40
- }
41
- return result;
42
- }
43
-
44
- async ping(): Promise<boolean> {
45
- for (const adapter of this.adapters) {
46
- if (!adapter.ping()) {
47
- return false;
48
- }
49
- }
50
- return true;
51
- }
52
-
53
- async getSize(): Promise<number> {
54
- let size = 0;
55
- for (const adapter of this.adapters) {
56
- size += await adapter.getSize();
57
- }
58
- return size;
59
- }
60
-
61
- protected getAdapter(key: string): Adapter {
62
- const hash = this.crc32(key);
63
- const index = hash % this.count;
64
- return this.adapters[index];
65
- }
66
-
67
- private crc32(str: string): number {
68
- let crc = 0 ^ (-1);
69
- for (let i = 0; i < str.length; i++) {
70
- crc = (crc >>> 8) ^ this.crc32Table[(crc ^ str.charCodeAt(i)) & 0xff];
71
- }
72
- return (crc ^ (-1)) >>> 0;
73
- }
74
-
75
- private crc32Table = (() => {
76
- let c: number;
77
- const table: number[] = [];
78
- for (let n = 0; n < 256; n++) {
79
- c = n;
80
- for (let k = 0; k < 8; k++) {
81
- c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
82
- }
83
- table[n] = c;
84
- }
85
- return table;
86
- })();
87
- }
@@ -1,75 +0,0 @@
1
- import { Adapter } from "./Adapter";
2
-
3
-
4
- export class Cache {
5
- private adapter: Adapter;
6
- public static caseSensitive: boolean = false;
7
-
8
- constructor(adapter: Adapter) {
9
- this.adapter = adapter;
10
- }
11
-
12
- private constructKey(key: any): string {
13
- if (Array.isArray(key)) {
14
- key = key.join(':');
15
- }
16
-
17
- return key;
18
- }
19
-
20
- public static setCaseSensitivity(value: boolean): boolean {
21
- return this.caseSensitive = value;
22
- }
23
-
24
- public async load(key: string | string[], ttl: number = 60 * 60 * 24, hash: string = ''): Promise<any> {
25
- key = this.constructKey(key);
26
- key = Cache.caseSensitive ? key : key.toLowerCase();
27
- hash = Cache.caseSensitive ? hash : hash.toLowerCase();
28
-
29
- return await this.adapter.load(key, ttl, hash);
30
- }
31
-
32
- public async save(key: string | string[], data: any, hash: string = ''): Promise<boolean | string | any[]> {
33
-
34
- key = this.constructKey(key);
35
-
36
- key = Cache.caseSensitive ? key : key.toLowerCase();
37
- hash = Cache.caseSensitive ? hash : hash.toLowerCase();
38
-
39
- return this.adapter.save(key, data, hash);
40
- }
41
-
42
- public async list(key: string | string[]): Promise<string[]> {
43
- key = this.constructKey(key);
44
- key = Cache.caseSensitive ? key : key.toLowerCase();
45
-
46
- return this.adapter.list(key);
47
- }
48
-
49
- public async purge(key: string | string[], hash: string = ''): Promise<boolean> {
50
-
51
- key = this.constructKey(key);
52
-
53
- key = Cache.caseSensitive ? key : key.toLowerCase();
54
- hash = Cache.caseSensitive ? hash : hash.toLowerCase();
55
-
56
- return this.adapter.purge(key, hash);
57
- }
58
-
59
- public async flush(): Promise<boolean> {
60
- return this.adapter.flush();
61
- }
62
-
63
- public async ping(): Promise<boolean> {
64
- return this.adapter.ping();
65
- }
66
-
67
- public async getSize(): Promise<number> {
68
- return this.adapter.getSize();
69
- }
70
-
71
- public async delWithStart(keys: string | string[]): Promise<number> {
72
- const pattern = this.constructKey(keys);
73
- return this.adapter.delWithStart(pattern);
74
- }
75
- }
@@ -1,5 +0,0 @@
1
- export * from './Cache';
2
- export * from './Adapters/None';
3
- export * from './Adapters/Redis';
4
- export * from './Adapters/Sharding';
5
- export * from './Adapters/Memory';
package/src/Cache/test.ts DELETED
File without changes
package/src/Services.ts DELETED
@@ -1,42 +0,0 @@
1
- import { Registry } from "./lib/Registry";
2
- import { createClient } from 'redis';
3
- import { Redis } from "./Cache/Adapters/Redis";
4
- import { Cache } from "./Cache";
5
- import 'server-only'
6
-
7
-
8
- export const registry = new Registry();
9
-
10
- registry.set('cache', () => {
11
- const client = createClient({
12
- socket: {
13
- host: process.env._APP_REDIS_HOST ?? 'localhost',
14
- port: Number.parseInt(process.env._APP_REDIS_PORT ?? '6379'),
15
-
16
- },
17
- password: undefined,
18
- });
19
-
20
- // Bağlantı hatalarını ele al
21
- client.on('error', (err) => {
22
-
23
- console.error('Redis Client Error', err);
24
- });
25
-
26
- // Connect to Redis
27
- client.connect();
28
-
29
- const redisAdapter = new Redis(client as any);
30
-
31
- const cacheProvider = new Cache(redisAdapter);
32
-
33
- return cacheProvider;
34
-
35
- })
36
-
37
- export class Services {
38
- public static get Cache(): Cache {
39
- return registry.get('cache');
40
- }
41
-
42
- }
@@ -1,102 +0,0 @@
1
- import { Services } from '../Services';
2
-
3
- function stableStringify(obj: any): string {
4
- if (obj && typeof obj === "object" && !Array.isArray(obj)) {
5
- return `{${Object.keys(obj).sort().map(key => `"${key}":${stableStringify(obj[key])}`).join(",")}}`;
6
- }
7
- return JSON.stringify(obj);
8
- }
9
-
10
- function generateCacheKey(...args: any[]): string {
11
- return stableStringify(args);
12
- }
13
-
14
-
15
- // console.log(generateCacheKey("user", 123, true, { role: "admin", permissions: ["read", "write"] }));
16
- // console.log(generateCacheKey("user", 123, true, { permissions: ["read", "write"], role: "admin" }));
17
-
18
-
19
-
20
- export function Cache(/* cacheKey?: string | string[] */) {
21
- return function (
22
- target: any,
23
- propertyKey: string,
24
- descriptor: PropertyDescriptor
25
- ) {
26
- const originalMethod = descriptor.value;
27
-
28
- descriptor.value = async function (...args: any[]) {
29
-
30
- const className = target.constructor.name.toLowerCase();
31
-
32
- // Metod adı
33
- const methodName = propertyKey.toLowerCase();
34
-
35
- const cacheKeys: any[] = [target.__cacheKeys || []].reverse();
36
- console.log("Defined cache keys:", cacheKeys);
37
-
38
- const cacheKey = ['admin', className, propertyKey];
39
-
40
- if (cacheKeys.length > 0) {
41
- for (let i = 0; i < cacheKeys.length; i++) {
42
- const keyIndex = cacheKeys[i]['parameterIndex'];
43
- if (args != null && args[keyIndex] != null) {
44
- const key = args[keyIndex].toString();
45
- cacheKey.push(key);
46
- }
47
- }
48
- } else if (args.length > 0) { //cacheKey belirtilmemisse tum parametreleri kullan
49
- for (let i = 0; i < args.length; i++) {
50
- const key = args[i].toString();
51
- cacheKey.push(key);
52
- }
53
- }
54
-
55
- // Cache key'i dizeye dönüştür
56
- // const key = Array.isArray(cacheKey) ? cacheKey.join(':') : cacheKey;
57
-
58
- // Cache'ten veri al
59
- let cachedData = await Services.Cache.load(cacheKey);
60
-
61
- if (cachedData != null) {
62
- return cachedData; // Cache'teki veriyi döndür
63
- }
64
-
65
- // Orijinal metodu çağır ve dönen değeri cache'e kaydet
66
- const result = await originalMethod.apply(this, args);
67
-
68
- // Cache'e kaydet (asenkron yapılır, beklenmez)
69
- Services.Cache.save(cacheKey, result);
70
- console.log('------------------------------Cache executed..')
71
- return result;
72
- };
73
-
74
- return descriptor;
75
- };
76
- }
77
-
78
-
79
- /* const cacheKeys: any[] = target.__cacheKeys || [];
80
- console.log("Defined cache keys:", [...cacheKeys].reverse());
81
-
82
- const className = target.constructor.name.toLowerCase();
83
-
84
- // Metod adı
85
- const methodName = propertyKey.toLowerCase();
86
-
87
- debugger
88
- const cacheKey = ['admin', className, propertyKey];
89
- if (cacheKey.length > 0) {
90
- for (let i = 0; i < cacheKeys.length; i++) {
91
- const keyIndex = cacheKeys[i]['parameterIndex'];
92
- if (args != null && args[keyIndex] != null) {
93
- const key = args[keyIndex].toString();
94
- cacheKey.push(key);
95
- }
96
- }
97
- } else if (args.length > 0) { //cacheKey belirtilmemisse tum parametreleri kullan
98
- for (let i = 0; i < args.length; i++) {
99
- const key = args[i].toString();
100
- cacheKey.push(key);
101
- }
102
- } */
@@ -1,9 +0,0 @@
1
-
2
- export function CacheKey() {
3
- return function (target: any, propertyKey: string | symbol, parameterIndex: number): void {
4
- if (!target.__cacheKeys) {
5
- target.__cacheKeys = [];
6
- }
7
- target.__cacheKeys.push({ propertyKey, parameterIndex });
8
- };
9
- }
@@ -1,68 +0,0 @@
1
- import { Services } from '../Services';
2
-
3
- export function Invalidate(keys: string | string[]) {
4
- return function (
5
- target: any,
6
- propertyKey: string,
7
- descriptor: PropertyDescriptor
8
- ) {
9
- const originalMethod = descriptor.value;
10
-
11
- descriptor.value = async function (...args: any[]) {
12
-
13
- const className = target.constructor.name.toLowerCase();
14
-
15
- // Metod adı
16
- const methodName = propertyKey.toLowerCase();
17
-
18
-
19
-
20
- const cacheKey = ['admin', className];
21
-
22
-
23
-
24
-
25
- // Orijinal metodu çağır ve dönen değeri cache'e kaydet
26
- const result = await originalMethod.apply(this, args);
27
-
28
- // Cache'e kaydet (asenkron yapılır, beklenmez)
29
-
30
- for (let key of keys) {
31
- Services.Cache.purge([...cacheKey, key]);
32
- Services.Cache.delWithStart([...cacheKey, key]);
33
- }
34
-
35
-
36
- console.log('------------------------------Cache deleted.')
37
- return result;
38
- };
39
-
40
- return descriptor;
41
- };
42
- }
43
-
44
-
45
- /* const cacheKeys: any[] = target.__cacheKeys || [];
46
- console.log("Defined cache keys:", [...cacheKeys].reverse());
47
-
48
- const className = target.constructor.name.toLowerCase();
49
-
50
- // Metod adı
51
- const methodName = propertyKey.toLowerCase();
52
-
53
- debugger
54
- const cacheKey = ['admin', className, propertyKey];
55
- if (cacheKey.length > 0) {
56
- for (let i = 0; i < cacheKeys.length; i++) {
57
- const keyIndex = cacheKeys[i]['parameterIndex'];
58
- if (args != null && args[keyIndex] != null) {
59
- const key = args[keyIndex].toString();
60
- cacheKey.push(key);
61
- }
62
- }
63
- } else if (args.length > 0) { //cacheKey belirtilmemisse tum parametreleri kullan
64
- for (let i = 0; i < args.length; i++) {
65
- const key = args[i].toString();
66
- cacheKey.push(key);
67
- }
68
- } */