@openfairygui/backend 0.3.0 → 0.4.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.
@@ -0,0 +1,284 @@
1
+ import { ProjectDiagnosticCode } from "@openfairygui/core";
2
+ import { UamTransactionSupportIssueCode } from "@openfairygui/core/uam";
3
+ import { ApplyUamTransactionAppError } from "@openfairygui/functions/uam";
4
+
5
+ //#region src/path-policy.d.ts
6
+ interface PathPolicyViolationError {
7
+ code: 'path_policy_violation';
8
+ message: string;
9
+ policy: 'save_target';
10
+ attemptedPath: string;
11
+ allowedPath: string;
12
+ }
13
+ //#endregion
14
+ //#region src/runtime/contracts.d.ts
15
+ interface EntityQueryError {
16
+ code: 'entity_query_failed';
17
+ message: string;
18
+ sessionId: string;
19
+ reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'response_budget_exceeded' | 'non_json_value';
20
+ }
21
+ interface SessionNotFoundError {
22
+ code: 'session_not_found';
23
+ message: string;
24
+ sessionId: string;
25
+ }
26
+ interface SessionStaleWriteError {
27
+ code: 'stale_write';
28
+ message: string;
29
+ sessionId: string;
30
+ canonicalPathKey: string;
31
+ expectedRevision: number;
32
+ actualRevision: number;
33
+ }
34
+ interface InProcessLockConflictError {
35
+ code: 'lock_conflict';
36
+ kind: 'in_process_session_exists';
37
+ message: string;
38
+ canonicalPathKey: string;
39
+ holderSessionId: string;
40
+ lockFilePath?: string;
41
+ }
42
+ interface AdvisoryLockConflictError {
43
+ code: 'lock_conflict';
44
+ kind: 'advisory_lock_conflict';
45
+ message: string;
46
+ canonicalPathKey: string;
47
+ holderSessionId?: string;
48
+ lockFilePath: string;
49
+ }
50
+ interface SessionIdConflictError {
51
+ code: 'session_id_conflict';
52
+ message: string;
53
+ sessionId: string;
54
+ }
55
+ interface SavePartialFailureError {
56
+ code: 'save_partial_failure';
57
+ message: string;
58
+ sessionId: string;
59
+ canonicalPathKey: string;
60
+ attemptedRevision: number;
61
+ lastSavedRevision: number;
62
+ committedPaths: string[];
63
+ failedPaths: string[];
64
+ diskMayBePartiallyUpdated: boolean;
65
+ }
66
+ interface UamFidelityUnsupportedError {
67
+ code: 'uam_fidelity_unsupported';
68
+ message: string;
69
+ sessionId: string;
70
+ canonicalPathKey: string;
71
+ }
72
+ interface MaterializeValidationFailedError {
73
+ code: 'materialize_validation_failed';
74
+ message: string;
75
+ sessionId: string;
76
+ canonicalPathKey: string;
77
+ issueCount: number;
78
+ diagnostics: BackendDiagnostic[];
79
+ }
80
+ interface MaterializeWriteFailedError {
81
+ code: 'write_failed';
82
+ message: string;
83
+ sessionId: string;
84
+ canonicalPathKey: string;
85
+ attemptedRevision: number;
86
+ lastSavedRevision: number;
87
+ writtenPaths: string[];
88
+ failedPaths: string[];
89
+ skippedPaths: string[];
90
+ diagnostics: BackendDiagnostic[];
91
+ diskMayBePartiallyUpdated: boolean;
92
+ }
93
+ interface EventCursorInvalidError {
94
+ code: 'event_cursor_invalid';
95
+ message: string;
96
+ sessionId: string;
97
+ after: string;
98
+ }
99
+ interface BackendJobNotFoundError {
100
+ code: 'job_not_found';
101
+ message: string;
102
+ sessionId: string;
103
+ jobId: string;
104
+ }
105
+ interface BackendJobNotCancellableError {
106
+ code: 'job_not_cancellable';
107
+ message: string;
108
+ sessionId: string;
109
+ jobId: string;
110
+ status: 'completed' | 'failed' | 'cancelled';
111
+ }
112
+ interface BackendJobCancelledError {
113
+ code: 'job_cancelled';
114
+ message: string;
115
+ sessionId: string;
116
+ jobId: string;
117
+ }
118
+ interface CacheRefreshFailedError {
119
+ code: 'cache_refresh_failed';
120
+ message: string;
121
+ sessionId: string;
122
+ jobId: string;
123
+ causeCode?: string;
124
+ }
125
+ interface BackendCapabilityUnavailableError {
126
+ code: 'capability_unavailable';
127
+ message: string;
128
+ capability: 'fileSystem' | 'artifact.publish' | 'artifact.restore';
129
+ requiredAdapter?: 'BackendFileSystem';
130
+ requiredHost?: 'node';
131
+ bridgeBoundary?: 'external-bridge';
132
+ }
133
+ type BackendError = SessionNotFoundError | TransactionPreviewError | EntityQueryError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
134
+ interface ProjectRootNotAllowedError {
135
+ code: 'project_root_not_allowed';
136
+ message: string;
137
+ projectPath: string;
138
+ }
139
+ interface ProjectOpenFailedError {
140
+ code: 'project_open_failed';
141
+ message: string;
142
+ projectPath: string;
143
+ }
144
+ interface TransactionPreviewError {
145
+ code: 'transaction_preview_failed';
146
+ message: string;
147
+ sessionId: string;
148
+ reason: 'response_budget_exceeded' | 'projection_failed';
149
+ }
150
+ //#endregion
151
+ //#region src/contracts.d.ts
152
+ type BackendDiagnosticCode = BackendError['code'] | UamTransactionSupportIssueCode | ProjectDiagnosticCode;
153
+ type BackendDiagnosticOwner = 'backend' | 'core.transaction' | 'core.validation';
154
+ interface BackendDiagnostic {
155
+ code: BackendDiagnosticCode;
156
+ message: string;
157
+ severity: 'info' | 'warning' | 'error';
158
+ path?: string;
159
+ nodeKind?: string;
160
+ resourceKind?: string;
161
+ gearKind?: string;
162
+ field?: string;
163
+ operationKind?: string;
164
+ opIndex?: number;
165
+ opId?: string;
166
+ /** Present for catalogued diagnostics only; original codes and classification are preserved. */
167
+ owner?: BackendDiagnosticOwner;
168
+ docsUri?: string;
169
+ remediation?: BackendDiagnosticRemediation;
170
+ }
171
+ interface BackendDiagnosticRemediation {
172
+ kind: 'refresh-and-replan' | 'revise-selector' | 'revise-operation' | 'host-action';
173
+ message: string;
174
+ /** A read-only starting point, never permission to retry or mutate. */
175
+ read?: {
176
+ method: 'getProjectOutline';
177
+ input: {
178
+ sessionId: string;
179
+ };
180
+ };
181
+ }
182
+ //#endregion
183
+ //#region src/diagnostics.d.ts
184
+ /** Shared codes list all canonical owners; responses preserve the actual reporting owner. */
185
+ interface BackendDiagnosticGuide {
186
+ code: BackendDiagnosticCode;
187
+ owners: readonly BackendDiagnosticOwner[];
188
+ remediation: Omit<BackendDiagnosticRemediation, 'read'>;
189
+ }
190
+ //#endregion
191
+ //#region src/docs.d.ts
192
+ /** JSON Schema data, not another validator or operation grammar. */
193
+ interface ContractSchema {
194
+ $ref?: string;
195
+ [keyword: string]: unknown;
196
+ }
197
+ interface ContractSnapshot {
198
+ digest: string;
199
+ schemaVersion: number;
200
+ versions: {
201
+ BACKEND_CONTRACT_VERSION: string;
202
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
203
+ };
204
+ operations: Record<string, ContractSchema>;
205
+ tools: Record<string, {
206
+ input: ContractSchema;
207
+ output: ContractSchema;
208
+ bytePaths: string[][];
209
+ [metadata: string]: unknown;
210
+ }>;
211
+ cli: Record<string, ContractSchema>;
212
+ $defs: Record<string, ContractSchema>;
213
+ diagnostics: BackendDiagnosticGuide[];
214
+ }
215
+ declare const OPENFAIRYGUI_DOCS_INDEX_URI = "openfairygui://docs/index";
216
+ declare const OPENFAIRYGUI_OPERATION_CATALOG_URI = "openfairygui://contracts/operations";
217
+ declare const OPENFAIRYGUI_OPERATION_SCHEMA_TEMPLATE = "openfairygui://contracts/operations/{kind}";
218
+ /** Detached copy for wire adapters; documentation and adapters share one generated snapshot. */
219
+ declare function getInstalledContractSnapshot(): ContractSnapshot;
220
+ declare function getInstalledDocumentationVersion(): {
221
+ contractDigest: string;
222
+ BACKEND_CONTRACT_VERSION: string;
223
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
224
+ packageName: string;
225
+ packageVersion: string;
226
+ nodeEngine: string;
227
+ documentationDigest: string;
228
+ };
229
+ declare function getOpenFairyGuiOperationCatalog(): {
230
+ operations: {
231
+ kind: string;
232
+ schemaUri: string;
233
+ }[];
234
+ BACKEND_CONTRACT_VERSION: string;
235
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
236
+ digest: string;
237
+ schemaVersion: number;
238
+ };
239
+ declare function getOpenFairyGuiOperationSchema(kind: string): ContractSchema;
240
+ declare function getInstalledDocumentationIndex(): {
241
+ documents: {
242
+ id: string;
243
+ title: string;
244
+ uri: string;
245
+ }[];
246
+ contractDigest: string;
247
+ BACKEND_CONTRACT_VERSION: string;
248
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
249
+ packageName: string;
250
+ packageVersion: string;
251
+ nodeEngine: string;
252
+ documentationDigest: string;
253
+ };
254
+ /** IDs come from the index, never filesystem paths or remote URLs. */
255
+ declare function readInstalledDocumentation(id: string): {
256
+ mimeType: string;
257
+ text: string;
258
+ id: string;
259
+ title: string;
260
+ uri: string;
261
+ contractDigest: string;
262
+ BACKEND_CONTRACT_VERSION: string;
263
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
264
+ packageName: string;
265
+ packageVersion: string;
266
+ nodeEngine: string;
267
+ documentationDigest: string;
268
+ };
269
+ declare function findInstalledDocumentation(query: string): {
270
+ documents: {
271
+ id: string;
272
+ title: string;
273
+ uri: string;
274
+ }[];
275
+ contractDigest: string;
276
+ BACKEND_CONTRACT_VERSION: string;
277
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
278
+ packageName: string;
279
+ packageVersion: string;
280
+ nodeEngine: string;
281
+ documentationDigest: string;
282
+ };
283
+ //#endregion
284
+ export { ContractSchema, ContractSnapshot, OPENFAIRYGUI_DOCS_INDEX_URI, OPENFAIRYGUI_OPERATION_CATALOG_URI, OPENFAIRYGUI_OPERATION_SCHEMA_TEMPLATE, findInstalledDocumentation, getInstalledContractSnapshot, getInstalledDocumentationIndex, getInstalledDocumentationVersion, getOpenFairyGuiOperationCatalog, getOpenFairyGuiOperationSchema, readInstalledDocumentation };
@@ -0,0 +1,284 @@
1
+ import { ProjectDiagnosticCode } from "@openfairygui/core";
2
+ import { UamTransactionSupportIssueCode } from "@openfairygui/core/uam";
3
+ import { ApplyUamTransactionAppError } from "@openfairygui/functions/uam";
4
+
5
+ //#region src/path-policy.d.ts
6
+ interface PathPolicyViolationError {
7
+ code: 'path_policy_violation';
8
+ message: string;
9
+ policy: 'save_target';
10
+ attemptedPath: string;
11
+ allowedPath: string;
12
+ }
13
+ //#endregion
14
+ //#region src/runtime/contracts.d.ts
15
+ interface EntityQueryError {
16
+ code: 'entity_query_failed';
17
+ message: string;
18
+ sessionId: string;
19
+ reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'response_budget_exceeded' | 'non_json_value';
20
+ }
21
+ interface SessionNotFoundError {
22
+ code: 'session_not_found';
23
+ message: string;
24
+ sessionId: string;
25
+ }
26
+ interface SessionStaleWriteError {
27
+ code: 'stale_write';
28
+ message: string;
29
+ sessionId: string;
30
+ canonicalPathKey: string;
31
+ expectedRevision: number;
32
+ actualRevision: number;
33
+ }
34
+ interface InProcessLockConflictError {
35
+ code: 'lock_conflict';
36
+ kind: 'in_process_session_exists';
37
+ message: string;
38
+ canonicalPathKey: string;
39
+ holderSessionId: string;
40
+ lockFilePath?: string;
41
+ }
42
+ interface AdvisoryLockConflictError {
43
+ code: 'lock_conflict';
44
+ kind: 'advisory_lock_conflict';
45
+ message: string;
46
+ canonicalPathKey: string;
47
+ holderSessionId?: string;
48
+ lockFilePath: string;
49
+ }
50
+ interface SessionIdConflictError {
51
+ code: 'session_id_conflict';
52
+ message: string;
53
+ sessionId: string;
54
+ }
55
+ interface SavePartialFailureError {
56
+ code: 'save_partial_failure';
57
+ message: string;
58
+ sessionId: string;
59
+ canonicalPathKey: string;
60
+ attemptedRevision: number;
61
+ lastSavedRevision: number;
62
+ committedPaths: string[];
63
+ failedPaths: string[];
64
+ diskMayBePartiallyUpdated: boolean;
65
+ }
66
+ interface UamFidelityUnsupportedError {
67
+ code: 'uam_fidelity_unsupported';
68
+ message: string;
69
+ sessionId: string;
70
+ canonicalPathKey: string;
71
+ }
72
+ interface MaterializeValidationFailedError {
73
+ code: 'materialize_validation_failed';
74
+ message: string;
75
+ sessionId: string;
76
+ canonicalPathKey: string;
77
+ issueCount: number;
78
+ diagnostics: BackendDiagnostic[];
79
+ }
80
+ interface MaterializeWriteFailedError {
81
+ code: 'write_failed';
82
+ message: string;
83
+ sessionId: string;
84
+ canonicalPathKey: string;
85
+ attemptedRevision: number;
86
+ lastSavedRevision: number;
87
+ writtenPaths: string[];
88
+ failedPaths: string[];
89
+ skippedPaths: string[];
90
+ diagnostics: BackendDiagnostic[];
91
+ diskMayBePartiallyUpdated: boolean;
92
+ }
93
+ interface EventCursorInvalidError {
94
+ code: 'event_cursor_invalid';
95
+ message: string;
96
+ sessionId: string;
97
+ after: string;
98
+ }
99
+ interface BackendJobNotFoundError {
100
+ code: 'job_not_found';
101
+ message: string;
102
+ sessionId: string;
103
+ jobId: string;
104
+ }
105
+ interface BackendJobNotCancellableError {
106
+ code: 'job_not_cancellable';
107
+ message: string;
108
+ sessionId: string;
109
+ jobId: string;
110
+ status: 'completed' | 'failed' | 'cancelled';
111
+ }
112
+ interface BackendJobCancelledError {
113
+ code: 'job_cancelled';
114
+ message: string;
115
+ sessionId: string;
116
+ jobId: string;
117
+ }
118
+ interface CacheRefreshFailedError {
119
+ code: 'cache_refresh_failed';
120
+ message: string;
121
+ sessionId: string;
122
+ jobId: string;
123
+ causeCode?: string;
124
+ }
125
+ interface BackendCapabilityUnavailableError {
126
+ code: 'capability_unavailable';
127
+ message: string;
128
+ capability: 'fileSystem' | 'artifact.publish' | 'artifact.restore';
129
+ requiredAdapter?: 'BackendFileSystem';
130
+ requiredHost?: 'node';
131
+ bridgeBoundary?: 'external-bridge';
132
+ }
133
+ type BackendError = SessionNotFoundError | TransactionPreviewError | EntityQueryError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
134
+ interface ProjectRootNotAllowedError {
135
+ code: 'project_root_not_allowed';
136
+ message: string;
137
+ projectPath: string;
138
+ }
139
+ interface ProjectOpenFailedError {
140
+ code: 'project_open_failed';
141
+ message: string;
142
+ projectPath: string;
143
+ }
144
+ interface TransactionPreviewError {
145
+ code: 'transaction_preview_failed';
146
+ message: string;
147
+ sessionId: string;
148
+ reason: 'response_budget_exceeded' | 'projection_failed';
149
+ }
150
+ //#endregion
151
+ //#region src/contracts.d.ts
152
+ type BackendDiagnosticCode = BackendError['code'] | UamTransactionSupportIssueCode | ProjectDiagnosticCode;
153
+ type BackendDiagnosticOwner = 'backend' | 'core.transaction' | 'core.validation';
154
+ interface BackendDiagnostic {
155
+ code: BackendDiagnosticCode;
156
+ message: string;
157
+ severity: 'info' | 'warning' | 'error';
158
+ path?: string;
159
+ nodeKind?: string;
160
+ resourceKind?: string;
161
+ gearKind?: string;
162
+ field?: string;
163
+ operationKind?: string;
164
+ opIndex?: number;
165
+ opId?: string;
166
+ /** Present for catalogued diagnostics only; original codes and classification are preserved. */
167
+ owner?: BackendDiagnosticOwner;
168
+ docsUri?: string;
169
+ remediation?: BackendDiagnosticRemediation;
170
+ }
171
+ interface BackendDiagnosticRemediation {
172
+ kind: 'refresh-and-replan' | 'revise-selector' | 'revise-operation' | 'host-action';
173
+ message: string;
174
+ /** A read-only starting point, never permission to retry or mutate. */
175
+ read?: {
176
+ method: 'getProjectOutline';
177
+ input: {
178
+ sessionId: string;
179
+ };
180
+ };
181
+ }
182
+ //#endregion
183
+ //#region src/diagnostics.d.ts
184
+ /** Shared codes list all canonical owners; responses preserve the actual reporting owner. */
185
+ interface BackendDiagnosticGuide {
186
+ code: BackendDiagnosticCode;
187
+ owners: readonly BackendDiagnosticOwner[];
188
+ remediation: Omit<BackendDiagnosticRemediation, 'read'>;
189
+ }
190
+ //#endregion
191
+ //#region src/docs.d.ts
192
+ /** JSON Schema data, not another validator or operation grammar. */
193
+ interface ContractSchema {
194
+ $ref?: string;
195
+ [keyword: string]: unknown;
196
+ }
197
+ interface ContractSnapshot {
198
+ digest: string;
199
+ schemaVersion: number;
200
+ versions: {
201
+ BACKEND_CONTRACT_VERSION: string;
202
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
203
+ };
204
+ operations: Record<string, ContractSchema>;
205
+ tools: Record<string, {
206
+ input: ContractSchema;
207
+ output: ContractSchema;
208
+ bytePaths: string[][];
209
+ [metadata: string]: unknown;
210
+ }>;
211
+ cli: Record<string, ContractSchema>;
212
+ $defs: Record<string, ContractSchema>;
213
+ diagnostics: BackendDiagnosticGuide[];
214
+ }
215
+ declare const OPENFAIRYGUI_DOCS_INDEX_URI = "openfairygui://docs/index";
216
+ declare const OPENFAIRYGUI_OPERATION_CATALOG_URI = "openfairygui://contracts/operations";
217
+ declare const OPENFAIRYGUI_OPERATION_SCHEMA_TEMPLATE = "openfairygui://contracts/operations/{kind}";
218
+ /** Detached copy for wire adapters; documentation and adapters share one generated snapshot. */
219
+ declare function getInstalledContractSnapshot(): ContractSnapshot;
220
+ declare function getInstalledDocumentationVersion(): {
221
+ contractDigest: string;
222
+ BACKEND_CONTRACT_VERSION: string;
223
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
224
+ packageName: string;
225
+ packageVersion: string;
226
+ nodeEngine: string;
227
+ documentationDigest: string;
228
+ };
229
+ declare function getOpenFairyGuiOperationCatalog(): {
230
+ operations: {
231
+ kind: string;
232
+ schemaUri: string;
233
+ }[];
234
+ BACKEND_CONTRACT_VERSION: string;
235
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
236
+ digest: string;
237
+ schemaVersion: number;
238
+ };
239
+ declare function getOpenFairyGuiOperationSchema(kind: string): ContractSchema;
240
+ declare function getInstalledDocumentationIndex(): {
241
+ documents: {
242
+ id: string;
243
+ title: string;
244
+ uri: string;
245
+ }[];
246
+ contractDigest: string;
247
+ BACKEND_CONTRACT_VERSION: string;
248
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
249
+ packageName: string;
250
+ packageVersion: string;
251
+ nodeEngine: string;
252
+ documentationDigest: string;
253
+ };
254
+ /** IDs come from the index, never filesystem paths or remote URLs. */
255
+ declare function readInstalledDocumentation(id: string): {
256
+ mimeType: string;
257
+ text: string;
258
+ id: string;
259
+ title: string;
260
+ uri: string;
261
+ contractDigest: string;
262
+ BACKEND_CONTRACT_VERSION: string;
263
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
264
+ packageName: string;
265
+ packageVersion: string;
266
+ nodeEngine: string;
267
+ documentationDigest: string;
268
+ };
269
+ declare function findInstalledDocumentation(query: string): {
270
+ documents: {
271
+ id: string;
272
+ title: string;
273
+ uri: string;
274
+ }[];
275
+ contractDigest: string;
276
+ BACKEND_CONTRACT_VERSION: string;
277
+ BACKEND_CAPABILITY_SCHEMA_VERSION: number;
278
+ packageName: string;
279
+ packageVersion: string;
280
+ nodeEngine: string;
281
+ documentationDigest: string;
282
+ };
283
+ //#endregion
284
+ export { ContractSchema, ContractSnapshot, OPENFAIRYGUI_DOCS_INDEX_URI, OPENFAIRYGUI_OPERATION_CATALOG_URI, OPENFAIRYGUI_OPERATION_SCHEMA_TEMPLATE, findInstalledDocumentation, getInstalledContractSnapshot, getInstalledDocumentationIndex, getInstalledDocumentationVersion, getOpenFairyGuiOperationCatalog, getOpenFairyGuiOperationSchema, readInstalledDocumentation };