@wzyjs/utils 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/browser/cjs/browser/element.js +40 -0
  2. package/dist/browser/cjs/browser/index.js +20 -0
  3. package/dist/browser/cjs/browser/other.js +12 -0
  4. package/dist/browser/cjs/browser/style.js +49 -0
  5. package/dist/browser/cjs/browser.js +171 -0
  6. package/dist/browser/cjs/common/classs.js +14 -0
  7. package/dist/browser/cjs/common/dayjs.js +27 -0
  8. package/dist/browser/cjs/types/index.d.ts +27 -0
  9. package/dist/{esm/fe → browser/cjs/utils/src/browser}/index.d.ts +0 -1
  10. package/dist/browser/cjs/utils/src/browser.d.ts +2 -0
  11. package/dist/browser/cjs/utils/src/common/classs.d.ts +5 -0
  12. package/dist/browser/cjs/utils/src/common/index.d.ts +11 -0
  13. package/dist/{cjs/common/tools → browser/cjs/utils/src/common}/other.d.ts +1 -1
  14. package/dist/browser/cjs/utils/src/node.d.ts +2 -0
  15. package/dist/{esm/fe → browser/esm/browser}/index.js +0 -1
  16. package/dist/{esm/index_fe.js → browser/esm/browser.js} +12 -10
  17. package/dist/browser/esm/common/classs.js +12 -0
  18. package/dist/browser/esm/types/index.d.ts +27 -0
  19. package/dist/{cjs/fe → browser/esm/utils/src/browser}/index.d.ts +0 -1
  20. package/dist/browser/esm/utils/src/browser.d.ts +2 -0
  21. package/dist/browser/esm/utils/src/common/classs.d.ts +5 -0
  22. package/dist/browser/esm/utils/src/common/index.d.ts +11 -0
  23. package/dist/{esm/common/tools → browser/esm/utils/src/common}/other.d.ts +1 -1
  24. package/dist/{esm/rd → browser/esm/utils/src/node}/jsonFile/index.d.ts +1 -1
  25. package/dist/browser/esm/utils/src/node.d.ts +2 -0
  26. package/dist/node/cjs/common/classs.js +14 -0
  27. package/dist/node/cjs/common/dayjs.js +27 -0
  28. package/dist/node/cjs/common/number.js +34 -0
  29. package/dist/node/cjs/common/object.js +43 -0
  30. package/dist/node/cjs/common/other.js +112 -0
  31. package/dist/node/cjs/common/string.js +137 -0
  32. package/dist/{cjs/index_rd.js → node/cjs/node.js} +28 -8
  33. package/dist/node/cjs/types/index.d.ts +27 -0
  34. package/dist/node/cjs/utils/src/browser/element.d.ts +9 -0
  35. package/dist/node/cjs/utils/src/browser/index.d.ts +18 -0
  36. package/dist/node/cjs/utils/src/browser/other.d.ts +1 -0
  37. package/dist/node/cjs/utils/src/browser/style.d.ts +10 -0
  38. package/dist/node/cjs/utils/src/browser.d.ts +2 -0
  39. package/dist/node/cjs/utils/src/common/classs.d.ts +5 -0
  40. package/dist/node/cjs/utils/src/common/dayjs.d.ts +4 -0
  41. package/dist/node/cjs/utils/src/common/index.d.ts +11 -0
  42. package/dist/node/cjs/utils/src/common/number.d.ts +3 -0
  43. package/dist/node/cjs/utils/src/common/object.d.ts +10 -0
  44. package/dist/node/cjs/utils/src/common/other.d.ts +26 -0
  45. package/dist/node/cjs/utils/src/common/string.d.ts +16 -0
  46. package/dist/node/cjs/utils/src/node/database/Collection.d.ts +22 -0
  47. package/dist/node/cjs/utils/src/node/database/Database.d.ts +10 -0
  48. package/dist/node/cjs/utils/src/node/database/index.d.ts +2 -0
  49. package/dist/node/cjs/utils/src/node/database/types.d.ts +151 -0
  50. package/dist/node/cjs/utils/src/node/database/utils.d.ts +3 -0
  51. package/dist/node/cjs/utils/src/node/index.d.ts +3 -0
  52. package/dist/node/cjs/utils/src/node/jsonFile/index.d.ts +6 -0
  53. package/dist/node/cjs/utils/src/node/mail/index.d.ts +1 -0
  54. package/dist/node/cjs/utils/src/node.d.ts +2 -0
  55. package/dist/node/esm/common/classs.js +12 -0
  56. package/dist/node/esm/common/dayjs.js +18 -0
  57. package/dist/node/esm/common/number.js +30 -0
  58. package/dist/node/esm/common/object.js +39 -0
  59. package/dist/node/esm/common/other.js +106 -0
  60. package/dist/node/esm/common/string.js +120 -0
  61. package/dist/node/esm/node/database/Collection.js +200 -0
  62. package/dist/node/esm/node/database/Database.js +23 -0
  63. package/dist/node/esm/node/database/types.js +25 -0
  64. package/dist/node/esm/node/database/utils.js +27 -0
  65. package/dist/node/esm/node/jsonFile/index.js +27 -0
  66. package/dist/node/esm/node/mail/index.js +29 -0
  67. package/dist/node/esm/node.js +14 -0
  68. package/dist/node/esm/types/index.d.ts +27 -0
  69. package/dist/node/esm/utils/src/browser/element.d.ts +9 -0
  70. package/dist/node/esm/utils/src/browser/index.d.ts +18 -0
  71. package/dist/node/esm/utils/src/browser/other.d.ts +1 -0
  72. package/dist/node/esm/utils/src/browser/style.d.ts +10 -0
  73. package/dist/node/esm/utils/src/browser.d.ts +2 -0
  74. package/dist/node/esm/utils/src/common/classs.d.ts +5 -0
  75. package/dist/node/esm/utils/src/common/dayjs.d.ts +4 -0
  76. package/dist/node/esm/utils/src/common/index.d.ts +11 -0
  77. package/dist/node/esm/utils/src/common/number.d.ts +3 -0
  78. package/dist/node/esm/utils/src/common/object.d.ts +10 -0
  79. package/dist/node/esm/utils/src/common/other.d.ts +26 -0
  80. package/dist/node/esm/utils/src/common/string.d.ts +16 -0
  81. package/dist/node/esm/utils/src/node/database/Collection.d.ts +22 -0
  82. package/dist/node/esm/utils/src/node/database/Database.d.ts +10 -0
  83. package/dist/node/esm/utils/src/node/database/index.d.ts +2 -0
  84. package/dist/node/esm/utils/src/node/database/types.d.ts +151 -0
  85. package/dist/node/esm/utils/src/node/database/utils.d.ts +3 -0
  86. package/dist/node/esm/utils/src/node/index.d.ts +3 -0
  87. package/dist/node/esm/utils/src/node/jsonFile/index.d.ts +6 -0
  88. package/dist/node/esm/utils/src/node/mail/index.d.ts +1 -0
  89. package/dist/node/esm/utils/src/node.d.ts +2 -0
  90. package/package.json +23 -11
  91. package/dist/cjs/common/index.d.ts +0 -6
  92. package/dist/cjs/common/tools/index.d.ts +0 -4
  93. package/dist/cjs/common/types/index.d.ts +0 -15
  94. package/dist/cjs/index_all.d.ts +0 -3
  95. package/dist/cjs/index_fe.d.ts +0 -2
  96. package/dist/cjs/index_rd.d.ts +0 -2
  97. package/dist/esm/common/index.d.ts +0 -6
  98. package/dist/esm/common/tools/index.d.ts +0 -4
  99. package/dist/esm/common/types/index.d.ts +0 -15
  100. package/dist/esm/index_all.d.ts +0 -3
  101. package/dist/esm/index_fe.d.ts +0 -2
  102. package/dist/esm/index_rd.d.ts +0 -2
  103. /package/dist/{cjs/common/tools → browser/cjs/common}/number.js +0 -0
  104. /package/dist/{cjs/common/tools → browser/cjs/common}/object.js +0 -0
  105. /package/dist/{cjs/common/tools → browser/cjs/common}/other.js +0 -0
  106. /package/dist/{cjs/common/tools → browser/cjs/common}/string.js +0 -0
  107. /package/dist/{cjs/fe → browser/cjs/utils/src/browser}/element.d.ts +0 -0
  108. /package/dist/{cjs/fe → browser/cjs/utils/src/browser}/other.d.ts +0 -0
  109. /package/dist/{cjs/fe → browser/cjs/utils/src/browser}/style.d.ts +0 -0
  110. /package/dist/{cjs/fe → browser/cjs/utils/src/common}/dayjs.d.ts +0 -0
  111. /package/dist/{cjs/common/tools → browser/cjs/utils/src/common}/number.d.ts +0 -0
  112. /package/dist/{cjs/common/tools → browser/cjs/utils/src/common}/object.d.ts +0 -0
  113. /package/dist/{cjs/common/tools → browser/cjs/utils/src/common}/string.d.ts +0 -0
  114. /package/dist/{cjs/rd → browser/cjs/utils/src/node}/database/Collection.d.ts +0 -0
  115. /package/dist/{cjs/rd → browser/cjs/utils/src/node}/database/Database.d.ts +0 -0
  116. /package/dist/{cjs/rd → browser/cjs/utils/src/node}/database/index.d.ts +0 -0
  117. /package/dist/{cjs/rd → browser/cjs/utils/src/node}/database/types.d.ts +0 -0
  118. /package/dist/{cjs/rd → browser/cjs/utils/src/node}/database/utils.d.ts +0 -0
  119. /package/dist/{cjs/rd → browser/cjs/utils/src/node}/index.d.ts +0 -0
  120. /package/dist/{cjs/rd → browser/cjs/utils/src/node}/jsonFile/index.d.ts +0 -0
  121. /package/dist/{cjs/rd → browser/cjs/utils/src/node}/mail/index.d.ts +0 -0
  122. /package/dist/{esm/fe → browser/esm/browser}/element.js +0 -0
  123. /package/dist/{esm/fe → browser/esm/browser}/other.js +0 -0
  124. /package/dist/{esm/fe → browser/esm/browser}/style.js +0 -0
  125. /package/dist/{esm/fe → browser/esm/common}/dayjs.js +0 -0
  126. /package/dist/{esm/common/tools → browser/esm/common}/number.js +0 -0
  127. /package/dist/{esm/common/tools → browser/esm/common}/object.js +0 -0
  128. /package/dist/{esm/common/tools → browser/esm/common}/other.js +0 -0
  129. /package/dist/{esm/common/tools → browser/esm/common}/string.js +0 -0
  130. /package/dist/{esm/fe → browser/esm/utils/src/browser}/element.d.ts +0 -0
  131. /package/dist/{esm/fe → browser/esm/utils/src/browser}/other.d.ts +0 -0
  132. /package/dist/{esm/fe → browser/esm/utils/src/browser}/style.d.ts +0 -0
  133. /package/dist/{esm/fe → browser/esm/utils/src/common}/dayjs.d.ts +0 -0
  134. /package/dist/{esm/common/tools → browser/esm/utils/src/common}/number.d.ts +0 -0
  135. /package/dist/{esm/common/tools → browser/esm/utils/src/common}/object.d.ts +0 -0
  136. /package/dist/{esm/common/tools → browser/esm/utils/src/common}/string.d.ts +0 -0
  137. /package/dist/{esm/rd → browser/esm/utils/src/node}/database/Collection.d.ts +0 -0
  138. /package/dist/{esm/rd → browser/esm/utils/src/node}/database/Database.d.ts +0 -0
  139. /package/dist/{esm/rd → browser/esm/utils/src/node}/database/index.d.ts +0 -0
  140. /package/dist/{esm/rd → browser/esm/utils/src/node}/database/types.d.ts +0 -0
  141. /package/dist/{esm/rd → browser/esm/utils/src/node}/database/utils.d.ts +0 -0
  142. /package/dist/{esm/rd → browser/esm/utils/src/node}/index.d.ts +0 -0
  143. /package/dist/{esm/rd → browser/esm/utils/src/node}/mail/index.d.ts +0 -0
  144. /package/dist/{cjs/rd → node/cjs/node}/database/Collection.js +0 -0
  145. /package/dist/{cjs/rd → node/cjs/node}/database/Database.js +0 -0
  146. /package/dist/{cjs/rd → node/cjs/node}/database/types.js +0 -0
  147. /package/dist/{cjs/rd → node/cjs/node}/database/utils.js +0 -0
  148. /package/dist/{cjs/rd → node/cjs/node}/jsonFile/index.js +0 -0
  149. /package/dist/{cjs/rd → node/cjs/node}/mail/index.js +0 -0
@@ -0,0 +1,14 @@
1
+ export { default as _, cloneDeep, debounce, find, groupBy, isBoolean, isEmpty, isEqual, isError, isFunction, isNumber, isObject, isString, merge, noop, omit, pick, uniq, uniqBy, uniqWith } from 'lodash';
2
+ import * as consola from 'consola';
3
+ export { consola };
4
+ import './common/dayjs.js';
5
+ export * from 'zod';
6
+ export { amount, getChinese, getChineseByStr, getCookie, getLength, getProxyUrl, getRandomColor, getRandomString, getSliceStr, getStrLength, getType, isJson, jsonParse, replaceAll, replaceByRules, toString } from './common/string.js';
7
+ export { filterParams, findItem, watch } from './common/object.js';
8
+ export { delay, executePromise, handleParams, handleRes2List, locationFn } from './common/other.js';
9
+ export { getFileSize, getRandomNum, limitDecimals } from './common/number.js';
10
+ export { CustomError } from './common/classs.js';
11
+ export { Database } from './node/database/Database.js';
12
+ export { JsonFile } from './node/jsonFile/index.js';
13
+ export { sendMail } from './node/mail/index.js';
14
+ export { Dayjs, default as dayjs } from 'dayjs';
@@ -0,0 +1,27 @@
1
+ export interface RequestRes<D = any> {
2
+ success: boolean;
3
+ message: string;
4
+ data: D;
5
+ }
6
+ export type KeyValue<D extends object | string = string, V = any> = Partial<Record<D extends string ? string : keyof D, V>>;
7
+ export interface Pagination {
8
+ current?: number;
9
+ pageSize?: number;
10
+ }
11
+ export type SortParams<D extends object | string = string> = Record<D extends string ? string : keyof D, 'ascend' | 'descend'>;
12
+ export type OrderParams<D extends object | string = string> = {
13
+ field: D extends string ? string : keyof D;
14
+ type: 'asc' | 'desc';
15
+ };
16
+ export interface Option<V extends string | number = string> {
17
+ label: string;
18
+ value: V;
19
+ children?: Option<V>[];
20
+ }
21
+ export type OrderBy = {
22
+ [key: string]: 'asc' | 'desc';
23
+ } | {
24
+ [key: string]: 'asc' | 'desc';
25
+ }[];
26
+ export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
27
+ export type Set<T, OmitK extends keyof T = never, OptionalK extends Exclude<keyof T, OmitK> = never> = Optional<Omit<T, OmitK>, OptionalK>;
@@ -0,0 +1,9 @@
1
+ export declare const scrollIntoView: (el: Element, option?: ScrollIntoViewOptions) => void;
2
+ export declare const getElement: (el: string | Element) => {
3
+ element: null;
4
+ originalStyle: {};
5
+ } | {
6
+ element: Element;
7
+ originalStyle: CSSStyleDeclaration;
8
+ };
9
+ export declare const isElementInViewport: (el: string | Element) => boolean | undefined;
@@ -0,0 +1,18 @@
1
+ import md5 from 'md5';
2
+ import classnames from 'classnames';
3
+ import copy from 'copy-to-clipboard';
4
+ import anime from 'animejs';
5
+ export { copy, classnames, md5, anime };
6
+ export declare const localforage: {
7
+ config: {
8
+ (options: LocalForageOptions): boolean;
9
+ (options: string): any;
10
+ (): LocalForageOptions;
11
+ };
12
+ setItem: <T>(key: string, value: T, callback?: ((err: any, value: T) => void) | undefined) => Promise<T>;
13
+ getItem: <T_1>(key: string, callback?: ((err: any, value: T_1 | null) => void) | undefined) => Promise<T_1 | null>;
14
+ removeItem: (key: string, callback?: ((err: any) => void) | undefined) => Promise<void>;
15
+ };
16
+ export * from './style';
17
+ export * from './element';
18
+ export * from './other';
@@ -0,0 +1 @@
1
+ export declare const readClipboard: () => Promise<string>;
@@ -0,0 +1,10 @@
1
+ export declare const hexToRgba: (hexColor: string, a?: number) => {
2
+ nums: {
3
+ red: number;
4
+ green: number;
5
+ blue: number;
6
+ };
7
+ text: string;
8
+ };
9
+ export declare const flashBackground: (el: string | Element, color: string, a?: number) => void;
10
+ export declare const flashBorder: (el: string | Element, color: string, a?: number) => void;
@@ -0,0 +1,2 @@
1
+ export * from './common';
2
+ export * from './browser/index';
@@ -0,0 +1,5 @@
1
+ export declare class CustomError extends Error {
2
+ code?: number;
3
+ data?: any;
4
+ constructor(message: string, code?: number, data?: any);
5
+ }
@@ -0,0 +1,4 @@
1
+ import dayjs from 'dayjs';
2
+ import 'dayjs/locale/zh-cn';
3
+ export { Dayjs } from 'dayjs';
4
+ export default dayjs;
@@ -0,0 +1,11 @@
1
+ import { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy, noop } from 'lodash';
2
+ export { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy, noop, };
3
+ export * as consola from 'consola';
4
+ export { default as dayjs, Dayjs } from './dayjs';
5
+ export * from 'zod';
6
+ export * from './string';
7
+ export * from './object';
8
+ export * from './other';
9
+ export * from './number';
10
+ export * from './classs';
11
+ export { default as _ } from 'lodash';
@@ -0,0 +1,3 @@
1
+ export declare const getRandomNum: (min: number, max: number) => number;
2
+ export declare const limitDecimals: (v: string, num: number | undefined, isForce: boolean) => string;
3
+ export declare const getFileSize: (size: number) => string;
@@ -0,0 +1,10 @@
1
+ export declare const findItem: <I>(list: I[], attr: keyof I, value?: I[keyof I] | undefined) => I | undefined;
2
+ export declare const filterParams: (params: {
3
+ [key: string]: any;
4
+ }) => {};
5
+ export declare const watch: {
6
+ observe(obj: {
7
+ [key: string]: any;
8
+ }, key: string, watchFun: (value: any, val: any) => undefined): void;
9
+ setWatcher(data?: {}, watch?: {}): void;
10
+ };
@@ -0,0 +1,26 @@
1
+ import { KeyValue, OrderParams, Pagination, SortParams } from '@wzyjs/types';
2
+ export declare const handleParams: (params?: Pagination & KeyValue, sort?: SortParams) => {
3
+ page: {
4
+ size?: number | undefined;
5
+ current?: number | undefined;
6
+ };
7
+ where: KeyValue<string, string | number | boolean | RegExp>;
8
+ order?: OrderParams<string> | undefined;
9
+ };
10
+ export declare const handleRes2List: <D>(reqPromise: any) => Promise<{
11
+ label: string;
12
+ value: string;
13
+ }[]>;
14
+ export declare const executePromise: (promise: Promise<any>) => Promise<{
15
+ result: any;
16
+ time: number;
17
+ }>;
18
+ export declare const locationFn: {
19
+ url2Params: (url?: string) => {};
20
+ params2Url: (params: {
21
+ [key: string]: any;
22
+ }) => string;
23
+ setUrlParams: (key: string, value: any, keepName: string) => void;
24
+ urlGetPath: (url?: string) => string;
25
+ };
26
+ export declare const delay: (time?: number) => Promise<unknown>;
@@ -0,0 +1,16 @@
1
+ export declare const getChineseByStr: (str: string) => string;
2
+ export declare const getStrLength: (value: string) => number;
3
+ export declare const replaceAll: (str: string, searchValue: string, replaceValue: string) => string;
4
+ export declare const replaceByRules: (str: string, rules: [string, string][]) => string;
5
+ export declare const getType: (value: any) => string;
6
+ export declare const amount: (str: string) => string;
7
+ export declare const jsonParse: (value: string | object) => object;
8
+ export declare const isJson: (str: string) => boolean;
9
+ export declare const toString: (value: any) => string;
10
+ export declare const getRandomColor: () => string;
11
+ export declare const getRandomString: (length?: number) => string;
12
+ export declare const getChinese: (str: string) => string;
13
+ export declare const getSliceStr: (str: string, before: string, after: string) => string;
14
+ export declare const getProxyUrl: (url: string) => string;
15
+ export declare const getLength: (value: string) => number;
16
+ export declare const getCookie: (name: string) => string | null;
@@ -0,0 +1,22 @@
1
+ import { Database, IKeyValue } from '@cloudbase/node-sdk';
2
+ import { Add, Conditions, Count, Delete, Find, FindList, IdConditions, MethodParams, Update, WhereConditions } from './types';
3
+ export declare class Collection<D extends IKeyValue> {
4
+ private readonly db;
5
+ private readonly collection;
6
+ constructor(db: Database.Db, name: string);
7
+ private joinConditions;
8
+ private request;
9
+ private handleRes;
10
+ private handleData;
11
+ handleConditions(params: MethodParams<D>): MethodParams<D>;
12
+ private exec;
13
+ add(data: Add.Params<D>['data']): Promise<Add.Res>;
14
+ add(data: Add.Params<D>['data'], isReturn: true, conditions?: Pick<IdConditions, 'field'>): Promise<Find.Res<D>>;
15
+ delete(conditions: Conditions): Promise<Delete.Res>;
16
+ update(conditions: Conditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
17
+ update(conditions: IdConditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
18
+ update(conditions: IdConditions, data: Update.Params<D>['data'], isReturn: true, isSet?: true): Promise<Find.Res<D>>;
19
+ find(conditions?: Conditions): Promise<Find.Res<D>>;
20
+ findList(conditions?: WhereConditions): Promise<FindList.Res<D>>;
21
+ count(conditions: Conditions): Promise<Count.Res>;
22
+ }
@@ -0,0 +1,10 @@
1
+ import tcb, { IKeyValue } from '@cloudbase/node-sdk';
2
+ import { Config } from './types';
3
+ import { Collection } from './Collection';
4
+ export declare class Database {
5
+ private readonly db;
6
+ private readonly instance;
7
+ constructor(config: Config);
8
+ collection<D extends IKeyValue>(name: string): Collection<D>;
9
+ createCollection(name: string): tcb.IBaseRes;
10
+ }
@@ -0,0 +1,2 @@
1
+ export { Database } from './Database';
2
+ export { Conditions, IdConditions, WhereConditions, Record } from './types';
@@ -0,0 +1,151 @@
1
+ import { Database, ICountRes } from '@cloudbase/node-sdk';
2
+ export interface Config {
3
+ env: string;
4
+ secretId: string;
5
+ secretKey: string;
6
+ }
7
+ export type IdConditions = {
8
+ _id: string;
9
+ field?: string[] | {
10
+ [key: string]: false;
11
+ };
12
+ options?: {
13
+ timeout: number;
14
+ multiple?: false;
15
+ };
16
+ };
17
+ export declare enum Command {
18
+ Eq = "eq",
19
+ Neq = "neq",
20
+ Lt = "lt",
21
+ Lte = "lte",
22
+ Gt = "gt",
23
+ Gte = "gte",
24
+ In = "in",
25
+ Nin = "nin",
26
+ Gtlt = "gtlt"
27
+ }
28
+ export type CommandWhere = {
29
+ type: Command.Eq;
30
+ value: any;
31
+ } | {
32
+ type: Command.Neq;
33
+ value: any;
34
+ } | {
35
+ type: Command.Gt;
36
+ value: number;
37
+ } | {
38
+ type: Command.Gte;
39
+ value: number;
40
+ } | {
41
+ type: Command.Lt;
42
+ value: number;
43
+ } | {
44
+ type: Command.Lte;
45
+ value: number;
46
+ } | {
47
+ type: Command.Gtlt;
48
+ value: number[];
49
+ } | {
50
+ type: Command.In;
51
+ value: any[];
52
+ } | {
53
+ type: Command.Nin;
54
+ value: any[];
55
+ };
56
+ export type WhereConditions = {
57
+ where?: {
58
+ [key: string]: any | CommandWhere;
59
+ };
60
+ field?: string[] | {
61
+ [key: string]: false;
62
+ };
63
+ page?: {
64
+ size?: number;
65
+ current?: number;
66
+ };
67
+ order?: {
68
+ field: string;
69
+ type?: 'asc' | 'desc';
70
+ };
71
+ options?: {
72
+ timeout?: number;
73
+ multiple?: boolean;
74
+ };
75
+ };
76
+ export type Conditions = IdConditions | WhereConditions;
77
+ export declare enum Method {
78
+ Add = "add",
79
+ Find = "find",
80
+ FindList = "findList",
81
+ Delete = "delete",
82
+ Update = "update",
83
+ Count = "count"
84
+ }
85
+ export declare namespace Add {
86
+ type Params<D> = {
87
+ method: Method.Add;
88
+ data: D;
89
+ conditions?: Pick<IdConditions, 'field'>;
90
+ isReturn?: true;
91
+ };
92
+ type Res = {
93
+ id: string;
94
+ };
95
+ }
96
+ export declare namespace Find {
97
+ type Params = {
98
+ method: Method.Find;
99
+ conditions?: Conditions;
100
+ };
101
+ type Res<D> = Record<D> | undefined;
102
+ }
103
+ export declare namespace FindList {
104
+ type Params = {
105
+ method: Method.FindList;
106
+ conditions?: WhereConditions;
107
+ };
108
+ type Res<D> = {
109
+ list?: Record<D>[];
110
+ total?: number;
111
+ };
112
+ }
113
+ export declare namespace Delete {
114
+ type Params = {
115
+ method: Method.Delete;
116
+ conditions: Conditions;
117
+ };
118
+ type Res = {
119
+ deleted: number | string;
120
+ };
121
+ }
122
+ export declare namespace Update {
123
+ type Params<D> = {
124
+ method: Method.Update;
125
+ conditions: Conditions;
126
+ data: Partial<Record<D>>;
127
+ isReturn?: true;
128
+ isSet?: true;
129
+ };
130
+ type Res<D> = {
131
+ updated?: number;
132
+ doc?: D;
133
+ };
134
+ }
135
+ export declare namespace Count {
136
+ type Params = {
137
+ method: Method.Count;
138
+ conditions?: WhereConditions;
139
+ };
140
+ type Res = {
141
+ total?: number;
142
+ };
143
+ }
144
+ export type MethodParams<D> = Add.Params<D> | Find.Params | FindList.Params | Delete.Params | Update.Params<D> | Count.Params;
145
+ export type MethodRes<D> = Add.Res | Find.Res<D> | FindList.Res<D> | Delete.Res | Update.Res<D> | Count.Res;
146
+ export type IRes = Database.IAddRes | Database.IGetRes | Database.IDeleteResult | Database.IUpdateResult | ICountRes;
147
+ export type Record<D> = D & {
148
+ _id: string;
149
+ createAt: number;
150
+ updateAt: number;
151
+ };
@@ -0,0 +1,3 @@
1
+ import { Conditions } from './types';
2
+ export declare const appendTime: <D>(data: D, type: 'create' | 'update') => D;
3
+ export declare const defaultConditions: Conditions;
@@ -0,0 +1,3 @@
1
+ export * from './database';
2
+ export * from './jsonFile';
3
+ export * from './mail';
@@ -0,0 +1,6 @@
1
+ export declare class JsonFile {
2
+ filePath: string;
3
+ constructor(filePath: string);
4
+ get(key: string): Promise<unknown>;
5
+ set(key: string, value: any): void;
6
+ }
@@ -0,0 +1 @@
1
+ export declare const sendMail: (toEmail: string, title: string, content?: string) => Promise<string>;
@@ -0,0 +1,2 @@
1
+ export * from './common';
2
+ export * from './node/index';
package/package.json CHANGED
@@ -1,18 +1,28 @@
1
1
  {
2
2
  "name": "@wzyjs/utils",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "description",
5
5
  "author": "wzy",
6
6
  "license": "ISC",
7
- "main": "dist/cjs/index_rd.js",
8
- "module": "dist/esm/index_fe.js",
9
- "typings": "dist/esm/index_all.d.ts",
10
7
  "exports": {
11
8
  ".": {
12
- "import": "./dist/esm/index_fe.js",
13
- "require": "./dist/cjs/index_rd.js"
9
+ "import": "./dist/browser/esm/browser.js",
10
+ "require": "./dist/browser/cjs/browser.js"
14
11
  },
15
- "./package.json": "./package.json"
12
+ "./node": {
13
+ "import": "./dist/node/esm/node.js",
14
+ "require": "./dist/node/cjs/node.js"
15
+ }
16
+ },
17
+ "typesVersions": {
18
+ "*": {
19
+ "*": [
20
+ "./dist/browser/esm/utils/src/browser.d.ts"
21
+ ],
22
+ "node": [
23
+ "./dist/node/esm/utils/src/node.d.ts"
24
+ ]
25
+ }
16
26
  },
17
27
  "scripts": {
18
28
  "dev": "rollup -c -w --bundleConfigAsCjs",
@@ -23,8 +33,6 @@
23
33
  ],
24
34
  "dependencies": {
25
35
  "@cloudbase/node-sdk": "^2.9.1",
26
- "@types/animejs": "^3.1.6",
27
- "@types/nodemailer": "^6.4.7",
28
36
  "animejs": "^3.2.1",
29
37
  "classnames": "^2.3.2",
30
38
  "consola": "^2.15.3",
@@ -34,14 +42,18 @@
34
42
  "lodash": "^4.17.21",
35
43
  "md5": "^2.3.0",
36
44
  "nodemailer": "^6.9.1",
37
- "tslib": "^2.4.1"
45
+ "tslib": "^2.4.1",
46
+ "zod": "^3.21.4"
38
47
  },
39
48
  "devDependencies": {
40
49
  "@rollup/plugin-commonjs": "^23.0.3",
41
50
  "@rollup/plugin-node-resolve": "^15.0.1",
51
+ "@types/animejs": "^3.1.6",
42
52
  "@types/lodash": "^4.14.189",
43
53
  "@types/md5": "^2.3.2",
44
54
  "@types/node": "^18.11.11",
55
+ "@types/nodemailer": "^6.4.7",
56
+ "@wzyjs/types": "^0.0.28",
45
57
  "rollup": "^3.6.0",
46
58
  "rollup-plugin-typescript2": "^0.34.1",
47
59
  "typescript": "^4.9.3"
@@ -53,5 +65,5 @@
53
65
  "type": "git",
54
66
  "url": "https://gitee.com/wang-zhenyu/app.git"
55
67
  },
56
- "gitHead": "df22fdc32eef4bfe3a8920a1c3d048f5713bda8e"
68
+ "gitHead": "b27e8d285e4092485cd1be538c1f571bc29e7835"
57
69
  }
@@ -1,6 +0,0 @@
1
- import { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy } from 'lodash';
2
- export { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy };
3
- export * as consola from 'consola';
4
- export * from './tools';
5
- export * from './types';
6
- export { default as lodash } from 'lodash';
@@ -1,4 +0,0 @@
1
- export * from './string';
2
- export * from './object';
3
- export * from './other';
4
- export * from './number';
@@ -1,15 +0,0 @@
1
- export interface RequestRes<D = any> {
2
- success?: boolean;
3
- message?: string;
4
- data?: D;
5
- }
6
- export type KeyValue<D extends object | string = string, V = any> = Partial<Record<D extends string ? string : keyof D, V>>;
7
- export interface Pagination {
8
- current?: number;
9
- pageSize?: number;
10
- }
11
- export type SortParams<D extends object | string = string> = Record<D extends string ? string : keyof D, 'ascend' | 'descend'>;
12
- export type OrderParams<D extends object | string = string> = {
13
- field: D extends string ? string : keyof D;
14
- type: 'asc' | 'desc';
15
- };
@@ -1,3 +0,0 @@
1
- export * from './common';
2
- export * from './fe';
3
- export * from './rd';
@@ -1,2 +0,0 @@
1
- export * from './common';
2
- export * from './fe';
@@ -1,2 +0,0 @@
1
- export * from './common';
2
- export * from './rd';
@@ -1,6 +0,0 @@
1
- import { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy } from 'lodash';
2
- export { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy };
3
- export * as consola from 'consola';
4
- export * from './tools';
5
- export * from './types';
6
- export { default as lodash } from 'lodash';
@@ -1,4 +0,0 @@
1
- export * from './string';
2
- export * from './object';
3
- export * from './other';
4
- export * from './number';
@@ -1,15 +0,0 @@
1
- export interface RequestRes<D = any> {
2
- success?: boolean;
3
- message?: string;
4
- data?: D;
5
- }
6
- export type KeyValue<D extends object | string = string, V = any> = Partial<Record<D extends string ? string : keyof D, V>>;
7
- export interface Pagination {
8
- current?: number;
9
- pageSize?: number;
10
- }
11
- export type SortParams<D extends object | string = string> = Record<D extends string ? string : keyof D, 'ascend' | 'descend'>;
12
- export type OrderParams<D extends object | string = string> = {
13
- field: D extends string ? string : keyof D;
14
- type: 'asc' | 'desc';
15
- };
@@ -1,3 +0,0 @@
1
- export * from './common';
2
- export * from './fe';
3
- export * from './rd';
@@ -1,2 +0,0 @@
1
- export * from './common';
2
- export * from './fe';
@@ -1,2 +0,0 @@
1
- export * from './common';
2
- export * from './rd';
File without changes
File without changes
File without changes
File without changes