drapcode-utility 2.0.1 → 2.0.2
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/build/encryption/KMS.js +54 -102
- package/build/encryption/crypt.d.ts +4 -2
- package/build/encryption/crypt.js +76 -91
- package/build/encryption/file.d.ts +0 -2
- package/build/encryption/file.js +14 -130
- package/build/encryption/index.js +162 -334
- package/build/encryption/utility.js +7 -10
- package/build/errors/app-error.js +9 -27
- package/build/errors/axios-error.js +3 -3
- package/build/errors/bad-request-error.js +10 -28
- package/build/errors/custom-error.js +5 -23
- package/build/errors/not-found.js +9 -27
- package/build/format-fields/index.d.ts +0 -1
- package/build/format-fields/index.js +32 -65
- package/build/index.d.ts +1 -4
- package/build/index.js +1 -4
- package/build/middlewares/error-logger.d.ts +1 -1
- package/build/middlewares/error-logger.js +29 -29
- package/build/middlewares/redis/request-log.js +24 -74
- package/build/query/queryBuilder.d.ts +9 -0
- package/build/query/queryBuilder.js +567 -0
- package/build/utils/check-error.d.ts +15 -8
- package/build/utils/check-error.js +71 -160
- package/build/utils/common-util.d.ts +40 -39
- package/build/utils/common-util.js +60 -59
- package/build/utils/date-util.d.ts +28 -7
- package/build/utils/date-util.js +180 -127
- package/build/utils/file-util.d.ts +51 -6
- package/build/utils/file-util.js +36 -40
- package/build/utils/prepare-query.js +70 -43
- package/build/utils/project-util.d.ts +43 -5
- package/build/utils/project-util.js +176 -121
- package/build/utils/query-parser.d.ts +1 -1
- package/build/utils/query-parser.js +289 -342
- package/build/utils/query-utils.d.ts +2 -2
- package/build/utils/query-utils.js +103 -116
- package/build/utils/rest-client.js +236 -328
- package/build/utils/s3-util.js +238 -469
- package/build/utils/token.js +34 -81
- package/build/utils/util.d.ts +58 -13
- package/build/utils/util.js +424 -494
- package/build/utils/uuid-generator.d.ts +20 -1
- package/build/utils/uuid-generator.js +111 -47
- package/package.json +7 -5
- package/build/middlewares/interceptor-logger-new.d.ts +0 -2
- package/build/middlewares/interceptor-logger-new.js +0 -53
- package/build/middlewares/interceptor-logger.d.ts +0 -2
- package/build/middlewares/interceptor-logger.js +0 -52
- package/build/utils/query-parser-new.d.ts +0 -1
- package/build/utils/query-parser-new.js +0 -541
|
@@ -4,24 +4,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.saveCollections = exports.loadCollection = exports.loadCollections = exports.saveTemplates = exports.loadTemplate = exports.loadTemplates = exports.saveDevAPIs = exports.loadDevAPI = exports.loadDevAPIs = exports.savePlugins = exports.loadPlugin = exports.loadPlugins = exports.saveLocalizations = exports.loadLocalization = exports.loadLocalizations = exports.saveSnippets = exports.loadSnippet = exports.loadSnippets = exports.saveEvents = exports.loadEvent = exports.loadEvents = exports.saveTasks = exports.loadTask = exports.loadTasks = exports.saveCustomMappings = exports.loadCustomMapping = exports.loadCustomMappings = exports.saveCustomComponents = exports.loadCustomComponent = exports.loadCustomComponents = exports.saveExternalApis = exports.loadExternalApi = exports.loadExternalApis = exports.saveWebhooks = exports.loadWebhook = exports.loadWebhooks = exports.saveProjectPages = exports.loadPage = exports.loadPages = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var filePath = process.env.BUILD_FOLDER;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const file_util_1 = require("./file-util");
|
|
10
9
|
/**
|
|
11
10
|
* Page Related
|
|
12
11
|
*/
|
|
13
|
-
|
|
14
|
-
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "pages", [
|
|
12
|
+
const loadPages = (projectId) => {
|
|
13
|
+
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "pages", [
|
|
14
|
+
"default.json",
|
|
15
|
+
]);
|
|
15
16
|
};
|
|
16
17
|
exports.loadPages = loadPages;
|
|
17
|
-
|
|
18
|
+
const loadPage = (projectId, slug) => {
|
|
18
19
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "pages", slug);
|
|
19
20
|
};
|
|
20
21
|
exports.loadPage = loadPage;
|
|
21
|
-
|
|
22
|
-
(0, file_util_1.saveEntities)(projectId, "pages", pages,
|
|
22
|
+
const saveProjectPages = (projectId, pages) => {
|
|
23
|
+
(0, file_util_1.saveEntities)(projectId, "pages", pages, (page) => page.slug, (folderPath, page) => {
|
|
23
24
|
if (page.isDefaultPage) {
|
|
24
|
-
|
|
25
|
+
const defaultPath = path_1.default.join(folderPath, "default.json");
|
|
25
26
|
(0, file_util_1.createFile)(defaultPath, page);
|
|
26
27
|
}
|
|
27
28
|
});
|
|
@@ -30,125 +31,125 @@ exports.saveProjectPages = saveProjectPages;
|
|
|
30
31
|
/**
|
|
31
32
|
* Webhook Related
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
+
const loadWebhooks = (projectId) => {
|
|
34
35
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "webhooks");
|
|
35
36
|
};
|
|
36
37
|
exports.loadWebhooks = loadWebhooks;
|
|
37
|
-
|
|
38
|
+
const loadWebhook = (projectId, uuid) => {
|
|
38
39
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "webhooks", uuid);
|
|
39
40
|
};
|
|
40
41
|
exports.loadWebhook = loadWebhook;
|
|
41
|
-
|
|
42
|
-
(0, file_util_1.saveEntities)(projectId, "webhooks", webhooks,
|
|
42
|
+
const saveWebhooks = (projectId, webhooks) => {
|
|
43
|
+
(0, file_util_1.saveEntities)(projectId, "webhooks", webhooks, (webhook) => webhook.uuid);
|
|
43
44
|
};
|
|
44
45
|
exports.saveWebhooks = saveWebhooks;
|
|
45
46
|
/**
|
|
46
47
|
* External API Related
|
|
47
48
|
*/
|
|
48
|
-
|
|
49
|
+
const loadExternalApis = (projectId) => {
|
|
49
50
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "external-apis");
|
|
50
51
|
};
|
|
51
52
|
exports.loadExternalApis = loadExternalApis;
|
|
52
|
-
|
|
53
|
+
const loadExternalApi = (projectId, uuid) => {
|
|
53
54
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "external-apis", uuid);
|
|
54
55
|
};
|
|
55
56
|
exports.loadExternalApi = loadExternalApi;
|
|
56
|
-
|
|
57
|
-
(0, file_util_1.saveEntities)(projectId, "external-apis", externalApis,
|
|
57
|
+
const saveExternalApis = (projectId, externalApis) => {
|
|
58
|
+
(0, file_util_1.saveEntities)(projectId, "external-apis", externalApis, (api) => api.uuid);
|
|
58
59
|
};
|
|
59
60
|
exports.saveExternalApis = saveExternalApis;
|
|
60
61
|
/**
|
|
61
62
|
* Custom Component Related
|
|
62
63
|
*/
|
|
63
|
-
|
|
64
|
+
const loadCustomComponents = (projectId) => {
|
|
64
65
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "custom-components");
|
|
65
66
|
};
|
|
66
67
|
exports.loadCustomComponents = loadCustomComponents;
|
|
67
|
-
|
|
68
|
+
const loadCustomComponent = (projectId, uuid) => {
|
|
68
69
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "custom-components", uuid);
|
|
69
70
|
};
|
|
70
71
|
exports.loadCustomComponent = loadCustomComponent;
|
|
71
|
-
|
|
72
|
-
(0, file_util_1.saveEntities)(projectId, "custom-components", customComponents,
|
|
72
|
+
const saveCustomComponents = (projectId, customComponents) => {
|
|
73
|
+
(0, file_util_1.saveEntities)(projectId, "custom-components", customComponents, (customComponent) => customComponent.uuid);
|
|
73
74
|
};
|
|
74
75
|
exports.saveCustomComponents = saveCustomComponents;
|
|
75
76
|
/**
|
|
76
77
|
* Custom Component Related
|
|
77
78
|
*/
|
|
78
|
-
|
|
79
|
+
const loadCustomMappings = (projectId) => {
|
|
79
80
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "custom-data-mappings");
|
|
80
81
|
};
|
|
81
82
|
exports.loadCustomMappings = loadCustomMappings;
|
|
82
|
-
|
|
83
|
+
const loadCustomMapping = (projectId, uuid) => {
|
|
83
84
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "custom-data-mappings", uuid);
|
|
84
85
|
};
|
|
85
86
|
exports.loadCustomMapping = loadCustomMapping;
|
|
86
|
-
|
|
87
|
-
(0, file_util_1.saveEntities)(projectId, "custom-data-mappings", customMappings,
|
|
87
|
+
const saveCustomMappings = (projectId, customMappings) => {
|
|
88
|
+
(0, file_util_1.saveEntities)(projectId, "custom-data-mappings", customMappings, (customMapping) => customMapping.uuid);
|
|
88
89
|
};
|
|
89
90
|
exports.saveCustomMappings = saveCustomMappings;
|
|
90
91
|
/**
|
|
91
92
|
* Custom Component Related
|
|
92
93
|
*/
|
|
93
|
-
|
|
94
|
+
const loadTasks = (projectId) => {
|
|
94
95
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "tasks");
|
|
95
96
|
};
|
|
96
97
|
exports.loadTasks = loadTasks;
|
|
97
|
-
|
|
98
|
+
const loadTask = (projectId, uuid) => {
|
|
98
99
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "tasks", uuid);
|
|
99
100
|
};
|
|
100
101
|
exports.loadTask = loadTask;
|
|
101
|
-
|
|
102
|
-
(0, file_util_1.saveEntities)(projectId, "tasks", tasks,
|
|
102
|
+
const saveTasks = (projectId, tasks) => {
|
|
103
|
+
(0, file_util_1.saveEntities)(projectId, "tasks", tasks, (task) => task.uuid);
|
|
103
104
|
};
|
|
104
105
|
exports.saveTasks = saveTasks;
|
|
105
106
|
/**
|
|
106
107
|
* Event Related
|
|
107
108
|
*/
|
|
108
|
-
|
|
109
|
+
const loadEvents = (projectId) => {
|
|
109
110
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "events");
|
|
110
111
|
};
|
|
111
112
|
exports.loadEvents = loadEvents;
|
|
112
|
-
|
|
113
|
+
const loadEvent = (projectId, uuid) => {
|
|
113
114
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "events", uuid);
|
|
114
115
|
};
|
|
115
116
|
exports.loadEvent = loadEvent;
|
|
116
|
-
|
|
117
|
-
(0, file_util_1.saveEntities)(projectId, "events", events,
|
|
117
|
+
const saveEvents = (projectId, events) => {
|
|
118
|
+
(0, file_util_1.saveEntities)(projectId, "events", events, (event) => event.uuid);
|
|
118
119
|
};
|
|
119
120
|
exports.saveEvents = saveEvents;
|
|
120
121
|
/**
|
|
121
122
|
* Snippet Related
|
|
122
123
|
*/
|
|
123
|
-
|
|
124
|
+
const loadSnippets = (projectId) => {
|
|
124
125
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "snippets");
|
|
125
126
|
};
|
|
126
127
|
exports.loadSnippets = loadSnippets;
|
|
127
|
-
|
|
128
|
+
const loadSnippet = (projectId, uuid) => {
|
|
128
129
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "snippets", uuid);
|
|
129
130
|
};
|
|
130
131
|
exports.loadSnippet = loadSnippet;
|
|
131
|
-
|
|
132
|
-
(0, file_util_1.saveEntities)(projectId, "snippets", snippets,
|
|
132
|
+
const saveSnippets = (projectId, snippets) => {
|
|
133
|
+
(0, file_util_1.saveEntities)(projectId, "snippets", snippets, (snippet) => snippet.uuid);
|
|
133
134
|
};
|
|
134
135
|
exports.saveSnippets = saveSnippets;
|
|
135
136
|
/**
|
|
136
137
|
* Localization Related
|
|
137
138
|
*/
|
|
138
|
-
|
|
139
|
+
const loadLocalizations = (projectId) => {
|
|
139
140
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "localizations", [
|
|
140
141
|
"default.json",
|
|
141
142
|
]);
|
|
142
143
|
};
|
|
143
144
|
exports.loadLocalizations = loadLocalizations;
|
|
144
|
-
|
|
145
|
+
const loadLocalization = (projectId, language) => {
|
|
145
146
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "localizations", language);
|
|
146
147
|
};
|
|
147
148
|
exports.loadLocalization = loadLocalization;
|
|
148
|
-
|
|
149
|
-
(0, file_util_1.saveEntities)(projectId, "localizations", localizations,
|
|
149
|
+
const saveLocalizations = (projectId, localizations) => {
|
|
150
|
+
(0, file_util_1.saveEntities)(projectId, "localizations", localizations, (localization) => localization.language, (folderPath, localization) => {
|
|
150
151
|
if (localization.isDefault) {
|
|
151
|
-
|
|
152
|
+
const defaultPath = path_1.default.join(folderPath, "default.json");
|
|
152
153
|
(0, file_util_1.createFile)(defaultPath, localization);
|
|
153
154
|
}
|
|
154
155
|
});
|
|
@@ -157,62 +158,62 @@ exports.saveLocalizations = saveLocalizations;
|
|
|
157
158
|
/**
|
|
158
159
|
* Plugin Related
|
|
159
160
|
*/
|
|
160
|
-
|
|
161
|
+
const loadPlugins = (projectId) => {
|
|
161
162
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "plugins");
|
|
162
163
|
};
|
|
163
164
|
exports.loadPlugins = loadPlugins;
|
|
164
|
-
|
|
165
|
+
const loadPlugin = (projectId, code) => {
|
|
165
166
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "plugins", code);
|
|
166
167
|
};
|
|
167
168
|
exports.loadPlugin = loadPlugin;
|
|
168
|
-
|
|
169
|
-
(0, file_util_1.saveEntities)(projectId, "plugins", plugins,
|
|
169
|
+
const savePlugins = (projectId, plugins) => {
|
|
170
|
+
(0, file_util_1.saveEntities)(projectId, "plugins", plugins, (plugin) => plugin.code);
|
|
170
171
|
};
|
|
171
172
|
exports.savePlugins = savePlugins;
|
|
172
173
|
/**
|
|
173
174
|
* DEV APIs Related
|
|
174
175
|
*/
|
|
175
|
-
|
|
176
|
+
const loadDevAPIs = (projectId) => {
|
|
176
177
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "dev-apis");
|
|
177
178
|
};
|
|
178
179
|
exports.loadDevAPIs = loadDevAPIs;
|
|
179
|
-
|
|
180
|
+
const loadDevAPI = (projectId, uuid) => {
|
|
180
181
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "dev-apis", uuid);
|
|
181
182
|
};
|
|
182
183
|
exports.loadDevAPI = loadDevAPI;
|
|
183
|
-
|
|
184
|
-
(0, file_util_1.saveEntities)(projectId, "dev-apis", devApis,
|
|
184
|
+
const saveDevAPIs = (projectId, devApis) => {
|
|
185
|
+
(0, file_util_1.saveEntities)(projectId, "dev-apis", devApis, (plugin) => plugin.uuid);
|
|
185
186
|
};
|
|
186
187
|
exports.saveDevAPIs = saveDevAPIs;
|
|
187
188
|
/**
|
|
188
189
|
* Template Related
|
|
189
190
|
*/
|
|
190
|
-
|
|
191
|
+
const loadTemplates = (projectId) => {
|
|
191
192
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "templates");
|
|
192
193
|
};
|
|
193
194
|
exports.loadTemplates = loadTemplates;
|
|
194
|
-
|
|
195
|
+
const loadTemplate = (projectId, uuid) => {
|
|
195
196
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "templates", uuid);
|
|
196
197
|
};
|
|
197
198
|
exports.loadTemplate = loadTemplate;
|
|
198
|
-
|
|
199
|
-
(0, file_util_1.saveEntities)(projectId, "templates", templates,
|
|
199
|
+
const saveTemplates = (projectId, templates) => {
|
|
200
|
+
(0, file_util_1.saveEntities)(projectId, "templates", templates, (template) => template.uuid);
|
|
200
201
|
};
|
|
201
202
|
exports.saveTemplates = saveTemplates;
|
|
202
203
|
/**
|
|
203
204
|
* Collection Related
|
|
204
205
|
*/
|
|
205
|
-
|
|
206
|
+
const loadCollections = (projectId) => {
|
|
206
207
|
return (0, file_util_1.loadJsonFilesFromSubfolder)(projectId, "collections");
|
|
207
208
|
};
|
|
208
209
|
exports.loadCollections = loadCollections;
|
|
209
|
-
|
|
210
|
+
const loadCollection = (projectId, uuid) => {
|
|
210
211
|
return (0, file_util_1.loadSingleJsonFromSubfolder)(projectId, "collections", uuid);
|
|
211
212
|
};
|
|
212
213
|
exports.loadCollection = loadCollection;
|
|
213
|
-
|
|
214
|
-
(0, file_util_1.saveEntities)(projectId, "collections", collections,
|
|
215
|
-
|
|
214
|
+
const saveCollections = (projectId, collections) => {
|
|
215
|
+
(0, file_util_1.saveEntities)(projectId, "collections", collections, (collection) => collection.uuid, (folderPath, collection) => {
|
|
216
|
+
const defaultPath = path_1.default.join(folderPath, `${collection.collectionName}.json`);
|
|
216
217
|
(0, file_util_1.createFile)(defaultPath, collection);
|
|
217
218
|
});
|
|
218
219
|
};
|
|
@@ -1,9 +1,30 @@
|
|
|
1
|
+
interface DateField {
|
|
2
|
+
fieldName: string;
|
|
3
|
+
type: string;
|
|
4
|
+
extraFieldSetting?: {
|
|
5
|
+
dateDisplayType?: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
interface DateRangeValue {
|
|
9
|
+
[key: string]: {
|
|
10
|
+
$gte?: string;
|
|
11
|
+
$lte?: string;
|
|
12
|
+
} | {
|
|
13
|
+
$or?: Array<{
|
|
14
|
+
[key: string]: {
|
|
15
|
+
$gte?: string;
|
|
16
|
+
$lte?: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
1
21
|
export declare const DATE_REGEX: RegExp;
|
|
2
|
-
export declare const createLoggerDateFormat: (timezone?: string) =>
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const createLogsDateFormat: (timezone?: string) =>
|
|
5
|
-
export declare const getDateValue: (value: string, timezone?: string) =>
|
|
6
|
-
export declare const getDateRangeValue: (key: string, field: string, value: string) =>
|
|
7
|
-
export declare const nextDayDate: (date:
|
|
22
|
+
export declare const createLoggerDateFormat: (timezone?: string) => string;
|
|
23
|
+
export declare const createLoggerPreviousDateFormat: () => string;
|
|
24
|
+
export declare const createLogsDateFormat: (timezone?: string) => string;
|
|
25
|
+
export declare const getDateValue: (value: string, timezone?: string) => string;
|
|
26
|
+
export declare const getDateRangeValue: (key: string, field: string, value: string) => DateRangeValue;
|
|
27
|
+
export declare const nextDayDate: (date: string | Date) => string;
|
|
8
28
|
export declare const timezoneDateParse: (value: string, nextDay?: boolean, prevDay?: boolean) => Date;
|
|
9
|
-
export declare const formatProjectDates: (item: any, dateFormat: string, fields:
|
|
29
|
+
export declare const formatProjectDates: (item: Record<string, any> | Record<string, any>[], dateFormat: string, fields: DateField[], reverse: boolean) => Record<string, any> | Record<string, any>[];
|
|
30
|
+
export {};
|