@appconda/nextjs 1.0.130 → 1.0.132

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 (58) hide show
  1. package/dist/modules/hooks/index.d.ts +3 -0
  2. package/dist/modules/hooks/index.js +4 -0
  3. package/dist/modules/hooks/lib/Hooks.d.ts +32 -0
  4. package/dist/modules/hooks/lib/Hooks.js +64 -0
  5. package/dist/modules/hooks/lib/handler.d.ts +12 -0
  6. package/dist/modules/hooks/lib/handler.js +23 -0
  7. package/dist/modules/hooks/lib/jobs/index.d.ts +2 -0
  8. package/dist/modules/hooks/lib/jobs/index.js +3 -0
  9. package/dist/modules/hooks/lib/jobs/job1.d.ts +1 -0
  10. package/dist/modules/hooks/lib/jobs/job1.js +16 -0
  11. package/dist/modules/hooks/lib/jobs/log-job.d.ts +1 -0
  12. package/dist/modules/hooks/lib/jobs/log-job.js +9 -0
  13. package/dist/modules/hooks/lib/wait.d.ts +8 -0
  14. package/dist/modules/hooks/lib/wait.js +13 -0
  15. package/dist/modules/index.d.ts +1 -0
  16. package/dist/modules/index.js +2 -1
  17. package/dist/modules/scheduled-job/action.d.ts +43 -1
  18. package/dist/modules/scheduled-job/action.js +38 -2
  19. package/dist/modules/scheduled-job/index.d.ts +3 -0
  20. package/dist/modules/scheduled-job/index.js +4 -1
  21. package/dist/modules/scheduled-job/lib/Schedules.d.ts +32 -0
  22. package/dist/modules/scheduled-job/lib/Schedules.js +64 -0
  23. package/dist/modules/scheduled-job/lib/handler.d.ts +12 -0
  24. package/dist/modules/scheduled-job/lib/handler.js +23 -0
  25. package/dist/modules/scheduled-job/lib/jobs/index.d.ts +2 -0
  26. package/dist/modules/scheduled-job/lib/jobs/index.js +3 -0
  27. package/dist/modules/scheduled-job/lib/jobs/job1.d.ts +1 -0
  28. package/dist/modules/scheduled-job/lib/jobs/job1.js +30 -0
  29. package/dist/modules/scheduled-job/lib/jobs/log-job.d.ts +1 -0
  30. package/dist/modules/scheduled-job/lib/jobs/log-job.js +9 -0
  31. package/dist/modules/scheduled-job/lib/wait.d.ts +8 -0
  32. package/dist/modules/scheduled-job/lib/wait.js +13 -0
  33. package/dist/modules/scheduled-job/schema.d.ts +21 -0
  34. package/dist/modules/scheduled-job/schema.js +11 -2
  35. package/dist/modules/scheduled-job/service.d.ts +6 -3
  36. package/dist/modules/scheduled-job/service.js +10 -1
  37. package/dist/modules/scheduled-job/types.d.ts +16 -0
  38. package/dist/modules/scheduled-job/types.js +1 -1
  39. package/package.json +1 -1
  40. package/src/modules/hooks/index.ts +5 -0
  41. package/src/modules/hooks/lib/Hooks.ts +103 -0
  42. package/src/modules/hooks/lib/handler.ts +27 -0
  43. package/src/modules/hooks/lib/jobs/index.ts +2 -0
  44. package/src/modules/hooks/lib/jobs/job1.ts +20 -0
  45. package/src/modules/hooks/lib/jobs/log-job.ts +10 -0
  46. package/src/modules/hooks/lib/wait.ts +17 -0
  47. package/src/modules/index.ts +2 -1
  48. package/src/modules/scheduled-job/action.ts +45 -2
  49. package/src/modules/scheduled-job/index.ts +5 -1
  50. package/src/modules/scheduled-job/lib/Schedules.ts +103 -0
  51. package/src/modules/scheduled-job/lib/handler.ts +27 -0
  52. package/src/modules/scheduled-job/lib/jobs/index.ts +2 -0
  53. package/src/modules/scheduled-job/lib/jobs/job1.ts +34 -0
  54. package/src/modules/scheduled-job/lib/jobs/log-job.ts +9 -0
  55. package/src/modules/scheduled-job/lib/wait.ts +17 -0
  56. package/src/modules/scheduled-job/schema.ts +18 -1
  57. package/src/modules/scheduled-job/service.ts +15 -3
  58. package/src/modules/scheduled-job/types.ts +22 -0
@@ -0,0 +1,34 @@
1
+ import { schedules } from "../Schedules";
2
+
3
+ schedules.task({
4
+ id: "job1",
5
+ cron: "*/5 * * * *",
6
+ run: async () => {
7
+ console.log("hello from job 1");
8
+ },
9
+ });
10
+
11
+
12
+ schedules.task({
13
+ id: "job2",
14
+ cron: "*/5 * * * *",
15
+ run: async () => {
16
+ console.log("hello from job 2");
17
+ },
18
+ });
19
+
20
+ schedules.task({
21
+ id: "job3",
22
+ cron: "*/5 * * * *",
23
+ run: async () => {
24
+ console.log("hello from job 3");
25
+ },
26
+ });
27
+
28
+ schedules.task({
29
+ id: "job4",
30
+ cron: "*/5 * * * *",
31
+ run: async () => {
32
+ console.log("hello from job 4");
33
+ },
34
+ });
@@ -0,0 +1,9 @@
1
+ import { schedules } from "../Schedules";
2
+
3
+ schedules.task({
4
+ id: "test",
5
+ cron: "*/50 * * * * *",
6
+ run: async () => {
7
+ console.log("test");
8
+ },
9
+ });
@@ -0,0 +1,17 @@
1
+ export const wait = {
2
+ for: ({ seconds }: { seconds: number }) =>
3
+ new Promise((resolve) => setTimeout(resolve, seconds * 1000)),
4
+
5
+ until: ({ date }: { date: Date }) => {
6
+ const now = new Date();
7
+ const diff = date.getTime() - now.getTime();
8
+
9
+ if (diff <= 0) {
10
+ // Hedef tarih zaten geçmişse hiç bekleme
11
+ return Promise.resolve();
12
+ }
13
+
14
+ return new Promise((resolve) => setTimeout(resolve, diff));
15
+ },
16
+ };
17
+
@@ -16,9 +16,21 @@ export const GetScheduledJobSchema = z.object({
16
16
  });
17
17
 
18
18
  export const ListExecutionsSchema = z.object({
19
- scheduledJobId: z.string()
19
+ scheduledJobId: z.string(),
20
+ status: z.string().optional()
20
21
  });
21
22
 
23
+ export const ListAvgExecutionsSchema = z.object({
24
+ });
25
+
26
+ export const UpdateJobSchema = z.object({
27
+ id: z.string(),
28
+ name: z.string().optional(),
29
+ cron: z.string().optional(),
30
+ enabled: z.boolean().optional(),
31
+ });
32
+
33
+
22
34
  export const GetDailyExecutionTrendSchema = z.object({
23
35
 
24
36
  });
@@ -26,3 +38,8 @@ export const GetDailyExecutionTrendSchema = z.object({
26
38
  export const GetTopFailedJobsSchema = z.object({
27
39
 
28
40
  });
41
+
42
+ export const GetJobStatsSchema = z.object({
43
+
44
+ });
45
+
@@ -1,8 +1,8 @@
1
1
 
2
2
  import z from "zod";
3
3
  import { ServiceClient } from "../../service-client";
4
- import { CreateScheduledJobSchema, ListScheduledJobsSchema, GetScheduledJobSchema, ListExecutionsSchema, GetDailyExecutionTrendSchema, GetTopFailedJobsSchema } from "./schema";
5
- import { Execution, ExecutionTrend, FailedJob, ScheduledJob } from "./types";
4
+ import { CreateScheduledJobSchema, ListScheduledJobsSchema, GetScheduledJobSchema, ListExecutionsSchema, GetDailyExecutionTrendSchema, GetTopFailedJobsSchema, GetJobStatsSchema, ListAvgExecutionsSchema, UpdateJobSchema } from "./schema";
5
+ import { AvgExecution, Execution, ExecutionTrend, FailedJob, JobStats, ScheduledJob } from "./types";
6
6
 
7
7
  export class ScheduledJobService extends ServiceClient {
8
8
  protected getServiceName(): string {
@@ -25,12 +25,24 @@ export class ScheduledJobService extends ServiceClient {
25
25
  return await this.actionCall('ListExecutions', payload);
26
26
  }
27
27
 
28
+ public async ListAvgExecutions(payload: z.infer<typeof ListAvgExecutionsSchema>): Promise<AvgExecution[]> {
29
+ return await this.actionCall('ListAvgExecutions', payload);
30
+ }
31
+
32
+ public async UpdateJob(payload: z.infer<typeof UpdateJobSchema>): Promise<ScheduledJob> {
33
+ return await this.actionCall('UpdateJob', payload);
34
+ }
35
+
28
36
  public async GetDailyExecutionTrend(payload: z.infer<typeof GetDailyExecutionTrendSchema>): Promise<ExecutionTrend[]> {
29
37
  return await this.actionCall('GetDailyExecutionTrend', payload);
30
38
  }
31
39
 
32
- public async GetTopFailedJobs(payload: z.infer<typeof GetTopFailedJobsSchema>): Promise<FailedJob[]> {
40
+ public async GetTopFailedJobs(payload: z.infer<typeof GetTopFailedJobsSchema>): Promise<FailedJob> {
33
41
  return await this.actionCall('GetTopFailedJobs', payload);
34
42
  }
43
+
44
+ public async GetJobStats(payload: z.infer<typeof GetJobStatsSchema>): Promise<JobStats> {
45
+ return await this.actionCall('GetJobStats', payload);
46
+ }
35
47
 
36
48
  }
@@ -26,6 +26,16 @@ export type Execution = {
26
26
  status: string;
27
27
  }
28
28
 
29
+
30
+ export type AvgExecution = {
31
+ scheduledJobId: string;
32
+ totalExecutions: number;
33
+ activeDays: number;
34
+ avgExecutionsPerDay: number;
35
+ }
36
+
37
+
38
+
29
39
  export type ExecutionTrend = {
30
40
  labels: string[];
31
41
  datasets: {
@@ -43,3 +53,15 @@ export type FailedJob = {
43
53
  backgroundColor: string;
44
54
  }[];
45
55
  }
56
+
57
+ export type JobStats = {
58
+ scheduledJobId: string;
59
+ total: number;
60
+ completed: number;
61
+ failed: number;
62
+ queued: number;
63
+ avgDay: number;
64
+ avgDuration: number;
65
+ lastRun: string;
66
+ }
67
+