@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.
- package/README.md +58 -6
- package/dist/src/batch.d.ts +6 -0
- package/dist/src/batch.js +6 -0
- package/dist/src/batch.js.map +1 -0
- package/dist/src/cli.d.ts +161 -0
- package/dist/src/cli.js +130 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/command-spec.d.ts +90 -0
- package/dist/src/command-spec.js +400 -0
- package/dist/src/command-spec.js.map +1 -0
- package/dist/src/lib/artifacts.d.ts +9 -0
- package/dist/src/lib/auth-identity-receipt.d.ts +160 -0
- package/dist/src/lib/auth-identity-receipt.js +634 -0
- package/dist/src/lib/auth-identity-receipt.js.map +1 -0
- package/dist/src/lib/batch/attempt-recovery.d.ts +12 -0
- package/dist/src/lib/batch/attempt-recovery.js +183 -0
- package/dist/src/lib/batch/attempt-recovery.js.map +1 -0
- package/dist/src/lib/batch/canonical-contracts.d.ts +21 -0
- package/dist/src/lib/batch/canonical-contracts.js +180 -0
- package/dist/src/lib/batch/canonical-contracts.js.map +1 -0
- package/dist/src/lib/batch/engine.d.ts +2 -0
- package/dist/src/lib/batch/engine.js +294 -0
- package/dist/src/lib/batch/engine.js.map +1 -0
- package/dist/src/lib/batch/errors.d.ts +51 -0
- package/dist/src/lib/batch/errors.js +81 -0
- package/dist/src/lib/batch/errors.js.map +1 -0
- package/dist/src/lib/batch/item-projection.d.ts +10 -0
- package/dist/src/lib/batch/item-projection.js +118 -0
- package/dist/src/lib/batch/item-projection.js.map +1 -0
- package/dist/src/lib/batch/run-lock.d.ts +4 -0
- package/dist/src/lib/batch/run-lock.js +155 -0
- package/dist/src/lib/batch/run-lock.js.map +1 -0
- package/dist/src/lib/batch/scheduler-runtime.d.ts +29 -0
- package/dist/src/lib/batch/scheduler-runtime.js +114 -0
- package/dist/src/lib/batch/scheduler-runtime.js.map +1 -0
- package/dist/src/lib/batch/types.d.ts +183 -0
- package/dist/src/lib/batch/types.js +2 -0
- package/dist/src/lib/batch/types.js.map +1 -0
- package/dist/src/lib/dataset-author.d.ts +39 -0
- package/dist/src/lib/dataset-bilingual.d.ts +165 -0
- package/dist/src/lib/dataset-classification.d.ts +279 -0
- package/dist/src/lib/dataset-command.d.ts +53 -0
- package/dist/src/lib/dataset-contract.d.ts +82 -0
- package/dist/src/lib/dataset-curation-queue.d.ts +219 -0
- package/dist/src/lib/dataset-evidence-search.d.ts +134 -0
- package/dist/src/lib/dataset-import-lca.d.ts +136 -0
- package/dist/src/lib/dataset-local.d.ts +23 -0
- package/dist/src/lib/dataset-maintenance-alias-request.d.ts +12 -0
- package/dist/src/lib/dataset-maintenance-alias-rewrite.d.ts +111 -0
- package/dist/src/lib/dataset-maintenance-apply.d.ts +458 -0
- package/dist/src/lib/dataset-maintenance-clear-account.d.ts +161 -0
- package/dist/src/lib/dataset-maintenance-contract.d.ts +317 -0
- package/dist/src/lib/dataset-maintenance-derivatives.d.ts +48 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-approval-claim.d.ts +50 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-capture.d.ts +110 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-command.d.ts +15 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-contract.d.ts +387 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-execution-contract.d.ts +456 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-freeze.d.ts +99 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-plan.d.ts +85 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-recovery.d.ts +268 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-run.d.ts +123 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-seal.d.ts +50 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-verify.d.ts +85 -0
- package/dist/src/lib/dataset-maintenance-flow-identity-wire.d.ts +32 -0
- package/dist/src/lib/dataset-maintenance-pagination.d.ts +58 -0
- package/dist/src/lib/dataset-maintenance-plan.d.ts +40 -0
- package/dist/src/lib/dataset-maintenance-protected-artifacts.d.ts +16 -0
- package/dist/src/lib/dataset-maintenance-protected-before.d.ts +71 -0
- package/dist/src/lib/dataset-maintenance-protected-contract.d.ts +385 -0
- package/dist/src/lib/dataset-maintenance-protected-freeze.d.ts +148 -0
- package/dist/src/lib/dataset-maintenance-protected-preparation.d.ts +76 -0
- package/dist/src/lib/dataset-maintenance-protected-run.d.ts +252 -0
- package/dist/src/lib/dataset-maintenance-protected-seal.d.ts +93 -0
- package/dist/src/lib/dataset-maintenance-protected-toolchain.d.ts +31 -0
- package/dist/src/lib/dataset-maintenance-protected-verify.d.ts +99 -0
- package/dist/src/lib/dataset-maintenance-remote.d.ts +212 -0
- package/dist/src/lib/dataset-maintenance-support-validation.d.ts +18 -0
- package/dist/src/lib/dataset-maintenance-verify.d.ts +102 -0
- package/dist/src/lib/dataset-patch.d.ts +193 -0
- package/dist/src/lib/dataset-references-rewrite.d.ts +77 -0
- package/dist/src/lib/dataset-remote-refresh.d.ts +64 -0
- package/dist/src/lib/dataset-remote-verify.d.ts +168 -0
- package/dist/src/lib/dataset-save-draft-run.d.ts +283 -0
- package/dist/src/lib/dataset-save-draft-run.js +54 -21
- package/dist/src/lib/dataset-save-draft-run.js.map +1 -1
- package/dist/src/lib/dataset-source-upload-attachments.d.ts +109 -0
- package/dist/src/lib/dataset-validate.d.ts +62 -0
- package/dist/src/lib/dotenv.d.ts +6 -0
- package/dist/src/lib/env.d.ts +59 -0
- package/dist/src/lib/errors.d.ts +18 -0
- package/dist/src/lib/flow-build-alias-map.d.ts +80 -0
- package/dist/src/lib/flow-fetch-rows.d.ts +70 -0
- package/dist/src/lib/flow-get.d.ts +35 -0
- package/dist/src/lib/flow-governance.d.ts +22 -0
- package/dist/src/lib/flow-list.d.ts +57 -0
- package/dist/src/lib/flow-materialize-decisions.d.ts +67 -0
- package/dist/src/lib/flow-payload-validation.d.ts +32 -0
- package/dist/src/lib/flow-publish-reviewed-data.d.ts +262 -0
- package/dist/src/lib/flow-publish-version.d.ts +193 -0
- package/dist/src/lib/flow-qa.d.ts +289 -0
- package/dist/src/lib/flow-read.d.ts +70 -0
- package/dist/src/lib/flow-regen-product.d.ts +431 -0
- package/dist/src/lib/flow-remediate.d.ts +133 -0
- package/dist/src/lib/http.d.ts +25 -0
- package/dist/src/lib/http.js.map +1 -1
- package/dist/src/lib/identity-preflight.d.ts +235 -0
- package/dist/src/lib/io.d.ts +2 -0
- package/dist/src/lib/kb-search.d.ts +23 -0
- package/dist/src/lib/lca-release.d.ts +105 -0
- package/dist/src/lib/lifecyclemodel-auto-build.d.ts +223 -0
- package/dist/src/lib/lifecyclemodel-bundle-save.d.ts +71 -0
- package/dist/src/lib/lifecyclemodel-graph.d.ts +91 -0
- package/dist/src/lib/lifecyclemodel-orchestrate.d.ts +349 -0
- package/dist/src/lib/lifecyclemodel-publish-build.d.ts +77 -0
- package/dist/src/lib/lifecyclemodel-publish-resulting-process.d.ts +27 -0
- package/dist/src/lib/lifecyclemodel-qa.d.ts +206 -0
- package/dist/src/lib/lifecyclemodel-resulting-process.d.ts +204 -0
- package/dist/src/lib/lifecyclemodel-save-draft-run.d.ts +96 -0
- package/dist/src/lib/lifecyclemodel-validate-build.d.ts +78 -0
- package/dist/src/lib/llm.d.ts +51 -0
- package/dist/src/lib/package-version.d.ts +3 -0
- package/dist/src/lib/process-auto-build.d.ts +168 -0
- package/dist/src/lib/process-batch-build.d.ts +97 -0
- package/dist/src/lib/process-dedup-review.d.ts +253 -0
- package/dist/src/lib/process-flow-build-plan.d.ts +108 -0
- package/dist/src/lib/process-get.d.ts +26 -0
- package/dist/src/lib/process-list.d.ts +87 -0
- package/dist/src/lib/process-payload-validation.d.ts +27 -0
- package/dist/src/lib/process-publish-build.d.ts +148 -0
- package/dist/src/lib/process-qa.d.ts +243 -0
- package/dist/src/lib/process-refresh-references.d.ts +179 -0
- package/dist/src/lib/process-required-fields.d.ts +142 -0
- package/dist/src/lib/process-resume-build.d.ts +77 -0
- package/dist/src/lib/process-save-draft-run.d.ts +72 -0
- package/dist/src/lib/process-save-draft.d.ts +53 -0
- package/dist/src/lib/process-scope-statistics.d.ts +210 -0
- package/dist/src/lib/process-verify-rows.d.ts +71 -0
- package/dist/src/lib/publish.d.ts +219 -0
- package/dist/src/lib/remote.d.ts +19 -0
- package/dist/src/lib/run.d.ts +60 -0
- package/dist/src/lib/runtime-rulesets.d.ts +29 -0
- package/dist/src/lib/state-lock.d.ts +25 -0
- package/dist/src/lib/state-lock.js +23 -1
- package/dist/src/lib/state-lock.js.map +1 -1
- package/dist/src/lib/supabase-client.d.ts +47 -0
- package/dist/src/lib/supabase-data-api-contract.d.ts +304 -0
- package/dist/src/lib/supabase-data-api-replay.d.ts +74 -0
- package/dist/src/lib/supabase-json-ordered-write.d.ts +65 -0
- package/dist/src/lib/supabase-rest.d.ts +26 -0
- package/dist/src/lib/supabase-session.d.ts +115 -0
- package/dist/src/lib/tidas-languages.d.ts +3 -0
- package/dist/src/lib/tidas-sdk-package-validator.d.ts +111 -0
- package/dist/src/lib/tidas-sdk-validation.d.ts +42 -0
- package/dist/src/lib/unstructured.d.ts +32 -0
- package/dist/src/lib/user-api-key.d.ts +16 -0
- package/dist/src/lib/validation.d.ts +82 -0
- package/dist/src/main.d.ts +4 -0
- package/package.json +17 -3
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import * as tidasSdk from '@tiangong-lca/tidas-sdk';
|
|
2
|
+
import { type DatasetCommandTable } from './dataset-command.js';
|
|
3
|
+
import type { FetchLike } from './http.js';
|
|
4
|
+
import { type SupabaseDataRuntime } from './supabase-client.js';
|
|
5
|
+
import { type RemoteDatasetLookup, type RemoteDatasetReference, type RemoteDatasetTable } from './dataset-remote-verify.js';
|
|
6
|
+
type JsonObject = Record<string, unknown>;
|
|
7
|
+
export type DatasetSaveDraftType = 'auto' | 'contact' | 'source' | 'unitgroup' | 'flowproperty' | 'flow' | 'process';
|
|
8
|
+
type ConcreteDatasetSaveDraftType = Exclude<DatasetSaveDraftType, 'auto'>;
|
|
9
|
+
type DatasetTypeConfig = {
|
|
10
|
+
table: DatasetCommandTable;
|
|
11
|
+
rootKey: string;
|
|
12
|
+
informationKey: string;
|
|
13
|
+
schemaName: keyof typeof tidasSdk;
|
|
14
|
+
factoryName: keyof typeof tidasSdk;
|
|
15
|
+
};
|
|
16
|
+
type DatasetSaveDraftValidationIssue = {
|
|
17
|
+
path: string;
|
|
18
|
+
message: string;
|
|
19
|
+
code: string;
|
|
20
|
+
};
|
|
21
|
+
type DatasetSaveDraftValidationResult = {
|
|
22
|
+
ok: true;
|
|
23
|
+
validator: string;
|
|
24
|
+
issue_count: 0;
|
|
25
|
+
issues: [];
|
|
26
|
+
} | {
|
|
27
|
+
ok: false;
|
|
28
|
+
validator: string;
|
|
29
|
+
issue_count: number;
|
|
30
|
+
issues: DatasetSaveDraftValidationIssue[];
|
|
31
|
+
};
|
|
32
|
+
declare function normalizeValidationIssue(issue: {
|
|
33
|
+
path?: Array<string | number>;
|
|
34
|
+
message?: string;
|
|
35
|
+
code?: string;
|
|
36
|
+
}): DatasetSaveDraftValidationIssue;
|
|
37
|
+
export type DatasetSaveDraftRowReport = {
|
|
38
|
+
index: number;
|
|
39
|
+
id: string | null;
|
|
40
|
+
version: string | null;
|
|
41
|
+
type: ConcreteDatasetSaveDraftType | null;
|
|
42
|
+
table: DatasetCommandTable | null;
|
|
43
|
+
status: 'prepared' | 'executed' | 'failed' | 'unknown' | 'blocked';
|
|
44
|
+
operation: 'would_sync' | 'insert' | 'save_draft' | 'skipped_invalid' | 'reference_only_type' | 'type_unknown' | 'identity_missing' | 'elementary_flow_insert_blocked' | 'remote_reference_unresolved' | 'recovered_exact_readback' | 'blocked_dependency' | null;
|
|
45
|
+
validation: DatasetSaveDraftValidationResult | null;
|
|
46
|
+
visible_row?: VisibleDatasetRow | null;
|
|
47
|
+
error?: {
|
|
48
|
+
message: string;
|
|
49
|
+
details?: unknown;
|
|
50
|
+
};
|
|
51
|
+
action_id?: string;
|
|
52
|
+
desired_sha256?: string;
|
|
53
|
+
attempt_consumed?: boolean;
|
|
54
|
+
replayed?: false;
|
|
55
|
+
readback?: 'desired_exact' | 'not_desired' | 'not_performed';
|
|
56
|
+
};
|
|
57
|
+
export type DatasetSaveDraftReport = {
|
|
58
|
+
schema_version: 1 | 2;
|
|
59
|
+
generated_at_utc: string;
|
|
60
|
+
input_path: string;
|
|
61
|
+
requested_type: DatasetSaveDraftType;
|
|
62
|
+
out_dir: string;
|
|
63
|
+
commit: boolean;
|
|
64
|
+
mode: 'dry_run' | 'commit';
|
|
65
|
+
status: 'completed' | 'completed_with_failures' | 'completed_with_unknowns';
|
|
66
|
+
counts: {
|
|
67
|
+
selected: number;
|
|
68
|
+
prepared: number;
|
|
69
|
+
executed: number;
|
|
70
|
+
failed: number;
|
|
71
|
+
unknown?: number;
|
|
72
|
+
blocked?: number;
|
|
73
|
+
attempts_consumed?: number;
|
|
74
|
+
by_table: Partial<Record<DatasetCommandTable, number>>;
|
|
75
|
+
operations: Record<string, number>;
|
|
76
|
+
};
|
|
77
|
+
files: {
|
|
78
|
+
selected_rows: string;
|
|
79
|
+
progress_jsonl: string;
|
|
80
|
+
failures_jsonl: string;
|
|
81
|
+
summary_json: string;
|
|
82
|
+
execution_ledger?: string;
|
|
83
|
+
};
|
|
84
|
+
rows: DatasetSaveDraftRowReport[];
|
|
85
|
+
execution_contract?: {
|
|
86
|
+
path: string;
|
|
87
|
+
sha256: string;
|
|
88
|
+
execution_id: string;
|
|
89
|
+
target_mode: 'owner_draft';
|
|
90
|
+
max_parallel: number;
|
|
91
|
+
serial_prefix_actions: number;
|
|
92
|
+
parallel_suffix_actions: number;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
export type RunDatasetSaveDraftOptions = {
|
|
96
|
+
inputPath: string;
|
|
97
|
+
type?: string | null;
|
|
98
|
+
outDir?: string | null;
|
|
99
|
+
commit?: boolean | null;
|
|
100
|
+
rawInput?: unknown;
|
|
101
|
+
env?: NodeJS.ProcessEnv;
|
|
102
|
+
fetchImpl?: FetchLike;
|
|
103
|
+
timeoutMs?: number;
|
|
104
|
+
now?: Date;
|
|
105
|
+
/**
|
|
106
|
+
* Explicit opt-in to write account-local (My Data, state_code=0) Unit Group and
|
|
107
|
+
* Flow Property support rows that are otherwise reference-only. Default false keeps
|
|
108
|
+
* the CLI safe-by-default for interactive operators.
|
|
109
|
+
*/
|
|
110
|
+
allowReferenceOnlySupport?: boolean | null;
|
|
111
|
+
executionContractPath?: string | null;
|
|
112
|
+
maxParallel?: number | null;
|
|
113
|
+
};
|
|
114
|
+
type DatasetSaveDraftExecutionAction = {
|
|
115
|
+
action_id: string;
|
|
116
|
+
desired_sha256: string;
|
|
117
|
+
expected_operation: 'insert' | 'save_draft';
|
|
118
|
+
table: DatasetCommandTable;
|
|
119
|
+
id: string;
|
|
120
|
+
version: string;
|
|
121
|
+
before_sha256: string | null;
|
|
122
|
+
dependency_action_ids: string[];
|
|
123
|
+
};
|
|
124
|
+
type DatasetSaveDraftExecutionContract = {
|
|
125
|
+
schema_version: 'dataset-save-draft-execution-contract.v1';
|
|
126
|
+
execution_id: string;
|
|
127
|
+
project_ref: string;
|
|
128
|
+
target_mode: 'owner_draft';
|
|
129
|
+
owner: {
|
|
130
|
+
user_id: string;
|
|
131
|
+
email: string;
|
|
132
|
+
state_code: 0;
|
|
133
|
+
};
|
|
134
|
+
actions: DatasetSaveDraftExecutionAction[];
|
|
135
|
+
};
|
|
136
|
+
type DatasetSaveDraftLedgerEvent = {
|
|
137
|
+
schema_version: 'dataset-save-draft-execution-event.v1';
|
|
138
|
+
sequence: number;
|
|
139
|
+
contract_sha256: string;
|
|
140
|
+
action_id: string;
|
|
141
|
+
desired_sha256: string;
|
|
142
|
+
action_binding_sha256: string;
|
|
143
|
+
event_type: 'attempt_emitted' | 'outcome';
|
|
144
|
+
operation: 'insert' | 'save_draft';
|
|
145
|
+
outcome: 'executed' | 'unknown' | null;
|
|
146
|
+
recovered: boolean;
|
|
147
|
+
recorded_at_utc: string;
|
|
148
|
+
previous_event_sha256: string | null;
|
|
149
|
+
event_sha256: string;
|
|
150
|
+
};
|
|
151
|
+
type ExecutionLedgerState = {
|
|
152
|
+
events: Map<string, DatasetSaveDraftLedgerEvent[]>;
|
|
153
|
+
attempts: Map<string, DatasetSaveDraftLedgerEvent>;
|
|
154
|
+
outcomes: Map<string, DatasetSaveDraftLedgerEvent>;
|
|
155
|
+
};
|
|
156
|
+
type PreparedDatasetRow = {
|
|
157
|
+
index: number;
|
|
158
|
+
row: JsonObject;
|
|
159
|
+
payload: JsonObject;
|
|
160
|
+
type: ConcreteDatasetSaveDraftType | null;
|
|
161
|
+
config: DatasetTypeConfig | null;
|
|
162
|
+
id: string | null;
|
|
163
|
+
version: string | null;
|
|
164
|
+
validation: DatasetSaveDraftValidationResult | null;
|
|
165
|
+
};
|
|
166
|
+
type VisibleDatasetRow = {
|
|
167
|
+
id: string;
|
|
168
|
+
version: string;
|
|
169
|
+
user_id: string | null;
|
|
170
|
+
state_code: number | null;
|
|
171
|
+
};
|
|
172
|
+
type ExecutionDatasetRow = VisibleDatasetRow & {
|
|
173
|
+
json_ordered: JsonObject | null;
|
|
174
|
+
};
|
|
175
|
+
type MissingFlowRemoteReference = {
|
|
176
|
+
table: RemoteDatasetTable | null;
|
|
177
|
+
id: string | null;
|
|
178
|
+
version: string | null;
|
|
179
|
+
path: string;
|
|
180
|
+
short_description: string | null;
|
|
181
|
+
status: 'missing_dataset' | 'missing_version' | 'unsupported_type' | 'version_missing' | 'version_outdated';
|
|
182
|
+
latest_version: string | null;
|
|
183
|
+
};
|
|
184
|
+
declare function parseExecutionContract(value: unknown): DatasetSaveDraftExecutionContract;
|
|
185
|
+
declare function bindExecutionContractRows(contract: DatasetSaveDraftExecutionContract, rows: PreparedDatasetRow[]): void;
|
|
186
|
+
declare function executionActionBindingSha256(action: DatasetSaveDraftExecutionAction): string;
|
|
187
|
+
declare function executionLedgerRoot(env: NodeJS.ProcessEnv, contract: DatasetSaveDraftExecutionContract): string;
|
|
188
|
+
declare function executionLedgerPath(ledgerRoot: string, action: DatasetSaveDraftExecutionAction): string;
|
|
189
|
+
declare function parseLedgerEvent(value: unknown, index: number): DatasetSaveDraftLedgerEvent;
|
|
190
|
+
declare function loadExecutionLedger(ledgerRoot: string, contract: DatasetSaveDraftExecutionContract): ExecutionLedgerState;
|
|
191
|
+
declare function projectRefFromApiBaseUrl(apiBaseUrl: string): string;
|
|
192
|
+
declare function decodeExecutionActor(accessToken: string): {
|
|
193
|
+
user_id: string;
|
|
194
|
+
email: string;
|
|
195
|
+
};
|
|
196
|
+
declare function serializeError(error: unknown): {
|
|
197
|
+
message: string;
|
|
198
|
+
details?: unknown;
|
|
199
|
+
};
|
|
200
|
+
declare function normalizeType(value: string | null | undefined, allowReferenceOnlySupport?: boolean): DatasetSaveDraftType;
|
|
201
|
+
declare function unwrapPayload(row: JsonObject): JsonObject;
|
|
202
|
+
declare function detectType(payload: JsonObject): ConcreteDatasetSaveDraftType | null;
|
|
203
|
+
declare function validatePayload(payload: JsonObject, type: ConcreteDatasetSaveDraftType, config: DatasetTypeConfig): DatasetSaveDraftValidationResult;
|
|
204
|
+
declare function extractIdentity(payload: JsonObject, row: JsonObject, config: DatasetTypeConfig): {
|
|
205
|
+
id: string | null;
|
|
206
|
+
version: string | null;
|
|
207
|
+
};
|
|
208
|
+
declare function flowType(payload: JsonObject): string | null;
|
|
209
|
+
declare function isElementaryFlowPayload(payload: JsonObject): boolean;
|
|
210
|
+
declare function compareVersions(left: string | null, right: string | null): number;
|
|
211
|
+
declare function supportLookupKey(reference: {
|
|
212
|
+
table: RemoteDatasetTable;
|
|
213
|
+
id: string;
|
|
214
|
+
version: string | null;
|
|
215
|
+
}): string;
|
|
216
|
+
declare function isLookupableRemoteReference(reference: RemoteDatasetReference): reference is RemoteDatasetReference & {
|
|
217
|
+
table: RemoteDatasetTable;
|
|
218
|
+
id: string;
|
|
219
|
+
};
|
|
220
|
+
declare function uniqueFlowRemoteReferences(payload: JsonObject): RemoteDatasetReference[];
|
|
221
|
+
declare function remoteReferenceFallbackKey(reference: Pick<RemoteDatasetReference, 'path' | 'type'>): string;
|
|
222
|
+
declare function missingFlowRemoteReferences(options: {
|
|
223
|
+
runtime: SupabaseDataRuntime;
|
|
224
|
+
fetchImpl: FetchLike;
|
|
225
|
+
timeoutMs: number;
|
|
226
|
+
cache: Map<string, Promise<RemoteDatasetLookup>>;
|
|
227
|
+
payload: JsonObject;
|
|
228
|
+
}): Promise<MissingFlowRemoteReference[]>;
|
|
229
|
+
declare function prepareRows(inputPath: string, rawInput: unknown | undefined, requestedType: DatasetSaveDraftType): PreparedDatasetRow[];
|
|
230
|
+
declare function buildFiles(outDir: string): DatasetSaveDraftReport['files'];
|
|
231
|
+
declare function defaultOutDir(inputPath: string, commit: boolean, now: Date): string;
|
|
232
|
+
declare function operationCount(rows: DatasetSaveDraftRowReport[]): Record<string, number>;
|
|
233
|
+
declare function byTable(rows: PreparedDatasetRow[]): Partial<Record<DatasetCommandTable, number>>;
|
|
234
|
+
declare function selectedRow(row: PreparedDatasetRow): JsonObject;
|
|
235
|
+
declare function buildPreparedFailure(row: PreparedDatasetRow, allowReferenceOnlySupport?: boolean): DatasetSaveDraftRowReport | null;
|
|
236
|
+
declare function buildVisibleRowsUrl(restBaseUrl: string, table: DatasetCommandTable, id: string, version: string): string;
|
|
237
|
+
declare function parseVisibleRows(payload: unknown, url: string): VisibleDatasetRow[];
|
|
238
|
+
declare function parseExecutionRows(payload: unknown, url: string): ExecutionDatasetRow[];
|
|
239
|
+
declare function exactDesiredReadback(options: {
|
|
240
|
+
rows: ExecutionDatasetRow[];
|
|
241
|
+
action: DatasetSaveDraftExecutionAction;
|
|
242
|
+
contract: DatasetSaveDraftExecutionContract;
|
|
243
|
+
}): boolean;
|
|
244
|
+
export declare function runDatasetSaveDraft(options: RunDatasetSaveDraftOptions): Promise<DatasetSaveDraftReport>;
|
|
245
|
+
export declare const __testInternals: {
|
|
246
|
+
DATASET_CONFIGS: Record<ConcreteDatasetSaveDraftType, DatasetTypeConfig>;
|
|
247
|
+
buildFiles: typeof buildFiles;
|
|
248
|
+
buildPreparedFailure: typeof buildPreparedFailure;
|
|
249
|
+
buildVisibleRowsUrl: typeof buildVisibleRowsUrl;
|
|
250
|
+
byTable: typeof byTable;
|
|
251
|
+
compareVersions: typeof compareVersions;
|
|
252
|
+
defaultOutDir: typeof defaultOutDir;
|
|
253
|
+
detectType: typeof detectType;
|
|
254
|
+
decodeExecutionActor: typeof decodeExecutionActor;
|
|
255
|
+
bindExecutionContractRows: typeof bindExecutionContractRows;
|
|
256
|
+
executionLedgerRoot: typeof executionLedgerRoot;
|
|
257
|
+
executionLedgerPath: typeof executionLedgerPath;
|
|
258
|
+
executionActionBindingSha256: typeof executionActionBindingSha256;
|
|
259
|
+
loadExecutionLedger: typeof loadExecutionLedger;
|
|
260
|
+
exactDesiredReadback: typeof exactDesiredReadback;
|
|
261
|
+
extractIdentity: typeof extractIdentity;
|
|
262
|
+
flowType: typeof flowType;
|
|
263
|
+
isElementaryFlowPayload: typeof isElementaryFlowPayload;
|
|
264
|
+
isLookupableRemoteReference: typeof isLookupableRemoteReference;
|
|
265
|
+
missingFlowRemoteReferences: typeof missingFlowRemoteReferences;
|
|
266
|
+
normalizeValidationIssue: typeof normalizeValidationIssue;
|
|
267
|
+
normalizeType: typeof normalizeType;
|
|
268
|
+
operationCount: typeof operationCount;
|
|
269
|
+
parseVisibleRows: typeof parseVisibleRows;
|
|
270
|
+
parseExecutionContract: typeof parseExecutionContract;
|
|
271
|
+
parseExecutionRows: typeof parseExecutionRows;
|
|
272
|
+
parseLedgerEvent: typeof parseLedgerEvent;
|
|
273
|
+
projectRefFromApiBaseUrl: typeof projectRefFromApiBaseUrl;
|
|
274
|
+
prepareRows: typeof prepareRows;
|
|
275
|
+
remoteReferenceFallbackKey: typeof remoteReferenceFallbackKey;
|
|
276
|
+
selectedRow: typeof selectedRow;
|
|
277
|
+
serializeError: typeof serializeError;
|
|
278
|
+
supportLookupKey: typeof supportLookupKey;
|
|
279
|
+
unwrapPayload: typeof unwrapPayload;
|
|
280
|
+
uniqueFlowRemoteReferences: typeof uniqueFlowRemoteReferences;
|
|
281
|
+
validatePayload: typeof validatePayload;
|
|
282
|
+
};
|
|
283
|
+
export {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { closeSync, chmodSync, fsyncSync, mkdirSync, openSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import * as tidasSdk from '@tiangong-lca/tidas-sdk';
|
|
6
|
+
import { createBatchContract, runBoundedBatch } from '../batch.js';
|
|
6
7
|
import { writeJsonArtifact, writeJsonLinesArtifact } from './artifacts.js';
|
|
7
8
|
import { collectImportContentIssues } from './dataset-validate.js';
|
|
8
9
|
import { createDatasetRecord, saveDraftDatasetRecord, } from './dataset-command.js';
|
|
@@ -937,6 +938,18 @@ function assertParallelSuffixTargetsAreUnique(contract, serialPrefixLength) {
|
|
|
937
938
|
targets.add(target);
|
|
938
939
|
}
|
|
939
940
|
}
|
|
941
|
+
function executionBatchActionContent(action) {
|
|
942
|
+
return {
|
|
943
|
+
action_id: action.action_id,
|
|
944
|
+
desired_sha256: action.desired_sha256,
|
|
945
|
+
expected_operation: action.expected_operation,
|
|
946
|
+
table: action.table,
|
|
947
|
+
id: action.id,
|
|
948
|
+
version: action.version,
|
|
949
|
+
before_sha256: action.before_sha256,
|
|
950
|
+
dependency_action_ids: [...action.dependency_action_ids],
|
|
951
|
+
};
|
|
952
|
+
}
|
|
940
953
|
async function renewExecutionOwnerToken(options) {
|
|
941
954
|
const accessToken = await options.runtime.getAccessToken();
|
|
942
955
|
const actor = decodeExecutionActor(accessToken);
|
|
@@ -1169,27 +1182,47 @@ async function runExecutionContractBatch(options) {
|
|
|
1169
1182
|
for (let index = 0; index < serialPrefixLength; index += 1) {
|
|
1170
1183
|
await executeAction(index);
|
|
1171
1184
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1185
|
+
const parallelIndexes = options.contract.actions
|
|
1186
|
+
.slice(serialPrefixLength)
|
|
1187
|
+
.map((_action, suffixIndex) => serialPrefixLength + suffixIndex);
|
|
1188
|
+
const parallelBatch = await runBoundedBatch({
|
|
1189
|
+
contract: createBatchContract({
|
|
1190
|
+
identity: {
|
|
1191
|
+
schema: 'dataset-save-draft.parallel-suffix.v1',
|
|
1192
|
+
execution_id: options.contract.execution_id,
|
|
1193
|
+
contract_sha256: contractSha256,
|
|
1194
|
+
},
|
|
1195
|
+
content: parallelIndexes.map((index) => executionBatchActionContent(options.contract.actions[index])),
|
|
1196
|
+
policy: {
|
|
1197
|
+
max_parallel: options.maxParallel,
|
|
1198
|
+
serial_prefix_actions: serialPrefixLength,
|
|
1199
|
+
mutation_retry: 'none',
|
|
1200
|
+
fatal_stop: true,
|
|
1201
|
+
},
|
|
1202
|
+
}),
|
|
1203
|
+
items: parallelIndexes,
|
|
1204
|
+
getItemIdentity: (index) => options.contract.actions[index].action_id,
|
|
1205
|
+
projectItemContent: (index) => executionBatchActionContent(options.contract.actions[index]),
|
|
1206
|
+
projectItemPolicy: (index) => {
|
|
1207
|
+
const action = options.contract.actions[index];
|
|
1208
|
+
return {
|
|
1209
|
+
contract_sha256: contractSha256,
|
|
1210
|
+
target_mode: 'owner_draft',
|
|
1211
|
+
expected_operation: action.expected_operation,
|
|
1212
|
+
};
|
|
1213
|
+
},
|
|
1214
|
+
getExclusiveKey: ({ item: index }) => {
|
|
1215
|
+
const action = options.contract.actions[index];
|
|
1216
|
+
return JSON.stringify([action.table, action.id, action.version]);
|
|
1217
|
+
},
|
|
1218
|
+
mode: 'mutation',
|
|
1219
|
+
maxConcurrency: options.maxParallel,
|
|
1220
|
+
execute: async ({ item: index }) => executeAction(index),
|
|
1221
|
+
shouldStop: ({ last_result: lastResult }) => lastResult.status === 'failed',
|
|
1222
|
+
});
|
|
1223
|
+
const fatalWorkerResult = parallelBatch.results_completion_order.find((result) => result.status === 'failed');
|
|
1224
|
+
if (fatalWorkerResult?.status === 'failed') {
|
|
1225
|
+
throw fatalWorkerResult.error;
|
|
1193
1226
|
}
|
|
1194
1227
|
const completedReports = reports;
|
|
1195
1228
|
const failures = completedReports.filter((row) => ['failed', 'unknown', 'blocked'].includes(row.status));
|