alepha 0.11.6 → 0.11.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +15 -100
- package/api/files.d.ts +172 -173
- package/api/jobs.d.ts +220 -183
- package/api/notifications.d.ts +98 -99
- package/api/users.d.ts +497 -498
- package/command.d.ts +1 -1
- package/core.d.ts +90 -63
- package/datetime.d.ts +3 -28
- package/devtools.d.ts +166 -322
- package/email.d.ts +4 -4
- package/logger.d.ts +5 -6
- package/package.json +50 -57
- package/postgres.d.ts +23 -26
- package/react/form.d.ts +4 -1
- package/react.d.ts +31 -29
- package/redis.d.ts +10 -10
- package/security.d.ts +4 -4
- package/server/health.d.ts +17 -18
- package/server.d.ts +20 -20
- package/vite.d.ts +2 -2
- package/ui.cjs +0 -8
- package/ui.d.ts +0 -786
- package/ui.js +0 -1
package/api/jobs.d.ts
CHANGED
|
@@ -3,84 +3,82 @@ import { Alepha, Async, Descriptor, KIND, Static } from "alepha";
|
|
|
3
3
|
import "alepha/server/security";
|
|
4
4
|
import * as _alepha_postgres0 from "alepha/postgres";
|
|
5
5
|
import * as _alepha_server0 from "alepha/server";
|
|
6
|
-
import * as _alepha_logger0 from "alepha/logger";
|
|
7
6
|
import { DateTime, DateTimeProvider } from "alepha/datetime";
|
|
8
|
-
import
|
|
7
|
+
import { LockDescriptor } from "alepha/lock";
|
|
9
8
|
import { CronProvider } from "alepha/scheduler";
|
|
10
|
-
import * as
|
|
11
|
-
import * as dayjs0 from "dayjs";
|
|
9
|
+
import * as typebox152 from "typebox";
|
|
12
10
|
|
|
13
11
|
//#region src/schemas/jobExecutionQuerySchema.d.ts
|
|
14
|
-
declare const jobExecutionQuerySchema:
|
|
15
|
-
page:
|
|
16
|
-
size:
|
|
17
|
-
sort:
|
|
18
|
-
status:
|
|
19
|
-
job:
|
|
12
|
+
declare const jobExecutionQuerySchema: typebox152.TObject<{
|
|
13
|
+
page: typebox152.TOptional<typebox152.TInteger>;
|
|
14
|
+
size: typebox152.TOptional<typebox152.TInteger>;
|
|
15
|
+
sort: typebox152.TOptional<typebox152.TString>;
|
|
16
|
+
status: typebox152.TOptional<typebox152.TUnsafe<"STARTED" | "FAILED" | "COMPLETED">>;
|
|
17
|
+
job: typebox152.TOptional<typebox152.TString>;
|
|
20
18
|
}>;
|
|
21
19
|
type JobExecutionQuery = Static<typeof jobExecutionQuerySchema>;
|
|
22
20
|
//#endregion
|
|
23
21
|
//#region src/services/JobService.d.ts
|
|
24
22
|
declare class JobService {
|
|
25
23
|
protected readonly alepha: Alepha;
|
|
26
|
-
protected readonly executionRepository: _alepha_postgres0.Repository<
|
|
27
|
-
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
28
|
-
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
29
|
-
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
30
|
-
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
31
|
-
finishedAt:
|
|
32
|
-
job:
|
|
33
|
-
status:
|
|
34
|
-
error:
|
|
35
|
-
logs:
|
|
36
|
-
level:
|
|
37
|
-
message:
|
|
38
|
-
service:
|
|
39
|
-
module:
|
|
40
|
-
context:
|
|
41
|
-
app:
|
|
42
|
-
data:
|
|
43
|
-
timestamp:
|
|
24
|
+
protected readonly executionRepository: _alepha_postgres0.Repository<typebox152.TObject<{
|
|
25
|
+
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_PRIMARY_KEY>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
26
|
+
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TInteger, typeof _alepha_postgres0.PG_VERSION>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
27
|
+
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_CREATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
28
|
+
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_UPDATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
29
|
+
finishedAt: typebox152.TOptional<typebox152.TString>;
|
|
30
|
+
job: typebox152.TString;
|
|
31
|
+
status: typebox152.TUnsafe<"STARTED" | "FAILED" | "COMPLETED">;
|
|
32
|
+
error: typebox152.TOptional<typebox152.TString>;
|
|
33
|
+
logs: typebox152.TOptional<typebox152.TArray<typebox152.TObject<{
|
|
34
|
+
level: typebox152.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
35
|
+
message: typebox152.TString;
|
|
36
|
+
service: typebox152.TString;
|
|
37
|
+
module: typebox152.TString;
|
|
38
|
+
context: typebox152.TOptional<typebox152.TString>;
|
|
39
|
+
app: typebox152.TOptional<typebox152.TString>;
|
|
40
|
+
data: typebox152.TOptional<typebox152.TAny>;
|
|
41
|
+
timestamp: typebox152.TString;
|
|
44
42
|
}>>>;
|
|
45
43
|
}>>;
|
|
46
44
|
getJobs(): Promise<string[]>;
|
|
47
|
-
getJobExecutions(query?: JobExecutionQuery): Promise<_alepha_core1.Page<_alepha_postgres0.PgStatic<
|
|
48
|
-
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
49
|
-
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
50
|
-
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
51
|
-
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
52
|
-
finishedAt:
|
|
53
|
-
job:
|
|
54
|
-
status:
|
|
55
|
-
error:
|
|
56
|
-
logs:
|
|
57
|
-
level:
|
|
58
|
-
message:
|
|
59
|
-
service:
|
|
60
|
-
module:
|
|
61
|
-
context:
|
|
62
|
-
app:
|
|
63
|
-
data:
|
|
64
|
-
timestamp:
|
|
45
|
+
getJobExecutions(query?: JobExecutionQuery): Promise<_alepha_core1.Page<_alepha_postgres0.PgStatic<typebox152.TObject<{
|
|
46
|
+
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_PRIMARY_KEY>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
47
|
+
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TInteger, typeof _alepha_postgres0.PG_VERSION>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
48
|
+
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_CREATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
49
|
+
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_UPDATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
50
|
+
finishedAt: typebox152.TOptional<typebox152.TString>;
|
|
51
|
+
job: typebox152.TString;
|
|
52
|
+
status: typebox152.TUnsafe<"STARTED" | "FAILED" | "COMPLETED">;
|
|
53
|
+
error: typebox152.TOptional<typebox152.TString>;
|
|
54
|
+
logs: typebox152.TOptional<typebox152.TArray<typebox152.TObject<{
|
|
55
|
+
level: typebox152.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
56
|
+
message: typebox152.TString;
|
|
57
|
+
service: typebox152.TString;
|
|
58
|
+
module: typebox152.TString;
|
|
59
|
+
context: typebox152.TOptional<typebox152.TString>;
|
|
60
|
+
app: typebox152.TOptional<typebox152.TString>;
|
|
61
|
+
data: typebox152.TOptional<typebox152.TAny>;
|
|
62
|
+
timestamp: typebox152.TString;
|
|
65
63
|
}>>>;
|
|
66
|
-
}>, _alepha_postgres0.PgRelationMap<
|
|
67
|
-
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
68
|
-
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
69
|
-
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
70
|
-
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
71
|
-
finishedAt:
|
|
72
|
-
job:
|
|
73
|
-
status:
|
|
74
|
-
error:
|
|
75
|
-
logs:
|
|
76
|
-
level:
|
|
77
|
-
message:
|
|
78
|
-
service:
|
|
79
|
-
module:
|
|
80
|
-
context:
|
|
81
|
-
app:
|
|
82
|
-
data:
|
|
83
|
-
timestamp:
|
|
64
|
+
}>, _alepha_postgres0.PgRelationMap<typebox152.TObject<{
|
|
65
|
+
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_PRIMARY_KEY>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
66
|
+
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TInteger, typeof _alepha_postgres0.PG_VERSION>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
67
|
+
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_CREATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
68
|
+
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_UPDATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
69
|
+
finishedAt: typebox152.TOptional<typebox152.TString>;
|
|
70
|
+
job: typebox152.TString;
|
|
71
|
+
status: typebox152.TUnsafe<"STARTED" | "FAILED" | "COMPLETED">;
|
|
72
|
+
error: typebox152.TOptional<typebox152.TString>;
|
|
73
|
+
logs: typebox152.TOptional<typebox152.TArray<typebox152.TObject<{
|
|
74
|
+
level: typebox152.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
75
|
+
message: typebox152.TString;
|
|
76
|
+
service: typebox152.TString;
|
|
77
|
+
module: typebox152.TString;
|
|
78
|
+
context: typebox152.TOptional<typebox152.TString>;
|
|
79
|
+
app: typebox152.TOptional<typebox152.TString>;
|
|
80
|
+
data: typebox152.TOptional<typebox152.TAny>;
|
|
81
|
+
timestamp: typebox152.TString;
|
|
84
82
|
}>>>;
|
|
85
83
|
}>>>>>;
|
|
86
84
|
triggerJob(name: string): Promise<{
|
|
@@ -94,116 +92,87 @@ declare class JobController {
|
|
|
94
92
|
protected readonly group: string;
|
|
95
93
|
protected readonly jobService: JobService;
|
|
96
94
|
readonly getJobs: _alepha_server0.ActionDescriptorFn<{
|
|
97
|
-
response:
|
|
95
|
+
response: typebox152.TArray<typebox152.TString>;
|
|
98
96
|
}>;
|
|
99
97
|
readonly getJobExecutions: _alepha_server0.ActionDescriptorFn<{
|
|
100
|
-
query:
|
|
101
|
-
page:
|
|
102
|
-
size:
|
|
103
|
-
sort:
|
|
104
|
-
status:
|
|
105
|
-
job:
|
|
98
|
+
query: typebox152.TObject<{
|
|
99
|
+
page: typebox152.TOptional<typebox152.TInteger>;
|
|
100
|
+
size: typebox152.TOptional<typebox152.TInteger>;
|
|
101
|
+
sort: typebox152.TOptional<typebox152.TString>;
|
|
102
|
+
status: typebox152.TOptional<typebox152.TUnsafe<"STARTED" | "FAILED" | "COMPLETED">>;
|
|
103
|
+
job: typebox152.TOptional<typebox152.TString>;
|
|
106
104
|
}>;
|
|
107
|
-
response: _alepha_core1.TPage<
|
|
108
|
-
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
109
|
-
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
110
|
-
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
111
|
-
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
112
|
-
finishedAt:
|
|
113
|
-
job:
|
|
114
|
-
status:
|
|
115
|
-
error:
|
|
116
|
-
logs:
|
|
117
|
-
level:
|
|
118
|
-
message:
|
|
119
|
-
service:
|
|
120
|
-
module:
|
|
121
|
-
context:
|
|
122
|
-
app:
|
|
123
|
-
data:
|
|
124
|
-
timestamp:
|
|
105
|
+
response: _alepha_core1.TPage<typebox152.TObject<{
|
|
106
|
+
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_PRIMARY_KEY>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
107
|
+
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TInteger, typeof _alepha_postgres0.PG_VERSION>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
108
|
+
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_CREATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
109
|
+
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_UPDATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
110
|
+
finishedAt: typebox152.TOptional<typebox152.TString>;
|
|
111
|
+
job: typebox152.TString;
|
|
112
|
+
status: typebox152.TUnsafe<"STARTED" | "FAILED" | "COMPLETED">;
|
|
113
|
+
error: typebox152.TOptional<typebox152.TString>;
|
|
114
|
+
logs: typebox152.TOptional<typebox152.TArray<typebox152.TObject<{
|
|
115
|
+
level: typebox152.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
116
|
+
message: typebox152.TString;
|
|
117
|
+
service: typebox152.TString;
|
|
118
|
+
module: typebox152.TString;
|
|
119
|
+
context: typebox152.TOptional<typebox152.TString>;
|
|
120
|
+
app: typebox152.TOptional<typebox152.TString>;
|
|
121
|
+
data: typebox152.TOptional<typebox152.TAny>;
|
|
122
|
+
timestamp: typebox152.TString;
|
|
125
123
|
}>>>;
|
|
126
124
|
}>>;
|
|
127
125
|
}>;
|
|
128
126
|
readonly triggerJob: _alepha_server0.ActionDescriptorFn<{
|
|
129
|
-
body:
|
|
130
|
-
name:
|
|
127
|
+
body: typebox152.TObject<{
|
|
128
|
+
name: typebox152.TString;
|
|
131
129
|
}>;
|
|
132
|
-
response:
|
|
133
|
-
ok:
|
|
134
|
-
id:
|
|
135
|
-
count:
|
|
130
|
+
response: typebox152.TObject<{
|
|
131
|
+
ok: typebox152.TBoolean;
|
|
132
|
+
id: typebox152.TOptional<typebox152.TUnion<[typebox152.TString, typebox152.TInteger]>>;
|
|
133
|
+
count: typebox152.TOptional<typebox152.TNumber>;
|
|
136
134
|
}>;
|
|
137
135
|
}>;
|
|
138
136
|
}
|
|
139
137
|
//#endregion
|
|
140
|
-
//#region src/
|
|
141
|
-
/**
|
|
142
|
-
* Job descriptor - a drop-in replacement for $scheduler with built-in execution tracking.
|
|
143
|
-
*/
|
|
144
|
-
declare const $job: {
|
|
145
|
-
(options: JobDescriptorOptions): JobDescriptor;
|
|
146
|
-
[KIND]: typeof JobDescriptor;
|
|
147
|
-
};
|
|
148
|
-
type JobDescriptorOptions = {
|
|
149
|
-
/**
|
|
150
|
-
* Function to run on schedule.
|
|
151
|
-
*/
|
|
152
|
-
handler: (args: JobHandlerArguments) => Async<void>;
|
|
153
|
-
/**
|
|
154
|
-
* Name of the job. Defaults to the function name.
|
|
155
|
-
*/
|
|
156
|
-
name?: string;
|
|
157
|
-
/**
|
|
158
|
-
* Optional description of the job.
|
|
159
|
-
*/
|
|
160
|
-
description?: string;
|
|
161
|
-
/**
|
|
162
|
-
* Cron expression to run the job.
|
|
163
|
-
*/
|
|
164
|
-
cron?: string;
|
|
165
|
-
/**
|
|
166
|
-
* If true, the job will be locked and only one instance will run at a time.
|
|
167
|
-
* You probably need to import {@link AlephaLockRedis} for distributed locking.
|
|
168
|
-
*
|
|
169
|
-
* @default true
|
|
170
|
-
*/
|
|
171
|
-
lock?: boolean;
|
|
172
|
-
};
|
|
138
|
+
//#region src/providers/JobProvider.d.ts
|
|
173
139
|
declare const envSchema: _alepha_core1.TObject<{
|
|
174
140
|
JOB_PREFIX: _alepha_core1.TOptional<_alepha_core1.TString>;
|
|
175
141
|
}>;
|
|
176
142
|
declare module "alepha" {
|
|
177
143
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
178
144
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Provider for job management and execution.
|
|
147
|
+
* Handles job lifecycle, execution tracking, log capturing, and event emission.
|
|
148
|
+
*/
|
|
149
|
+
declare class JobProvider {
|
|
184
150
|
protected readonly alepha: Alepha;
|
|
185
151
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
186
152
|
protected readonly cronProvider: CronProvider;
|
|
187
153
|
protected readonly executionRepository: _alepha_postgres0.Repository<_alepha_core1.TObject<{
|
|
188
154
|
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<_alepha_core1.TString, typeof _alepha_postgres0.PG_PRIMARY_KEY>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
189
|
-
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
190
|
-
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
191
|
-
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
192
|
-
finishedAt: _alepha_core1.TOptional<
|
|
155
|
+
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TInteger, typeof _alepha_postgres0.PG_VERSION>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
156
|
+
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<_alepha_core1.TString, typeof _alepha_postgres0.PG_CREATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
157
|
+
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<_alepha_core1.TString, typeof _alepha_postgres0.PG_UPDATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
158
|
+
finishedAt: _alepha_core1.TOptional<_alepha_core1.TString>;
|
|
193
159
|
job: _alepha_core1.TString;
|
|
194
|
-
status:
|
|
160
|
+
status: typebox152.TUnsafe<"STARTED" | "FAILED" | "COMPLETED">;
|
|
195
161
|
error: _alepha_core1.TOptional<_alepha_core1.TString>;
|
|
196
|
-
logs: _alepha_core1.TOptional<
|
|
197
|
-
level:
|
|
162
|
+
logs: _alepha_core1.TOptional<typebox152.TArray<_alepha_core1.TObject<{
|
|
163
|
+
level: typebox152.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
198
164
|
message: _alepha_core1.TString;
|
|
199
165
|
service: _alepha_core1.TString;
|
|
200
166
|
module: _alepha_core1.TString;
|
|
201
167
|
context: _alepha_core1.TOptional<_alepha_core1.TString>;
|
|
202
168
|
app: _alepha_core1.TOptional<_alepha_core1.TString>;
|
|
203
|
-
data: _alepha_core1.TOptional<
|
|
204
|
-
timestamp:
|
|
169
|
+
data: _alepha_core1.TOptional<typebox152.TAny>;
|
|
170
|
+
timestamp: _alepha_core1.TString;
|
|
205
171
|
}>>>;
|
|
206
172
|
}>>;
|
|
173
|
+
protected readonly env: {
|
|
174
|
+
JOB_PREFIX?: string | undefined;
|
|
175
|
+
};
|
|
207
176
|
protected readonly logs: Map<string, {
|
|
208
177
|
context?: string | undefined;
|
|
209
178
|
app?: string | undefined;
|
|
@@ -212,66 +181,134 @@ declare class JobDescriptor extends Descriptor<JobDescriptorOptions> {
|
|
|
212
181
|
message: string;
|
|
213
182
|
service: string;
|
|
214
183
|
module: string;
|
|
215
|
-
timestamp:
|
|
184
|
+
timestamp: string;
|
|
216
185
|
}[]>;
|
|
186
|
+
protected readonly jobs: Map<string, JobRegistration>;
|
|
187
|
+
/**
|
|
188
|
+
* Register and set up a job for execution (called during descriptor initialization).
|
|
189
|
+
*/
|
|
190
|
+
registerJob(options: Job): JobRegistration;
|
|
191
|
+
/**
|
|
192
|
+
* Trigger a job by name.
|
|
193
|
+
*/
|
|
194
|
+
triggerJob(jobName: string): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* Execute a job handler (called by the job descriptor).
|
|
197
|
+
*/
|
|
198
|
+
executeJob(jobName: string, handler: (args: {
|
|
199
|
+
now: DateTime;
|
|
200
|
+
}) => Async<void>): Promise<void>;
|
|
201
|
+
}
|
|
202
|
+
interface Job {
|
|
203
|
+
/**
|
|
204
|
+
* Name of the job.
|
|
205
|
+
*/
|
|
206
|
+
name: string;
|
|
207
|
+
/**
|
|
208
|
+
* Optional description of the job.
|
|
209
|
+
*/
|
|
210
|
+
description?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Function to run on schedule.
|
|
213
|
+
*/
|
|
214
|
+
handler: (args: {
|
|
215
|
+
now: DateTime;
|
|
216
|
+
}) => Async<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Cron expression to run the job.
|
|
219
|
+
*/
|
|
220
|
+
cron?: string;
|
|
221
|
+
/**
|
|
222
|
+
* If true, the job will be locked and only one instance will run at a time.
|
|
223
|
+
* You probably need to import {@link AlephaLockRedis} for distributed locking.
|
|
224
|
+
*
|
|
225
|
+
* @default true
|
|
226
|
+
*/
|
|
227
|
+
lock?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Optional prefix for job lock keys.
|
|
230
|
+
*/
|
|
231
|
+
lockPrefix?: string;
|
|
232
|
+
}
|
|
233
|
+
interface JobRegistration {
|
|
234
|
+
name: string;
|
|
235
|
+
options: Job;
|
|
236
|
+
lockDescriptor: LockDescriptor<() => Promise<void>> | null;
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region src/descriptors/$job.d.ts
|
|
240
|
+
/**
|
|
241
|
+
* Job descriptor - a drop-in replacement for $scheduler with built-in execution tracking.
|
|
242
|
+
*/
|
|
243
|
+
declare const $job: {
|
|
244
|
+
(options: JobDescriptorOptions): JobDescriptor;
|
|
245
|
+
[KIND]: typeof JobDescriptor;
|
|
246
|
+
};
|
|
247
|
+
type JobDescriptorOptions = Omit<Job, "name"> & {
|
|
248
|
+
/**
|
|
249
|
+
* Name of the job. Defaults to the descriptor property name.
|
|
250
|
+
*/
|
|
251
|
+
name?: string;
|
|
252
|
+
};
|
|
253
|
+
declare class JobDescriptor extends Descriptor<JobDescriptorOptions> {
|
|
254
|
+
protected readonly jobProvider: JobProvider;
|
|
217
255
|
get name(): string;
|
|
218
256
|
protected onInit(): void;
|
|
219
257
|
trigger(): Promise<void>;
|
|
220
|
-
protected jobLock: _alepha_lock0.LockDescriptor<(args: JobHandlerArguments) => Promise<void>>;
|
|
221
258
|
}
|
|
222
259
|
interface JobHandlerArguments {
|
|
223
260
|
now: DateTime;
|
|
224
261
|
}
|
|
225
262
|
//#endregion
|
|
226
263
|
//#region src/entities/jobExecutions.d.ts
|
|
227
|
-
declare const jobExecutions: _alepha_postgres0.EntityDescriptor<
|
|
228
|
-
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
229
|
-
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
230
|
-
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
231
|
-
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
232
|
-
finishedAt:
|
|
233
|
-
job:
|
|
234
|
-
status:
|
|
235
|
-
error:
|
|
236
|
-
logs:
|
|
237
|
-
level:
|
|
238
|
-
message:
|
|
239
|
-
service:
|
|
240
|
-
module:
|
|
241
|
-
context:
|
|
242
|
-
app:
|
|
243
|
-
data:
|
|
244
|
-
timestamp:
|
|
264
|
+
declare const jobExecutions: _alepha_postgres0.EntityDescriptor<typebox152.TObject<{
|
|
265
|
+
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_PRIMARY_KEY>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
266
|
+
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TInteger, typeof _alepha_postgres0.PG_VERSION>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
267
|
+
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_CREATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
268
|
+
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_UPDATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
269
|
+
finishedAt: typebox152.TOptional<typebox152.TString>;
|
|
270
|
+
job: typebox152.TString;
|
|
271
|
+
status: typebox152.TUnsafe<"STARTED" | "FAILED" | "COMPLETED">;
|
|
272
|
+
error: typebox152.TOptional<typebox152.TString>;
|
|
273
|
+
logs: typebox152.TOptional<typebox152.TArray<typebox152.TObject<{
|
|
274
|
+
level: typebox152.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
275
|
+
message: typebox152.TString;
|
|
276
|
+
service: typebox152.TString;
|
|
277
|
+
module: typebox152.TString;
|
|
278
|
+
context: typebox152.TOptional<typebox152.TString>;
|
|
279
|
+
app: typebox152.TOptional<typebox152.TString>;
|
|
280
|
+
data: typebox152.TOptional<typebox152.TAny>;
|
|
281
|
+
timestamp: typebox152.TString;
|
|
245
282
|
}>>>;
|
|
246
283
|
}>>;
|
|
247
284
|
type JobExecutionEntity = Static<typeof jobExecutions.schema>;
|
|
248
285
|
//#endregion
|
|
249
286
|
//#region src/schemas/jobExecutionResourceSchema.d.ts
|
|
250
|
-
declare const jobExecutionResourceSchema:
|
|
251
|
-
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
252
|
-
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
253
|
-
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
254
|
-
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<
|
|
255
|
-
finishedAt:
|
|
256
|
-
job:
|
|
257
|
-
status:
|
|
258
|
-
error:
|
|
259
|
-
logs:
|
|
260
|
-
level:
|
|
261
|
-
message:
|
|
262
|
-
service:
|
|
263
|
-
module:
|
|
264
|
-
context:
|
|
265
|
-
app:
|
|
266
|
-
data:
|
|
267
|
-
timestamp:
|
|
287
|
+
declare const jobExecutionResourceSchema: typebox152.TObject<{
|
|
288
|
+
id: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_PRIMARY_KEY>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
289
|
+
version: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TInteger, typeof _alepha_postgres0.PG_VERSION>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
290
|
+
createdAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_CREATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
291
|
+
updatedAt: _alepha_postgres0.PgAttr<_alepha_postgres0.PgAttr<typebox152.TString, typeof _alepha_postgres0.PG_UPDATED_AT>, typeof _alepha_postgres0.PG_DEFAULT>;
|
|
292
|
+
finishedAt: typebox152.TOptional<typebox152.TString>;
|
|
293
|
+
job: typebox152.TString;
|
|
294
|
+
status: typebox152.TUnsafe<"STARTED" | "FAILED" | "COMPLETED">;
|
|
295
|
+
error: typebox152.TOptional<typebox152.TString>;
|
|
296
|
+
logs: typebox152.TOptional<typebox152.TArray<typebox152.TObject<{
|
|
297
|
+
level: typebox152.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
298
|
+
message: typebox152.TString;
|
|
299
|
+
service: typebox152.TString;
|
|
300
|
+
module: typebox152.TString;
|
|
301
|
+
context: typebox152.TOptional<typebox152.TString>;
|
|
302
|
+
app: typebox152.TOptional<typebox152.TString>;
|
|
303
|
+
data: typebox152.TOptional<typebox152.TAny>;
|
|
304
|
+
timestamp: typebox152.TString;
|
|
268
305
|
}>>>;
|
|
269
306
|
}>;
|
|
270
307
|
type JobExecutionResource = Static<typeof jobExecutionResourceSchema>;
|
|
271
308
|
//#endregion
|
|
272
309
|
//#region src/schemas/triggerJobSchema.d.ts
|
|
273
|
-
declare const triggerJobSchema:
|
|
274
|
-
name:
|
|
310
|
+
declare const triggerJobSchema: typebox152.TObject<{
|
|
311
|
+
name: typebox152.TString;
|
|
275
312
|
}>;
|
|
276
313
|
type TriggerJob = Static<typeof triggerJobSchema>;
|
|
277
314
|
//#endregion
|
|
@@ -286,5 +323,5 @@ type TriggerJob = Static<typeof triggerJobSchema>;
|
|
|
286
323
|
*/
|
|
287
324
|
declare const AlephaApiJobs: _alepha_core1.Service<_alepha_core1.Module>;
|
|
288
325
|
//#endregion
|
|
289
|
-
export { $job, AlephaApiJobs, JobController, JobDescriptor, JobDescriptorOptions, JobExecutionEntity, JobExecutionQuery, JobExecutionResource, JobHandlerArguments, JobService, TriggerJob, jobExecutionQuerySchema, jobExecutionResourceSchema, jobExecutions, triggerJobSchema };
|
|
326
|
+
export { $job, AlephaApiJobs, Job, JobController, JobDescriptor, JobDescriptorOptions, JobExecutionEntity, JobExecutionQuery, JobExecutionResource, JobHandlerArguments, JobProvider, JobRegistration, JobService, TriggerJob, jobExecutionQuerySchema, jobExecutionResourceSchema, jobExecutions, triggerJobSchema };
|
|
290
327
|
//# sourceMappingURL=index.d.ts.map
|