@friggframework/core 2.0.0--canary.517.095e3f6.0 → 2.0.0--canary.517.06fe141.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.
Files changed (30) hide show
  1. package/admin-scripts/index.js +11 -11
  2. package/admin-scripts/repositories/{admin-process-repository-documentdb.js → admin-script-execution-repository-documentdb.js} +4 -4
  3. package/admin-scripts/repositories/{admin-process-repository-factory.js → admin-script-execution-repository-factory.js} +14 -14
  4. package/admin-scripts/repositories/{admin-process-repository-interface.js → admin-script-execution-repository-interface.js} +19 -19
  5. package/admin-scripts/repositories/{admin-process-repository-mongo.js → admin-script-execution-repository-mongo.js} +24 -24
  6. package/admin-scripts/repositories/{admin-process-repository-postgres.js → admin-script-execution-repository-postgres.js} +33 -33
  7. package/application/commands/admin-script-commands.js +35 -35
  8. package/application/commands/integration-commands.js +43 -4
  9. package/generated/prisma-mongodb/edge.js +8 -15
  10. package/generated/prisma-mongodb/index-browser.js +5 -5
  11. package/generated/prisma-mongodb/index.d.ts +480 -494
  12. package/generated/prisma-mongodb/index.js +8 -15
  13. package/generated/prisma-mongodb/package.json +1 -1
  14. package/generated/prisma-mongodb/schema.prisma +6 -14
  15. package/generated/prisma-mongodb/wasm.js +8 -15
  16. package/generated/prisma-postgresql/edge.js +7 -14
  17. package/generated/prisma-postgresql/index-browser.js +4 -4
  18. package/generated/prisma-postgresql/index.d.ts +699 -713
  19. package/generated/prisma-postgresql/index.js +7 -14
  20. package/generated/prisma-postgresql/package.json +1 -1
  21. package/generated/prisma-postgresql/schema.prisma +6 -14
  22. package/generated/prisma-postgresql/wasm.js +7 -14
  23. package/integrations/repositories/integration-repository-documentdb.js +12 -0
  24. package/integrations/repositories/integration-repository-interface.js +14 -0
  25. package/integrations/repositories/integration-repository-mongo.js +36 -0
  26. package/integrations/repositories/integration-repository-postgres.js +39 -0
  27. package/integrations/tests/doubles/test-integration-repository.js +11 -0
  28. package/package.json +5 -5
  29. package/prisma-mongodb/schema.prisma +6 -14
  30. package/prisma-postgresql/schema.prisma +6 -14
@@ -16,16 +16,16 @@
16
16
  */
17
17
 
18
18
  // Repository Interfaces
19
- const { AdminProcessRepositoryInterface } = require('./repositories/admin-process-repository-interface');
19
+ const { AdminScriptExecutionRepositoryInterface } = require('./repositories/admin-script-execution-repository-interface');
20
20
  const { ScriptScheduleRepositoryInterface } = require('./repositories/script-schedule-repository-interface');
21
21
 
22
22
  // Repository Factories
23
23
  const {
24
- createAdminProcessRepository,
25
- AdminProcessRepositoryMongo,
26
- AdminProcessRepositoryPostgres,
27
- AdminProcessRepositoryDocumentDB,
28
- } = require('./repositories/admin-process-repository-factory');
24
+ createAdminScriptExecutionRepository,
25
+ AdminScriptExecutionRepositoryMongo,
26
+ AdminScriptExecutionRepositoryPostgres,
27
+ AdminScriptExecutionRepositoryDocumentDB,
28
+ } = require('./repositories/admin-script-execution-repository-factory');
29
29
  const {
30
30
  createScriptScheduleRepository,
31
31
  ScriptScheduleRepositoryMongo,
@@ -35,17 +35,17 @@ const {
35
35
 
36
36
  module.exports = {
37
37
  // Repository Interfaces
38
- AdminProcessRepositoryInterface,
38
+ AdminScriptExecutionRepositoryInterface,
39
39
  ScriptScheduleRepositoryInterface,
40
40
 
41
41
  // Repository Factories (primary exports for use cases)
42
- createAdminProcessRepository,
42
+ createAdminScriptExecutionRepository,
43
43
  createScriptScheduleRepository,
44
44
 
45
45
  // Concrete Implementations (for testing)
46
- AdminProcessRepositoryMongo,
47
- AdminProcessRepositoryPostgres,
48
- AdminProcessRepositoryDocumentDB,
46
+ AdminScriptExecutionRepositoryMongo,
47
+ AdminScriptExecutionRepositoryPostgres,
48
+ AdminScriptExecutionRepositoryDocumentDB,
49
49
  ScriptScheduleRepositoryMongo,
50
50
  ScriptScheduleRepositoryPostgres,
51
51
  ScriptScheduleRepositoryDocumentDB,
@@ -1,6 +1,6 @@
1
1
  const {
2
- AdminProcessRepositoryMongo,
3
- } = require('./admin-process-repository-mongo');
2
+ AdminScriptExecutionRepositoryMongo,
3
+ } = require('./admin-script-execution-repository-mongo');
4
4
 
5
5
  /**
6
6
  * DocumentDB Admin Process Repository Adapter
@@ -12,10 +12,10 @@ const {
12
12
  * - IDs are strings with ObjectId format
13
13
  * - All operations identical to MongoDB implementation
14
14
  */
15
- class AdminProcessRepositoryDocumentDB extends AdminProcessRepositoryMongo {
15
+ class AdminScriptExecutionRepositoryDocumentDB extends AdminScriptExecutionRepositoryMongo {
16
16
  constructor() {
17
17
  super();
18
18
  }
19
19
  }
20
20
 
21
- module.exports = { AdminProcessRepositoryDocumentDB };
21
+ module.exports = { AdminScriptExecutionRepositoryDocumentDB };
@@ -1,8 +1,8 @@
1
- const { AdminProcessRepositoryMongo } = require('./admin-process-repository-mongo');
2
- const { AdminProcessRepositoryPostgres } = require('./admin-process-repository-postgres');
1
+ const { AdminScriptExecutionRepositoryMongo } = require('./admin-script-execution-repository-mongo');
2
+ const { AdminScriptExecutionRepositoryPostgres } = require('./admin-script-execution-repository-postgres');
3
3
  const {
4
- AdminProcessRepositoryDocumentDB,
5
- } = require('./admin-process-repository-documentdb');
4
+ AdminScriptExecutionRepositoryDocumentDB,
5
+ } = require('./admin-script-execution-repository-documentdb');
6
6
  const config = require('../../database/config');
7
7
 
8
8
  /**
@@ -16,24 +16,24 @@ const config = require('../../database/config');
16
16
  *
17
17
  * Usage:
18
18
  * ```javascript
19
- * const repository = createAdminProcessRepository();
19
+ * const repository = createAdminScriptExecutionRepository();
20
20
  * ```
21
21
  *
22
- * @returns {AdminProcessRepositoryInterface} Configured repository adapter
22
+ * @returns {AdminScriptExecutionRepositoryInterface} Configured repository adapter
23
23
  * @throws {Error} If database type is not supported
24
24
  */
25
- function createAdminProcessRepository() {
25
+ function createAdminScriptExecutionRepository() {
26
26
  const dbType = config.DB_TYPE;
27
27
 
28
28
  switch (dbType) {
29
29
  case 'mongodb':
30
- return new AdminProcessRepositoryMongo();
30
+ return new AdminScriptExecutionRepositoryMongo();
31
31
 
32
32
  case 'postgresql':
33
- return new AdminProcessRepositoryPostgres();
33
+ return new AdminScriptExecutionRepositoryPostgres();
34
34
 
35
35
  case 'documentdb':
36
- return new AdminProcessRepositoryDocumentDB();
36
+ return new AdminScriptExecutionRepositoryDocumentDB();
37
37
 
38
38
  default:
39
39
  throw new Error(
@@ -43,9 +43,9 @@ function createAdminProcessRepository() {
43
43
  }
44
44
 
45
45
  module.exports = {
46
- createAdminProcessRepository,
46
+ createAdminScriptExecutionRepository,
47
47
  // Export adapters for direct testing
48
- AdminProcessRepositoryMongo,
49
- AdminProcessRepositoryPostgres,
50
- AdminProcessRepositoryDocumentDB,
48
+ AdminScriptExecutionRepositoryMongo,
49
+ AdminScriptExecutionRepositoryPostgres,
50
+ AdminScriptExecutionRepositoryDocumentDB,
51
51
  };
@@ -12,13 +12,13 @@
12
12
  * - Database migrations
13
13
  * - Scheduled maintenance tasks
14
14
  *
15
- * The AdminProcess model uses a flexible JSON storage pattern:
15
+ * The AdminScriptExecution model uses a flexible JSON storage pattern:
16
16
  * - context: Input parameters, trigger info, audit data, script version
17
17
  * - results: Output data, logs, metrics, error details
18
18
  *
19
19
  * @abstract
20
20
  */
21
- class AdminProcessRepositoryInterface {
21
+ class AdminScriptExecutionRepositoryInterface {
22
22
  /**
23
23
  * Create a new admin process record
24
24
  *
@@ -37,8 +37,8 @@ class AdminProcessRepositoryInterface {
37
37
  * @returns {Promise<Object>} The created process record
38
38
  * @abstract
39
39
  */
40
- async createProcess({ name, type, context }) {
41
- throw new Error('Method createProcess must be implemented by subclass');
40
+ async createExecution({ name, type, context }) {
41
+ throw new Error('Method createExecution must be implemented by subclass');
42
42
  }
43
43
 
44
44
  /**
@@ -48,9 +48,9 @@ class AdminProcessRepositoryInterface {
48
48
  * @returns {Promise<Object|null>} The process record or null if not found
49
49
  * @abstract
50
50
  */
51
- async findProcessById(id) {
51
+ async findExecutionById(id) {
52
52
  throw new Error(
53
- 'Method findProcessById must be implemented by subclass'
53
+ 'Method findExecutionById must be implemented by subclass'
54
54
  );
55
55
  }
56
56
 
@@ -67,9 +67,9 @@ class AdminProcessRepositoryInterface {
67
67
  * @returns {Promise<Array>} Array of process records
68
68
  * @abstract
69
69
  */
70
- async findProcessesByName(name, options = {}) {
70
+ async findExecutionsByName(name, options = {}) {
71
71
  throw new Error(
72
- 'Method findProcessesByName must be implemented by subclass'
72
+ 'Method findExecutionsByName must be implemented by subclass'
73
73
  );
74
74
  }
75
75
 
@@ -85,9 +85,9 @@ class AdminProcessRepositoryInterface {
85
85
  * @returns {Promise<Array>} Array of process records
86
86
  * @abstract
87
87
  */
88
- async findProcessesByState(state, options = {}) {
88
+ async findExecutionsByState(state, options = {}) {
89
89
  throw new Error(
90
- 'Method findProcessesByState must be implemented by subclass'
90
+ 'Method findExecutionsByState must be implemented by subclass'
91
91
  );
92
92
  }
93
93
 
@@ -99,9 +99,9 @@ class AdminProcessRepositoryInterface {
99
99
  * @returns {Promise<Object>} Updated process record
100
100
  * @abstract
101
101
  */
102
- async updateProcessState(id, state) {
102
+ async updateExecutionState(id, state) {
103
103
  throw new Error(
104
- 'Method updateProcessState must be implemented by subclass'
104
+ 'Method updateExecutionState must be implemented by subclass'
105
105
  );
106
106
  }
107
107
 
@@ -123,9 +123,9 @@ class AdminProcessRepositoryInterface {
123
123
  * @returns {Promise<Object>} Updated process record
124
124
  * @abstract
125
125
  */
126
- async updateProcessResults(id, results) {
126
+ async updateExecutionResults(id, results) {
127
127
  throw new Error(
128
- 'Method updateProcessResults must be implemented by subclass'
128
+ 'Method updateExecutionResults must be implemented by subclass'
129
129
  );
130
130
  }
131
131
 
@@ -141,9 +141,9 @@ class AdminProcessRepositoryInterface {
141
141
  * @returns {Promise<Object>} Updated process record
142
142
  * @abstract
143
143
  */
144
- async appendProcessLog(id, logEntry) {
144
+ async appendExecutionLog(id, logEntry) {
145
145
  throw new Error(
146
- 'Method appendProcessLog must be implemented by subclass'
146
+ 'Method appendExecutionLog must be implemented by subclass'
147
147
  );
148
148
  }
149
149
 
@@ -155,11 +155,11 @@ class AdminProcessRepositoryInterface {
155
155
  * @returns {Promise<Object>} Deletion result with count
156
156
  * @abstract
157
157
  */
158
- async deleteProcessesOlderThan(date) {
158
+ async deleteExecutionsOlderThan(date) {
159
159
  throw new Error(
160
- 'Method deleteProcessesOlderThan must be implemented by subclass'
160
+ 'Method deleteExecutionsOlderThan must be implemented by subclass'
161
161
  );
162
162
  }
163
163
  }
164
164
 
165
- module.exports = { AdminProcessRepositoryInterface };
165
+ module.exports = { AdminScriptExecutionRepositoryInterface };
@@ -1,7 +1,7 @@
1
1
  const { prisma } = require('../../database/prisma');
2
2
  const {
3
- AdminProcessRepositoryInterface,
4
- } = require('./admin-process-repository-interface');
3
+ AdminScriptExecutionRepositoryInterface,
4
+ } = require('./admin-script-execution-repository-interface');
5
5
 
6
6
  /**
7
7
  * MongoDB Admin Process Repository Adapter
@@ -12,7 +12,7 @@ const {
12
12
  * - context and results are Json objects
13
13
  * - Stores logs in results.logs array
14
14
  */
15
- class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
15
+ class AdminScriptExecutionRepositoryMongo extends AdminScriptExecutionRepositoryInterface {
16
16
  constructor() {
17
17
  super();
18
18
  this.prisma = prisma;
@@ -27,7 +27,7 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
27
27
  * @param {Object} [params.context] - Context data
28
28
  * @returns {Promise<Object>} The created process record
29
29
  */
30
- async createProcess({ name, type, context = {} }) {
30
+ async createExecution({ name, type, context = {} }) {
31
31
  const data = {
32
32
  name,
33
33
  type,
@@ -35,7 +35,7 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
35
35
  results: { logs: [] },
36
36
  };
37
37
 
38
- const process = await this.prisma.adminProcess.create({
38
+ const process = await this.prisma.adminScriptExecution.create({
39
39
  data,
40
40
  });
41
41
 
@@ -48,8 +48,8 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
48
48
  * @param {string} id - The process ID
49
49
  * @returns {Promise<Object|null>} The process record or null if not found
50
50
  */
51
- async findProcessById(id) {
52
- const process = await this.prisma.adminProcess.findUnique({
51
+ async findExecutionById(id) {
52
+ const process = await this.prisma.adminScriptExecution.findUnique({
53
53
  where: { id },
54
54
  });
55
55
 
@@ -67,7 +67,7 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
67
67
  * @param {string} [options.sortOrder] - Sort order ('asc' or 'desc')
68
68
  * @returns {Promise<Array>} Array of process records
69
69
  */
70
- async findProcessesByName(name, options = {}) {
70
+ async findExecutionsByName(name, options = {}) {
71
71
  const {
72
72
  limit,
73
73
  offset,
@@ -79,7 +79,7 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
79
79
  const where = { name };
80
80
  if (state) where.state = state;
81
81
 
82
- const processes = await this.prisma.adminProcess.findMany({
82
+ const processes = await this.prisma.adminScriptExecution.findMany({
83
83
  where,
84
84
  orderBy: { [sortBy]: sortOrder },
85
85
  take: limit,
@@ -100,7 +100,7 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
100
100
  * @param {string} [options.sortOrder] - Sort order ('asc' or 'desc')
101
101
  * @returns {Promise<Array>} Array of process records
102
102
  */
103
- async findProcessesByState(state, options = {}) {
103
+ async findExecutionsByState(state, options = {}) {
104
104
  const {
105
105
  limit,
106
106
  offset,
@@ -108,7 +108,7 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
108
108
  sortOrder = 'desc',
109
109
  } = options;
110
110
 
111
- const processes = await this.prisma.adminProcess.findMany({
111
+ const processes = await this.prisma.adminScriptExecution.findMany({
112
112
  where: { state },
113
113
  orderBy: { [sortBy]: sortOrder },
114
114
  take: limit,
@@ -125,8 +125,8 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
125
125
  * @param {string} state - New state value
126
126
  * @returns {Promise<Object>} Updated process record
127
127
  */
128
- async updateProcessState(id, state) {
129
- const process = await this.prisma.adminProcess.update({
128
+ async updateExecutionState(id, state) {
129
+ const process = await this.prisma.adminScriptExecution.update({
130
130
  where: { id },
131
131
  data: { state },
132
132
  });
@@ -142,14 +142,14 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
142
142
  * @param {Object} results - Results data to merge
143
143
  * @returns {Promise<Object>} Updated process record
144
144
  */
145
- async updateProcessResults(id, results) {
145
+ async updateExecutionResults(id, results) {
146
146
  // Get current process to merge results
147
- const currentProcess = await this.prisma.adminProcess.findUnique({
147
+ const currentProcess = await this.prisma.adminScriptExecution.findUnique({
148
148
  where: { id },
149
149
  });
150
150
 
151
151
  if (!currentProcess) {
152
- throw new Error(`AdminProcess ${id} not found`);
152
+ throw new Error(`AdminScriptExecution ${id} not found`);
153
153
  }
154
154
 
155
155
  // Merge new results with existing results
@@ -158,7 +158,7 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
158
158
  ...results,
159
159
  };
160
160
 
161
- const process = await this.prisma.adminProcess.update({
161
+ const process = await this.prisma.adminScriptExecution.update({
162
162
  where: { id },
163
163
  data: { results: mergedResults },
164
164
  });
@@ -177,14 +177,14 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
177
177
  * @param {string} logEntry.timestamp - ISO timestamp
178
178
  * @returns {Promise<Object>} Updated process record
179
179
  */
180
- async appendProcessLog(id, logEntry) {
180
+ async appendExecutionLog(id, logEntry) {
181
181
  // Get current process
182
- const process = await this.prisma.adminProcess.findUnique({
182
+ const process = await this.prisma.adminScriptExecution.findUnique({
183
183
  where: { id },
184
184
  });
185
185
 
186
186
  if (!process) {
187
- throw new Error(`AdminProcess ${id} not found`);
187
+ throw new Error(`AdminScriptExecution ${id} not found`);
188
188
  }
189
189
 
190
190
  // Get current results and logs
@@ -193,7 +193,7 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
193
193
  logs.push(logEntry);
194
194
 
195
195
  // Update with new logs array in results
196
- const updated = await this.prisma.adminProcess.update({
196
+ const updated = await this.prisma.adminScriptExecution.update({
197
197
  where: { id },
198
198
  data: { results: { ...results, logs } },
199
199
  });
@@ -208,8 +208,8 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
208
208
  * @param {Date} date - Delete processes older than this date
209
209
  * @returns {Promise<Object>} Deletion result with count
210
210
  */
211
- async deleteProcessesOlderThan(date) {
212
- const result = await this.prisma.adminProcess.deleteMany({
211
+ async deleteExecutionsOlderThan(date) {
212
+ const result = await this.prisma.adminScriptExecution.deleteMany({
213
213
  where: {
214
214
  createdAt: {
215
215
  lt: date,
@@ -224,4 +224,4 @@ class AdminProcessRepositoryMongo extends AdminProcessRepositoryInterface {
224
224
  }
225
225
  }
226
226
 
227
- module.exports = { AdminProcessRepositoryMongo };
227
+ module.exports = { AdminScriptExecutionRepositoryMongo };
@@ -1,7 +1,7 @@
1
1
  const { prisma } = require('../../database/prisma');
2
2
  const {
3
- AdminProcessRepositoryInterface,
4
- } = require('./admin-process-repository-interface');
3
+ AdminScriptExecutionRepositoryInterface,
4
+ } = require('./admin-script-execution-repository-interface');
5
5
 
6
6
  /**
7
7
  * PostgreSQL Admin Process Repository Adapter
@@ -13,7 +13,7 @@ const {
13
13
  * - All returned IDs are converted to strings for application layer consistency
14
14
  * - context and results are Json objects
15
15
  */
16
- class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
16
+ class AdminScriptExecutionRepositoryPostgres extends AdminScriptExecutionRepositoryInterface {
17
17
  constructor() {
18
18
  super();
19
19
  this.prisma = prisma;
@@ -41,12 +41,12 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
41
41
  * @param {Object|null} process - Process object from database
42
42
  * @returns {Object|null} Process with string IDs
43
43
  */
44
- _convertProcessIds(process) {
44
+ _convertExecutionIds(process) {
45
45
  if (!process) return process;
46
46
  return {
47
47
  ...process,
48
48
  id: process.id?.toString(),
49
- parentProcessId: process.parentProcessId?.toString(),
49
+ parentExecutionId: process.parentExecutionId?.toString(),
50
50
  };
51
51
  }
52
52
 
@@ -59,7 +59,7 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
59
59
  * @param {Object} [params.context] - Context data
60
60
  * @returns {Promise<Object>} The created process record with string ID
61
61
  */
62
- async createProcess({ name, type, context = {} }) {
62
+ async createExecution({ name, type, context = {} }) {
63
63
  const data = {
64
64
  name,
65
65
  type,
@@ -67,11 +67,11 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
67
67
  results: { logs: [] },
68
68
  };
69
69
 
70
- const process = await this.prisma.adminProcess.create({
70
+ const process = await this.prisma.adminScriptExecution.create({
71
71
  data,
72
72
  });
73
73
 
74
- return this._convertProcessIds(process);
74
+ return this._convertExecutionIds(process);
75
75
  }
76
76
 
77
77
  /**
@@ -80,13 +80,13 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
80
80
  * @param {string|number} id - The process ID
81
81
  * @returns {Promise<Object|null>} The process record with string ID or null if not found
82
82
  */
83
- async findProcessById(id) {
83
+ async findExecutionById(id) {
84
84
  const intId = this._convertId(id);
85
- const process = await this.prisma.adminProcess.findUnique({
85
+ const process = await this.prisma.adminScriptExecution.findUnique({
86
86
  where: { id: intId },
87
87
  });
88
88
 
89
- return this._convertProcessIds(process);
89
+ return this._convertExecutionIds(process);
90
90
  }
91
91
 
92
92
  /**
@@ -100,7 +100,7 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
100
100
  * @param {string} [options.sortOrder] - Sort order ('asc' or 'desc')
101
101
  * @returns {Promise<Array>} Array of process records with string IDs
102
102
  */
103
- async findProcessesByName(name, options = {}) {
103
+ async findExecutionsByName(name, options = {}) {
104
104
  const {
105
105
  limit,
106
106
  offset,
@@ -112,14 +112,14 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
112
112
  const where = { name };
113
113
  if (state) where.state = state;
114
114
 
115
- const processes = await this.prisma.adminProcess.findMany({
115
+ const processes = await this.prisma.adminScriptExecution.findMany({
116
116
  where,
117
117
  orderBy: { [sortBy]: sortOrder },
118
118
  take: limit,
119
119
  skip: offset,
120
120
  });
121
121
 
122
- return processes.map((process) => this._convertProcessIds(process));
122
+ return processes.map((process) => this._convertExecutionIds(process));
123
123
  }
124
124
 
125
125
  /**
@@ -133,7 +133,7 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
133
133
  * @param {string} [options.sortOrder] - Sort order ('asc' or 'desc')
134
134
  * @returns {Promise<Array>} Array of process records with string IDs
135
135
  */
136
- async findProcessesByState(state, options = {}) {
136
+ async findExecutionsByState(state, options = {}) {
137
137
  const {
138
138
  limit,
139
139
  offset,
@@ -141,14 +141,14 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
141
141
  sortOrder = 'desc',
142
142
  } = options;
143
143
 
144
- const processes = await this.prisma.adminProcess.findMany({
144
+ const processes = await this.prisma.adminScriptExecution.findMany({
145
145
  where: { state },
146
146
  orderBy: { [sortBy]: sortOrder },
147
147
  take: limit,
148
148
  skip: offset,
149
149
  });
150
150
 
151
- return processes.map((process) => this._convertProcessIds(process));
151
+ return processes.map((process) => this._convertExecutionIds(process));
152
152
  }
153
153
 
154
154
  /**
@@ -158,14 +158,14 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
158
158
  * @param {string} state - New state value
159
159
  * @returns {Promise<Object>} Updated process record with string ID
160
160
  */
161
- async updateProcessState(id, state) {
161
+ async updateExecutionState(id, state) {
162
162
  const intId = this._convertId(id);
163
- const process = await this.prisma.adminProcess.update({
163
+ const process = await this.prisma.adminScriptExecution.update({
164
164
  where: { id: intId },
165
165
  data: { state },
166
166
  });
167
167
 
168
- return this._convertProcessIds(process);
168
+ return this._convertExecutionIds(process);
169
169
  }
170
170
 
171
171
  /**
@@ -176,16 +176,16 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
176
176
  * @param {Object} results - Results data to merge
177
177
  * @returns {Promise<Object>} Updated process record with string ID
178
178
  */
179
- async updateProcessResults(id, results) {
179
+ async updateExecutionResults(id, results) {
180
180
  const intId = this._convertId(id);
181
181
 
182
182
  // Get current process to merge results
183
- const currentProcess = await this.prisma.adminProcess.findUnique({
183
+ const currentProcess = await this.prisma.adminScriptExecution.findUnique({
184
184
  where: { id: intId },
185
185
  });
186
186
 
187
187
  if (!currentProcess) {
188
- throw new Error(`AdminProcess ${id} not found`);
188
+ throw new Error(`AdminScriptExecution ${id} not found`);
189
189
  }
190
190
 
191
191
  // Merge new results with existing results
@@ -194,12 +194,12 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
194
194
  ...results,
195
195
  };
196
196
 
197
- const process = await this.prisma.adminProcess.update({
197
+ const process = await this.prisma.adminScriptExecution.update({
198
198
  where: { id: intId },
199
199
  data: { results: mergedResults },
200
200
  });
201
201
 
202
- return this._convertProcessIds(process);
202
+ return this._convertExecutionIds(process);
203
203
  }
204
204
 
205
205
  /**
@@ -213,16 +213,16 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
213
213
  * @param {string} logEntry.timestamp - ISO timestamp
214
214
  * @returns {Promise<Object>} Updated process record with string ID
215
215
  */
216
- async appendProcessLog(id, logEntry) {
216
+ async appendExecutionLog(id, logEntry) {
217
217
  const intId = this._convertId(id);
218
218
 
219
219
  // Get current process
220
- const process = await this.prisma.adminProcess.findUnique({
220
+ const process = await this.prisma.adminScriptExecution.findUnique({
221
221
  where: { id: intId },
222
222
  });
223
223
 
224
224
  if (!process) {
225
- throw new Error(`AdminProcess ${id} not found`);
225
+ throw new Error(`AdminScriptExecution ${id} not found`);
226
226
  }
227
227
 
228
228
  // Get current results and logs
@@ -231,12 +231,12 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
231
231
  logs.push(logEntry);
232
232
 
233
233
  // Update with new logs array in results
234
- const updated = await this.prisma.adminProcess.update({
234
+ const updated = await this.prisma.adminScriptExecution.update({
235
235
  where: { id: intId },
236
236
  data: { results: { ...results, logs } },
237
237
  });
238
238
 
239
- return this._convertProcessIds(updated);
239
+ return this._convertExecutionIds(updated);
240
240
  }
241
241
 
242
242
  /**
@@ -246,8 +246,8 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
246
246
  * @param {Date} date - Delete processes older than this date
247
247
  * @returns {Promise<Object>} Deletion result with count
248
248
  */
249
- async deleteProcessesOlderThan(date) {
250
- const result = await this.prisma.adminProcess.deleteMany({
249
+ async deleteExecutionsOlderThan(date) {
250
+ const result = await this.prisma.adminScriptExecution.deleteMany({
251
251
  where: {
252
252
  createdAt: {
253
253
  lt: date,
@@ -262,4 +262,4 @@ class AdminProcessRepositoryPostgres extends AdminProcessRepositoryInterface {
262
262
  }
263
263
  }
264
264
 
265
- module.exports = { AdminProcessRepositoryPostgres };
265
+ module.exports = { AdminScriptExecutionRepositoryPostgres };