@wzyjs/types 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 (76) hide show
  1. package/dist/cjs/common/index.d.ts +6 -0
  2. package/dist/cjs/common/tools/index.d.ts +4 -0
  3. package/dist/cjs/common/tools/number.d.ts +3 -0
  4. package/dist/cjs/common/tools/number.js +34 -0
  5. package/dist/cjs/common/tools/object.d.ts +10 -0
  6. package/dist/cjs/common/tools/object.js +43 -0
  7. package/dist/cjs/common/tools/other.d.ts +26 -0
  8. package/dist/cjs/common/tools/other.js +112 -0
  9. package/dist/cjs/common/tools/string.d.ts +16 -0
  10. package/dist/cjs/common/tools/string.js +137 -0
  11. package/dist/cjs/common/types/index.d.ts +20 -0
  12. package/dist/cjs/fe/dayjs.d.ts +4 -0
  13. package/dist/cjs/fe/element.d.ts +9 -0
  14. package/dist/cjs/fe/index.d.ts +20 -0
  15. package/dist/cjs/fe/middlewares/error.d.ts +3 -0
  16. package/dist/cjs/fe/middlewares/index.d.ts +1 -0
  17. package/dist/cjs/fe/other.d.ts +1 -0
  18. package/dist/cjs/fe/style.d.ts +10 -0
  19. package/dist/cjs/index_all.d.ts +3 -0
  20. package/dist/cjs/index_fe.d.ts +2 -0
  21. package/dist/cjs/index_rd.d.ts +2 -0
  22. package/dist/cjs/index_rd.js +141 -0
  23. package/dist/cjs/rd/database/Collection.d.ts +22 -0
  24. package/dist/cjs/rd/database/Collection.js +202 -0
  25. package/dist/cjs/rd/database/Database.d.ts +10 -0
  26. package/dist/cjs/rd/database/Database.js +25 -0
  27. package/dist/cjs/rd/database/index.d.ts +2 -0
  28. package/dist/cjs/rd/database/types.d.ts +151 -0
  29. package/dist/cjs/rd/database/types.js +25 -0
  30. package/dist/cjs/rd/database/utils.d.ts +3 -0
  31. package/dist/cjs/rd/database/utils.js +30 -0
  32. package/dist/cjs/rd/index.d.ts +3 -0
  33. package/dist/cjs/rd/jsonFile/index.d.ts +6 -0
  34. package/dist/cjs/rd/jsonFile/index.js +29 -0
  35. package/dist/cjs/rd/mail/index.d.ts +1 -0
  36. package/dist/cjs/rd/mail/index.js +31 -0
  37. package/dist/cjs/rd/middlewares/index.d.ts +1 -0
  38. package/dist/cjs/rd/middlewares/logger.d.ts +1 -0
  39. package/dist/esm/common/index.d.ts +6 -0
  40. package/dist/esm/common/tools/index.d.ts +4 -0
  41. package/dist/esm/common/tools/number.d.ts +3 -0
  42. package/dist/esm/common/tools/number.js +30 -0
  43. package/dist/esm/common/tools/object.d.ts +10 -0
  44. package/dist/esm/common/tools/object.js +39 -0
  45. package/dist/esm/common/tools/other.d.ts +26 -0
  46. package/dist/esm/common/tools/other.js +106 -0
  47. package/dist/esm/common/tools/string.d.ts +16 -0
  48. package/dist/esm/common/tools/string.js +120 -0
  49. package/dist/esm/common/types/index.d.ts +20 -0
  50. package/dist/esm/fe/dayjs.d.ts +4 -0
  51. package/dist/esm/fe/dayjs.js +18 -0
  52. package/dist/esm/fe/element.d.ts +9 -0
  53. package/dist/esm/fe/element.js +36 -0
  54. package/dist/esm/fe/index.d.ts +20 -0
  55. package/dist/esm/fe/index.js +16 -0
  56. package/dist/esm/fe/middlewares/error.d.ts +3 -0
  57. package/dist/esm/fe/middlewares/error.js +22 -0
  58. package/dist/esm/fe/middlewares/index.d.ts +1 -0
  59. package/dist/esm/fe/other.d.ts +1 -0
  60. package/dist/esm/fe/other.js +10 -0
  61. package/dist/esm/fe/style.d.ts +10 -0
  62. package/dist/esm/fe/style.js +45 -0
  63. package/dist/esm/index_all.d.ts +3 -0
  64. package/dist/esm/index_fe.d.ts +2 -0
  65. package/dist/esm/index_fe.js +19 -0
  66. package/dist/esm/index_rd.d.ts +2 -0
  67. package/dist/esm/rd/database/Collection.d.ts +22 -0
  68. package/dist/esm/rd/database/Database.d.ts +10 -0
  69. package/dist/esm/rd/database/index.d.ts +2 -0
  70. package/dist/esm/rd/database/types.d.ts +151 -0
  71. package/dist/esm/rd/database/utils.d.ts +3 -0
  72. package/dist/esm/rd/index.d.ts +3 -0
  73. package/dist/esm/rd/jsonFile/index.d.ts +6 -0
  74. package/dist/esm/rd/mail/index.d.ts +1 -0
  75. package/index.ts +40 -0
  76. package/package.json +16 -0
@@ -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>;
package/index.ts ADDED
@@ -0,0 +1,40 @@
1
+ // 接口响应的类型
2
+ export interface RequestRes<D = any> {
3
+ success: boolean,
4
+ message: string,
5
+ data: D,
6
+ }
7
+
8
+ // 键值对的类型
9
+ export type KeyValue<D extends object | string = string, V = any> = Partial<Record<D extends string ? string : keyof D, V>>
10
+
11
+ // 分页的类型
12
+ export interface Pagination {
13
+ current?: number,
14
+ pageSize?: number,
15
+ }
16
+
17
+ // 前端排序参数的类型
18
+ export type SortParams<D extends object | string = string> = Record<D extends string ? string : keyof D, 'ascend' | 'descend'>
19
+
20
+ // 后端排序参数的类型
21
+ export type OrderParams<D extends object | string = string> = {
22
+ field: D extends string ? string : keyof D,
23
+ type: 'asc' | 'desc'
24
+ }
25
+
26
+ // 选项
27
+ export interface Option<V extends string | number = string> {
28
+ label: string,
29
+ value: V,
30
+ children?: Option<V>[],
31
+ }
32
+
33
+ // 排序参数的类型
34
+ export type OrderBy = { [key: string]: 'asc' | 'desc' } | { [key: string]: 'asc' | 'desc' }[]
35
+
36
+ // 将指定 key 设为可选
37
+ export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
38
+
39
+ // 将指定类型排除、将指定类型设为可选
40
+ export type Set<T, OmitK extends keyof T = never, OptionalK extends Exclude<keyof T, OmitK> = never> = Optional<Omit<T, OmitK>, OptionalK>
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@wzyjs/types",
3
+ "version": "0.0.28",
4
+ "description": "description",
5
+ "author": "wzy",
6
+ "license": "ISC",
7
+ "typings": "index.ts",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://gitee.com/wang-zhenyu/app.git"
14
+ },
15
+ "gitHead": "b27e8d285e4092485cd1be538c1f571bc29e7835"
16
+ }