Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
92 lines
3.8 KiB
TypeScript
92 lines
3.8 KiB
TypeScript
import { z } from 'zod';
|
|
import { BaseDomainEventPayloadSchema, changesSchema, updatedFieldsSchema, uuidSchema } from './commonEventPayloadSchemas';
|
|
|
|
const assetIdSchema = uuidSchema('Asset ID');
|
|
const clientIdSchema = uuidSchema('Client ID');
|
|
const userIdSchema = uuidSchema('User ID');
|
|
const fileIdSchema = uuidSchema('File ID');
|
|
|
|
export const assetCreatedEventPayloadSchema = BaseDomainEventPayloadSchema.extend({
|
|
assetId: assetIdSchema,
|
|
clientId: clientIdSchema.optional(),
|
|
createdByUserId: userIdSchema.optional(),
|
|
createdAt: z.string().datetime().optional(),
|
|
assetType: z.string().optional(),
|
|
serialNumber: z.string().optional(),
|
|
}).describe('Payload for ASSET_CREATED');
|
|
|
|
export type AssetCreatedEventPayload = z.infer<typeof assetCreatedEventPayloadSchema>;
|
|
|
|
export const assetUpdatedEventPayloadSchema = BaseDomainEventPayloadSchema.extend({
|
|
assetId: assetIdSchema,
|
|
updatedByUserId: userIdSchema.optional(),
|
|
updatedAt: z.string().datetime().optional(),
|
|
updatedFields: updatedFieldsSchema,
|
|
changes: changesSchema,
|
|
}).describe('Payload for ASSET_UPDATED');
|
|
|
|
export type AssetUpdatedEventPayload = z.infer<typeof assetUpdatedEventPayloadSchema>;
|
|
|
|
const ownerTypeSchema = z.string().min(1).describe('Owner type (client/contact/site/etc)');
|
|
|
|
export const assetAssignedEventPayloadSchema = BaseDomainEventPayloadSchema.extend({
|
|
assetId: assetIdSchema,
|
|
previousOwnerType: ownerTypeSchema.optional(),
|
|
previousOwnerId: z.string().optional(),
|
|
newOwnerType: ownerTypeSchema,
|
|
newOwnerId: z.string().min(1),
|
|
assignedAt: z.string().datetime().optional(),
|
|
}).describe('Payload for ASSET_ASSIGNED');
|
|
|
|
export type AssetAssignedEventPayload = z.infer<typeof assetAssignedEventPayloadSchema>;
|
|
|
|
export const assetUnassignedEventPayloadSchema = BaseDomainEventPayloadSchema.extend({
|
|
assetId: assetIdSchema,
|
|
previousOwnerType: ownerTypeSchema,
|
|
previousOwnerId: z.string().min(1),
|
|
unassignedAt: z.string().datetime().optional(),
|
|
reason: z.string().optional(),
|
|
}).describe('Payload for ASSET_UNASSIGNED');
|
|
|
|
export type AssetUnassignedEventPayload = z.infer<typeof assetUnassignedEventPayloadSchema>;
|
|
|
|
export const assetWarrantyExpiringEventPayloadSchema = BaseDomainEventPayloadSchema.extend({
|
|
assetId: assetIdSchema,
|
|
expiresAt: z.string().datetime(),
|
|
daysUntilExpiry: z.number().int().nonnegative(),
|
|
clientId: clientIdSchema.optional(),
|
|
}).describe('Payload for ASSET_WARRANTY_EXPIRING');
|
|
|
|
export type AssetWarrantyExpiringEventPayload = z.infer<typeof assetWarrantyExpiringEventPayloadSchema>;
|
|
|
|
export const fileUploadedEventPayloadSchema = BaseDomainEventPayloadSchema.extend({
|
|
fileId: fileIdSchema,
|
|
uploadedByUserId: userIdSchema.optional(),
|
|
uploadedAt: z.string().datetime().optional(),
|
|
fileName: z.string().min(1),
|
|
contentType: z.string().min(1),
|
|
sizeBytes: z.number().int().nonnegative(),
|
|
storageKey: z.string().min(1),
|
|
}).describe('Payload for FILE_UPLOADED');
|
|
|
|
export type FileUploadedEventPayload = z.infer<typeof fileUploadedEventPayloadSchema>;
|
|
|
|
export const mediaProcessingSucceededEventPayloadSchema = BaseDomainEventPayloadSchema.extend({
|
|
fileId: fileIdSchema,
|
|
processedAt: z.string().datetime().optional(),
|
|
outputs: z.array(z.unknown()).optional(),
|
|
durationMs: z.number().int().nonnegative().optional(),
|
|
}).describe('Payload for MEDIA_PROCESSING_SUCCEEDED');
|
|
|
|
export type MediaProcessingSucceededEventPayload = z.infer<typeof mediaProcessingSucceededEventPayloadSchema>;
|
|
|
|
export const mediaProcessingFailedEventPayloadSchema = BaseDomainEventPayloadSchema.extend({
|
|
fileId: fileIdSchema,
|
|
failedAt: z.string().datetime().optional(),
|
|
errorCode: z.string().optional(),
|
|
errorMessage: z.string().min(1),
|
|
retryable: z.boolean().optional(),
|
|
}).describe('Payload for MEDIA_PROCESSING_FAILED');
|
|
|
|
export type MediaProcessingFailedEventPayload = z.infer<typeof mediaProcessingFailedEventPayloadSchema>;
|