@zalosai/zalos-cli 0.2.30 → 0.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/onboard-input.js +45 -19
- package/package.json +1 -1
|
@@ -103,6 +103,17 @@ export async function onboardInput(o) {
|
|
|
103
103
|
'');
|
|
104
104
|
};
|
|
105
105
|
try {
|
|
106
|
+
const publish = async (request, message, details) => {
|
|
107
|
+
const path = '/developer/finance/registry/onboard-input';
|
|
108
|
+
const options = { timeoutMs: 120_000 };
|
|
109
|
+
const preview = dataRow(await client.post(path, request, options));
|
|
110
|
+
printJson({ ...preview, ...details });
|
|
111
|
+
if (o.preview || (await ask(message + ' Type publish to confirm', 'cancel')) !== 'publish')
|
|
112
|
+
return;
|
|
113
|
+
if (typeof preview.confirmation !== 'string')
|
|
114
|
+
throw new Error('Mesh did not return a confirmed proposal digest');
|
|
115
|
+
printJson(dataRow(await client.post(path, { ...request, confirm: preview.confirmation }, options)));
|
|
116
|
+
};
|
|
106
117
|
const previous = input.binding;
|
|
107
118
|
const sources = registry.sources.filter((s) => !s.retired).map((s) => s.key);
|
|
108
119
|
const current = registry.datasets.find((d) => d.key === previous?.datasetKey);
|
|
@@ -134,6 +145,7 @@ export async function onboardInput(o) {
|
|
|
134
145
|
source: dataset.source,
|
|
135
146
|
matchedHeaders: headers,
|
|
136
147
|
headerRow: header.row,
|
|
148
|
+
contractSha256: dataset.spec.contract.sha256,
|
|
137
149
|
},
|
|
138
150
|
]
|
|
139
151
|
: [];
|
|
@@ -173,7 +185,7 @@ export async function onboardInput(o) {
|
|
|
173
185
|
if (!['period', 'prior_period', 'next_period'].includes(window))
|
|
174
186
|
throw new Error('Choose period, prior_period or next_period');
|
|
175
187
|
const confirmed = Boolean(o.window || terminal);
|
|
176
|
-
|
|
188
|
+
const details = {
|
|
177
189
|
...context,
|
|
178
190
|
...match,
|
|
179
191
|
format: sample.format,
|
|
@@ -185,8 +197,32 @@ export async function onboardInput(o) {
|
|
|
185
197
|
},
|
|
186
198
|
windowConfirmed: confirmed,
|
|
187
199
|
confirmationRequired: confirmed ? [] : ['window'],
|
|
188
|
-
message: confirmed ? '
|
|
189
|
-
}
|
|
200
|
+
message: confirmed ? 'Review the proposed input binding.' : prompt,
|
|
201
|
+
};
|
|
202
|
+
if (o.preview || !confirmed) {
|
|
203
|
+
printJson(details);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (sample.headerRow !== match.headerRow)
|
|
207
|
+
sample = await profileSample(o.sample, { ...o, ...sample.format, headerRow: String(match.headerRow) }, ask, undefined, input.input.maxFileSizeMb);
|
|
208
|
+
await publish({
|
|
209
|
+
teamId,
|
|
210
|
+
workflowId,
|
|
211
|
+
field,
|
|
212
|
+
authoredDate: new Date().toISOString().slice(0, 10),
|
|
213
|
+
expectedVersion: input.registryVersion,
|
|
214
|
+
workflowVersionId: input.workflowVersionId,
|
|
215
|
+
archiveSha256: input.package.archiveSha256,
|
|
216
|
+
existingContractSha256: match.contractSha256,
|
|
217
|
+
format: sample.format,
|
|
218
|
+
columns: sample.columns,
|
|
219
|
+
sizeBytes: sample.sizeBytes,
|
|
220
|
+
source: match.source,
|
|
221
|
+
datasetKey: key,
|
|
222
|
+
name: key,
|
|
223
|
+
window,
|
|
224
|
+
rules: 'inherit',
|
|
225
|
+
}, 'Bind ' + key + ' to ' + field + ' for ' + window + ' and publish?', { matchedHeaders: match.matchedHeaders, headerRow: match.headerRow });
|
|
190
226
|
return;
|
|
191
227
|
}
|
|
192
228
|
}
|
|
@@ -264,7 +300,7 @@ export async function onboardInput(o) {
|
|
|
264
300
|
}
|
|
265
301
|
const window = o.window ??
|
|
266
302
|
previous?.window ??
|
|
267
|
-
(await ask('Input window (period
|
|
303
|
+
(await ask('Input window (period, prior_period, next_period)', 'period'));
|
|
268
304
|
const compatible = current?.spec.parser?.kind === sample.format.kind;
|
|
269
305
|
const rules = o.rules ??
|
|
270
306
|
(compatible
|
|
@@ -287,23 +323,13 @@ export async function onboardInput(o) {
|
|
|
287
323
|
window,
|
|
288
324
|
rules,
|
|
289
325
|
};
|
|
290
|
-
const path = '/developer/finance/registry/onboard-input';
|
|
291
|
-
const preview = dataRow(await client.post(path, request));
|
|
292
|
-
printJson({
|
|
293
|
-
...preview,
|
|
294
|
-
headerRow: sample.headerRow,
|
|
295
|
-
possibleExcelDates: sample.ambiguousDates,
|
|
296
|
-
});
|
|
297
|
-
if (o.preview)
|
|
298
|
-
return;
|
|
299
326
|
const message = previous
|
|
300
327
|
? 'Replace ' + previous.datasetKey + ' with ' + datasetKey + ' for ' + field + ' and publish?'
|
|
301
328
|
: 'Bind ' + datasetKey + ' to ' + field + ' and publish?';
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
printJson(dataRow(await client.post(path, { ...request, confirm: preview.confirmation })));
|
|
329
|
+
await publish(request, message, {
|
|
330
|
+
headerRow: sample.headerRow,
|
|
331
|
+
possibleExcelDates: sample.ambiguousDates,
|
|
332
|
+
});
|
|
307
333
|
}
|
|
308
334
|
finally {
|
|
309
335
|
terminal?.close();
|
|
@@ -320,7 +346,7 @@ export function registerOnboardInput(registry) {
|
|
|
320
346
|
.option('--source <key>', 'Existing registry source')
|
|
321
347
|
.option('--dataset-key <key>', 'Select a matching dataset for an unbound input, or choose a new dataset key')
|
|
322
348
|
.option('--rules <mode>', 'inherit compatible rules from the bound dataset, or table')
|
|
323
|
-
.option('--window <window>', 'Input window (
|
|
349
|
+
.option('--window <window>', 'Input window (period, prior_period, next_period)')
|
|
324
350
|
.option('--sheet <name>', 'Workbook worksheet')
|
|
325
351
|
.option('--header-row <number>', 'One-based sample header row')
|
|
326
352
|
.option('--delimiter <character>', 'CSV delimiter')
|