@wayai/cli 0.3.235 → 0.3.236

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/index.js CHANGED
@@ -6504,13 +6504,10 @@ var init_chunk_BEOHBREG = __esm({
6504
6504
  }
6505
6505
  });
6506
6506
 
6507
- // ../../packages/core/dist/chunk-AMHCCKZ3.js
6508
- function declaresReview(schema) {
6509
- return typeof schema === "object" && schema !== null && schema[REVIEW_DECLARATION_KEY] !== void 0;
6510
- }
6511
- var TOOLSET_SLUG_PATTERN, REKOR_STRUCTURAL_ID_PATTERN, baseEnvironmentSchema, toolsetFileToolSchema, toolsetSurfaceSchema, toolsetConnectionBindingSchema, rekorToolsetToolsSchema, rekorBoundAttestation, rekorResolvedToolsetSchema, REVIEW_DECLARATION_KEY, resolvedRecordTypeSchema, reviewWritersSchema, sharedScopeSchema, resolvedFileToolSchema, rekorToolsetFileSchema, rekorToolsetFileUrlAnswerSchema, rekorToolsetFileListSchema, rekorToolsetFileGetSchema, rekorToolsetFilePutSchema, TOOLSET_CUSTOMER_FACING_REFUSAL_MARK, TOOLSET_CUSTOMER_FACING_REFUSAL;
6512
- var init_chunk_AMHCCKZ3 = __esm({
6513
- "../../packages/core/dist/chunk-AMHCCKZ3.js"() {
6507
+ // ../../packages/core/dist/chunk-TPFTFBLF.js
6508
+ var TOOLSET_SLUG_PATTERN, REKOR_STRUCTURAL_ID_PATTERN, baseEnvironmentSchema, toolsetFileToolSchema, toolsetSurfaceSchema, toolsetConnectionBindingSchema, rekorToolsetToolsSchema, rekorBoundAttestation, rekorResolvedToolsetSchema, resolvedRecordTypeSchema, reviewWritersSchema, sharedScopeSchema, resolvedFileToolSchema, rekorToolsetFileSchema, rekorToolsetFileUrlAnswerSchema, rekorToolsetFileListSchema, rekorToolsetFileGetSchema, rekorToolsetFilePutSchema, TOOLSET_CUSTOMER_FACING_REFUSAL_MARK, TOOLSET_CUSTOMER_FACING_REFUSAL;
6509
+ var init_chunk_TPFTFBLF = __esm({
6510
+ "../../packages/core/dist/chunk-TPFTFBLF.js"() {
6514
6511
  "use strict";
6515
6512
  init_chunk_BEOHBREG();
6516
6513
  init_chunk_DHPUPI4Y();
@@ -6559,13 +6556,14 @@ var init_chunk_AMHCCKZ3 = __esm({
6559
6556
  */
6560
6557
  file_writes: external_exports.boolean().optional(),
6561
6558
  /**
6562
- * A record type the toolset's actions or composite steps reach (the resolve's `record_types`) names it
6563
- * among its writers (`x-review.writers`, #5083 RK4): the toolset writes the type's drafts and reads its
6564
- * every record, drafts included. Or such a type's declaration this side cannot read, or a resolve
6565
- * reaching records that carries no record types. A type only its relationship tools reach is not
6566
- * judged: the resolve does not carry that type's declaration. Absent
6567
- * on a surface recorded before it was, which the customer-facing rule reads as writing, for a toolset
6568
- * reaching records, until the connection's next tool sync or token save records it.
6559
+ * A record type the resolve's `record_types` carries names the toolset among its writers
6560
+ * (`x-review.writers`, #5083 RK4): the toolset writes the type's drafts and reads its every record,
6561
+ * drafts included. Those are the types its actions and composite record steps reach, and every
6562
+ * reviewed type it reaches otherwise: at a relationship tool's or a composite relationship step's
6563
+ * end, in a `batch` entry, or, through `sql_query`, all of them (decision 198). Or such a type's
6564
+ * declaration this side cannot read, or a resolve reaching records that carries no record types.
6565
+ * Absent on a surface recorded before it was, which the customer-facing rule reads as writing, for a
6566
+ * toolset reaching records, until the connection's next tool sync or token save records it.
6569
6567
  */
6570
6568
  review_writes: external_exports.boolean().optional(),
6571
6569
  /**
@@ -6658,18 +6656,21 @@ var init_chunk_AMHCCKZ3 = __esm({
6658
6656
  /** The toolset serves one customer per call (#5083 RK2). Absent reads as not scoped. */
6659
6657
  customer_scope: external_exports.boolean().optional(),
6660
6658
  /**
6661
- * Each record type the toolset's actions and composite steps reach, by id, as the data product
6662
- * stores it (`json_schema` included). A reviewed type's `x-review` names its writers (#5083 RK4).
6659
+ * Record types the toolset reaches, by id, as the data product stores them (`json_schema`
6660
+ * included): each one its actions and composite record steps reach, and each reviewed one it
6661
+ * reaches otherwise (relationship ends, `batch` entries, every one through `sql_query`; #5083
6662
+ * decision 198). An unreviewed type it reaches only otherwise is not here. A reviewed type's
6663
+ * `x-review` names its writers (RK4).
6663
6664
  */
6664
6665
  record_types: external_exports.record(external_exports.unknown()).optional(),
6665
6666
  /**
6666
- * What each record type the toolset can reach is to a customer scope (`{ role }`, or null), by id:
6667
- * those `record_types` holds, and those only its relationship tools and steps reach (#5083 RK2).
6667
+ * What each record type the toolset's actions, composite steps and relationship tools reach is to a
6668
+ * customer scope (`{ role }`, or null), by id (#5083 RK2). A reviewed type `record_types` carries
6669
+ * because only a `batch` entry or `sql_query` reaches it has none.
6668
6670
  */
6669
6671
  record_type_scopes: external_exports.record(external_exports.unknown()).optional()
6670
6672
  }).passthrough()
6671
6673
  });
6672
- REVIEW_DECLARATION_KEY = "x-review";
6673
6674
  resolvedRecordTypeSchema = external_exports.object({ json_schema: external_exports.record(external_exports.unknown()) });
6674
6675
  reviewWritersSchema = external_exports.object({ writers: external_exports.array(external_exports.string()).optional() });
6675
6676
  sharedScopeSchema = external_exports.object({ role: external_exports.literal("shared") });
@@ -15087,7 +15088,7 @@ var init_contracts = __esm({
15087
15088
  init_chunk_Y7CFCYX4();
15088
15089
  init_chunk_5DGHIY7L();
15089
15090
  init_chunk_N4FMK4UY();
15090
- init_chunk_AMHCCKZ3();
15091
+ init_chunk_TPFTFBLF();
15091
15092
  init_chunk_BEOHBREG();
15092
15093
  init_chunk_IPDOHAZ5();
15093
15094
  init_chunk_YUZFHVB2();
@@ -37441,16 +37442,6 @@ var init_batch = __esm({
37441
37442
  }
37442
37443
  });
37443
37444
 
37444
- // ../../packages/core/dist/contracts/rekor-toolset.js
37445
- var init_rekor_toolset = __esm({
37446
- "../../packages/core/dist/contracts/rekor-toolset.js"() {
37447
- "use strict";
37448
- init_chunk_AMHCCKZ3();
37449
- init_chunk_BEOHBREG();
37450
- init_chunk_DHPUPI4Y();
37451
- }
37452
- });
37453
-
37454
37445
  // src/data/commands/import.ts
37455
37446
  import { createReadStream } from "fs";
37456
37447
  import { access, constants, stat } from "fs/promises";
@@ -37677,14 +37668,16 @@ Stopped at chunk ${nextIndex}. To resume, re-run the SAME command with:
37677
37668
  }
37678
37669
  if (!opts.yes) {
37679
37670
  const plan = await client.request("GET", `/v1/${base}/import/${pathSegment(importId, "import id")}/rollback-plan?counts=true`);
37680
- const n = plan.matched_records ?? 0;
37671
+ const matched = plan.matched_records ?? 0;
37672
+ const kept2 = Math.min(plan.kept?.records ?? 0, matched);
37673
+ const n = matched - kept2;
37681
37674
  if (n === 0) {
37682
- console.error("No rows left to undo \u2014 closing the import session.");
37675
+ console.error(
37676
+ kept2 > 0 ? `Nothing to delete: the ${approvedRecords(kept2)} left of this import ${kept2 === 1 ? "is" : "are"} kept, since only a person signed in to WayAI removes an approved record \u2014 closing the import session.` : "No rows left to undo \u2014 closing the import session."
37677
+ );
37683
37678
  } else {
37684
- const reviewed = await recordTypeIsReviewed(client, base, plan.record_type);
37685
- const count = `${reviewed ? "up to " : ""}${n} record${n === 1 ? "" : "s"}`;
37686
37679
  const ok = await confirm(
37687
- `Delete ${count} created by this import into "${sanitizeTerminalText(String(plan.record_type))}"${reviewed ? " (those approved now stay unless you are signed in to WayAI as a person)" : ""}, plus every relationship pointing at them?`
37680
+ `Delete ${n} record${n === 1 ? "" : "s"} created by this import into "${sanitizeTerminalText(String(plan.record_type))}"${kept2 > 0 ? ` (${approvedRecords(kept2)} stay: only a person signed in to WayAI removes an approved record)` : ""}, plus every relationship pointing at them?`
37688
37681
  );
37689
37682
  if (!ok) {
37690
37683
  console.error("Aborted.");
@@ -37749,23 +37742,13 @@ Stopped at chunk ${nextIndex}. To resume, re-run the SAME command with:
37749
37742
  });
37750
37743
  return importCmd;
37751
37744
  }
37752
- async function recordTypeIsReviewed(client, base, recordType2) {
37753
- if (recordType2 === null) return false;
37754
- try {
37755
- const type = await client.request(
37756
- "GET",
37757
- `/v1/${base}/record-types/${pathSegment(recordType2, "record_type")}`
37758
- );
37759
- return declaresReview(type?.json_schema);
37760
- } catch {
37761
- return true;
37762
- }
37745
+ function approvedRecords(n) {
37746
+ return `${n} approved record${n === 1 ? "" : "s"}`;
37763
37747
  }
37764
37748
  var MAX_CHUNK_ROWS, MAX_ATTEMPTS, MAX_ROLLBACK_SWEEPS, BASE_BACKOFF_MS, RETRYABLE_CODES, sleep2;
37765
37749
  var init_import = __esm({
37766
37750
  "src/data/commands/import.ts"() {
37767
37751
  "use strict";
37768
- init_rekor_toolset();
37769
37752
  init_client();
37770
37753
  init_output();
37771
37754
  init_helpers();