@senticor/hive 1.163.1 → 1.164.0

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 (2) hide show
  1. package/hive.cjs +61 -17
  2. package/package.json +1 -1
package/hive.cjs CHANGED
@@ -9551,8 +9551,9 @@ function schemaErrorFields(data) {
9551
9551
  const paths = errors.map((entry) => String(entry?.instancePath ?? "").trim()).filter(Boolean).map((path10) => path10.replace(/^\//, ""));
9552
9552
  return [...new Set(paths)];
9553
9553
  }
9554
- function remoteFailureRemediation(data) {
9554
+ function remoteFailureRemediation(data, request) {
9555
9555
  const code = remoteErrorFields(data).code.toUpperCase();
9556
+ if (code === "PRECONDITION_REQUIRED" || code === "VERSION_CONFLICT") return versionTokenRemediation(data, request);
9556
9557
  const scope = tenantFailureScope();
9557
9558
  if (code === "TENANT_NOT_ALLOWED") {
9558
9559
  const selection = appliedTenantSelection();
@@ -9565,6 +9566,28 @@ function remoteFailureRemediation(data) {
9565
9566
  }
9566
9567
  return void 0;
9567
9568
  }
9569
+ function versionTokenRemediation(data, request) {
9570
+ const fromPath = request?.path?.match(/^\/api\/records\/([^/?#]+)(\/[^?#]*)?/);
9571
+ const pathId = fromPath && fromPath[1] !== "bulk" ? fromPath[1] : void 0;
9572
+ const fromBody = data?.recordId;
9573
+ let id = pathId ?? (typeof fromBody === "string" && fromBody ? fromBody : void 0);
9574
+ if (pathId) {
9575
+ try {
9576
+ id = decodeURIComponent(pathId);
9577
+ } catch {
9578
+ id = pathId;
9579
+ }
9580
+ }
9581
+ const read = id ? `Read the record again with 'hive record get --id ${id}'` : "Read the record again with 'hive record get'";
9582
+ const lifecycle = request?.method === "POST" && pathId && /^\/(archive|unarchive|transitions\/[^/]+)\/?$/.test(fromPath?.[2] ?? "");
9583
+ if (lifecycle) {
9584
+ return `Nothing was written. ${read} and run the command again with its data.recordVersion as --expectedRecordVersion <n>.`;
9585
+ }
9586
+ if (request?.method) {
9587
+ return `Nothing was written. ${read}, put its data.recordVersion into the JSON file as expectedRecordVersion, and run the command again.`;
9588
+ }
9589
+ return `Nothing was written. ${read} and send its data.recordVersion again: as --expectedRecordVersion for transition, archive and unarchive, as expectedRecordVersion in the JSON file for patch and create.`;
9590
+ }
9568
9591
  function tenantFailureScope() {
9569
9592
  const selection = appliedTenantSelection();
9570
9593
  return selection ? `${describeAppliedTenant(selection)}. ` : "";
@@ -9663,7 +9686,7 @@ function installRemoteFailureExit() {
9663
9686
  const failure2 = pendingRemoteFailure();
9664
9687
  if (!failure2) return;
9665
9688
  const symbolic = remoteErrorFields(failure2.body).code || remoteFailureCode(failure2.status);
9666
- const remediation = remoteFailureRemediation(failure2.body) ?? (failure2.status === 401 ? "Run 'hive login' to authenticate, or set HIVE_TOKEN." : void 0);
9689
+ const remediation = remoteFailureRemediation(failure2.body, { method: failure2.method, path: failure2.path }) ?? (failure2.status === 401 ? "Run 'hive login' to authenticate, or set HIVE_TOKEN." : void 0);
9667
9690
  const tenant = remoteFailureTenant(failure2.body);
9668
9691
  const problemType = remoteProblemType(failure2.body);
9669
9692
  const details = remoteProblemDetails(failure2.body);
@@ -10552,22 +10575,22 @@ var artifactName = injectedString(
10552
10575
  true ? "hive-cli" : void 0
10553
10576
  ) || String(process.env.HIVE_CLI_ARTIFACT_NAME || "hive-cli").trim() || "hive-cli";
10554
10577
  var packageVersion = injectedString(
10555
- true ? "1.163.1" : void 0
10578
+ true ? "1.164.0" : void 0
10556
10579
  ) || String(process.env.HIVE_CLI_PACKAGE_VERSION || "").trim() || readPackageVersion();
10557
10580
  var releaseVersion = injectedString(
10558
- true ? "1.163.1" : void 0
10581
+ true ? "1.164.0" : void 0
10559
10582
  ) || String(process.env.HIVE_CLI_RELEASE_VERSION || "").trim() || packageVersion || "dev";
10560
10583
  var releaseChannel = injectedString(
10561
10584
  true ? "final" : void 0
10562
10585
  ) || String(process.env.HIVE_CLI_RELEASE_CHANNEL || "").trim() || (releaseVersion.includes("-rc.") ? "rc" : releaseVersion === "dev" ? "dev" : "final");
10563
10586
  var buildCommit = injectedString(
10564
- true ? "9bc96d0072199373b9292867188f0b072b278910" : void 0
10587
+ true ? "27a870bc10e581e44f64aa623083470a8a9fcf4f" : void 0
10565
10588
  ) || String(process.env.HIVE_CLI_BUILD_COMMIT || "").trim() || "unknown";
10566
10589
  var buildTimestamp = injectedString(
10567
- true ? "2026-11-18T00:17:57Z" : void 0
10590
+ true ? "2026-11-18T08:02:36Z" : void 0
10568
10591
  ) || String(process.env.HIVE_CLI_BUILD_TIMESTAMP || "").trim() || "unknown";
10569
10592
  var ociRef = injectedString(
10570
- true ? "registry.onstackit.cloud/senticor/hive-cli:1.163.1" : void 0
10593
+ true ? "registry.onstackit.cloud/senticor/hive-cli:1.164.0" : void 0
10571
10594
  ) || String(process.env.HIVE_CLI_OCI_REF || "").trim() || `registry.onstackit.cloud/senticor/${artifactName}:${releaseVersion}`;
10572
10595
  var RELEASE_INFO = Object.freeze({
10573
10596
  packageVersion,
@@ -36814,7 +36837,8 @@ var recordArgs = withArgs({
36814
36837
  name: { type: "string", description: "Alias for --transition (used by `record transition`)" },
36815
36838
  dryRun: { type: "boolean", description: "Preview archive/unarchive without mutating state" },
36816
36839
  recordIds: { type: "string", description: "Comma-separated record ids for bulk archive/unarchive" },
36817
- expectedSchemaVersion: { type: "string", description: "Optional optimistic-concurrency guard for archive/unarchive" },
36840
+ expectedRecordVersion: { type: "string", description: "Optimistic-concurrency token for record transition/archive/unarchive: the record's current data.recordVersion (see `hive record get`). Required on version-controlled record types" },
36841
+ expectedSchemaVersion: { type: "string", description: "Deprecated alias of --expectedRecordVersion (it never referred to data.schemaVersion)" },
36818
36842
  schema: { type: "string", description: "Path to a JSON Schema file (for `record validate`)" },
36819
36843
  dataOnly: { type: "boolean", description: "Validate the record's `.data` instead of the whole file" },
36820
36844
  filter: { type: "string", description: "Comma-separated registry filters as key=value pairs (for `record list`)" }
@@ -36851,33 +36875,54 @@ function parseRegisteredRecordFilters(raw) {
36851
36875
  }
36852
36876
  return out;
36853
36877
  }
36854
- function optionalPositiveInt(args, key) {
36878
+ function applyRecordVersionToken(args, body) {
36879
+ const canonical = optionalVersionInt(args, "expectedRecordVersion");
36880
+ const alias = optionalVersionInt(args, "expectedSchemaVersion");
36881
+ if (canonical !== void 0 && alias !== void 0 && canonical !== alias) {
36882
+ throw commandError("INVALID_FLAG", 1, "--expectedRecordVersion and its deprecated alias --expectedSchemaVersion differ; pass only --expectedRecordVersion");
36883
+ }
36884
+ const value = canonical ?? alias;
36885
+ if (value !== void 0) body.expectedRecordVersion = value;
36886
+ }
36887
+ function refuseVersionFlagOnBulk(args, action) {
36888
+ for (const key of ["expectedRecordVersion", "expectedSchemaVersion"]) {
36889
+ if (args[key] !== void 0) {
36890
+ throw commandError(
36891
+ "INVALID_FLAG",
36892
+ 1,
36893
+ `--${key} does not apply to ${action}: one version cannot guard several records. To version-check each row, use --file with { "records": [{ "recordId": "...", "expectedRecordVersion": <n> }] }.`
36894
+ );
36895
+ }
36896
+ }
36897
+ }
36898
+ function optionalVersionInt(args, key) {
36855
36899
  const raw = args[key];
36856
36900
  if (raw === void 0 || raw === null || raw === "") return void 0;
36857
36901
  const parsed = Number(raw);
36858
- if (!Number.isInteger(parsed) || parsed < 1) {
36859
- throw commandError("INVALID_FLAG", 1, `--${key} must be a positive integer`);
36902
+ if (typeof raw === "boolean" || !Number.isInteger(parsed) || parsed < 0) {
36903
+ throw commandError("INVALID_FLAG", 1, `--${key} must be a non-negative integer`);
36860
36904
  }
36861
36905
  return parsed;
36862
36906
  }
36863
36907
  function recordLifecycleBody(args) {
36864
36908
  const body = {};
36865
36909
  if (args.reason) body.reason = String(args.reason);
36866
- const expectedSchemaVersion = optionalPositiveInt(args, "expectedSchemaVersion");
36867
- if (expectedSchemaVersion !== void 0) body.expectedSchemaVersion = expectedSchemaVersion;
36910
+ applyRecordVersionToken(args, body);
36868
36911
  return body;
36869
36912
  }
36870
36913
  function recordBulkLifecycleBody(args, action) {
36914
+ refuseVersionFlagOnBulk(args, action);
36871
36915
  const body = args.file ? { ...recordOf5(readJsonFile(args.file)) } : {};
36916
+ if (args.reason) body.reason = String(args.reason);
36917
+ if (Array.isArray(body.records) && body.records.length && args.recordIds === void 0 && body.recordIds === void 0) return body;
36872
36918
  const recordIds = normalizeCliList(args.recordIds ?? body.recordIds);
36873
36919
  if (!recordIds.length) {
36874
36920
  throw commandError(
36875
36921
  "RECORD_IDS_REQUIRED",
36876
36922
  1,
36877
- `${action} requires --record-ids <id[,id...]> or --file containing recordIds[].`
36923
+ `${action} requires --record-ids <id[,id...]> or --file containing recordIds[] or records[].`
36878
36924
  );
36879
36925
  }
36880
- if (args.reason) body.reason = String(args.reason);
36881
36926
  body.recordIds = recordIds;
36882
36927
  return body;
36883
36928
  }
@@ -36956,8 +37001,7 @@ var record2 = defineCommand({
36956
37001
  const recordId2 = reqAny(args, "recordId", "id");
36957
37002
  const transitionName = reqAny(args, "transition", "name");
36958
37003
  const body = {};
36959
- const expectedSchemaVersion = optionalPositiveInt(args, "expectedSchemaVersion");
36960
- if (expectedSchemaVersion !== void 0) body.expectedSchemaVersion = expectedSchemaVersion;
37004
+ applyRecordVersionToken(args, body);
36961
37005
  return output((await client.post(`/api/records/${enc(recordId2)}/transitions/${enc(transitionName)}`, body)).data, fmt);
36962
37006
  }
36963
37007
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@senticor/hive",
3
- "version": "1.163.1",
3
+ "version": "1.164.0",
4
4
  "description": "Cognitive Hive OS — unified CLI",
5
5
  "type": "commonjs",
6
6
  "bin": {