@mastra/factory 0.29.0-alpha.4 → 0.29.0-alpha.5
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/README.md +119 -60
- package/dist/boards/board-events.d.ts +89 -9
- package/dist/boards/board-events.d.ts.map +1 -1
- package/dist/boards/board-events.js +176 -13
- package/dist/boards/board-events.js.map +1 -1
- package/dist/boards/board-writes.d.ts.map +1 -1
- package/dist/boards/board-writes.js +14 -1
- package/dist/boards/board-writes.js.map +1 -1
- package/dist/boards/busy-card.d.ts +11 -0
- package/dist/boards/busy-card.d.ts.map +1 -0
- package/dist/boards/busy-card.js +15 -0
- package/dist/boards/busy-card.js.map +1 -0
- package/dist/boards/card-facts.d.ts.map +1 -1
- package/dist/boards/card-facts.js +18 -4
- package/dist/boards/card-facts.js.map +1 -1
- package/dist/boards/index.d.ts +2 -1
- package/dist/boards/index.d.ts.map +1 -1
- package/dist/boards/index.js +3 -2
- package/dist/boards/intake-dry-run.d.ts +109 -0
- package/dist/boards/intake-dry-run.d.ts.map +1 -0
- package/dist/boards/intake-dry-run.js +158 -0
- package/dist/boards/intake-dry-run.js.map +1 -0
- package/dist/boards/intake-lookup.d.ts +32 -0
- package/dist/boards/intake-lookup.d.ts.map +1 -0
- package/dist/boards/intake-lookup.js +12 -0
- package/dist/boards/intake-lookup.js.map +1 -0
- package/dist/boards/intake-order.d.ts +32 -0
- package/dist/boards/intake-order.d.ts.map +1 -0
- package/dist/boards/intake-order.js +60 -0
- package/dist/boards/intake-order.js.map +1 -0
- package/dist/boards/intake-routing.d.ts +246 -35
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js +437 -52
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/reroute.d.ts +7 -3
- package/dist/boards/reroute.d.ts.map +1 -1
- package/dist/boards/reroute.js +21 -4
- package/dist/boards/reroute.js.map +1 -1
- package/dist/boards/semantics.d.ts +8 -28
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +7 -39
- package/dist/boards/semantics.js.map +1 -1
- package/dist/boards/work-routes.d.ts +31 -11
- package/dist/boards/work-routes.d.ts.map +1 -1
- package/dist/boards/work-routes.js +104 -20
- package/dist/boards/work-routes.js.map +1 -1
- package/dist/factory.d.ts +27 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +31 -9
- package/dist/factory.js.map +1 -1
- package/dist/integrations/base.d.ts +9 -0
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/dependabot/rules.js +1 -1
- package/dist/integrations/dependabot/rules.js.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +22 -1
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +23 -5
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/intake-lookup.d.ts +16 -0
- package/dist/integrations/github/intake-lookup.d.ts.map +1 -0
- package/dist/integrations/github/intake-lookup.js +76 -0
- package/dist/integrations/github/intake-lookup.js.map +1 -0
- package/dist/integrations/github/integration.d.ts +19 -5
- package/dist/integrations/github/integration.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +21 -6
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/review-status-reporter.js +1 -1
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +14 -2
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +12 -1
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +218 -30
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +30 -4
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +19 -3
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/intake-lookup.d.ts +17 -0
- package/dist/integrations/gitlab/intake-lookup.d.ts.map +1 -0
- package/dist/integrations/gitlab/intake-lookup.js +85 -0
- package/dist/integrations/gitlab/intake-lookup.js.map +1 -0
- package/dist/integrations/gitlab/integration.d.ts +5 -0
- package/dist/integrations/gitlab/integration.d.ts.map +1 -1
- package/dist/integrations/gitlab/integration.js +21 -1
- package/dist/integrations/gitlab/integration.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts +20 -0
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +108 -12
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +14 -4
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +12 -2
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +13 -2
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +9 -1
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +6 -6
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +22 -3
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/pull-request-head.d.ts +1 -1
- package/dist/integrations/pull-request-head.d.ts.map +1 -1
- package/dist/integrations/pull-request-head.js +5 -0
- package/dist/integrations/pull-request-head.js.map +1 -1
- package/dist/integrations/vanta/rules.js +1 -1
- package/dist/integrations/vanta/rules.js.map +1 -1
- package/dist/routes/board-snapshot.d.ts +8 -1
- package/dist/routes/board-snapshot.d.ts.map +1 -1
- package/dist/routes/board-snapshot.js +33 -7
- package/dist/routes/board-snapshot.js.map +1 -1
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/config.d.ts +6 -0
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +5 -2
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +1258 -0
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +586 -13
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/intake-check.d.ts +92 -0
- package/dist/routes/intake-check.d.ts.map +1 -0
- package/dist/routes/intake-check.js +322 -0
- package/dist/routes/intake-check.js.map +1 -0
- package/dist/routes/intake-routes.d.ts +10 -2
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +292 -11
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/mastra-gateway.d.ts.map +1 -1
- package/dist/routes/mastra-gateway.js +3 -2
- package/dist/routes/mastra-gateway.js.map +1 -1
- package/dist/routes/project-sessions.d.ts +49 -0
- package/dist/routes/project-sessions.d.ts.map +1 -0
- package/dist/routes/project-sessions.js +93 -0
- package/dist/routes/project-sessions.js.map +1 -0
- package/dist/routes/run-queue.d.ts +6 -6
- package/dist/routes/run-queue.d.ts.map +1 -1
- package/dist/routes/run-queue.js +28 -8
- package/dist/routes/run-queue.js.map +1 -1
- package/dist/routes/session-rows.d.ts +30 -0
- package/dist/routes/session-rows.d.ts.map +1 -0
- package/dist/routes/session-rows.js +98 -0
- package/dist/routes/session-rows.js.map +1 -0
- package/dist/routes/source-control-sessions.d.ts +4 -5
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +8 -87
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/surface.d.ts +13 -1
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +24 -26
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/work-item-starters.d.ts +1 -0
- package/dist/routes/work-item-starters.d.ts.map +1 -1
- package/dist/routes/work-item-starters.js +14 -2
- package/dist/routes/work-item-starters.js.map +1 -1
- package/dist/routes/work-items.d.ts +13 -0
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +87 -34
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/dispatch-errors.js +1 -1
- package/dist/rules/dispatch-errors.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +39 -7
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +361 -122
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/event-rules.d.ts +69 -1
- package/dist/rules/event-rules.d.ts.map +1 -1
- package/dist/rules/event-rules.js +151 -5
- package/dist/rules/event-rules.js.map +1 -1
- package/dist/rules/review-source-tool.js +1 -1
- package/dist/rules/rule-group.d.ts +18 -1
- package/dist/rules/rule-group.d.ts.map +1 -1
- package/dist/rules/rule-group.js +52 -8
- package/dist/rules/rule-group.js.map +1 -1
- package/dist/rules/run-bearing.d.ts +8 -0
- package/dist/rules/run-bearing.d.ts.map +1 -0
- package/dist/rules/run-bearing.js +11 -0
- package/dist/rules/run-bearing.js.map +1 -0
- package/dist/rules/start-coordinator.d.ts +2 -3
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +26 -34
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.js +2 -1
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.d.ts +16 -0
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +34 -10
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +18 -5
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +2 -1
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/update-fold.d.ts +32 -0
- package/dist/rules/update-fold.d.ts.map +1 -0
- package/dist/rules/update-fold.js +60 -0
- package/dist/rules/update-fold.js.map +1 -0
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +54 -6
- package/dist/rules/validation.js.map +1 -1
- package/dist/session/resource-migration.d.ts.map +1 -1
- package/dist/session/resource-migration.js +2 -3
- package/dist/session/resource-migration.js.map +1 -1
- package/dist/session/run-audit.d.ts +9 -0
- package/dist/session/run-audit.d.ts.map +1 -1
- package/dist/session/run-audit.js +9 -1
- package/dist/session/run-audit.js.map +1 -1
- package/dist/session/self-review-gate.d.ts +26 -2
- package/dist/session/self-review-gate.d.ts.map +1 -1
- package/dist/session/self-review-gate.js +60 -10
- package/dist/session/self-review-gate.js.map +1 -1
- package/dist/session/session-row-query.d.ts +25 -0
- package/dist/session/session-row-query.d.ts.map +1 -0
- package/dist/session/session-row-query.js +47 -0
- package/dist/session/session-row-query.js.map +1 -0
- package/dist/session/session-row-status.d.ts +16 -0
- package/dist/session/session-row-status.d.ts.map +1 -0
- package/dist/session/session-row-status.js +14 -0
- package/dist/session/session-row-status.js.map +1 -0
- package/dist/session/session-row-view.d.ts +14 -0
- package/dist/session/session-row-view.d.ts.map +1 -0
- package/dist/session/session-row-view.js +125 -0
- package/dist/session/session-row-view.js.map +1 -0
- package/dist/session/session-rows.d.ts +46 -0
- package/dist/session/session-rows.d.ts.map +1 -0
- package/dist/session/session-rows.js +232 -0
- package/dist/session/session-rows.js.map +1 -0
- package/dist/session/session-threads.d.ts.map +1 -1
- package/dist/session/session-threads.js +1 -0
- package/dist/session/session-threads.js.map +1 -1
- package/dist/session/source-control-tools.d.ts +14 -7
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +10 -2
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/session/work-item-repository.d.ts +44 -0
- package/dist/session/work-item-repository.d.ts.map +1 -1
- package/dist/session/work-item-repository.js +80 -1
- package/dist/session/work-item-repository.js.map +1 -1
- package/dist/session/work-item-state-processor.d.ts.map +1 -1
- package/dist/session/work-item-state-processor.js +44 -8
- package/dist/session/work-item-state-processor.js.map +1 -1
- package/dist/storage/domains/audit/actions.d.ts +2 -1
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +3 -1
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +162 -14
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +415 -41
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/boards/schemas.d.ts +6 -0
- package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
- package/dist/storage/domains/boards/schemas.js +95 -1
- package/dist/storage/domains/boards/schemas.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +19 -10
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +5 -2
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +48 -17
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +128 -75
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +3 -2
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
- package/dist/storage/domains/work-items/cards.js +4 -2
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- package/dist/storage/probed-list.d.ts +11 -0
- package/dist/storage/probed-list.d.ts.map +1 -0
- package/dist/storage/probed-list.js +52 -0
- package/dist/storage/probed-list.js.map +1 -0
- package/dist/tools/audit-events-tool.d.ts +2 -2
- package/dist/tools/read-tools.d.ts +0 -3
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +4 -42
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +5 -9
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/work-item-tools.d.ts +3 -0
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +8 -4
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/work-item-branch.d.ts +4 -0
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +7 -1
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/card-context-sessions.d.ts +50 -0
- package/dist/work-items/card-context-sessions.d.ts.map +1 -0
- package/dist/work-items/card-context-sessions.js +84 -0
- package/dist/work-items/card-context-sessions.js.map +1 -0
- package/dist/work-items/change-requests.d.ts +87 -0
- package/dist/work-items/change-requests.d.ts.map +1 -0
- package/dist/work-items/change-requests.js +134 -0
- package/dist/work-items/change-requests.js.map +1 -0
- package/dist/work-items/create-work-item.d.ts +7 -2
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +44 -13
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/work-items/list-related-cards.d.ts.map +1 -1
- package/dist/work-items/list-related-cards.js +1 -1
- package/dist/work-items/list-related-cards.js.map +1 -1
- package/dist/work-items/providers/github.d.ts.map +1 -1
- package/dist/work-items/providers/github.js +1 -0
- package/dist/work-items/providers/github.js.map +1 -1
- package/factory-skills/factory-build/SKILL.md +1 -1
- package/factory-skills/factory-plan/SKILL.md +5 -3
- package/factory-skills/factory-self-review/SKILL.md +2 -0
- package/factory-skills/factory-triage/SKILL.md +1 -1
- package/package.json +8 -8
package/dist/routes/contracts.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { INTAKE_ROUTE_RULE_FIELDS, STATUS_EVENTS, routeEventsProblem } from "../boards/board-events.js";
|
|
1
|
+
import { CLOSE_REASONS, INTAKE_ROUTE_RULE_FIELDS, ROUTE_EVENTS, STATUS_EVENTS, routeEventsProblem } from "../boards/board-events.js";
|
|
2
2
|
import { storedBoardDefinitionSchema, storedBoardInputSchema, storedPhaseInputSchema } from "../boards/stored-board.js";
|
|
3
3
|
import { cardRuleGroupSchema, ruleGroupSchema } from "../rules/rule-group.js";
|
|
4
4
|
import { BOARD_IDENTIFIER_RE } from "../rules/validation.js";
|
|
5
|
+
import { SESSION_ROW_GROUP_BYS, SESSION_ROW_SORTS, SESSION_ROW_STATUSES, SESSION_ROW_UPDATED_WITHIN, sessionRowOwnerSchema } from "../session/session-row-query.js";
|
|
5
6
|
import "../storage/domains/boards/base.js";
|
|
6
7
|
import { FACTORY_MODEL_SCOPES } from "../storage/domains/projects/base.js";
|
|
8
|
+
import { PULL_REQUEST_STATUSES } from "../work-items/change-requests.js";
|
|
7
9
|
import { validateSkillContent } from "@mastra/core/skills";
|
|
8
10
|
import { z } from "zod";
|
|
9
11
|
import { THINKING_LEVEL_VALUES } from "@mastra/code-sdk/thinking";
|
|
@@ -80,7 +82,12 @@ const intakeRouteTargetSchema = z.object({
|
|
|
80
82
|
* File a pull request on the card of the issue it closes (on `boardKey`) instead of a new card;
|
|
81
83
|
* that card moves to `phaseKey` when its board allows it. Matches no other arrival.
|
|
82
84
|
*/
|
|
83
|
-
joinClosedIssue: z.boolean().optional()
|
|
85
|
+
joinClosedIssue: z.boolean().optional(),
|
|
86
|
+
/**
|
|
87
|
+
* On a route moving existing cards on later events, the board the card moves to, at `phaseKey`;
|
|
88
|
+
* `boardKey` stays the board whose cards the route moves. Unset keeps the card on `boardKey`.
|
|
89
|
+
*/
|
|
90
|
+
moveToBoardKey: boardIdentifierSchema.nullable().optional()
|
|
84
91
|
}).strict();
|
|
85
92
|
const intakeRouteWhenSchema = ruleGroupSchema(INTAKE_ROUTE_RULE_FIELDS);
|
|
86
93
|
const intakeRouteFields = {
|
|
@@ -90,8 +97,12 @@ const intakeRouteFields = {
|
|
|
90
97
|
when: intakeRouteWhenSchema.nullable(),
|
|
91
98
|
/** Where matching cards land. */
|
|
92
99
|
target: intakeRouteTargetSchema,
|
|
93
|
-
/**
|
|
94
|
-
|
|
100
|
+
/**
|
|
101
|
+
* The events the route handles. `work_item.opened` files new issues and `pull_request.opened` new
|
|
102
|
+
* pull requests with no card (and moves the card of an issue whose pull request opens); the others
|
|
103
|
+
* move existing cards. `work_item.created`, the legacy event, files both and is kept as written.
|
|
104
|
+
*/
|
|
105
|
+
on: z.array(z.enum(ROUTE_EVENTS, { error: (issue) => routeEventsProblem([String(issue.input)], null) ?? void 0 })).superRefine((on, ctx) => {
|
|
95
106
|
const problem = routeEventsProblem(on, null);
|
|
96
107
|
if (problem) ctx.addIssue({
|
|
97
108
|
code: "custom",
|
|
@@ -104,7 +115,9 @@ const intakeRouteInputSchema = z.object({
|
|
|
104
115
|
enabled: intakeRouteFields.enabled.default(true),
|
|
105
116
|
when: intakeRouteFields.when.default(null),
|
|
106
117
|
target: intakeRouteFields.target,
|
|
107
|
-
on: intakeRouteFields.on.optional()
|
|
118
|
+
on: intakeRouteFields.on.optional(),
|
|
119
|
+
/** Restores a route read with `pullRequestOpenedMovesOnly` as it was: moving cards on `pull_request.opened`, filing none. */
|
|
120
|
+
pullRequestOpenedMovesOnly: z.literal(true).optional()
|
|
108
121
|
}).strict();
|
|
109
122
|
/** Changes the named fields; send the `revision` you read so a concurrent edit is not overwritten. */
|
|
110
123
|
const intakeRoutePatchSchema = z.object({
|
|
@@ -115,9 +128,17 @@ const intakeRoutePatchSchema = z.object({
|
|
|
115
128
|
on: intakeRouteFields.on.optional(),
|
|
116
129
|
expectedRevision: boardRevisionSchema
|
|
117
130
|
}).strict().refine(({ expectedRevision: _revision, ...fields }) => Object.values(fields).some((value) => value !== void 0), { message: "Change at least one field." });
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
131
|
+
/** Bounds a whole-project reorder, which names every rule of every board. */
|
|
132
|
+
const MAX_PROJECT_INTAKE_ROUTES = 1e4;
|
|
133
|
+
const intakeRouteReorderBodySchema = z.object({
|
|
134
|
+
/** Reorders only this board's rules, within the places they hold; omitted, the whole project's. */
|
|
135
|
+
boardKey: z.string().min(1).max(128).optional(),
|
|
136
|
+
/** Every rule of the board (or of the project), once each, in the new order. */
|
|
137
|
+
ids: z.array(uuidSchema).min(1).max(MAX_PROJECT_INTAKE_ROUTES).refine((ids) => new Set(ids).size === ids.length, { message: "Each route may appear only once." })
|
|
138
|
+
}).strict().refine(({ boardKey, ids }) => boardKey === void 0 || ids.length <= 100, {
|
|
139
|
+
message: `A board has at most 100 intake rules.`,
|
|
140
|
+
path: ["ids"]
|
|
141
|
+
});
|
|
121
142
|
const intakeRouteSchema = z.object({
|
|
122
143
|
id: z.string(),
|
|
123
144
|
name: z.string(),
|
|
@@ -128,9 +149,15 @@ const intakeRouteSchema = z.object({
|
|
|
128
149
|
target: z.object({
|
|
129
150
|
boardKey: z.string(),
|
|
130
151
|
phaseKey: z.string().nullable(),
|
|
131
|
-
joinClosedIssue: z.boolean()
|
|
152
|
+
joinClosedIssue: z.boolean(),
|
|
153
|
+
moveToBoardKey: z.string().nullable()
|
|
132
154
|
}),
|
|
133
|
-
on: z.array(z.enum(
|
|
155
|
+
on: z.array(z.enum(ROUTE_EVENTS)),
|
|
156
|
+
/**
|
|
157
|
+
* True on a route stored by 0.28 naming `pull_request.opened`: there it only moves a card, and
|
|
158
|
+
* files no pull request, through every edit. Add a route to file pull requests.
|
|
159
|
+
*/
|
|
160
|
+
pullRequestOpenedMovesOnly: z.literal(true).optional(),
|
|
134
161
|
/** Send it back as `expectedRevision` when editing or deleting. */
|
|
135
162
|
revision: z.number().int(),
|
|
136
163
|
createdBy: z.string(),
|
|
@@ -158,6 +185,333 @@ const intakeRerouteApplyResponseSchema = z.object({
|
|
|
158
185
|
moved: z.number().int(),
|
|
159
186
|
skipped: z.number().int()
|
|
160
187
|
});
|
|
188
|
+
const intakeRouteListQuerySchema = z.object({
|
|
189
|
+
/** Lists only this board's rules, in their order. */
|
|
190
|
+
boardKey: z.string().min(1).max(128).optional() }).strict();
|
|
191
|
+
const intakeOrderResponseSchema = z.object({
|
|
192
|
+
/** Every board of the project, in the order intake asks them. */
|
|
193
|
+
boards: z.array(z.object({
|
|
194
|
+
boardKey: z.string(),
|
|
195
|
+
name: z.string()
|
|
196
|
+
})),
|
|
197
|
+
/**
|
|
198
|
+
* `derived` follows the rule list until an admin sets the order; then it is `explicit`. A project
|
|
199
|
+
* created with intake order has its own order from the start, so it is `explicit` from the start.
|
|
200
|
+
*/
|
|
201
|
+
origin: z.enum(["derived", "explicit"]),
|
|
202
|
+
/** Which evaluator places the project's new items now: `route-list` (the old one) or `intake-order`. */
|
|
203
|
+
evaluator: z.enum(["route-list", "intake-order"]),
|
|
204
|
+
/**
|
|
205
|
+
* What decided `evaluator`: the Factory's `intake.evaluator` option or `FACTORY_INTAKE_EVALUATOR`
|
|
206
|
+
* (forced on every project), the project's own setting, or none (a project from before the
|
|
207
|
+
* setting, on `route-list`).
|
|
208
|
+
*/
|
|
209
|
+
evaluatorSource: z.enum([
|
|
210
|
+
"option",
|
|
211
|
+
"env",
|
|
212
|
+
"project",
|
|
213
|
+
"legacy"
|
|
214
|
+
]),
|
|
215
|
+
/** The project's own setting, used unless one is forced; null for a project from before the setting. */
|
|
216
|
+
projectEvaluator: z.enum(["route-list", "intake-order"]).nullable(),
|
|
217
|
+
/** Both evaluators run over the project's newest 200 items against this order, worked out on each read. */
|
|
218
|
+
comparison: z.object({
|
|
219
|
+
compared: z.number().int(),
|
|
220
|
+
differing: z.number().int(),
|
|
221
|
+
notRouted: z.number().int()
|
|
222
|
+
}),
|
|
223
|
+
/** Whether the caller may change the order. */
|
|
224
|
+
canEdit: z.boolean()
|
|
225
|
+
});
|
|
226
|
+
const intakeOrderBodySchema = z.object({
|
|
227
|
+
/** Every board of the project, once each, in the new order. */
|
|
228
|
+
boardKeys: z.array(z.string().min(1).max(128)).min(1).max(MAX_PROJECT_INTAKE_ROUTES).refine((keys) => new Set(keys).size === keys.length, { message: "Each board may appear only once." }).optional(),
|
|
229
|
+
/** Switches the project's evaluator; a forced one still wins until it is unset. */
|
|
230
|
+
evaluator: z.enum(["route-list", "intake-order"]).optional()
|
|
231
|
+
}).strict().refine((body) => body.boardKeys !== void 0 || body.evaluator !== void 0, { message: "Name the boardKeys, the evaluator, or both." });
|
|
232
|
+
const intakeDecisionSchema = z.object({
|
|
233
|
+
id: z.string(),
|
|
234
|
+
outcome: z.enum([
|
|
235
|
+
"placed",
|
|
236
|
+
"not_routed",
|
|
237
|
+
"rule_skipped",
|
|
238
|
+
"rule_retired"
|
|
239
|
+
]),
|
|
240
|
+
evaluator: z.enum(["route-list", "intake-order"]),
|
|
241
|
+
boardKey: z.string().nullable(),
|
|
242
|
+
routeId: z.string().nullable(),
|
|
243
|
+
/** Why no board took it. */
|
|
244
|
+
reason: z.string().nullable(),
|
|
245
|
+
sourceKey: z.string().nullable(),
|
|
246
|
+
title: z.string(),
|
|
247
|
+
url: z.string().nullable(),
|
|
248
|
+
decidedAt: z.string()
|
|
249
|
+
});
|
|
250
|
+
const intakeNotRoutedQuerySchema = z.object({
|
|
251
|
+
limit: z.coerce.number().int().min(1).max(100).optional(),
|
|
252
|
+
/** The `nextCursor` of the page before. */
|
|
253
|
+
cursor: z.string().min(1).max(200).optional()
|
|
254
|
+
}).strict();
|
|
255
|
+
const intakeNotRoutedResponseSchema = z.object({
|
|
256
|
+
/** Oldest first. */
|
|
257
|
+
notRouted: z.array(intakeDecisionSchema),
|
|
258
|
+
/** Pass as `cursor` for the next page; null on the last. */
|
|
259
|
+
nextCursor: z.string().nullable(),
|
|
260
|
+
/** Whether the caller may route an item again. */
|
|
261
|
+
canEdit: z.boolean()
|
|
262
|
+
});
|
|
263
|
+
const intakeSkippedResponseSchema = z.object({
|
|
264
|
+
/** Card-move rules that matched but whose target couldn't take the card, in the last 30 days. */
|
|
265
|
+
skipped: z.array(z.object({
|
|
266
|
+
routeId: z.string(),
|
|
267
|
+
count: z.number().int(),
|
|
268
|
+
latest: intakeDecisionSchema
|
|
269
|
+
})) });
|
|
270
|
+
const intakeDecisionPathSchema = z.object({
|
|
271
|
+
id: uuidSchema,
|
|
272
|
+
decisionId: uuidSchema
|
|
273
|
+
});
|
|
274
|
+
const intakeRouteAgainResponseSchema = z.object({
|
|
275
|
+
/** The item is queued to be filed here; the card appears once the dispatcher files it. */
|
|
276
|
+
status: z.literal("queued"),
|
|
277
|
+
boardKey: z.string(),
|
|
278
|
+
phaseKey: z.string(),
|
|
279
|
+
routeId: z.string()
|
|
280
|
+
});
|
|
281
|
+
/** A board's rules as edited, not saved yet: they stand in for all of that board's rules. */
|
|
282
|
+
const intakeDraftBoardSchema = z.object({
|
|
283
|
+
boardKey: z.string().min(1).max(128),
|
|
284
|
+
routes: z.array(z.object({
|
|
285
|
+
/** The saved rule this edits, so its counts line up; omitted for a new rule. */
|
|
286
|
+
id: uuidSchema.optional(),
|
|
287
|
+
name: intakeRouteFields.name,
|
|
288
|
+
enabled: intakeRouteFields.enabled.default(true),
|
|
289
|
+
when: intakeRouteFields.when.default(null),
|
|
290
|
+
target: z.object({
|
|
291
|
+
phaseKey: z.string().min(1).max(128).nullable().optional(),
|
|
292
|
+
/** On a card-move rule: the board the card moves to; unset keeps it on this board. */
|
|
293
|
+
moveToBoardKey: intakeRouteTargetSchema.shape.moveToBoardKey,
|
|
294
|
+
/** On a pull request rule: join the card of the issue it closes, as the saved rule does. */
|
|
295
|
+
joinClosedIssue: z.boolean().optional()
|
|
296
|
+
}).strict(),
|
|
297
|
+
on: intakeRouteFields.on.optional()
|
|
298
|
+
}).strict()).max(100)
|
|
299
|
+
}).strict();
|
|
300
|
+
const intakeDraftFields = {
|
|
301
|
+
/** Unsaved rules, board by board; boards not named run their saved rules. */
|
|
302
|
+
boards: z.array(intakeDraftBoardSchema).max(MAX_PROJECT_INTAKE_ROUTES).refine((boards) => new Set(boards.map((board) => board.boardKey)).size === boards.length, { message: "Each board may appear only once." }).optional(),
|
|
303
|
+
/** An unsaved intake order; omitted, the saved one. */
|
|
304
|
+
order: intakeOrderBodySchema.shape.boardKeys.optional()
|
|
305
|
+
};
|
|
306
|
+
const intakeDryRunBodySchema = z.object(intakeDraftFields).strict();
|
|
307
|
+
const intakePlacementSchema = z.object({
|
|
308
|
+
boardKey: z.string(),
|
|
309
|
+
routeId: z.string(),
|
|
310
|
+
phase: z.string()
|
|
311
|
+
});
|
|
312
|
+
const intakeKeysByBoardSchema = z.array(z.object({
|
|
313
|
+
boardKey: z.string(),
|
|
314
|
+
keys: z.array(z.string())
|
|
315
|
+
}));
|
|
316
|
+
const intakeDryRunResponseSchema = z.object({
|
|
317
|
+
/**
|
|
318
|
+
* The evaluator that files this project's items. Both endpoints always answer as `intake-order`;
|
|
319
|
+
* under `route-list` filing can land items elsewhere, such as on the default board.
|
|
320
|
+
*/
|
|
321
|
+
evaluator: z.enum(["route-list", "intake-order"]),
|
|
322
|
+
/** How many of the project's newest items (at most 200) were decided, from their stored facts. */
|
|
323
|
+
sampled: z.number().int(),
|
|
324
|
+
/** Every board in intake order, with what it and each of its rules would take. */
|
|
325
|
+
boards: z.array(z.object({
|
|
326
|
+
boardKey: z.string(),
|
|
327
|
+
name: z.string(),
|
|
328
|
+
/** Keys of the items the board would take. */
|
|
329
|
+
takes: z.array(z.string()),
|
|
330
|
+
/** Items its rules matched that another board took first, by that board. */
|
|
331
|
+
lostTo: intakeKeysByBoardSchema,
|
|
332
|
+
rules: z.array(z.object({
|
|
333
|
+
/** A rule not saved yet reads `draft:<boardKey>:<index>`. */
|
|
334
|
+
routeId: z.string(),
|
|
335
|
+
name: z.string().nullable(),
|
|
336
|
+
enabled: z.boolean(),
|
|
337
|
+
takes: z.array(z.string()),
|
|
338
|
+
/** Items it matched but an earlier rule took, by the board that took them. */
|
|
339
|
+
lost: intakeKeysByBoardSchema,
|
|
340
|
+
/** Cards it actually filed in the last 30 days. */
|
|
341
|
+
filed: z.number().int()
|
|
342
|
+
}))
|
|
343
|
+
})),
|
|
344
|
+
/** Keys of the items no board would take. */
|
|
345
|
+
notRouted: z.array(z.string()),
|
|
346
|
+
/** With unsaved rules or order: how many items land somewhere other than the saved ones put them. */
|
|
347
|
+
changed: z.number().int().optional(),
|
|
348
|
+
items: z.array(z.object({
|
|
349
|
+
key: z.string(),
|
|
350
|
+
/** The card's id, or the Not routed decision's. */
|
|
351
|
+
id: z.string(),
|
|
352
|
+
kind: z.enum(["card", "not_routed"]),
|
|
353
|
+
title: z.string(),
|
|
354
|
+
url: z.string().nullable(),
|
|
355
|
+
placement: intakePlacementSchema.nullable(),
|
|
356
|
+
/** Every rule that matched and could take it, in the order intake asked them; the first won. */
|
|
357
|
+
matched: z.array(z.object({
|
|
358
|
+
boardKey: z.string(),
|
|
359
|
+
routeId: z.string()
|
|
360
|
+
})),
|
|
361
|
+
/** With unsaved rules or order: where the saved ones put it. */
|
|
362
|
+
before: intakePlacementSchema.nullable().optional()
|
|
363
|
+
})),
|
|
364
|
+
/** Whether the caller may run unsaved rules or order. */
|
|
365
|
+
canEdit: z.boolean()
|
|
366
|
+
});
|
|
367
|
+
/** The most labels or assignees one test event may name on each side. */
|
|
368
|
+
const MAX_TEST_EVENT_NAMES = 100;
|
|
369
|
+
const itemChangeSchema = z.object({
|
|
370
|
+
added: z.array(z.string().min(1).max(500)).max(MAX_TEST_EVENT_NAMES).default([]),
|
|
371
|
+
removed: z.array(z.string().min(1).max(500)).max(MAX_TEST_EVENT_NAMES).default([])
|
|
372
|
+
}).strict();
|
|
373
|
+
/** A status event as card-move rules read it. */
|
|
374
|
+
const intakeTestEventSchema = z.object({
|
|
375
|
+
type: z.enum(STATUS_EVENTS),
|
|
376
|
+
/** On `work_item.closed`. */
|
|
377
|
+
reason: z.enum(CLOSE_REASONS).optional(),
|
|
378
|
+
/** On an update: the labels and assignees it changed. */
|
|
379
|
+
labels: itemChangeSchema.optional(),
|
|
380
|
+
assignees: itemChangeSchema.optional(),
|
|
381
|
+
/** On a pull request event: whether that pull request's author is trusted. */
|
|
382
|
+
pullRequestTrusted: z.boolean().optional()
|
|
383
|
+
}).strict();
|
|
384
|
+
const intakeTestBodySchema = z.object({
|
|
385
|
+
...intakeDraftFields,
|
|
386
|
+
/** An issue or pull request URL; one the Factory has never seen is fetched once, read-only, from a linked source. */
|
|
387
|
+
url: z.string().trim().url().max(2e3).optional(),
|
|
388
|
+
/** A recent item: a card's id, or a Not routed decision's. */
|
|
389
|
+
itemId: uuidSchema.optional(),
|
|
390
|
+
/** A status event to try on the item's card, as if it had just happened; its recent events are replayed either way. */
|
|
391
|
+
event: intakeTestEventSchema.optional()
|
|
392
|
+
}).strict().refine((body) => body.url === void 0 !== (body.itemId === void 0), { message: "Send either a url or an itemId." });
|
|
393
|
+
const failedConditionSchema = z.object({
|
|
394
|
+
field: z.string(),
|
|
395
|
+
operator: z.string(),
|
|
396
|
+
value: z.unknown().optional(),
|
|
397
|
+
/** The item's value for the field; null when it has none. */
|
|
398
|
+
actual: z.unknown()
|
|
399
|
+
});
|
|
400
|
+
const intakeTestResponseSchema = z.object({
|
|
401
|
+
item: z.object({
|
|
402
|
+
title: z.string(),
|
|
403
|
+
url: z.string().nullable(),
|
|
404
|
+
/** `card` and `not_routed` are items the Factory has; `fetched` was read from its provider for this test. */
|
|
405
|
+
kind: z.enum([
|
|
406
|
+
"card",
|
|
407
|
+
"not_routed",
|
|
408
|
+
"fetched"
|
|
409
|
+
]),
|
|
410
|
+
id: z.string().nullable()
|
|
411
|
+
}),
|
|
412
|
+
placement: intakePlacementSchema.nullable(),
|
|
413
|
+
/** Why no board takes it. */
|
|
414
|
+
reason: z.string().nullable(),
|
|
415
|
+
/** What this answer leaves out, such as a fetched pull request joining an existing card instead. */
|
|
416
|
+
note: z.string().nullable(),
|
|
417
|
+
/**
|
|
418
|
+
* The evaluator that files this project's items. Both endpoints always answer as `intake-order`;
|
|
419
|
+
* under `route-list` filing can land items elsewhere, such as on the default board.
|
|
420
|
+
*/
|
|
421
|
+
evaluator: z.enum(["route-list", "intake-order"]),
|
|
422
|
+
/** Every board in intake order and every placing rule on it, with what it answered. */
|
|
423
|
+
boards: z.array(z.object({
|
|
424
|
+
boardKey: z.string(),
|
|
425
|
+
name: z.string(),
|
|
426
|
+
rules: z.array(z.object({
|
|
427
|
+
routeId: z.string(),
|
|
428
|
+
name: z.string().nullable(),
|
|
429
|
+
phase: z.string(),
|
|
430
|
+
/** `took` decides; `lost` matched after the rule that took it; `phase_refuses` matched but its phase can't hold the item. */
|
|
431
|
+
outcome: z.enum([
|
|
432
|
+
"took",
|
|
433
|
+
"lost",
|
|
434
|
+
"no_match",
|
|
435
|
+
"phase_refuses",
|
|
436
|
+
"disabled"
|
|
437
|
+
]),
|
|
438
|
+
/** With `no_match`: the conditions it failed on. */
|
|
439
|
+
failed: z.array(failedConditionSchema).optional(),
|
|
440
|
+
/** With `lost`: the rule that took it. */
|
|
441
|
+
to: z.object({
|
|
442
|
+
boardKey: z.string(),
|
|
443
|
+
routeId: z.string()
|
|
444
|
+
}).optional()
|
|
445
|
+
}))
|
|
446
|
+
})),
|
|
447
|
+
/** On a card: where it is now, and the intake rule that filed it, if one did. */
|
|
448
|
+
current: z.object({
|
|
449
|
+
boardKey: z.string(),
|
|
450
|
+
phase: z.string().nullable(),
|
|
451
|
+
routeId: z.string().nullable()
|
|
452
|
+
}).nullable(),
|
|
453
|
+
/**
|
|
454
|
+
* On a card: the event sent in the request, then its recent status events newest first, each
|
|
455
|
+
* replayed against today's rules (or the draft) and the card as it is now.
|
|
456
|
+
*/
|
|
457
|
+
moves: z.array(z.object({
|
|
458
|
+
/** The stored event's decision; null for the event sent in the request. */
|
|
459
|
+
decisionId: z.string().nullable(),
|
|
460
|
+
at: z.string().nullable(),
|
|
461
|
+
event: z.object({
|
|
462
|
+
type: z.enum(STATUS_EVENTS),
|
|
463
|
+
reason: z.enum(CLOSE_REASONS).optional(),
|
|
464
|
+
labels: z.object({
|
|
465
|
+
added: z.array(z.string()),
|
|
466
|
+
removed: z.array(z.string())
|
|
467
|
+
}).optional(),
|
|
468
|
+
assignees: z.object({
|
|
469
|
+
added: z.array(z.string()),
|
|
470
|
+
removed: z.array(z.string())
|
|
471
|
+
}).optional(),
|
|
472
|
+
pullRequestTrusted: z.boolean().optional()
|
|
473
|
+
}),
|
|
474
|
+
/**
|
|
475
|
+
* `moves` to `to`; `stays` where it is; `rule_default` leaves it to the integration's own move
|
|
476
|
+
* (to `phase`, when there is one) because no rule takes it; `ignored` when the event can't move
|
|
477
|
+
* a card in its state, with `reason`; `unknown` when an update burst reaches back past the
|
|
478
|
+
* history read, with `reason`.
|
|
479
|
+
*/
|
|
480
|
+
outcome: z.enum([
|
|
481
|
+
"moves",
|
|
482
|
+
"stays",
|
|
483
|
+
"rule_default",
|
|
484
|
+
"ignored",
|
|
485
|
+
"unknown"
|
|
486
|
+
]),
|
|
487
|
+
to: z.object({
|
|
488
|
+
boardKey: z.string(),
|
|
489
|
+
phase: z.string(),
|
|
490
|
+
routeId: z.string()
|
|
491
|
+
}).nullable(),
|
|
492
|
+
phase: z.string().nullable(),
|
|
493
|
+
reason: z.string().nullable(),
|
|
494
|
+
/** Every rule on the card's board that handles the event, top to bottom. */
|
|
495
|
+
rules: z.array(z.object({
|
|
496
|
+
routeId: z.string(),
|
|
497
|
+
name: z.string().nullable(),
|
|
498
|
+
/** `skipped` matched but its target board or phase can't take the card, with `reason`. */
|
|
499
|
+
outcome: z.enum([
|
|
500
|
+
"took",
|
|
501
|
+
"lost",
|
|
502
|
+
"no_match",
|
|
503
|
+
"skipped",
|
|
504
|
+
"disabled"
|
|
505
|
+
]),
|
|
506
|
+
failed: z.array(failedConditionSchema).optional(),
|
|
507
|
+
to: z.object({
|
|
508
|
+
boardKey: z.string(),
|
|
509
|
+
routeId: z.string()
|
|
510
|
+
}).optional(),
|
|
511
|
+
reason: z.string().optional()
|
|
512
|
+
}))
|
|
513
|
+
}))
|
|
514
|
+
});
|
|
161
515
|
const workItemPathSchema = z.object({ id: uuidSchema });
|
|
162
516
|
const transitionPathSchema = z.object({
|
|
163
517
|
id: uuidSchema,
|
|
@@ -201,6 +555,12 @@ const runQueueEntrySchema = z.object({
|
|
|
201
555
|
"sendMessage",
|
|
202
556
|
"signalActivity"
|
|
203
557
|
]),
|
|
558
|
+
/**
|
|
559
|
+
* `interactive`: a reply a person sent on the card's pull request or issue,
|
|
560
|
+
* claimed ahead of automated runs into its own reserve of slots.
|
|
561
|
+
* `automated`: everything else.
|
|
562
|
+
*/
|
|
563
|
+
lane: z.enum(["automated", "interactive"]),
|
|
204
564
|
role: z.string().nullable(),
|
|
205
565
|
/** The skill an `invokeSkill` run starts; `null` for a prompt run and for messages and activity. */
|
|
206
566
|
skillName: z.string().nullable(),
|
|
@@ -218,14 +578,29 @@ const runQueueResponseSchema = z.object({
|
|
|
218
578
|
/** This server process's run slots; `null` when it runs no dispatcher. Other servers keep their own. */
|
|
219
579
|
slots: z.object({
|
|
220
580
|
scope: z.literal("server"),
|
|
581
|
+
/** Automated run slots, including any a person's reply borrowed once its reserve was full. */
|
|
221
582
|
inUse: z.number().int(),
|
|
222
|
-
cap: z.number().int()
|
|
583
|
+
cap: z.number().int(),
|
|
584
|
+
/** Slots kept for people's replies, on top of `cap`. */
|
|
585
|
+
interactive: z.object({
|
|
586
|
+
inUse: z.number().int(),
|
|
587
|
+
cap: z.number().int()
|
|
588
|
+
})
|
|
223
589
|
}).nullable(),
|
|
224
590
|
/** The project's runs holding a slot on any server. */
|
|
225
591
|
running: z.number().int(),
|
|
226
592
|
claimed: z.array(runQueueEntrySchema),
|
|
227
|
-
/** Every waiting run, though `queued` lists at most
|
|
593
|
+
/** Every waiting run, though `queued` lists at most 50. */
|
|
228
594
|
queuedCount: z.number().int(),
|
|
595
|
+
/** `queuedCount` split by lane. */
|
|
596
|
+
queuedByLane: z.object({
|
|
597
|
+
automated: z.number().int(),
|
|
598
|
+
interactive: z.number().int()
|
|
599
|
+
}),
|
|
600
|
+
/**
|
|
601
|
+
* Waiting replies, then automated runs, each oldest first: interactive runs are claimed before
|
|
602
|
+
* automated ones. `position` counts within the run's lane.
|
|
603
|
+
*/
|
|
229
604
|
queued: z.array(runQueueEntrySchema.extend({ position: z.number().int().positive() }))
|
|
230
605
|
});
|
|
231
606
|
const createProjectBodySchema = z.object({
|
|
@@ -608,6 +983,124 @@ const workItemFilterOptionsResponseSchema = z.object({
|
|
|
608
983
|
/** The Factory users who created a card, moved one or started a session on one, sorted. */
|
|
609
984
|
actorIds: z.array(z.string())
|
|
610
985
|
});
|
|
986
|
+
/** `<group key>:<count>`: how many rows of one group to list. Group keys hold colons, so the count follows the last. */
|
|
987
|
+
const sessionRowWindowSchema = z.string().transform((entry) => {
|
|
988
|
+
const colon = entry.lastIndexOf(":");
|
|
989
|
+
return [entry.slice(0, Math.max(colon, 0)), entry.slice(colon + 1)];
|
|
990
|
+
}).pipe(z.tuple([z.string().min(1).max(512), z.string().regex(/^[1-9]\d{0,2}$/).transform(Number).pipe(z.number().max(500))]));
|
|
991
|
+
const sessionIdQuerySchema = z.string().min(1).max(512);
|
|
992
|
+
const sessionRowsQuerySchema = z.object({
|
|
993
|
+
sort: z.enum(SESSION_ROW_SORTS).default("activity"),
|
|
994
|
+
groupBy: z.enum(SESSION_ROW_GROUP_BYS).default("none"),
|
|
995
|
+
/** `all`, `mine`, or `owner:<user id>`. */
|
|
996
|
+
owner: sessionRowOwnerSchema.default("all"),
|
|
997
|
+
status: z.enum(SESSION_ROW_STATUSES).optional(),
|
|
998
|
+
updated: z.enum(SESSION_ROW_UPDATED_WITHIN).optional(),
|
|
999
|
+
/** `true` lists a card's other sessions under its row. */
|
|
1000
|
+
children: z.enum(["true"]).optional(),
|
|
1001
|
+
/** Repeatable. Sessions listed before every other one of their group. */
|
|
1002
|
+
pin: z.array(sessionIdQuerySchema).max(100).default([]).transform((ids) => new Set(ids)),
|
|
1003
|
+
/** The session the reader has open: its group lists it however deep it lies. */
|
|
1004
|
+
open: sessionIdQuerySchema.optional(),
|
|
1005
|
+
/** Repeatable `<group key>:<count>`: lists that group's first `count` rows instead of `SESSION_ROW_WINDOW`. */
|
|
1006
|
+
window: z.array(sessionRowWindowSchema).max(64).default([]).refine((windows) => new Set(windows.map(([group]) => group)).size === windows.length, { message: "Send one window per group" }).transform((windows) => new Map(windows))
|
|
1007
|
+
});
|
|
1008
|
+
const sessionRowStatusSchema = z.enum(SESSION_ROW_STATUSES);
|
|
1009
|
+
const changeRequestSchema = z.object({
|
|
1010
|
+
url: z.string().optional(),
|
|
1011
|
+
provider: z.enum(["github", "gitlab"]),
|
|
1012
|
+
number: z.number().optional(),
|
|
1013
|
+
status: z.enum(PULL_REQUEST_STATUSES).optional(),
|
|
1014
|
+
draft: z.boolean(),
|
|
1015
|
+
syncedAt: z.number().optional()
|
|
1016
|
+
});
|
|
1017
|
+
const sessionRowFields = {
|
|
1018
|
+
session: z.object({
|
|
1019
|
+
id: z.string(),
|
|
1020
|
+
sessionId: z.string(),
|
|
1021
|
+
projectRepositoryId: z.string().nullable(),
|
|
1022
|
+
userId: z.string(),
|
|
1023
|
+
branch: z.string(),
|
|
1024
|
+
title: z.string().nullable(),
|
|
1025
|
+
visibility: z.enum(["org", "private"]),
|
|
1026
|
+
createdAt: z.string(),
|
|
1027
|
+
owner: z.object({
|
|
1028
|
+
id: z.string(),
|
|
1029
|
+
name: z.string(),
|
|
1030
|
+
avatarUrl: z.string().optional()
|
|
1031
|
+
}).optional()
|
|
1032
|
+
}),
|
|
1033
|
+
/** `factory` for a session the Factory runs on a card's branch, `user` for one a person or Slack started. */
|
|
1034
|
+
origin: z.enum(["factory", "user"]),
|
|
1035
|
+
board: z.string().optional(),
|
|
1036
|
+
status: sessionRowStatusSchema,
|
|
1037
|
+
/** The status of the card's whole row: its most urgent session's. */
|
|
1038
|
+
cardStatus: sessionRowStatusSchema.optional(),
|
|
1039
|
+
pinned: z.boolean(),
|
|
1040
|
+
/** The card's last change for a card's session, else the session's. */
|
|
1041
|
+
updatedAt: z.string(),
|
|
1042
|
+
card: z.object({
|
|
1043
|
+
id: z.string(),
|
|
1044
|
+
title: z.string(),
|
|
1045
|
+
workItemUrl: z.string().nullable(),
|
|
1046
|
+
externalSource: z.object({
|
|
1047
|
+
integrationId: z.string(),
|
|
1048
|
+
type: z.string(),
|
|
1049
|
+
externalId: z.string(),
|
|
1050
|
+
workspaceId: z.string().optional(),
|
|
1051
|
+
url: z.string().optional()
|
|
1052
|
+
}).nullable()
|
|
1053
|
+
}).optional(),
|
|
1054
|
+
itemId: z.string().optional(),
|
|
1055
|
+
threadId: z.string().optional(),
|
|
1056
|
+
pullRequest: changeRequestSchema.optional(),
|
|
1057
|
+
cardSessionIds: z.array(z.string()).optional(),
|
|
1058
|
+
phaseLabel: z.string().optional(),
|
|
1059
|
+
runByFactory: z.literal(true).optional(),
|
|
1060
|
+
/** A followed card's session waiting on a person. */
|
|
1061
|
+
waitingSessionId: z.string().optional()
|
|
1062
|
+
};
|
|
1063
|
+
const sessionRowSchema = z.object({
|
|
1064
|
+
...sessionRowFields,
|
|
1065
|
+
/** With `children=true`: the card's other sessions. */
|
|
1066
|
+
childRows: z.array(z.object(sessionRowFields)).optional()
|
|
1067
|
+
});
|
|
1068
|
+
const sessionRowsResponseSchema = z.object({
|
|
1069
|
+
/** Rows of the project, whatever the filters. */
|
|
1070
|
+
total: countSchema,
|
|
1071
|
+
matching: countSchema,
|
|
1072
|
+
groups: z.array(z.object({
|
|
1073
|
+
/** `board:<id>`, `user`, `slack`, `status:<status>`, `owner:<user id>` or `all`. */
|
|
1074
|
+
key: z.string(),
|
|
1075
|
+
/** Rows of this group that match the filters. */
|
|
1076
|
+
total: countSchema,
|
|
1077
|
+
openIndex: countSchema.optional(),
|
|
1078
|
+
/** The first of them in the view's order, keeping the open session. */
|
|
1079
|
+
rows: z.array(sessionRowSchema)
|
|
1080
|
+
})),
|
|
1081
|
+
/** Boards some row belongs to, whatever the filters. */
|
|
1082
|
+
boards: z.array(z.string()),
|
|
1083
|
+
/** People who own some row, whatever the filters. */
|
|
1084
|
+
owners: z.array(z.object({
|
|
1085
|
+
userId: z.string(),
|
|
1086
|
+
name: z.string().optional(),
|
|
1087
|
+
avatarUrl: z.string().optional()
|
|
1088
|
+
})),
|
|
1089
|
+
/** Some session is still coming up: the answer changes without anything else telling the reader. */
|
|
1090
|
+
settling: z.boolean()
|
|
1091
|
+
});
|
|
1092
|
+
const sessionActivityResponseSchema = z.object({
|
|
1093
|
+
runningSessionIds: z.array(z.string()),
|
|
1094
|
+
/** Sessions of a card whose run waits on a person's answer. */
|
|
1095
|
+
parkedSessionIds: z.array(z.string()),
|
|
1096
|
+
initializingSessionIds: z.array(z.string()),
|
|
1097
|
+
/** Cards with a session working, and with one waiting on a person. */
|
|
1098
|
+
cards: z.object({
|
|
1099
|
+
working: countSchema,
|
|
1100
|
+
waiting: countSchema
|
|
1101
|
+
}),
|
|
1102
|
+
settling: z.boolean()
|
|
1103
|
+
});
|
|
611
1104
|
const sessionsSchema = z.record(z.string().min(1).max(64), sessionSchema);
|
|
612
1105
|
const metadataSchema = z.union([z.record(z.string(), z.unknown()), z.null()]).refine((value) => {
|
|
613
1106
|
try {
|
|
@@ -1076,6 +1569,7 @@ const FACTORY_ROUTE_CONTRACTS = {
|
|
|
1076
1569
|
path: "/web/factory/projects/:id/intake-routes",
|
|
1077
1570
|
description: "List a Factory project's intake routes in evaluation order",
|
|
1078
1571
|
pathSchema: projectPathSchema,
|
|
1572
|
+
querySchema: intakeRouteListQuerySchema,
|
|
1079
1573
|
responseSchema: intakeRouteListResponseSchema
|
|
1080
1574
|
},
|
|
1081
1575
|
intakeRouteGet: {
|
|
@@ -1131,6 +1625,59 @@ const FACTORY_ROUTE_CONTRACTS = {
|
|
|
1131
1625
|
bodySchema: intakeRouteReorderBodySchema,
|
|
1132
1626
|
responseSchema: intakeRouteListResponseSchema
|
|
1133
1627
|
},
|
|
1628
|
+
intakeOrderGet: {
|
|
1629
|
+
method: "GET",
|
|
1630
|
+
path: "/web/factory/projects/:id/intake-order",
|
|
1631
|
+
description: "The order a Factory project's boards are asked to take a new item, and the evaluator in use",
|
|
1632
|
+
pathSchema: projectPathSchema,
|
|
1633
|
+
responseSchema: intakeOrderResponseSchema
|
|
1634
|
+
},
|
|
1635
|
+
intakeOrderUpdate: {
|
|
1636
|
+
method: "PUT",
|
|
1637
|
+
path: "/web/factory/projects/:id/intake-order",
|
|
1638
|
+
description: "Set the order a Factory project's boards are asked to take a new item, or its evaluator",
|
|
1639
|
+
pathSchema: projectPathSchema,
|
|
1640
|
+
bodySchema: intakeOrderBodySchema,
|
|
1641
|
+
responseSchema: intakeOrderResponseSchema
|
|
1642
|
+
},
|
|
1643
|
+
intakeNotRoutedList: {
|
|
1644
|
+
method: "GET",
|
|
1645
|
+
path: "/web/factory/projects/:id/intake/not-routed",
|
|
1646
|
+
description: "Items no board's intake rules took, oldest first, a page at a time",
|
|
1647
|
+
pathSchema: projectPathSchema,
|
|
1648
|
+
querySchema: intakeNotRoutedQuerySchema,
|
|
1649
|
+
responseSchema: intakeNotRoutedResponseSchema
|
|
1650
|
+
},
|
|
1651
|
+
intakeRouteAgain: {
|
|
1652
|
+
method: "POST",
|
|
1653
|
+
path: "/web/factory/projects/:id/intake/not-routed/:decisionId/route-again",
|
|
1654
|
+
description: "Run intake again for an item no board took, filing it where the rules now say",
|
|
1655
|
+
pathSchema: intakeDecisionPathSchema,
|
|
1656
|
+
responseSchema: intakeRouteAgainResponseSchema
|
|
1657
|
+
},
|
|
1658
|
+
intakeSkippedList: {
|
|
1659
|
+
method: "GET",
|
|
1660
|
+
path: "/web/factory/projects/:id/intake/skipped",
|
|
1661
|
+
description: "How often each card-move rule was skipped in the last 30 days, with its newest skip",
|
|
1662
|
+
pathSchema: projectPathSchema,
|
|
1663
|
+
responseSchema: intakeSkippedResponseSchema
|
|
1664
|
+
},
|
|
1665
|
+
intakeDryRun: {
|
|
1666
|
+
method: "POST",
|
|
1667
|
+
path: "/web/factory/projects/:id/intake/dry-run",
|
|
1668
|
+
description: "Run a Factory project's intake rules, saved or unsaved, over its newest 200 items without filing anything",
|
|
1669
|
+
pathSchema: projectPathSchema,
|
|
1670
|
+
bodySchema: intakeDryRunBodySchema,
|
|
1671
|
+
responseSchema: intakeDryRunResponseSchema
|
|
1672
|
+
},
|
|
1673
|
+
intakeTest: {
|
|
1674
|
+
method: "POST",
|
|
1675
|
+
path: "/web/factory/projects/:id/intake/test",
|
|
1676
|
+
description: "Show where intake would file one item, and what every rule answered, without filing it",
|
|
1677
|
+
pathSchema: projectPathSchema,
|
|
1678
|
+
bodySchema: intakeTestBodySchema,
|
|
1679
|
+
responseSchema: intakeTestResponseSchema
|
|
1680
|
+
},
|
|
1134
1681
|
workItemList: {
|
|
1135
1682
|
method: "GET",
|
|
1136
1683
|
path: "/web/factory/projects/:id/work-items",
|
|
@@ -1174,6 +1721,21 @@ const FACTORY_ROUTE_CONTRACTS = {
|
|
|
1174
1721
|
pathSchema: projectPathSchema,
|
|
1175
1722
|
responseSchema: workItemFilterOptionsResponseSchema
|
|
1176
1723
|
},
|
|
1724
|
+
sessionRows: {
|
|
1725
|
+
method: "GET",
|
|
1726
|
+
path: "/web/factory/projects/:id/session-rows",
|
|
1727
|
+
description: "List the sidebar's session rows of a view, grouped and in order, with how many match",
|
|
1728
|
+
pathSchema: projectPathSchema,
|
|
1729
|
+
querySchema: sessionRowsQuerySchema,
|
|
1730
|
+
responseSchema: sessionRowsResponseSchema
|
|
1731
|
+
},
|
|
1732
|
+
sessionActivity: {
|
|
1733
|
+
method: "GET",
|
|
1734
|
+
path: "/web/factory/projects/:id/session-activity",
|
|
1735
|
+
description: "List which of a project's sessions are running, waiting on a person or coming up",
|
|
1736
|
+
pathSchema: projectPathSchema,
|
|
1737
|
+
responseSchema: sessionActivityResponseSchema
|
|
1738
|
+
},
|
|
1177
1739
|
workItemCreate: {
|
|
1178
1740
|
method: "POST",
|
|
1179
1741
|
path: "/web/factory/projects/:id/work-items",
|
|
@@ -1205,6 +1767,17 @@ const FACTORY_ROUTE_CONTRACTS = {
|
|
|
1205
1767
|
bodySchema: transitionBodySchema,
|
|
1206
1768
|
responseSchema: entitySchema
|
|
1207
1769
|
},
|
|
1770
|
+
workItemWorkingPullRequest: {
|
|
1771
|
+
method: "PUT",
|
|
1772
|
+
path: "/web/factory/projects/:id/work-items/:workItemId/working-pull-request",
|
|
1773
|
+
description: "Make one of the pull requests linked to a card the one its sessions work on. The only way an outside author's pull request becomes a card's working pull request.",
|
|
1774
|
+
pathSchema: transitionPathSchema,
|
|
1775
|
+
bodySchema: z.object({
|
|
1776
|
+
pullRequest: z.number().int().positive(),
|
|
1777
|
+
expectedRevision: z.number().int().nonnegative()
|
|
1778
|
+
}),
|
|
1779
|
+
responseSchema: workItemResponseSchema
|
|
1780
|
+
},
|
|
1208
1781
|
workItemStart: {
|
|
1209
1782
|
method: "POST",
|
|
1210
1783
|
path: "/web/factory/projects/:id/runs/start",
|
|
@@ -1340,6 +1913,6 @@ const FACTORY_ROUTE_CONTRACTS = {
|
|
|
1340
1913
|
responseSchema: skillResponseSchema
|
|
1341
1914
|
}
|
|
1342
1915
|
};
|
|
1343
|
-
export { BOARD_PHASES_SORTS, FACTORY_ROUTE_CONTRACTS, MAX_SANDBOX_ENV_VALUE_LENGTH, MAX_SKILL_OVERRIDE_LENGTH, RESERVED_SANDBOX_ENV_NAMES, THINKING_LEVELS, UUID_PATTERN, attentionQuerySchema, automationRunStartBodySchema, boardDeleteQuerySchema, boardPhasesQuerySchema, boardPhasesResponseSchema, boardResetBodySchema, createProjectBodySchema, createWorkItemBodySchema, decisionQuerySchema, environmentBuildResponseSchema, environmentBuildSchema, environmentBuildStartResponseSchema, environmentBuildTriggersSchema, environmentBuildsResponseSchema, environmentLastBuildSchema, environmentSandboxSchema, intakeRouteInputSchema, intakeRoutePatchSchema, intakeRouteReorderBodySchema, metricsQuerySchema, projectEnvironmentResponseSchema, projectListRepositorySchema, replaceBoardBodySchema, runQueueResponseSchema, sandboxEnvAppliesToSchema, sandboxEnvNameSchema, sandboxEnvSetBodySchema, sandboxEnvUpdateBodySchema, skillOverrideBodySchema, skillOverrideSaveRequestSchema, startWorkItemBodySchema, transitionBodySchema, updateProjectBodySchema, updateProjectEnvironmentBodySchema, updateWorkItemBodySchema, workItemActivityQuerySchema, workItemActivityResponseSchema, workItemFilterOptionsResponseSchema, workItemStartersResponseSchema };
|
|
1916
|
+
export { BOARD_PHASES_SORTS, FACTORY_ROUTE_CONTRACTS, MAX_SANDBOX_ENV_VALUE_LENGTH, MAX_SKILL_OVERRIDE_LENGTH, RESERVED_SANDBOX_ENV_NAMES, THINKING_LEVELS, UUID_PATTERN, attentionQuerySchema, automationRunStartBodySchema, boardDeleteQuerySchema, boardPhasesQuerySchema, boardPhasesResponseSchema, boardResetBodySchema, createProjectBodySchema, createWorkItemBodySchema, decisionQuerySchema, environmentBuildResponseSchema, environmentBuildSchema, environmentBuildStartResponseSchema, environmentBuildTriggersSchema, environmentBuildsResponseSchema, environmentLastBuildSchema, environmentSandboxSchema, intakeDryRunBodySchema, intakeOrderBodySchema, intakeRouteInputSchema, intakeRoutePatchSchema, intakeRouteReorderBodySchema, intakeTestBodySchema, metricsQuerySchema, projectEnvironmentResponseSchema, projectListRepositorySchema, replaceBoardBodySchema, runQueueResponseSchema, sandboxEnvAppliesToSchema, sandboxEnvNameSchema, sandboxEnvSetBodySchema, sandboxEnvUpdateBodySchema, sessionActivityResponseSchema, sessionRowsQuerySchema, sessionRowsResponseSchema, skillOverrideBodySchema, skillOverrideSaveRequestSchema, startWorkItemBodySchema, transitionBodySchema, updateProjectBodySchema, updateProjectEnvironmentBodySchema, updateWorkItemBodySchema, workItemActivityQuerySchema, workItemActivityResponseSchema, workItemFilterOptionsResponseSchema, workItemStartersResponseSchema };
|
|
1344
1917
|
|
|
1345
1918
|
//# sourceMappingURL=contracts.js.map
|