cc-core-cli 1.0.133 → 1.0.135

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 (72) hide show
  1. package/bin/index.js +4 -4
  2. package/package.json +1 -1
  3. package/template/admin_v3/src/pages/api/database/[type]/index.ts +23 -0
  4. package/template/admin_v3/src/pages/api/layout_chart_widget/[name]/index.ts +18 -0
  5. package/template/admin_v3/src/pages/api/layout_chart_widget/compare_matrix.ts +17 -0
  6. package/template/admin_v3/src/pages/api/redis/[type]/[connect]/index.ts +20 -0
  7. package/template/admin_v3/src/pages/api/redis/custom.ts +10 -0
  8. package/template/admin_v3/src/pages/api/setting/module/[code].ts +34 -0
  9. package/template/admin_v3/src/pages/api/template/[type].ts +21 -0
  10. package/template/admin_v3/src/pages/api/template/bulk_print/[id].ts +15 -0
  11. package/template/admin_v3/src/pages/api/template/print/[id]/[doc_ref].ts +11 -0
  12. package/template/core_v3/Dockerfile +60 -0
  13. package/template/core_v3/_env +12 -0
  14. package/template/core_v3/_gitignore +52 -0
  15. package/template/core_v3/_npmrc +1 -0
  16. package/template/core_v3/buildspec.yml +29 -0
  17. package/template/core_v3/docker-compose.yml +11 -0
  18. package/template/core_v3/jest.config.js +43 -0
  19. package/template/core_v3/newrelic.sh +15 -0
  20. package/template/core_v3/package.json +54 -0
  21. package/template/core_v3/post-install.js +34 -0
  22. package/template/core_v3/sonar-project.properties +27 -0
  23. package/template/core_v3/src/app.controller.ts +39 -0
  24. package/template/core_v3/src/app.module.ts +174 -0
  25. package/template/core_v3/src/app.service.ts +21 -0
  26. package/template/core_v3/src/app_cluster.service.ts +61 -0
  27. package/template/core_v3/src/core/core.controller.ts +444 -0
  28. package/template/core_v3/src/core/core.module.ts +90 -0
  29. package/template/core_v3/src/core/core.service.ts +737 -0
  30. package/template/core_v3/src/core/setting/_settings/about.layout.json +105 -0
  31. package/template/core_v3/src/core/setting/_settings/cache.layout.json +309 -0
  32. package/template/core_v3/src/core/setting/_settings/global_login.json +299 -0
  33. package/template/core_v3/src/core/setting/_settings/header_footer.json +83 -0
  34. package/template/core_v3/src/core/setting/_settings/import_export.layout.json +69 -0
  35. package/template/core_v3/src/core/setting/_settings/list_detail.json +685 -0
  36. package/template/core_v3/src/core/setting/_settings/logs.layout.json +39 -0
  37. package/template/core_v3/src/core/setting/_settings/queue.layout.json +63 -0
  38. package/template/core_v3/src/core/setting/_settings/schedule.layout.json +132 -0
  39. package/template/core_v3/src/core/setting/_settings/security.layout.json +1110 -0
  40. package/template/core_v3/src/core/setting/_settings/storage.layout.json +158 -0
  41. package/template/core_v3/src/core/setting/_settings/swagger.layout.json +128 -0
  42. package/template/core_v3/src/core/setting/_settings/toast.json +344 -0
  43. package/template/core_v3/src/main.ts +308 -0
  44. package/template/core_v3/src/modules/modules.ts +16 -0
  45. package/template/core_v3/src/private.controller.ts +18 -0
  46. package/template/core_v3/storage/documents/index.html +14 -0
  47. package/template/core_v3/storage/public/system/menu/icons/company.svg +1 -0
  48. package/template/core_v3/storage/public/system/menu/icons/deploy.svg +2 -0
  49. package/template/core_v3/storage/public/system/menu/icons/entities.svg +55 -0
  50. package/template/core_v3/storage/public/system/menu/icons/files.svg +1 -0
  51. package/template/core_v3/storage/public/system/menu/icons/gateway.svg +1 -0
  52. package/template/core_v3/storage/public/system/menu/icons/import-export.svg +41 -0
  53. package/template/core_v3/storage/public/system/menu/icons/integration.svg +1 -0
  54. package/template/core_v3/storage/public/system/menu/icons/master_data.svg +53 -0
  55. package/template/core_v3/storage/public/system/menu/icons/modules.svg +79 -0
  56. package/template/core_v3/storage/public/system/menu/icons/monitoring.svg +114 -0
  57. package/template/core_v3/storage/public/system/menu/icons/pipeline.svg +1 -0
  58. package/template/core_v3/storage/public/system/menu/icons/provider.svg +1 -0
  59. package/template/core_v3/storage/public/system/menu/icons/report.svg +69 -0
  60. package/template/core_v3/storage/public/system/menu/icons/schedule.svg +1 -0
  61. package/template/core_v3/storage/public/system/menu/icons/security.svg +1 -0
  62. package/template/core_v3/storage/public/system/menu/icons/storage.svg +1 -0
  63. package/template/core_v3/storage/public/system/menu/icons/template.svg +44 -0
  64. package/template/core_v3/storage/public/system/menu/icons/theme-layout.svg +1 -0
  65. package/template/core_v3/test/__mocks__/cc-core-lib.d.ts +161 -0
  66. package/template/core_v3/test/__mocks__/cc-core-lib.js +311 -0
  67. package/template/core_v3/test/__mocks__/pdf-img-convert.js +5 -0
  68. package/template/core_v3/test/jest.setup.ts +25 -0
  69. package/template/core_v3/tsconfig.build.json +4 -0
  70. package/template/core_v3/tsconfig.json +22 -0
  71. package/template/core_v3/tsconfig.test.json +17 -0
  72. package/template/core_v3/version.json +5 -0
@@ -0,0 +1,311 @@
1
+ const mongoose = require('mongoose');
2
+ const { Schema } = mongoose;
3
+ // const jest = require('jest-mock');
4
+
5
+ // ---- Mock BaseSchema ----
6
+ class BaseSchema {
7
+ constructor(definition = {}, options = {}) {
8
+ this.definition = definition;
9
+ this.options = options;
10
+ this._id = new mongoose.Types.ObjectId();
11
+ this.id = this._id.toString();
12
+ this.created_at = new Date();
13
+ this.updated_at = new Date();
14
+ this.created_by = 'test-user';
15
+ this.updated_by = 'test-user';
16
+ this.is_deleted = false;
17
+ this.is_active = true;
18
+ }
19
+
20
+ save() {
21
+ return Promise.resolve(this);
22
+ }
23
+
24
+ // Add mock schema methods
25
+ add = jest.fn();
26
+ pre = jest.fn().mockReturnThis();
27
+ post = jest.fn().mockReturnThis();
28
+ plugin = jest.fn().mockReturnThis();
29
+ index = jest.fn().mockReturnThis();
30
+ set = jest.fn().mockReturnThis();
31
+ virtual = jest.fn().mockReturnThis();
32
+ path = jest.fn().mockReturnThis();
33
+ }
34
+
35
+ // ---- Mock Services & Classes ----
36
+ class BasePipelineProvider {
37
+ constructor() {
38
+ this._settings = null;
39
+ }
40
+
41
+ async init(settings) {
42
+ this._settings = settings;
43
+ return '[PIPELINE] Initialized';
44
+ }
45
+
46
+ async process(data) {
47
+ return data;
48
+ }
49
+
50
+ async queue(data) {
51
+ return data;
52
+ }
53
+ }
54
+
55
+ class BaseService {
56
+ constructor(cls, model) {
57
+ this.cls = cls;
58
+ this.model = {
59
+ create: jest.fn().mockImplementation((data) => {
60
+ console.log('🔥 MOCK: BBaseService.model.create called:', data);
61
+ return data;
62
+ })
63
+ };
64
+ }
65
+
66
+ static prefix = '';
67
+
68
+ async find(query) {
69
+ const result = this.model.find(query);
70
+ return result.exec ? result.exec() : result;
71
+ }
72
+
73
+ async findOne(query, field, ignore) {
74
+ const result = this.model.findOne(query);
75
+ return result.exec ? result.exec() : result;
76
+ }
77
+
78
+ async findById(id) {
79
+ const result = this.model.findById(id);
80
+ return result.exec ? result.exec() : result;
81
+ }
82
+
83
+ async findByIdAndUpdate(id, update, options) {
84
+ const result = this.model.findByIdAndUpdate(id, update, options);
85
+ return result.exec ? result.exec() : result;
86
+ }
87
+
88
+ async findOneAndUpdate(query, update, options) {
89
+ const result = this.model.findOneAndUpdate(query, update, options);
90
+ return result.exec ? result.exec() : result;
91
+ }
92
+
93
+ async create(data) {
94
+ return data;
95
+ }
96
+
97
+ async update(id, data) {
98
+ return { _id: id, ...data };
99
+ }
100
+
101
+ async delete(id) {
102
+ return { _id: id, deleted: true };
103
+ }
104
+ }
105
+
106
+ class BaseModuleSettingService {
107
+ constructor(code, setting, cls) {
108
+ this.code = code;
109
+ this.setting = setting;
110
+ this.cls = cls;
111
+ }
112
+
113
+ async init() {
114
+ return 'Initialized';
115
+ }
116
+
117
+ async getSetting(key) {
118
+ // Use the injected setting service if available, otherwise return default data
119
+ if (this.setting && this.setting.getSetting) {
120
+ return await this.setting.getSetting(key);
121
+ }
122
+ return {
123
+ transaction: {
124
+ format: 'TR${ _date("YYMMDD","7h","") }',
125
+ running: 4,
126
+ },
127
+ };
128
+ }
129
+
130
+ async setSetting(data, key) {
131
+ // Use the injected setting service if available, otherwise return the data
132
+ if (this.setting && this.setting.setSetting) {
133
+ return await this.setting.setSetting(data, key);
134
+ }
135
+ return data;
136
+ }
137
+
138
+ async defaultPermission() {
139
+ return {};
140
+ }
141
+
142
+ async setPermission(permission) {
143
+ return [];
144
+ }
145
+
146
+ async getModuleConfig() {
147
+ return {
148
+ point_expiration_days: 30,
149
+ birthday_points: 100,
150
+ signup_points: 50,
151
+ programs: [
152
+ { rule_type: 'PURCHASE', points: 10, min_spend: 100, max_points: 1000 },
153
+ { rule_type: 'QR_SCAN', points: 5 },
154
+ { rule_type: 'GAME_REWARD', points: 20 },
155
+ ],
156
+ };
157
+ }
158
+
159
+ async updateModuleConfig(config) {
160
+ return config;
161
+ }
162
+
163
+ async getScheduleConfig() {
164
+ return {};
165
+ }
166
+
167
+ async updateScheduleConfig(config) {
168
+ return config;
169
+ }
170
+ }
171
+
172
+ class BaseController {
173
+ constructor(service) {
174
+ this.service = service;
175
+ }
176
+ }
177
+
178
+ // ---- Helper Mocks ----
179
+ const BaseSchemaFactory = {
180
+ createForClass: jest.fn((cls) => ({
181
+ prototype: new cls(),
182
+ })),
183
+ };
184
+
185
+ const callAddQueueInternal = jest.fn().mockResolvedValue(true);
186
+ const callCountInternalService = jest.fn().mockResolvedValue(1);
187
+ const callFindInternalService = jest.fn().mockResolvedValue({});
188
+ const callListInternalService = jest.fn().mockResolvedValue({ rows: [] });
189
+ const callCreateInternalService = jest.fn().mockResolvedValue({});
190
+ const callDeleteInternalService = jest.fn().mockResolvedValue({});
191
+ const callBulkDeleteInternalService = jest.fn().mockResolvedValue({});
192
+ const callBulkUpdateInternalService = jest.fn().mockResolvedValue({});
193
+ const callUpdateInternalService = jest.fn().mockResolvedValue({});
194
+ const callInternalService = jest.fn().mockResolvedValue({});
195
+ const callGetInternalService = jest.fn();
196
+
197
+ const transformString = jest.fn((str, data) => str);
198
+ const executeFunc = jest.fn((str, entity, data) => str);
199
+ const generateRunningNumber = jest.fn((prefix, template, running) => `${template}${running}`);
200
+ const loadEntity = jest.fn().mockResolvedValue({ id: 'test-entity' });
201
+ const getNextExecuteTime = jest.fn(() => new Date());
202
+ const transform = jest.fn((data) => data);
203
+ const generateOtp = jest.fn().mockResolvedValue({ ref: 'test-ref', otp: '123456' });
204
+ const validateOtp = jest.fn().mockResolvedValue(true);
205
+ const initQueue = jest.fn().mockResolvedValue(true);
206
+ const randomString = jest.fn((length) => 'a'.repeat(length || 8));
207
+ const convertConditionToMongoQuery = jest.fn((condition) => condition);
208
+ const addSystemSchedule = jest.fn();
209
+
210
+ // Basic decorator mock - works for both class and method decorators
211
+ const Basic = () => {
212
+ return (target, propertyKey, descriptor) => {
213
+ // If descriptor is provided, it's a method decorator
214
+ if (descriptor) {
215
+ return descriptor;
216
+ }
217
+ // Otherwise, it's a class decorator
218
+ return target;
219
+ };
220
+ };
221
+
222
+ // Public decorator mock
223
+ const Public = () => {
224
+ return (target, propertyKey, descriptor) => {
225
+ // If descriptor is provided, it's a method decorator
226
+ if (descriptor) {
227
+ return descriptor;
228
+ }
229
+ // Otherwise, it's a class decorator
230
+ return target;
231
+ };
232
+ };
233
+
234
+ class EntitiesService {
235
+ refreshSystemSchema = jest.fn().mockResolvedValue(true);
236
+ }
237
+
238
+ const SettingService = jest.fn(() => ({
239
+ getSetting: jest.fn().mockResolvedValue({}),
240
+ setSetting: jest.fn().mockResolvedValue({}),
241
+ }));
242
+
243
+ const UserPermission = {
244
+ creator: 'creator',
245
+ viewer: 'viewer',
246
+ access_denied: 'access_denied',
247
+ };
248
+
249
+ // Mock LayoutEntity (interface, so just an empty object)
250
+ const LayoutEntity = {};
251
+
252
+ // Mock WorkflowEntity (interface, so just an empty object)
253
+ const WorkflowEntity = {};
254
+
255
+ // Mock IModuleSetting (interface, so just an empty object)
256
+ const IModuleSetting = {};
257
+
258
+ // Mock PipelineExecuteDto (interface, so just an empty object)
259
+ const PipelineExecuteDto = {};
260
+
261
+ // Mock CONST object
262
+ const CONST = {
263
+ CUSTOM_PROVIDERS: [],
264
+ IGNORE_ENTITY: []
265
+ };
266
+
267
+ // ---- Export Everything ----
268
+ module.exports = {
269
+ BaseSchema,
270
+ BaseService,
271
+ BaseController,
272
+ BasePipelineProvider,
273
+ BaseModuleSettingService,
274
+ BaseSchemaFactory,
275
+ callAddQueueInternal,
276
+ callCountInternalService,
277
+ callFindInternalService,
278
+ callListInternalService,
279
+ callCreateInternalService,
280
+ callDeleteInternalService,
281
+ callBulkDeleteInternalService,
282
+ callBulkUpdateInternalService,
283
+ callUpdateInternalService,
284
+ callInternalService,
285
+ callGetInternalService,
286
+ loadEntity,
287
+ getNextExecuteTime,
288
+ transformString,
289
+ executeFunc,
290
+ generateRunningNumber,
291
+ EntitiesService,
292
+ SettingService,
293
+ UserPermission,
294
+ LayoutEntity,
295
+ WorkflowEntity,
296
+ IModuleSetting,
297
+ PipelineExecuteDto,
298
+ CONST,
299
+ transform,
300
+ generateOtp,
301
+ validateOtp,
302
+ initQueue,
303
+ randomString,
304
+ Basic,
305
+ Public,
306
+ convertConditionToMongoQuery,
307
+ addSystemSchedule
308
+ };
309
+
310
+ // Optional: ESM Compatibility
311
+ module.exports.default = module.exports;
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ convert: jest.fn().mockResolvedValue([]),
3
+ fromPath: jest.fn().mockResolvedValue([]),
4
+ fromBuffer: jest.fn().mockResolvedValue([])
5
+ };
@@ -0,0 +1,25 @@
1
+ import mongoose from 'mongoose';
2
+
3
+ // Configure Mongoose
4
+ mongoose.set('strictQuery', false);
5
+
6
+ // Mock console methods to reduce noise in tests
7
+ global.console = {
8
+ ...console,
9
+ error: jest.fn(),
10
+ warn: jest.fn(),
11
+ info: jest.fn(),
12
+ };
13
+
14
+ // Mock cc-core-lib
15
+ jest.mock('@shopstack/cc-core-lib/core');
16
+
17
+ // Clear mocks before each test
18
+ beforeEach(() => {
19
+ jest.clearAllMocks();
20
+ });
21
+
22
+ // Disconnect Mongoose after all tests
23
+ afterAll(async () => {
24
+ await mongoose.disconnect();
25
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "exclude": ["node_modules", "test", "dist", "media", "temp", "**/*spec.ts","*.bak"]
4
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "declaration": true,
5
+ "removeComments": true,
6
+ "emitDecoratorMetadata": true,
7
+ "experimentalDecorators": true,
8
+ "target": "es2017",
9
+ "sourceMap": true,
10
+ "outDir": "./dist",
11
+ "baseUrl": "./",
12
+ "incremental": true,
13
+ "allowSyntheticDefaultImports": true,
14
+ "resolveJsonModule": true,
15
+ "skipLibCheck": true
16
+ },
17
+ "exclude": [
18
+ "node_modules",
19
+ "dist",
20
+ "media"
21
+ ]
22
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "experimentalDecorators": true,
5
+ "emitDecoratorMetadata": true,
6
+ "paths": {
7
+ "@shopstack/cc-core-lib/core": [
8
+ "test/__mocks__/cc-core-lib"
9
+ ]
10
+ }
11
+ },
12
+ "include": [
13
+ "**/*.spec.ts",
14
+ "**/__tests__/**/*",
15
+ "test/__mocks__/*.d.ts"
16
+ ]
17
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "major": "1",
3
+ "minor": "0",
4
+ "patch": "0"
5
+ }