kanbo-cli 0.1.3 → 0.2.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.
@@ -1926,15 +1926,12 @@ async function approve(store, issueId, input, actor, scope) {
1926
1926
  * leaves even says "returned by you".
1927
1927
  */
1928
1928
  async function returnCard(store, issueId, input, actor, scope) {
1929
- if (actor.kind !== "user") throw new require_migrations_path.BoardError("board_return_requires_user", {
1930
- issueId,
1931
- actorKind: actor.kind
1932
- });
1933
1929
  return await runBoardWrite(store, async ({ tx }) => {
1930
+ await ensureDefaultColumns(tx, (await requireCard$1(tx, issueId)).workspaceId, { tx });
1931
+ const target = await assertReturnable(tx, issueId, input, actor);
1934
1932
  const card = await requireCard$1(tx, issueId);
1935
- const columns = await ensureDefaultColumns(tx, card.workspaceId, { tx });
1936
1933
  const updates = {
1937
- statusId: (input.toStatusName ? await requireColumn(tx, card.workspaceId, input.toStatusName) : previousColumn(columns, card)).id,
1934
+ statusId: target.id,
1938
1935
  waitingFor: null,
1939
1936
  updatedAt: currentUnixSeconds()
1940
1937
  };
@@ -1955,6 +1952,27 @@ async function returnCard(store, issueId, input, actor, scope) {
1955
1952
  };
1956
1953
  }, scope);
1957
1954
  }
1955
+ /**
1956
+ * Every reason `returnCard` would refuse, asked on reads alone, and the column
1957
+ * the card would go back to when none applies.
1958
+ *
1959
+ * `returnCard` asks exactly this inside its write. A caller that has to undo
1960
+ * something of its own before the return — stop listening for the approval the
1961
+ * card is waiting on, say — asks it first, so a return the board refuses leaves
1962
+ * that untouched. The refusals are the same `BoardError` codes: an actor who is
1963
+ * not a person (`board_return_requires_user`), a card that is not there
1964
+ * (`issue_not_found`), a named column the workspace does not hold
1965
+ * (`issue_status_not_found`), and a card already in the first column with no
1966
+ * column named (`board_return_no_previous_column`).
1967
+ */
1968
+ async function assertReturnable(store, issueId, input, actor) {
1969
+ if (actor.kind !== "user") throw new require_migrations_path.BoardError("board_return_requires_user", {
1970
+ issueId,
1971
+ actorKind: actor.kind
1972
+ });
1973
+ const card = await requireCard$1(store, issueId);
1974
+ return input.toStatusName ? await requireColumn(store, card.workspaceId, input.toStatusName) : previousColumn(await listColumns(store, card.workspaceId), card);
1975
+ }
1958
1976
  /** Write a comment on the card, as the actor unless the caller names another author. */
1959
1977
  async function addComment(store, input, actor, scope) {
1960
1978
  return await runBoardWrite(store, async ({ tx }) => {
@@ -2832,6 +2850,7 @@ function createBoardOps(store) {
2832
2850
  waitApproval: async (issueId, input, actor, scope) => await waitApproval(store, issueId, input, actor, scope),
2833
2851
  approve: async (issueId, input, actor, scope) => await approve(store, issueId, input, actor, scope),
2834
2852
  returnCard: async (issueId, input, actor, scope) => await returnCard(store, issueId, input, actor, scope),
2853
+ assertReturnable: async (issueId, input, actor) => await assertReturnable(store, issueId, input, actor),
2835
2854
  readApproval: async (issueId) => await readApproval(store, issueId),
2836
2855
  linkPullRequest: async (issueId, urlOrRef, actor, scope) => await linkPullRequest(store, issueId, urlOrRef, actor, scope),
2837
2856
  unlinkPullRequest: async (issueId, linkId, actor, scope) => await unlinkPullRequest(store, issueId, linkId, actor, scope),
@@ -4334,7 +4353,7 @@ function readRequestedRules(options) {
4334
4353
  * `package.version`. A build carries it as a literal; running from source
4335
4354
  * (tests, `tsx`) reads the package's own `package.json` instead.
4336
4355
  */
4337
- const KANBO_PACKAGE_VERSION = "0.1.3";
4356
+ const KANBO_PACKAGE_VERSION = "0.2.0";
4338
4357
  //#endregion
4339
4358
  //#region src/cli/failure.ts
4340
4359
  /**
@@ -7020,21 +7039,6 @@ function sendBoardPage(response, pathname, assets) {
7020
7039
  * reason turned around: the answer will be yes once the card meets them, and
7021
7040
  * `details.unmet` says what is missing.
7022
7041
  *
7023
- * The five failures about where a board is kept read the same rule. A database
7024
- * that holds no board this build can speak for is 409 — the setting is there,
7025
- * the board behind it is not yet, and `board-storage prepare` is what settles
7026
- * that — and one nobody could reach at all is 503, because nothing about the
7027
- * request was wrong. A workspace naming no board at all is 404: the caller
7028
- * asked about a setting that is not there. A board still holding cards when
7029
- * somebody asks to point the workspace elsewhere is 409, because the answer
7030
- * would have been yes on an empty board and `board-storage migrate` is what
7031
- * makes it one. An operation naming cards from two different boards is 400: no
7032
- * transaction reaches both, so the caller asked for something that cannot be
7033
- * done. A copy that would land on a card number or a column name the target
7034
- * already holds under a different id is 409 for the same reason the others
7035
- * are: the answer would have been yes on a target that did not hold that
7036
- * board, and `details.conflicts` names every value that clashed.
7037
- *
7038
7042
  * A failure may also be renamed here: the package names its codes after the
7039
7043
  * board, while every error the `/issues` routes answer with is named after the
7040
7044
  * issue, and a client matching on `issue_*` should not have to learn a second
@@ -7056,10 +7060,6 @@ const BOARD_ERROR_RESPONSES = {
7056
7060
  message: "The card does not meet what that column asks for yet",
7057
7061
  code: "issue_column_rules_unmet"
7058
7062
  },
7059
- board_copy_conflict: {
7060
- status: 409,
7061
- message: "That board already holds cards or columns of this workspace under the same numbers or names; nothing was copied"
7062
- },
7063
7063
  board_entry_rule_invalid: {
7064
7064
  status: 400,
7065
7065
  message: "Unknown column entry rule"
@@ -7068,10 +7068,6 @@ const BOARD_ERROR_RESPONSES = {
7068
7068
  status: 400,
7069
7069
  message: "Execution mode cannot change once the card has been launched"
7070
7070
  },
7071
- board_mixed_workspaces: {
7072
- status: 400,
7073
- message: "Those cards are not all on the same board"
7074
- },
7075
7071
  board_pull_request_invalid: {
7076
7072
  status: 400,
7077
7073
  message: "Not a GitHub pull request: give its URL or owner/repo#number"
@@ -7131,22 +7127,6 @@ const BOARD_ERROR_RESPONSES = {
7131
7127
  status: 400,
7132
7128
  message: "A sprint cannot start after it is due"
7133
7129
  },
7134
- board_storage_not_configured: {
7135
- status: 404,
7136
- message: "This workspace names no board storage"
7137
- },
7138
- board_storage_not_empty: {
7139
- status: 409,
7140
- message: "That board still holds cards of this workspace; move them with migrate before changing where the board is kept"
7141
- },
7142
- board_storage_not_prepared: {
7143
- status: 409,
7144
- message: "That board has not been prepared yet"
7145
- },
7146
- board_storage_unavailable: {
7147
- status: 503,
7148
- message: "That board could not be reached"
7149
- },
7150
7130
  issue_comment_delete_requires_user: {
7151
7131
  status: 403,
7152
7132
  message: "Only a person can delete a comment the board wrote"
@@ -9368,4 +9348,4 @@ Object.defineProperty(exports, "writeBinding", {
9368
9348
  }
9369
9349
  });
9370
9350
 
9371
- //# sourceMappingURL=manifest-BBJIrMw7.cjs.map
9351
+ //# sourceMappingURL=manifest-RDyoGrVR.cjs.map