@candlerip/shared 0.0.130 → 0.0.131

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,6 +1,6 @@
1
1
  import { CustomErrorWorker } from '../../../common/index.js';
2
2
  import { createClient } from 'redis';
3
- import { composeGetRedisData } from './compose-redis-get-data/index.js';
3
+ import { composeGetRedisData } from './compose-get-redis-data/index.js';
4
4
  export const CacheWorker = (environmentMode, url, password, options) => {
5
5
  const _isEnabled = Boolean(options?.isEnabled);
6
6
  const customErrorWorker = CustomErrorWorker();
@@ -38,9 +38,10 @@ export const CacheWorker = (environmentMode, url, password, options) => {
38
38
  data: _client,
39
39
  };
40
40
  };
41
- const getCache = async (props) => {
41
+ const get = async (props) => {
42
+ const { cacheKey } = props;
42
43
  const { composeCustomError } = CustomErrorWorker({ info: props });
43
- const { cacheKey, objKeys, pathKeys } = composeGetRedisData(props);
44
+ const { objKeys, pathKeys } = composeGetRedisData(props);
44
45
  const { data: client, customError } = _getClient();
45
46
  if (customError) {
46
47
  return { customError };
@@ -79,7 +80,7 @@ export const CacheWorker = (environmentMode, url, password, options) => {
79
80
  data: normalizedData,
80
81
  };
81
82
  };
82
- const mGetCache = async (props) => {
83
+ const gets = async (props) => {
83
84
  const { composeCustomError } = CustomErrorWorker({ info: { props } });
84
85
  const getRedisData = props.map((it) => composeGetRedisData(it));
85
86
  const { data: client, customError } = _getClient();
@@ -123,7 +124,7 @@ export const CacheWorker = (environmentMode, url, password, options) => {
123
124
  data: normalizedData,
124
125
  };
125
126
  };
126
- const setCache = async (key, data) => {
127
+ const set = async (key, data) => {
127
128
  const { composeCustomError } = CustomErrorWorker({ info: { key } });
128
129
  const { data: client, customError } = _getClient();
129
130
  if (customError) {
@@ -142,8 +143,8 @@ export const CacheWorker = (environmentMode, url, password, options) => {
142
143
  };
143
144
  };
144
145
  return {
145
- getCache,
146
- mGetCache,
147
- setCache,
146
+ get,
147
+ gets,
148
+ set,
148
149
  };
149
150
  };
@@ -4,23 +4,23 @@ import { createClient } from 'redis';
4
4
  export type TCacheWorker = (environmentMode: EnvironmentMode, url: string, password: string, options?: {
5
5
  isEnabled?: boolean;
6
6
  }) => {
7
- getCache: GetCache;
8
- mGetCache: MGetCache;
9
- setCache: SetCache;
7
+ get: Get;
8
+ gets: Gets;
9
+ set: Set;
10
10
  };
11
11
  export type GetClient = () => TCustomError<ReturnType<typeof createClient>>;
12
- export type SetCache = <T extends keyof Cache>(key: T, data: Cache[T]) => Promise<TCustomError<null>>;
13
- export type GetCache = <T extends CacheData = never, C extends CacheKey = CacheKey>(props: GetCacheProps<C>) => Promise<TCustomError<T>>;
14
- export type GetCacheProps<C extends CacheKey> = C extends CandleLightingProfilesCacheKey ? {
12
+ export type Set = <T extends keyof Cache>(key: T, data: Cache[T]) => Promise<TCustomError<null>>;
13
+ export type Get = <T extends CacheData = never, C extends CacheKey = CacheKey>(props: GetProps<C>) => Promise<TCustomError<T>>;
14
+ export type GetProps<C extends CacheKey> = C extends CandleLightingProfilesCacheKey ? {
15
15
  cacheKey: C;
16
16
  objKey?: ObjKey;
17
17
  } : {
18
18
  cacheKey: C;
19
19
  objKeys?: string[];
20
20
  };
21
- export type MGetCache = <T extends {
21
+ export type Gets = <T extends {
22
22
  [key in CacheKey]?: CacheData;
23
- } = never, C extends CacheKey = CacheKey>(props: GetCacheProps<C>[]) => Promise<TCustomError<T>>;
23
+ } = never, C extends CacheKey = CacheKey>(props: GetProps<C>[]) => Promise<TCustomError<T>>;
24
24
  export type ObjKeys = string[];
25
25
  export type ObjKey = {
26
26
  code: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared",
3
- "version": "0.0.130",
3
+ "version": "0.0.131",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "=22.19.0"