@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,219 @@
1
+ export type DatasetCurationQueueEntityType = 'support' | 'flow' | 'process';
2
+ export type RunDatasetCurationQueueBuildOptions = {
3
+ processesPath: string;
4
+ flowsPath?: string;
5
+ supportPaths?: string[];
6
+ externalFlowRefPaths?: string[];
7
+ outDir: string;
8
+ excludeProcessIds?: string[];
9
+ processLimit?: number;
10
+ };
11
+ export type RunDatasetCurationQueueNextOptions = {
12
+ queueDir: string;
13
+ entityType?: DatasetCurationQueueEntityType;
14
+ taskId?: string;
15
+ };
16
+ export type RunDatasetCurationQueueVerifyOptions = {
17
+ queueDir: string;
18
+ entityType?: DatasetCurationQueueEntityType;
19
+ taskId?: string;
20
+ };
21
+ export type DatasetCurationQueueTask = {
22
+ schema_version: 1;
23
+ entity_type: DatasetCurationQueueEntityType;
24
+ task_id: string;
25
+ entity_id: string;
26
+ version: string;
27
+ lock_key: string;
28
+ depends_on: string[];
29
+ input_rows_file: string;
30
+ work_dir: string;
31
+ checkpoint_file: string;
32
+ run_plan_file: string;
33
+ closure_file: string;
34
+ };
35
+ type DatasetCurationQueueBlocker = {
36
+ schema_version: 1;
37
+ code: string;
38
+ severity: 'blocker';
39
+ entity_type: DatasetCurationQueueEntityType;
40
+ entity_id: string | null;
41
+ version: string | null;
42
+ message: string;
43
+ details?: unknown;
44
+ };
45
+ export type DatasetCurationQueueBuildReport = {
46
+ schema_version: 1;
47
+ generated_at_utc: string;
48
+ status: 'ready' | 'blocked';
49
+ out_dir: string;
50
+ inputs: {
51
+ processes: string;
52
+ flows: string | null;
53
+ support: string[];
54
+ external_flow_refs: string[];
55
+ };
56
+ counts: {
57
+ support_rows: number;
58
+ flow_rows: number;
59
+ process_rows: number;
60
+ external_flow_refs: number;
61
+ tasks: number;
62
+ blockers: number;
63
+ };
64
+ hashes: {
65
+ inputs: Record<string, string>;
66
+ task_order: string;
67
+ };
68
+ files: {
69
+ manifest: string;
70
+ tasks: string;
71
+ locks: string;
72
+ blockers: string;
73
+ };
74
+ tasks: DatasetCurationQueueTask[];
75
+ blockers: DatasetCurationQueueBlocker[];
76
+ };
77
+ export type DatasetCurationQueueTaskRuntimeStatus = 'complete' | 'pending' | 'waiting_dependencies' | 'blocked';
78
+ export type DatasetCurationQueueTaskState = {
79
+ task_id: string;
80
+ entity_type: DatasetCurationQueueEntityType;
81
+ entity_id: string;
82
+ version: string;
83
+ status: DatasetCurationQueueTaskRuntimeStatus;
84
+ checkpoint_status: string | null;
85
+ checkpoint_file: string;
86
+ depends_on: string[];
87
+ incomplete_dependencies: string[];
88
+ reason: string | null;
89
+ };
90
+ export type DatasetCurationQueueNextReport = {
91
+ schema_version: 1;
92
+ generated_at_utc: string;
93
+ status: 'ready' | 'complete' | 'blocked';
94
+ queue_dir: string;
95
+ scope: {
96
+ entity_type: DatasetCurationQueueEntityType | null;
97
+ task_id: string | null;
98
+ };
99
+ counts: {
100
+ total: number;
101
+ complete: number;
102
+ pending: number;
103
+ waiting_dependencies: number;
104
+ blocked: number;
105
+ runnable: number;
106
+ };
107
+ next_task: (DatasetCurationQueueTask & {
108
+ action: {
109
+ kind: 'entity_curation_task';
110
+ input_artifact: string;
111
+ output_artifacts: string[];
112
+ };
113
+ }) | null;
114
+ task_states: DatasetCurationQueueTaskState[];
115
+ blockers: DatasetCurationQueueBlocker[];
116
+ };
117
+ export type DatasetCurationQueueVerifyReport = {
118
+ schema_version: 1;
119
+ generated_at_utc: string;
120
+ status: 'passed' | 'blocked';
121
+ queue_dir: string;
122
+ scope: {
123
+ entity_type: DatasetCurationQueueEntityType | null;
124
+ task_id: string | null;
125
+ };
126
+ counts: {
127
+ total: number;
128
+ complete: number;
129
+ pending: number;
130
+ waiting_dependencies: number;
131
+ blocked: number;
132
+ };
133
+ task_states: DatasetCurationQueueTaskState[];
134
+ blockers: DatasetCurationQueueBlocker[];
135
+ };
136
+ type FlowRef = {
137
+ id: string;
138
+ version: string | null;
139
+ path: string;
140
+ };
141
+ type DeferredFlowRef = FlowRef & {
142
+ actionItemCode: string | null;
143
+ reason: string | null;
144
+ };
145
+ export declare function runDatasetCurationQueueBuild(options: RunDatasetCurationQueueBuildOptions): Promise<DatasetCurationQueueBuildReport>;
146
+ export declare function runDatasetCurationQueueNext(options: RunDatasetCurationQueueNextOptions): Promise<DatasetCurationQueueNextReport>;
147
+ export declare function runDatasetCurationQueueVerify(options: RunDatasetCurationQueueVerifyOptions): Promise<DatasetCurationQueueVerifyReport>;
148
+ declare function readQueueRuntime(queueDirInput: string): {
149
+ queueDir: string;
150
+ tasks: DatasetCurationQueueTask[];
151
+ blockers: DatasetCurationQueueBlocker[];
152
+ };
153
+ declare function normalizeQueueScope(options: {
154
+ entityType?: DatasetCurationQueueEntityType;
155
+ taskId?: string;
156
+ }): {
157
+ entity_type: DatasetCurationQueueEntityType | null;
158
+ task_id: string | null;
159
+ };
160
+ declare function buildTaskStates(tasks: DatasetCurationQueueTask[]): DatasetCurationQueueTaskState[];
161
+ declare function taskRuntimeStatus(checkpointStatus: string | null, incompleteDependencies: string[]): DatasetCurationQueueTaskRuntimeStatus;
162
+ declare function readCheckpointStatus(checkpointFile: string): string | null;
163
+ declare function taskMatchesScope(task: Pick<DatasetCurationQueueTask, 'entity_type' | 'task_id'>, scope: {
164
+ entity_type: DatasetCurationQueueEntityType | null;
165
+ task_id: string | null;
166
+ }): boolean;
167
+ declare function countTaskStates(taskStates: DatasetCurationQueueTaskState[]): {
168
+ total: number;
169
+ complete: number;
170
+ pending: number;
171
+ waiting_dependencies: number;
172
+ blocked: number;
173
+ };
174
+ declare function withQueueAction(task: DatasetCurationQueueTask): DatasetCurationQueueTask & {
175
+ action: {
176
+ kind: 'entity_curation_task';
177
+ input_artifact: string;
178
+ output_artifacts: string[];
179
+ };
180
+ };
181
+ declare function readJsonlFile(inputPath: string): unknown[];
182
+ declare function parseQueueTask(value: unknown, inputPath: string, index: number): DatasetCurationQueueTask;
183
+ declare function parseQueueBlocker(value: unknown, inputPath: string, index: number): DatasetCurationQueueBlocker;
184
+ declare function extractDeferredProcessFlowRefs(payload: unknown): DeferredFlowRef[];
185
+ declare function normalizeReferencePath(value: string): string;
186
+ declare function extractProcessFlowRefs(payload: unknown): FlowRef[];
187
+ declare function normalizeProcessLimit(value: number | undefined): number | null;
188
+ declare function requirePath(value: string | undefined, flag: string): string;
189
+ declare function requireExistingPath(value: string | undefined, flag: string): string;
190
+ declare function entityDirPlural(entityType: DatasetCurationQueueEntityType): string;
191
+ declare function entityDirName(id: string, version: string): string;
192
+ declare function taskIdFor(entityType: DatasetCurationQueueEntityType, id: string, version: string): string;
193
+ declare function sanitizePathToken(value: string): string;
194
+ declare function jsonLines(rows: unknown[]): string;
195
+ export declare const __testInternals: {
196
+ buildTaskStates: typeof buildTaskStates;
197
+ countTaskStates: typeof countTaskStates;
198
+ entityDirName: typeof entityDirName;
199
+ entityDirPlural: typeof entityDirPlural;
200
+ extractDeferredProcessFlowRefs: typeof extractDeferredProcessFlowRefs;
201
+ extractProcessFlowRefs: typeof extractProcessFlowRefs;
202
+ jsonLines: typeof jsonLines;
203
+ normalizeReferencePath: typeof normalizeReferencePath;
204
+ normalizeProcessLimit: typeof normalizeProcessLimit;
205
+ normalizeQueueScope: typeof normalizeQueueScope;
206
+ parseQueueBlocker: typeof parseQueueBlocker;
207
+ parseQueueTask: typeof parseQueueTask;
208
+ readCheckpointStatus: typeof readCheckpointStatus;
209
+ readJsonlFile: typeof readJsonlFile;
210
+ readQueueRuntime: typeof readQueueRuntime;
211
+ requireExistingPath: typeof requireExistingPath;
212
+ requirePath: typeof requirePath;
213
+ sanitizePathToken: typeof sanitizePathToken;
214
+ taskIdFor: typeof taskIdFor;
215
+ taskMatchesScope: typeof taskMatchesScope;
216
+ taskRuntimeStatus: typeof taskRuntimeStatus;
217
+ withQueueAction: typeof withQueueAction;
218
+ };
219
+ export {};
@@ -0,0 +1,134 @@
1
+ import type { FetchLike } from './http.js';
2
+ export type EvidenceSearchMode = 'plan' | 'run';
3
+ export type EvidenceSearchProfile = 'shallow' | 'balanced' | 'deep';
4
+ export type EvidenceSearchStatus = 'planned' | 'completed_with_evidence' | 'completed_with_partial_evidence' | 'completed_no_sufficient_evidence';
5
+ export type EvidenceSearchBudget = {
6
+ max_queries: number;
7
+ max_results_per_query: number;
8
+ max_provider_calls: number;
9
+ };
10
+ export type EvidenceSearchQuery = {
11
+ query_id: string;
12
+ text: string;
13
+ purpose: string;
14
+ source_tier: string;
15
+ priority: number;
16
+ expected_terms: string[];
17
+ };
18
+ export type EvidenceSearchResult = {
19
+ query_id: string | null;
20
+ query: string | null;
21
+ provider: string;
22
+ rank: number;
23
+ title: string;
24
+ url: string;
25
+ snippet: string | null;
26
+ published_at: string | null;
27
+ source_domain: string | null;
28
+ source_tier: string;
29
+ matched_terms: string[];
30
+ score: number;
31
+ };
32
+ export type EvidenceSearchDeclaration = {
33
+ schema_version: 1;
34
+ generated_at_utc: string;
35
+ question: string;
36
+ declaration_type: 'no_sufficient_evidence' | 'partial_temporal_evidence';
37
+ statement: string;
38
+ search_scope: {
39
+ query_count: number;
40
+ provider_count: number;
41
+ normalized_result_count: number;
42
+ authoritative_result_count: number;
43
+ required_complete_year: boolean;
44
+ requested_year: number | null;
45
+ temporal_coverage_status: string;
46
+ };
47
+ limits: string[];
48
+ };
49
+ export type EvidenceSearchReport = {
50
+ schema_version: 1;
51
+ generated_at_utc: string;
52
+ mode: EvidenceSearchMode;
53
+ status: EvidenceSearchStatus;
54
+ question: string;
55
+ field: {
56
+ dataset_type: string | null;
57
+ field_path: string | null;
58
+ };
59
+ profile: EvidenceSearchProfile;
60
+ budget: EvidenceSearchBudget;
61
+ plan: {
62
+ query_count: number;
63
+ queries: EvidenceSearchQuery[];
64
+ };
65
+ run: {
66
+ provider_count: number;
67
+ provider_call_count: number;
68
+ normalized_result_count: number;
69
+ authoritative_result_count: number;
70
+ high_confidence_result_count: number;
71
+ stop_reason: string;
72
+ };
73
+ evidence_quality: {
74
+ sufficient: boolean;
75
+ temporal_coverage_status: string;
76
+ requested_year: number | null;
77
+ required_complete_year: boolean;
78
+ };
79
+ files: {
80
+ plan: string | null;
81
+ results: string | null;
82
+ report: string | null;
83
+ declaration: string | null;
84
+ };
85
+ };
86
+ export type RunDatasetEvidenceSearchOptions = {
87
+ mode: EvidenceSearchMode;
88
+ query?: string | null;
89
+ inputPath?: string | null;
90
+ resultsPath?: string | null;
91
+ providerUrl?: string | null;
92
+ providerKey?: string | null;
93
+ profile?: string | null;
94
+ outDir?: string | null;
95
+ maxQueries?: number | null;
96
+ maxResultsPerQuery?: number | null;
97
+ timeoutMs?: number | null;
98
+ rawInput?: unknown;
99
+ rawResults?: unknown;
100
+ now?: Date;
101
+ fetchImpl?: FetchLike;
102
+ };
103
+ type EvidenceSearchRequest = {
104
+ question: string;
105
+ field: {
106
+ dataset_type: string | null;
107
+ field_path: string | null;
108
+ };
109
+ profile: EvidenceSearchProfile;
110
+ budget: EvidenceSearchBudget;
111
+ preferred_domains: string[];
112
+ required_terms: string[];
113
+ required_complete_year: boolean;
114
+ requested_year: number | null;
115
+ };
116
+ declare function classifySourceTier(domain: string | null, preferredDomains: string[]): string;
117
+ declare function buildSearchPlan(request: EvidenceSearchRequest): EvidenceSearchQuery[];
118
+ declare function normalizeRequest(options: RunDatasetEvidenceSearchOptions): EvidenceSearchRequest;
119
+ declare function normalizeResults(options: {
120
+ rawResults: unknown;
121
+ terms: string[];
122
+ preferredDomains: string[];
123
+ maxResultsPerQuery: number;
124
+ }): EvidenceSearchResult[];
125
+ declare function temporalCoverageStatus(request: EvidenceSearchRequest, now: Date): string;
126
+ export declare function runDatasetEvidenceSearch(options: RunDatasetEvidenceSearchOptions): Promise<EvidenceSearchReport>;
127
+ export declare const __testInternals: {
128
+ buildSearchPlan: typeof buildSearchPlan;
129
+ classifySourceTier: typeof classifySourceTier;
130
+ normalizeResults: typeof normalizeResults;
131
+ normalizeRequest: typeof normalizeRequest;
132
+ temporalCoverageStatus: typeof temporalCoverageStatus;
133
+ };
134
+ export {};
@@ -0,0 +1,136 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ declare const OPERATION_REPORT_SCHEMA = "tidas.operation-report.v1";
3
+ declare const INVOCATION_CONTEXT_SCHEMA = "tidas.invocation-context.v1";
4
+ declare const IMPORT_REPORT_SCHEMA = "tidas.import-execution-report.v1";
5
+ declare const EXIT_CODES: {
6
+ readonly success: 0;
7
+ readonly 'data-issues': 2;
8
+ readonly usage: 64;
9
+ readonly unavailable: 69;
10
+ readonly internal: 70;
11
+ readonly io: 74;
12
+ readonly cancelled: 130;
13
+ };
14
+ declare const OPERATION_STATUSES: readonly ['succeeded', 'completed-with-issues', 'failed', 'cancelled'];
15
+ declare const COMPLETENESS_VALUES: readonly ['complete', 'partial', 'not-started'];
16
+ declare const SOURCE_FORMATS: readonly ['ecospold1', 'ecospold2', 'simapro-csv', 'openlca-jsonld', 'openlca-process-xlsx', 'ilcd'];
17
+ type TidasExitClass = keyof typeof EXIT_CODES;
18
+ type TidasOperationStatus = (typeof OPERATION_STATUSES)[number];
19
+ type TidasCompleteness = (typeof COMPLETENESS_VALUES)[number];
20
+ export type DatasetImportLcaTarget = 'tidas' | 'ilcd' | 'both';
21
+ export type DatasetImportLcaSourceFormat = (typeof SOURCE_FORMATS)[number];
22
+ type TidasOperationReport = {
23
+ schema_version: typeof OPERATION_REPORT_SCHEMA;
24
+ command: 'version' | 'import';
25
+ status: TidasOperationStatus;
26
+ exit_class: TidasExitClass;
27
+ completeness: TidasCompleteness;
28
+ invocation: {
29
+ schema_version: typeof INVOCATION_CONTEXT_SCHEMA;
30
+ input_policy: 'explicit-path-or-dash';
31
+ report_destination: 'stdout' | 'file';
32
+ diagnostic_destination: 'stderr';
33
+ [key: string]: unknown;
34
+ };
35
+ summary: Record<string, unknown>;
36
+ diagnostics: unknown[];
37
+ artifacts: unknown[];
38
+ next_actions: unknown[];
39
+ };
40
+ export type DatasetImportLcaReport = {
41
+ schema_version: 'tiangong-lca.dataset-import-lca-report.v2';
42
+ status: TidasOperationStatus;
43
+ exit_class: TidasExitClass;
44
+ exit_code: number;
45
+ generated_at_utc: string;
46
+ input_path: string;
47
+ output_dir: string;
48
+ from_format: DatasetImportLcaSourceFormat | 'auto';
49
+ target: DatasetImportLcaTarget;
50
+ tidas: {
51
+ executable: string;
52
+ version: string;
53
+ operation_report_schema: typeof OPERATION_REPORT_SCHEMA;
54
+ import_report_schema: typeof IMPORT_REPORT_SCHEMA;
55
+ };
56
+ command: {
57
+ args: string[];
58
+ cwd: string;
59
+ stderr: string;
60
+ };
61
+ operation_report: TidasOperationReport;
62
+ files: {
63
+ report: string | null;
64
+ native_import_report: string;
65
+ issues: string;
66
+ tidas_dir: string | null;
67
+ ilcd_dir: string | null;
68
+ mapping_csv: string | null;
69
+ process_bundles_dir: string | null;
70
+ };
71
+ };
72
+ export type TidasProcessResult = {
73
+ status: number | null;
74
+ signal: NodeJS.Signals | null;
75
+ stdout: string;
76
+ stderr: string;
77
+ error?: Error | undefined;
78
+ };
79
+ export type RunDatasetImportLcaConvertOptions = {
80
+ inputPath: string;
81
+ outputDir: string;
82
+ fromFormat?: string | undefined;
83
+ target?: string | undefined;
84
+ reportPath?: string | undefined;
85
+ writeMapping?: boolean | undefined;
86
+ processBundles?: boolean | undefined;
87
+ failOnWarning?: boolean | undefined;
88
+ maxEntryMib?: number | undefined;
89
+ memoryBudgetMib?: number | undefined;
90
+ queueCapacity?: number | undefined;
91
+ tidasBin?: string | undefined;
92
+ tidasConfig?: string | undefined;
93
+ env?: NodeJS.ProcessEnv | undefined;
94
+ cwd?: string | undefined;
95
+ platform?: NodeJS.Platform | undefined;
96
+ arch?: string | undefined;
97
+ now?: Date | undefined;
98
+ spawnImpl?: typeof spawnSync | undefined;
99
+ };
100
+ export declare function runDatasetImportLcaConvert(options: RunDatasetImportLcaConvertOptions): Promise<DatasetImportLcaReport>;
101
+ declare function buildImportArgs(options: {
102
+ inputPath: string;
103
+ outputDir: string;
104
+ fromFormat: DatasetImportLcaSourceFormat | 'auto';
105
+ target: DatasetImportLcaTarget;
106
+ reportPath: string | null;
107
+ configPath: string | null;
108
+ writeMapping: boolean;
109
+ processBundles: boolean;
110
+ failOnWarning: boolean;
111
+ maxEntryMib: number | undefined;
112
+ memoryBudgetMib: number | undefined;
113
+ queueCapacity: number | undefined;
114
+ }): string[];
115
+ declare function readProcessReport(run: TidasProcessResult, reportPath: string | null): string;
116
+ declare function parseOperationReport(text: string, command: 'version' | 'import'): TidasOperationReport;
117
+ declare function readCompatibleVersion(report: TidasOperationReport): string;
118
+ declare function assertImportContract(report: TidasOperationReport): void;
119
+ declare function normalizeSourceFormat(value: string | undefined): DatasetImportLcaSourceFormat | 'auto';
120
+ declare function normalizeTarget(value: string | undefined): DatasetImportLcaTarget;
121
+ declare function resolveTidasBinary(explicitValue: string | undefined, env: NodeJS.ProcessEnv): string;
122
+ declare function assertSupportedPlatform(platform: NodeJS.Platform, arch: string): void;
123
+ declare function requirePositiveInteger(flag: string, value: number | undefined): void;
124
+ export declare const __testInternals: {
125
+ assertImportContract: typeof assertImportContract;
126
+ assertSupportedPlatform: typeof assertSupportedPlatform;
127
+ buildImportArgs: typeof buildImportArgs;
128
+ normalizeSourceFormat: typeof normalizeSourceFormat;
129
+ normalizeTarget: typeof normalizeTarget;
130
+ parseOperationReport: typeof parseOperationReport;
131
+ readCompatibleVersion: typeof readCompatibleVersion;
132
+ readProcessReport: typeof readProcessReport;
133
+ requirePositiveInteger: typeof requirePositiveInteger;
134
+ resolveTidasBinary: typeof resolveTidasBinary;
135
+ };
136
+ export {};
@@ -0,0 +1,23 @@
1
+ export type JsonObject = Record<string, unknown>;
2
+ export type DatasetKind = 'contact' | 'flow' | 'flowproperty' | 'lifecyclemodel' | 'process' | 'source' | 'unitgroup';
3
+ export type DatasetRowInput = {
4
+ index: number;
5
+ row: JsonObject;
6
+ payload: JsonObject;
7
+ kind: DatasetKind | null;
8
+ id: string | null;
9
+ version: string | null;
10
+ };
11
+ export declare function isRecord(value: unknown): value is JsonObject;
12
+ export declare function cloneJson<T>(value: T): T;
13
+ export declare function trimToken(value: unknown): string | null;
14
+ export declare function firstNonEmpty(...values: unknown[]): string | null;
15
+ export declare function readDatasetRowsInput(inputPath: string, rawInput?: unknown): JsonObject[];
16
+ export declare function datasetRoot(payload: JsonObject, kind: DatasetKind): JsonObject;
17
+ export declare function detectDatasetKind(value: JsonObject): DatasetKind | null;
18
+ export declare function unwrapDatasetPayload(row: JsonObject): JsonObject;
19
+ export declare function datasetIdentity(row: JsonObject, payload: JsonObject, kind: DatasetKind | null): {
20
+ id: string | null;
21
+ version: string | null;
22
+ };
23
+ export declare function materializeDatasetRows(inputPath: string, rawInput?: unknown): DatasetRowInput[];
@@ -0,0 +1,12 @@
1
+ import { type DatasetMaintenanceAliasBatchPlan, type DatasetMaintenancePlan, type DatasetMaintenancePlanAction, type JsonObject } from './dataset-maintenance-contract.js';
2
+ export declare function loadMaintenanceDesiredPayload(planDir: string, action: DatasetMaintenancePlanAction): JsonObject;
3
+ export declare function orderedAliasBatches(plan: DatasetMaintenancePlan): DatasetMaintenanceAliasBatchPlan[];
4
+ export declare function buildAliasBatchRequest(options: {
5
+ plan: DatasetMaintenancePlan;
6
+ batch: DatasetMaintenanceAliasBatchPlan;
7
+ planDir: string;
8
+ }): JsonObject;
9
+ export declare function buildAliasPlanRequest(options: {
10
+ plan: DatasetMaintenancePlan;
11
+ planDir: string;
12
+ }): JsonObject;
@@ -0,0 +1,111 @@
1
+ import { type DatasetMaintenanceAliasBatch, type DatasetMaintenanceAliasBatchPlan, type DatasetMaintenanceAliasExchangeRewrite, type DatasetMaintenancePlanAction, type DatasetMaintenanceRemoteRow, type DatasetMaintenanceRowSnapshot, type DatasetMaintenanceScope, type JsonObject } from './dataset-maintenance-contract.js';
2
+ import type { SafeParseSchema } from './tidas-sdk-validation.js';
3
+ export type DatasetMaintenanceAliasSchemas = {
4
+ flowproperties: SafeParseSchema;
5
+ flows: SafeParseSchema;
6
+ processes: SafeParseSchema;
7
+ };
8
+ type DecimalParts = {
9
+ negative: boolean;
10
+ coefficient: bigint;
11
+ scale: number;
12
+ };
13
+ declare function decimalParts(value: string): DecimalParts | null;
14
+ declare function decimalEqual(left: string, right: string): boolean;
15
+ declare function decimalText(parts: DecimalParts): string;
16
+ export declare function multiplyExactDecimal(value: string, factor: string): string | null;
17
+ declare function flowPropertyEntries(payload: JsonObject): JsonObject[] | null;
18
+ declare function flowPropertySingleton(payload: JsonObject): JsonObject | null;
19
+ declare function processExchangeEntries(payload: JsonObject): JsonObject[] | null;
20
+ declare function referenceIdentity(value: unknown): {
21
+ id: string | null;
22
+ version: string | null;
23
+ };
24
+ declare function referenceMatches(value: unknown, id: string, version?: string | null): boolean;
25
+ declare function targetSnapshotValid(snapshot: DatasetMaintenanceRowSnapshot | null, table: 'unitgroups' | 'flowproperties', batch: DatasetMaintenanceAliasBatch, userId: string): boolean;
26
+ declare function sourceUnitGroupSnapshotValid(snapshot: DatasetMaintenanceRowSnapshot | null, batch: DatasetMaintenanceAliasBatch, userId: string): boolean;
27
+ declare function sourceReferenceUnit(snapshot: DatasetMaintenanceRowSnapshot | null, batch: DatasetMaintenanceAliasBatch): JsonObject | null;
28
+ declare function targetConversionUnit(options: {
29
+ source: JsonObject | null;
30
+ target: DatasetMaintenanceRowSnapshot | null;
31
+ factor: string;
32
+ }): JsonObject | null;
33
+ declare function targetUnitGroupReferenceFromFlowProperty(snapshot: DatasetMaintenanceRowSnapshot | null, batch: DatasetMaintenanceAliasBatch): JsonObject | null;
34
+ declare function canonicalFlowPropertyReference(rows: DatasetMaintenanceRemoteRow[], batch: DatasetMaintenanceAliasBatch): JsonObject | null;
35
+ declare function replaceAliasFlowProperty(payload: JsonObject, batch: DatasetMaintenanceAliasBatch, targetReference: JsonObject): JsonObject | null;
36
+ declare function replaceFlowReferenceProperty(payload: JsonObject, batch: DatasetMaintenanceAliasBatch, targetReference: JsonObject): JsonObject | null;
37
+ declare function rewriteProcessExchanges(options: {
38
+ payload: JsonObject;
39
+ action: DatasetMaintenancePlanAction;
40
+ batch: DatasetMaintenanceAliasBatch;
41
+ }): {
42
+ payload: JsonObject;
43
+ rewrites: DatasetMaintenanceAliasExchangeRewrite[];
44
+ } | null;
45
+ declare function countFlowPropertyRefs(rows: DatasetMaintenanceRemoteRow[], flowpropertyId: string, flowpropertyVersion: string): number;
46
+ declare function countUnitGroupRefs(rows: DatasetMaintenanceRemoteRow[], unitgroupId: string, unitgroupVersion: string): number;
47
+ declare function flowsWithProperty(rows: DatasetMaintenanceRemoteRow[], flowpropertyId: string, flowpropertyVersion: string): Set<string>;
48
+ declare function countExchangeFlowRefs(rows: DatasetMaintenanceRemoteRow[], flowRefs: Set<string>): number;
49
+ declare function exchangeClosureKeys(rows: DatasetMaintenanceRemoteRow[], flowRefs: Set<string>): Set<string>;
50
+ declare function selectorClosureKeys(actions: DatasetMaintenancePlanAction[]): Set<string>;
51
+ declare function projectRows(rows: DatasetMaintenanceRemoteRow[], desiredPayloads: Map<string, JsonObject>, actions: DatasetMaintenancePlanAction[]): DatasetMaintenanceRemoteRow[];
52
+ export declare function buildAliasRewritePlan(options: {
53
+ scope: DatasetMaintenanceScope;
54
+ actions: DatasetMaintenancePlanAction[];
55
+ accountRows: DatasetMaintenanceRemoteRow[];
56
+ targetSnapshots: Map<string, DatasetMaintenanceAliasBatchPlan['target_snapshots']>;
57
+ schemas?: DatasetMaintenanceAliasSchemas;
58
+ }): {
59
+ desired_payloads: Map<string, JsonObject>;
60
+ batches: DatasetMaintenanceAliasBatchPlan[];
61
+ };
62
+ export declare const __testInternals: {
63
+ ALIAS_PROFILES: {
64
+ readonly time: {
65
+ readonly factor: '0.00011415525114155251';
66
+ readonly rows: 25;
67
+ readonly flowproperties: 1;
68
+ readonly flows: 10;
69
+ readonly processes: 14;
70
+ readonly exchanges: 20;
71
+ readonly target_flow_refs: 106;
72
+ readonly target_exchange_refs: 441;
73
+ };
74
+ readonly length_time: {
75
+ readonly factor: '1000';
76
+ readonly rows: 27;
77
+ readonly flowproperties: 1;
78
+ readonly flows: 13;
79
+ readonly processes: 13;
80
+ readonly exchanges: 39;
81
+ readonly target_flow_refs: 32;
82
+ readonly target_exchange_refs: 3216;
83
+ };
84
+ };
85
+ EXPECTED_UNRELATED_EXCHANGES: number;
86
+ countExchangeFlowRefs: typeof countExchangeFlowRefs;
87
+ countFlowPropertyRefs: typeof countFlowPropertyRefs;
88
+ countUnitGroupRefs: typeof countUnitGroupRefs;
89
+ decimalEqual: typeof decimalEqual;
90
+ decimalParts: typeof decimalParts;
91
+ decimalText: typeof decimalText;
92
+ exchangeClosureKeys: typeof exchangeClosureKeys;
93
+ flowPropertyEntries: typeof flowPropertyEntries;
94
+ flowPropertySingleton: typeof flowPropertySingleton;
95
+ flowsWithProperty: typeof flowsWithProperty;
96
+ processExchangeEntries: typeof processExchangeEntries;
97
+ projectRows: typeof projectRows;
98
+ referenceIdentity: typeof referenceIdentity;
99
+ referenceMatches: typeof referenceMatches;
100
+ replaceAliasFlowProperty: typeof replaceAliasFlowProperty;
101
+ replaceFlowReferenceProperty: typeof replaceFlowReferenceProperty;
102
+ rewriteProcessExchanges: typeof rewriteProcessExchanges;
103
+ selectorClosureKeys: typeof selectorClosureKeys;
104
+ targetUnitGroupReferenceFromFlowProperty: typeof targetUnitGroupReferenceFromFlowProperty;
105
+ canonicalFlowPropertyReference: typeof canonicalFlowPropertyReference;
106
+ targetSnapshotValid: typeof targetSnapshotValid;
107
+ sourceReferenceUnit: typeof sourceReferenceUnit;
108
+ sourceUnitGroupSnapshotValid: typeof sourceUnitGroupSnapshotValid;
109
+ targetConversionUnit: typeof targetConversionUnit;
110
+ };
111
+ export {};