drapcode-utility 2.0.0 → 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.
Files changed (50) hide show
  1. package/build/encryption/KMS.js +54 -102
  2. package/build/encryption/crypt.d.ts +4 -2
  3. package/build/encryption/crypt.js +76 -91
  4. package/build/encryption/file.d.ts +0 -2
  5. package/build/encryption/file.js +14 -130
  6. package/build/encryption/index.js +162 -334
  7. package/build/encryption/utility.js +7 -10
  8. package/build/errors/app-error.js +9 -27
  9. package/build/errors/axios-error.js +3 -3
  10. package/build/errors/bad-request-error.js +10 -28
  11. package/build/errors/custom-error.js +5 -23
  12. package/build/errors/not-found.js +9 -27
  13. package/build/format-fields/index.d.ts +0 -1
  14. package/build/format-fields/index.js +32 -65
  15. package/build/index.d.ts +1 -4
  16. package/build/index.js +1 -4
  17. package/build/middlewares/error-logger.d.ts +1 -1
  18. package/build/middlewares/error-logger.js +29 -29
  19. package/build/middlewares/redis/request-log.js +24 -74
  20. package/build/query/queryBuilder.d.ts +9 -0
  21. package/build/query/queryBuilder.js +567 -0
  22. package/build/utils/check-error.d.ts +15 -8
  23. package/build/utils/check-error.js +71 -160
  24. package/build/utils/common-util.d.ts +40 -39
  25. package/build/utils/common-util.js +60 -59
  26. package/build/utils/date-util.d.ts +28 -7
  27. package/build/utils/date-util.js +180 -127
  28. package/build/utils/file-util.d.ts +51 -6
  29. package/build/utils/file-util.js +36 -40
  30. package/build/utils/prepare-query.js +70 -43
  31. package/build/utils/project-util.d.ts +43 -5
  32. package/build/utils/project-util.js +176 -121
  33. package/build/utils/query-parser.d.ts +1 -1
  34. package/build/utils/query-parser.js +289 -342
  35. package/build/utils/query-utils.d.ts +2 -2
  36. package/build/utils/query-utils.js +103 -116
  37. package/build/utils/rest-client.js +236 -328
  38. package/build/utils/s3-util.js +238 -469
  39. package/build/utils/token.js +34 -81
  40. package/build/utils/util.d.ts +58 -13
  41. package/build/utils/util.js +424 -494
  42. package/build/utils/uuid-generator.d.ts +20 -1
  43. package/build/utils/uuid-generator.js +111 -47
  44. package/package.json +7 -5
  45. package/build/middlewares/interceptor-logger-new.d.ts +0 -2
  46. package/build/middlewares/interceptor-logger-new.js +0 -53
  47. package/build/middlewares/interceptor-logger.d.ts +0 -2
  48. package/build/middlewares/interceptor-logger.js +0 -52
  49. package/build/utils/query-parser-new.d.ts +0 -1
  50. package/build/utils/query-parser-new.js +0 -541
@@ -1,22 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.commonLookupSetting = exports.prepareChildRefCreatedByLookup = exports.prepareCreatedByLookup = void 0;
4
- var drapcode_constant_1 = require("drapcode-constant");
5
- var prepareCreatedByLookup = function (lookupConfig, aggregateQuery, field) {
6
- var _a;
7
- var enableLookup = lookupConfig.enableLookup, lookups = lookupConfig.lookups;
8
- var findCollInLookup = lookups
9
- ? lookups.find(function (lkp) { return lkp.collectionName === "createdBy"; })
4
+ const drapcode_constant_1 = require("drapcode-constant");
5
+ const prepareCreatedByLookup = (lookupConfig, aggregateQuery, field) => {
6
+ const { enableLookup, lookups } = lookupConfig;
7
+ const findCollInLookup = lookups
8
+ ? lookups.find((lkp) => lkp.collectionName === "createdBy")
10
9
  : null;
11
10
  if (!enableLookup || findCollInLookup) {
12
11
  aggregateQuery.push({
13
12
  $lookup: {
14
13
  from: "user",
15
- let: (_a = {}, _a["".concat(field.fieldName)] = "$".concat(field.fieldName), _a),
14
+ let: { [`${field.fieldName}`]: `$${field.fieldName}` },
16
15
  pipeline: [
17
16
  {
18
17
  $match: {
19
- $expr: { $eq: ["$uuid", "$$".concat(field.fieldName)] },
18
+ $expr: { $eq: ["$uuid", `$$${field.fieldName}`] },
20
19
  },
21
20
  },
22
21
  { $project: { _id: 0, password: 0 } },
@@ -27,32 +26,39 @@ var prepareCreatedByLookup = function (lookupConfig, aggregateQuery, field) {
27
26
  }
28
27
  };
29
28
  exports.prepareCreatedByLookup = prepareCreatedByLookup;
30
- var prepareChildRefCreatedByLookup = function (collectionName, findCollInLookup, lookupConfig, field, aggregateQuery) {
31
- var _a;
32
- var enableLookup = lookupConfig.enableLookup;
33
- var pPipeline = [];
29
+ const prepareChildRefCreatedByLookup = (collectionName, findCollInLookup, lookupConfig, field, aggregateQuery) => {
30
+ const { enableLookup } = lookupConfig;
31
+ const pPipeline = [];
32
+ // pPipeline.push({
33
+ // $match: {
34
+ // $expr: {
35
+ // $in: [
36
+ // "$uuid",
37
+ // {
38
+ // $cond: {
39
+ // if: {
40
+ // $or: [
41
+ // { $eq: [`$$${field.fieldName}`, null] },
42
+ // { $eq: [`$$${field.fieldName}`, ""] },
43
+ // ],
44
+ // },
45
+ // then: [],
46
+ // else: { $ifNull: [`$$${field.fieldName}`, []] },
47
+ // },
48
+ // },
49
+ // ],
50
+ // },
51
+ // },
52
+ // });
34
53
  pPipeline.push({
35
54
  $match: {
36
55
  $expr: {
37
- $in: [
38
- "$uuid",
39
- {
40
- $cond: {
41
- if: {
42
- $in: ["$$".concat(field.fieldName), ["", null]],
43
- },
44
- then: [],
45
- else: {
46
- $ifNull: ["$$".concat(field.fieldName), []],
47
- },
48
- },
49
- },
50
- ],
56
+ $in: ["$uuid", { $ifNull: [`$$${field.fieldName}`, []] }],
51
57
  },
52
58
  },
53
59
  });
54
- var findChildLookup = findCollInLookup && findCollInLookup.childLookups
55
- ? findCollInLookup.childLookups.find(function (chlkp) { return chlkp.collectionName === "createdBy"; })
60
+ const findChildLookup = findCollInLookup && findCollInLookup.childLookups
61
+ ? findCollInLookup.childLookups.find((chlkp) => chlkp.collectionName === "createdBy")
56
62
  : null;
57
63
  if (!enableLookup || findChildLookup) {
58
64
  pPipeline.push({
@@ -73,44 +79,42 @@ var prepareChildRefCreatedByLookup = function (collectionName, findCollInLookup,
73
79
  }
74
80
  aggregateQuery.push({
75
81
  $lookup: {
76
- from: "".concat(collectionName),
77
- let: (_a = {}, _a["".concat(field.fieldName)] = "$".concat(field.fieldName), _a),
82
+ from: `${collectionName}`,
83
+ let: { [`${field.fieldName}`]: `$${field.fieldName}` },
78
84
  pipeline: pPipeline,
79
85
  as: field.fieldName,
80
86
  },
81
87
  });
82
88
  };
83
89
  exports.prepareChildRefCreatedByLookup = prepareChildRefCreatedByLookup;
84
- var commonLookupSetting = function (field, lookupConfig, aggregateQuery) {
85
- var _a;
86
- console.log("lookupConfig commonLookupSetting", lookupConfig);
87
- var enableLookup = lookupConfig.enableLookup, lookups = lookupConfig.lookups;
90
+ const commonLookupSetting = (field, lookupConfig, aggregateQuery) => {
91
+ const { enableLookup, lookups } = lookupConfig;
88
92
  if (drapcode_constant_1.BelongsToReferenceField.includes(field.type)) {
89
- var collectionName_1 = field.refCollection
93
+ let collectionName = field.refCollection
90
94
  ? field.refCollection["collectionName"]
91
95
  : null;
92
- if (collectionName_1) {
93
- var findCollInLookup = lookups
94
- ? lookups.find(function (lkp) { return lkp.collectionName === collectionName_1; })
96
+ if (collectionName) {
97
+ const findCollInLookup = lookups
98
+ ? lookups.find((lkp) => lkp.collectionName === collectionName)
95
99
  : null;
96
100
  if (!enableLookup || findCollInLookup) {
97
101
  if (field.type === "belongsTo") {
98
102
  aggregateQuery.push({
99
103
  $lookup: {
100
- from: "".concat(collectionName_1),
104
+ from: collectionName,
101
105
  localField: field.fieldName,
102
106
  foreignField: "uuid",
103
107
  as: field.fieldName,
104
108
  },
105
109
  });
106
110
  aggregateQuery.push({
107
- $addFields: (_a = {},
108
- _a["_$belongsToMetaData"] = field,
109
- _a),
111
+ $addFields: {
112
+ [`_$belongsToMetaData`]: trimFieldForRefCollection(field),
113
+ },
110
114
  });
111
115
  }
112
116
  else {
113
- (0, exports.prepareChildRefCreatedByLookup)(collectionName_1, findCollInLookup, lookupConfig, field, aggregateQuery);
117
+ (0, exports.prepareChildRefCreatedByLookup)(collectionName, findCollInLookup, lookupConfig, field, aggregateQuery);
114
118
  }
115
119
  }
116
120
  }
@@ -120,3 +124,26 @@ var commonLookupSetting = function (field, lookupConfig, aggregateQuery) {
120
124
  }
121
125
  };
122
126
  exports.commonLookupSetting = commonLookupSetting;
127
+ const trimFieldForRefCollection = (field) => {
128
+ if (!field) {
129
+ return field;
130
+ }
131
+ const copyField = Object.assign({}, field);
132
+ delete copyField.fieldTitle;
133
+ delete copyField.placeholder;
134
+ delete copyField.validation;
135
+ delete copyField.createdAt;
136
+ delete copyField.updatedAt;
137
+ delete copyField._id;
138
+ delete copyField.isGenerateURL;
139
+ delete copyField.isGenerateIcons;
140
+ delete copyField.isPrivate;
141
+ delete copyField.encrypted;
142
+ delete copyField.isPluginField;
143
+ delete copyField.isMultiSelect;
144
+ if (!copyField.staticOptions || copyField.staticOptions.length === 0)
145
+ delete copyField.staticOptions;
146
+ delete copyField.required;
147
+ console.log("copyField :>> ", copyField);
148
+ return copyField;
149
+ };
@@ -1,5 +1,43 @@
1
- export declare const saveProjectToFile: (project: any) => void;
2
- export declare const findProjectFromFile: (query: any) => any;
3
- export declare const updateProjectInFile: () => void;
4
- export declare const removeProjectFromFile: (project: any) => void;
5
- export declare const clearProjectSubfolder: (projectId: string, subfolder: string) => null | undefined;
1
+ import { FileContent } from "./file-util";
2
+ interface Project extends FileContent {
3
+ uuid: string;
4
+ seoName: string;
5
+ apiDomainName?: string;
6
+ domainName?: string;
7
+ }
8
+ interface ProjectQuery {
9
+ or?: Array<{
10
+ [key: string]: string;
11
+ }>;
12
+ apiDomainName?: string;
13
+ seoName?: string;
14
+ domainName?: string;
15
+ uuid?: string;
16
+ }
17
+ /**
18
+ * Saves a project to the file system
19
+ * @param project - The project to save
20
+ * @throws {ProjectError} If project is invalid or file operations fail
21
+ */
22
+ export declare const saveProjectToFile: (project: Project) => void;
23
+ /**
24
+ * Finds a project from the file system based on query parameters
25
+ * @param query - The query parameters to find the project
26
+ * @returns The found project or null if not found
27
+ * @throws {ProjectError} If file operations fail
28
+ */
29
+ export declare const findProjectFromFile: (query: ProjectQuery) => Project | null;
30
+ /**
31
+ * Removes a project from the file system
32
+ * @param project - The project to remove
33
+ * @throws {ProjectError} If project is invalid or file operations fail
34
+ */
35
+ export declare const removeProjectFromFile: (project: Project) => void;
36
+ /**
37
+ * Clears a project subfolder
38
+ * @param projectId - The project ID
39
+ * @param subfolder - The subfolder to clear
40
+ * @throws {ProjectError} If file operations fail
41
+ */
42
+ export declare const clearProjectSubfolder: (projectId: string, subfolder: string) => void;
43
+ export {};
@@ -3,149 +3,204 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.clearProjectSubfolder = exports.removeProjectFromFile = exports.updateProjectInFile = exports.findProjectFromFile = exports.saveProjectToFile = void 0;
7
- var fs_1 = require("fs");
8
- var path_1 = __importDefault(require("path"));
9
- var file_util_1 = require("./file-util");
10
- var filePath = process.env.BUILD_FOLDER;
11
- var saveProjectToFile = function (project) {
12
- if (!project) {
13
- return;
14
- }
15
- (0, file_util_1.checkFolder)(filePath);
16
- var projectPath = path_1.default.join(filePath, "projects");
17
- (0, file_util_1.checkFolder)(projectPath);
18
- var uuid = project.uuid, seoName = project.seoName, apiDomainName = project.apiDomainName, domainName = project.domainName;
19
- console.log("Create UUID JSON file");
20
- (0, file_util_1.createFile)(path_1.default.join(projectPath, "".concat(uuid, ".json")), project);
21
- console.log("Create SeoName JSON file");
22
- (0, file_util_1.createFile)(path_1.default.join(projectPath, "".concat(seoName, ".json")), project);
23
- if (apiDomainName) {
24
- console.log("Create API Domain JSON file");
25
- (0, file_util_1.createFile)(path_1.default.join(projectPath, "".concat(apiDomainName, ".json")), project);
26
- }
27
- if (domainName) {
28
- console.log("Create Domain JSON file");
29
- (0, file_util_1.createFile)(path_1.default.join(projectPath, "".concat(domainName, ".json")), project);
6
+ exports.clearProjectSubfolder = exports.removeProjectFromFile = exports.findProjectFromFile = exports.saveProjectToFile = void 0;
7
+ const fs_1 = require("fs");
8
+ const path_1 = __importDefault(require("path"));
9
+ const file_util_1 = require("./file-util");
10
+ // Constants
11
+ const PROJECTS_FOLDER = "projects";
12
+ const PROJECT_PREFIX = "project_";
13
+ // Error types
14
+ class ProjectError extends Error {
15
+ constructor(message) {
16
+ super(message);
17
+ this.name = "ProjectError";
18
+ }
19
+ }
20
+ // Configuration
21
+ const filePath = process.env.BUILD_FOLDER || "";
22
+ /**
23
+ * Saves a project to the file system
24
+ * @param project - The project to save
25
+ * @throws {ProjectError} If project is invalid or file operations fail
26
+ */
27
+ const saveProjectToFile = (project) => {
28
+ if (!project?.uuid || !project?.seoName) {
29
+ throw new ProjectError("Invalid project: missing required fields");
30
+ }
31
+ try {
32
+ (0, file_util_1.checkFolder)(filePath);
33
+ const projectPath = path_1.default.join(filePath, PROJECTS_FOLDER);
34
+ (0, file_util_1.checkFolder)(projectPath);
35
+ const filePaths = getProjectFilePaths(project, projectPath);
36
+ console.log("Creating project files...");
37
+ Object.entries(filePaths).forEach(([key, filePath]) => {
38
+ console.log("key :>> ", key);
39
+ if (filePath) {
40
+ (0, file_util_1.createFile)(filePath, project);
41
+ }
42
+ });
43
+ }
44
+ catch (error) {
45
+ const message = error instanceof Error ? error.message : "Unknown error";
46
+ console.error("Failed to save project:", message);
47
+ throw new ProjectError(`Failed to save project: ${message}`);
30
48
  }
31
49
  };
32
50
  exports.saveProjectToFile = saveProjectToFile;
33
- var findProjectFromFile = function (query) {
34
- var _a, _b;
35
- var isMainExists = verifyProjectsFolder();
36
- if (!isMainExists) {
51
+ /**
52
+ * Finds a project from the file system based on query parameters
53
+ * @param query - The query parameters to find the project
54
+ * @returns The found project or null if not found
55
+ * @throws {ProjectError} If file operations fail
56
+ */
57
+ const findProjectFromFile = (query) => {
58
+ try {
59
+ if (!verifyProjectsFolder()) {
60
+ return null;
61
+ }
62
+ const projectPath = path_1.default.join(filePath, PROJECTS_FOLDER);
63
+ const { or, apiDomainName, seoName, domainName, uuid } = query;
64
+ // Check by UUID first as it's the most reliable identifier
65
+ if (uuid) {
66
+ console.log("Checking for Project UUID");
67
+ return (0, file_util_1.readFile)(path_1.default.join(projectPath, `${uuid}.json`));
68
+ }
69
+ // Check other identifiers
70
+ const identifiers = [
71
+ { value: apiDomainName, type: "API Domain" },
72
+ { value: seoName, type: "SEO Name" },
73
+ { value: domainName, type: "Domain Name" },
74
+ ];
75
+ for (const { value, type } of identifiers) {
76
+ if (value) {
77
+ console.log(`Checking for Project ${type}`);
78
+ const project = (0, file_util_1.readFile)(path_1.default.join(projectPath, `${value}.json`));
79
+ if (project)
80
+ return project;
81
+ }
82
+ }
83
+ // Check OR conditions
84
+ if (or?.length) {
85
+ const pSeoName = extractDomainSeo(or, "seoName")?.["seoName"];
86
+ const pDomainName = extractDomainSeo(or, "domainName")?.["domainName"];
87
+ if (pSeoName) {
88
+ console.log("Checking for Project SEO Name");
89
+ return (0, file_util_1.readFile)(path_1.default.join(projectPath, `${pSeoName}.json`));
90
+ }
91
+ if (pDomainName) {
92
+ console.log("Checking for Project Domain Name");
93
+ return (0, file_util_1.readFile)(path_1.default.join(projectPath, `${pDomainName}.json`));
94
+ }
95
+ }
37
96
  return null;
38
97
  }
39
- var projectPath = path_1.default.join(filePath, "projects");
40
- var or = query.or, apiDomainName = query.apiDomainName, seoName = query.seoName, domainName = query.domainName, uuid = query.uuid;
41
- if (uuid) {
42
- //If uuid exists then please check with this no need of or
43
- console.log("Checking for Project UUID");
44
- var project = (0, file_util_1.readFile)(path_1.default.join(projectPath, "".concat(uuid, ".json")));
45
- return project;
46
- }
47
- if (apiDomainName) {
48
- //If api domain exists then please check with this no need of or
49
- console.log("Checking for Project API Domain");
50
- var project = (0, file_util_1.readFile)(path_1.default.join(projectPath, "".concat(apiDomainName, ".json")));
51
- return project;
52
- }
53
- if (seoName) {
54
- //IF api seo name exists then not need to check or
55
- console.log("Checking for Project SEO Name");
56
- var project = (0, file_util_1.readFile)(path_1.default.join(projectPath, "".concat(seoName, ".json")));
57
- return project;
58
- }
59
- if (domainName) {
60
- //IF api seo name exists then not need to check or
61
- console.log("Checking for Project SEO Name");
62
- var project = (0, file_util_1.readFile)(path_1.default.join(projectPath, "".concat(domainName, ".json")));
63
- return project;
64
- }
65
- if (!or || or.length === 0) {
66
- return null;
98
+ catch (error) {
99
+ const message = error instanceof Error ? error.message : "Unknown error";
100
+ console.error("Failed to find project:", message);
101
+ throw new ProjectError(`Failed to find project: ${message}`);
67
102
  }
68
- var pSeoName = (_a = extractDomainSeo(or, "seoName")) === null || _a === void 0 ? void 0 : _a["seoName"];
69
- var pDomainName = (_b = extractDomainSeo(or, "domainName")) === null || _b === void 0 ? void 0 : _b["domainName"];
70
- // Now check with pSeoName and domainName
71
- console.log("pSeoName :>> ", pSeoName);
72
- console.log("domainName :>> ", domainName);
73
- if (pSeoName) {
74
- //IF api seo name exists then not need to check or
75
- console.log("Checking for Project SEO Name");
76
- var project = (0, file_util_1.readFile)(path_1.default.join(projectPath, "".concat(pSeoName, ".json")));
77
- return project;
78
- }
79
- if (pDomainName) {
80
- //IF api seo name exists then not need to check or
81
- console.log("Checking for Project Domain Name");
82
- var project = (0, file_util_1.readFile)(path_1.default.join(projectPath, "".concat(pDomainName, ".json")));
83
- return project;
84
- }
85
- return null;
86
103
  };
87
104
  exports.findProjectFromFile = findProjectFromFile;
88
- var updateProjectInFile = function () { };
89
- exports.updateProjectInFile = updateProjectInFile;
90
- var removeProjectFromFile = function (project) {
91
- //Check if projects folder exists in filePath or not
92
- //Remove
93
- if (!project) {
94
- console.log("I do not have project");
95
- return;
96
- }
97
- var isMainExists = verifyProjectsFolder();
98
- console.log("Project Folder failed", isMainExists);
99
- if (!isMainExists) {
100
- return;
101
- }
102
- var projectPath = path_1.default.join(filePath, "projects");
103
- console.log("Check path", projectPath);
104
- var uuid = project.uuid, seoName = project.seoName, apiDomainName = project.apiDomainName, domainName = project.domainName;
105
- console.log("Removing UUID JSON");
106
- removeFile(path_1.default.join(projectPath, "".concat(uuid, ".json")));
107
- console.log("Removing Seo Name JSON");
108
- removeFile(path_1.default.join(projectPath, "".concat(seoName, ".json")));
109
- if (apiDomainName) {
110
- console.log("Removing API Domain JSON");
111
- removeFile(path_1.default.join(projectPath, "".concat(apiDomainName, ".json")));
112
- }
113
- if (domainName) {
114
- console.log("Removing Domain JSON");
115
- removeFile(path_1.default.join(projectPath, "".concat(domainName, ".json")));
105
+ /**
106
+ * Removes a project from the file system
107
+ * @param project - The project to remove
108
+ * @throws {ProjectError} If project is invalid or file operations fail
109
+ */
110
+ const removeProjectFromFile = (project) => {
111
+ if (!project?.uuid || !project?.seoName) {
112
+ throw new ProjectError("Invalid project: missing required fields");
113
+ }
114
+ try {
115
+ if (!verifyProjectsFolder()) {
116
+ return;
117
+ }
118
+ const projectPath = path_1.default.join(filePath, PROJECTS_FOLDER);
119
+ const filePaths = getProjectFilePaths(project, projectPath);
120
+ console.log("Removing project files...");
121
+ Object.entries(filePaths).forEach(([key, filePath]) => {
122
+ console.log("key :>> ", key);
123
+ if (filePath) {
124
+ removeFile(filePath);
125
+ }
126
+ });
127
+ }
128
+ catch (error) {
129
+ const message = error instanceof Error ? error.message : "Unknown error";
130
+ console.error("Failed to remove project:", message);
131
+ throw new ProjectError(`Failed to remove project: ${message}`);
116
132
  }
117
133
  };
118
134
  exports.removeProjectFromFile = removeProjectFromFile;
119
- var clearProjectSubfolder = function (projectId, subfolder) {
120
- if (!projectId)
121
- return;
122
- var isMainExists = (0, file_util_1.verifyProjectSettingFolder)(projectId);
123
- if (!isMainExists)
124
- return null;
125
- var projectPath = path_1.default.join(filePath, "project_".concat(projectId), subfolder);
126
- removeFolder(projectPath);
135
+ /**
136
+ * Clears a project subfolder
137
+ * @param projectId - The project ID
138
+ * @param subfolder - The subfolder to clear
139
+ * @throws {ProjectError} If file operations fail
140
+ */
141
+ const clearProjectSubfolder = (projectId, subfolder) => {
142
+ if (!projectId) {
143
+ throw new ProjectError("Project ID is required");
144
+ }
145
+ if (!subfolder) {
146
+ throw new ProjectError("Sub Folder is required");
147
+ }
148
+ try {
149
+ if ((0, file_util_1.verifyProjectSettingFolder)(projectId)) {
150
+ return;
151
+ }
152
+ const projectPath = path_1.default.join(filePath, `${PROJECT_PREFIX}${projectId}`, subfolder);
153
+ removeFolder(projectPath);
154
+ }
155
+ catch (error) {
156
+ const message = error instanceof Error ? error.message : "Unknown error";
157
+ console.error("Failed to clear project subfolder:", message);
158
+ throw new ProjectError(`Failed to clear project subfolder: ${message}`);
159
+ }
127
160
  };
128
161
  exports.clearProjectSubfolder = clearProjectSubfolder;
129
- var verifyProjectsFolder = function () {
130
- var projectPath = path_1.default.join(filePath, "projects");
162
+ // Helper functions
163
+ const verifyProjectsFolder = () => {
164
+ const projectPath = path_1.default.join(filePath, PROJECTS_FOLDER);
131
165
  return (0, fs_1.existsSync)(filePath) && (0, fs_1.existsSync)(projectPath);
132
166
  };
133
- var removeFile = function (filePath) {
167
+ const removeFile = (filePath) => {
134
168
  try {
135
- (0, fs_1.existsSync)(filePath) && (0, fs_1.unlinkSync)(filePath);
169
+ if ((0, fs_1.existsSync)(filePath)) {
170
+ (0, fs_1.unlinkSync)(filePath);
171
+ }
136
172
  }
137
173
  catch (error) {
138
- console.log("error :>> ", error);
174
+ const message = error instanceof Error ? error.message : "Unknown error";
175
+ console.error("Failed to remove file:", message);
176
+ throw new ProjectError(`Failed to remove file: ${message}`);
139
177
  }
140
178
  };
141
- var removeFolder = function (folderPath) {
179
+ const removeFolder = (folderPath) => {
142
180
  try {
143
- (0, fs_1.existsSync)(folderPath) && (0, fs_1.rmdirSync)(folderPath, { recursive: true });
181
+ if ((0, fs_1.existsSync)(folderPath)) {
182
+ (0, fs_1.rmdirSync)(folderPath, { recursive: true });
183
+ }
144
184
  }
145
185
  catch (error) {
146
- console.log("error :>> ", error);
186
+ const message = error instanceof Error ? error.message : "Unknown error";
187
+ console.error("Failed to remove folder:", message);
188
+ throw new ProjectError(`Failed to remove folder: ${message}`);
147
189
  }
148
190
  };
149
- function extractDomainSeo(or, key) {
150
- return or.find(function (obj) { return Object.keys(obj)[0] === key; });
151
- }
191
+ const extractDomainSeo = (or, key) => {
192
+ return or.find((obj) => Object.keys(obj)[0] === key);
193
+ };
194
+ const getProjectFilePaths = (project, projectPath) => {
195
+ const { uuid, seoName, apiDomainName, domainName } = project;
196
+ return {
197
+ uuidPath: path_1.default.join(projectPath, `${uuid}.json`),
198
+ seoNamePath: path_1.default.join(projectPath, `${seoName}.json`),
199
+ apiDomainNamePath: apiDomainName
200
+ ? path_1.default.join(projectPath, `${apiDomainName}.json`)
201
+ : undefined,
202
+ domainNamePath: domainName
203
+ ? path_1.default.join(projectPath, `${domainName}.json`)
204
+ : undefined,
205
+ };
206
+ };
@@ -1,2 +1,2 @@
1
- export declare const queryParser: (collectionName: string, query: any, constants: any[], externalParams: any, currentUser: any, timezone: string, searchObj: any, refCollectionFieldsInItems: any, searchQueryTypeObj: any, currentTenant: any, currentUserSetting: any, currentSubTenant: any, lookupConfig: any, rowLevelSecurityFilter: any) => Promise<any>;
1
+ export declare const queryParser: (collectionName: string, query: any, constants: any[], externalParams: any, currentUser: any | undefined, timezone: string, searchObj: any | undefined, refCollectionFieldsInItems: any | undefined, searchQueryTypeObj: any | undefined, currentTenant: any | undefined, currentUserSetting: any | undefined, currentSubTenant: any | undefined, lookupConfig: any | undefined, rowLevelSecurityFilter: any) => Promise<any>;
2
2
  export declare const isEntityInCondition: (value: any) => boolean;