alepha 0.19.2 → 0.19.4
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/assets/swagger-ui/swagger-ui-bundle.js +1 -1
- package/dist/api/audits/index.d.ts +8 -8
- package/dist/api/invitations/index.d.ts +790 -0
- package/dist/api/invitations/index.d.ts.map +1 -0
- package/dist/api/invitations/index.js +665 -0
- package/dist/api/invitations/index.js.map +1 -0
- package/dist/api/jobs/index.browser.js +8 -9
- package/dist/api/jobs/index.browser.js.map +1 -1
- package/dist/api/jobs/index.d.ts +90 -34
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +267 -44
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/notifications/index.browser.js +0 -1
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +3 -3
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +0 -1
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/parameters/index.browser.js +112 -1
- package/dist/api/parameters/index.browser.js.map +1 -1
- package/dist/api/parameters/index.d.ts +90 -3
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +79 -12
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/{billing → api/payments}/index.d.ts +67 -49
- package/dist/api/payments/index.d.ts.map +1 -0
- package/dist/{billing → api/payments}/index.js +108 -74
- package/dist/api/payments/index.js.map +1 -0
- package/dist/api/subscriptions/index.d.ts +1692 -0
- package/dist/api/subscriptions/index.d.ts.map +1 -0
- package/dist/api/subscriptions/index.js +1870 -0
- package/dist/api/subscriptions/index.js.map +1 -0
- package/dist/api/users/index.d.ts +27 -21
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +167 -34
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/workflows/index.browser.js +246 -0
- package/dist/api/workflows/index.browser.js.map +1 -0
- package/dist/api/workflows/index.d.ts +1618 -0
- package/dist/api/workflows/index.d.ts.map +1 -0
- package/dist/api/workflows/index.js +1504 -0
- package/dist/api/workflows/index.js.map +1 -0
- package/dist/cli/config/index.d.ts +6 -28
- package/dist/cli/config/index.d.ts.map +1 -1
- package/dist/cli/config/index.js +5 -10
- package/dist/cli/config/index.js.map +1 -1
- package/dist/cli/core/index.d.ts +11669 -208
- package/dist/cli/core/index.d.ts.map +1 -1
- package/dist/cli/core/index.js +60 -69
- package/dist/cli/core/index.js.map +1 -1
- package/dist/cli/devtools/index.d.ts +5 -0
- package/dist/cli/devtools/index.d.ts.map +1 -1
- package/dist/cli/devtools/index.js +4 -0
- package/dist/cli/devtools/index.js.map +1 -1
- package/dist/cli/platform/index.d.ts +69 -64
- package/dist/cli/platform/index.d.ts.map +1 -1
- package/dist/cli/platform/index.js +6 -2
- package/dist/cli/platform/index.js.map +1 -1
- package/dist/cli/vendor/index.d.ts +38 -10
- package/dist/cli/vendor/index.d.ts.map +1 -1
- package/dist/cli/vendor/index.js +85 -26
- package/dist/cli/vendor/index.js.map +1 -1
- package/dist/core/index.browser.js +21 -2
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +33 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +25 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +25 -2
- package/dist/core/index.native.js.map +1 -1
- package/dist/core/index.workerd.js +25 -2
- package/dist/core/index.workerd.js.map +1 -1
- package/dist/email/smtp/index.js +24 -8
- package/dist/email/smtp/index.js.map +1 -1
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/logger/index.js.map +1 -1
- package/dist/orm/core/index.browser.js +0 -18
- package/dist/orm/core/index.browser.js.map +1 -1
- package/dist/orm/core/index.bun.js +25 -73
- package/dist/orm/core/index.bun.js.map +1 -1
- package/dist/orm/core/index.d.ts +10 -32
- package/dist/orm/core/index.d.ts.map +1 -1
- package/dist/orm/core/index.js +25 -73
- package/dist/orm/core/index.js.map +1 -1
- package/dist/orm/postgres/index.bun.js +3 -3
- package/dist/orm/postgres/index.bun.js.map +1 -1
- package/dist/orm/postgres/index.d.ts +2 -1
- package/dist/orm/postgres/index.d.ts.map +1 -1
- package/dist/orm/postgres/index.js +3 -3
- package/dist/orm/postgres/index.js.map +1 -1
- package/dist/react/router/index.browser.js +25 -3
- package/dist/react/router/index.browser.js.map +1 -1
- package/dist/react/router/index.d.ts +16 -1
- package/dist/react/router/index.d.ts.map +1 -1
- package/dist/react/router/index.js +25 -3
- package/dist/react/router/index.js.map +1 -1
- package/dist/security/index.d.ts +28 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +28 -0
- package/dist/security/index.js.map +1 -1
- package/package.json +37 -20
- package/src/api/invitations/__tests__/InvitationService.spec.ts +439 -0
- package/src/api/invitations/controllers/AdminInvitationController.ts +86 -0
- package/src/api/invitations/controllers/InvitationController.ts +84 -0
- package/src/api/invitations/entities/invitations.ts +33 -0
- package/src/api/invitations/index.ts +65 -0
- package/src/api/invitations/jobs/InvitationJobs.ts +37 -0
- package/src/api/invitations/providers/InvitationProvider.ts +45 -0
- package/src/api/invitations/schemas/createInvitationSchema.ts +12 -0
- package/src/api/invitations/schemas/invitationConfigAtom.ts +20 -0
- package/src/api/invitations/schemas/invitationQuerySchema.ts +15 -0
- package/src/api/invitations/schemas/invitationResourceSchema.ts +6 -0
- package/src/api/invitations/schemas/invitationWithResourceInfoSchema.ts +22 -0
- package/src/api/invitations/schemas/myInvitationsQuerySchema.ts +10 -0
- package/src/api/invitations/services/InvitationService.ts +556 -0
- package/src/api/jobs/__tests__/$job.spec.ts +876 -0
- package/src/api/jobs/controllers/AdminJobController.ts +44 -0
- package/src/api/jobs/entities/jobExecutionEntity.ts +0 -2
- package/src/api/jobs/index.ts +0 -3
- package/src/api/jobs/primitives/$job.ts +22 -11
- package/src/api/jobs/providers/JobProvider.ts +239 -25
- package/src/api/jobs/schemas/jobConfigAtom.ts +4 -0
- package/src/api/jobs/schemas/jobCronInfoSchema.ts +1 -0
- package/src/api/jobs/schemas/jobExecutionQuerySchema.ts +0 -1
- package/src/api/jobs/schemas/jobQueueDepthSchema.ts +1 -0
- package/src/api/jobs/schemas/jobRegistrationSchema.ts +1 -6
- package/src/api/jobs/services/JobService.ts +51 -12
- package/src/api/notifications/schemas/notificationQuerySchema.ts +0 -1
- package/src/api/parameters/__tests__/$parameter.spec.ts +327 -0
- package/src/api/parameters/controllers/AdminParameterController.ts +29 -3
- package/src/api/parameters/index.browser.ts +12 -0
- package/src/api/parameters/primitives/$parameter.ts +20 -3
- package/src/api/parameters/services/ParameterProvider.ts +48 -7
- package/src/{billing → api/payments}/__tests__/PaymentMethodService.spec.ts +32 -6
- package/src/api/payments/__tests__/PaymentService.spec.ts +279 -0
- package/src/{billing/controllers/AdminBillingController.ts → api/payments/controllers/AdminPaymentController.ts} +26 -21
- package/src/{billing/controllers/BillingController.ts → api/payments/controllers/PaymentController.ts} +23 -11
- package/src/{billing → api/payments}/entities/paymentIntents.ts +1 -0
- package/src/{billing/errors/BillingError.ts → api/payments/errors/PaymentError.ts} +1 -1
- package/src/{billing → api/payments}/index.ts +31 -25
- package/src/{billing/providers/MemoryBillingProvider.ts → api/payments/providers/MemoryPaymentProvider.ts} +4 -4
- package/src/{billing/providers/BillingProvider.ts → api/payments/providers/PaymentProvider.ts} +9 -2
- package/src/{billing → api/payments}/services/PaymentMethodService.ts +5 -5
- package/src/{billing/services/BillingService.ts → api/payments/services/PaymentService.ts} +94 -18
- package/src/api/subscriptions/__tests__/BillingService.spec.ts +218 -0
- package/src/api/subscriptions/__tests__/SubscriptionService.spec.ts +278 -0
- package/src/api/subscriptions/controllers/AdminSubscriptionController.ts +212 -0
- package/src/api/subscriptions/controllers/SubscriptionController.ts +189 -0
- package/src/api/subscriptions/entities/subscriptionEvents.ts +54 -0
- package/src/api/subscriptions/entities/subscriptions.ts +68 -0
- package/src/api/subscriptions/index.ts +144 -0
- package/src/api/subscriptions/jobs/SubscriptionJobs.ts +382 -0
- package/src/api/subscriptions/middleware/$requireLimit.ts +50 -0
- package/src/api/subscriptions/middleware/$requirePlan.ts +49 -0
- package/src/api/subscriptions/notifications/SubscriptionNotifications.ts +110 -0
- package/src/api/subscriptions/schemas/cancelSubscriptionSchema.ts +8 -0
- package/src/api/subscriptions/schemas/changePlanSchema.ts +9 -0
- package/src/api/subscriptions/schemas/createSubscriptionSchema.ts +11 -0
- package/src/api/subscriptions/schemas/entitlementsSchema.ts +21 -0
- package/src/api/subscriptions/schemas/mrrSchema.ts +13 -0
- package/src/api/subscriptions/schemas/planDefinitionSchema.ts +71 -0
- package/src/api/subscriptions/schemas/planResourceSchema.ts +25 -0
- package/src/api/subscriptions/schemas/subscriptionEventResourceSchema.ts +8 -0
- package/src/api/subscriptions/schemas/subscriptionQuerySchema.ts +19 -0
- package/src/api/subscriptions/schemas/subscriptionResourceSchema.ts +6 -0
- package/src/api/subscriptions/schemas/subscriptionSettingsSchema.ts +32 -0
- package/src/api/subscriptions/schemas/subscriptionStatsSchema.ts +23 -0
- package/src/api/subscriptions/services/BillingService.ts +437 -0
- package/src/api/subscriptions/services/SubscriptionConfig.ts +56 -0
- package/src/api/subscriptions/services/SubscriptionService.ts +867 -0
- package/src/api/subscriptions/services/UsageService.ts +118 -0
- package/src/api/users/__tests__/AdminUserController.spec.ts +80 -1
- package/src/api/users/__tests__/CredentialService.spec.ts +177 -0
- package/src/api/users/__tests__/EmailVerification.spec.ts +29 -18
- package/src/api/users/__tests__/PasswordReset.spec.ts +3 -0
- package/src/api/users/__tests__/RegistrationService.spec.ts +148 -1
- package/src/api/users/__tests__/SessionService.spec.ts +142 -1
- package/src/api/users/atoms/realmAuthSettingsAtom.ts +10 -1
- package/src/api/users/controllers/UserController.ts +3 -8
- package/src/api/users/notifications/UserNotifications.ts +23 -0
- package/src/api/users/schemas/loginSchema.ts +1 -1
- package/src/api/users/services/CredentialService.ts +51 -4
- package/src/api/users/services/RegistrationService.ts +38 -9
- package/src/api/users/services/SessionService.ts +62 -9
- package/src/api/users/services/UserService.ts +21 -12
- package/src/api/workflows/__tests__/$workflow.spec.ts +616 -0
- package/src/api/workflows/controllers/AdminWorkflowController.ts +191 -0
- package/src/api/workflows/entities/workflowExecutions.ts +74 -0
- package/src/api/workflows/entities/workflowStepExecutions.ts +74 -0
- package/src/api/workflows/entities/workflowStepLogs.ts +13 -0
- package/src/api/workflows/index.browser.ts +22 -0
- package/src/api/workflows/index.ts +124 -0
- package/src/api/workflows/jobs/WorkflowJobs.ts +77 -0
- package/src/api/workflows/primitives/$workflow.ts +202 -0
- package/src/api/workflows/providers/WorkflowProvider.ts +1284 -0
- package/src/api/workflows/schemas/workflowActivitySchema.ts +15 -0
- package/src/api/workflows/schemas/workflowConfigAtom.ts +51 -0
- package/src/api/workflows/schemas/workflowExecutionDetailSchema.ts +18 -0
- package/src/api/workflows/schemas/workflowExecutionQuerySchema.ts +26 -0
- package/src/api/workflows/schemas/workflowExecutionResourceSchema.ts +30 -0
- package/src/api/workflows/schemas/workflowRegistrationSchema.ts +26 -0
- package/src/api/workflows/schemas/workflowStatsSchema.ts +16 -0
- package/src/api/workflows/schemas/workflowStepExecutionResourceSchema.ts +15 -0
- package/src/api/workflows/services/WorkflowService.ts +382 -0
- package/src/cli/config/defineConfig.ts +17 -46
- package/src/cli/core/providers/ViteDevServerProvider.ts +45 -3
- package/src/cli/core/services/PackageManagerUtils.ts +3 -1
- package/src/cli/core/services/ProjectScaffolder.ts +5 -5
- package/src/cli/core/templates/agentMd.ts +14 -5
- package/src/cli/core/templates/webAppRouterTs.ts +5 -58
- package/src/cli/devtools/index.ts +21 -1
- package/src/cli/platform/index.ts +23 -2
- package/src/cli/vendor/__tests__/VendorService.spec.ts +283 -178
- package/src/cli/vendor/index.ts +20 -3
- package/src/cli/vendor/services/VendorService.ts +126 -27
- package/src/core/Alepha.ts +10 -0
- package/src/core/__tests__/TypeProvider.spec.ts +4 -2
- package/src/core/providers/SchemaValidator.ts +1 -1
- package/src/core/providers/TypeProvider.ts +46 -3
- package/src/logger/index.ts +6 -1
- package/src/orm/__tests__/enums.spec.ts +22 -29
- package/src/orm/__tests__/orm-showcase-tests.ts +430 -0
- package/src/orm/__tests__/orm-showcase.spec.ts +167 -0
- package/src/orm/core/providers/DatabaseTypeProvider.ts +0 -29
- package/src/orm/core/providers/DrizzleKitProvider.ts +56 -105
- package/src/orm/postgres/services/PostgresModelBuilder.ts +3 -6
- package/src/react/router/__tests__/$page.browser.spec.tsx +157 -0
- package/src/react/router/providers/ReactBrowserProvider.ts +39 -0
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +22 -0
- package/src/security/__tests__/$secure-combinations.spec.ts +945 -0
- package/src/security/primitives/$secure.ts +28 -0
- package/tsconfig.base.json +0 -1
- package/dist/billing/index.d.ts.map +0 -1
- package/dist/billing/index.js.map +0 -1
- package/src/billing/__tests__/BillingService.spec.ts +0 -136
- /package/src/{billing → api/payments}/entities/paymentMethods.ts +0 -0
- /package/src/{billing → api/payments}/entities/refunds.ts +0 -0
- /package/src/{billing → api/payments}/schemas/intentSchemas.ts +0 -0
- /package/src/{billing → api/payments}/schemas/paymentMethodSchemas.ts +0 -0
- /package/src/{billing → api/payments}/schemas/refundSchemas.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/api/invitations/schemas/invitationQuerySchema.ts","../../../src/api/invitations/entities/invitations.ts","../../../src/api/invitations/schemas/invitationResourceSchema.ts","../../../src/api/invitations/providers/InvitationProvider.ts","../../../src/api/invitations/schemas/invitationConfigAtom.ts","../../../src/api/invitations/services/InvitationService.ts","../../../src/api/invitations/controllers/AdminInvitationController.ts","../../../src/api/invitations/schemas/createInvitationSchema.ts","../../../src/api/invitations/schemas/invitationWithResourceInfoSchema.ts","../../../src/api/invitations/schemas/myInvitationsQuerySchema.ts","../../../src/api/invitations/controllers/InvitationController.ts","../../../src/api/invitations/jobs/InvitationJobs.ts","../../../src/api/invitations/index.ts"],"sourcesContent":["import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\nimport { pageQuerySchema } from \"alepha/orm\";\n\nexport const invitationQuerySchema = t.extend(pageQuerySchema, {\n email: t.optional(t.text({ description: \"Filter by invited email\" })),\n resourceType: t.optional(t.text({ description: \"Filter by resource type\" })),\n resourceId: t.optional(t.text({ description: \"Filter by resource ID\" })),\n status: t.optional(\n t.enum([\"pending\", \"accepted\", \"declined\", \"expired\", \"revoked\"]),\n ),\n invitedBy: t.optional(t.uuid()),\n});\n\nexport type InvitationQuery = Static<typeof invitationQuerySchema>;\n","import { type Static, t } from \"alepha\";\nimport { users } from \"alepha/api/users\";\nimport { $entity, db } from \"alepha/orm\";\n\nexport const invitations = $entity({\n name: \"invitations\",\n schema: t.object({\n id: db.primaryKey(t.uuid()),\n version: db.version(),\n createdAt: db.createdAt(),\n updatedAt: db.updatedAt(),\n invitedBy: db.ref(t.uuid(), () => users.cols.id, { onDelete: \"cascade\" }),\n email: t.string({ format: \"email\" }),\n resourceType: t.text({ minLength: 1, maxLength: 100 }),\n resourceId: t.text({ minLength: 1, maxLength: 255 }),\n status: t.enum([\"pending\", \"accepted\", \"declined\", \"expired\", \"revoked\"]),\n roles: t.optional(t.array(t.text())),\n metadata: t.optional(t.record(t.text(), t.any())),\n token: t.text(),\n expiresAt: t.datetime(),\n resolvedAt: t.optional(t.datetime()),\n resolvedBy: t.optional(db.ref(t.uuid(), () => users.cols.id)),\n }),\n indexes: [\n { columns: [\"email\", \"status\"] },\n { columns: [\"resourceType\", \"resourceId\", \"email\", \"status\"] },\n { columns: [\"invitedBy\"] },\n { columns: [\"expiresAt\"] },\n { columns: [\"token\"], unique: true },\n ],\n});\n\nexport type InvitationEntity = Static<typeof invitations.schema>;\n","import type { Static } from \"alepha\";\nimport { invitations } from \"../entities/invitations.ts\";\n\nexport const invitationResourceSchema = invitations.schema;\n\nexport type InvitationResource = Static<typeof invitationResourceSchema>;\n","import type { InvitationEntity } from \"../entities/invitations.ts\";\n\n/**\n * Abstract provider that apps implement to customize invitation behavior\n * per resource type.\n */\nexport abstract class InvitationProvider {\n /**\n * Validate that the resource exists and the inviter has permission to invite.\n * Throw BadRequestError/ForbiddenError to reject.\n */\n abstract validateResource(\n resourceType: string,\n resourceId: string,\n inviter: { id: string; email?: string },\n ): Promise<void>;\n\n /**\n * Check if the email is already a member of the resource.\n * Return true to reject the invitation as duplicate membership.\n */\n abstract isMember(\n resourceType: string,\n resourceId: string,\n email: string,\n userId?: string,\n ): Promise<boolean>;\n\n /**\n * Called when an invitation is accepted.\n * Create membership records, assign roles, etc.\n */\n abstract onAccept(\n invitation: InvitationEntity,\n acceptedBy: { id: string; email?: string },\n ): Promise<void>;\n\n /**\n * Return display info for the resource (used in API responses).\n */\n abstract getResourceInfo(\n resourceType: string,\n resourceId: string,\n ): Promise<{ name: string; description?: string; url?: string }>;\n}\n","import { $atom, t } from \"alepha\";\n\nexport const invitationConfigAtom = $atom({\n name: \"alepha.api.invitations.config\",\n schema: t.object({\n expirationDays: t.integer({ minimum: 1, maximum: 90 }),\n maxPendingPerResource: t.integer({ minimum: 1, maximum: 500 }),\n maxPendingPerInviter: t.integer({\n minimum: 1,\n maximum: 1000,\n }),\n purgeDays: t.integer({ minimum: 0, maximum: 365 }),\n }),\n default: {\n expirationDays: 7,\n maxPendingPerResource: 50,\n maxPendingPerInviter: 100,\n purgeDays: 90,\n },\n});\n","import { $inject, Alepha } from \"alepha\";\nimport { type UserEntity, users } from \"alepha/api/users\";\nimport { CryptoProvider } from \"alepha/crypto\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { $logger } from \"alepha/logger\";\nimport { $repository, type Page } from \"alepha/orm\";\nimport { BadRequestError, ForbiddenError } from \"alepha/server\";\nimport { type InvitationEntity, invitations } from \"../entities/invitations.ts\";\nimport { InvitationProvider } from \"../providers/InvitationProvider.ts\";\nimport type { CreateInvitation } from \"../schemas/createInvitationSchema.ts\";\nimport { invitationConfigAtom } from \"../schemas/invitationConfigAtom.ts\";\nimport type { InvitationQuery } from \"../schemas/invitationQuerySchema.ts\";\nimport type { InvitationWithResourceInfo } from \"../schemas/invitationWithResourceInfoSchema.ts\";\nimport type { MyInvitationsQuery } from \"../schemas/myInvitationsQuerySchema.ts\";\n\nexport class InvitationService {\n protected readonly alepha = $inject(Alepha);\n protected readonly log = $logger();\n protected readonly repo = $repository(invitations);\n protected readonly users = $repository(users);\n protected readonly crypto = $inject(CryptoProvider);\n protected readonly dateTime = $inject(DateTimeProvider);\n protected readonly provider = $inject(InvitationProvider);\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Get an invitation by ID.\n */\n public async getById(id: string): Promise<InvitationEntity> {\n return this.repo.getById(id);\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Create a new invitation.\n */\n public async create(\n data: CreateInvitation,\n inviter: { id: string; email?: string },\n ): Promise<InvitationEntity> {\n if (data.email === inviter.email) {\n throw new BadRequestError(\"Cannot invite yourself\");\n }\n\n await this.provider.validateResource(\n data.resourceType,\n data.resourceId,\n inviter,\n );\n\n const existingUser = await this.users.findOne({\n where: { email: { eq: data.email } },\n });\n\n if (existingUser) {\n const alreadyMember = await this.provider.isMember(\n data.resourceType,\n data.resourceId,\n data.email,\n existingUser.id,\n );\n\n if (alreadyMember) {\n throw new BadRequestError(\"User is already a member of this resource\");\n }\n }\n\n const pendingForSameTarget = await this.repo.findOne({\n where: {\n resourceType: { eq: data.resourceType },\n resourceId: { eq: data.resourceId },\n email: { eq: data.email },\n status: { eq: \"pending\" },\n },\n });\n\n if (pendingForSameTarget) {\n throw new BadRequestError(\n \"A pending invitation already exists for this email and resource\",\n );\n }\n\n const config = this.alepha.store.get(invitationConfigAtom);\n\n const resourcePendingCount = await this.repo.count({\n resourceType: { eq: data.resourceType },\n resourceId: { eq: data.resourceId },\n status: { eq: \"pending\" },\n });\n\n if (resourcePendingCount >= config.maxPendingPerResource) {\n throw new BadRequestError(\n `Maximum pending invitations per resource reached (${config.maxPendingPerResource})`,\n );\n }\n\n const inviterPendingCount = await this.repo.count({\n invitedBy: { eq: inviter.id },\n status: { eq: \"pending\" },\n });\n\n if (inviterPendingCount >= config.maxPendingPerInviter) {\n throw new BadRequestError(\n `Maximum pending invitations per inviter reached (${config.maxPendingPerInviter})`,\n );\n }\n\n const token = this.crypto.randomUUID();\n const tokenHash = this.crypto.hash(token, \"sha256\");\n const expiresAt = this.dateTime\n .now()\n .add(config.expirationDays, \"days\")\n .toISOString();\n\n const entity = await this.repo.create({\n invitedBy: inviter.id,\n email: data.email,\n resourceType: data.resourceType,\n resourceId: data.resourceId,\n status: \"pending\",\n roles: data.roles,\n metadata: data.metadata,\n token: tokenHash,\n expiresAt,\n });\n\n this.log.info(\"Invitation created\", {\n id: entity.id,\n email: data.email,\n resourceType: data.resourceType,\n resourceId: data.resourceId,\n invitedBy: inviter.id,\n });\n\n await this.alepha.events.emit(\"invitation:created\", {\n invitation: entity,\n token,\n inviter,\n });\n\n return entity;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Accept a pending invitation.\n */\n public async accept(\n invitationId: string,\n acceptedBy: { id: string; email?: string },\n ): Promise<void> {\n const invitation = await this.repo.getById(invitationId);\n\n if (invitation.status !== \"pending\") {\n throw new BadRequestError(\n `Invitation is not pending (current status: ${invitation.status})`,\n );\n }\n\n if (invitation.email !== acceptedBy.email) {\n throw new ForbiddenError(\"This invitation was sent to a different email\");\n }\n\n const now = this.dateTime.now();\n\n if (now.isAfter(invitation.expiresAt)) {\n await this.repo.updateById(invitationId, {\n status: \"expired\",\n resolvedAt: now.toISOString(),\n });\n throw new BadRequestError(\"Invitation has expired\");\n }\n\n const alreadyMember = await this.provider.isMember(\n invitation.resourceType,\n invitation.resourceId,\n invitation.email,\n acceptedBy.id,\n );\n\n if (alreadyMember) {\n await this.repo.updateById(invitationId, {\n status: \"accepted\",\n resolvedAt: now.toISOString(),\n resolvedBy: acceptedBy.id,\n });\n\n this.log.info(\"Invitation accepted (already member)\", {\n id: invitationId,\n acceptedBy: acceptedBy.id,\n });\n\n return;\n }\n\n await this.provider.onAccept(invitation, acceptedBy);\n\n await this.repo.updateById(invitationId, {\n status: \"accepted\",\n resolvedAt: now.toISOString(),\n resolvedBy: acceptedBy.id,\n });\n\n this.log.info(\"Invitation accepted\", {\n id: invitationId,\n email: invitation.email,\n resourceType: invitation.resourceType,\n resourceId: invitation.resourceId,\n acceptedBy: acceptedBy.id,\n });\n\n await this.alepha.events.emit(\"invitation:accepted\", {\n invitation,\n acceptedBy,\n });\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Decline a pending invitation.\n */\n public async decline(\n invitationId: string,\n declinedBy: { id: string; email?: string },\n ): Promise<void> {\n const invitation = await this.repo.getById(invitationId);\n\n if (invitation.status !== \"pending\") {\n throw new BadRequestError(\n `Invitation is not pending (current status: ${invitation.status})`,\n );\n }\n\n if (invitation.email !== declinedBy.email) {\n throw new ForbiddenError(\"This invitation was sent to a different email\");\n }\n\n const now = this.dateTime.now();\n\n await this.repo.updateById(invitationId, {\n status: \"declined\",\n resolvedAt: now.toISOString(),\n resolvedBy: declinedBy.id,\n });\n\n this.log.info(\"Invitation declined\", {\n id: invitationId,\n email: invitation.email,\n resourceType: invitation.resourceType,\n resourceId: invitation.resourceId,\n declinedBy: declinedBy.id,\n });\n\n await this.alepha.events.emit(\"invitation:declined\", {\n invitation,\n declinedBy,\n });\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Revoke a pending invitation (by the inviter or admin).\n */\n public async revoke(\n invitationId: string,\n revokedBy: { id: string },\n ): Promise<void> {\n const invitation = await this.repo.getById(invitationId);\n\n if (invitation.status !== \"pending\") {\n throw new BadRequestError(\n `Invitation is not pending (current status: ${invitation.status})`,\n );\n }\n\n const now = this.dateTime.now();\n\n await this.repo.updateById(invitationId, {\n status: \"revoked\",\n resolvedAt: now.toISOString(),\n resolvedBy: revokedBy.id,\n });\n\n this.log.info(\"Invitation revoked\", {\n id: invitationId,\n email: invitation.email,\n resourceType: invitation.resourceType,\n resourceId: invitation.resourceId,\n revokedBy: revokedBy.id,\n });\n\n await this.alepha.events.emit(\"invitation:revoked\", {\n invitation,\n revokedBy,\n });\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Find invitations for a given email with resource info enrichment.\n */\n public async findByEmail(\n email: string,\n query: MyInvitationsQuery = {},\n ): Promise<InvitationWithResourceInfo[]> {\n const where = this.repo.createQueryWhere();\n where.email = { eq: email };\n\n if (query.status) {\n where.status = { eq: query.status };\n }\n\n const results = await this.repo.findMany({\n where,\n orderBy: { column: \"createdAt\", direction: \"desc\" },\n });\n\n const inviterIds = [...new Set(results.map((inv) => inv.invitedBy))];\n const inviters = await this.loadInviters(inviterIds);\n\n const enriched: InvitationWithResourceInfo[] = [];\n\n for (const inv of results) {\n const inviter = inviters.get(inv.invitedBy);\n let resourceName = inv.resourceType;\n let resourceUrl: string | undefined;\n\n try {\n const info = await this.provider.getResourceInfo(\n inv.resourceType,\n inv.resourceId,\n );\n resourceName = info.name;\n resourceUrl = info.url;\n } catch (error) {\n this.log.warn(\"Failed to load resource info for invitation\", {\n invitationId: inv.id,\n resourceType: inv.resourceType,\n resourceId: inv.resourceId,\n error,\n });\n }\n\n enriched.push({\n id: inv.id,\n email: inv.email,\n resourceType: inv.resourceType,\n resourceId: inv.resourceId,\n resourceName,\n resourceUrl,\n invitedBy: inv.invitedBy,\n inviterName: this.formatInviterName(inviter),\n inviterEmail: inviter?.email,\n roles: inv.roles,\n status: inv.status,\n createdAt: inv.createdAt,\n expiresAt: inv.expiresAt,\n });\n }\n\n return enriched;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Find invitations for a specific resource.\n */\n public async findByResource(\n resourceType: string,\n resourceId: string,\n status?: string,\n ): Promise<InvitationEntity[]> {\n const where = this.repo.createQueryWhere();\n where.resourceType = { eq: resourceType };\n where.resourceId = { eq: resourceId };\n\n if (status) {\n where.status = { eq: status as InvitationEntity[\"status\"] };\n }\n\n return this.repo.findMany({\n where,\n orderBy: { column: \"createdAt\", direction: \"desc\" },\n });\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Find invitations with pagination and filtering (admin).\n */\n public async findInvitations(\n query: InvitationQuery = {},\n ): Promise<Page<InvitationEntity>> {\n query.sort ??= \"-createdAt\";\n\n const where = this.repo.createQueryWhere();\n\n if (query.email) {\n where.email = { like: `%${query.email}%` };\n }\n\n if (query.resourceType) {\n where.resourceType = { eq: query.resourceType };\n }\n\n if (query.resourceId) {\n where.resourceId = { eq: query.resourceId };\n }\n\n if (query.status) {\n where.status = { eq: query.status };\n }\n\n if (query.invitedBy) {\n where.invitedBy = { eq: query.invitedBy };\n }\n\n return this.repo.paginate(query, { where }, { count: true });\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Delete an invitation (admin). Only non-pending invitations can be deleted.\n */\n public async deleteInvitation(id: string): Promise<void> {\n const invitation = await this.repo.getById(id);\n\n if (invitation.status === \"pending\") {\n throw new BadRequestError(\n \"Cannot delete a pending invitation. Revoke it first.\",\n );\n }\n\n await this.repo.deleteById(id);\n\n this.log.info(\"Invitation deleted\", { id });\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Expire all pending invitations that have passed their expiration date.\n * Returns the number of expired invitations.\n */\n public async expirePending(): Promise<number> {\n const now = this.dateTime.nowISOString();\n\n const expired = await this.repo.findMany({\n where: {\n status: { eq: \"pending\" },\n expiresAt: { lt: now },\n },\n });\n\n if (expired.length === 0) {\n return 0;\n }\n\n const ids = expired.map((inv) => inv.id);\n\n await this.repo.updateMany(\n { id: { inArray: ids } },\n {\n status: \"expired\",\n resolvedAt: now,\n },\n );\n\n for (const inv of expired) {\n await this.alepha.events.emit(\"invitation:expired\", {\n invitation: inv,\n });\n }\n\n this.log.info(\"Expired pending invitations\", { count: expired.length });\n\n return expired.length;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Purge resolved invitations older than the configured purge days.\n * Returns the number of purged invitations.\n */\n public async purgeResolved(): Promise<number> {\n const config = this.alepha.store.get(invitationConfigAtom);\n\n if (config.purgeDays === 0) {\n return 0;\n }\n\n const cutoff = this.dateTime\n .now()\n .subtract(config.purgeDays, \"days\")\n .toISOString();\n\n const ids = await this.repo.deleteMany({\n status: { inArray: [\"accepted\", \"declined\", \"expired\", \"revoked\"] },\n resolvedAt: { lt: cutoff },\n });\n\n if (ids.length > 0) {\n this.log.info(\"Purged resolved invitations\", { count: ids.length });\n }\n\n return ids.length;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Load user records for a list of inviter IDs.\n */\n protected async loadInviters(\n ids: string[],\n ): Promise<Map<string, UserEntity>> {\n if (ids.length === 0) {\n return new Map();\n }\n\n const result = await this.users.findMany({\n where: { id: { inArray: ids } },\n });\n\n return new Map(result.map((user) => [user.id, user]));\n }\n\n /**\n * Format inviter display name from user entity.\n */\n protected formatInviterName(user?: UserEntity): string | undefined {\n if (!user) {\n return undefined;\n }\n\n if (user.firstName && user.lastName) {\n return `${user.firstName} ${user.lastName}`;\n }\n\n if (user.firstName) {\n return user.firstName;\n }\n\n return user.username ?? user.email;\n }\n}\n","import { $inject, t } from \"alepha\";\nimport { $secure } from \"alepha/security\";\nimport { $action, okSchema } from \"alepha/server\";\nimport { invitationQuerySchema } from \"../schemas/invitationQuerySchema.ts\";\nimport { invitationResourceSchema } from \"../schemas/invitationResourceSchema.ts\";\nimport { InvitationService } from \"../services/InvitationService.ts\";\n\nexport class AdminInvitationController {\n protected readonly url = \"/invitations\";\n protected readonly group = \"admin:invitations\";\n protected readonly invitationService = $inject(InvitationService);\n\n /**\n * Find invitations with pagination and filtering.\n */\n public readonly findInvitations = $action({\n path: this.url,\n group: this.group,\n use: [$secure({ permissions: [\"admin:invitation:read\"] })],\n description: \"Find invitations with pagination and filtering\",\n schema: {\n query: invitationQuerySchema,\n response: t.page(invitationResourceSchema),\n },\n handler: ({ query }) => this.invitationService.findInvitations(query),\n });\n\n /**\n * Get an invitation by ID.\n */\n public readonly getInvitation = $action({\n path: `${this.url}/:id`,\n group: this.group,\n use: [$secure({ permissions: [\"admin:invitation:read\"] })],\n description: \"Get an invitation by ID\",\n schema: {\n params: t.object({\n id: t.uuid(),\n }),\n response: invitationResourceSchema,\n },\n handler: ({ params }) => this.invitationService.getById(params.id),\n });\n\n /**\n * Revoke a pending invitation.\n */\n public readonly revokeInvitation = $action({\n method: \"POST\",\n path: `${this.url}/:id/revoke`,\n group: this.group,\n use: [$secure({ permissions: [\"admin:invitation:delete\"] })],\n description: \"Revoke a pending invitation\",\n schema: {\n params: t.object({\n id: t.uuid(),\n }),\n response: okSchema,\n },\n handler: async ({ params, user }) => {\n await this.invitationService.revoke(params.id, { id: user.id });\n return { ok: true };\n },\n });\n\n /**\n * Delete an invitation.\n */\n public readonly deleteInvitation = $action({\n method: \"DELETE\",\n path: `${this.url}/:id`,\n group: this.group,\n use: [$secure({ permissions: [\"admin:invitation:delete\"] })],\n description: \"Delete an invitation\",\n schema: {\n params: t.object({\n id: t.uuid(),\n }),\n response: okSchema,\n },\n handler: async ({ params }) => {\n await this.invitationService.deleteInvitation(params.id);\n return { ok: true, id: params.id };\n },\n });\n}\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const createInvitationSchema = t.object({\n email: t.string({ format: \"email\" }),\n resourceType: t.text({ minLength: 1, maxLength: 100 }),\n resourceId: t.text({ minLength: 1, maxLength: 255 }),\n roles: t.optional(t.array(t.text())),\n metadata: t.optional(t.record(t.text(), t.any())),\n});\n\nexport type CreateInvitation = Static<typeof createInvitationSchema>;\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const invitationWithResourceInfoSchema = t.object({\n id: t.uuid(),\n email: t.string({ format: \"email\" }),\n resourceType: t.text(),\n resourceId: t.text(),\n resourceName: t.text(),\n resourceUrl: t.optional(t.text()),\n invitedBy: t.uuid(),\n inviterName: t.optional(t.text()),\n inviterEmail: t.optional(t.string({ format: \"email\" })),\n roles: t.optional(t.array(t.text())),\n status: t.enum([\"pending\", \"accepted\", \"declined\", \"expired\", \"revoked\"]),\n createdAt: t.datetime(),\n expiresAt: t.datetime(),\n});\n\nexport type InvitationWithResourceInfo = Static<\n typeof invitationWithResourceInfoSchema\n>;\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const myInvitationsQuerySchema = t.object({\n status: t.optional(\n t.enum([\"pending\", \"accepted\", \"declined\", \"expired\", \"revoked\"]),\n ),\n});\n\nexport type MyInvitationsQuery = Static<typeof myInvitationsQuerySchema>;\n","import { $inject, t } from \"alepha\";\nimport { $secure } from \"alepha/security\";\nimport { $action, okSchema } from \"alepha/server\";\nimport { createInvitationSchema } from \"../schemas/createInvitationSchema.ts\";\nimport { invitationResourceSchema } from \"../schemas/invitationResourceSchema.ts\";\nimport { invitationWithResourceInfoSchema } from \"../schemas/invitationWithResourceInfoSchema.ts\";\nimport { myInvitationsQuerySchema } from \"../schemas/myInvitationsQuerySchema.ts\";\nimport { InvitationService } from \"../services/InvitationService.ts\";\n\nexport class InvitationController {\n protected readonly url = \"/invitations\";\n protected readonly group = \"invitations\";\n protected readonly invitationService = $inject(InvitationService);\n\n /**\n * Create a new invitation.\n */\n public readonly createInvitation = $action({\n method: \"POST\",\n path: this.url,\n group: this.group,\n use: [$secure({ permissions: [\"invitation:create\"] })],\n description: \"Create a new invitation\",\n schema: {\n body: createInvitationSchema,\n response: invitationResourceSchema,\n },\n handler: ({ body, user }) => this.invitationService.create(body, user),\n });\n\n /**\n * List invitations for the current user.\n */\n public readonly getMyInvitations = $action({\n path: `${this.url}/mine`,\n group: this.group,\n use: [$secure()],\n description: \"List invitations for the current user\",\n schema: {\n query: myInvitationsQuerySchema,\n response: t.array(invitationWithResourceInfoSchema),\n },\n handler: ({ query, user }) =>\n this.invitationService.findByEmail(user.email!, query),\n });\n\n /**\n * Accept an invitation.\n */\n public readonly acceptInvitation = $action({\n method: \"POST\",\n path: `${this.url}/:id/accept`,\n group: this.group,\n use: [$secure()],\n description: \"Accept an invitation\",\n schema: {\n params: t.object({ id: t.uuid() }),\n response: okSchema,\n },\n handler: async ({ params, user }) => {\n await this.invitationService.accept(params.id, user);\n return { ok: true };\n },\n });\n\n /**\n * Decline an invitation.\n */\n public readonly declineInvitation = $action({\n method: \"POST\",\n path: `${this.url}/:id/decline`,\n group: this.group,\n use: [$secure()],\n description: \"Decline an invitation\",\n schema: {\n params: t.object({ id: t.uuid() }),\n response: okSchema,\n },\n handler: async ({ params, user }) => {\n await this.invitationService.decline(params.id, user);\n return { ok: true };\n },\n });\n}\n","import { $inject } from \"alepha\";\nimport { $job } from \"alepha/api/jobs\";\nimport { $logger } from \"alepha/logger\";\nimport { InvitationService } from \"../services/InvitationService.ts\";\n\nexport class InvitationJobs {\n protected readonly log = $logger();\n protected readonly invitationService = $inject(InvitationService);\n\n /**\n * Expire pending invitations that have passed their expiration date.\n */\n public readonly expireInvitations = $job({\n cron: \"0 * * * *\",\n lock: true,\n handler: async () => {\n const count = await this.invitationService.expirePending();\n if (count > 0) {\n this.log.info(`Expired ${count} invitations`);\n }\n },\n });\n\n /**\n * Purge old resolved invitations.\n */\n public readonly purgeInvitations = $job({\n cron: \"0 3 * * *\",\n lock: true,\n handler: async () => {\n const count = await this.invitationService.purgeResolved();\n if (count > 0) {\n this.log.info(`Purged ${count} old invitations`);\n }\n },\n });\n}\n","import { $module } from \"alepha\";\nimport { AdminInvitationController } from \"./controllers/AdminInvitationController.ts\";\nimport { InvitationController } from \"./controllers/InvitationController.ts\";\nimport { InvitationJobs } from \"./jobs/InvitationJobs.ts\";\nimport { InvitationService } from \"./services/InvitationService.ts\";\n\nexport * from \"./controllers/AdminInvitationController.ts\";\nexport * from \"./controllers/InvitationController.ts\";\nexport * from \"./entities/invitations.ts\";\nexport * from \"./jobs/InvitationJobs.ts\";\nexport * from \"./providers/InvitationProvider.ts\";\nexport * from \"./schemas/createInvitationSchema.ts\";\nexport * from \"./schemas/invitationConfigAtom.ts\";\nexport * from \"./schemas/invitationQuerySchema.ts\";\nexport * from \"./schemas/invitationResourceSchema.ts\";\nexport * from \"./schemas/invitationWithResourceInfoSchema.ts\";\nexport * from \"./schemas/myInvitationsQuerySchema.ts\";\nexport * from \"./services/InvitationService.ts\";\n\ndeclare module \"alepha\" {\n interface Hooks {\n \"invitation:created\": {\n invitation: import(\"./entities/invitations.ts\").InvitationEntity;\n token: string;\n inviter: { id: string; email?: string };\n };\n \"invitation:accepted\": {\n invitation: import(\"./entities/invitations.ts\").InvitationEntity;\n acceptedBy: { id: string; email?: string };\n };\n \"invitation:declined\": {\n invitation: import(\"./entities/invitations.ts\").InvitationEntity;\n declinedBy: { id: string; email?: string };\n };\n \"invitation:expired\": {\n invitation: import(\"./entities/invitations.ts\").InvitationEntity;\n };\n \"invitation:revoked\": {\n invitation: import(\"./entities/invitations.ts\").InvitationEntity;\n revokedBy: { id: string };\n };\n }\n}\n\n/**\n * Invitation management module — create, accept, decline, revoke, and expire invitations.\n *\n * @module alepha.api.invitations\n */\nexport const AlephaApiInvitations = $module({\n name: \"alepha.api.invitations\",\n services: [\n InvitationService,\n InvitationJobs,\n InvitationController,\n AdminInvitationController,\n ],\n register: (alepha) => {\n alepha\n .with(InvitationService)\n .with(InvitationJobs)\n .with(InvitationController)\n .with(AdminInvitationController);\n },\n});\n"],"mappings":";;;;;;;;;;AAIA,MAAa,wBAAwB,EAAE,OAAO,iBAAiB;CAC7D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,2BAA2B,CAAC,CAAC;CACrE,cAAc,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,2BAA2B,CAAC,CAAC;CAC5E,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,yBAAyB,CAAC,CAAC;CACxE,QAAQ,EAAE,SACR,EAAE,KAAK;EAAC;EAAW;EAAY;EAAY;EAAW;EAAU,CAAC,CAClE;CACD,WAAW,EAAE,SAAS,EA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ACpB,KAAK,qBAAqB,CAC1B,KAAK,0BAA0B;;CAErC,CAAC"}
|
|
@@ -17,7 +17,6 @@ const jobExecutionEntity = $entity({
|
|
|
17
17
|
"retrying",
|
|
18
18
|
"running",
|
|
19
19
|
"completed",
|
|
20
|
-
"failed",
|
|
21
20
|
"dead",
|
|
22
21
|
"cancelled"
|
|
23
22
|
]), "pending"),
|
|
@@ -90,7 +89,8 @@ const jobConfig = $atom({
|
|
|
90
89
|
}),
|
|
91
90
|
delayed: t.object({ interval: t.integer({ description: "Sweep interval (ms)." }) }),
|
|
92
91
|
logRetentionDays: t.integer({ description: "Days to keep completed/dead executions." }),
|
|
93
|
-
logMaxEntries: t.integer({ description: "Max log entries captured per execution." })
|
|
92
|
+
logMaxEntries: t.integer({ description: "Max log entries captured per execution." }),
|
|
93
|
+
drainTimeout: t.integer({ description: "Max time (ms) to wait for in-flight jobs during shutdown." })
|
|
94
94
|
}),
|
|
95
95
|
default: {
|
|
96
96
|
recovery: {
|
|
@@ -100,7 +100,8 @@ const jobConfig = $atom({
|
|
|
100
100
|
},
|
|
101
101
|
delayed: { interval: 3e5 },
|
|
102
102
|
logRetentionDays: 30,
|
|
103
|
-
logMaxEntries: 100
|
|
103
|
+
logMaxEntries: 100,
|
|
104
|
+
drainTimeout: 3e4
|
|
104
105
|
}
|
|
105
106
|
});
|
|
106
107
|
//#endregion
|
|
@@ -117,6 +118,7 @@ const jobCronInfoSchema = t.object({
|
|
|
117
118
|
]),
|
|
118
119
|
concurrency: t.integer(),
|
|
119
120
|
hasSchema: t.boolean(),
|
|
121
|
+
paused: t.boolean(),
|
|
120
122
|
lastExecution: t.optional(t.object({
|
|
121
123
|
id: t.uuid(),
|
|
122
124
|
status: t.text(),
|
|
@@ -154,7 +156,6 @@ const jobExecutionQuerySchema = t.extend(pageQuerySchema, {
|
|
|
154
156
|
"retrying",
|
|
155
157
|
"running",
|
|
156
158
|
"completed",
|
|
157
|
-
"failed",
|
|
158
159
|
"dead",
|
|
159
160
|
"cancelled"
|
|
160
161
|
])),
|
|
@@ -183,7 +184,8 @@ const jobQueueDepthSchema = t.object({
|
|
|
183
184
|
scheduled: t.integer(),
|
|
184
185
|
retrying: t.integer(),
|
|
185
186
|
dead: t.integer(),
|
|
186
|
-
concurrency: t.integer()
|
|
187
|
+
concurrency: t.integer(),
|
|
188
|
+
paused: t.boolean()
|
|
187
189
|
});
|
|
188
190
|
//#endregion
|
|
189
191
|
//#region ../../src/api/jobs/schemas/jobRegistrationSchema.ts
|
|
@@ -208,10 +210,7 @@ const jobRegistrationSchema = t.object({
|
|
|
208
210
|
retries: t.integer(),
|
|
209
211
|
hasBackoff: t.boolean()
|
|
210
212
|
})),
|
|
211
|
-
|
|
212
|
-
size: t.integer(),
|
|
213
|
-
window: t.text()
|
|
214
|
-
}))
|
|
213
|
+
paused: t.boolean()
|
|
215
214
|
});
|
|
216
215
|
//#endregion
|
|
217
216
|
//#region ../../src/api/jobs/schemas/jobStatsSchema.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.js","names":[],"sources":["../../../src/api/jobs/entities/jobExecutionEntity.ts","../../../src/api/jobs/entities/jobExecutionLogEntity.ts","../../../src/api/jobs/schemas/jobActivitySchema.ts","../../../src/api/jobs/schemas/jobConfigAtom.ts","../../../src/api/jobs/schemas/jobCronInfoSchema.ts","../../../src/api/jobs/schemas/jobExecutionResourceSchema.ts","../../../src/api/jobs/schemas/jobExecutionDetailResourceSchema.ts","../../../src/api/jobs/schemas/jobExecutionQuerySchema.ts","../../../src/api/jobs/schemas/jobFailureSchema.ts","../../../src/api/jobs/schemas/jobQueueDepthSchema.ts","../../../src/api/jobs/schemas/jobRegistrationSchema.ts","../../../src/api/jobs/schemas/jobStatsSchema.ts","../../../src/api/jobs/schemas/triggerJobSchema.ts","../../../src/api/jobs/index.browser.ts"],"sourcesContent":["import { type Static, t } from \"alepha\";\nimport { $entity, db } from \"alepha/orm\";\n\nexport const jobExecutionEntity = $entity({\n name: \"job_executions\",\n schema: t.object({\n id: db.primaryKey(t.uuid()),\n createdAt: db.createdAt(),\n updatedAt: db.updatedAt(),\n\n jobName: t.text(),\n key: t.optional(t.nullable(t.text())),\n\n payload: t.optional(t.record(t.text(), t.any())),\n status: db.default(\n t.enum([\n \"pending\",\n \"scheduled\",\n \"retrying\",\n \"running\",\n \"completed\",\n \"failed\",\n \"dead\",\n \"cancelled\",\n ]),\n \"pending\",\n ),\n priority: db.default(t.integer({ minimum: 0, maximum: 3 }), 2),\n\n attempt: db.default(t.integer(), 0),\n maxAttempts: db.default(t.integer(), 1),\n\n scheduledAt: t.optional(t.datetime()),\n startedAt: t.optional(t.datetime()),\n completedAt: t.optional(t.datetime()),\n\n result: t.optional(t.record(t.text(), t.any())),\n error: t.optional(t.text()),\n workerId: t.optional(t.text()),\n\n triggeredBy: t.optional(t.text()),\n triggeredByName: t.optional(t.text()),\n cancelledBy: t.optional(t.text()),\n cancelledByName: t.optional(t.text()),\n }),\n indexes: [\n { columns: [\"jobName\", \"status\", \"priority\", \"scheduledAt\"] },\n { columns: [\"jobName\", \"status\", \"startedAt\"] },\n { columns: [\"jobName\", \"completedAt\"] },\n { columns: [\"jobName\", \"key\"], unique: true },\n ],\n});\n\nexport type JobExecutionEntity = Static<typeof jobExecutionEntity.schema>;\n\nexport type JobStatus =\n | \"pending\"\n | \"scheduled\"\n | \"retrying\"\n | \"running\"\n | \"completed\"\n | \"failed\"\n | \"dead\"\n | \"cancelled\";\n","import { type Static, t } from \"alepha\";\nimport { logEntrySchema } from \"alepha/logger\";\nimport { $entity, db } from \"alepha/orm\";\n\nexport const jobExecutionLogEntity = $entity({\n name: \"job_execution_logs\",\n schema: t.object({\n id: db.primaryKey(t.uuid()),\n logs: t.array(logEntrySchema),\n }),\n});\n\nexport type JobExecutionLogEntity = Static<typeof jobExecutionLogEntity.schema>;\n","import { type Static, t } from \"alepha\";\n\nexport const jobActivityPointSchema = t.object({\n date: t.text(),\n completed: t.integer(),\n failed: t.integer(),\n});\n\nexport type JobActivityPoint = Static<typeof jobActivityPointSchema>;\n\nexport const jobActivityQuerySchema = t.object({\n days: t.optional(t.integer({ minimum: 1, maximum: 90 })),\n});\n\nexport type JobActivityQuery = Static<typeof jobActivityQuerySchema>;\n","import { $atom, type Static, t } from \"alepha\";\n\nexport const jobConfig = $atom({\n name: \"alepha.jobs\",\n description: \"Configuration for the $job v2 primitive.\",\n schema: t.object({\n recovery: t.object({\n interval: t.integer({ description: \"Sweep interval (ms).\" }),\n staleThreshold: t.integer({\n description: \"Pending age (ms) before re-dispatch.\",\n }),\n runTimeout: t.integer({\n description:\n \"Running age (ms) before assumed crash. Used as fallback when no per-job timeout is set.\",\n }),\n }),\n delayed: t.object({\n interval: t.integer({ description: \"Sweep interval (ms).\" }),\n }),\n logRetentionDays: t.integer({\n description: \"Days to keep completed/dead executions.\",\n }),\n logMaxEntries: t.integer({\n description: \"Max log entries captured per execution.\",\n }),\n }),\n default: {\n recovery: {\n interval: 300_000,\n staleThreshold: 300_000,\n runTimeout: 1_800_000,\n },\n delayed: {\n interval: 300_000,\n },\n logRetentionDays: 30,\n logMaxEntries: 100,\n },\n});\n\nexport type JobConfig = Static<typeof jobConfig.schema>;\n\ndeclare module \"alepha\" {\n interface State {\n [jobConfig.key]: JobConfig;\n }\n}\n","import { type Static, t } from \"alepha\";\n\nexport const jobCronInfoSchema = t.object({\n name: t.text(),\n cron: t.text(),\n lock: t.boolean(),\n priority: t.enum([\"critical\", \"high\", \"normal\", \"low\"]),\n concurrency: t.integer(),\n hasSchema: t.boolean(),\n lastExecution: t.optional(\n t.object({\n id: t.uuid(),\n status: t.text(),\n startedAt: t.optional(t.datetime()),\n completedAt: t.optional(t.datetime()),\n error: t.optional(t.text()),\n }),\n ),\n});\n\nexport type JobCronInfo = Static<typeof jobCronInfoSchema>;\n","import { type Static, t } from \"alepha\";\nimport { jobExecutionEntity } from \"../entities/jobExecutionEntity.ts\";\n\nexport const jobExecutionCanSchema = t.object({\n retry: t.boolean(),\n cancel: t.boolean(),\n});\n\nexport const jobExecutionResourceSchema = t.extend(\n jobExecutionEntity.schema,\n {\n can: jobExecutionCanSchema,\n },\n {\n title: \"JobExecutionResource\",\n description: \"A job execution resource.\",\n },\n);\n\nexport type JobExecutionResource = Static<typeof jobExecutionResourceSchema>;\n","import { type Static, t } from \"alepha\";\nimport { logEntrySchema } from \"alepha/logger\";\nimport { jobExecutionEntity } from \"../entities/jobExecutionEntity.ts\";\nimport { jobExecutionCanSchema } from \"./jobExecutionResourceSchema.ts\";\n\nexport const jobExecutionDetailResourceSchema = t.extend(\n jobExecutionEntity.schema,\n {\n can: jobExecutionCanSchema,\n logs: t.optional(t.array(logEntrySchema)),\n },\n {\n title: \"JobExecutionDetailResource\",\n description: \"A job execution resource with logs.\",\n },\n);\n\nexport type JobExecutionDetailResource = Static<\n typeof jobExecutionDetailResourceSchema\n>;\n","import { type Static, t } from \"alepha\";\nimport { pageQuerySchema } from \"alepha/orm\";\n\nexport const jobExecutionQuerySchema = t.extend(pageQuerySchema, {\n job: t.optional(\n t.text({\n description: \"Filter by job name\",\n }),\n ),\n status: t.optional(\n t.enum([\n \"pending\",\n \"scheduled\",\n \"retrying\",\n \"running\",\n \"completed\",\n \"failed\",\n \"dead\",\n \"cancelled\",\n ]),\n ),\n priority: t.optional(t.enum([\"critical\", \"high\", \"normal\", \"low\"])),\n from: t.optional(\n t.datetime({\n description: \"From date (ISO)\",\n }),\n ),\n to: t.optional(\n t.datetime({\n description: \"To date (ISO)\",\n }),\n ),\n});\n\nexport type JobExecutionQuery = Static<typeof jobExecutionQuerySchema>;\n","import { type Static, t } from \"alepha\";\n\nexport const jobFailureSchema = t.object({\n jobName: t.text(),\n failures: t.integer(),\n lastError: t.optional(t.text()),\n});\n\nexport type JobFailure = Static<typeof jobFailureSchema>;\n","import { type Static, t } from \"alepha\";\n\nexport const jobQueueDepthSchema = t.object({\n jobName: t.text(),\n pending: t.integer(),\n running: t.integer(),\n scheduled: t.integer(),\n retrying: t.integer(),\n dead: t.integer(),\n concurrency: t.integer(),\n});\n\nexport type JobQueueDepth = Static<typeof jobQueueDepthSchema>;\n","import { type Static, t } from \"alepha\";\n\nexport const jobRegistrationSchema = t.object({\n name: t.text(),\n type: t.enum([\"cron\", \"push\", \"both\"]),\n priority: t.enum([\"critical\", \"high\", \"normal\", \"low\"]),\n concurrency: t.integer(),\n hasSchema: t.boolean(),\n cron: t.optional(t.text()),\n timeout: t.optional(t.text()),\n retry: t.optional(\n t.object({\n retries: t.integer(),\n hasBackoff: t.boolean(),\n }),\n ),\n batch: t.optional(\n t.object({\n size: t.integer(),\n window: t.text(),\n }),\n ),\n});\n\nexport type JobRegistration = Static<typeof jobRegistrationSchema>;\n","import { type Static, t } from \"alepha\";\n\nexport const jobStatsSchema = t.object({\n registered: t.integer(),\n running: t.integer(),\n pending: t.integer(),\n scheduled: t.integer(),\n retrying: t.integer(),\n dead: t.integer(),\n completed: t.integer(),\n failed: t.integer(),\n});\n\nexport type JobStats = Static<typeof jobStatsSchema>;\n","import { type Static, t } from \"alepha\";\n\nexport const triggerJobSchema = t.object({\n name: t.text(),\n payload: t.optional(t.record(t.text(), t.any())),\n});\n\nexport type TriggerJob = Static<typeof triggerJobSchema>;\n","import { $module } from \"alepha\";\n\n// -----------------------------------------------------------------------------------------------------------------\n\nexport * from \"./entities/jobExecutionEntity.ts\";\nexport * from \"./entities/jobExecutionLogEntity.ts\";\nexport * from \"./schemas/jobActivitySchema.ts\";\nexport * from \"./schemas/jobConfigAtom.ts\";\nexport * from \"./schemas/jobCronInfoSchema.ts\";\nexport * from \"./schemas/jobExecutionDetailResourceSchema.ts\";\nexport * from \"./schemas/jobExecutionQuerySchema.ts\";\nexport * from \"./schemas/jobExecutionResourceSchema.ts\";\nexport * from \"./schemas/jobFailureSchema.ts\";\nexport * from \"./schemas/jobQueueDepthSchema.ts\";\nexport * from \"./schemas/jobRegistrationSchema.ts\";\nexport * from \"./schemas/jobStatsSchema.ts\";\nexport * from \"./schemas/triggerJobSchema.ts\";\n\n// -----------------------------------------------------------------------------------------------------------------\n\nexport const AlephaApiJobs = $module({\n name: \"alepha.api.jobs\",\n services: [],\n});\n"],"mappings":";;;;AAGA,MAAa,qBAAqB,QAAQ;CACxC,MAAM;CACN,QAAQ,EAAE,OAAO;EACf,IAAI,GAAG,WAAW,EAAE,MAAM,CAAC;EAC3B,WAAW,GAAG,WAAW;EACzB,WAAW,GAAG,WAAW;EAEzB,SAAS,EAAE,MAAM;EACjB,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;EAErC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;EAChD,QAAQ,GAAG,QACT,EAAE,KAAK;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EACF,UACD;EACD,UAAU,GAAG,QAAQ,EAAE,QAAQ;GAAE,SAAS;GAAG,SAAS;GAAG,CAAC,EAAE,EAAE;EAE9D,SAAS,GAAG,QAAQ,EAAE,SAAS,EAAE,EAAE;EACnC,aAAa,GAAG,QAAQ,EAAE,SAAS,EAAE,EAAE;EAEvC,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC;EACrC,WAAW,EAAE,SAAS,EAAE,UAAU,CAAC;EACnC,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC;EAErC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;EAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC;EAC3B,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC;EAE9B,aAAa,EAAE,SAAS,EAAE,MAAM,CAAC;EACjC,iBAAiB,EAAE,SAAS,EAAE,MAAM,CAAC;EACrC,aAAa,EAAE,SAAS,EAAE,MAAM,CAAC;EACjC,iBAAiB,EAAE,SAAS,EAAE,MAAM,CAAC;EACtC,CAAC;CACF,SAAS;EACP,EAAE,SAAS;GAAC;GAAW;G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CACnC,MAAM;CACN,UAAU,EAAE;CACb,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.browser.js","names":[],"sources":["../../../src/api/jobs/entities/jobExecutionEntity.ts","../../../src/api/jobs/entities/jobExecutionLogEntity.ts","../../../src/api/jobs/schemas/jobActivitySchema.ts","../../../src/api/jobs/schemas/jobConfigAtom.ts","../../../src/api/jobs/schemas/jobCronInfoSchema.ts","../../../src/api/jobs/schemas/jobExecutionResourceSchema.ts","../../../src/api/jobs/schemas/jobExecutionDetailResourceSchema.ts","../../../src/api/jobs/schemas/jobExecutionQuerySchema.ts","../../../src/api/jobs/schemas/jobFailureSchema.ts","../../../src/api/jobs/schemas/jobQueueDepthSchema.ts","../../../src/api/jobs/schemas/jobRegistrationSchema.ts","../../../src/api/jobs/schemas/jobStatsSchema.ts","../../../src/api/jobs/schemas/triggerJobSchema.ts","../../../src/api/jobs/index.browser.ts"],"sourcesContent":["import { type Static, t } from \"alepha\";\nimport { $entity, db } from \"alepha/orm\";\n\nexport const jobExecutionEntity = $entity({\n name: \"job_executions\",\n schema: t.object({\n id: db.primaryKey(t.uuid()),\n createdAt: db.createdAt(),\n updatedAt: db.updatedAt(),\n\n jobName: t.text(),\n key: t.optional(t.nullable(t.text())),\n\n payload: t.optional(t.record(t.text(), t.any())),\n status: db.default(\n t.enum([\n \"pending\",\n \"scheduled\",\n \"retrying\",\n \"running\",\n \"completed\",\n \"dead\",\n \"cancelled\",\n ]),\n \"pending\",\n ),\n priority: db.default(t.integer({ minimum: 0, maximum: 3 }), 2),\n\n attempt: db.default(t.integer(), 0),\n maxAttempts: db.default(t.integer(), 1),\n\n scheduledAt: t.optional(t.datetime()),\n startedAt: t.optional(t.datetime()),\n completedAt: t.optional(t.datetime()),\n\n result: t.optional(t.record(t.text(), t.any())),\n error: t.optional(t.text()),\n workerId: t.optional(t.text()),\n\n triggeredBy: t.optional(t.text()),\n triggeredByName: t.optional(t.text()),\n cancelledBy: t.optional(t.text()),\n cancelledByName: t.optional(t.text()),\n }),\n indexes: [\n { columns: [\"jobName\", \"status\", \"priority\", \"scheduledAt\"] },\n { columns: [\"jobName\", \"status\", \"startedAt\"] },\n { columns: [\"jobName\", \"completedAt\"] },\n { columns: [\"jobName\", \"key\"], unique: true },\n ],\n});\n\nexport type JobExecutionEntity = Static<typeof jobExecutionEntity.schema>;\n\nexport type JobStatus =\n | \"pending\"\n | \"scheduled\"\n | \"retrying\"\n | \"running\"\n | \"completed\"\n | \"dead\"\n | \"cancelled\";\n","import { type Static, t } from \"alepha\";\nimport { logEntrySchema } from \"alepha/logger\";\nimport { $entity, db } from \"alepha/orm\";\n\nexport const jobExecutionLogEntity = $entity({\n name: \"job_execution_logs\",\n schema: t.object({\n id: db.primaryKey(t.uuid()),\n logs: t.array(logEntrySchema),\n }),\n});\n\nexport type JobExecutionLogEntity = Static<typeof jobExecutionLogEntity.schema>;\n","import { type Static, t } from \"alepha\";\n\nexport const jobActivityPointSchema = t.object({\n date: t.text(),\n completed: t.integer(),\n failed: t.integer(),\n});\n\nexport type JobActivityPoint = Static<typeof jobActivityPointSchema>;\n\nexport const jobActivityQuerySchema = t.object({\n days: t.optional(t.integer({ minimum: 1, maximum: 90 })),\n});\n\nexport type JobActivityQuery = Static<typeof jobActivityQuerySchema>;\n","import { $atom, type Static, t } from \"alepha\";\n\nexport const jobConfig = $atom({\n name: \"alepha.jobs\",\n description: \"Configuration for the $job v2 primitive.\",\n schema: t.object({\n recovery: t.object({\n interval: t.integer({ description: \"Sweep interval (ms).\" }),\n staleThreshold: t.integer({\n description: \"Pending age (ms) before re-dispatch.\",\n }),\n runTimeout: t.integer({\n description:\n \"Running age (ms) before assumed crash. Used as fallback when no per-job timeout is set.\",\n }),\n }),\n delayed: t.object({\n interval: t.integer({ description: \"Sweep interval (ms).\" }),\n }),\n logRetentionDays: t.integer({\n description: \"Days to keep completed/dead executions.\",\n }),\n logMaxEntries: t.integer({\n description: \"Max log entries captured per execution.\",\n }),\n drainTimeout: t.integer({\n description: \"Max time (ms) to wait for in-flight jobs during shutdown.\",\n }),\n }),\n default: {\n recovery: {\n interval: 300_000,\n staleThreshold: 300_000,\n runTimeout: 1_800_000,\n },\n delayed: {\n interval: 300_000,\n },\n logRetentionDays: 30,\n logMaxEntries: 100,\n drainTimeout: 30_000,\n },\n});\n\nexport type JobConfig = Static<typeof jobConfig.schema>;\n\ndeclare module \"alepha\" {\n interface State {\n [jobConfig.key]: JobConfig;\n }\n}\n","import { type Static, t } from \"alepha\";\n\nexport const jobCronInfoSchema = t.object({\n name: t.text(),\n cron: t.text(),\n lock: t.boolean(),\n priority: t.enum([\"critical\", \"high\", \"normal\", \"low\"]),\n concurrency: t.integer(),\n hasSchema: t.boolean(),\n paused: t.boolean(),\n lastExecution: t.optional(\n t.object({\n id: t.uuid(),\n status: t.text(),\n startedAt: t.optional(t.datetime()),\n completedAt: t.optional(t.datetime()),\n error: t.optional(t.text()),\n }),\n ),\n});\n\nexport type JobCronInfo = Static<typeof jobCronInfoSchema>;\n","import { type Static, t } from \"alepha\";\nimport { jobExecutionEntity } from \"../entities/jobExecutionEntity.ts\";\n\nexport const jobExecutionCanSchema = t.object({\n retry: t.boolean(),\n cancel: t.boolean(),\n});\n\nexport const jobExecutionResourceSchema = t.extend(\n jobExecutionEntity.schema,\n {\n can: jobExecutionCanSchema,\n },\n {\n title: \"JobExecutionResource\",\n description: \"A job execution resource.\",\n },\n);\n\nexport type JobExecutionResource = Static<typeof jobExecutionResourceSchema>;\n","import { type Static, t } from \"alepha\";\nimport { logEntrySchema } from \"alepha/logger\";\nimport { jobExecutionEntity } from \"../entities/jobExecutionEntity.ts\";\nimport { jobExecutionCanSchema } from \"./jobExecutionResourceSchema.ts\";\n\nexport const jobExecutionDetailResourceSchema = t.extend(\n jobExecutionEntity.schema,\n {\n can: jobExecutionCanSchema,\n logs: t.optional(t.array(logEntrySchema)),\n },\n {\n title: \"JobExecutionDetailResource\",\n description: \"A job execution resource with logs.\",\n },\n);\n\nexport type JobExecutionDetailResource = Static<\n typeof jobExecutionDetailResourceSchema\n>;\n","import { type Static, t } from \"alepha\";\nimport { pageQuerySchema } from \"alepha/orm\";\n\nexport const jobExecutionQuerySchema = t.extend(pageQuerySchema, {\n job: t.optional(\n t.text({\n description: \"Filter by job name\",\n }),\n ),\n status: t.optional(\n t.enum([\n \"pending\",\n \"scheduled\",\n \"retrying\",\n \"running\",\n \"completed\",\n \"dead\",\n \"cancelled\",\n ]),\n ),\n priority: t.optional(t.enum([\"critical\", \"high\", \"normal\", \"low\"])),\n from: t.optional(\n t.datetime({\n description: \"From date (ISO)\",\n }),\n ),\n to: t.optional(\n t.datetime({\n description: \"To date (ISO)\",\n }),\n ),\n});\n\nexport type JobExecutionQuery = Static<typeof jobExecutionQuerySchema>;\n","import { type Static, t } from \"alepha\";\n\nexport const jobFailureSchema = t.object({\n jobName: t.text(),\n failures: t.integer(),\n lastError: t.optional(t.text()),\n});\n\nexport type JobFailure = Static<typeof jobFailureSchema>;\n","import { type Static, t } from \"alepha\";\n\nexport const jobQueueDepthSchema = t.object({\n jobName: t.text(),\n pending: t.integer(),\n running: t.integer(),\n scheduled: t.integer(),\n retrying: t.integer(),\n dead: t.integer(),\n concurrency: t.integer(),\n paused: t.boolean(),\n});\n\nexport type JobQueueDepth = Static<typeof jobQueueDepthSchema>;\n","import { type Static, t } from \"alepha\";\n\nexport const jobRegistrationSchema = t.object({\n name: t.text(),\n type: t.enum([\"cron\", \"push\", \"both\"]),\n priority: t.enum([\"critical\", \"high\", \"normal\", \"low\"]),\n concurrency: t.integer(),\n hasSchema: t.boolean(),\n cron: t.optional(t.text()),\n timeout: t.optional(t.text()),\n retry: t.optional(\n t.object({\n retries: t.integer(),\n hasBackoff: t.boolean(),\n }),\n ),\n paused: t.boolean(),\n});\n\nexport type JobRegistration = Static<typeof jobRegistrationSchema>;\n","import { type Static, t } from \"alepha\";\n\nexport const jobStatsSchema = t.object({\n registered: t.integer(),\n running: t.integer(),\n pending: t.integer(),\n scheduled: t.integer(),\n retrying: t.integer(),\n dead: t.integer(),\n completed: t.integer(),\n failed: t.integer(),\n});\n\nexport type JobStats = Static<typeof jobStatsSchema>;\n","import { type Static, t } from \"alepha\";\n\nexport const triggerJobSchema = t.object({\n name: t.text(),\n payload: t.optional(t.record(t.text(), t.any())),\n});\n\nexport type TriggerJob = Static<typeof triggerJobSchema>;\n","import { $module } from \"alepha\";\n\n// -----------------------------------------------------------------------------------------------------------------\n\nexport * from \"./entities/jobExecutionEntity.ts\";\nexport * from \"./entities/jobExecutionLogEntity.ts\";\nexport * from \"./schemas/jobActivitySchema.ts\";\nexport * from \"./schemas/jobConfigAtom.ts\";\nexport * from \"./schemas/jobCronInfoSchema.ts\";\nexport * from \"./schemas/jobExecutionDetailResourceSchema.ts\";\nexport * from \"./schemas/jobExecutionQuerySchema.ts\";\nexport * from \"./schemas/jobExecutionResourceSchema.ts\";\nexport * from \"./schemas/jobFailureSchema.ts\";\nexport * from \"./schemas/jobQueueDepthSchema.ts\";\nexport * from \"./schemas/jobRegistrationSchema.ts\";\nexport * from \"./schemas/jobStatsSchema.ts\";\nexport * from \"./schemas/triggerJobSchema.ts\";\n\n// -----------------------------------------------------------------------------------------------------------------\n\nexport const AlephaApiJobs = $module({\n name: \"alepha.api.jobs\",\n services: [],\n});\n"],"mappings":";;;;AAGA,MAAa,qBAAqB,QAAQ;CACxC,MAAM;CACN,QAAQ,EAAE,OAAO;EACf,IAAI,GAAG,WAAW,EAAE,MAAM,CAAC;EAC3B,WAAW,GAAG,WAAW;EACzB,WAAW,GAAG,WAAW;EAEzB,SAAS,EAAE,MAAM;EACjB,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;EAErC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;EAChD,QAAQ,GAAG,QACT,EAAE,KAAK;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EACF,UACD;EACD,UAAU,GAAG,QAAQ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AAQ;EAAU;EAAM,CAAC;CACvD,aAAa,EAAE,SAAS;CACxB,WAAW,EAAE,SAAS;CACtB,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC;CAC1B,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC;CAC7B,OAAO,EAAE,SACP,EAAE,OAAO;EACP,SAAS,EAAE,SAAS;EACpB,YAAY,EAAE,SAAS;EACxB,CAAC,CACH;CACD,QAAQ,EAAE,SAAS;CACpB,CAAC;;;ACfF,MAAa,iBAAiB,EAAE,OAAO;CACrC,YAAY,EAAE,SAAS;CACvB,SAAS,EAAE,SAAS;CACpB,SAAS,EAAE,SAAS;CACpB,WAAW,EAAE,SAAS;CACtB,UAAU,EAAE,SAAS;CACrB,MAAM,EAAE,SAAS;CACjB,WAAW,EAAE,SAAS;CACtB,QAAQ,EAAE,SAAS;CACpB,CAAC;;;ACTF,MAAa,mBAAmB,EAAE,OAAO;CACvC,MAAM,EAAE,MAAM;CACd,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;CACjD,CAAC;;;ACeF,MAAa,gBAAgB,QAAQ;CACnC,MAAM;CACN,UAAU,EAAE;CACb,CAAC"}
|
package/dist/api/jobs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _$alepha from "alepha";
|
|
2
2
|
import { Alepha, AlephaError, Async, KIND, PipelinePrimitive, PipelinePrimitiveOptions, Static, TNull, TObject, TOptional, TSchema, TUnion } from "alepha";
|
|
3
|
+
import { LockProvider } from "alepha/lock";
|
|
3
4
|
import * as _$alepha_queue0 from "alepha/queue";
|
|
4
5
|
import { CronProvider } from "alepha/scheduler";
|
|
5
6
|
import * as _$alepha_server0 from "alepha/server";
|
|
@@ -316,7 +317,7 @@ declare module "alepha" {
|
|
|
316
317
|
//#endregion
|
|
317
318
|
//#region ../../src/api/jobs/primitives/$job.d.ts
|
|
318
319
|
/**
|
|
319
|
-
* Job primitive for defining scheduled and on-demand tasks with payload validation
|
|
320
|
+
* Job primitive for defining scheduled and on-demand tasks with payload validation and retry policies.
|
|
320
321
|
*/
|
|
321
322
|
declare const $job: {
|
|
322
323
|
<T extends TSchema = TSchema>(options: JobPrimitiveOptions<T>): JobPrimitive<T>;
|
|
@@ -343,10 +344,6 @@ interface JobRetryOptions {
|
|
|
343
344
|
backoff?: DurationLike | JobRetryBackoff;
|
|
344
345
|
when?: (error: Error) => boolean;
|
|
345
346
|
}
|
|
346
|
-
interface JobBatchOptions {
|
|
347
|
-
size: number;
|
|
348
|
-
window: DurationLike;
|
|
349
|
-
}
|
|
350
347
|
type JobPriority = "critical" | "high" | "normal" | "low";
|
|
351
348
|
interface JobPrimitiveOptions<T extends TSchema = TSchema> extends PipelinePrimitiveOptions {
|
|
352
349
|
/**
|
|
@@ -375,10 +372,6 @@ interface JobPrimitiveOptions<T extends TSchema = TSchema> extends PipelinePrimi
|
|
|
375
372
|
* @default 1
|
|
376
373
|
*/
|
|
377
374
|
concurrency?: number;
|
|
378
|
-
/**
|
|
379
|
-
* Consumer batching configuration.
|
|
380
|
-
*/
|
|
381
|
-
batch?: JobBatchOptions;
|
|
382
375
|
/**
|
|
383
376
|
* Default priority for pushed jobs.
|
|
384
377
|
* @default "normal"
|
|
@@ -409,6 +402,18 @@ declare class JobPrimitive<T extends TSchema = TSchema> extends PipelinePrimitiv
|
|
|
409
402
|
* Manually trigger the job (admin / CLI).
|
|
410
403
|
*/
|
|
411
404
|
trigger(context?: JobTriggerContext): Promise<void>;
|
|
405
|
+
/**
|
|
406
|
+
* Pause this job. Pushed items are still accepted but processing is held.
|
|
407
|
+
*/
|
|
408
|
+
pause(): void;
|
|
409
|
+
/**
|
|
410
|
+
* Resume a paused job and dispatch any pending items.
|
|
411
|
+
*/
|
|
412
|
+
resume(): Promise<void>;
|
|
413
|
+
/**
|
|
414
|
+
* Whether this job is currently paused.
|
|
415
|
+
*/
|
|
416
|
+
get paused(): boolean;
|
|
412
417
|
}
|
|
413
418
|
//#endregion
|
|
414
419
|
//#region ../../src/api/jobs/providers/JobProvider.d.ts
|
|
@@ -442,6 +447,7 @@ declare class JobProvider {
|
|
|
442
447
|
protected readonly alepha: Alepha;
|
|
443
448
|
protected readonly dt: DateTimeProvider;
|
|
444
449
|
protected readonly cronProvider: CronProvider;
|
|
450
|
+
protected readonly lockProvider: LockProvider;
|
|
445
451
|
protected readonly config: Readonly<{
|
|
446
452
|
recovery: {
|
|
447
453
|
interval: number;
|
|
@@ -453,6 +459,7 @@ declare class JobProvider {
|
|
|
453
459
|
};
|
|
454
460
|
logRetentionDays: number;
|
|
455
461
|
logMaxEntries: number;
|
|
462
|
+
drainTimeout: number;
|
|
456
463
|
}>;
|
|
457
464
|
protected readonly log: _$alepha_logger0.Logger;
|
|
458
465
|
protected readonly executions: _$alepha_orm0.Repository<_$alepha.TObject<{
|
|
@@ -462,7 +469,7 @@ declare class JobProvider {
|
|
|
462
469
|
jobName: _$alepha.TString;
|
|
463
470
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
464
471
|
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
465
|
-
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
472
|
+
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
466
473
|
priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
467
474
|
attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
468
475
|
maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
@@ -491,6 +498,8 @@ declare class JobProvider {
|
|
|
491
498
|
}>>;
|
|
492
499
|
}>>;
|
|
493
500
|
protected readonly jobs: Map<string, JobRegistration$1>;
|
|
501
|
+
protected readonly pausedJobs: Set<string>;
|
|
502
|
+
protected readonly inFlight: Set<Promise<void>>;
|
|
494
503
|
/**
|
|
495
504
|
* When set, job executions are dispatched through a queue (e.g. `JobQueueProvider`).
|
|
496
505
|
* When null, jobs execute inline (fire-and-forget). Useful for serverless environments.
|
|
@@ -521,6 +530,12 @@ declare class JobProvider {
|
|
|
521
530
|
cancel(executionId: string, context?: CancelContext): Promise<void>;
|
|
522
531
|
protected scheduleProcessing(jobName: string, executionId: string): Promise<void>;
|
|
523
532
|
processExecution(jobName: string, executionId: string): Promise<void>;
|
|
533
|
+
protected processExecutionInner(jobName: string, executionId: string): Promise<void>;
|
|
534
|
+
/**
|
|
535
|
+
* After a job finishes (success, failure, or cancel), dispatch any pending
|
|
536
|
+
* jobs that were deferred due to the concurrency limit.
|
|
537
|
+
*/
|
|
538
|
+
protected dispatchNextPending(jobName: string): Promise<void>;
|
|
524
539
|
protected claim(executionId: string): Promise<boolean>;
|
|
525
540
|
protected handleFailure(executionId: string, jobName: string, error: Error, context: string): Promise<void>;
|
|
526
541
|
protected computeBackoff(retryOpts: JobRetryOptions, attempt: number): string;
|
|
@@ -549,6 +564,12 @@ declare class JobProvider {
|
|
|
549
564
|
* Deletes completed/dead/cancelled execution records older than `logRetentionDays`.
|
|
550
565
|
*/
|
|
551
566
|
protected logPurge(): Promise<void>;
|
|
567
|
+
pauseJob(name: string): void;
|
|
568
|
+
resumeJob(name: string): Promise<void>;
|
|
569
|
+
isJobPaused(name: string): boolean;
|
|
570
|
+
getPausedJobs(): string[];
|
|
571
|
+
protected tryLock(key: string, ttlMs: number): Promise<boolean>;
|
|
572
|
+
protected releaseLock(key: string): Promise<void>;
|
|
552
573
|
protected readonly onStart: _$alepha.HookPrimitive<"start">;
|
|
553
574
|
protected readonly onStop: _$alepha.HookPrimitive<"stop">;
|
|
554
575
|
protected getRegistration(name: string): JobRegistration$1;
|
|
@@ -574,6 +595,7 @@ declare const jobCronInfoSchema: _$alepha.TObject<{
|
|
|
574
595
|
priority: _$alepha.TUnsafe<"critical" | "high" | "normal" | "low">;
|
|
575
596
|
concurrency: _$alepha.TInteger;
|
|
576
597
|
hasSchema: _$alepha.TBoolean;
|
|
598
|
+
paused: _$alepha.TBoolean;
|
|
577
599
|
lastExecution: _$alepha.TOptional<_$alepha.TObject<{
|
|
578
600
|
id: _$alepha.TString;
|
|
579
601
|
status: _$alepha.TString;
|
|
@@ -590,7 +612,7 @@ declare const jobExecutionQuerySchema: _$alepha.TObject<{
|
|
|
590
612
|
size: _$alepha.TOptional<_$alepha.TInteger>;
|
|
591
613
|
sort: _$alepha.TOptional<_$alepha.TString>;
|
|
592
614
|
job: _$alepha.TOptional<_$alepha.TString>;
|
|
593
|
-
status: _$alepha.TOptional<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
615
|
+
status: _$alepha.TOptional<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">>;
|
|
594
616
|
priority: _$alepha.TOptional<_$alepha.TUnsafe<"critical" | "high" | "normal" | "low">>;
|
|
595
617
|
from: _$alepha.TOptional<_$alepha.TString>;
|
|
596
618
|
to: _$alepha.TOptional<_$alepha.TString>;
|
|
@@ -614,6 +636,7 @@ declare const jobQueueDepthSchema: _$alepha.TObject<{
|
|
|
614
636
|
retrying: _$alepha.TInteger;
|
|
615
637
|
dead: _$alepha.TInteger;
|
|
616
638
|
concurrency: _$alepha.TInteger;
|
|
639
|
+
paused: _$alepha.TBoolean;
|
|
617
640
|
}>;
|
|
618
641
|
type JobQueueDepth = Static<typeof jobQueueDepthSchema>;
|
|
619
642
|
//#endregion
|
|
@@ -630,10 +653,7 @@ declare const jobRegistrationSchema: _$alepha.TObject<{
|
|
|
630
653
|
retries: _$alepha.TInteger;
|
|
631
654
|
hasBackoff: _$alepha.TBoolean;
|
|
632
655
|
}>>;
|
|
633
|
-
|
|
634
|
-
size: _$alepha.TInteger;
|
|
635
|
-
window: _$alepha.TString;
|
|
636
|
-
}>>;
|
|
656
|
+
paused: _$alepha.TBoolean;
|
|
637
657
|
}>;
|
|
638
658
|
type JobRegistration = Static<typeof jobRegistrationSchema>;
|
|
639
659
|
//#endregion
|
|
@@ -664,7 +684,7 @@ declare class JobService {
|
|
|
664
684
|
jobName: _$alepha.TString;
|
|
665
685
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
666
686
|
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
667
|
-
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
687
|
+
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
668
688
|
priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
669
689
|
attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
670
690
|
maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
@@ -720,7 +740,7 @@ declare class JobService {
|
|
|
720
740
|
jobName: _$alepha.TString;
|
|
721
741
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
722
742
|
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
723
|
-
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
743
|
+
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
724
744
|
priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
725
745
|
attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
726
746
|
maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
@@ -745,7 +765,7 @@ declare class JobService {
|
|
|
745
765
|
jobName: _$alepha.TString;
|
|
746
766
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
747
767
|
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
748
|
-
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
768
|
+
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
749
769
|
priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
750
770
|
attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
751
771
|
maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
@@ -770,7 +790,7 @@ declare class JobService {
|
|
|
770
790
|
createdAt: string;
|
|
771
791
|
updatedAt: string;
|
|
772
792
|
jobName: string;
|
|
773
|
-
status: "pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
793
|
+
status: "pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled";
|
|
774
794
|
priority: number;
|
|
775
795
|
attempt: number;
|
|
776
796
|
maxAttempts: number;
|
|
@@ -800,7 +820,7 @@ declare class JobService {
|
|
|
800
820
|
jobName: _$alepha.TString;
|
|
801
821
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
802
822
|
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
803
|
-
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
823
|
+
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
804
824
|
priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
805
825
|
attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
806
826
|
maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
@@ -825,7 +845,7 @@ declare class JobService {
|
|
|
825
845
|
jobName: _$alepha.TString;
|
|
826
846
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
827
847
|
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
828
|
-
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
848
|
+
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
829
849
|
priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
830
850
|
attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
831
851
|
maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
@@ -850,7 +870,7 @@ declare class JobService {
|
|
|
850
870
|
createdAt: string;
|
|
851
871
|
updatedAt: string;
|
|
852
872
|
jobName: string;
|
|
853
|
-
status: "pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
873
|
+
status: "pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled";
|
|
854
874
|
priority: number;
|
|
855
875
|
attempt: number;
|
|
856
876
|
maxAttempts: number;
|
|
@@ -870,6 +890,19 @@ declare class JobService {
|
|
|
870
890
|
}): Promise<{
|
|
871
891
|
ok: boolean;
|
|
872
892
|
}>;
|
|
893
|
+
pauseJob(name: string, context?: {
|
|
894
|
+
pausedBy?: string;
|
|
895
|
+
pausedByName?: string;
|
|
896
|
+
}): {
|
|
897
|
+
ok: boolean;
|
|
898
|
+
};
|
|
899
|
+
resumeJob(name: string, context?: {
|
|
900
|
+
resumedBy?: string;
|
|
901
|
+
resumedByName?: string;
|
|
902
|
+
}): Promise<{
|
|
903
|
+
ok: boolean;
|
|
904
|
+
}>;
|
|
905
|
+
getPausedJobs(): string[];
|
|
873
906
|
getCronJobs(): Promise<JobCronInfo[]>;
|
|
874
907
|
getQueueDepth(): Promise<JobQueueDepth[]>;
|
|
875
908
|
getActivity(days?: number): Promise<JobActivityPoint[]>;
|
|
@@ -925,10 +958,7 @@ declare class AdminJobController {
|
|
|
925
958
|
retries: _$alepha.TInteger;
|
|
926
959
|
hasBackoff: _$alepha.TBoolean;
|
|
927
960
|
}>>;
|
|
928
|
-
|
|
929
|
-
size: _$alepha.TInteger;
|
|
930
|
-
window: _$alepha.TString;
|
|
931
|
-
}>>;
|
|
961
|
+
paused: _$alepha.TBoolean;
|
|
932
962
|
}>>;
|
|
933
963
|
}>;
|
|
934
964
|
readonly findJobExecutions: _$alepha_server0.ActionPrimitiveFn<{
|
|
@@ -937,7 +967,7 @@ declare class AdminJobController {
|
|
|
937
967
|
size: _$alepha.TOptional<_$alepha.TInteger>;
|
|
938
968
|
sort: _$alepha.TOptional<_$alepha.TString>;
|
|
939
969
|
job: _$alepha.TOptional<_$alepha.TString>;
|
|
940
|
-
status: _$alepha.TOptional<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
970
|
+
status: _$alepha.TOptional<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">>;
|
|
941
971
|
priority: _$alepha.TOptional<_$alepha.TUnsafe<"critical" | "high" | "normal" | "low">>;
|
|
942
972
|
from: _$alepha.TOptional<_$alepha.TString>;
|
|
943
973
|
to: _$alepha.TOptional<_$alepha.TString>;
|
|
@@ -949,7 +979,7 @@ declare class AdminJobController {
|
|
|
949
979
|
jobName: _$alepha.TString;
|
|
950
980
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
951
981
|
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
952
|
-
status: PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
982
|
+
status: PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof PG_DEFAULT>;
|
|
953
983
|
priority: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
954
984
|
attempt: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
955
985
|
maxAttempts: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
@@ -980,7 +1010,7 @@ declare class AdminJobController {
|
|
|
980
1010
|
jobName: _$alepha.TString;
|
|
981
1011
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
982
1012
|
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
983
|
-
status: PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
1013
|
+
status: PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof PG_DEFAULT>;
|
|
984
1014
|
priority: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
985
1015
|
attempt: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
986
1016
|
maxAttempts: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
@@ -1059,6 +1089,7 @@ declare class AdminJobController {
|
|
|
1059
1089
|
priority: _$alepha.TUnsafe<"critical" | "high" | "normal" | "low">;
|
|
1060
1090
|
concurrency: _$alepha.TInteger;
|
|
1061
1091
|
hasSchema: _$alepha.TBoolean;
|
|
1092
|
+
paused: _$alepha.TBoolean;
|
|
1062
1093
|
lastExecution: _$alepha.TOptional<_$alepha.TObject<{
|
|
1063
1094
|
id: _$alepha.TString;
|
|
1064
1095
|
status: _$alepha.TString;
|
|
@@ -1077,6 +1108,7 @@ declare class AdminJobController {
|
|
|
1077
1108
|
retrying: _$alepha.TInteger;
|
|
1078
1109
|
dead: _$alepha.TInteger;
|
|
1079
1110
|
concurrency: _$alepha.TInteger;
|
|
1111
|
+
paused: _$alepha.TBoolean;
|
|
1080
1112
|
}>>;
|
|
1081
1113
|
}>;
|
|
1082
1114
|
readonly getJobTopFailures: _$alepha_server0.ActionPrimitiveFn<{
|
|
@@ -1089,6 +1121,29 @@ declare class AdminJobController {
|
|
|
1089
1121
|
lastError: _$alepha.TOptional<_$alepha.TString>;
|
|
1090
1122
|
}>>;
|
|
1091
1123
|
}>;
|
|
1124
|
+
readonly pauseJob: _$alepha_server0.ActionPrimitiveFn<{
|
|
1125
|
+
body: _$alepha.TObject<{
|
|
1126
|
+
name: _$alepha.TString;
|
|
1127
|
+
}>;
|
|
1128
|
+
response: _$alepha.TObject<{
|
|
1129
|
+
ok: _$alepha.TBoolean;
|
|
1130
|
+
id: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TString, _$alepha.TInteger]>>;
|
|
1131
|
+
count: _$alepha.TOptional<_$alepha.TNumber>;
|
|
1132
|
+
}>;
|
|
1133
|
+
}>;
|
|
1134
|
+
readonly resumeJob: _$alepha_server0.ActionPrimitiveFn<{
|
|
1135
|
+
body: _$alepha.TObject<{
|
|
1136
|
+
name: _$alepha.TString;
|
|
1137
|
+
}>;
|
|
1138
|
+
response: _$alepha.TObject<{
|
|
1139
|
+
ok: _$alepha.TBoolean;
|
|
1140
|
+
id: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TString, _$alepha.TInteger]>>;
|
|
1141
|
+
count: _$alepha.TOptional<_$alepha.TNumber>;
|
|
1142
|
+
}>;
|
|
1143
|
+
}>;
|
|
1144
|
+
readonly getPausedJobs: _$alepha_server0.ActionPrimitiveFn<{
|
|
1145
|
+
response: _$alepha.TArray<_$alepha.TString>;
|
|
1146
|
+
}>;
|
|
1092
1147
|
}
|
|
1093
1148
|
//#endregion
|
|
1094
1149
|
//#region ../../src/api/jobs/entities/jobExecutionEntity.d.ts
|
|
@@ -1099,7 +1154,7 @@ declare const jobExecutionEntity: _$alepha_orm0.EntityPrimitive<_$alepha.TObject
|
|
|
1099
1154
|
jobName: _$alepha.TString;
|
|
1100
1155
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
1101
1156
|
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
1102
|
-
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
1157
|
+
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
1103
1158
|
priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
1104
1159
|
attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
1105
1160
|
maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
@@ -1115,7 +1170,7 @@ declare const jobExecutionEntity: _$alepha_orm0.EntityPrimitive<_$alepha.TObject
|
|
|
1115
1170
|
cancelledByName: _$alepha.TOptional<_$alepha.TString>;
|
|
1116
1171
|
}>>;
|
|
1117
1172
|
type JobExecutionEntity = Static<typeof jobExecutionEntity.schema>;
|
|
1118
|
-
type JobStatus = "pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
1173
|
+
type JobStatus = "pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled";
|
|
1119
1174
|
//#endregion
|
|
1120
1175
|
//#region ../../src/api/jobs/entities/jobExecutionLogEntity.d.ts
|
|
1121
1176
|
declare const jobExecutionLogEntity: _$alepha_orm0.EntityPrimitive<_$alepha.TObject<{
|
|
@@ -1167,6 +1222,7 @@ declare const jobConfig: _$alepha.Atom<_$alepha.TObject<{
|
|
|
1167
1222
|
}>;
|
|
1168
1223
|
logRetentionDays: _$alepha.TInteger;
|
|
1169
1224
|
logMaxEntries: _$alepha.TInteger;
|
|
1225
|
+
drainTimeout: _$alepha.TInteger;
|
|
1170
1226
|
}>, "alepha.jobs">;
|
|
1171
1227
|
type JobConfig = Static<typeof jobConfig.schema>;
|
|
1172
1228
|
declare module "alepha" {
|
|
@@ -1183,7 +1239,7 @@ declare const jobExecutionDetailResourceSchema: _$alepha.TObject<{
|
|
|
1183
1239
|
jobName: _$alepha.TString;
|
|
1184
1240
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
1185
1241
|
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
1186
|
-
status: PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
1242
|
+
status: PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof PG_DEFAULT>;
|
|
1187
1243
|
priority: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
1188
1244
|
attempt: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
1189
1245
|
maxAttempts: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
@@ -1226,7 +1282,7 @@ declare const jobExecutionResourceSchema: _$alepha.TObject<{
|
|
|
1226
1282
|
jobName: _$alepha.TString;
|
|
1227
1283
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
1228
1284
|
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
1229
|
-
status: PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "
|
|
1285
|
+
status: PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof PG_DEFAULT>;
|
|
1230
1286
|
priority: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
1231
1287
|
attempt: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
1232
1288
|
maxAttempts: PgAttr<_$alepha.TInteger, typeof PG_DEFAULT>;
|
|
@@ -1307,5 +1363,5 @@ declare const jobEnvSchema: _$alepha.TObject<{
|
|
|
1307
1363
|
*/
|
|
1308
1364
|
declare const AlephaApiJobs: _$alepha.Service<_$alepha.Module>;
|
|
1309
1365
|
//#endregion
|
|
1310
|
-
export { $job, AdminJobController, AlephaApiJobs, CancelContext, JobActivityPoint, JobActivityQuery,
|
|
1366
|
+
export { $job, AdminJobController, AlephaApiJobs, CancelContext, JobActivityPoint, JobActivityQuery, JobConfig, JobCronInfo, JobExecutionDetailResource, JobExecutionEntity, JobExecutionLogEntity, JobExecutionQuery, JobExecutionResource, JobFailure, JobHandlerArgs, JobItem, JobPrimitive, JobPrimitiveOptions, JobPriority, JobProvider, JobQueueDepth, JobQueueProvider, JobRegistration, JobRetryBackoff, JobRetryOptions, JobService, JobStats, JobStatus, JobTriggerContext, PushManyItem, PushOptions, TriggerJob, jobActivityPointSchema, jobActivityQuerySchema, jobConfig, jobCronInfoSchema, jobExecutionCanSchema, jobExecutionDetailResourceSchema, jobExecutionEntity, jobExecutionLogEntity, jobExecutionQuerySchema, jobExecutionResourceSchema, jobFailureSchema, jobQueueDepthSchema, jobRegistrationSchema, jobStatsSchema, triggerJobSchema };
|
|
1311
1367
|
//# sourceMappingURL=index.d.ts.map
|