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
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import type {
|
|
IRecurringServicePeriodRecordProvenance,
|
|
RecurringServicePeriodProvenanceKind,
|
|
RecurringServicePeriodProvenanceReasonCode,
|
|
} from '@alga-psa/types';
|
|
import { RECURRING_SERVICE_PERIOD_PROVENANCE_REASON_CODES } from '@alga-psa/types';
|
|
|
|
export function isRecurringServicePeriodProvenanceReasonCode(
|
|
kind: RecurringServicePeriodProvenanceKind,
|
|
reasonCode: string,
|
|
): reasonCode is RecurringServicePeriodProvenanceReasonCode {
|
|
return (
|
|
RECURRING_SERVICE_PERIOD_PROVENANCE_REASON_CODES[kind] as readonly string[]
|
|
).includes(reasonCode);
|
|
}
|
|
|
|
export function isRecurringServicePeriodProvenanceDivergent(
|
|
provenance: IRecurringServicePeriodRecordProvenance,
|
|
) {
|
|
return provenance.kind !== 'generated';
|
|
}
|
|
|
|
export function validateRecurringServicePeriodProvenance(
|
|
provenance: IRecurringServicePeriodRecordProvenance,
|
|
) {
|
|
const errors: string[] = [];
|
|
|
|
if (!isRecurringServicePeriodProvenanceReasonCode(provenance.kind, provenance.reasonCode)) {
|
|
errors.push(`Unsupported reason code "${provenance.reasonCode}" for provenance kind "${provenance.kind}"`);
|
|
}
|
|
|
|
switch (provenance.kind) {
|
|
case 'generated':
|
|
if (!provenance.sourceRunKey) {
|
|
errors.push('Generated provenance requires sourceRunKey');
|
|
}
|
|
if (provenance.supersedesRecordId != null) {
|
|
errors.push('Generated provenance must not supersede an earlier record');
|
|
}
|
|
break;
|
|
case 'user_edited':
|
|
if (!provenance.supersedesRecordId) {
|
|
errors.push('User-edited provenance requires supersedesRecordId');
|
|
}
|
|
break;
|
|
case 'regenerated':
|
|
if (!provenance.sourceRunKey) {
|
|
errors.push('Regenerated provenance requires sourceRunKey');
|
|
}
|
|
if (!provenance.supersedesRecordId) {
|
|
errors.push('Regenerated provenance requires supersedesRecordId');
|
|
}
|
|
break;
|
|
case 'repair':
|
|
break;
|
|
}
|
|
|
|
return {
|
|
valid: errors.length === 0,
|
|
errors,
|
|
};
|
|
}
|