cc-core-cli 1.0.130 → 1.0.133

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 (154) hide show
  1. package/bin/index.js +6 -6
  2. package/package.json +1 -1
  3. package/template/admin_v3/Dockerfile +15 -0
  4. package/template/admin_v3/README.md +1 -0
  5. package/template/admin_v3/_env +10 -0
  6. package/template/admin_v3/_gitignore +5 -0
  7. package/template/admin_v3/_npmrc +1 -0
  8. package/template/admin_v3/docker-compose.yml +11 -0
  9. package/template/admin_v3/next-env.d.ts +5 -0
  10. package/template/admin_v3/package.json +37 -0
  11. package/template/admin_v3/postcss.config.js +6 -0
  12. package/template/admin_v3/public/images/component/barchart.svg +20 -0
  13. package/template/admin_v3/public/images/component/bubble_chart.svg +17 -0
  14. package/template/admin_v3/public/images/component/button.svg +17 -0
  15. package/template/admin_v3/public/images/component/calendar.svg +63 -0
  16. package/template/admin_v3/public/images/component/checkbox.svg +25 -0
  17. package/template/admin_v3/public/images/component/color_picker.svg +25 -0
  18. package/template/admin_v3/public/images/component/cron_tab.svg +33 -0
  19. package/template/admin_v3/public/images/component/currency.svg +34 -0
  20. package/template/admin_v3/public/images/component/custom_fields.svg +34 -0
  21. package/template/admin_v3/public/images/component/data_table.svg +101 -0
  22. package/template/admin_v3/public/images/component/date_picker.svg +47 -0
  23. package/template/admin_v3/public/images/component/donut.svg +23 -0
  24. package/template/admin_v3/public/images/component/edit_table.svg +96 -0
  25. package/template/admin_v3/public/images/component/entity_field.svg +36 -0
  26. package/template/admin_v3/public/images/component/entity_layout.svg +40 -0
  27. package/template/admin_v3/public/images/component/entity_list.svg +88 -0
  28. package/template/admin_v3/public/images/component/file.svg +36 -0
  29. package/template/admin_v3/public/images/component/hidden_field.svg +34 -0
  30. package/template/admin_v3/public/images/component/image.svg +38 -0
  31. package/template/admin_v3/public/images/component/input.svg +34 -0
  32. package/template/admin_v3/public/images/component/input_icon.svg +13 -0
  33. package/template/admin_v3/public/images/component/input_number.svg +34 -0
  34. package/template/admin_v3/public/images/component/input_translate.svg +47 -0
  35. package/template/admin_v3/public/images/component/json.svg +31 -0
  36. package/template/admin_v3/public/images/component/label.svg +11 -0
  37. package/template/admin_v3/public/images/component/line_chart.svg +19 -0
  38. package/template/admin_v3/public/images/component/matrix_table.svg +34 -0
  39. package/template/admin_v3/public/images/component/mixed_chart.svg +25 -0
  40. package/template/admin_v3/public/images/component/polar_chart.svg +33 -0
  41. package/template/admin_v3/public/images/component/radio.svg +24 -0
  42. package/template/admin_v3/public/images/component/redar_chart.svg +17 -0
  43. package/template/admin_v3/public/images/component/scatter_chart.svg +25 -0
  44. package/template/admin_v3/public/images/component/select.svg +34 -0
  45. package/template/admin_v3/public/images/component/summary_box.svg +31 -0
  46. package/template/admin_v3/public/images/component/switch.svg +12 -0
  47. package/template/admin_v3/public/images/component/translate.svg +35 -0
  48. package/template/admin_v3/public/images/component/tree.svg +78 -0
  49. package/template/admin_v3/public/images/default-profile.png +0 -0
  50. package/template/admin_v3/public/images/empty-data.png +0 -0
  51. package/template/admin_v3/public/images/file.png +0 -0
  52. package/template/admin_v3/public/images/forgot-step-1.png +0 -0
  53. package/template/admin_v3/public/images/forgot-step-2.png +0 -0
  54. package/template/admin_v3/public/images/forgot-step-3.png +0 -0
  55. package/template/admin_v3/public/images/form.png +0 -0
  56. package/template/admin_v3/public/images/info-panel.png +0 -0
  57. package/template/admin_v3/public/images/panel.png +0 -0
  58. package/template/admin_v3/public/images/split.svg +1 -0
  59. package/template/admin_v3/public/images/stack.png +0 -0
  60. package/template/admin_v3/public/images/type-all.png +0 -0
  61. package/template/admin_v3/public/images/type-boolean.png +0 -0
  62. package/template/admin_v3/public/images/type-date.png +0 -0
  63. package/template/admin_v3/public/images/type-file.png +0 -0
  64. package/template/admin_v3/public/images/type-image.png +0 -0
  65. package/template/admin_v3/public/images/type-json.png +0 -0
  66. package/template/admin_v3/public/images/type-number.png +0 -0
  67. package/template/admin_v3/public/images/type-options.png +0 -0
  68. package/template/admin_v3/public/images/type-password.png +0 -0
  69. package/template/admin_v3/public/images/type-related.png +0 -0
  70. package/template/admin_v3/public/images/type-string.png +0 -0
  71. package/template/admin_v3/public/images/type-trash.png +0 -0
  72. package/template/admin_v3/public/images/type-unknown.png +0 -0
  73. package/template/admin_v3/public/images/upload.png +0 -0
  74. package/template/admin_v3/public/private-image-worker.js +24 -0
  75. package/template/admin_v3/src/pages/[...url_key].tsx +9 -0
  76. package/template/admin_v3/src/pages/_app.tsx +22 -0
  77. package/template/admin_v3/src/pages/activate.tsx +9 -0
  78. package/template/admin_v3/src/pages/api/auth/activate_account/confirm.ts +13 -0
  79. package/template/admin_v3/src/pages/api/auth/activate_account/index.ts +13 -0
  80. package/template/admin_v3/src/pages/api/auth/activate_account/resend.ts +13 -0
  81. package/template/admin_v3/src/pages/api/auth/activate_account/set_password.ts +17 -0
  82. package/template/admin_v3/src/pages/api/auth/authen/confirm.ts +24 -0
  83. package/template/admin_v3/src/pages/api/auth/authen/resend.ts +13 -0
  84. package/template/admin_v3/src/pages/api/auth/callback/index.ts +24 -0
  85. package/template/admin_v3/src/pages/api/auth/forgot_password/confirm.ts +13 -0
  86. package/template/admin_v3/src/pages/api/auth/forgot_password/index.ts +13 -0
  87. package/template/admin_v3/src/pages/api/auth/forgot_password/resend.ts +13 -0
  88. package/template/admin_v3/src/pages/api/auth/forgot_password/reset.ts +17 -0
  89. package/template/admin_v3/src/pages/api/auth/login.ts +24 -0
  90. package/template/admin_v3/src/pages/api/auth/logout.ts +30 -0
  91. package/template/admin_v3/src/pages/api/custom/[...path].ts +16 -0
  92. package/template/admin_v3/src/pages/api/download.ts +79 -0
  93. package/template/admin_v3/src/pages/api/entity/[entity]/[id].ts +46 -0
  94. package/template/admin_v3/src/pages/api/entity/[entity]/delete.ts +18 -0
  95. package/template/admin_v3/src/pages/api/entity/[entity]/find.ts +17 -0
  96. package/template/admin_v3/src/pages/api/entity/[entity]/index.ts +30 -0
  97. package/template/admin_v3/src/pages/api/entity/[entity]/update.ts +18 -0
  98. package/template/admin_v3/src/pages/api/entity/approve/[entity]/[id].ts +19 -0
  99. package/template/admin_v3/src/pages/api/entity/schema/[entity]/index.ts +27 -0
  100. package/template/admin_v3/src/pages/api/entity/schema/[entity]/relate.ts +16 -0
  101. package/template/admin_v3/src/pages/api/entity/schema/index.ts +27 -0
  102. package/template/admin_v3/src/pages/api/import_export/example/index.ts +13 -0
  103. package/template/admin_v3/src/pages/api/import_export/execute/index.ts +13 -0
  104. package/template/admin_v3/src/pages/api/import_export/export/index.ts +13 -0
  105. package/template/admin_v3/src/pages/api/import_export/import/index.ts +13 -0
  106. package/template/admin_v3/src/pages/api/import_export/progresses/index.ts +13 -0
  107. package/template/admin_v3/src/pages/api/import_export/verify_progress/index.ts +13 -0
  108. package/template/admin_v3/src/pages/api/language/set.ts +15 -0
  109. package/template/admin_v3/src/pages/api/media/private.ts +49 -0
  110. package/template/admin_v3/src/pages/api/queue/[queue]/count.ts +17 -0
  111. package/template/admin_v3/src/pages/api/queue/[queue]/flush.ts +17 -0
  112. package/template/admin_v3/src/pages/api/queue/[queue]/flushall.ts +16 -0
  113. package/template/admin_v3/src/pages/api/queue/[queue]/index.ts +20 -0
  114. package/template/admin_v3/src/pages/api/queue/index.ts +13 -0
  115. package/template/admin_v3/src/pages/api/redis/[connect]/index.ts +0 -0
  116. package/template/admin_v3/src/pages/api/redis/index.ts +0 -0
  117. package/template/admin_v3/src/pages/api/setting/[code].ts +21 -0
  118. package/template/admin_v3/src/pages/api/system/config.ts +13 -0
  119. package/template/admin_v3/src/pages/api/system/data_source/[code].ts +17 -0
  120. package/template/admin_v3/src/pages/api/system/endpoint/[method].ts +17 -0
  121. package/template/admin_v3/src/pages/api/system/queue.ts +13 -0
  122. package/template/admin_v3/src/pages/api/system/role.ts +13 -0
  123. package/template/admin_v3/src/pages/api/user/change_password.ts +13 -0
  124. package/template/admin_v3/src/pages/api/user/filter/index.ts +13 -0
  125. package/template/admin_v3/src/pages/api/user/me.ts +24 -0
  126. package/template/admin_v3/src/pages/api/user/register.ts +13 -0
  127. package/template/admin_v3/src/pages/callback/[channel].tsx +9 -0
  128. package/template/admin_v3/src/pages/entity/[entity]/[layout]/[id].tsx +17 -0
  129. package/template/admin_v3/src/pages/entity/[entity]/[layout]/index.tsx +19 -0
  130. package/template/admin_v3/src/pages/forgot_password.tsx +9 -0
  131. package/template/admin_v3/src/pages/index.tsx +7 -0
  132. package/template/admin_v3/src/pages/login.tsx +9 -0
  133. package/template/admin_v3/src/pages/profile.tsx +9 -0
  134. package/template/admin_v3/src/pages/register.tsx +9 -0
  135. package/template/admin_v3/src/pages/setting/entities/[key].tsx +10 -0
  136. package/template/admin_v3/src/pages/setting/entities/index.tsx +10 -0
  137. package/template/admin_v3/src/pages/setting/module/[module]/[layout].tsx +16 -0
  138. package/template/admin_v3/src/pages/setting/modules.tsx +10 -0
  139. package/template/admin_v3/src/styles/global.css +101 -0
  140. package/template/admin_v3/src/styles/workflow.css +40 -0
  141. package/template/admin_v3/src/utils/color.ts +88 -0
  142. package/template/admin_v3/tailwind.config.js +57 -0
  143. package/template/admin_v3/tsconfig.json +36 -0
  144. package/template/core/_gitignore +4 -0
  145. package/template/core/buildspec.yml +29 -0
  146. package/template/core/jest.config.js +43 -0
  147. package/template/core/package.json +14 -2
  148. package/template/core/sonar-project.properties +27 -0
  149. package/template/core/test/__mocks__/cc-core-lib.d.ts +161 -0
  150. package/template/core/test/__mocks__/cc-core-lib.js +311 -0
  151. package/template/core/test/__mocks__/pdf-img-convert.js +5 -0
  152. package/template/core/test/jest.setup.ts +25 -0
  153. package/template/core/tsconfig.json +13 -13
  154. package/template/core/tsconfig.test.json +17 -0
@@ -0,0 +1,161 @@
1
+ declare module '@shopstack/cc-core-lib/core' {
2
+ import type { Mock } from 'jest-mock';
3
+
4
+ // Mocked classes
5
+ export class BaseSchema {
6
+ constructor(definition?: any, options?: any);
7
+ _id: any;
8
+ id: string;
9
+ created_at: Date;
10
+ updated_at: Date;
11
+ created_by: string;
12
+ updated_by: string;
13
+ is_deleted: boolean;
14
+ is_active: boolean;
15
+ save: () => Promise<this>;
16
+ add: Mock;
17
+ pre: Mock;
18
+ post: Mock;
19
+ plugin: Mock;
20
+ index: Mock;
21
+ set: Mock;
22
+ virtual: Mock;
23
+ path: Mock;
24
+ }
25
+
26
+ export class BasePipelineProvider {
27
+ constructor();
28
+ init(settings: any): Promise<string>;
29
+ process(data: any): Promise<any>;
30
+ queue(data: any): Promise<any>;
31
+ }
32
+
33
+ export class BaseService<T = any> {
34
+ code: string;
35
+ protected model: any;
36
+ static prefix: string;
37
+ constructor(cls: any, model: any);
38
+ find(query: any): Promise<T[]>;
39
+ findOne(query: any, field?: string[], ignore?: any): Promise<T>;
40
+ findById(id: string): Promise<T>;
41
+ findByIdAndUpdate(id: string, update: any, options?: any): Promise<T>;
42
+ findOneAndUpdate(query: any, update: any, options?: any): Promise<T>;
43
+ create(data: any): Promise<T>;
44
+ update(id: string, data: any): Promise<T>;
45
+ delete(id: string): Promise<any>;
46
+ }
47
+
48
+ export class BaseModuleSettingService {
49
+ code: string;
50
+ protected setting: any;
51
+ cls: any;
52
+ constructor(code: string, setting: any, cls: any);
53
+ init(): Promise<string>;
54
+ getSetting(key?: string): Promise<any>;
55
+ setSetting(data: any, key?: string): Promise<any>;
56
+ defaultPermission(): Promise<any>;
57
+ setPermission(permission: any): Promise<any[]>;
58
+ getModuleConfig(): Promise<any>;
59
+ updateModuleConfig(config: any): Promise<any>;
60
+ getScheduleConfig(): Promise<any>;
61
+ updateScheduleConfig(config: any): Promise<any>;
62
+ }
63
+
64
+ export interface IModuleSetting {
65
+ defaultPermission(): Promise<any>;
66
+ setPermission(permission: any): Promise<any[]>;
67
+ getSetting(key?: string): Promise<any>;
68
+ setSetting(data: any, key?: string): Promise<any>;
69
+ }
70
+
71
+ export interface PipelineExecuteDto {
72
+ [key: string]: any;
73
+ }
74
+
75
+ export const CONST: {
76
+ CUSTOM_PROVIDERS: any[];
77
+ IGNORE_ENTITY: any[];
78
+ };
79
+
80
+ export const BaseSchemaFactory: {
81
+ createForClass: Mock<any, [any]>;
82
+ };
83
+
84
+ export const callAddQueueInternal: Mock<Promise<boolean>, [string, any]>;
85
+ export const callCountInternalService: Mock<Promise<number>, [string, any]>;
86
+ export const callFindInternalService: Mock<Promise<any>, [string, string?, any?, string?, string?, any?]>;
87
+ export const callListInternalService: Mock<Promise<any>, [string, any?, any?]>;
88
+ export const callCreateInternalService: Mock<Promise<any>, [string, any, any?, boolean?]>;
89
+ export const callDeleteInternalService: Mock<Promise<any>, [string, string]>;
90
+ export const callBulkDeleteInternalService: Mock<Promise<any>, [string, string[]]>;
91
+ export const callBulkUpdateInternalService: Mock<Promise<any>, [string, any[]]>;
92
+ export const callUpdateInternalService: Mock<Promise<any>, [string, string, any]>;
93
+ export const callInternalService: Mock<Promise<any>, [string, string, any?, any?]>;
94
+ export const callGetInternalService: Mock<Promise<any>, [string, string]>;
95
+
96
+ export const transformString: Mock<string, [string, any]>;
97
+ export const executeFunc: Mock<string, [string, any, any]>;
98
+ export const generateRunningNumber: Mock<string, [string, string, number]>;
99
+ export const loadEntity: Mock<Promise<any>, [string]>;
100
+ export const getNextExecuteTime: Mock<Date, []>;
101
+ export const transform: Mock<any, [any]>;
102
+ export const generateOtp: Mock<Promise<string>, []>;
103
+ export const validateOtp: Mock<Promise<boolean>, [string, string]>;
104
+ export const initQueue: Mock<Promise<boolean>, [string, any]>;
105
+ export const randomString: Mock<string, [number?]>;
106
+ export const convertConditionToMongoQuery: Mock<any, [any]>;
107
+ export const addSystemSchedule: Mock<void, [any]>;
108
+
109
+ export interface SearchResultDto {
110
+ rows: any[];
111
+ total: number;
112
+ page: number;
113
+ limit: number;
114
+ }
115
+
116
+ export class EntitiesService {
117
+ refreshSystemSchema: Mock<Promise<boolean>, [any, any, any, any, any?]>;
118
+ }
119
+
120
+ export class SettingService {
121
+ getSetting: Mock<Promise<any>, [string?]>;
122
+ setSetting: Mock<Promise<any>, [any, string?]>;
123
+ }
124
+
125
+ export const UserPermission: {
126
+ creator: string;
127
+ viewer: string;
128
+ access_denied: string;
129
+ };
130
+
131
+ export const PointProgramRuleType: {
132
+ BIRTHDAY: string;
133
+ SPEND: string;
134
+ FIXED: string;
135
+ QR_SCAN: string;
136
+ GAME_REWARD: string;
137
+ SIGNUP: string;
138
+ };
139
+
140
+ export interface LayoutEntity {
141
+ name: string;
142
+ code: string;
143
+ type: string[];
144
+ detail: any;
145
+ list?: any;
146
+ allow_workflow_actions?: boolean;
147
+ [key: string]: any; // Allow additional properties
148
+ }
149
+
150
+ export interface WorkflowEntity {
151
+ [key: string]: any; // Allow any properties for workflow
152
+ }
153
+
154
+ export class BaseController {
155
+ constructor(service: any);
156
+ }
157
+
158
+ // Decorators
159
+ export const Basic: () => (target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => any;
160
+ export const Public: () => (target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => any;
161
+ }
@@ -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
+ });
@@ -1,18 +1,18 @@
1
1
  {
2
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,
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
16
  },
17
17
  "exclude": [
18
18
  "node_modules",
@@ -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
+ }