@foir/cli 0.66.0 → 0.67.1
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/cli.js +25 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -12006,6 +12006,15 @@ function registerModelsCommands(program2, globalOpts) {
|
|
|
12006
12006
|
|
|
12007
12007
|
// src/commands/records.ts
|
|
12008
12008
|
import { toJson as toJson4 } from "@bufbuild/protobuf";
|
|
12009
|
+
function draftStateMessage(record) {
|
|
12010
|
+
if (!record.hasUnpublishedChanges) return null;
|
|
12011
|
+
const state = record.publishedVersionNumber !== void 0 ? `v${record.publishedVersionNumber} is live, and the content shown is the published one` : "nothing is published yet, and the content shown is empty";
|
|
12012
|
+
return `This is a DRAFT: ${state}. Read the draft with --preview` + (record.currentVersionId ? `, or publish it with \`foir records publish ${record.currentVersionId}\`.` : ".");
|
|
12013
|
+
}
|
|
12014
|
+
function reportDraftState(record) {
|
|
12015
|
+
const message = draftStateMessage(record);
|
|
12016
|
+
if (message) warn(message);
|
|
12017
|
+
}
|
|
12009
12018
|
var ENVELOPE_ONLY_KEYS = /* @__PURE__ */ new Set([
|
|
12010
12019
|
"data",
|
|
12011
12020
|
"update",
|
|
@@ -12061,7 +12070,7 @@ function registerRecordsCommands(program2, globalOpts) {
|
|
|
12061
12070
|
records.command("get <modelKey> <idOrKey>").description("Get a record by ID or natural key").option("--resolved", "Include resolved content (published version)").option("--preview", "Resolve latest draft instead of published version").option("--locale <locale>", "Locale for field translations").action(
|
|
12062
12071
|
withErrorHandler(
|
|
12063
12072
|
globalOpts,
|
|
12064
|
-
async (modelKey, idOrKey,
|
|
12073
|
+
async (modelKey, idOrKey, cmdOpts) => {
|
|
12065
12074
|
const opts = globalOpts();
|
|
12066
12075
|
const client = await createPlatformClient(opts);
|
|
12067
12076
|
const record = isUUID(idOrKey) ? await client.records.getRecord(idOrKey) : await client.records.getRecordByKey(modelKey, idOrKey);
|
|
@@ -12070,7 +12079,21 @@ function registerRecordsCommands(program2, globalOpts) {
|
|
|
12070
12079
|
`Record "${idOrKey}" not found in model "${modelKey}".`
|
|
12071
12080
|
);
|
|
12072
12081
|
}
|
|
12082
|
+
if (cmdOpts.resolved || cmdOpts.preview) {
|
|
12083
|
+
const [resolved] = await client.records.batchResolveRecords({
|
|
12084
|
+
modelKey: record.modelKey,
|
|
12085
|
+
recordIds: [record.id],
|
|
12086
|
+
preview: !!cmdOpts.preview,
|
|
12087
|
+
...typeof cmdOpts.locale === "string" ? { context: { locale: cmdOpts.locale } } : {}
|
|
12088
|
+
});
|
|
12089
|
+
const envelope = toJson4(RecordSchema, record);
|
|
12090
|
+
formatOutput({ ...envelope, data: resolved?.data ?? {} }, opts);
|
|
12091
|
+
return;
|
|
12092
|
+
}
|
|
12073
12093
|
formatOutputProto(RecordSchema, record, opts);
|
|
12094
|
+
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
12095
|
+
reportDraftState(record);
|
|
12096
|
+
}
|
|
12074
12097
|
}
|
|
12075
12098
|
)
|
|
12076
12099
|
);
|
|
@@ -12217,6 +12240,7 @@ function registerRecordsCommands(program2, globalOpts) {
|
|
|
12217
12240
|
);
|
|
12218
12241
|
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
12219
12242
|
success(`Saved record ${id}`);
|
|
12243
|
+
if (result) reportDraftState(result);
|
|
12220
12244
|
}
|
|
12221
12245
|
}
|
|
12222
12246
|
)
|