@nexia/sdk 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-availability.d.ts +18 -0
- package/dist/app-availability.js +29 -0
- package/dist/approval.d.ts +180 -0
- package/dist/approval.js +9 -0
- package/dist/context.d.ts +49 -0
- package/dist/context.js +1 -0
- package/dist/data-migration.d.ts +123 -0
- package/dist/data-migration.js +70 -0
- package/dist/fixtures/approval-contract-negative.d.ts +1 -0
- package/dist/fixtures/approval-contract-negative.js +8 -0
- package/dist/handoff-result.d.ts +6 -0
- package/dist/handoff-result.js +17 -0
- package/dist/host.d.ts +602 -0
- package/dist/host.js +803 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +21 -0
- package/dist/number.d.ts +2 -0
- package/dist/number.js +9 -0
- package/dist/organization-target.d.ts +101 -0
- package/dist/organization-target.js +105 -0
- package/dist/permissions.d.ts +3 -0
- package/dist/permissions.js +12 -0
- package/dist/platform.d.ts +378 -0
- package/dist/platform.js +114 -0
- package/dist/process.d.ts +98 -0
- package/dist/process.js +10 -0
- package/dist/resource-composition.d.ts +104 -0
- package/dist/resource-composition.js +576 -0
- package/dist/resource-create-destination.d.ts +17 -0
- package/dist/resource-create-destination.js +1 -0
- package/dist/resource-reference.d.ts +122 -0
- package/dist/resource-reference.js +203 -0
- package/dist/resources/resource-information.d.ts +128 -0
- package/dist/resources/resource-information.js +12 -0
- package/dist/resources/resource-list.d.ts +23 -0
- package/dist/resources/resource-list.js +1 -0
- package/dist/resources/resource-projections.d.ts +311 -0
- package/dist/resources/resource-projections.js +1 -0
- package/dist/resources/resource-transfer.d.ts +208 -0
- package/dist/resources/resource-transfer.js +1 -0
- package/dist/shell.d.ts +1297 -0
- package/dist/shell.js +1 -0
- package/dist/signature.d.ts +489 -0
- package/dist/signature.js +171 -0
- package/dist/spreadsheet.d.ts +42 -0
- package/dist/spreadsheet.js +15 -0
- package/dist/testing.d.ts +16 -0
- package/dist/testing.js +17 -0
- package/package.json +53 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical availability of a target App from one consumer's viewpoint.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the backend `Nexia\AppRuntime\AppAvailability` enum. App-level
|
|
5
|
+
* state — distinct from the per-record `ResourceReferenceStatus` and the
|
|
6
|
+
* per-request `HandoffResultState`. Consume the values as-is.
|
|
7
|
+
*/
|
|
8
|
+
export declare const APP_AVAILABILITY_STATES: readonly ["operational", "unavailable", "disabled", "unauthorized", "failed", "stale"];
|
|
9
|
+
export type AppAvailabilityState = (typeof APP_AVAILABILITY_STATES)[number];
|
|
10
|
+
export declare function isAppAvailabilityState(value: unknown): value is AppAvailabilityState;
|
|
11
|
+
/**
|
|
12
|
+
* Manual fallback is legitimate only when the target App has never been
|
|
13
|
+
* installed. Disabled, failed, stale, and unauthorized Apps retain their own
|
|
14
|
+
* recovery paths and must not be silently replaced.
|
|
15
|
+
*/
|
|
16
|
+
export declare function permitsManualFallback(state: AppAvailabilityState): boolean;
|
|
17
|
+
/** @deprecated Use permitsManualFallback to match the PHP contract. */
|
|
18
|
+
export declare const allowsManualAppFallback: typeof permitsManualFallback;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical availability of a target App from one consumer's viewpoint.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the backend `Nexia\AppRuntime\AppAvailability` enum. App-level
|
|
5
|
+
* state — distinct from the per-record `ResourceReferenceStatus` and the
|
|
6
|
+
* per-request `HandoffResultState`. Consume the values as-is.
|
|
7
|
+
*/
|
|
8
|
+
export const APP_AVAILABILITY_STATES = [
|
|
9
|
+
'operational',
|
|
10
|
+
'unavailable',
|
|
11
|
+
'disabled',
|
|
12
|
+
'unauthorized',
|
|
13
|
+
'failed',
|
|
14
|
+
'stale',
|
|
15
|
+
];
|
|
16
|
+
export function isAppAvailabilityState(value) {
|
|
17
|
+
return (typeof value === 'string' &&
|
|
18
|
+
APP_AVAILABILITY_STATES.includes(value));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Manual fallback is legitimate only when the target App has never been
|
|
22
|
+
* installed. Disabled, failed, stale, and unauthorized Apps retain their own
|
|
23
|
+
* recovery paths and must not be silently replaced.
|
|
24
|
+
*/
|
|
25
|
+
export function permitsManualFallback(state) {
|
|
26
|
+
return state === 'unavailable';
|
|
27
|
+
}
|
|
28
|
+
/** @deprecated Use permitsManualFallback to match the PHP contract. */
|
|
29
|
+
export const allowsManualAppFallback = permitsManualFallback;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { ComponentType, LazyExoticComponent } from 'react';
|
|
2
|
+
export declare const APPROVAL_STATES: readonly ["draft", "submitted", "approved", "rejected", "recalled", "cancelled"];
|
|
3
|
+
export type ApprovalState = (typeof APPROVAL_STATES)[number];
|
|
4
|
+
export type ApprovalBusinessFormEntryMode = 'create' | 'link';
|
|
5
|
+
export declare const APPROVAL_STEP_KINDS: readonly ["approval", "consultation"];
|
|
6
|
+
export type ApprovalStepKind = (typeof APPROVAL_STEP_KINDS)[number];
|
|
7
|
+
export type ApprovalLineResolutionCategory = 'resolution' | 'authority' | 'availability';
|
|
8
|
+
export interface ApprovalLineStep {
|
|
9
|
+
kind: ApprovalStepKind;
|
|
10
|
+
user_id: number;
|
|
11
|
+
is_final_authority?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export type ApprovalLineStages = ApprovalLineStep[][];
|
|
14
|
+
export interface ApprovalLineResolutionError {
|
|
15
|
+
code: string;
|
|
16
|
+
category: ApprovalLineResolutionCategory;
|
|
17
|
+
message: string;
|
|
18
|
+
user_id: number | null;
|
|
19
|
+
}
|
|
20
|
+
export interface ApprovalBusinessFormSubmitError {
|
|
21
|
+
kind: 'business_validation' | 'approval_line' | 'system';
|
|
22
|
+
message?: string;
|
|
23
|
+
lineErrors?: ApprovalLineResolutionError[];
|
|
24
|
+
}
|
|
25
|
+
export interface ApprovalActor {
|
|
26
|
+
id: number;
|
|
27
|
+
name: string;
|
|
28
|
+
email: string;
|
|
29
|
+
status: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ApprovalStep {
|
|
32
|
+
id: number;
|
|
33
|
+
position: number;
|
|
34
|
+
branch_index: number;
|
|
35
|
+
kind: string;
|
|
36
|
+
mode: string;
|
|
37
|
+
state: string;
|
|
38
|
+
is_final_authority?: boolean;
|
|
39
|
+
required_user: ApprovalActor | null;
|
|
40
|
+
effective_actor: ApprovalActor | null;
|
|
41
|
+
acted_at: string | null;
|
|
42
|
+
}
|
|
43
|
+
export interface ApprovalBodySnapshot {
|
|
44
|
+
template_key: string;
|
|
45
|
+
template_version: number;
|
|
46
|
+
body: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ApprovalSupplementalBodySnapshot {
|
|
49
|
+
body: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ApprovalResourceSummaryField {
|
|
52
|
+
key: string;
|
|
53
|
+
type: string;
|
|
54
|
+
label_key?: string | null;
|
|
55
|
+
enum_labels?: Record<string, string> | null;
|
|
56
|
+
role?: 'subtitle' | 'meta' | 'status' | null;
|
|
57
|
+
value: unknown;
|
|
58
|
+
}
|
|
59
|
+
export interface ApprovalResourceSummary {
|
|
60
|
+
display: string;
|
|
61
|
+
route: string | null;
|
|
62
|
+
fields: ApprovalResourceSummaryField[];
|
|
63
|
+
}
|
|
64
|
+
export interface ApprovalDocumentField {
|
|
65
|
+
key: string;
|
|
66
|
+
type: string;
|
|
67
|
+
label_key?: string | null;
|
|
68
|
+
value?: unknown;
|
|
69
|
+
enum_labels?: Record<string, string> | null;
|
|
70
|
+
columns?: ApprovalDocumentField[];
|
|
71
|
+
rows?: Record<string, unknown>[];
|
|
72
|
+
}
|
|
73
|
+
export interface ApprovalDocumentSection {
|
|
74
|
+
title_key?: string | null;
|
|
75
|
+
fields: ApprovalDocumentField[];
|
|
76
|
+
}
|
|
77
|
+
export interface ApprovalDocument {
|
|
78
|
+
title_key?: string | null;
|
|
79
|
+
sections: ApprovalDocumentSection[];
|
|
80
|
+
}
|
|
81
|
+
export interface ApprovalDrafterIdentity {
|
|
82
|
+
name: string;
|
|
83
|
+
legal_entity_name: string;
|
|
84
|
+
affiliation?: string | null;
|
|
85
|
+
title?: string | null;
|
|
86
|
+
identifier?: string | null;
|
|
87
|
+
}
|
|
88
|
+
export interface ApprovalCirculationRecipient {
|
|
89
|
+
user: ApprovalActor | null;
|
|
90
|
+
acknowledged_at: string | null;
|
|
91
|
+
}
|
|
92
|
+
export interface ApprovalCase {
|
|
93
|
+
id: string;
|
|
94
|
+
legal_entity_public_id: string;
|
|
95
|
+
title: string;
|
|
96
|
+
document_number?: string | null;
|
|
97
|
+
state: ApprovalState;
|
|
98
|
+
drafter: ApprovalActor | null;
|
|
99
|
+
submitted_at: string | null;
|
|
100
|
+
drafter_identity?: ApprovalDrafterIdentity | null;
|
|
101
|
+
document?: ApprovalDocument | null;
|
|
102
|
+
resource_summary?: ApprovalResourceSummary | null;
|
|
103
|
+
submit_body_snapshot?: ApprovalBodySnapshot | null;
|
|
104
|
+
final_body_snapshot?: ApprovalBodySnapshot | null;
|
|
105
|
+
supplemental_body_snapshot?: ApprovalSupplementalBodySnapshot | null;
|
|
106
|
+
steps?: ApprovalStep[];
|
|
107
|
+
reference_recipients?: ApprovalActor[];
|
|
108
|
+
circulation_recipients?: ApprovalCirculationRecipient[];
|
|
109
|
+
}
|
|
110
|
+
export type ApprovalDocumentView = Pick<ApprovalCase, 'title' | 'document_number' | 'submitted_at' | 'drafter_identity' | 'drafter' | 'document' | 'supplemental_body_snapshot' | 'submit_body_snapshot' | 'final_body_snapshot' | 'resource_summary' | 'steps' | 'reference_recipients' | 'circulation_recipients'>;
|
|
111
|
+
export interface ApprovalBusinessFormSubmitEnvelope {
|
|
112
|
+
templateKey: string;
|
|
113
|
+
templateVersion: number;
|
|
114
|
+
supplementalBody: string | null;
|
|
115
|
+
supportingAttachmentStageIds: string[];
|
|
116
|
+
line: ApprovalLineStages;
|
|
117
|
+
/** Provenance of the line as last confirmed in the Core composer. */
|
|
118
|
+
lineSource: 'manual' | 'personal_preset' | 'shared_line';
|
|
119
|
+
/** Shared route-policy key when lineSource is shared_line. */
|
|
120
|
+
lineSourceKey: string | null;
|
|
121
|
+
/** Canonical Core preview hash when lineSource is shared_line. */
|
|
122
|
+
lineSourceHash: string | null;
|
|
123
|
+
referenceUserIds: number[];
|
|
124
|
+
circulationUserIds: number[];
|
|
125
|
+
}
|
|
126
|
+
export interface ApprovalBusinessFormController {
|
|
127
|
+
readonly canSubmit: boolean;
|
|
128
|
+
saveDraft: () => Promise<ApprovalBusinessFormDraftResult>;
|
|
129
|
+
buildPreview: () => ApprovalDocumentView | null;
|
|
130
|
+
submit: (envelope: ApprovalBusinessFormSubmitEnvelope) => Promise<ApprovalBusinessFormSubmitResult>;
|
|
131
|
+
}
|
|
132
|
+
export interface ApprovalBusinessFormDraftResult {
|
|
133
|
+
appDraftRef: string;
|
|
134
|
+
}
|
|
135
|
+
export interface ApprovalBusinessFormSubmitResult {
|
|
136
|
+
caseId: string;
|
|
137
|
+
}
|
|
138
|
+
export interface ApprovalBusinessFormTemplate {
|
|
139
|
+
key: string;
|
|
140
|
+
version: number;
|
|
141
|
+
}
|
|
142
|
+
export interface ApprovalBusinessFormBinding {
|
|
143
|
+
key: string;
|
|
144
|
+
version: string | null;
|
|
145
|
+
entryMode: ApprovalBusinessFormEntryMode;
|
|
146
|
+
}
|
|
147
|
+
export interface ApprovalBusinessFormSubject {
|
|
148
|
+
resourceId: string;
|
|
149
|
+
resourceVersion: string | null;
|
|
150
|
+
}
|
|
151
|
+
export interface ApprovalBusinessFormSlotPropsV2 {
|
|
152
|
+
slotApiVersion: 2;
|
|
153
|
+
legalEntityPublicId: string;
|
|
154
|
+
template: ApprovalBusinessFormTemplate;
|
|
155
|
+
binding: ApprovalBusinessFormBinding;
|
|
156
|
+
subject?: ApprovalBusinessFormSubject;
|
|
157
|
+
appDraftRef?: string | null;
|
|
158
|
+
registerController: (controller: ApprovalBusinessFormController | null) => void;
|
|
159
|
+
}
|
|
160
|
+
export type ApprovalBusinessFormWidgetLoader = () => Promise<{
|
|
161
|
+
default: ComponentType<ApprovalBusinessFormSlotPropsV2>;
|
|
162
|
+
}>;
|
|
163
|
+
export interface ApprovalBusinessFormRegistration {
|
|
164
|
+
formWidgetKey: string;
|
|
165
|
+
loader: ApprovalBusinessFormWidgetLoader;
|
|
166
|
+
}
|
|
167
|
+
/** App-facing registration capability. Inspection remains host/test-only. */
|
|
168
|
+
export interface ApprovalBusinessFormRegistrar {
|
|
169
|
+
register(registration: ApprovalBusinessFormRegistration): void;
|
|
170
|
+
register(formWidgetKey: string, loader: ApprovalBusinessFormWidgetLoader): void;
|
|
171
|
+
}
|
|
172
|
+
export interface ApprovalBusinessFormRegistry {
|
|
173
|
+
register(registration: ApprovalBusinessFormRegistration): void;
|
|
174
|
+
register(formWidgetKey: string, loader: ApprovalBusinessFormWidgetLoader): void;
|
|
175
|
+
get: (formWidgetKey: string) => LazyExoticComponent<ComponentType<ApprovalBusinessFormSlotPropsV2>> | null;
|
|
176
|
+
keys: () => string[];
|
|
177
|
+
subscribe: (listener: () => void) => () => void;
|
|
178
|
+
snapshot: () => number;
|
|
179
|
+
resetForTests: () => void;
|
|
180
|
+
}
|
package/dist/approval.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { SubjectPopulation } from './permissions';
|
|
3
|
+
export interface UserContext {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
email: string;
|
|
7
|
+
locale: string;
|
|
8
|
+
theme: string;
|
|
9
|
+
timezone: string;
|
|
10
|
+
table_style?: 'striped' | 'grid';
|
|
11
|
+
table_density?: 'compact' | 'standard' | 'comfortable';
|
|
12
|
+
must_reset_password: boolean;
|
|
13
|
+
must_enroll_two_factor: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface TenantContext {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
symbol_url?: string | null;
|
|
19
|
+
default_business_timezone: string;
|
|
20
|
+
}
|
|
21
|
+
export interface LegalEntityContext {
|
|
22
|
+
public_id: string;
|
|
23
|
+
code: string;
|
|
24
|
+
name: string;
|
|
25
|
+
}
|
|
26
|
+
export interface WorkspaceContext {
|
|
27
|
+
id: number | string | null;
|
|
28
|
+
name: string | null;
|
|
29
|
+
slug: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface ContextResponse {
|
|
32
|
+
user: UserContext;
|
|
33
|
+
tenant: TenantContext | null;
|
|
34
|
+
/** @deprecated Shell bootstrap no longer emits a Legal Entity selection. */
|
|
35
|
+
legal_entity?: LegalEntityContext | null;
|
|
36
|
+
workspace: WorkspaceContext | null;
|
|
37
|
+
home?: {
|
|
38
|
+
default_dashboard_id: string | null;
|
|
39
|
+
} | null;
|
|
40
|
+
}
|
|
41
|
+
export interface PermissionsResponse {
|
|
42
|
+
permissions: string[];
|
|
43
|
+
permission_populations: Record<string, SubjectPopulation[]>;
|
|
44
|
+
roles: string[];
|
|
45
|
+
legal_entity_public_id?: string | null;
|
|
46
|
+
operating_unit_public_id?: string | null;
|
|
47
|
+
}
|
|
48
|
+
export type ContextQueryResult = UseQueryResult<ContextResponse>;
|
|
49
|
+
export type PermissionsQueryResult = UseQueryResult<PermissionsResponse>;
|
package/dist/context.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { ComponentType, LazyExoticComponent } from 'react';
|
|
2
|
+
export type DataMigrationRunStatus = 'processing' | 'completed' | 'completed_with_errors' | 'failed';
|
|
3
|
+
/** Host-owned asynchronous operation returned by migration analysis/apply APIs. */
|
|
4
|
+
export interface DataMigrationBackgroundOperation<TResult = Readonly<Record<string, unknown>>> {
|
|
5
|
+
ticket: string;
|
|
6
|
+
status: 'processing' | 'completed' | 'failed' | 'unknown';
|
|
7
|
+
result?: TResult;
|
|
8
|
+
errors?: string[];
|
|
9
|
+
validation_errors?: Record<string, string[]>;
|
|
10
|
+
progress?: number;
|
|
11
|
+
phase?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Initial response when a migration operation continues on the queue. */
|
|
14
|
+
export interface DataMigrationOperationAccepted {
|
|
15
|
+
ticket: string;
|
|
16
|
+
status: 'processing';
|
|
17
|
+
status_url?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DataMigrationOperationWaitOptions {
|
|
20
|
+
statusUrl?: string;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
onProgress?: (progress: number, phase: string | null) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface DataMigrationBackgroundOperationClient {
|
|
25
|
+
wait<TResult>(accepted: DataMigrationOperationAccepted | string, options?: DataMigrationOperationWaitOptions): Promise<TResult>;
|
|
26
|
+
cancelAll(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare function isDataMigrationOperationAccepted(value: unknown): value is DataMigrationOperationAccepted;
|
|
29
|
+
/** Builds one browser file-picker contract from server-published format keys. */
|
|
30
|
+
export declare function dataMigrationUploadAccept(formats: readonly string[]): string;
|
|
31
|
+
export interface DataMigrationSessionCheckpointStore<TState> {
|
|
32
|
+
get(key: string): TState | null;
|
|
33
|
+
remember(key: string, state: TState): void;
|
|
34
|
+
delete(key: string): void;
|
|
35
|
+
clear(): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Bounded, session-memory-only checkpoints for migration surfaces that park or
|
|
39
|
+
* remount while a contextual Resource is created.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createDataMigrationSessionCheckpointStore<TState>(capacity?: number): DataMigrationSessionCheckpointStore<TState>;
|
|
42
|
+
/** Server-owned evidence for one concrete migration execution. */
|
|
43
|
+
export interface DataMigrationRun {
|
|
44
|
+
public_id: string;
|
|
45
|
+
stage_key: string;
|
|
46
|
+
provider_key: string;
|
|
47
|
+
target_key: string;
|
|
48
|
+
status: DataMigrationRunStatus;
|
|
49
|
+
legal_entity_public_id: string | null;
|
|
50
|
+
result: Readonly<Record<string, unknown>> | null;
|
|
51
|
+
started_at: string;
|
|
52
|
+
completed_at: string | null;
|
|
53
|
+
failed_at: string | null;
|
|
54
|
+
}
|
|
55
|
+
/** Reads the standard terminal evidence embedded in migration API results. */
|
|
56
|
+
export declare function dataMigrationRunPublicId(result: unknown): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* A stage only announces which server-owned run settled. The host re-reads
|
|
59
|
+
* that run from its authenticated API instead of trusting browser state as
|
|
60
|
+
* completion evidence.
|
|
61
|
+
*/
|
|
62
|
+
export interface DataMigrationStageCompletion {
|
|
63
|
+
runPublicId: string;
|
|
64
|
+
}
|
|
65
|
+
/** App-owned stage rendered inside the host-owned data migration workspace. */
|
|
66
|
+
export interface DataMigrationStageProps {
|
|
67
|
+
providerKey: string;
|
|
68
|
+
onCompleted: (completion: DataMigrationStageCompletion) => void;
|
|
69
|
+
}
|
|
70
|
+
export type DataMigrationStageLoader = () => Promise<{
|
|
71
|
+
default: ComponentType<DataMigrationStageProps>;
|
|
72
|
+
}>;
|
|
73
|
+
export interface DataMigrationProviderRegistration {
|
|
74
|
+
key: string;
|
|
75
|
+
labelKey: string;
|
|
76
|
+
descriptionKey: string;
|
|
77
|
+
order: number;
|
|
78
|
+
ownerAppKey?: string | null;
|
|
79
|
+
}
|
|
80
|
+
/** Product destination shown in the host migration workspace. */
|
|
81
|
+
export interface DataMigrationTargetRegistration {
|
|
82
|
+
key: string;
|
|
83
|
+
appFamilyKey: string;
|
|
84
|
+
familyOrder?: number;
|
|
85
|
+
labelKey: string;
|
|
86
|
+
descriptionKey: string;
|
|
87
|
+
order: number;
|
|
88
|
+
icon?: string | null;
|
|
89
|
+
/** App Catalog key when this target requires a tenant-installed App. */
|
|
90
|
+
installationAppKey?: string | null;
|
|
91
|
+
ownerAppKey?: string | null;
|
|
92
|
+
}
|
|
93
|
+
export interface DataMigrationStageRegistration {
|
|
94
|
+
/** Globally stable logical stage id shared by its provider adapters. */
|
|
95
|
+
id: string;
|
|
96
|
+
providerKey: string;
|
|
97
|
+
/** Logical destination; multiple providers may adapt the same stage. */
|
|
98
|
+
targetKey: string;
|
|
99
|
+
labelKey: string;
|
|
100
|
+
descriptionKey: string;
|
|
101
|
+
order: number;
|
|
102
|
+
ownerAppKey?: string | null;
|
|
103
|
+
requiredPermissions?: readonly string[];
|
|
104
|
+
permissionMode?: 'all' | 'any';
|
|
105
|
+
prerequisiteStageIds?: readonly string[];
|
|
106
|
+
loader: DataMigrationStageLoader;
|
|
107
|
+
}
|
|
108
|
+
/** App-facing capability. Inspection and composition remain host-owned. */
|
|
109
|
+
export interface DataMigrationRegistrar {
|
|
110
|
+
registerProvider(registration: DataMigrationProviderRegistration): void;
|
|
111
|
+
registerTarget(registration: DataMigrationTargetRegistration): void;
|
|
112
|
+
registerStage(registration: DataMigrationStageRegistration): void;
|
|
113
|
+
}
|
|
114
|
+
export interface DataMigrationRegistry extends DataMigrationRegistrar {
|
|
115
|
+
providers(): readonly DataMigrationProviderRegistration[];
|
|
116
|
+
targets(): readonly DataMigrationTargetRegistration[];
|
|
117
|
+
allStages(): readonly DataMigrationStageRegistration[];
|
|
118
|
+
stages(providerKey: string): readonly DataMigrationStageRegistration[];
|
|
119
|
+
getStage(providerKey: string, stageId: string): LazyExoticComponent<ComponentType<DataMigrationStageProps>> | null;
|
|
120
|
+
subscribe(listener: () => void): () => void;
|
|
121
|
+
snapshot(): number;
|
|
122
|
+
resetForTests(): void;
|
|
123
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export function isDataMigrationOperationAccepted(value) {
|
|
2
|
+
return (typeof value === 'object'
|
|
3
|
+
&& value !== null
|
|
4
|
+
&& 'ticket' in value
|
|
5
|
+
&& typeof value.ticket === 'string'
|
|
6
|
+
&& value.status === 'processing');
|
|
7
|
+
}
|
|
8
|
+
const DATA_MIGRATION_FORMAT_ACCEPT = {
|
|
9
|
+
csv: ['.csv', 'text/csv'],
|
|
10
|
+
xlsx: [
|
|
11
|
+
'.xlsx',
|
|
12
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
13
|
+
],
|
|
14
|
+
xlsm: [
|
|
15
|
+
'.xlsm',
|
|
16
|
+
'application/vnd.ms-excel.sheet.macroEnabled.12',
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
/** Builds one browser file-picker contract from server-published format keys. */
|
|
20
|
+
export function dataMigrationUploadAccept(formats) {
|
|
21
|
+
return Array.from(new Set(formats.flatMap((format) => {
|
|
22
|
+
const normalized = format.trim().toLowerCase();
|
|
23
|
+
if (!normalized)
|
|
24
|
+
return [];
|
|
25
|
+
return DATA_MIGRATION_FORMAT_ACCEPT[normalized] ?? [`.${normalized}`];
|
|
26
|
+
}))).join(',');
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Bounded, session-memory-only checkpoints for migration surfaces that park or
|
|
30
|
+
* remount while a contextual Resource is created.
|
|
31
|
+
*/
|
|
32
|
+
export function createDataMigrationSessionCheckpointStore(capacity = 24) {
|
|
33
|
+
if (!Number.isInteger(capacity) || capacity < 1) {
|
|
34
|
+
throw new Error('Data migration checkpoint capacity must be positive.');
|
|
35
|
+
}
|
|
36
|
+
const states = new Map();
|
|
37
|
+
return {
|
|
38
|
+
get: (key) => states.get(key) ?? null,
|
|
39
|
+
remember(key, state) {
|
|
40
|
+
states.delete(key);
|
|
41
|
+
states.set(key, state);
|
|
42
|
+
while (states.size > capacity) {
|
|
43
|
+
const oldest = states.keys().next().value;
|
|
44
|
+
if (typeof oldest !== 'string')
|
|
45
|
+
break;
|
|
46
|
+
states.delete(oldest);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
delete: (key) => {
|
|
50
|
+
states.delete(key);
|
|
51
|
+
},
|
|
52
|
+
clear: () => states.clear(),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Reads the standard terminal evidence embedded in migration API results. */
|
|
56
|
+
export function dataMigrationRunPublicId(result) {
|
|
57
|
+
if (typeof result !== 'object' || result === null || Array.isArray(result)) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const migrationRun = result.migration_run;
|
|
61
|
+
if (typeof migrationRun !== 'object'
|
|
62
|
+
|| migrationRun === null
|
|
63
|
+
|| Array.isArray(migrationRun)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const publicId = migrationRun.public_id;
|
|
67
|
+
return typeof publicId === 'string' && publicId.trim() !== ''
|
|
68
|
+
? publicId
|
|
69
|
+
: null;
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const validRegistration = {
|
|
2
|
+
formWidgetKey: 'sample.expense_report',
|
|
3
|
+
loader: async () => ({ default: () => null }),
|
|
4
|
+
};
|
|
5
|
+
registry.register(validRegistration);
|
|
6
|
+
// @ts-expect-error A registrar payload must supply its typed widget loader.
|
|
7
|
+
registry.register({ formWidgetKey: 'sample.expense_report' });
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const HANDOFF_RESULT_STATES: readonly ["ACCEPTED", "REJECTED", "UNAUTHORIZED", "STALE", "RETRYABLE_FAILED", "TERMINAL_FAILED"];
|
|
2
|
+
export type HandoffResultState = (typeof HANDOFF_RESULT_STATES)[number];
|
|
3
|
+
export declare function isHandoffResultState(value: unknown): value is HandoffResultState;
|
|
4
|
+
export declare function isRetryableFailure(state: HandoffResultState): boolean;
|
|
5
|
+
/** @deprecated Use isRetryableFailure to match the PHP contract. */
|
|
6
|
+
export declare const isRetryableHandoffFailure: typeof isRetryableFailure;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const HANDOFF_RESULT_STATES = [
|
|
2
|
+
'ACCEPTED',
|
|
3
|
+
'REJECTED',
|
|
4
|
+
'UNAUTHORIZED',
|
|
5
|
+
'STALE',
|
|
6
|
+
'RETRYABLE_FAILED',
|
|
7
|
+
'TERMINAL_FAILED',
|
|
8
|
+
];
|
|
9
|
+
export function isHandoffResultState(value) {
|
|
10
|
+
return (typeof value === 'string' &&
|
|
11
|
+
HANDOFF_RESULT_STATES.includes(value));
|
|
12
|
+
}
|
|
13
|
+
export function isRetryableFailure(state) {
|
|
14
|
+
return state === 'RETRYABLE_FAILED';
|
|
15
|
+
}
|
|
16
|
+
/** @deprecated Use isRetryableFailure to match the PHP contract. */
|
|
17
|
+
export const isRetryableHandoffFailure = isRetryableFailure;
|