@tiangong-lca/cli 0.1.0 → 0.1.2

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.
Files changed (159) hide show
  1. package/README.md +58 -6
  2. package/dist/src/batch.d.ts +6 -0
  3. package/dist/src/batch.js +6 -0
  4. package/dist/src/batch.js.map +1 -0
  5. package/dist/src/cli.d.ts +161 -0
  6. package/dist/src/cli.js +130 -0
  7. package/dist/src/cli.js.map +1 -1
  8. package/dist/src/command-spec.d.ts +90 -0
  9. package/dist/src/command-spec.js +400 -0
  10. package/dist/src/command-spec.js.map +1 -0
  11. package/dist/src/lib/artifacts.d.ts +9 -0
  12. package/dist/src/lib/auth-identity-receipt.d.ts +160 -0
  13. package/dist/src/lib/auth-identity-receipt.js +634 -0
  14. package/dist/src/lib/auth-identity-receipt.js.map +1 -0
  15. package/dist/src/lib/batch/attempt-recovery.d.ts +12 -0
  16. package/dist/src/lib/batch/attempt-recovery.js +183 -0
  17. package/dist/src/lib/batch/attempt-recovery.js.map +1 -0
  18. package/dist/src/lib/batch/canonical-contracts.d.ts +21 -0
  19. package/dist/src/lib/batch/canonical-contracts.js +180 -0
  20. package/dist/src/lib/batch/canonical-contracts.js.map +1 -0
  21. package/dist/src/lib/batch/engine.d.ts +2 -0
  22. package/dist/src/lib/batch/engine.js +294 -0
  23. package/dist/src/lib/batch/engine.js.map +1 -0
  24. package/dist/src/lib/batch/errors.d.ts +51 -0
  25. package/dist/src/lib/batch/errors.js +81 -0
  26. package/dist/src/lib/batch/errors.js.map +1 -0
  27. package/dist/src/lib/batch/item-projection.d.ts +10 -0
  28. package/dist/src/lib/batch/item-projection.js +118 -0
  29. package/dist/src/lib/batch/item-projection.js.map +1 -0
  30. package/dist/src/lib/batch/run-lock.d.ts +4 -0
  31. package/dist/src/lib/batch/run-lock.js +155 -0
  32. package/dist/src/lib/batch/run-lock.js.map +1 -0
  33. package/dist/src/lib/batch/scheduler-runtime.d.ts +29 -0
  34. package/dist/src/lib/batch/scheduler-runtime.js +114 -0
  35. package/dist/src/lib/batch/scheduler-runtime.js.map +1 -0
  36. package/dist/src/lib/batch/types.d.ts +183 -0
  37. package/dist/src/lib/batch/types.js +2 -0
  38. package/dist/src/lib/batch/types.js.map +1 -0
  39. package/dist/src/lib/dataset-author.d.ts +39 -0
  40. package/dist/src/lib/dataset-bilingual.d.ts +165 -0
  41. package/dist/src/lib/dataset-classification.d.ts +279 -0
  42. package/dist/src/lib/dataset-command.d.ts +53 -0
  43. package/dist/src/lib/dataset-contract.d.ts +82 -0
  44. package/dist/src/lib/dataset-curation-queue.d.ts +219 -0
  45. package/dist/src/lib/dataset-evidence-search.d.ts +134 -0
  46. package/dist/src/lib/dataset-import-lca.d.ts +136 -0
  47. package/dist/src/lib/dataset-local.d.ts +23 -0
  48. package/dist/src/lib/dataset-maintenance-alias-request.d.ts +12 -0
  49. package/dist/src/lib/dataset-maintenance-alias-rewrite.d.ts +111 -0
  50. package/dist/src/lib/dataset-maintenance-apply.d.ts +458 -0
  51. package/dist/src/lib/dataset-maintenance-clear-account.d.ts +161 -0
  52. package/dist/src/lib/dataset-maintenance-contract.d.ts +317 -0
  53. package/dist/src/lib/dataset-maintenance-derivatives.d.ts +48 -0
  54. package/dist/src/lib/dataset-maintenance-flow-identity-approval-claim.d.ts +50 -0
  55. package/dist/src/lib/dataset-maintenance-flow-identity-capture.d.ts +110 -0
  56. package/dist/src/lib/dataset-maintenance-flow-identity-command.d.ts +15 -0
  57. package/dist/src/lib/dataset-maintenance-flow-identity-contract.d.ts +387 -0
  58. package/dist/src/lib/dataset-maintenance-flow-identity-execution-contract.d.ts +456 -0
  59. package/dist/src/lib/dataset-maintenance-flow-identity-freeze.d.ts +99 -0
  60. package/dist/src/lib/dataset-maintenance-flow-identity-plan.d.ts +85 -0
  61. package/dist/src/lib/dataset-maintenance-flow-identity-recovery.d.ts +268 -0
  62. package/dist/src/lib/dataset-maintenance-flow-identity-run.d.ts +123 -0
  63. package/dist/src/lib/dataset-maintenance-flow-identity-seal.d.ts +50 -0
  64. package/dist/src/lib/dataset-maintenance-flow-identity-verify.d.ts +85 -0
  65. package/dist/src/lib/dataset-maintenance-flow-identity-wire.d.ts +32 -0
  66. package/dist/src/lib/dataset-maintenance-pagination.d.ts +58 -0
  67. package/dist/src/lib/dataset-maintenance-plan.d.ts +40 -0
  68. package/dist/src/lib/dataset-maintenance-protected-artifacts.d.ts +16 -0
  69. package/dist/src/lib/dataset-maintenance-protected-before.d.ts +71 -0
  70. package/dist/src/lib/dataset-maintenance-protected-contract.d.ts +385 -0
  71. package/dist/src/lib/dataset-maintenance-protected-freeze.d.ts +148 -0
  72. package/dist/src/lib/dataset-maintenance-protected-preparation.d.ts +76 -0
  73. package/dist/src/lib/dataset-maintenance-protected-run.d.ts +252 -0
  74. package/dist/src/lib/dataset-maintenance-protected-seal.d.ts +93 -0
  75. package/dist/src/lib/dataset-maintenance-protected-toolchain.d.ts +31 -0
  76. package/dist/src/lib/dataset-maintenance-protected-verify.d.ts +99 -0
  77. package/dist/src/lib/dataset-maintenance-remote.d.ts +212 -0
  78. package/dist/src/lib/dataset-maintenance-support-validation.d.ts +18 -0
  79. package/dist/src/lib/dataset-maintenance-verify.d.ts +102 -0
  80. package/dist/src/lib/dataset-patch.d.ts +193 -0
  81. package/dist/src/lib/dataset-references-rewrite.d.ts +77 -0
  82. package/dist/src/lib/dataset-remote-refresh.d.ts +64 -0
  83. package/dist/src/lib/dataset-remote-verify.d.ts +168 -0
  84. package/dist/src/lib/dataset-save-draft-run.d.ts +283 -0
  85. package/dist/src/lib/dataset-save-draft-run.js +54 -21
  86. package/dist/src/lib/dataset-save-draft-run.js.map +1 -1
  87. package/dist/src/lib/dataset-source-upload-attachments.d.ts +109 -0
  88. package/dist/src/lib/dataset-validate.d.ts +62 -0
  89. package/dist/src/lib/dotenv.d.ts +6 -0
  90. package/dist/src/lib/env.d.ts +59 -0
  91. package/dist/src/lib/errors.d.ts +18 -0
  92. package/dist/src/lib/flow-build-alias-map.d.ts +80 -0
  93. package/dist/src/lib/flow-fetch-rows.d.ts +70 -0
  94. package/dist/src/lib/flow-get.d.ts +35 -0
  95. package/dist/src/lib/flow-governance.d.ts +22 -0
  96. package/dist/src/lib/flow-list.d.ts +57 -0
  97. package/dist/src/lib/flow-materialize-decisions.d.ts +67 -0
  98. package/dist/src/lib/flow-payload-validation.d.ts +32 -0
  99. package/dist/src/lib/flow-publish-reviewed-data.d.ts +262 -0
  100. package/dist/src/lib/flow-publish-version.d.ts +193 -0
  101. package/dist/src/lib/flow-qa.d.ts +289 -0
  102. package/dist/src/lib/flow-read.d.ts +70 -0
  103. package/dist/src/lib/flow-regen-product.d.ts +431 -0
  104. package/dist/src/lib/flow-remediate.d.ts +133 -0
  105. package/dist/src/lib/http.d.ts +25 -0
  106. package/dist/src/lib/http.js.map +1 -1
  107. package/dist/src/lib/identity-preflight.d.ts +235 -0
  108. package/dist/src/lib/io.d.ts +2 -0
  109. package/dist/src/lib/kb-search.d.ts +23 -0
  110. package/dist/src/lib/lca-release.d.ts +105 -0
  111. package/dist/src/lib/lifecyclemodel-auto-build.d.ts +223 -0
  112. package/dist/src/lib/lifecyclemodel-bundle-save.d.ts +71 -0
  113. package/dist/src/lib/lifecyclemodel-graph.d.ts +91 -0
  114. package/dist/src/lib/lifecyclemodel-orchestrate.d.ts +349 -0
  115. package/dist/src/lib/lifecyclemodel-publish-build.d.ts +77 -0
  116. package/dist/src/lib/lifecyclemodel-publish-resulting-process.d.ts +27 -0
  117. package/dist/src/lib/lifecyclemodel-qa.d.ts +206 -0
  118. package/dist/src/lib/lifecyclemodel-resulting-process.d.ts +204 -0
  119. package/dist/src/lib/lifecyclemodel-save-draft-run.d.ts +96 -0
  120. package/dist/src/lib/lifecyclemodel-validate-build.d.ts +78 -0
  121. package/dist/src/lib/llm.d.ts +51 -0
  122. package/dist/src/lib/package-version.d.ts +3 -0
  123. package/dist/src/lib/process-auto-build.d.ts +168 -0
  124. package/dist/src/lib/process-batch-build.d.ts +97 -0
  125. package/dist/src/lib/process-dedup-review.d.ts +253 -0
  126. package/dist/src/lib/process-flow-build-plan.d.ts +108 -0
  127. package/dist/src/lib/process-get.d.ts +26 -0
  128. package/dist/src/lib/process-list.d.ts +87 -0
  129. package/dist/src/lib/process-payload-validation.d.ts +27 -0
  130. package/dist/src/lib/process-publish-build.d.ts +148 -0
  131. package/dist/src/lib/process-qa.d.ts +243 -0
  132. package/dist/src/lib/process-refresh-references.d.ts +179 -0
  133. package/dist/src/lib/process-required-fields.d.ts +142 -0
  134. package/dist/src/lib/process-resume-build.d.ts +77 -0
  135. package/dist/src/lib/process-save-draft-run.d.ts +72 -0
  136. package/dist/src/lib/process-save-draft.d.ts +53 -0
  137. package/dist/src/lib/process-scope-statistics.d.ts +210 -0
  138. package/dist/src/lib/process-verify-rows.d.ts +71 -0
  139. package/dist/src/lib/publish.d.ts +219 -0
  140. package/dist/src/lib/remote.d.ts +19 -0
  141. package/dist/src/lib/run.d.ts +60 -0
  142. package/dist/src/lib/runtime-rulesets.d.ts +29 -0
  143. package/dist/src/lib/state-lock.d.ts +25 -0
  144. package/dist/src/lib/state-lock.js +23 -1
  145. package/dist/src/lib/state-lock.js.map +1 -1
  146. package/dist/src/lib/supabase-client.d.ts +47 -0
  147. package/dist/src/lib/supabase-data-api-contract.d.ts +304 -0
  148. package/dist/src/lib/supabase-data-api-replay.d.ts +74 -0
  149. package/dist/src/lib/supabase-json-ordered-write.d.ts +65 -0
  150. package/dist/src/lib/supabase-rest.d.ts +26 -0
  151. package/dist/src/lib/supabase-session.d.ts +115 -0
  152. package/dist/src/lib/tidas-languages.d.ts +3 -0
  153. package/dist/src/lib/tidas-sdk-package-validator.d.ts +111 -0
  154. package/dist/src/lib/tidas-sdk-validation.d.ts +42 -0
  155. package/dist/src/lib/unstructured.d.ts +32 -0
  156. package/dist/src/lib/user-api-key.d.ts +16 -0
  157. package/dist/src/lib/validation.d.ts +82 -0
  158. package/dist/src/main.d.ts +4 -0
  159. package/package.json +17 -3
@@ -0,0 +1,431 @@
1
+ import { type FlowRecord, type JsonRecord } from './flow-governance.js';
2
+ import { type SdkValidationEntity } from './tidas-sdk-validation.js';
3
+ export type AutoPatchPolicy = 'disabled' | 'alias-only' | 'alias-or-unique-name';
4
+ export type TidasMode = 'auto' | 'required' | 'skip';
5
+ type PathPart = string | number;
6
+ type LangEntry = {
7
+ lang: string;
8
+ text: string;
9
+ };
10
+ type ProcessIdentity = {
11
+ id: string;
12
+ version: string;
13
+ name: string;
14
+ };
15
+ type FlowIndex = {
16
+ records: FlowRecord[];
17
+ byUuid: Record<string, FlowRecord[]>;
18
+ byUuidVersion: Record<string, FlowRecord>;
19
+ byName: Record<string, FlowRecord[]>;
20
+ };
21
+ type ScanFinding = {
22
+ process_id: string;
23
+ process_version: string;
24
+ process_name: string;
25
+ exchange_internal_id: string;
26
+ exchange_direction: unknown;
27
+ reference_flow_id: string;
28
+ reference_flow_version: string;
29
+ reference_flow_text: string;
30
+ issue_type: string;
31
+ severity: 'info' | 'warning' | 'error';
32
+ evidence: JsonRecord;
33
+ };
34
+ type RepairAction = {
35
+ process_id: string;
36
+ process_version: string;
37
+ process_name: string;
38
+ exchange_internal_id: string;
39
+ current_flow_id: string;
40
+ current_flow_version: string;
41
+ exchange_direction: unknown;
42
+ exchange_text: string;
43
+ current_issue_type?: string;
44
+ auto_patch_policy: AutoPatchPolicy;
45
+ decision: 'keep_as_is' | 'auto_patch' | 'manual_review';
46
+ reason: string;
47
+ target_flow_id?: string;
48
+ target_flow_version?: string;
49
+ target_flow_name?: string;
50
+ target_reference?: JsonRecord;
51
+ candidate_count?: number;
52
+ candidate_refs?: Array<Record<string, string>>;
53
+ };
54
+ export type ProcessPatchValidationIssue = JsonRecord & {
55
+ type: string;
56
+ severity: 'error';
57
+ };
58
+ export type ProcessPatchValidationResult = {
59
+ process_id: string;
60
+ process_version: string;
61
+ process_name: string;
62
+ ok: boolean;
63
+ issues: ProcessPatchValidationIssue[];
64
+ };
65
+ export type ProcessPatchValidationSummary = {
66
+ patched_process_count: number;
67
+ passed: number;
68
+ failed: number;
69
+ tidas_validation: boolean;
70
+ };
71
+ export type ScanStageFiles = {
72
+ out_dir: string;
73
+ emergy_excluded_processes: string;
74
+ summary: string;
75
+ findings: string;
76
+ findings_jsonl: string;
77
+ };
78
+ export type RepairStageFiles = {
79
+ out_dir: string;
80
+ plan: string;
81
+ plan_jsonl: string;
82
+ manual_review_queue: string;
83
+ summary: string;
84
+ };
85
+ export type ApplyStageFiles = RepairStageFiles & {
86
+ patched_processes: string;
87
+ patch_root: string;
88
+ };
89
+ export type ValidateStageFiles = {
90
+ out_dir: string;
91
+ report: string;
92
+ failures: string;
93
+ };
94
+ export type FlowProcessRefScanSummary = {
95
+ process_count_before_emergy_exclusion: number;
96
+ process_count: number;
97
+ emergy_excluded_process_count: number;
98
+ exchange_count: number;
99
+ issue_counts: Record<string, number>;
100
+ processes_with_issues: number;
101
+ };
102
+ export type FlowProcessFlowRepairSummary = {
103
+ auto_patch_policy: AutoPatchPolicy;
104
+ process_count: number;
105
+ repair_item_count: number;
106
+ decision_counts: Record<string, number>;
107
+ patched_process_count: number;
108
+ process_pool_sync?: JsonRecord;
109
+ };
110
+ type FlowRegenProductFiles = {
111
+ report: string;
112
+ scan: ScanStageFiles;
113
+ repair: RepairStageFiles;
114
+ apply: ApplyStageFiles | null;
115
+ validate: ValidateStageFiles | null;
116
+ };
117
+ type FlowRegenProductCounts = {
118
+ process_count_before_emergy_exclusion: number;
119
+ process_count: number;
120
+ emergy_excluded_process_count: number;
121
+ exchange_count: number;
122
+ issue_counts: Record<string, number>;
123
+ processes_with_issues: number;
124
+ repair_item_count: number;
125
+ decision_counts: Record<string, number>;
126
+ patched_process_count: number;
127
+ validation_passed_count: number | null;
128
+ validation_failed_count: number | null;
129
+ };
130
+ export type FlowRegenProductReport = {
131
+ schema_version: 1;
132
+ generated_at_utc: string;
133
+ status: 'completed_local_flow_regen_product';
134
+ mode: 'plan' | 'apply';
135
+ processes_file: string;
136
+ scope_flow_files: string[];
137
+ catalog_flow_files: string[];
138
+ alias_map_file: string | null;
139
+ exclude_emergy: boolean;
140
+ auto_patch_policy: AutoPatchPolicy;
141
+ process_pool_file: string | null;
142
+ tidas_mode: TidasMode;
143
+ out_dir: string;
144
+ counts: FlowRegenProductCounts;
145
+ validation: {
146
+ enabled: boolean;
147
+ tidas_validation: boolean;
148
+ ok: boolean | null;
149
+ };
150
+ files: FlowRegenProductFiles;
151
+ };
152
+ export type RunFlowRegenProductOptions = {
153
+ processesFile: string;
154
+ scopeFlowFiles: string[];
155
+ catalogFlowFiles?: string[];
156
+ aliasMapFile?: string | null;
157
+ outDir: string;
158
+ excludeEmergy?: boolean;
159
+ autoPatchPolicy?: AutoPatchPolicy;
160
+ apply?: boolean;
161
+ processPoolFile?: string | null;
162
+ tidasMode?: TidasMode;
163
+ };
164
+ export type RunFlowValidateProcessesOptions = {
165
+ originalProcessesFile: string;
166
+ patchedProcessesFile: string;
167
+ scopeFlowFiles: string[];
168
+ outDir: string;
169
+ tidasMode?: TidasMode;
170
+ };
171
+ export type RunFlowScanProcessFlowRefsOptions = {
172
+ processesFile: string;
173
+ scopeFlowFiles: string[];
174
+ catalogFlowFiles?: string[];
175
+ aliasMapFile?: string | null;
176
+ excludeEmergy?: boolean;
177
+ outDir: string;
178
+ };
179
+ export type RunFlowPlanProcessFlowRepairsOptions = {
180
+ processesFile: string;
181
+ scopeFlowFiles: string[];
182
+ aliasMapFile?: string | null;
183
+ scanFindingsFile?: string | null;
184
+ autoPatchPolicy?: AutoPatchPolicy;
185
+ outDir: string;
186
+ };
187
+ export type RunFlowApplyProcessFlowRepairsOptions = {
188
+ processesFile: string;
189
+ scopeFlowFiles: string[];
190
+ aliasMapFile?: string | null;
191
+ scanFindingsFile?: string | null;
192
+ autoPatchPolicy?: AutoPatchPolicy;
193
+ processPoolFile?: string | null;
194
+ outDir: string;
195
+ };
196
+ export type FlowValidateProcessesReport = {
197
+ schema_version: 1;
198
+ generated_at_utc: string;
199
+ status: 'completed_local_flow_validate_processes';
200
+ original_processes_file: string;
201
+ patched_processes_file: string;
202
+ scope_flow_files: string[];
203
+ out_dir: string;
204
+ tidas_mode: TidasMode;
205
+ summary: ProcessPatchValidationSummary;
206
+ files: ValidateStageFiles;
207
+ results: ProcessPatchValidationResult[];
208
+ };
209
+ export type FlowScanProcessFlowRefsReport = {
210
+ schema_version: 1;
211
+ generated_at_utc: string;
212
+ status: 'completed_local_flow_scan_process_flow_refs';
213
+ processes_file: string;
214
+ scope_flow_files: string[];
215
+ catalog_flow_files: string[];
216
+ alias_map_file: string | null;
217
+ exclude_emergy: boolean;
218
+ out_dir: string;
219
+ summary: FlowProcessRefScanSummary;
220
+ files: ScanStageFiles;
221
+ };
222
+ export type FlowPlanProcessFlowRepairsReport = {
223
+ schema_version: 1;
224
+ generated_at_utc: string;
225
+ status: 'completed_local_flow_plan_process_flow_repairs';
226
+ processes_file: string;
227
+ scope_flow_files: string[];
228
+ alias_map_file: string | null;
229
+ scan_findings_file: string | null;
230
+ auto_patch_policy: AutoPatchPolicy;
231
+ out_dir: string;
232
+ summary: FlowProcessFlowRepairSummary;
233
+ files: RepairStageFiles;
234
+ };
235
+ export type FlowApplyProcessFlowRepairsReport = {
236
+ schema_version: 1;
237
+ generated_at_utc: string;
238
+ status: 'completed_local_flow_apply_process_flow_repairs';
239
+ processes_file: string;
240
+ scope_flow_files: string[];
241
+ alias_map_file: string | null;
242
+ scan_findings_file: string | null;
243
+ auto_patch_policy: AutoPatchPolicy;
244
+ process_pool_file: string | null;
245
+ out_dir: string;
246
+ summary: FlowProcessFlowRepairSummary;
247
+ files: ApplyStageFiles;
248
+ };
249
+ type ProcessSdkModule = {
250
+ createProcess?: (data?: unknown, validationConfig?: {
251
+ mode?: 'strict' | 'weak' | 'ignore';
252
+ throwOnError?: boolean;
253
+ deepValidation?: boolean;
254
+ }) => SdkValidationEntity;
255
+ location?: string;
256
+ };
257
+ type FlowRegenProductDeps = {
258
+ loadSdkModule?: () => ProcessSdkModule;
259
+ now?: () => Date;
260
+ };
261
+ type ScanStageResult = {
262
+ filteredProcesses: JsonRecord[];
263
+ emergyExcludedProcesses: JsonRecord[];
264
+ findings: ScanFinding[];
265
+ summary: FlowProcessRefScanSummary;
266
+ files: ScanStageFiles;
267
+ };
268
+ type RepairStageResult = {
269
+ plan: RepairAction[];
270
+ manualQueue: RepairAction[];
271
+ summary: FlowProcessFlowRepairSummary;
272
+ files: RepairStageFiles | ApplyStageFiles;
273
+ patchedRows: JsonRecord[];
274
+ };
275
+ type ValidateStageResult = {
276
+ summary: ProcessPatchValidationSummary;
277
+ results: ProcessPatchValidationResult[];
278
+ failures: ProcessPatchValidationResult[];
279
+ files: ValidateStageFiles;
280
+ };
281
+ declare function resolveCliRepoRoot(): string;
282
+ declare function buildSdkCandidates(): string[];
283
+ declare function resolveSdkModuleFromCandidates(requireFn: NodeJS.Require, candidates: string[]): ProcessSdkModule & {
284
+ location: string;
285
+ };
286
+ declare function resolveLocalSdkModule(): ProcessSdkModule & {
287
+ location: string;
288
+ };
289
+ declare function assertInputFile(inputFile: string, requiredCode: string, missingCode: string): string;
290
+ declare function assertInputFiles(inputFiles: string[], requiredCode: string, missingCode: string): string[];
291
+ declare function assertOutDir(outDir: string): string;
292
+ declare function readJsonObjectFile(filePath: string, requiredCode: string, missingCode: string, invalidCode: string): JsonRecord;
293
+ declare function processDatasetFromRow(row: JsonRecord): JsonRecord;
294
+ declare function extractProcessIdentity(row: JsonRecord): ProcessIdentity;
295
+ declare function exchangeRecords(processRow: JsonRecord): JsonRecord[];
296
+ declare function extractProcessReferenceExchange(processRow: JsonRecord): JsonRecord | null;
297
+ declare function extractReferenceText(ref: unknown): string;
298
+ declare function extractProcessReferenceFlowRef(processRow: JsonRecord): {
299
+ flow_id: string;
300
+ flow_version: string;
301
+ flow_text: string;
302
+ exchange_internal_id: string;
303
+ };
304
+ declare function processRowKey(processRow: JsonRecord): string;
305
+ declare function versionKey(version: string): number[];
306
+ declare function compareVersionKeys(left: number[], right: number[]): number;
307
+ declare function processRowSortComparator(left: JsonRecord, right: JsonRecord): number;
308
+ declare function buildFlowIndex(rows: JsonRecord[]): FlowIndex;
309
+ declare function aliasLookup(aliasMap: JsonRecord, flowUuid: string, flowVersion: string | null): JsonRecord | null;
310
+ declare function buildLocalDatasetUri(datasetKind: string, uuidValue: string, version: string): string;
311
+ declare function preserveShortDescriptionShape(existing: unknown, target: JsonRecord): unknown;
312
+ declare function flowReferenceFromRecord(record: FlowRecord): JsonRecord;
313
+ declare function patchedFlowReference(currentRef: unknown, record: FlowRecord): JsonRecord;
314
+ declare function langEntries(value: unknown): LangEntry[];
315
+ declare function textHasEmergyKeyword(text: string): boolean;
316
+ declare function uniqueNonEmptyTexts(values: string[]): string[];
317
+ declare function flowEmergyScopeDecision(row: JsonRecord): JsonRecord;
318
+ declare function processEmergyScopeDecision(processRow: JsonRecord, flowIndex: FlowIndex | null): JsonRecord;
319
+ declare function filterEmergyNamedProcesses(rows: JsonRecord[], flowIndex: FlowIndex | null): {
320
+ keptRows: JsonRecord[];
321
+ excludedRows: JsonRecord[];
322
+ };
323
+ declare function classifyExchangeRef(processRow: JsonRecord, exchange: JsonRecord, scopeIndex: FlowIndex, catalogIndex: FlowIndex, aliasMap: JsonRecord): ScanFinding;
324
+ declare function buildFindingMap(findings: ScanFinding[]): Record<string, ScanFinding>;
325
+ declare function planExchangeRepair(exchange: JsonRecord, scopeIndex: FlowIndex, aliasMap: JsonRecord, finding: ScanFinding | null, autoPatchPolicy: AutoPatchPolicy): RepairAction;
326
+ declare function buildUnifiedJsonDiff(before: unknown, after: unknown): string;
327
+ declare function deepDiffPaths(before: unknown, after: unknown, prefix?: PathPart[]): PathPart[][];
328
+ declare function pathContainsReferenceToFlow(pathParts: PathPart[]): boolean;
329
+ declare function safeProcessKey(processId: string, version: string): string;
330
+ declare function writeRowsFile(filePath: string, rows: JsonRecord[]): string;
331
+ declare function mergeRowsByIdentity(existingRows: JsonRecord[], incomingRows: JsonRecord[]): {
332
+ mergedRows: JsonRecord[];
333
+ counts: {
334
+ inserted: number;
335
+ updated: number;
336
+ unchanged: number;
337
+ skipped_invalid: number;
338
+ };
339
+ };
340
+ declare function syncProcessPoolFile(poolFile: string, incomingRows: JsonRecord[]): JsonRecord;
341
+ declare function resolveProcessValidator(tidasMode: TidasMode, deps: FlowRegenProductDeps): {
342
+ createProcess: ProcessSdkModule['createProcess'] | null;
343
+ tidasValidation: boolean;
344
+ };
345
+ declare function formatValidationDetails(validation: unknown): string;
346
+ declare function evaluateProcessSdkValidation(payload: JsonRecord, createProcess: NonNullable<ProcessSdkModule['createProcess']>): string | null;
347
+ declare function validateProcessPatch(originalRow: JsonRecord | null, patchedRow: JsonRecord, scopeIndex: FlowIndex, createProcess: NonNullable<ProcessSdkModule['createProcess']> | null): ProcessPatchValidationResult;
348
+ declare function buildScanStageFiles(outDir: string): ScanStageFiles;
349
+ declare function buildRepairStageFiles(outDir: string): RepairStageFiles;
350
+ declare function buildApplyStageFiles(outDir: string): ApplyStageFiles;
351
+ declare function buildValidateStageFiles(outDir: string): ValidateStageFiles;
352
+ declare function runScanStage(processes: JsonRecord[], scopeIndex: FlowIndex, catalogIndex: FlowIndex, aliasMap: JsonRecord, outDir: string, excludeEmergy: boolean): ScanStageResult;
353
+ declare function runRepairStage(options: {
354
+ processes: JsonRecord[];
355
+ scopeIndex: FlowIndex;
356
+ aliasMap: JsonRecord;
357
+ scanFindings: ScanFinding[];
358
+ autoPatchPolicy: AutoPatchPolicy;
359
+ outDir: string;
360
+ apply: boolean;
361
+ processPoolFile: string | null;
362
+ }): RepairStageResult;
363
+ declare function runValidateStage(options: {
364
+ originalRows: JsonRecord[];
365
+ patchedRows: JsonRecord[];
366
+ scopeIndex: FlowIndex;
367
+ outDir: string;
368
+ tidasMode: TidasMode;
369
+ deps: FlowRegenProductDeps;
370
+ }): ValidateStageResult;
371
+ export declare function runFlowScanProcessFlowRefs(options: RunFlowScanProcessFlowRefsOptions, deps?: FlowRegenProductDeps): Promise<FlowScanProcessFlowRefsReport>;
372
+ export declare function runFlowPlanProcessFlowRepairs(options: RunFlowPlanProcessFlowRepairsOptions, deps?: FlowRegenProductDeps): Promise<FlowPlanProcessFlowRepairsReport>;
373
+ export declare function runFlowApplyProcessFlowRepairs(options: RunFlowApplyProcessFlowRepairsOptions, deps?: FlowRegenProductDeps): Promise<FlowApplyProcessFlowRepairsReport>;
374
+ declare function buildReportFiles(outDir: string, apply: boolean): FlowRegenProductFiles;
375
+ export declare function runFlowRegenProduct(options: RunFlowRegenProductOptions, deps?: FlowRegenProductDeps): Promise<FlowRegenProductReport>;
376
+ export declare function runFlowValidateProcesses(options: RunFlowValidateProcessesOptions, deps?: FlowRegenProductDeps): Promise<FlowValidateProcessesReport>;
377
+ export declare const __testInternals: {
378
+ resolveCliRepoRoot: typeof resolveCliRepoRoot;
379
+ assertInputFile: typeof assertInputFile;
380
+ assertInputFiles: typeof assertInputFiles;
381
+ assertOutDir: typeof assertOutDir;
382
+ readJsonObjectFile: typeof readJsonObjectFile;
383
+ resolveLocalSdkModule: typeof resolveLocalSdkModule;
384
+ processDatasetFromRow: typeof processDatasetFromRow;
385
+ extractProcessIdentity: typeof extractProcessIdentity;
386
+ exchangeRecords: typeof exchangeRecords;
387
+ extractProcessReferenceExchange: typeof extractProcessReferenceExchange;
388
+ extractReferenceText: typeof extractReferenceText;
389
+ extractProcessReferenceFlowRef: typeof extractProcessReferenceFlowRef;
390
+ processRowKey: typeof processRowKey;
391
+ versionKey: typeof versionKey;
392
+ compareVersionKeys: typeof compareVersionKeys;
393
+ processRowSortComparator: typeof processRowSortComparator;
394
+ buildFlowIndex: typeof buildFlowIndex;
395
+ aliasLookup: typeof aliasLookup;
396
+ buildLocalDatasetUri: typeof buildLocalDatasetUri;
397
+ preserveShortDescriptionShape: typeof preserveShortDescriptionShape;
398
+ flowReferenceFromRecord: typeof flowReferenceFromRecord;
399
+ patchedFlowReference: typeof patchedFlowReference;
400
+ langEntries: typeof langEntries;
401
+ textHasEmergyKeyword: typeof textHasEmergyKeyword;
402
+ uniqueNonEmptyTexts: typeof uniqueNonEmptyTexts;
403
+ flowEmergyScopeDecision: typeof flowEmergyScopeDecision;
404
+ processEmergyScopeDecision: typeof processEmergyScopeDecision;
405
+ filterEmergyNamedProcesses: typeof filterEmergyNamedProcesses;
406
+ classifyExchangeRef: typeof classifyExchangeRef;
407
+ buildFindingMap: typeof buildFindingMap;
408
+ planExchangeRepair: typeof planExchangeRepair;
409
+ buildUnifiedJsonDiff: typeof buildUnifiedJsonDiff;
410
+ deepDiffPaths: typeof deepDiffPaths;
411
+ pathContainsReferenceToFlow: typeof pathContainsReferenceToFlow;
412
+ safeProcessKey: typeof safeProcessKey;
413
+ writeRowsFile: typeof writeRowsFile;
414
+ mergeRowsByIdentity: typeof mergeRowsByIdentity;
415
+ syncProcessPoolFile: typeof syncProcessPoolFile;
416
+ buildSdkCandidates: typeof buildSdkCandidates;
417
+ resolveSdkModuleFromCandidates: typeof resolveSdkModuleFromCandidates;
418
+ resolveProcessValidator: typeof resolveProcessValidator;
419
+ formatValidationDetails: typeof formatValidationDetails;
420
+ evaluateProcessSdkValidation: typeof evaluateProcessSdkValidation;
421
+ validateProcessPatch: typeof validateProcessPatch;
422
+ buildScanStageFiles: typeof buildScanStageFiles;
423
+ buildRepairStageFiles: typeof buildRepairStageFiles;
424
+ buildApplyStageFiles: typeof buildApplyStageFiles;
425
+ buildValidateStageFiles: typeof buildValidateStageFiles;
426
+ runScanStage: typeof runScanStage;
427
+ runRepairStage: typeof runRepairStage;
428
+ runValidateStage: typeof runValidateStage;
429
+ buildReportFiles: typeof buildReportFiles;
430
+ };
431
+ export {};
@@ -0,0 +1,133 @@
1
+ import { type JsonRecord } from './flow-governance.js';
2
+ import { type SdkValidationEntity } from './tidas-sdk-validation.js';
3
+ type FlowValidationIssue = {
4
+ validator: 'tidas_sdk';
5
+ path: string;
6
+ message: string;
7
+ code: string;
8
+ };
9
+ type FlowRemediationRowResult = {
10
+ row: JsonRecord;
11
+ valid: boolean;
12
+ appliedFixes: string[];
13
+ finalReasons: FlowValidationIssue[];
14
+ versionBefore: string;
15
+ versionAfter: string;
16
+ };
17
+ type FlowValidationResult = {
18
+ success: true;
19
+ } | {
20
+ success: false;
21
+ issues: FlowValidationIssue[];
22
+ };
23
+ type FlowSdkModule = {
24
+ createFlow?: (data?: unknown, validationConfig?: {
25
+ mode?: 'strict' | 'weak' | 'ignore';
26
+ throwOnError?: boolean;
27
+ deepValidation?: boolean;
28
+ }) => SdkValidationEntity;
29
+ };
30
+ type FlowRemediationFiles = {
31
+ allRemediated: string;
32
+ readyForMcp: string;
33
+ residualManualQueue: string;
34
+ audit: string;
35
+ report: string;
36
+ prompt: string;
37
+ };
38
+ export type FlowRemediationReport = {
39
+ schema_version: 1;
40
+ generated_at_utc: string;
41
+ status: 'completed_local_flow_remediation';
42
+ input_file: string;
43
+ out_dir: string;
44
+ counts: {
45
+ input_rows: number;
46
+ state_code_0_rows: number;
47
+ state_code_100_rows: number;
48
+ remediated_rows: number;
49
+ ready_for_mcp_rows: number;
50
+ residual_manual_rows: number;
51
+ };
52
+ applied_fix_counts: Record<string, number>;
53
+ residual_manual_ids: string[];
54
+ validation_backend: 'tidas_sdk';
55
+ files: {
56
+ all_remediated: string;
57
+ ready_for_mcp: string;
58
+ residual_manual_queue: string;
59
+ audit: string;
60
+ prompt: string;
61
+ report: string;
62
+ };
63
+ };
64
+ export type RunFlowRemediateOptions = {
65
+ inputFile: string;
66
+ outDir: string;
67
+ };
68
+ type FlowRemediationDeps = {
69
+ loadSdkModule?: () => FlowSdkModule & {
70
+ location?: string;
71
+ };
72
+ now?: () => Date;
73
+ };
74
+ type FlowPropertyDescriptor = {
75
+ uuid: string;
76
+ name: string;
77
+ version: string;
78
+ };
79
+ declare function resolve_sdk_module_from_candidates(requireFn: NodeJS.Require, candidates: string[]): FlowSdkModule & {
80
+ location: string;
81
+ };
82
+ declare function assert_input_file(inputFile: string): string;
83
+ declare function assert_out_dir(outDir: string): string;
84
+ declare function build_output_files(outDir: string): FlowRemediationFiles;
85
+ declare function build_local_dataset_uri(datasetKind: string, uuidValue: string, version: string): string;
86
+ declare function build_dataset_format_reference(): JsonRecord;
87
+ declare function normalize_multilang_entries(value: unknown): JsonRecord[] | null;
88
+ declare function normalize_multilang_field(container: JsonRecord, key: string, fixes: string[]): void;
89
+ declare function normalize_name_block(dataSetInfo: JsonRecord, fixes: string[]): void;
90
+ declare function bump_ilcd_version(version: string): string;
91
+ declare function version_from_uri(uri: string): string;
92
+ declare function normalize_reference_block(ref: unknown, defaultType: string, shortDescriptionFallback: string): JsonRecord | null;
93
+ declare function canonical_contact_reference(): JsonRecord;
94
+ declare function canonical_compliance_block(): JsonRecord;
95
+ declare function infer_flow_property_descriptor_from_hint(value: unknown): FlowPropertyDescriptor | null;
96
+ declare function build_flow_property_item(descriptor: FlowPropertyDescriptor, internalId: string, meanValue: string): JsonRecord;
97
+ declare function normalize_flow_properties(dataset: JsonRecord, fixes: string[]): {
98
+ items: JsonRecord[];
99
+ unresolved: FlowValidationIssue[];
100
+ };
101
+ declare function normalize_quantitative_reference(dataset: JsonRecord, normalizedFlowProperties: JsonRecord[], fixes: string[], unresolved: FlowValidationIssue[]): void;
102
+ declare function update_permanent_dataset_uri(uriValue: unknown, targetVersion: string): unknown;
103
+ declare function parse_validation_error(error: unknown): FlowValidationIssue[];
104
+ declare function validate_flow_payload(payload: JsonRecord, deps: FlowRemediationDeps): FlowValidationResult;
105
+ declare function remediate_row(row: JsonRecord, deps: FlowRemediationDeps): FlowRemediationRowResult;
106
+ declare function build_prompt(manualRows: JsonRecord[], manualFile: string, promptFile: string): string;
107
+ export declare function runFlowRemediate(options: RunFlowRemediateOptions, deps?: FlowRemediationDeps): Promise<FlowRemediationReport>;
108
+ export declare const __testInternals: {
109
+ assert_input_file: typeof assert_input_file;
110
+ assert_out_dir: typeof assert_out_dir;
111
+ build_dataset_format_reference: typeof build_dataset_format_reference;
112
+ build_flow_property_item: typeof build_flow_property_item;
113
+ build_output_files: typeof build_output_files;
114
+ build_prompt: typeof build_prompt;
115
+ build_local_dataset_uri: typeof build_local_dataset_uri;
116
+ bump_ilcd_version: typeof bump_ilcd_version;
117
+ canonical_compliance_block: typeof canonical_compliance_block;
118
+ canonical_contact_reference: typeof canonical_contact_reference;
119
+ infer_flow_property_descriptor_from_hint: typeof infer_flow_property_descriptor_from_hint;
120
+ normalize_flow_properties: typeof normalize_flow_properties;
121
+ normalize_multilang_entries: typeof normalize_multilang_entries;
122
+ normalize_multilang_field: typeof normalize_multilang_field;
123
+ normalize_name_block: typeof normalize_name_block;
124
+ normalize_quantitative_reference: typeof normalize_quantitative_reference;
125
+ normalize_reference_block: typeof normalize_reference_block;
126
+ parse_validation_error: typeof parse_validation_error;
127
+ remediate_row: typeof remediate_row;
128
+ resolve_sdk_module_from_candidates: typeof resolve_sdk_module_from_candidates;
129
+ update_permanent_dataset_uri: typeof update_permanent_dataset_uri;
130
+ validate_flow_payload: typeof validate_flow_payload;
131
+ version_from_uri: typeof version_from_uri;
132
+ };
133
+ export {};
@@ -0,0 +1,25 @@
1
+ export type ResponseLike = {
2
+ ok: boolean;
3
+ status: number;
4
+ body?: ReadableStream<Uint8Array> | null;
5
+ headers: {
6
+ get(name: string): string | null;
7
+ };
8
+ text(): Promise<string>;
9
+ arrayBuffer?(): Promise<ArrayBuffer>;
10
+ };
11
+ export type FetchLike = (input: string, init?: RequestInit) => Promise<ResponseLike>;
12
+ export declare function requireRemoteOkPayload(payload: unknown, url: string): unknown;
13
+ export declare function postJson(options: {
14
+ url: string;
15
+ headers: Record<string, string>;
16
+ body: unknown;
17
+ timeoutMs: number;
18
+ fetchImpl: FetchLike;
19
+ }): Promise<unknown>;
20
+ export declare function getJson(options: {
21
+ url: string;
22
+ headers: Record<string, string>;
23
+ timeoutMs: number;
24
+ fetchImpl: FetchLike;
25
+ }): Promise<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","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AM,EAAE,KAAK;QACb,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,MAAM;KACP,CAAC,CAAC;IAEH,OAAO,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import { CliError } from './errors.js';\n\ntype JsonObject = Record<string, unknown>;\n\nexport type ResponseLike = {\n ok: boolean;\n status: number;\n headers: {\n get(name: string): string | null;\n };\n text(): Promise<string>;\n arrayBuffer?(): Promise<ArrayBuffer>;\n};\n\nexport type FetchLike = (input: string, init?: RequestInit) => Promise<ResponseLike>;\n\nfunction isRecord(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nasync function parseResponse(response: ResponseLike, url: string): Promise<unknown> {\n const rawText = await response.text();\n const contentType = response.headers.get('content-type') ?? '';\n\n if (!response.ok) {\n throw new CliError(`HTTP ${response.status} returned from ${url}`, {\n code: 'REMOTE_REQUEST_FAILED',\n exitCode: 1,\n details: rawText,\n });\n }\n\n if (contentType.includes('application/json')) {\n try {\n return JSON.parse(rawText);\n } catch (error) {\n throw new CliError(`Remote response was not valid JSON for ${url}`, {\n code: 'REMOTE_INVALID_JSON',\n exitCode: 1,\n details: String(error),\n });\n }\n }\n\n return rawText;\n}\n\nexport function requireRemoteOkPayload(payload: unknown, url: string): unknown {\n if (!isRecord(payload) || payload.ok !== false) {\n return payload;\n }\n\n const code =\n typeof payload.code === 'string' && payload.code.trim()\n ? payload.code.trim()\n : 'REMOTE_APPLICATION_ERROR';\n const message =\n typeof payload.message === 'string' && payload.message.trim()\n ? payload.message.trim()\n : `Remote application response returned ok:false for ${url}`;\n\n throw new CliError(message, {\n code,\n exitCode: 1,\n details: payload,\n });\n}\n\nexport async function postJson(options: {\n url: string;\n headers: Record<string, string>;\n body: unknown;\n timeoutMs: number;\n fetchImpl: FetchLike;\n}): Promise<unknown> {\n const signal = AbortSignal.timeout(options.timeoutMs);\n const response = await options.fetchImpl(options.url, {\n method: 'POST',\n headers: options.headers,\n body: JSON.stringify(options.body),\n signal,\n });\n\n return parseResponse(response, options.url);\n}\n\nexport async function getJson(options: {\n url: string;\n headers: Record<string, string>;\n timeoutMs: number;\n fetchImpl: FetchLike;\n}): Promise<unknown> {\n const signal = AbortSignal.timeout(options.timeoutMs);\n const response = await options.fetchImpl(options.url, {\n method: 'GET',\n headers: options.headers,\n signal,\n });\n\n return parseResponse(response, options.url);\n}\n"]}
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/lib/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAiBvC,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,QAAsB,EAAE,GAAW;IAC9D,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACtC,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAE/D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,QAAQ,CAAC,QAAQ,QAAQ,CAAC,MAAM,kBAAkB,GAAG,EAAE,EAAE;YACjE,IAAI,EAAE,uBAAuB;YAC7B,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;IACL,CAAC;IAED,IAAI,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC7C,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,QAAQ,CAAC,0CAA0C,GAAG,EAAE,E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C,CAAC;IAEH,OAAO,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAK7B;IACC,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE;QACpD,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,MAAM;KACP,CAAC,CAAC;IAEH,OAAO,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import { CliError } from './errors.js';\n\ntype JsonObject = Record<string, unknown>;\n\nexport type ResponseLike = {\n ok: boolean;\n status: number;\n body?: ReadableStream<Uint8Array> | null;\n headers: {\n get(name: string): string | null;\n };\n text(): Promise<string>;\n arrayBuffer?(): Promise<ArrayBuffer>;\n};\n\nexport type FetchLike = (input: string, init?: RequestInit) => Promise<ResponseLike>;\n\nfunction isRecord(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nasync function parseResponse(response: ResponseLike, url: string): Promise<unknown> {\n const rawText = await response.text();\n const contentType = response.headers.get('content-type') ?? '';\n\n if (!response.ok) {\n throw new CliError(`HTTP ${response.status} returned from ${url}`, {\n code: 'REMOTE_REQUEST_FAILED',\n exitCode: 1,\n details: rawText,\n });\n }\n\n if (contentType.includes('application/json')) {\n try {\n return JSON.parse(rawText);\n } catch (error) {\n throw new CliError(`Remote response was not valid JSON for ${url}`, {\n code: 'REMOTE_INVALID_JSON',\n exitCode: 1,\n details: String(error),\n });\n }\n }\n\n return rawText;\n}\n\nexport function requireRemoteOkPayload(payload: unknown, url: string): unknown {\n if (!isRecord(payload) || payload.ok !== false) {\n return payload;\n }\n\n const code =\n typeof payload.code === 'string' && payload.code.trim()\n ? payload.code.trim()\n : 'REMOTE_APPLICATION_ERROR';\n const message =\n typeof payload.message === 'string' && payload.message.trim()\n ? payload.message.trim()\n : `Remote application response returned ok:false for ${url}`;\n\n throw new CliError(message, {\n code,\n exitCode: 1,\n details: payload,\n });\n}\n\nexport async function postJson(options: {\n url: string;\n headers: Record<string, string>;\n body: unknown;\n timeoutMs: number;\n fetchImpl: FetchLike;\n}): Promise<unknown> {\n const signal = AbortSignal.timeout(options.timeoutMs);\n const response = await options.fetchImpl(options.url, {\n method: 'POST',\n headers: options.headers,\n body: JSON.stringify(options.body),\n signal,\n });\n\n return parseResponse(response, options.url);\n}\n\nexport async function getJson(options: {\n url: string;\n headers: Record<string, string>;\n timeoutMs: number;\n fetchImpl: FetchLike;\n}): Promise<unknown> {\n const signal = AbortSignal.timeout(options.timeoutMs);\n const response = await options.fetchImpl(options.url, {\n method: 'GET',\n headers: options.headers,\n signal,\n });\n\n return parseResponse(response, options.url);\n}\n"]}