Skip to content

Commit 4c6cf28

Browse files
Refactor: Extract API models to separate files
Extracted classes, interfaces, enums, and type aliases from src/CrystalQuartz.Application.Client2/src/api/index.ts into individual files within the same directory. Updated the main index.ts to re-export all models from their new locations, preserving the external API of the module.
1 parent 8aeb36e commit 4c6cf28

28 files changed

+303
-263
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export enum ActivityStatusCode {
2+
Active = 0,
3+
Paused = 1,
4+
Mixed = 2,
5+
Complete = 3,
6+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { ActivityStatusCode } from './activity-status-code';
2+
3+
export class ActivityStatus {
4+
public static readonly Active = new ActivityStatus(ActivityStatusCode.Active, 'Active', 'active');
5+
public static readonly Paused = new ActivityStatus(ActivityStatusCode.Paused, 'Paused', 'paused');
6+
public static readonly Mixed = new ActivityStatus(ActivityStatusCode.Mixed, 'Mixed', 'mixed');
7+
public static readonly Complete = new ActivityStatus(
8+
ActivityStatusCode.Complete,
9+
'Complete',
10+
'complete'
11+
);
12+
13+
private static readonly _dictionary: Record<ActivityStatusCode, ActivityStatus> = {
14+
0: ActivityStatus.Active,
15+
1: ActivityStatus.Paused,
16+
2: ActivityStatus.Mixed,
17+
3: ActivityStatus.Complete,
18+
};
19+
20+
public constructor(
21+
public readonly value: number,
22+
public readonly title: string,
23+
public readonly code: string
24+
) {}
25+
26+
public static findBy(value: ActivityStatusCode): ActivityStatus {
27+
return ActivityStatus._dictionary[value];
28+
}
29+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ActivityStatus } from './activity-status';
2+
3+
export interface Activity {
4+
Name: string;
5+
Status: ActivityStatus;
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { TriggerType } from './trigger-type';
2+
3+
export interface CronTriggerType extends TriggerType {
4+
CronExpression: string;
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface EnvironmentData {
2+
SelfVersion: string;
3+
QuartzVersion: string;
4+
DotNetVersion: string;
5+
CustomCssUrl: string;
6+
TimelineSpan: number;
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export class ErrorMessage {
2+
public constructor(
3+
public readonly level: number,
4+
public readonly text: string
5+
) {}
6+
}
Lines changed: 27 additions & 263 deletions
Original file line numberDiff line numberDiff line change
@@ -1,263 +1,27 @@
1-
type ApplicationStatusByCode = { [key: string]: SchedulerStatus };
2-
3-
export class SchedulerStatus {
4-
public static readonly Offline = new SchedulerStatus(-1, 'Offline');
5-
public static readonly Empty = new SchedulerStatus(0, 'empty');
6-
public static readonly Ready = new SchedulerStatus(1, 'ready');
7-
public static readonly Started = new SchedulerStatus(2, 'started');
8-
public static readonly Shutdown = new SchedulerStatus(3, 'shutdown');
9-
10-
private static readonly _all = [
11-
SchedulerStatus.Offline,
12-
SchedulerStatus.Empty,
13-
SchedulerStatus.Ready,
14-
SchedulerStatus.Started,
15-
SchedulerStatus.Shutdown,
16-
];
17-
18-
private static readonly _dictionaryByCode: ApplicationStatusByCode = SchedulerStatus._all.reduce(
19-
(result: ApplicationStatusByCode, item: SchedulerStatus) => {
20-
result[item.code] = item;
21-
return result;
22-
},
23-
{}
24-
);
25-
26-
public constructor(
27-
public readonly value: number,
28-
public readonly code: string
29-
) {}
30-
31-
public static findByCode(code: string): SchedulerStatus | undefined {
32-
return this._dictionaryByCode[code];
33-
}
34-
}
35-
36-
export enum ActivityStatusCode {
37-
Active = 0,
38-
Paused = 1,
39-
Mixed = 2,
40-
Complete = 3,
41-
}
42-
43-
export class ActivityStatus {
44-
public static readonly Active = new ActivityStatus(ActivityStatusCode.Active, 'Active', 'active');
45-
public static readonly Paused = new ActivityStatus(ActivityStatusCode.Paused, 'Paused', 'paused');
46-
public static readonly Mixed = new ActivityStatus(ActivityStatusCode.Mixed, 'Mixed', 'mixed');
47-
public static readonly Complete = new ActivityStatus(
48-
ActivityStatusCode.Complete,
49-
'Complete',
50-
'complete'
51-
);
52-
53-
private static readonly _dictionary: Record<ActivityStatusCode, ActivityStatus> = {
54-
0: ActivityStatus.Active,
55-
1: ActivityStatus.Paused,
56-
2: ActivityStatus.Mixed,
57-
3: ActivityStatus.Complete,
58-
};
59-
60-
public constructor(
61-
public readonly value: number,
62-
public readonly title: string,
63-
public readonly code: string
64-
) {}
65-
66-
public static findBy(value: ActivityStatusCode): ActivityStatus {
67-
return ActivityStatus._dictionary[value];
68-
}
69-
}
70-
71-
export interface Activity {
72-
Name: string;
73-
Status: ActivityStatus;
74-
}
75-
76-
export interface RunningJob {
77-
FireInstanceId: string;
78-
UniqueTriggerKey: string;
79-
}
80-
81-
export interface SchedulerData {
82-
Name: string;
83-
Status: string;
84-
InstanceId: string;
85-
RunningSince: number | null;
86-
JobsTotal: number;
87-
JobsExecuted: number;
88-
ServerInstanceMarker: number;
89-
JobGroups: JobGroup[];
90-
InProgress: RunningJob[];
91-
Events: SchedulerEvent[];
92-
}
93-
94-
export interface TypeInfo {
95-
Namespace: string;
96-
Name: string;
97-
Assembly: string;
98-
}
99-
100-
export interface SchedulerDetails {
101-
InStandbyMode: boolean;
102-
JobStoreClustered: boolean;
103-
JobStoreSupportsPersistence: boolean;
104-
JobStoreType: TypeInfo | null;
105-
NumberOfJobsExecuted: number;
106-
RunningSince: number | null;
107-
SchedulerInstanceId: string;
108-
SchedulerName: string;
109-
SchedulerRemote: boolean;
110-
SchedulerType: TypeInfo | null;
111-
Shutdown: boolean;
112-
Started: boolean;
113-
ThreadPoolSize: number;
114-
ThreadPoolType: TypeInfo | null;
115-
Version: string;
116-
}
117-
118-
export interface EnvironmentData {
119-
SelfVersion: string;
120-
QuartzVersion: string;
121-
DotNetVersion: string;
122-
CustomCssUrl: string;
123-
TimelineSpan: number;
124-
}
125-
126-
export interface JobGroup extends Activity {
127-
Jobs: Job[];
128-
}
129-
130-
export interface Job extends Activity {
131-
GroupName: string;
132-
UniqueName: string;
133-
Triggers: Trigger[];
134-
}
135-
136-
export interface TriggerType {
137-
Code: string;
138-
supportedMisfireInstructions: { [index: number]: string };
139-
}
140-
141-
export interface SimpleTriggerType extends TriggerType {
142-
RepeatCount: number;
143-
RepeatInterval: number;
144-
TimesTriggered: number;
145-
}
146-
147-
export interface CronTriggerType extends TriggerType {
148-
CronExpression: string;
149-
}
150-
151-
export interface Trigger extends Activity {
152-
GroupName: string;
153-
EndDate: number | null;
154-
NextFireDate: number | null;
155-
PreviousFireDate: number | null;
156-
StartDate: number;
157-
TriggerType: TriggerType;
158-
UniqueTriggerKey: string;
159-
}
160-
161-
export type ObjectPropertyValue = {
162-
typeCode: 'object';
163-
nestedProperties: Property[];
164-
overflowed?: true;
165-
};
166-
export type EnumerablePropertyValue = {
167-
typeCode: 'enumerable';
168-
nestedValues: (PropertyValue | null)[];
169-
overflowed?: true;
170-
};
171-
export type SinglePropertyValue = { typeCode: 'single'; kind: number; rawValue: string };
172-
export type ErrorPropertyValue = { typeCode: 'error'; errorMessage: string };
173-
export type EllipsisPropertyValue = { typeCode: '...' };
174-
export type PropertyValue =
175-
| SinglePropertyValue
176-
| ErrorPropertyValue
177-
| EllipsisPropertyValue
178-
| ObjectPropertyValue
179-
| EnumerablePropertyValue;
180-
181-
export class Property {
182-
public constructor(
183-
public readonly title: string,
184-
public readonly value: PropertyValue
185-
) {}
186-
}
187-
188-
export interface JobProperties {
189-
Description: string;
190-
ConcurrentExecutionDisallowed: boolean;
191-
PersistJobDataAfterExecution: boolean;
192-
RequestsRecovery: boolean;
193-
Durable: boolean;
194-
JobType: TypeInfo;
195-
}
196-
197-
export interface JobDetails {
198-
JobDataMap: PropertyValue | null;
199-
JobDetails: JobProperties | null;
200-
}
201-
202-
export interface TriggerDetails {
203-
trigger: Trigger;
204-
jobDataMap: PropertyValue | null;
205-
secondaryData: {
206-
priority: number;
207-
misfireInstruction: number;
208-
description: string;
209-
} | null;
210-
}
211-
212-
export class NullableDate {
213-
public readonly isEmpty = this.date == null;
214-
215-
public constructor(public readonly date: number | null) {}
216-
}
217-
218-
export class ErrorMessage {
219-
public constructor(
220-
public readonly level: number,
221-
public readonly text: string
222-
) {}
223-
}
224-
225-
export class SchedulerEvent {
226-
public constructor(
227-
public readonly id: number,
228-
public readonly date: number,
229-
public readonly scope: SchedulerEventScope,
230-
public readonly eventType: SchedulerEventType,
231-
public readonly itemKey: string,
232-
public readonly fireInstanceId: string,
233-
public readonly faulted: boolean,
234-
public readonly errors: ErrorMessage[] | null
235-
) {}
236-
}
237-
238-
export interface InputType {
239-
code: string;
240-
label: string;
241-
hasVariants: boolean;
242-
}
243-
244-
export interface InputTypeVariant {
245-
value: string;
246-
label: string;
247-
}
248-
249-
export enum SchedulerEventScope {
250-
Scheduler = 0,
251-
Group = 1,
252-
Job = 2,
253-
Trigger = 3,
254-
}
255-
256-
export enum SchedulerEventType {
257-
Fired = 0,
258-
Complete = 1,
259-
Paused = 2,
260-
Resumed = 3,
261-
Standby = 4,
262-
Shutdown = 5,
263-
}
1+
export * from './scheduler-status';
2+
export * from './activity-status-code';
3+
export * from './activity-status';
4+
export * from './activity';
5+
export * from './running-job';
6+
export * from './scheduler-data';
7+
export * from './type-info';
8+
export * from './scheduler-details';
9+
export * from './environment-data';
10+
export * from './job-group';
11+
export * from './job';
12+
export * from './trigger-type';
13+
export * from './simple-trigger-type';
14+
export * from './cron-trigger-type';
15+
export * from './trigger';
16+
export * from './property-value';
17+
export * from './property';
18+
export * from './job-properties';
19+
export * from './job-details';
20+
export * from './trigger-details';
21+
export * from './nullable-date';
22+
export * from './error-message';
23+
export * from './scheduler-event';
24+
export * from './input-type';
25+
export * from './input-type-variant';
26+
export * from './scheduler-event-scope';
27+
export * from './scheduler-event-type';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface InputTypeVariant {
2+
value: string;
3+
label: string;
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface InputType {
2+
code: string;
3+
label: string;
4+
hasVariants: boolean;
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { PropertyValue } from './property-value';
2+
import { JobProperties } from './job-properties';
3+
4+
export interface JobDetails {
5+
JobDataMap: PropertyValue | null;
6+
JobDetails: JobProperties | null;
7+
}

0 commit comments

Comments
 (0)