dce-reactkit 3.4.0-beta.8 → 3.4.0
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.
- package/.eslintrc.js +0 -2
- package/dist/cjs/index.js +190 -36371
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/abbreviate.test.d.ts +5 -0
- package/dist/cjs/types/helpers/avg.test.d.ts +5 -0
- package/dist/cjs/types/helpers/canReviewLogs.d.ts +5 -0
- package/dist/cjs/types/helpers/canReviewLogs.test.d.ts +5 -0
- package/dist/cjs/types/helpers/ceilToNumDecimals.test.d.ts +5 -0
- package/dist/cjs/types/helpers/compareArraysByProp.test.d.ts +5 -0
- package/dist/cjs/types/helpers/extractProp.test.d.ts +5 -0
- package/dist/cjs/types/helpers/floorToNumDecimals.test.d.ts +5 -0
- package/dist/cjs/types/helpers/forceNumIntoBounds.test.d.ts +5 -0
- package/dist/cjs/types/helpers/genCSV.test.d.ts +5 -0
- package/dist/cjs/types/helpers/genCommaList.d.ts +12 -0
- package/dist/cjs/types/helpers/genCommaList.test.d.ts +1 -0
- package/dist/cjs/types/helpers/getHumanReadableDate.test.d.ts +5 -0
- package/dist/cjs/types/helpers/getLocalTimeInfo.test.d.ts +6 -0
- package/dist/cjs/types/helpers/getMonthName.test.d.ts +5 -0
- package/dist/cjs/types/helpers/getOrdinal.test.d.ts +5 -0
- package/dist/cjs/types/helpers/getPartOfDay.test.d.ts +5 -0
- package/dist/cjs/types/helpers/getTimeInfoInET.test.d.ts +5 -0
- package/dist/cjs/types/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +10 -0
- package/dist/cjs/types/helpers/validators/shared/helpers/validateRegex.d.ts +19 -0
- package/dist/cjs/types/helpers/validators/shared/types/ValidationResult.d.ts +12 -0
- package/dist/cjs/types/helpers/validators/validateEmail.d.ts +11 -0
- package/dist/cjs/types/helpers/validators/validateEmail.test.d.ts +1 -0
- package/dist/cjs/types/helpers/validators/validatePhoneNumber.d.ts +11 -0
- package/dist/cjs/types/helpers/validators/validatePhoneNumber.test.d.ts +1 -0
- package/dist/cjs/types/helpers/validators/validateString.d.ts +22 -0
- package/dist/cjs/types/helpers/validators/validateString.test.d.ts +1 -0
- package/dist/cjs/types/index.d.ts +1 -6
- package/dist/esm/index.js +419 -36579
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/abbreviate.test.d.ts +5 -0
- package/dist/esm/types/helpers/avg.test.d.ts +5 -0
- package/dist/esm/types/helpers/canReviewLogs.d.ts +5 -0
- package/dist/esm/types/helpers/canReviewLogs.test.d.ts +5 -0
- package/dist/esm/types/helpers/ceilToNumDecimals.test.d.ts +5 -0
- package/dist/esm/types/helpers/compareArraysByProp.test.d.ts +5 -0
- package/dist/esm/types/helpers/extractProp.test.d.ts +5 -0
- package/dist/esm/types/helpers/floorToNumDecimals.test.d.ts +5 -0
- package/dist/esm/types/helpers/forceNumIntoBounds.test.d.ts +5 -0
- package/dist/esm/types/helpers/genCSV.test.d.ts +5 -0
- package/dist/esm/types/helpers/genCommaList.d.ts +12 -0
- package/dist/esm/types/helpers/genCommaList.test.d.ts +1 -0
- package/dist/esm/types/helpers/getHumanReadableDate.test.d.ts +5 -0
- package/dist/esm/types/helpers/getLocalTimeInfo.test.d.ts +6 -0
- package/dist/esm/types/helpers/getMonthName.test.d.ts +5 -0
- package/dist/esm/types/helpers/getOrdinal.test.d.ts +5 -0
- package/dist/esm/types/helpers/getPartOfDay.test.d.ts +5 -0
- package/dist/esm/types/helpers/getTimeInfoInET.test.d.ts +5 -0
- package/dist/esm/types/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +10 -0
- package/dist/esm/types/helpers/validators/shared/helpers/validateRegex.d.ts +19 -0
- package/dist/esm/types/helpers/validators/shared/types/ValidationResult.d.ts +12 -0
- package/dist/esm/types/helpers/validators/validateEmail.d.ts +11 -0
- package/dist/esm/types/helpers/validators/validateEmail.test.d.ts +1 -0
- package/dist/esm/types/helpers/validators/validatePhoneNumber.d.ts +11 -0
- package/dist/esm/types/helpers/validators/validatePhoneNumber.test.d.ts +1 -0
- package/dist/esm/types/helpers/validators/validateString.d.ts +22 -0
- package/dist/esm/types/helpers/validators/validateString.test.d.ts +1 -0
- package/dist/esm/types/index.d.ts +1 -6
- package/dist/index.d.ts +35 -166
- package/package.json +13 -17
- package/src/client/initClient.tsx +20 -12
- package/src/components/AppWrapper.tsx +1 -1
- package/src/components/ItemPicker/index.test.tsx +10 -10
- package/src/helpers/abbreviate.test.ts +26 -0
- package/src/helpers/avg.test.ts +24 -0
- package/src/helpers/canReviewLogs.test.ts +67 -0
- package/src/helpers/canReviewLogs.ts +20 -0
- package/src/helpers/ceilToNumDecimals.test.ts +39 -0
- package/src/helpers/compareArraysByProp.test.ts +102 -0
- package/src/helpers/extractProp.test.ts +34 -0
- package/src/helpers/floorToNumDecimals.test.ts +39 -0
- package/src/helpers/forceNumIntoBounds.test.ts +34 -0
- package/src/helpers/genCSV.test.ts +61 -0
- package/src/helpers/genCSV.ts +5 -2
- package/src/helpers/genCommaList.test.ts +57 -0
- package/src/helpers/genCommaList.ts +21 -0
- package/src/helpers/getHumanReadableDate.test.ts +29 -0
- package/src/helpers/getLocalTimeInfo.test.ts +48 -0
- package/src/helpers/getMonthName.test.ts +79 -0
- package/src/helpers/getOrdinal.test.ts +84 -0
- package/src/helpers/{getOrdinal.tsx → getOrdinal.ts} +1 -0
- package/src/helpers/getPartOfDay.test.ts +56 -0
- package/src/helpers/getTimeInfoInET.test.ts +72 -0
- package/src/helpers/validators/shared/constants/ERROR_MESSAGES.ts +18 -0
- package/src/helpers/validators/shared/helpers/validateRegex.ts +47 -0
- package/src/helpers/validators/shared/types/ValidationResult.ts +20 -0
- package/src/helpers/validators/validateEmail.test.ts +110 -0
- package/src/helpers/validators/validateEmail.ts +47 -0
- package/src/helpers/validators/validatePhoneNumber.test.ts +94 -0
- package/src/helpers/validators/validatePhoneNumber.ts +49 -0
- package/src/helpers/validators/validateString.test.ts +175 -0
- package/src/helpers/validators/validateString.ts +171 -0
- package/src/index.ts +10 -12
- package/tsconfig.json +6 -2
- package/dist/cjs/types/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.d.ts +0 -10
- package/dist/cjs/types/components/DBEntryManagerPanel/AddOrEditDBEntry/index.d.ts +0 -34
- package/dist/cjs/types/components/DBEntryManagerPanel/helpers/generateEndpointPath.d.ts +0 -9
- package/dist/cjs/types/components/DBEntryManagerPanel/index.d.ts +0 -25
- package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntry.d.ts +0 -8
- package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntryField.d.ts +0 -49
- package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntryFieldType.d.ts +0 -12
- package/dist/cjs/types/helpers/addDBEditorEndpoints.d.ts +0 -40
- package/dist/esm/types/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.d.ts +0 -10
- package/dist/esm/types/components/DBEntryManagerPanel/AddOrEditDBEntry/index.d.ts +0 -34
- package/dist/esm/types/components/DBEntryManagerPanel/helpers/generateEndpointPath.d.ts +0 -9
- package/dist/esm/types/components/DBEntryManagerPanel/index.d.ts +0 -25
- package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntry.d.ts +0 -8
- package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntryField.d.ts +0 -49
- package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntryFieldType.d.ts +0 -12
- package/dist/esm/types/helpers/addDBEditorEndpoints.d.ts +0 -40
- package/src/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.tsx +0 -286
- package/src/components/DBEntryManagerPanel/AddOrEditDBEntry/index.tsx +0 -722
- package/src/components/DBEntryManagerPanel/helpers/generateEndpointPath.ts +0 -15
- package/src/components/DBEntryManagerPanel/index.tsx +0 -511
- package/src/components/DBEntryManagerPanel/types/DBEntry.ts +0 -7
- package/src/components/DBEntryManagerPanel/types/DBEntryField.ts +0 -94
- package/src/components/DBEntryManagerPanel/types/DBEntryFieldType.ts +0 -18
- package/src/helpers/addDBEditorEndpoints.ts +0 -124
- /package/src/helpers/{abbreviate.tsx → abbreviate.ts} +0 -0
- /package/src/helpers/{avg.tsx → avg.ts} +0 -0
- /package/src/helpers/{ceilToNumDecimals.tsx → ceilToNumDecimals.ts} +0 -0
- /package/src/helpers/{floorToNumDecimals.tsx → floorToNumDecimals.ts} +0 -0
- /package/src/helpers/{forceNumIntoBounds.tsx → forceNumIntoBounds.ts} +0 -0
- /package/src/helpers/{getLocalTimeInfo.tsx → getLocalTimeInfo.ts} +0 -0
- /package/src/helpers/{getTimeInfoInET.tsx → getTimeInfoInET.ts} +0 -0
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
|
|
3
|
-
// Import shared helpers
|
|
4
|
-
import genRouteHandler from './genRouteHandler';
|
|
5
|
-
import generateEndpointPath from '../components/DBEntryManagerPanel/helpers/generateEndpointPath';
|
|
6
|
-
|
|
7
|
-
// Import shared types
|
|
8
|
-
import ParamType from '../types/ParamType';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Interface for a collection in the database
|
|
12
|
-
* @author Yuen Ler Chow
|
|
13
|
-
*/
|
|
14
|
-
interface Collection {
|
|
15
|
-
/**
|
|
16
|
-
* Find all items in the collection that match the filter query
|
|
17
|
-
* @param filterQuery
|
|
18
|
-
* @returns list of items that match the filter query
|
|
19
|
-
*/
|
|
20
|
-
find: (filterQuery: any) => Promise<any[]>,
|
|
21
|
-
/**
|
|
22
|
-
* Insert an item into the collection
|
|
23
|
-
* @param item the item to insert
|
|
24
|
-
*/
|
|
25
|
-
insert: (item: any) => Promise<void>,
|
|
26
|
-
/**
|
|
27
|
-
* Delete an item in the collection
|
|
28
|
-
* @param id the id of the item to delete
|
|
29
|
-
*/
|
|
30
|
-
delete: (filterQuery: { id: string }) => Promise<void>,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Add all routes for the DBEditor
|
|
35
|
-
* @author Yuen Ler Chow
|
|
36
|
-
* @param opts object containing all arguments
|
|
37
|
-
* @param opts.app express app to add routes too
|
|
38
|
-
* @param opts.collectionName the name of the collection
|
|
39
|
-
* @param opts.adminsOnly true if the endpoint is for admins only
|
|
40
|
-
*/
|
|
41
|
-
const addDBEditorEndpoints = (opts: {
|
|
42
|
-
app: express.Application,
|
|
43
|
-
collectionName: string,
|
|
44
|
-
adminsOnly: boolean,
|
|
45
|
-
collection: Collection
|
|
46
|
-
},
|
|
47
|
-
) => {
|
|
48
|
-
const {
|
|
49
|
-
app,
|
|
50
|
-
collectionName,
|
|
51
|
-
adminsOnly,
|
|
52
|
-
collection,
|
|
53
|
-
} = opts;
|
|
54
|
-
|
|
55
|
-
const endpointPath = generateEndpointPath(collectionName, adminsOnly);
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* List all items in the collection
|
|
59
|
-
* @author Yuen Ler Chow
|
|
60
|
-
* @returns {any[]} the list of items in the collection
|
|
61
|
-
*/
|
|
62
|
-
app.get(
|
|
63
|
-
endpointPath,
|
|
64
|
-
genRouteHandler({
|
|
65
|
-
paramTypes: {
|
|
66
|
-
filterQuery: ParamType.JSONOptional,
|
|
67
|
-
},
|
|
68
|
-
handler: async ({ params }) => {
|
|
69
|
-
const filterQuery = params.filterQuery ?? {};
|
|
70
|
-
const categories = await collection.find(filterQuery);
|
|
71
|
-
return categories;
|
|
72
|
-
},
|
|
73
|
-
}),
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Create a new item in the collection
|
|
78
|
-
* @author Yuen Ler Chow
|
|
79
|
-
* @param {any} item the item to create
|
|
80
|
-
*/
|
|
81
|
-
app.post(
|
|
82
|
-
endpointPath,
|
|
83
|
-
genRouteHandler({
|
|
84
|
-
paramTypes: {
|
|
85
|
-
item: ParamType.JSON,
|
|
86
|
-
},
|
|
87
|
-
handler: async ({
|
|
88
|
-
params,
|
|
89
|
-
}) => {
|
|
90
|
-
// Destructure params
|
|
91
|
-
const {
|
|
92
|
-
item,
|
|
93
|
-
} = params;
|
|
94
|
-
|
|
95
|
-
await collection.insert(item);
|
|
96
|
-
},
|
|
97
|
-
}),
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Remove an item from the collection by id
|
|
102
|
-
* @author Yuen Ler Chow
|
|
103
|
-
*/
|
|
104
|
-
app.delete(
|
|
105
|
-
`${endpointPath}/:id`,
|
|
106
|
-
genRouteHandler({
|
|
107
|
-
paramTypes: {
|
|
108
|
-
id: ParamType.String,
|
|
109
|
-
},
|
|
110
|
-
handler: async ({
|
|
111
|
-
params,
|
|
112
|
-
}) => {
|
|
113
|
-
// Destructure params
|
|
114
|
-
const {
|
|
115
|
-
id,
|
|
116
|
-
} = params;
|
|
117
|
-
|
|
118
|
-
await collection.delete({ id });
|
|
119
|
-
},
|
|
120
|
-
}),
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export default addDBEditorEndpoints;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|