@appconda/nextjs 1.0.161 → 1.0.171
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/dist/actions/actionClient.d.ts +8 -2
- package/dist/actions/actionClient.js +21 -15
- package/dist/actions/auth.d.ts +1 -0
- package/dist/actions/auth.js +7 -0
- package/dist/actions/authOptions.d.ts +5 -0
- package/dist/actions/authOptions.js +235 -0
- package/dist/actions/index.d.ts +3 -0
- package/dist/actions/index.js +4 -0
- package/dist/actions/nextAuthHandler.d.ts +1 -0
- package/dist/actions/nextAuthHandler.js +6 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -0
- package/dist/decorators/Cache.js +1 -0
- package/dist/decorators/CacheKey.js +1 -0
- package/dist/decorators/Invalidate.js +1 -0
- package/dist/enums/api-service.js +1 -0
- package/dist/enums/api.js +1 -0
- package/dist/enums/auth-method.js +1 -0
- package/dist/enums/browser.js +1 -0
- package/dist/enums/compression.js +1 -0
- package/dist/enums/credit-card.js +1 -0
- package/dist/enums/database-usage-range.js +1 -0
- package/dist/enums/email-template-locale.js +1 -0
- package/dist/enums/email-template-type.js +1 -0
- package/dist/enums/entities/EntityLimitType.js +1 -0
- package/dist/enums/entities/PropertyAttributeName.js +1 -0
- package/dist/enums/entities/PropertyCondition.js +1 -0
- package/dist/enums/entities/PropertyType.js +1 -0
- package/dist/enums/entities/PropertyValueType.js +1 -0
- package/dist/enums/entities/RowAccess.js +1 -0
- package/dist/enums/entities/ViewFilterCondition.js +1 -0
- package/dist/enums/execution-method.js +1 -0
- package/dist/enums/flag.js +1 -0
- package/dist/enums/function-usage-range.js +1 -0
- package/dist/enums/image-format.js +1 -0
- package/dist/enums/image-gravity.js +1 -0
- package/dist/enums/index-type.js +1 -0
- package/dist/enums/messaging-provider-type.js +1 -0
- package/dist/enums/name.js +1 -0
- package/dist/enums/o-auth-provider copy.js +1 -0
- package/dist/enums/password-hash.js +1 -0
- package/dist/enums/platform-type.js +1 -0
- package/dist/enums/project-usage-range.js +1 -0
- package/dist/enums/region.js +1 -0
- package/dist/enums/relation-mutate.js +1 -0
- package/dist/enums/relationship-type.js +1 -0
- package/dist/enums/resource-type.js +1 -0
- package/dist/enums/runtime.js +1 -0
- package/dist/enums/s-m-t-p-secure.js +1 -0
- package/dist/enums/shared/ApplicationLayout.js +1 -0
- package/dist/enums/shared/Colors.js +1 -0
- package/dist/enums/shared/InputType.js +1 -0
- package/dist/enums/shared/Periodicity.js +1 -0
- package/dist/enums/shared/SvgIcon.js +1 -0
- package/dist/enums/shared/Theme.js +1 -0
- package/dist/enums/sms-template-locale.js +1 -0
- package/dist/enums/sms-template-type.js +1 -0
- package/dist/enums/smtp-encryption.js +1 -0
- package/dist/enums/storage-usage-range.js +1 -0
- package/dist/enums/subscriptions/PricingModel.js +1 -0
- package/dist/enums/subscriptions/SubscriptionBillingPeriod.js +1 -0
- package/dist/enums/subscriptions/SubscriptionFeatureLimitType.js +1 -0
- package/dist/enums/subscriptions/SubscriptionPriceType.js +1 -0
- package/dist/enums/tenants/LinkedAccountStatus.js +1 -0
- package/dist/enums/tenants/TenantUserJoined.js +1 -0
- package/dist/enums/tenants/TenantUserStatus.js +1 -0
- package/dist/enums/tenants/TenantUserType.js +1 -0
- package/dist/enums/user-usage-range.js +1 -0
- package/dist/getAppcondaClient.js +5 -3
- package/dist/getSDKForCurrentUser.d.ts +8 -2
- package/dist/getSDKForCurrentUser.js +13 -5
- package/dist/getSDKForService.js +3 -1
- package/dist/getSDKForTenant.d.ts +20 -0
- package/dist/getSDKForTenant.js +44 -0
- package/dist/id.js +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +5 -1
- package/dist/inputFile.js +1 -0
- package/dist/lib/Cache/Adapter.js +1 -0
- package/dist/lib/Cache/Adapters/Filesystem.js +1 -0
- package/dist/lib/Cache/Adapters/Memory.js +1 -0
- package/dist/lib/Cache/Adapters/None.js +1 -0
- package/dist/lib/Cache/Adapters/Sharding.js +1 -0
- package/dist/lib/Cache/Cache.js +1 -0
- package/dist/lib/Cache/index.js +1 -0
- package/dist/lib/Cache/test.js +1 -0
- package/dist/lib/Registry/Registry.js +1 -0
- package/dist/lib/Registry/index.js +1 -0
- package/dist/lib/Services.js +1 -0
- package/dist/lib/crypto.d.ts +23 -0
- package/dist/lib/crypto.js +78 -0
- package/dist/lib/env.d.ts +1 -0
- package/dist/lib/env.js +137 -0
- package/dist/lib/errors.d.ts +70 -0
- package/dist/lib/errors.js +76 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +3 -0
- package/dist/lib/jwt.d.ts +12 -0
- package/dist/lib/jwt.js +103 -0
- package/dist/lib/types.d.ts +5 -0
- package/dist/lib/types.js +2 -0
- package/dist/models.js +1 -0
- package/dist/modules/account/actions.d.ts +6 -24
- package/dist/modules/account/actions.js +12 -10
- package/dist/modules/account/enums/authentication-factor.js +1 -0
- package/dist/modules/account/enums/authenticator-type.js +1 -0
- package/dist/modules/account/enums/o-auth-provider.js +1 -0
- package/dist/modules/account/index.js +1 -0
- package/dist/modules/account/schema.d.ts +8 -8
- package/dist/modules/account/schema.js +1 -0
- package/dist/modules/account/service.js +1 -0
- package/dist/modules/account/types.js +1 -0
- package/dist/modules/acl/service.d.ts +26 -0
- package/dist/modules/acl/service.js +27 -0
- package/dist/modules/agent/action.d.ts +28 -52
- package/dist/modules/agent/action.js +24 -34
- package/dist/modules/agent/index.js +1 -0
- package/dist/modules/agent/schema.d.ts +18 -18
- package/dist/modules/agent/schema.js +1 -0
- package/dist/modules/agent/service.js +1 -0
- package/dist/modules/agent/types.js +1 -0
- package/dist/modules/ai/index.js +1 -0
- package/dist/modules/ai/node/actions.d.ts +4 -4
- package/dist/modules/ai/node/actions.js +6 -7
- package/dist/modules/ai/node/index.js +1 -0
- package/dist/modules/ai/node/service.js +1 -0
- package/dist/modules/hooks/index.d.ts +3 -0
- package/dist/modules/hooks/index.js +4 -0
- package/dist/modules/hooks/lib/Hooks.d.ts +32 -0
- package/dist/modules/hooks/lib/Hooks.js +64 -0
- package/dist/modules/hooks/lib/handler.d.ts +12 -0
- package/dist/modules/hooks/lib/handler.js +23 -0
- package/dist/modules/hooks/lib/jobs/index.d.ts +2 -0
- package/dist/modules/hooks/lib/jobs/index.js +3 -0
- package/dist/modules/hooks/lib/jobs/job1.d.ts +1 -0
- package/dist/modules/hooks/lib/jobs/job1.js +16 -0
- package/dist/modules/hooks/lib/jobs/log-job.d.ts +1 -0
- package/dist/modules/hooks/lib/jobs/log-job.js +9 -0
- package/dist/modules/hooks/lib/wait.d.ts +8 -0
- package/dist/modules/hooks/lib/wait.js +13 -0
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -0
- package/dist/modules/scheduled-job/action.d.ts +65 -0
- package/dist/modules/scheduled-job/action.js +163 -0
- package/dist/modules/scheduled-job/action2.d.ts +5 -0
- package/dist/modules/scheduled-job/action2.js +17 -0
- package/dist/modules/scheduled-job/index.d.ts +7 -0
- package/dist/modules/scheduled-job/index.js +8 -0
- package/dist/modules/scheduled-job/lib/Schedules.d.ts +34 -0
- package/dist/modules/scheduled-job/lib/Schedules.js +65 -0
- package/dist/modules/scheduled-job/lib/handler.d.ts +13 -0
- package/dist/modules/scheduled-job/lib/handler.js +23 -0
- package/dist/modules/scheduled-job/lib/jobs/index.d.ts +1 -0
- package/dist/modules/scheduled-job/lib/jobs/index.js +2 -0
- package/dist/modules/scheduled-job/lib/jobs/job1.d.ts +1 -0
- package/dist/modules/scheduled-job/lib/jobs/job1.js +10 -0
- package/dist/modules/scheduled-job/lib/jobs/log-job.d.ts +1 -0
- package/dist/modules/scheduled-job/lib/jobs/log-job.js +9 -0
- package/dist/modules/scheduled-job/lib/wait.d.ts +8 -0
- package/dist/modules/scheduled-job/lib/wait.js +13 -0
- package/dist/modules/scheduled-job/schema.d.ts +75 -0
- package/dist/modules/scheduled-job/schema.js +34 -0
- package/dist/modules/scheduled-job/service.d.ts +19 -0
- package/dist/modules/scheduled-job/service.js +43 -0
- package/dist/modules/scheduled-job/types.d.ts +65 -0
- package/dist/modules/scheduled-job/types.js +2 -0
- package/dist/modules/task/action.d.ts +77 -0
- package/dist/modules/task/action.js +136 -0
- package/dist/modules/task/index.d.ts +4 -0
- package/dist/modules/task/index.js +5 -0
- package/dist/modules/task/schema.d.ts +117 -0
- package/dist/modules/task/schema.js +48 -0
- package/dist/modules/task/service.d.ts +20 -0
- package/dist/modules/task/service.js +46 -0
- package/dist/modules/task/types.d.ts +84 -0
- package/dist/modules/task/types.js +2 -0
- package/dist/modules/tenant/actions.d.ts +48 -0
- package/dist/modules/tenant/actions.js +51 -0
- package/dist/modules/tenant/index.d.ts +3 -0
- package/dist/modules/tenant/index.js +4 -0
- package/dist/modules/tenant/tenant.d.ts +32 -0
- package/dist/modules/tenant/tenant.js +125 -0
- package/dist/modules/tenant/types.d.ts +11 -0
- package/dist/modules/tenant/types.js +2 -0
- package/dist/modules/waitlist/action.d.ts +31 -29
- package/dist/modules/waitlist/action.js +1 -0
- package/dist/modules/waitlist/index.js +1 -0
- package/dist/modules/waitlist/schema.d.ts +12 -12
- package/dist/modules/waitlist/schema.js +1 -0
- package/dist/modules/waitlist/service.js +1 -0
- package/dist/modules/waitlist/types.js +1 -0
- package/dist/permission.js +1 -0
- package/dist/query.js +1 -0
- package/dist/role.js +1 -0
- package/dist/schemas/nodes.js +1 -0
- package/dist/service-client.js +1 -0
- package/dist/service.js +1 -0
- package/dist/services/applets.js +1 -0
- package/dist/services/avatars.js +1 -0
- package/dist/services/chat-flow.js +1 -0
- package/dist/services/community.js +1 -0
- package/dist/services/configuration.js +1 -0
- package/dist/services/databases.js +1 -0
- package/dist/services/functions.js +1 -0
- package/dist/services/graphql.js +1 -0
- package/dist/services/health.js +1 -0
- package/dist/services/locale.js +1 -0
- package/dist/services/messaging.js +1 -0
- package/dist/services/permissions.js +1 -0
- package/dist/services/pricing.js +1 -0
- package/dist/services/projects.js +1 -0
- package/dist/services/roles.js +1 -0
- package/dist/services/schema.js +1 -0
- package/dist/services/storage.js +1 -0
- package/dist/services/subscription.js +1 -0
- package/dist/services/teams.js +1 -0
- package/dist/services/tenant-subscription.js +1 -0
- package/dist/services/users.js +1 -0
- package/package.json +4 -1
- package/src/actions/actionClient.ts +13 -6
- package/src/actions/auth.ts +7 -0
- package/src/actions/authOptions.ts +255 -0
- package/src/actions/index.ts +3 -0
- package/src/actions/nextAuthHandler.ts +9 -0
- package/src/client.ts +1 -1
- package/src/getAppcondaClient.ts +4 -3
- package/src/getSDKForCurrentUser.ts +12 -5
- package/src/getSDKForService.ts +2 -1
- package/src/getSDKForTenant.ts +52 -0
- package/src/index.ts +4 -2
- package/src/lib/crypto.ts +105 -0
- package/src/lib/env.ts +145 -0
- package/src/lib/errors.ts +138 -0
- package/src/lib/index.ts +2 -0
- package/src/lib/jwt.ts +113 -0
- package/src/lib/types.ts +7 -0
- package/src/modules/account/actions.ts +16 -13
- package/src/modules/acl/service.ts +55 -0
- package/src/modules/agent/action.ts +27 -38
- package/src/modules/ai/node/actions.ts +5 -8
- package/src/modules/hooks/index.ts +5 -0
- package/src/modules/hooks/lib/Hooks.ts +103 -0
- package/src/modules/hooks/lib/handler.ts +27 -0
- package/src/modules/hooks/lib/jobs/index.ts +2 -0
- package/src/modules/hooks/lib/jobs/job1.ts +20 -0
- package/src/modules/hooks/lib/jobs/log-job.ts +10 -0
- package/src/modules/hooks/lib/wait.ts +17 -0
- package/src/modules/index.ts +5 -1
- package/src/modules/scheduled-job/action.ts +201 -0
- package/src/modules/scheduled-job/index.ts +8 -0
- package/src/modules/scheduled-job/lib/Schedules.ts +105 -0
- package/src/modules/scheduled-job/lib/handler.ts +27 -0
- package/src/modules/scheduled-job/lib/jobs/index.ts +2 -0
- package/src/modules/scheduled-job/lib/jobs/job1.ts +12 -0
- package/src/modules/scheduled-job/lib/wait.ts +17 -0
- package/src/modules/scheduled-job/schema.ts +55 -0
- package/src/modules/scheduled-job/service.ts +60 -0
- package/src/modules/scheduled-job/types.ts +78 -0
- package/src/modules/task/action.ts +167 -0
- package/src/modules/task/index.ts +4 -0
- package/src/modules/task/schema.ts +58 -0
- package/src/modules/task/service.ts +65 -0
- package/src/modules/task/types.ts +89 -0
- package/src/modules/tenant/actions.ts +57 -0
- package/src/modules/tenant/index.ts +3 -0
- package/src/{services → modules/tenant}/tenant.ts +3 -4
- package/src/modules/tenant/types.ts +12 -0
- package/tsconfig.json +4 -1
- package/dist/actions/nodes.d.ts +0 -4
- package/dist/actions/nodes.js +0 -15
- package/dist/enums/authentication-factor.d.ts +0 -6
- package/dist/enums/authentication-factor.js +0 -7
- package/dist/enums/authenticator-type.d.ts +0 -3
- package/dist/enums/authenticator-type.js +0 -4
- package/dist/enums/o-auth-provider.d.ts +0 -41
- package/dist/enums/o-auth-provider.js +0 -42
- package/dist/services/account.d.ts +0 -530
- package/dist/services/account.js +0 -1259
- package/dist/services/node.d.ts +0 -5
- package/dist/services/node.js +0 -11
@@ -0,0 +1,105 @@
|
|
1
|
+
|
2
|
+
type TaskPayload = {
|
3
|
+
timestamp: Date;
|
4
|
+
lastTimestamp?: Date;
|
5
|
+
timezone: string;
|
6
|
+
};
|
7
|
+
|
8
|
+
type TaskContext = {
|
9
|
+
retriesLeft: number;
|
10
|
+
};
|
11
|
+
|
12
|
+
type TaskArgs = {
|
13
|
+
id: string;
|
14
|
+
name: string;
|
15
|
+
cron: string;
|
16
|
+
maxDuration?: number; // saniye
|
17
|
+
retries?: number;
|
18
|
+
run: (
|
19
|
+
payload: TaskPayload,
|
20
|
+
tools: { ctx: TaskContext }
|
21
|
+
) => Promise<void> | void;
|
22
|
+
};
|
23
|
+
|
24
|
+
export class Schedules {
|
25
|
+
private lastRunTimestamps: Record<string, Date> = {};
|
26
|
+
private Tasks: TaskArgs[] = [];
|
27
|
+
|
28
|
+
public task(args: TaskArgs) {
|
29
|
+
this.Tasks.push(args);
|
30
|
+
}
|
31
|
+
|
32
|
+
public async run(taskId: string) {
|
33
|
+
const now = new Date();
|
34
|
+
const lastTimestamp = this.lastRunTimestamps[taskId];
|
35
|
+
|
36
|
+
const payload: TaskPayload = {
|
37
|
+
timestamp: now,
|
38
|
+
lastTimestamp,
|
39
|
+
timezone: "UTC",
|
40
|
+
};
|
41
|
+
|
42
|
+
this.lastRunTimestamps[taskId] = now;
|
43
|
+
|
44
|
+
const context: TaskContext = {
|
45
|
+
retriesLeft: this.Tasks.find(task => task.id === taskId)?.retries ?? 0,
|
46
|
+
};
|
47
|
+
|
48
|
+
await this.runWithRetry(this.Tasks.find(task => task.id === taskId)!, payload, context);
|
49
|
+
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
private async runWithRetry(
|
54
|
+
task: TaskArgs,
|
55
|
+
payload: TaskPayload,
|
56
|
+
ctx: TaskContext
|
57
|
+
) {
|
58
|
+
const start = Date.now();
|
59
|
+
|
60
|
+
try {
|
61
|
+
await Promise.race([
|
62
|
+
task.run(payload, { ctx }),
|
63
|
+
timeout(task.maxDuration ?? 60),
|
64
|
+
]);
|
65
|
+
log("success", { taskId: task.id, name: task.name, time: new Date().toISOString() });
|
66
|
+
} catch (err) {
|
67
|
+
//@ts-ignore
|
68
|
+
log("error", { taskId: task.id, name: task.name, error: err });
|
69
|
+
|
70
|
+
if (ctx.retriesLeft > 0) {
|
71
|
+
ctx.retriesLeft -= 1;
|
72
|
+
//@ts-ignore
|
73
|
+
log("warn", { taskId: task.id, name: task.name, msg: "Retrying..." });
|
74
|
+
await this.runWithRetry(task, payload, ctx);
|
75
|
+
}
|
76
|
+
} finally {
|
77
|
+
const duration = Date.now() - start;
|
78
|
+
//@ts-ignore
|
79
|
+
log("info", { taskId: task.id, name: task.name, durationMs: duration });
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
public toJSON() {
|
84
|
+
return this.Tasks.map(task => ({
|
85
|
+
id: task.id,
|
86
|
+
name: task.name,
|
87
|
+
cron: task.cron,
|
88
|
+
maxDuration: task.maxDuration,
|
89
|
+
retries: task.retries,
|
90
|
+
}));
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
function log(arg0: string, arg1: { taskId: string; name: string; time: string; }) {
|
95
|
+
// console.log(arg0, arg1);
|
96
|
+
}
|
97
|
+
|
98
|
+
function timeout(seconds: number) {
|
99
|
+
return new Promise((_, reject) =>
|
100
|
+
setTimeout(() => reject(new Error("Timeout reached")), seconds * 1000)
|
101
|
+
);
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
export const schedules = new Schedules();
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
2
|
+
|
3
|
+
import './jobs';
|
4
|
+
import { schedules } from './Schedules';
|
5
|
+
|
6
|
+
/* export async function GET() {
|
7
|
+
return NextResponse.json({ schedules: schedules.toJSON() },
|
8
|
+
{ status: 200 });
|
9
|
+
}
|
10
|
+
|
11
|
+
export async function POST(request: Request) {
|
12
|
+
|
13
|
+
} */
|
14
|
+
|
15
|
+
export async function scheduledJobHandler(request: NextRequest, res: NextResponse) {
|
16
|
+
if (request.method === 'POST') {
|
17
|
+
const body = await request.json();
|
18
|
+
const taskId = body.taskId;
|
19
|
+
schedules.run(taskId);
|
20
|
+
return NextResponse.json({ message: 'Callback triggered' },
|
21
|
+
{ status: 200 });
|
22
|
+
} else {
|
23
|
+
return NextResponse.json({ schedules: schedules.toJSON() },
|
24
|
+
{ status: 200 });
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
@@ -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
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { z } from "zod";
|
2
|
+
|
3
|
+
export const CreateScheduledJobSchema = z.object({
|
4
|
+
id: z.string().optional(),
|
5
|
+
name: z.string(),
|
6
|
+
description: z.string().optional(),
|
7
|
+
cron: z.string(),
|
8
|
+
enabled: z.boolean().optional().default(true),
|
9
|
+
});
|
10
|
+
|
11
|
+
export const ListScheduledJobsSchema = z.object({
|
12
|
+
|
13
|
+
});
|
14
|
+
|
15
|
+
export const GetScheduledJobSchema = z.object({
|
16
|
+
id: z.string()
|
17
|
+
});
|
18
|
+
|
19
|
+
export const ListExecutionsSchema = z.object({
|
20
|
+
scheduledJobId: z.string(),
|
21
|
+
status: z.string().optional()
|
22
|
+
});
|
23
|
+
|
24
|
+
export const ListAvgExecutionsSchema = z.object({
|
25
|
+
});
|
26
|
+
|
27
|
+
export const UpdateJobSchema = z.object({
|
28
|
+
id: z.string(),
|
29
|
+
name: z.string().optional(),
|
30
|
+
description: z.string().optional(),
|
31
|
+
cron: z.string().optional(),
|
32
|
+
enabled: z.boolean().optional(),
|
33
|
+
});
|
34
|
+
|
35
|
+
|
36
|
+
export const GetDailyExecutionTrendSchema = z.object({
|
37
|
+
|
38
|
+
});
|
39
|
+
|
40
|
+
export const GetTopFailedJobsSchema = z.object({
|
41
|
+
|
42
|
+
});
|
43
|
+
|
44
|
+
export const GetJobStatsSchema = z.object({
|
45
|
+
|
46
|
+
});
|
47
|
+
|
48
|
+
export const DeleteJobSchema = z.object({
|
49
|
+
id: z.string()
|
50
|
+
});
|
51
|
+
|
52
|
+
export const QueueJobSchema = z.object({
|
53
|
+
id: z.string()
|
54
|
+
});
|
55
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
import z from "zod";
|
3
|
+
import { ServiceClient } from "../../service-client";
|
4
|
+
import { CreateScheduledJobSchema, ListScheduledJobsSchema, GetScheduledJobSchema, ListExecutionsSchema, GetDailyExecutionTrendSchema, GetTopFailedJobsSchema, GetJobStatsSchema, ListAvgExecutionsSchema, UpdateJobSchema, DeleteJobSchema, QueueJobSchema } from "./schema";
|
5
|
+
import { AvgExecution, Execution, ExecutionTrend, FailedJob, JobMetrics, JobStats, ScheduledJob } from "./types";
|
6
|
+
|
7
|
+
export class ScheduledJobService extends ServiceClient {
|
8
|
+
protected getServiceName(): string {
|
9
|
+
return 'com.appconda.service.scheduled-jobs';
|
10
|
+
}
|
11
|
+
|
12
|
+
public async CreateScheduledJob(payload: z.infer<typeof CreateScheduledJobSchema>): Promise<ScheduledJob> {
|
13
|
+
return await this.actionCall('CreateScheduledJob', payload);
|
14
|
+
}
|
15
|
+
|
16
|
+
public async ListScheduledJobs(payload: z.infer<typeof ListScheduledJobsSchema>): Promise<ScheduledJob[]> {
|
17
|
+
return await this.actionCall('ListScheduledJobs', payload);
|
18
|
+
}
|
19
|
+
|
20
|
+
public async GetScheduledJob(payload: z.infer<typeof GetScheduledJobSchema>): Promise<ScheduledJob> {
|
21
|
+
return await this.actionCall('GetScheduledJob', payload);
|
22
|
+
}
|
23
|
+
|
24
|
+
public async ListExecutions(payload: z.infer<typeof ListExecutionsSchema>): Promise<Execution[]> {
|
25
|
+
return await this.actionCall('ListExecutions', payload);
|
26
|
+
}
|
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
|
+
|
36
|
+
public async GetDailyExecutionTrend(payload: z.infer<typeof GetDailyExecutionTrendSchema>): Promise<ExecutionTrend[]> {
|
37
|
+
return await this.actionCall('GetDailyExecutionTrend', payload);
|
38
|
+
}
|
39
|
+
|
40
|
+
public async GetTopFailedJobs(payload: z.infer<typeof GetTopFailedJobsSchema>): Promise<FailedJob> {
|
41
|
+
return await this.actionCall('GetTopFailedJobs', payload);
|
42
|
+
}
|
43
|
+
|
44
|
+
public async GetJobStats(payload: z.infer<typeof GetJobStatsSchema>): Promise<JobStats> {
|
45
|
+
return await this.actionCall('GetJobStats', payload);
|
46
|
+
}
|
47
|
+
|
48
|
+
public async DeleteJob(payload: z.infer<typeof DeleteJobSchema>): Promise<void> {
|
49
|
+
return await this.actionCall('DeleteJob', payload);
|
50
|
+
}
|
51
|
+
|
52
|
+
public async GetJobMetrics(): Promise<JobMetrics> {
|
53
|
+
return await this.actionCall('GetJobMetrics', {});
|
54
|
+
}
|
55
|
+
|
56
|
+
public async QueueJob(payload: z.infer<typeof QueueJobSchema>): Promise<void> {
|
57
|
+
return await this.actionCall('QueueJob', payload);
|
58
|
+
}
|
59
|
+
|
60
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
export type ScheduledJob = {
|
4
|
+
id: string;
|
5
|
+
name: string;
|
6
|
+
description: string;
|
7
|
+
cron: string;
|
8
|
+
enabled: boolean;
|
9
|
+
lastRun?: Date;
|
10
|
+
nextRun?: Date;
|
11
|
+
createdAt: Date;
|
12
|
+
updatedAt: Date;
|
13
|
+
}
|
14
|
+
|
15
|
+
export type JobRun = {
|
16
|
+
id: string;
|
17
|
+
jobId: string;
|
18
|
+
createdAt: Date;
|
19
|
+
updatedAt: Date;
|
20
|
+
}
|
21
|
+
|
22
|
+
export type Execution = {
|
23
|
+
id: string;
|
24
|
+
scheduledJobId: string;
|
25
|
+
createdAt: Date;
|
26
|
+
updatedAt: Date;
|
27
|
+
status: string;
|
28
|
+
}
|
29
|
+
|
30
|
+
|
31
|
+
export type AvgExecution = {
|
32
|
+
scheduledJobId: string;
|
33
|
+
totalExecutions: number;
|
34
|
+
activeDays: number;
|
35
|
+
avgExecutionsPerDay: number;
|
36
|
+
completed: number;
|
37
|
+
failed: number;
|
38
|
+
queued: number;
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
export type ExecutionTrend = {
|
44
|
+
labels: string[];
|
45
|
+
datasets: {
|
46
|
+
label: string;
|
47
|
+
data: number[];
|
48
|
+
borderColor: string;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
export type FailedJob = {
|
53
|
+
labels: string[];
|
54
|
+
datasets: {
|
55
|
+
label: string;
|
56
|
+
data: number[];
|
57
|
+
backgroundColor: string;
|
58
|
+
}[];
|
59
|
+
}
|
60
|
+
|
61
|
+
export type JobStats = {
|
62
|
+
scheduledJobId: string;
|
63
|
+
total: number;
|
64
|
+
completed: number;
|
65
|
+
failed: number;
|
66
|
+
queued: number;
|
67
|
+
avgDay: number;
|
68
|
+
avgDuration: number;
|
69
|
+
lastRun: string;
|
70
|
+
}
|
71
|
+
|
72
|
+
export type JobMetrics = {
|
73
|
+
totalExecutions: number;
|
74
|
+
completed: number;
|
75
|
+
failed: number;
|
76
|
+
queued: number;
|
77
|
+
|
78
|
+
}
|
@@ -0,0 +1,167 @@
|
|
1
|
+
'use server';
|
2
|
+
|
3
|
+
|
4
|
+
import { z } from 'zod';
|
5
|
+
import { getSDKForCurrentUser } from '../../getSDKForCurrentUser';
|
6
|
+
import { CreateProjectSchema, CreateSprintSchema, CreateTaskListSchema, DeleteExecutionsSchema, DeleteSprintSchema, DeleteTaskListSchema, GetSprintSchema, GetTaskListSchema, ListProjectsSchema, UpdateSprintSchema, UpdateTaskListSchema } from './schema';
|
7
|
+
import { Project, Sprint, TaskList } from './types';
|
8
|
+
|
9
|
+
export const CreateProject = async ({ parsedInput }: { parsedInput: z.infer<typeof CreateProjectSchema> }): Promise<{data?: Project, serverError?: string}> => {
|
10
|
+
try {
|
11
|
+
const { task } = await getSDKForCurrentUser();
|
12
|
+
//@ts-ignore
|
13
|
+
return { data: await task.CreateProject(parsedInput) };
|
14
|
+
|
15
|
+
} catch (error) {
|
16
|
+
console.error('Error in CreateProject:', error);
|
17
|
+
return { serverError: error.toString() };
|
18
|
+
}
|
19
|
+
};
|
20
|
+
|
21
|
+
export const ListProjects = async ({ parsedInput }: { parsedInput: z.infer<typeof ListProjectsSchema> }): Promise<{data?: Project[], serverError?: string}> => {
|
22
|
+
try {
|
23
|
+
|
24
|
+
const { task } = await getSDKForCurrentUser();
|
25
|
+
//@ts-ignore
|
26
|
+
return { data: await task.ListProjects(parsedInput) };
|
27
|
+
|
28
|
+
} catch (error) {
|
29
|
+
console.error('Error in ListProjects:', error);
|
30
|
+
return { serverError: error.toString() };
|
31
|
+
}
|
32
|
+
};
|
33
|
+
|
34
|
+
export const CreateTaskList = async ({ parsedInput }: { parsedInput: z.infer<typeof CreateTaskListSchema> }): Promise<{data?: TaskList, serverError?: string}> => {
|
35
|
+
try {
|
36
|
+
|
37
|
+
const { task } = await getSDKForCurrentUser();
|
38
|
+
return { data: await task.CreateTaskList(parsedInput) };
|
39
|
+
|
40
|
+
} catch (error) {
|
41
|
+
console.error('Error in CreateTaskList:', error);
|
42
|
+
return { serverError: error.toString() };
|
43
|
+
}
|
44
|
+
};
|
45
|
+
|
46
|
+
export const GetTaskList = async ({ parsedInput }: { parsedInput: z.infer<typeof GetTaskListSchema> }): Promise<{data?: TaskList, serverError?: string}> => {
|
47
|
+
try {
|
48
|
+
|
49
|
+
const { task } = await getSDKForCurrentUser();
|
50
|
+
return { data: await task.GetTaskList(parsedInput) };
|
51
|
+
|
52
|
+
} catch (error) {
|
53
|
+
console.error('Error in GetTaskList:', error);
|
54
|
+
return { serverError: error.toString() };
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
export const ListTaskLists = async (): Promise<{data?: TaskList[], serverError?: string}> => {
|
61
|
+
try {
|
62
|
+
|
63
|
+
const { task } = await getSDKForCurrentUser();
|
64
|
+
return { data: await task.ListTaskLists() };
|
65
|
+
|
66
|
+
} catch (error) {
|
67
|
+
console.error('Error in ListTaskLists:', error);
|
68
|
+
return { serverError: error.toString() };
|
69
|
+
}
|
70
|
+
};
|
71
|
+
|
72
|
+
export const UpdateTaskList = async ({ parsedInput }: { parsedInput: z.infer<typeof UpdateTaskListSchema> }): Promise<{data?: TaskList, serverError?: string}> => {
|
73
|
+
try {
|
74
|
+
|
75
|
+
const { task } = await getSDKForCurrentUser();
|
76
|
+
return { data: await task.UpdateTaskList(parsedInput) };
|
77
|
+
|
78
|
+
} catch (error) {
|
79
|
+
console.error('Error in UpdateTaskList:', error);
|
80
|
+
return { serverError: error.toString() };
|
81
|
+
}
|
82
|
+
};
|
83
|
+
|
84
|
+
export const DeleteTaskList = async ({ parsedInput }: { parsedInput: z.infer<typeof DeleteTaskListSchema> }): Promise<{data?: void, serverError?: string}> => {
|
85
|
+
try {
|
86
|
+
|
87
|
+
const { task } = await getSDKForCurrentUser();
|
88
|
+
return { data: await task.DeleteTaskList(parsedInput) };
|
89
|
+
|
90
|
+
} catch (error) {
|
91
|
+
console.error('Error in DeleteTaskList:', error);
|
92
|
+
return { serverError: error.toString() };
|
93
|
+
}
|
94
|
+
};
|
95
|
+
|
96
|
+
export const CreateSprint = async ({ parsedInput }: { parsedInput: z.infer<typeof CreateSprintSchema> }): Promise<{data?: Sprint, serverError?: string}> => {
|
97
|
+
try {
|
98
|
+
|
99
|
+
const { task } = await getSDKForCurrentUser();
|
100
|
+
return { data: await task.CreateSprint(parsedInput) };
|
101
|
+
|
102
|
+
} catch (error) {
|
103
|
+
console.error('Error in CreateSprint:', error);
|
104
|
+
return { serverError: error.toString() };
|
105
|
+
}
|
106
|
+
};
|
107
|
+
|
108
|
+
export const GetSprint = async ({ parsedInput }: { parsedInput: z.infer<typeof GetSprintSchema> }): Promise<{data?: Sprint, serverError?: string}> => {
|
109
|
+
try {
|
110
|
+
|
111
|
+
const { task } = await getSDKForCurrentUser();
|
112
|
+
return { data: await task.GetSprint(parsedInput) };
|
113
|
+
|
114
|
+
} catch (error) {
|
115
|
+
console.error('Error in GetSprint:', error);
|
116
|
+
return { serverError: error.toString() };
|
117
|
+
}
|
118
|
+
};
|
119
|
+
//@ts-ignore
|
120
|
+
export const ListSprints = async ({ parsedInput }: { parsedInput: z.infer<typeof ListSprintsSchema> }): Promise<{data?: Sprint[], serverError?: string}> => {
|
121
|
+
try {
|
122
|
+
|
123
|
+
const { task } = await getSDKForCurrentUser();
|
124
|
+
return { data: await task.ListSprints() };
|
125
|
+
|
126
|
+
} catch (error) {
|
127
|
+
console.error('Error in ListSprints:', error);
|
128
|
+
return { serverError: error.toString() };
|
129
|
+
}
|
130
|
+
};
|
131
|
+
|
132
|
+
export const UpdateSprint = async ({ parsedInput }: { parsedInput: z.infer<typeof UpdateSprintSchema> }): Promise<{data?: Sprint, serverError?: string}> => {
|
133
|
+
try {
|
134
|
+
|
135
|
+
const { task } = await getSDKForCurrentUser();
|
136
|
+
return { data: await task.UpdateSprint(parsedInput) };
|
137
|
+
|
138
|
+
} catch (error) {
|
139
|
+
console.error('Error in UpdateSprint:', error);
|
140
|
+
return { serverError: error.toString() };
|
141
|
+
}
|
142
|
+
};
|
143
|
+
|
144
|
+
export const DeleteSprint = async ({ parsedInput }: { parsedInput: z.infer<typeof DeleteSprintSchema> }): Promise<{data?: void, serverError?: string}> => {
|
145
|
+
try {
|
146
|
+
|
147
|
+
const { task } = await getSDKForCurrentUser();
|
148
|
+
return { data: await task.DeleteSprint(parsedInput) };
|
149
|
+
|
150
|
+
} catch (error) {
|
151
|
+
console.error('Error in DeleteSprint:', error);
|
152
|
+
return { serverError: error.toString() };
|
153
|
+
}
|
154
|
+
};
|
155
|
+
|
156
|
+
export const DeleteExecutions = async ( parsedInput: z.infer<typeof DeleteExecutionsSchema> ): Promise<{data?: void, serverError?: string}> => {
|
157
|
+
try {
|
158
|
+
|
159
|
+
const { task } = await getSDKForCurrentUser();
|
160
|
+
return { data: await task.DeleteExecutions(parsedInput) };
|
161
|
+
|
162
|
+
} catch (error) {
|
163
|
+
console.error('Error in DeleteExecutions:', error);
|
164
|
+
return { serverError: error.toString() };
|
165
|
+
}
|
166
|
+
};
|
167
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { z } from "zod";
|
2
|
+
|
3
|
+
export const CreateProjectSchema = z.object({
|
4
|
+
id: z.string().optional(),
|
5
|
+
tenantId: z.string(),
|
6
|
+
ownerId: z.string(),
|
7
|
+
title: z.string(),
|
8
|
+
description: z.string().optional()
|
9
|
+
});
|
10
|
+
|
11
|
+
export const ListProjectsSchema = z.object({
|
12
|
+
tenantId: z.string()
|
13
|
+
});
|
14
|
+
|
15
|
+
export const CreateTaskListSchema = z.object({
|
16
|
+
id: z.string().optional(),
|
17
|
+
name: z.string(),
|
18
|
+
description: z.string().optional()
|
19
|
+
});
|
20
|
+
|
21
|
+
export const CreateSprintSchema = z.object({
|
22
|
+
id: z.string().optional(),
|
23
|
+
name: z.string(),
|
24
|
+
description: z.string().optional()
|
25
|
+
});
|
26
|
+
|
27
|
+
export const GetTaskListSchema = z.object({
|
28
|
+
id: z.string()
|
29
|
+
});
|
30
|
+
|
31
|
+
export const GetSprintSchema = z.object({
|
32
|
+
id: z.string()
|
33
|
+
});
|
34
|
+
|
35
|
+
export const UpdateTaskListSchema = z.object({
|
36
|
+
id: z.string(),
|
37
|
+
name: z.string(),
|
38
|
+
description: z.string().optional()
|
39
|
+
});
|
40
|
+
|
41
|
+
export const UpdateSprintSchema = z.object({
|
42
|
+
id: z.string(),
|
43
|
+
name: z.string(),
|
44
|
+
description: z.string().optional()
|
45
|
+
});
|
46
|
+
|
47
|
+
export const DeleteTaskListSchema = z.object({
|
48
|
+
id: z.string()
|
49
|
+
});
|
50
|
+
|
51
|
+
export const DeleteSprintSchema = z.object({
|
52
|
+
id: z.string()
|
53
|
+
});
|
54
|
+
|
55
|
+
export const DeleteExecutionsSchema = z.object({
|
56
|
+
jobId: z.string(),
|
57
|
+
status: z.string()
|
58
|
+
});
|
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
import z from "zod";
|
3
|
+
import { ServiceClient } from "../../service-client";
|
4
|
+
import { CreateProjectSchema, CreateSprintSchema, CreateTaskListSchema, DeleteExecutionsSchema, DeleteSprintSchema, DeleteTaskListSchema, GetSprintSchema, GetTaskListSchema, ListProjectsSchema, UpdateSprintSchema, UpdateTaskListSchema } from "./schema";
|
5
|
+
import { Project, Sprint, TaskList } from "./types";
|
6
|
+
|
7
|
+
|
8
|
+
export class TaskService extends ServiceClient {
|
9
|
+
protected getServiceName(): string {
|
10
|
+
return 'com.appconda.service.task';
|
11
|
+
}
|
12
|
+
|
13
|
+
public async CreateProject(payload: z.infer<typeof CreateProjectSchema>): Promise<Project> {
|
14
|
+
return await this.actionCall('CreateProject', payload);
|
15
|
+
}
|
16
|
+
|
17
|
+
public async ListProjects(payload: z.infer<typeof ListProjectsSchema>): Promise<Project[]> {
|
18
|
+
return await this.actionCall('ListProjects', payload);
|
19
|
+
}
|
20
|
+
|
21
|
+
public async CreateTaskList(payload: z.infer<typeof CreateTaskListSchema>): Promise<TaskList> {
|
22
|
+
return await this.actionCall('CreateTaskList', payload);
|
23
|
+
}
|
24
|
+
|
25
|
+
public async CreateSprint(payload: z.infer<typeof CreateSprintSchema>): Promise<Sprint> {
|
26
|
+
return await this.actionCall('CreateSprint', payload);
|
27
|
+
}
|
28
|
+
|
29
|
+
public async ListTaskLists(): Promise<TaskList[]> {
|
30
|
+
return await this.actionCall('ListTaskLists', {});
|
31
|
+
}
|
32
|
+
|
33
|
+
public async ListSprints(): Promise<Sprint[]> {
|
34
|
+
return await this.actionCall('ListSprints', {});
|
35
|
+
}
|
36
|
+
|
37
|
+
public async GetTaskList(payload: z.infer<typeof GetTaskListSchema>): Promise<TaskList> {
|
38
|
+
return await this.actionCall('GetTaskList', payload);
|
39
|
+
}
|
40
|
+
|
41
|
+
public async GetSprint(payload: z.infer<typeof GetSprintSchema>): Promise<Sprint> {
|
42
|
+
return await this.actionCall('GetSprint', payload);
|
43
|
+
}
|
44
|
+
|
45
|
+
public async UpdateTaskList(payload: z.infer<typeof UpdateTaskListSchema>): Promise<TaskList> {
|
46
|
+
return await this.actionCall('UpdateTaskList', payload);
|
47
|
+
}
|
48
|
+
|
49
|
+
public async UpdateSprint(payload: z.infer<typeof UpdateSprintSchema>): Promise<Sprint> {
|
50
|
+
return await this.actionCall('UpdateSprint', payload);
|
51
|
+
}
|
52
|
+
|
53
|
+
public async DeleteTaskList(payload: z.infer<typeof DeleteTaskListSchema>): Promise<void> {
|
54
|
+
return await this.actionCall('DeleteTaskList', payload);
|
55
|
+
}
|
56
|
+
|
57
|
+
public async DeleteSprint(payload: z.infer<typeof DeleteSprintSchema>): Promise<void> {
|
58
|
+
return await this.actionCall('DeleteSprint', payload);
|
59
|
+
}
|
60
|
+
|
61
|
+
public async DeleteExecutions(payload: z.infer<typeof DeleteExecutionsSchema>): Promise<void> {
|
62
|
+
return await this.actionCall('DeleteExecutions', payload);
|
63
|
+
}
|
64
|
+
|
65
|
+
}
|