@aviaratech/ai-delivery 0.3.34 → 0.3.36
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/CONTRIBUTING.md +12 -206
- package/README.md +57 -506
- package/dist/agent.d.ts +0 -2
- package/dist/agent.js +76 -16
- package/dist/agent.js.map +7 -1
- package/dist/agentReadiness.test.js +73 -67
- package/dist/agentReadiness.test.js.map +7 -1
- package/dist/boardReconcile.test.js +1746 -0
- package/dist/boardReconcile.test.js.map +7 -0
- package/dist/build.test.js +130 -0
- package/dist/build.test.js.map +7 -0
- package/dist/callerErrors.test.js +105 -0
- package/dist/callerErrors.test.js.map +7 -0
- package/dist/cli.js +406 -485
- package/dist/cli.js.map +7 -1
- package/dist/cliResult.d.ts +2 -2
- package/dist/cliResult.js +42 -25
- package/dist/cliResult.js.map +7 -1
- package/dist/cliResult.test.js +434 -297
- package/dist/cliResult.test.js.map +7 -1
- package/dist/config/deliveryConfig.d.ts +320 -14
- package/dist/config/deliveryConfig.js +472 -385
- package/dist/config/deliveryConfig.js.map +7 -1
- package/dist/config/deliveryConfig.test.js +775 -584
- package/dist/config/deliveryConfig.test.js.map +7 -1
- package/dist/contributorChecks.test.js +1694 -916
- package/dist/contributorChecks.test.js.map +7 -1
- package/dist/currentConsumer.test.js +819 -737
- package/dist/currentConsumer.test.js.map +7 -1
- package/dist/currentTrackingScenario.test.js +499 -477
- package/dist/currentTrackingScenario.test.js.map +7 -1
- package/dist/delivery/common.js +160 -172
- package/dist/delivery/common.js.map +7 -1
- package/dist/delivery/delivery.test.js +509 -431
- package/dist/delivery/delivery.test.js.map +7 -1
- package/dist/delivery/evidence.d.ts +2 -2
- package/dist/delivery/evidence.js +133 -120
- package/dist/delivery/evidence.js.map +7 -1
- package/dist/delivery/index.js +7 -2
- package/dist/delivery/index.js.map +7 -1
- package/dist/delivery/legacy.js +65 -5
- package/dist/delivery/legacy.js.map +7 -1
- package/dist/delivery/policy.d.ts +10 -10
- package/dist/delivery/policy.js +211 -238
- package/dist/delivery/policy.js.map +7 -1
- package/dist/delivery/stage.d.ts +18 -18
- package/dist/delivery/stage.js +220 -235
- package/dist/delivery/stage.js.map +7 -1
- package/dist/deliveryBoard.d.ts +74 -0
- package/dist/deliveryBoard.js +644 -0
- package/dist/deliveryBoard.js.map +7 -0
- package/dist/deliveryBoard.test.d.ts +1 -0
- package/dist/deliveryBoard.test.js +649 -0
- package/dist/deliveryBoard.test.js.map +7 -0
- package/dist/deliveryHealth.test.js +179 -155
- package/dist/deliveryHealth.test.js.map +7 -1
- package/dist/dependencyCompatibility.test.js +154 -140
- package/dist/dependencyCompatibility.test.js.map +7 -1
- package/dist/directoryIndependent.test.js +417 -383
- package/dist/directoryIndependent.test.js.map +7 -1
- package/dist/dispatch.d.ts +17 -12
- package/dist/dispatch.js +330 -322
- package/dist/dispatch.js.map +7 -1
- package/dist/errors.d.ts +16 -3
- package/dist/errors.js +104 -82
- package/dist/errors.js.map +7 -1
- package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
- package/dist/fixtures/deliveryBoardReplay.js +617 -0
- package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
- package/dist/fixtures/discovery.d.ts +59 -19
- package/dist/fixtures/discovery.js +96 -90
- package/dist/fixtures/discovery.js.map +7 -1
- package/dist/fixtures/inertEntrypointChild.js +57 -56
- package/dist/fixtures/inertEntrypointChild.js.map +7 -1
- package/dist/fixtures/inertEntrypoints.d.ts +1 -1
- package/dist/fixtures/inertEntrypoints.js +321 -276
- package/dist/fixtures/inertEntrypoints.js.map +7 -1
- package/dist/fixtures/inertTarget.d.ts +78 -7
- package/dist/fixtures/inertTarget.js +769 -691
- package/dist/fixtures/inertTarget.js.map +7 -1
- package/dist/fixtures/issue63.d.ts +4 -3
- package/dist/fixtures/issue63.js +260 -274
- package/dist/fixtures/issue63.js.map +7 -1
- package/dist/fixtures/issueProjectItems.d.ts +20 -0
- package/dist/fixtures/issueProjectItems.js +15 -0
- package/dist/fixtures/issueProjectItems.js.map +7 -0
- package/dist/fixtures/readView.d.ts +120 -0
- package/dist/fixtures/readView.js +172 -0
- package/dist/fixtures/readView.js.map +7 -0
- package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
- package/dist/fixtures/recordedGitHubFlows.js +109 -0
- package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
- package/dist/genericCompatibility.test.js +64 -55
- package/dist/genericCompatibility.test.js.map +7 -1
- package/dist/git.js +73 -67
- package/dist/git.js.map +7 -1
- package/dist/gitProcess.d.ts +1 -1
- package/dist/gitProcess.js +58 -53
- package/dist/gitProcess.js.map +7 -1
- package/dist/github/client.d.ts +2 -2
- package/dist/github/client.js +484 -379
- package/dist/github/client.js.map +7 -1
- package/dist/github/commandIdentityPolicy.js +44 -51
- package/dist/github/commandIdentityPolicy.js.map +7 -1
- package/dist/github/discovery.d.ts +3 -0
- package/dist/github/discovery.js +197 -201
- package/dist/github/discovery.js.map +7 -1
- package/dist/github/discovery.test.js +223 -177
- package/dist/github/discovery.test.js.map +7 -1
- package/dist/github/issueHistory.d.ts +2 -2
- package/dist/github/issueHistory.js +117 -125
- package/dist/github/issueHistory.js.map +7 -1
- package/dist/github/machineAuth.d.ts +1 -1
- package/dist/github/machineAuth.js +126 -117
- package/dist/github/machineAuth.js.map +7 -1
- package/dist/github/machineAuth.test.js +755 -639
- package/dist/github/machineAuth.test.js.map +7 -1
- package/dist/github/nativeIssueMetadata.js +286 -273
- package/dist/github/nativeIssueMetadata.js.map +7 -1
- package/dist/github/projectDelivery.d.ts +53 -1
- package/dist/github/projectDelivery.js +623 -460
- package/dist/github/projectDelivery.js.map +7 -1
- package/dist/github/relationships.d.ts +5 -2
- package/dist/github/relationships.js +434 -333
- package/dist/github/relationships.js.map +7 -1
- package/dist/github/repo.d.ts +1 -0
- package/dist/github/repo.js +123 -96
- package/dist/github/repo.js.map +7 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +7 -1
- package/dist/issue.d.ts +103 -7
- package/dist/issue.js +2104 -1547
- package/dist/issue.js.map +7 -1
- package/dist/issue63History.test.js +40 -42
- package/dist/issue63History.test.js.map +7 -1
- package/dist/issue63Routes.test.js +154 -143
- package/dist/issue63Routes.test.js.map +7 -1
- package/dist/issueBatchUpdate.test.js +1004 -683
- package/dist/issueBatchUpdate.test.js.map +7 -1
- package/dist/issueBlockerGuard.test.js +262 -226
- package/dist/issueBlockerGuard.test.js.map +7 -1
- package/dist/issueContract.d.ts +23 -4
- package/dist/issueContract.js +416 -395
- package/dist/issueContract.js.map +7 -1
- package/dist/issueContract.test.d.ts +4 -3
- package/dist/issueContract.test.js +358 -321
- package/dist/issueContract.test.js.map +7 -1
- package/dist/issueDates.test.js +235 -233
- package/dist/issueDates.test.js.map +7 -1
- package/dist/issueInfoReadback.test.js +304 -190
- package/dist/issueInfoReadback.test.js.map +7 -1
- package/dist/issueIntake.test.js +1945 -1732
- package/dist/issueIntake.test.js.map +7 -1
- package/dist/issueJournal.d.ts +40 -19
- package/dist/issueJournal.js +229 -138
- package/dist/issueJournal.js.map +7 -1
- package/dist/issueJournal.test.js +605 -422
- package/dist/issueJournal.test.js.map +7 -1
- package/dist/issueRollup.test.d.ts +1 -0
- package/dist/issueRollup.test.js +476 -0
- package/dist/issueRollup.test.js.map +7 -0
- package/dist/issueTracking.test.js +1088 -593
- package/dist/issueTracking.test.js.map +7 -1
- package/dist/issueWriteRecovery.test.d.ts +1 -0
- package/dist/issueWriteRecovery.test.js +260 -0
- package/dist/issueWriteRecovery.test.js.map +7 -0
- package/dist/lifecycle.test.js +112 -441
- package/dist/lifecycle.test.js.map +7 -1
- package/dist/logger.js +80 -74
- package/dist/logger.js.map +7 -1
- package/dist/mcp/index.js +116 -90
- package/dist/mcp/index.js.map +7 -1
- package/dist/mcp/tools.d.ts +790 -220
- package/dist/mcp/tools.js +267 -333
- package/dist/mcp/tools.js.map +7 -1
- package/dist/pluginAuthProbe.js +63 -52
- package/dist/pluginAuthProbe.js.map +7 -1
- package/dist/pluginAuthProbe.test.js +85 -62
- package/dist/pluginAuthProbe.test.js.map +7 -1
- package/dist/pluginCredentials.test.js +282 -259
- package/dist/pluginCredentials.test.js.map +7 -1
- package/dist/pluginDoctor.test.js +653 -588
- package/dist/pluginDoctor.test.js.map +7 -1
- package/dist/pluginInstaller.d.ts +7 -5
- package/dist/pluginInstaller.js +1173 -1231
- package/dist/pluginInstaller.js.map +7 -1
- package/dist/pluginInstaller.test.js +1822 -1283
- package/dist/pluginInstaller.test.js.map +7 -1
- package/dist/pluginPackaging.test.js +485 -305
- package/dist/pluginPackaging.test.js.map +7 -1
- package/dist/pr.d.ts +132 -94
- package/dist/pr.js +1521 -1323
- package/dist/pr.js.map +7 -1
- package/dist/pr.test.js +1678 -632
- package/dist/pr.test.js.map +7 -1
- package/dist/prAssociation.test.js +2419 -1788
- package/dist/prAssociation.test.js.map +7 -1
- package/dist/prDispatch.test.js +150 -89
- package/dist/prDispatch.test.js.map +7 -1
- package/dist/readView.d.ts +183 -0
- package/dist/readView.js +217 -0
- package/dist/readView.js.map +7 -0
- package/dist/readView.test.d.ts +1 -0
- package/dist/readView.test.js +119 -0
- package/dist/readView.test.js.map +7 -0
- package/dist/releaseReconciliation.test.js +267 -288
- package/dist/releaseReconciliation.test.js.map +7 -1
- package/dist/releaseWorkflow.test.js +2493 -422
- package/dist/releaseWorkflow.test.js.map +7 -1
- package/dist/review.d.ts +738 -2
- package/dist/review.js +601 -348
- package/dist/review.js.map +7 -1
- package/dist/review.test.js +1218 -812
- package/dist/review.test.js.map +7 -1
- package/dist/reviewSubmit.test.d.ts +1 -0
- package/dist/reviewSubmit.test.js +747 -0
- package/dist/reviewSubmit.test.js.map +7 -0
- package/dist/services/agentReadinessService.js +42 -37
- package/dist/services/agentReadinessService.js.map +7 -1
- package/dist/services/blockerGuardService.js +188 -188
- package/dist/services/blockerGuardService.js.map +7 -1
- package/dist/services/boardReconcileService.d.ts +1204 -0
- package/dist/services/boardReconcileService.js +1445 -0
- package/dist/services/boardReconcileService.js.map +7 -0
- package/dist/services/deliveryAdmission.d.ts +2 -0
- package/dist/services/deliveryAdmission.js +129 -152
- package/dist/services/deliveryAdmission.js.map +7 -1
- package/dist/services/deliveryHealthService.js +197 -199
- package/dist/services/deliveryHealthService.js.map +7 -1
- package/dist/services/legacyIssueMigration.js +263 -277
- package/dist/services/legacyIssueMigration.js.map +7 -1
- package/dist/services/worktreeRegistry.d.ts +27 -119
- package/dist/services/worktreeRegistry.js +765 -1182
- package/dist/services/worktreeRegistry.js.map +7 -1
- package/dist/stagedChecks.test.js +396 -194
- package/dist/stagedChecks.test.js.map +7 -1
- package/dist/start.test.js +99 -95
- package/dist/start.test.js.map +7 -1
- package/dist/stdoutRegression.test.js +354 -350
- package/dist/stdoutRegression.test.js.map +7 -1
- package/dist/targetPolicyDiscovery.test.js +141 -143
- package/dist/targetPolicyDiscovery.test.js.map +7 -1
- package/dist/targetPolicyEntrypoints.test.js +308 -269
- package/dist/targetPolicyEntrypoints.test.js.map +7 -1
- package/dist/targetPolicyLocal.test.js +580 -1051
- package/dist/targetPolicyLocal.test.js.map +7 -1
- package/dist/targetPolicyRoutes.test.js +305 -281
- package/dist/targetPolicyRoutes.test.js.map +7 -1
- package/dist/targetRepositoryExecution.test.d.ts +1 -0
- package/dist/targetRepositoryExecution.test.js +463 -0
- package/dist/targetRepositoryExecution.test.js.map +7 -0
- package/dist/terminalMessages.js +41 -35
- package/dist/terminalMessages.js.map +7 -1
- package/dist/toolOutput.d.ts +2 -0
- package/dist/toolOutput.js +36 -0
- package/dist/toolOutput.js.map +7 -0
- package/dist/toolOutput.test.d.ts +1 -0
- package/dist/toolOutput.test.js +240 -0
- package/dist/toolOutput.test.js.map +7 -0
- package/dist/utils/atomicJson.js +84 -76
- package/dist/utils/atomicJson.js.map +7 -1
- package/dist/utils/filesystem.js +15 -18
- package/dist/utils/filesystem.js.map +7 -1
- package/dist/utils/lockfile.js +68 -71
- package/dist/utils/lockfile.js.map +7 -1
- package/dist/verification.d.ts +1 -19
- package/dist/verification.js +1020 -1929
- package/dist/verification.js.map +7 -1
- package/dist/verificationGate.test.js +127 -117
- package/dist/verificationGate.test.js.map +7 -1
- package/dist/version.d.ts +6 -0
- package/dist/version.js +24 -10
- package/dist/version.js.map +7 -1
- package/dist/worktree.d.ts +3 -15
- package/dist/worktree.js +97 -177
- package/dist/worktree.js.map +7 -1
- package/package.json +10 -8
- package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
- package/plugins/ai-delivery/README.md +47 -156
- package/plugins/ai-delivery/plugin.json +1 -1
- package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +261 -43
- package/plugins/ai-delivery/runtime/dist/cli.js +369 -125
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
- package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
- package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
- package/dist/investigationCompletion.test.js +0 -728
- package/dist/investigationCompletion.test.js.map +0 -1
- package/dist/setup.d.ts +0 -60
- package/dist/setup.js +0 -585
- package/dist/setup.js.map +0 -1
- package/dist/setup.test.js +0 -3058
- package/dist/setup.test.js.map +0 -1
- package/dist/worktreeTransition.d.ts +0 -211
- package/dist/worktreeTransition.js +0 -1037
- package/dist/worktreeTransition.js.map +0 -1
- package/dist/worktreeTransition.test.js +0 -1191
- package/dist/worktreeTransition.test.js.map +0 -1
- /package/dist/{investigationCompletion.test.d.ts → boardReconcile.test.d.ts} +0 -0
- /package/dist/{setup.test.d.ts → build.test.d.ts} +0 -0
- /package/dist/{worktreeTransition.test.d.ts → callerErrors.test.d.ts} +0 -0
|
@@ -1,82 +1,94 @@
|
|
|
1
|
-
import { DeliveryError } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const response = await input.graphql(`
|
|
1
|
+
import { CollectionLimitError, DeliveryError } from "../errors.js";
|
|
2
|
+
const PROJECT_DELIVERY_STATUSES = ["Todo", "In Progress", "Blocked", "Done"];
|
|
3
|
+
const PROJECT_REVIEW_STATUS = "In Review";
|
|
4
|
+
async function archiveIssueProjectItem(input) {
|
|
5
|
+
const configuration = input.configuration ?? await getProjectDeliveryConfiguration({
|
|
6
|
+
...input,
|
|
7
|
+
settings: requireProjectSettings(input.settings),
|
|
8
|
+
requireWritable: true
|
|
9
|
+
});
|
|
10
|
+
assertWritableConfiguration(configuration);
|
|
11
|
+
const item = await findIssueProjectItem({ ...input, configuration });
|
|
12
|
+
if (item === null) return null;
|
|
13
|
+
if (item.archived) return { archived: true, itemId: item.id };
|
|
14
|
+
const response = await input.graphql(
|
|
15
|
+
`
|
|
17
16
|
mutation ArchiveProjectDeliveryItem($projectId: ID!, $itemId: ID!) {
|
|
18
17
|
archiveProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {
|
|
19
18
|
item { id isArchived }
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
`,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
`,
|
|
22
|
+
{ itemId: item.id, projectId: configuration.projectId }
|
|
23
|
+
);
|
|
24
|
+
const record = requireRecord(response, "GitHub returned invalid Project archive evidence.");
|
|
25
|
+
const payload = requireRecord(record.archiveProjectV2Item, "GitHub omitted Project archive payload.");
|
|
26
|
+
const archivedItem = requireRecord(payload.item, "GitHub omitted the archived Project item.");
|
|
27
|
+
if (archivedItem.id !== item.id || archivedItem.isArchived !== true) {
|
|
28
|
+
throw new DeliveryError("Project archive mutation did not return the exact archived item.");
|
|
29
|
+
}
|
|
30
|
+
await readBackProjectArchiveState({
|
|
31
|
+
archived: true,
|
|
32
|
+
configuration,
|
|
33
|
+
graphql: input.graphql,
|
|
34
|
+
issueNodeId: input.issueNodeId,
|
|
35
|
+
itemId: item.id
|
|
36
|
+
});
|
|
37
|
+
return { archived: true, itemId: item.id };
|
|
38
|
+
}
|
|
39
|
+
async function getIssueProjectStatus(input) {
|
|
40
|
+
const configuration = input.configuration ?? await getProjectDeliveryConfiguration({ ...input, settings: requireProjectSettings(input.settings) });
|
|
41
|
+
let item = await findIssueProjectItem({ ...input, configuration });
|
|
42
|
+
if (item === null || item.archived) return null;
|
|
43
|
+
if (item.status === null && item.statusOptionId === null) {
|
|
44
|
+
item = await readProjectItem({
|
|
45
|
+
configuration,
|
|
46
|
+
graphql: input.graphql,
|
|
47
|
+
issueNodeId: input.issueNodeId,
|
|
48
|
+
itemId: item.id,
|
|
49
|
+
...input.capacityRead ? { capacityRead: true } : {}
|
|
35
50
|
});
|
|
36
|
-
|
|
51
|
+
}
|
|
52
|
+
if (item.archived) return null;
|
|
53
|
+
if (item.status === null && item.statusOptionId === null) return null;
|
|
54
|
+
const status = requireItemStatus(item, configuration);
|
|
55
|
+
return { itemId: item.id, status, ...item.review ? { review: true } : {} };
|
|
37
56
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return null;
|
|
44
|
-
// The list projection may omit a status already verified by a direct item read.
|
|
45
|
-
// Resolve that exact item without inferring a status or accepting a missing item.
|
|
46
|
-
if (item.status === null && item.statusOptionId === null) {
|
|
47
|
-
item = await readProjectItem({
|
|
48
|
-
configuration,
|
|
49
|
-
graphql: input.graphql,
|
|
50
|
-
issueNodeId: input.issueNodeId,
|
|
51
|
-
itemId: item.id,
|
|
52
|
-
...(input.capacityRead ? { capacityRead: true } : {}),
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
if (item.archived)
|
|
56
|
-
return null;
|
|
57
|
-
if (item.status === null && item.statusOptionId === null)
|
|
58
|
-
return null;
|
|
59
|
-
const status = requireItemStatus(item, configuration);
|
|
60
|
-
return { itemId: item.id, status };
|
|
57
|
+
async function getArchivedIssueProjectStatus(input) {
|
|
58
|
+
const configuration = input.configuration ?? await getProjectDeliveryConfiguration({ ...input, settings: requireProjectSettings(input.settings) });
|
|
59
|
+
const item = await findIssueProjectItem({ ...input, configuration });
|
|
60
|
+
if (item === null || !item.archived || item.status === null && item.statusOptionId === null) return null;
|
|
61
|
+
return requireItemStatus(item, configuration);
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
63
|
+
async function getProjectDeliveryConfiguration(input) {
|
|
64
|
+
const settings = requireProjectSettings(input.settings);
|
|
65
|
+
const project = await readProjectDeliveryDefinition({
|
|
66
|
+
graphql: input.graphql,
|
|
67
|
+
org: input.org,
|
|
68
|
+
number: settings.number,
|
|
69
|
+
...input.maxPages === void 0 ? {} : { maxPages: input.maxPages }
|
|
70
|
+
});
|
|
71
|
+
return resolveProjectDeliveryConfiguration(project, { requireWritable: input.requireWritable === true, settings });
|
|
70
72
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
async function readProjectDeliveryDefinition(input) {
|
|
74
|
+
const nodes = [];
|
|
75
|
+
let cursor = null;
|
|
76
|
+
let hasNextPage = true;
|
|
77
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
78
|
+
const fieldIds = /* @__PURE__ */ new Set();
|
|
79
|
+
let project = null;
|
|
80
|
+
let pages = 0;
|
|
81
|
+
while (hasNextPage) {
|
|
82
|
+
if (input.maxPages !== void 0 && pages >= input.maxPages)
|
|
83
|
+
throw new CollectionLimitError({
|
|
84
|
+
collection: "project-fields",
|
|
85
|
+
pagesRequested: pages,
|
|
86
|
+
rowsObserved: nodes.length,
|
|
87
|
+
limit: input.maxPages
|
|
88
|
+
});
|
|
89
|
+
pages++;
|
|
90
|
+
const response = await input.graphql(
|
|
91
|
+
`
|
|
80
92
|
query ProjectDeliveryConfiguration($org: String!, $number: Int!, $cursor: String) {
|
|
81
93
|
organization(login: $org) {
|
|
82
94
|
projectV2(number: $number) {
|
|
@@ -122,206 +134,247 @@ export async function readProjectDeliveryDefinition(input) {
|
|
|
122
134
|
}
|
|
123
135
|
}
|
|
124
136
|
}
|
|
125
|
-
`,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const fieldId = requireString(field.id, 'GitHub omitted a delivery Project field ID.');
|
|
143
|
-
if (fieldIds.has(fieldId))
|
|
144
|
-
throw new DeliveryError('GitHub repeated a delivery Project field.');
|
|
145
|
-
fieldIds.add(fieldId);
|
|
146
|
-
requireString(field.name, 'GitHub omitted a delivery Project field name.');
|
|
147
|
-
requireString(field.__typename, 'GitHub omitted a delivery Project field type.');
|
|
148
|
-
if (field.__typename === 'ProjectV2SingleSelectField') {
|
|
149
|
-
if (typeof field.isIssueField !== 'boolean')
|
|
150
|
-
throw new DeliveryError('GitHub omitted the Project field binding kind.');
|
|
151
|
-
readOptions(field.options, 'Project field');
|
|
152
|
-
if (field.isIssueField) {
|
|
153
|
-
const issueField = requireRecord(field.issueField, 'GitHub omitted the bound organization field.');
|
|
154
|
-
requireString(issueField.__typename, 'GitHub omitted the bound organization field type.');
|
|
155
|
-
if (issueField.__typename === 'IssueFieldSingleSelect') {
|
|
156
|
-
requireString(issueField.id, 'GitHub omitted the bound organization field ID.');
|
|
157
|
-
requireString(issueField.name, 'GitHub omitted the bound organization field name.');
|
|
158
|
-
if (!/^[1-9]\d*$/u.test(String(issueField.fullDatabaseId)))
|
|
159
|
-
throw new DeliveryError('GitHub omitted the bound organization field database ID.');
|
|
160
|
-
readOptions(issueField.options, 'organization field');
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
nodes.push(node);
|
|
165
|
-
}
|
|
166
|
-
project = { ...pageProject, fields: { nodes } };
|
|
167
|
-
const pageInfo = requireRecord(fields.pageInfo, 'GitHub omitted delivery Project field pagination.');
|
|
168
|
-
if (typeof pageInfo.hasNextPage !== 'boolean')
|
|
169
|
-
throw new DeliveryError('GitHub omitted delivery Project pagination state.');
|
|
170
|
-
hasNextPage = pageInfo.hasNextPage === true;
|
|
171
|
-
const nextCursor = typeof pageInfo.endCursor === 'string' ? pageInfo.endCursor : null;
|
|
172
|
-
assertAdvancingCursor({ cursor, hasNextPage, nextCursor, seenCursors, surface: 'field' });
|
|
173
|
-
if (nextCursor !== null)
|
|
174
|
-
seenCursors.add(nextCursor);
|
|
175
|
-
cursor = nextCursor;
|
|
176
|
-
}
|
|
177
|
-
if (project === null) {
|
|
178
|
-
throw new DeliveryError(`Expected organization Project #${String(input.number)}.`);
|
|
137
|
+
`,
|
|
138
|
+
{ cursor, number: input.number, org: input.org }
|
|
139
|
+
);
|
|
140
|
+
const responseRecord = requireRecord(response, "GitHub returned invalid delivery Project configuration.");
|
|
141
|
+
if ("errors" in responseRecord) throw new DeliveryError("GitHub returned partial delivery Project evidence.");
|
|
142
|
+
const organization = requireRecord(
|
|
143
|
+
responseRecord.organization,
|
|
144
|
+
`Organization ${input.org} is unavailable to the selected GitHub identity.`
|
|
145
|
+
);
|
|
146
|
+
const pageProject = requireRecord(
|
|
147
|
+
organization.projectV2,
|
|
148
|
+
`Expected organization Project #${String(input.number)}.`
|
|
149
|
+
);
|
|
150
|
+
const fields = requireRecord(pageProject.fields, "GitHub omitted delivery Project fields.");
|
|
151
|
+
const previousProject = project;
|
|
152
|
+
if (previousProject !== null && ["id", "number", "title", "closed", "viewerCanUpdate"].some((key) => previousProject[key] !== pageProject[key])) {
|
|
153
|
+
throw new DeliveryError("Delivery Project identity changed while reading its field pages.");
|
|
179
154
|
}
|
|
180
|
-
return project;
|
|
181
|
-
}
|
|
182
|
-
export function projectSettingsFromDeliveryConfig(config) {
|
|
183
|
-
const project = config.native.project;
|
|
184
|
-
return {
|
|
185
|
-
number: project.number,
|
|
186
|
-
points: config.native.points,
|
|
187
|
-
priority: config.native.priority,
|
|
188
|
-
statuses: {
|
|
189
|
-
Blocked: project.statuses.blocked,
|
|
190
|
-
Done: project.statuses.done,
|
|
191
|
-
'In Progress': project.statuses.inProgress,
|
|
192
|
-
Todo: project.statuses.todo,
|
|
193
|
-
},
|
|
194
|
-
statusField: project.statusField,
|
|
195
|
-
title: project.title,
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
export function resolveProjectDeliveryConfiguration(raw, options) {
|
|
199
|
-
const settings = requireProjectSettings(options.settings);
|
|
200
|
-
const project = requireRecord(raw, 'GitHub returned invalid delivery Project configuration.');
|
|
201
|
-
if (project.number !== settings.number || project.title !== settings.title) {
|
|
202
|
-
throw new DeliveryError(`Expected organization Project #${String(settings.number)} titled ${settings.title}.`);
|
|
203
|
-
}
|
|
204
|
-
if (options.requireWritable === true && project.viewerCanUpdate !== true) {
|
|
205
|
-
throw new DeliveryError(`Organization Project #${String(settings.number)} is not writable by this identity.`);
|
|
206
|
-
}
|
|
207
|
-
const projectId = requireString(project.id, 'GitHub omitted the delivery Project node id.');
|
|
208
|
-
const fields = requireRecord(project.fields, 'GitHub omitted delivery Project fields.');
|
|
209
155
|
if (!Array.isArray(fields.nodes)) {
|
|
210
|
-
|
|
156
|
+
throw new DeliveryError("GitHub returned invalid delivery Project field nodes.");
|
|
211
157
|
}
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
158
|
+
for (const node of fields.nodes) {
|
|
159
|
+
const field = requireRecord(node, "GitHub returned an incomplete delivery Project field.");
|
|
160
|
+
const fieldId = requireString(field.id, "GitHub omitted a delivery Project field ID.");
|
|
161
|
+
if (fieldIds.has(fieldId)) throw new DeliveryError("GitHub repeated a delivery Project field.");
|
|
162
|
+
fieldIds.add(fieldId);
|
|
163
|
+
requireString(field.name, "GitHub omitted a delivery Project field name.");
|
|
164
|
+
requireString(field.__typename, "GitHub omitted a delivery Project field type.");
|
|
165
|
+
if (field.__typename === "ProjectV2SingleSelectField") {
|
|
166
|
+
if (typeof field.isIssueField !== "boolean")
|
|
167
|
+
throw new DeliveryError("GitHub omitted the Project field binding kind.");
|
|
168
|
+
readOptions(field.options, "Project field");
|
|
169
|
+
if (field.isIssueField) {
|
|
170
|
+
const issueField = requireRecord(field.issueField, "GitHub omitted the bound organization field.");
|
|
171
|
+
requireString(issueField.__typename, "GitHub omitted the bound organization field type.");
|
|
172
|
+
if (issueField.__typename === "IssueFieldSingleSelect") {
|
|
173
|
+
requireString(issueField.id, "GitHub omitted the bound organization field ID.");
|
|
174
|
+
requireString(issueField.name, "GitHub omitted the bound organization field name.");
|
|
175
|
+
if (!/^[1-9]\d*$/u.test(String(issueField.fullDatabaseId)))
|
|
176
|
+
throw new DeliveryError("GitHub omitted the bound organization field database ID.");
|
|
177
|
+
readOptions(issueField.options, "organization field");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
nodes.push(node);
|
|
227
182
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
183
|
+
project = { ...pageProject, fields: { nodes } };
|
|
184
|
+
const pageInfo = requireRecord(fields.pageInfo, "GitHub omitted delivery Project field pagination.");
|
|
185
|
+
if (typeof pageInfo.hasNextPage !== "boolean")
|
|
186
|
+
throw new DeliveryError("GitHub omitted delivery Project pagination state.");
|
|
187
|
+
hasNextPage = pageInfo.hasNextPage === true;
|
|
188
|
+
const nextCursor = typeof pageInfo.endCursor === "string" ? pageInfo.endCursor : null;
|
|
189
|
+
assertAdvancingCursor({ cursor, hasNextPage, nextCursor, seenCursors, surface: "field" });
|
|
190
|
+
if (nextCursor !== null) seenCursors.add(nextCursor);
|
|
191
|
+
cursor = nextCursor;
|
|
192
|
+
}
|
|
193
|
+
if (project === null) {
|
|
194
|
+
throw new DeliveryError(`Expected organization Project #${String(input.number)}.`);
|
|
195
|
+
}
|
|
196
|
+
return project;
|
|
197
|
+
}
|
|
198
|
+
function projectSettingsFromDeliveryConfig(config) {
|
|
199
|
+
const project = config.native.project;
|
|
200
|
+
return {
|
|
201
|
+
number: project.number,
|
|
202
|
+
points: config.native.points,
|
|
203
|
+
priority: config.native.priority,
|
|
204
|
+
statuses: {
|
|
205
|
+
Blocked: project.statuses.blocked,
|
|
206
|
+
Done: project.statuses.done,
|
|
207
|
+
"In Progress": project.statuses.inProgress,
|
|
208
|
+
Todo: project.statuses.todo
|
|
209
|
+
},
|
|
210
|
+
statusField: project.statusField,
|
|
211
|
+
title: project.title
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function resolveProjectDeliveryConfiguration(raw, options) {
|
|
215
|
+
const settings = requireProjectSettings(options.settings);
|
|
216
|
+
const project = requireRecord(raw, "GitHub returned invalid delivery Project configuration.");
|
|
217
|
+
if (project.number !== settings.number || project.title !== settings.title) {
|
|
218
|
+
throw new DeliveryError(`Expected organization Project #${String(settings.number)} titled ${settings.title}.`);
|
|
219
|
+
}
|
|
220
|
+
if (options.requireWritable === true && project.viewerCanUpdate !== true) {
|
|
221
|
+
throw new DeliveryError(`Organization Project #${String(settings.number)} is not writable by this identity.`);
|
|
222
|
+
}
|
|
223
|
+
const projectId = requireString(project.id, "GitHub omitted the delivery Project node id.");
|
|
224
|
+
const fields = requireRecord(project.fields, "GitHub omitted delivery Project fields.");
|
|
225
|
+
if (!Array.isArray(fields.nodes)) {
|
|
226
|
+
throw new DeliveryError("GitHub returned invalid delivery Project field nodes.");
|
|
227
|
+
}
|
|
228
|
+
const statusField = requireExactlyOneField(fields.nodes, settings.statusField);
|
|
229
|
+
const pointsField = requireBoundIssueField({
|
|
230
|
+
expectedDatabaseId: settings.points.databaseId,
|
|
231
|
+
expectedOptions: settings.points.values,
|
|
232
|
+
fields: fields.nodes,
|
|
233
|
+
name: settings.points.name
|
|
234
|
+
});
|
|
235
|
+
const priorityField = requireBoundIssueField({
|
|
236
|
+
expectedDatabaseId: settings.priority.databaseId,
|
|
237
|
+
expectedOptions: settings.priority.values,
|
|
238
|
+
fields: fields.nodes,
|
|
239
|
+
name: settings.priority.name
|
|
240
|
+
});
|
|
241
|
+
if (statusField.__typename !== "ProjectV2SingleSelectField" || statusField.isIssueField !== false) {
|
|
242
|
+
throw new DeliveryError("Project Status must be the sole Project-owned single-select workflow field.");
|
|
243
|
+
}
|
|
244
|
+
if (PROJECT_DELIVERY_STATUSES.some((status) => settings.statuses[status] === PROJECT_REVIEW_STATUS))
|
|
245
|
+
throw new DeliveryError(`Rename the configured Status that uses ${PROJECT_REVIEW_STATUS}; that name is reserved.`);
|
|
246
|
+
const allStatusOptions = readOptions(statusField.options, `Project ${settings.statusField}`);
|
|
247
|
+
const reviewOptions = allStatusOptions.filter((option) => option.name === PROJECT_REVIEW_STATUS);
|
|
248
|
+
const statusOptions = allStatusOptions.filter((option) => option.name !== PROJECT_REVIEW_STATUS);
|
|
249
|
+
if (reviewOptions.length > 1)
|
|
250
|
+
throw new DeliveryError(`Project ${settings.statusField} repeats ${PROJECT_REVIEW_STATUS}.`);
|
|
251
|
+
assertExactOptionSet({
|
|
252
|
+
expected: PROJECT_DELIVERY_STATUSES.map((status) => settings.statuses[status]),
|
|
253
|
+
fieldName: `Project ${settings.statusField}`,
|
|
254
|
+
options: statusOptions
|
|
255
|
+
});
|
|
256
|
+
const statusOptionIds = Object.fromEntries(
|
|
257
|
+
PROJECT_DELIVERY_STATUSES.map((status) => [
|
|
258
|
+
status,
|
|
259
|
+
statusOptions.find((option) => option.name === settings.statuses[status])?.id
|
|
260
|
+
])
|
|
261
|
+
);
|
|
262
|
+
return {
|
|
263
|
+
pointsFieldId: requireString(pointsField.id, "GitHub omitted the Project Points field id."),
|
|
264
|
+
priorityFieldId: requireString(priorityField.id, "GitHub omitted the Project Priority field id."),
|
|
265
|
+
projectId,
|
|
266
|
+
projectNumber: settings.number,
|
|
267
|
+
settings,
|
|
268
|
+
statusFieldId: requireString(statusField.id, "GitHub omitted the Project Status field id."),
|
|
269
|
+
statusOptionIds,
|
|
270
|
+
...reviewOptions[0] ? { reviewOptionId: reviewOptions[0].id } : {},
|
|
271
|
+
title: settings.title,
|
|
272
|
+
writable: project.viewerCanUpdate === true
|
|
273
|
+
};
|
|
249
274
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return { archived: false, itemId: item.id };
|
|
263
|
-
const response = await input.graphql(`
|
|
275
|
+
async function restoreIssueProjectItem(input) {
|
|
276
|
+
const configuration = input.configuration ?? await getProjectDeliveryConfiguration({
|
|
277
|
+
...input,
|
|
278
|
+
settings: requireProjectSettings(input.settings),
|
|
279
|
+
requireWritable: true
|
|
280
|
+
});
|
|
281
|
+
assertWritableConfiguration(configuration);
|
|
282
|
+
const item = await findIssueProjectItem({ ...input, configuration });
|
|
283
|
+
if (item === null) return null;
|
|
284
|
+
if (!item.archived) return { archived: false, itemId: item.id };
|
|
285
|
+
const response = await input.graphql(
|
|
286
|
+
`
|
|
264
287
|
mutation RestoreProjectDeliveryItem($projectId: ID!, $itemId: ID!) {
|
|
265
288
|
unarchiveProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {
|
|
266
289
|
item { id isArchived }
|
|
267
290
|
}
|
|
268
291
|
}
|
|
269
|
-
`,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
292
|
+
`,
|
|
293
|
+
{ itemId: item.id, projectId: configuration.projectId }
|
|
294
|
+
);
|
|
295
|
+
const record = requireRecord(response, "GitHub returned invalid Project restore evidence.");
|
|
296
|
+
const payload = requireRecord(record.unarchiveProjectV2Item, "GitHub omitted Project restore payload.");
|
|
297
|
+
const restoredItem = requireRecord(payload.item, "GitHub omitted the restored Project item.");
|
|
298
|
+
if (restoredItem.id !== item.id || restoredItem.isArchived !== false) {
|
|
299
|
+
throw new DeliveryError("Project restore mutation did not return the exact active item.");
|
|
300
|
+
}
|
|
301
|
+
await readBackProjectArchiveState({
|
|
302
|
+
archived: false,
|
|
303
|
+
configuration,
|
|
304
|
+
graphql: input.graphql,
|
|
305
|
+
issueNodeId: input.issueNodeId,
|
|
306
|
+
itemId: item.id
|
|
307
|
+
});
|
|
308
|
+
return { archived: false, itemId: item.id };
|
|
284
309
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
310
|
+
async function assertIssueProjectWritable(input) {
|
|
311
|
+
const configuration = input.configuration ?? await getProjectDeliveryConfiguration({
|
|
312
|
+
...input,
|
|
313
|
+
settings: requireProjectSettings(input.settings),
|
|
314
|
+
requireWritable: true
|
|
315
|
+
});
|
|
316
|
+
assertWritableConfiguration(configuration);
|
|
317
|
+
const item = await findIssueProjectItem({ ...input, configuration });
|
|
318
|
+
if (item?.archived === true) {
|
|
319
|
+
if (input.preserveArchived) return item.id;
|
|
320
|
+
throw new DeliveryError("The issue delivery Project item is archived and cannot be updated.");
|
|
321
|
+
}
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
async function ensureIssueProjectMembership(input) {
|
|
325
|
+
const configuration = input.configuration ?? await getProjectDeliveryConfiguration({
|
|
326
|
+
...input,
|
|
327
|
+
settings: requireProjectSettings(input.settings),
|
|
328
|
+
requireWritable: true
|
|
329
|
+
});
|
|
330
|
+
assertWritableConfiguration(configuration);
|
|
331
|
+
const existing = await findIssueProjectItem({ ...input, configuration });
|
|
332
|
+
if (existing?.archived) throw new DeliveryError("The issue delivery Project item is archived and cannot be updated.");
|
|
333
|
+
let itemId = existing?.id;
|
|
334
|
+
if (itemId === void 0) {
|
|
335
|
+
await input.beforeAdd?.();
|
|
336
|
+
const response = await input.graphql(
|
|
337
|
+
`
|
|
305
338
|
mutation AddProjectDeliveryItem($projectId: ID!, $contentId: ID!) {
|
|
306
339
|
addProjectV2ItemById(input: { projectId: $projectId, contentId: $contentId }) {
|
|
307
340
|
item { id }
|
|
308
341
|
}
|
|
309
342
|
}
|
|
310
|
-
`,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
343
|
+
`,
|
|
344
|
+
{ contentId: input.issueNodeId, projectId: configuration.projectId }
|
|
345
|
+
);
|
|
346
|
+
const added = requireRecord(response, "GitHub returned invalid Project item creation evidence.");
|
|
347
|
+
const payload = requireRecord(added.addProjectV2ItemById, "GitHub omitted Project item creation payload.");
|
|
348
|
+
const created = requireRecord(payload.item, "GitHub omitted the created Project item.");
|
|
349
|
+
itemId = requireString(created.id, "GitHub omitted the created Project item id.");
|
|
350
|
+
}
|
|
351
|
+
input.onItemKnown?.(itemId);
|
|
352
|
+
const item = await readProjectItem({ configuration, graphql: input.graphql, issueNodeId: input.issueNodeId, itemId });
|
|
353
|
+
if (item.archived) throw new DeliveryError("Project membership readback is archived.");
|
|
354
|
+
return { itemId, archived: false };
|
|
355
|
+
}
|
|
356
|
+
async function syncIssueProjectStatus(input) {
|
|
357
|
+
const configuration = input.configuration ?? await getProjectDeliveryConfiguration({
|
|
358
|
+
...input,
|
|
359
|
+
settings: requireProjectSettings(input.settings),
|
|
360
|
+
requireWritable: true
|
|
361
|
+
});
|
|
362
|
+
assertWritableConfiguration(configuration);
|
|
363
|
+
let item = await findIssueProjectItem({ ...input, configuration });
|
|
364
|
+
if (item?.archived === true) {
|
|
365
|
+
throw new DeliveryError("The issue delivery Project item is archived and cannot be updated.");
|
|
366
|
+
}
|
|
367
|
+
if (item !== null && item.status !== null && item.statusOptionId !== null && requireItemStatus(item, configuration) === input.status) {
|
|
368
|
+
return { itemId: item.id, status: input.status };
|
|
369
|
+
}
|
|
370
|
+
if (item === null) {
|
|
371
|
+
const membership = await ensureIssueProjectMembership({ ...input, configuration });
|
|
372
|
+
item = { archived: false, contentId: input.issueNodeId, id: membership.itemId, status: null, statusOptionId: null };
|
|
373
|
+
}
|
|
374
|
+
const optionId = configuration.statusOptionIds[input.status];
|
|
375
|
+
await input.beforeAdvance?.();
|
|
376
|
+
const updateResponse = await input.graphql(
|
|
377
|
+
`
|
|
325
378
|
mutation UpdateProjectDeliveryStatus($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {
|
|
326
379
|
updateProjectV2ItemFieldValue(
|
|
327
380
|
input: {
|
|
@@ -334,64 +387,75 @@ export async function syncIssueProjectStatus(input) {
|
|
|
334
387
|
projectV2Item { id }
|
|
335
388
|
}
|
|
336
389
|
}
|
|
337
|
-
`,
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const update = requireRecord(updateResponse, 'GitHub returned invalid Project Status mutation evidence.');
|
|
344
|
-
const updatePayload = requireRecord(update.updateProjectV2ItemFieldValue, 'GitHub omitted Project Status mutation payload.');
|
|
345
|
-
const updatedItem = requireRecord(updatePayload.projectV2Item, 'GitHub omitted the updated Project item.');
|
|
346
|
-
if (updatedItem.id !== item.id) {
|
|
347
|
-
throw new DeliveryError('Project Status mutation returned a different item identity.');
|
|
390
|
+
`,
|
|
391
|
+
{
|
|
392
|
+
fieldId: configuration.statusFieldId,
|
|
393
|
+
itemId: item.id,
|
|
394
|
+
optionId,
|
|
395
|
+
projectId: configuration.projectId
|
|
348
396
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
397
|
+
);
|
|
398
|
+
const update = requireRecord(updateResponse, "GitHub returned invalid Project Status mutation evidence.");
|
|
399
|
+
const updatePayload = requireRecord(
|
|
400
|
+
update.updateProjectV2ItemFieldValue,
|
|
401
|
+
"GitHub omitted Project Status mutation payload."
|
|
402
|
+
);
|
|
403
|
+
const updatedItem = requireRecord(updatePayload.projectV2Item, "GitHub omitted the updated Project item.");
|
|
404
|
+
if (updatedItem.id !== item.id) {
|
|
405
|
+
throw new DeliveryError("Project Status mutation returned a different item identity.");
|
|
406
|
+
}
|
|
407
|
+
return await readBackProjectItem({
|
|
408
|
+
configuration,
|
|
409
|
+
graphql: input.graphql,
|
|
410
|
+
issueNodeId: input.issueNodeId,
|
|
411
|
+
itemId: item.id,
|
|
412
|
+
status: input.status
|
|
413
|
+
});
|
|
356
414
|
}
|
|
357
415
|
function assertAdvancingCursor(input) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
throw new DeliveryError(`Delivery Project ${input.surface} pagination repeated a non-advancing cursor.`);
|
|
365
|
-
}
|
|
416
|
+
if (input.hasNextPage && input.nextCursor === null) {
|
|
417
|
+
throw new DeliveryError(`Delivery Project ${input.surface} pagination omitted its next cursor.`);
|
|
418
|
+
}
|
|
419
|
+
if (input.hasNextPage && input.nextCursor !== null && (input.nextCursor === input.cursor || input.seenCursors.has(input.nextCursor))) {
|
|
420
|
+
throw new DeliveryError(`Delivery Project ${input.surface} pagination repeated a non-advancing cursor.`);
|
|
421
|
+
}
|
|
366
422
|
}
|
|
367
423
|
function assertExactOptionSet(input) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
424
|
+
const observed = input.options.map((option) => option.name);
|
|
425
|
+
const observedSet = new Set(observed);
|
|
426
|
+
const expectedSet = new Set(input.expected);
|
|
427
|
+
if (observedSet.size !== observed.length || observedSet.size !== expectedSet.size || observed.some((option) => !expectedSet.has(option))) {
|
|
428
|
+
throw new DeliveryError(
|
|
429
|
+
`${input.fieldName} options must be exactly ${input.expected.join(", ")} (order is provider-owned).`
|
|
430
|
+
);
|
|
431
|
+
}
|
|
376
432
|
}
|
|
377
433
|
function assertWritableConfiguration(configuration) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
434
|
+
if (!configuration.writable) {
|
|
435
|
+
throw new DeliveryError(
|
|
436
|
+
`Organization Project #${String(configuration.projectNumber)} is not writable by this identity.`
|
|
437
|
+
);
|
|
438
|
+
}
|
|
381
439
|
}
|
|
382
|
-
async function
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
440
|
+
async function fetchProjectDeliveryItemNodes(input) {
|
|
441
|
+
const nodes = [];
|
|
442
|
+
let cursor = null;
|
|
443
|
+
let hasNextPage = true;
|
|
444
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
445
|
+
let pages = 0;
|
|
446
|
+
if (input.maxPages !== void 0 && (!Number.isSafeInteger(input.maxPages) || input.maxPages <= 0))
|
|
447
|
+
throw new DeliveryError("Project item page budget must be positive.");
|
|
448
|
+
while (hasNextPage) {
|
|
449
|
+
if (input.maxPages !== void 0 && pages >= input.maxPages)
|
|
450
|
+
throw new CollectionLimitError({
|
|
451
|
+
collection: "project-items",
|
|
452
|
+
pagesRequested: pages,
|
|
453
|
+
rowsObserved: nodes.length,
|
|
454
|
+
limit: input.maxPages
|
|
455
|
+
});
|
|
456
|
+
pages++;
|
|
457
|
+
const response = await input.graphql(
|
|
458
|
+
`
|
|
395
459
|
query ProjectDeliveryItems($org: String!, $number: Int!, $cursor: String, $statusField: String!) {
|
|
396
460
|
organization(login: $org) {
|
|
397
461
|
projectV2(number: $number) {
|
|
@@ -401,7 +465,7 @@ async function findIssueProjectItem(input) {
|
|
|
401
465
|
nodes {
|
|
402
466
|
id
|
|
403
467
|
isArchived
|
|
404
|
-
content { ... on Issue { id } }
|
|
468
|
+
content { __typename ... on Issue { id number repository { nameWithOwner } } ... on PullRequest { id } ... on DraftIssue { id } }
|
|
405
469
|
fieldValueByName(name: $statusField) {
|
|
406
470
|
... on ProjectV2ItemFieldSingleSelectValue { name optionId }
|
|
407
471
|
}
|
|
@@ -411,82 +475,174 @@ async function findIssueProjectItem(input) {
|
|
|
411
475
|
}
|
|
412
476
|
}
|
|
413
477
|
}
|
|
414
|
-
`,
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (item !== null && item.contentId === input.issueNodeId)
|
|
433
|
-
matches.push(item);
|
|
434
|
-
}
|
|
435
|
-
const pageInfo = requireRecord(items.pageInfo, 'GitHub omitted delivery Project item pagination.');
|
|
436
|
-
if (input.capacityRead && typeof pageInfo.hasNextPage !== 'boolean')
|
|
437
|
-
throw new DeliveryError('WIP capacity Project pagination is incomplete.');
|
|
438
|
-
hasNextPage = pageInfo.hasNextPage === true;
|
|
439
|
-
const nextCursor = typeof pageInfo.endCursor === 'string' ? pageInfo.endCursor : null;
|
|
440
|
-
assertAdvancingCursor({ cursor, hasNextPage, nextCursor, seenCursors, surface: 'item' });
|
|
441
|
-
if (nextCursor !== null)
|
|
442
|
-
seenCursors.add(nextCursor);
|
|
443
|
-
cursor = nextCursor;
|
|
478
|
+
`,
|
|
479
|
+
{
|
|
480
|
+
cursor,
|
|
481
|
+
number: input.configuration.projectNumber,
|
|
482
|
+
org: input.org,
|
|
483
|
+
statusField: input.configuration.settings.statusField
|
|
484
|
+
}
|
|
485
|
+
);
|
|
486
|
+
const record = requireRecord(response, "GitHub returned invalid delivery Project item evidence.");
|
|
487
|
+
if (input.strictProjection && "errors" in record)
|
|
488
|
+
throw new DeliveryError("GitHub returned partial Project item evidence.");
|
|
489
|
+
const organization = requireRecord(record.organization, "GitHub omitted the delivery Project organization.");
|
|
490
|
+
const project = requireRecord(organization.projectV2, "GitHub omitted the delivery Project.");
|
|
491
|
+
if ((input.capacityRead || input.strictProjection) && (project.id !== input.configuration.projectId || project.number !== input.configuration.projectNumber))
|
|
492
|
+
throw new DeliveryError("WIP capacity Project identity disagrees with the configured Project.");
|
|
493
|
+
const items = requireRecord(project.items, "GitHub omitted delivery Project items.");
|
|
494
|
+
if (!Array.isArray(items.nodes)) {
|
|
495
|
+
throw new DeliveryError("GitHub returned invalid delivery Project items.");
|
|
444
496
|
}
|
|
445
|
-
|
|
446
|
-
|
|
497
|
+
nodes.push(...items.nodes);
|
|
498
|
+
const pageInfo = requireRecord(items.pageInfo, "GitHub omitted delivery Project item pagination.");
|
|
499
|
+
if ((input.capacityRead || input.strictProjection) && typeof pageInfo.hasNextPage !== "boolean" || input.capacityRead && pageInfo.endCursor !== null && typeof pageInfo.endCursor !== "string")
|
|
500
|
+
throw new DeliveryError("WIP capacity Project pagination is incomplete.");
|
|
501
|
+
hasNextPage = pageInfo.hasNextPage === true;
|
|
502
|
+
const nextCursor = typeof pageInfo.endCursor === "string" ? pageInfo.endCursor : null;
|
|
503
|
+
assertAdvancingCursor({ cursor, hasNextPage, nextCursor, seenCursors, surface: "item" });
|
|
504
|
+
if (nextCursor !== null) seenCursors.add(nextCursor);
|
|
505
|
+
cursor = nextCursor;
|
|
506
|
+
}
|
|
507
|
+
return nodes;
|
|
508
|
+
}
|
|
509
|
+
async function findIssueProjectItem(input) {
|
|
510
|
+
const response = await input.graphql(
|
|
511
|
+
`
|
|
512
|
+
query ProjectDeliveryIssueItems($issueNodeId: ID!, $statusField: String!) {
|
|
513
|
+
node(id: $issueNodeId) {
|
|
514
|
+
... on Issue {
|
|
515
|
+
id
|
|
516
|
+
projectItems(first: 50, includeArchived: true) {
|
|
517
|
+
nodes {
|
|
518
|
+
id
|
|
519
|
+
isArchived
|
|
520
|
+
project { id number }
|
|
521
|
+
content { ... on Issue { id } }
|
|
522
|
+
fieldValueByName(name: $statusField) {
|
|
523
|
+
... on ProjectV2ItemFieldSingleSelectValue { name optionId }
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
pageInfo { hasNextPage }
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
`,
|
|
532
|
+
{ issueNodeId: input.issueNodeId, statusField: input.configuration.settings.statusField }
|
|
533
|
+
);
|
|
534
|
+
const record = requireRecord(response, "GitHub returned invalid issue Project evidence.");
|
|
535
|
+
const node = requireRecord(record.node, "GitHub omitted the issue.");
|
|
536
|
+
const items = requireRecord(node.projectItems, "GitHub omitted the issue Project items.");
|
|
537
|
+
if (node.id !== input.issueNodeId || !Array.isArray(items.nodes))
|
|
538
|
+
throw new DeliveryError("GitHub returned Project items for a different issue.");
|
|
539
|
+
if (requireRecord(items.pageInfo, "GitHub omitted issue Project pagination.").hasNextPage !== false)
|
|
540
|
+
throw new DeliveryError("Issue belongs to more than 50 Projects; Project membership cannot be proved.");
|
|
541
|
+
const matches = [];
|
|
542
|
+
for (const raw of items.nodes) {
|
|
543
|
+
const project = requireRecord(
|
|
544
|
+
requireRecord(raw, "GitHub returned an invalid Project item.").project,
|
|
545
|
+
"GitHub omitted the Project item identity."
|
|
546
|
+
);
|
|
547
|
+
if (project.id !== input.configuration.projectId) continue;
|
|
548
|
+
const item = parseProjectItem(raw, input.configuration, input.capacityRead);
|
|
549
|
+
if (item?.contentId !== input.issueNodeId)
|
|
550
|
+
throw new DeliveryError("Project membership is unreadable; absence cannot be proved.");
|
|
551
|
+
matches.push(item);
|
|
552
|
+
}
|
|
553
|
+
if (matches.length > 1)
|
|
554
|
+
throw new DeliveryError(
|
|
555
|
+
`Issue has ${String(matches.length)} duplicate Project items in ${input.configuration.title}.`
|
|
556
|
+
);
|
|
557
|
+
return matches[0] ?? null;
|
|
558
|
+
}
|
|
559
|
+
async function readProjectDeliveryItems(input) {
|
|
560
|
+
const observations = [];
|
|
561
|
+
const ids = /* @__PURE__ */ new Set();
|
|
562
|
+
for (const raw of await fetchProjectDeliveryItemNodes({ ...input, strictProjection: true })) {
|
|
563
|
+
const record = requireRecord(raw, "GitHub returned invalid Project membership.");
|
|
564
|
+
if (typeof record.isArchived !== "boolean") throw new DeliveryError("Project archive projection is incomplete.");
|
|
565
|
+
const content = requireRecord(record.content, "Project content is unreadable; absence cannot be proved.");
|
|
566
|
+
const kind = content.__typename;
|
|
567
|
+
if (kind !== "Issue" && kind !== "DraftIssue" && kind !== "PullRequest")
|
|
568
|
+
throw new DeliveryError("Project content type is unreadable.");
|
|
569
|
+
let item = parseProjectItem({ ...record, fieldValueByName: null }, input.configuration);
|
|
570
|
+
if (!item || ids.has(item.id)) throw new DeliveryError("Project item identity is missing or repeated.");
|
|
571
|
+
let statusRead = record.fieldValueByName === null ? "unset" : "unreadable";
|
|
572
|
+
const rawStatus = isRecord(record.fieldValueByName) ? record.fieldValueByName : null;
|
|
573
|
+
const safeText = (value) => typeof value === "string" && value.length > 0 && value.length <= 512 ? value : null;
|
|
574
|
+
const statusName = safeText(rawStatus?.name);
|
|
575
|
+
if (record.fieldValueByName !== void 0 && record.fieldValueByName !== null) {
|
|
576
|
+
try {
|
|
577
|
+
item = parseProjectItem(record, input.configuration);
|
|
578
|
+
statusRead = "verified";
|
|
579
|
+
} catch {
|
|
580
|
+
item.statusOptionId = safeText(rawStatus?.optionId);
|
|
581
|
+
}
|
|
447
582
|
}
|
|
448
|
-
|
|
583
|
+
ids.add(item.id);
|
|
584
|
+
const identity = {
|
|
585
|
+
...item,
|
|
586
|
+
projectId: input.configuration.projectId,
|
|
587
|
+
projectNumber: input.configuration.projectNumber,
|
|
588
|
+
statusRead,
|
|
589
|
+
statusName
|
|
590
|
+
};
|
|
591
|
+
if (kind === "Issue") {
|
|
592
|
+
const repository = requireString(
|
|
593
|
+
requireRecord(content.repository, "Project issue repository is unreadable.").nameWithOwner,
|
|
594
|
+
"Project issue repository is missing."
|
|
595
|
+
);
|
|
596
|
+
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u.test(repository) || !Number.isSafeInteger(content.number) || Number(content.number) <= 0)
|
|
597
|
+
throw new DeliveryError("Project issue identity is invalid.");
|
|
598
|
+
observations.push({ ...identity, contentKind: "issue", repository, issueNumber: Number(content.number) });
|
|
599
|
+
} else observations.push({ ...identity, contentKind: kind === "DraftIssue" ? "draft" : "pull-request" });
|
|
600
|
+
}
|
|
601
|
+
return observations;
|
|
449
602
|
}
|
|
450
603
|
function isRecord(value) {
|
|
451
|
-
|
|
604
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
452
605
|
}
|
|
453
606
|
function parseProjectItem(raw, configuration, capacityRead = false) {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
status = canonicalStatus;
|
|
477
|
-
statusOptionId = optionId;
|
|
607
|
+
const item = requireRecord(raw, "GitHub returned an invalid delivery Project item.");
|
|
608
|
+
if (capacityRead && (typeof item.isArchived !== "boolean" || item.fieldValueByName === void 0))
|
|
609
|
+
throw new DeliveryError("WIP capacity Project status or archive evidence is missing.");
|
|
610
|
+
const content = item.content;
|
|
611
|
+
if (capacityRead && !item.isArchived && (content === null || content === void 0))
|
|
612
|
+
throw new DeliveryError("WIP capacity Project item content is unreadable.");
|
|
613
|
+
if (content === null || content === void 0) return null;
|
|
614
|
+
const contentRecord = requireRecord(content, "GitHub returned an invalid delivery Project item content node.");
|
|
615
|
+
const contentId = requireString(contentRecord.id, "GitHub omitted a delivery Project item content id.");
|
|
616
|
+
const fieldValue = item.fieldValueByName;
|
|
617
|
+
let status = null;
|
|
618
|
+
let statusOptionId = null;
|
|
619
|
+
let review = false;
|
|
620
|
+
if (fieldValue !== null && fieldValue !== void 0) {
|
|
621
|
+
const statusRecord = requireRecord(fieldValue, "GitHub returned invalid Project Status readback.");
|
|
622
|
+
const name = requireString(statusRecord.name, "GitHub omitted Project Status name.");
|
|
623
|
+
const optionId = requireString(statusRecord.optionId, "GitHub omitted Project Status option id.");
|
|
624
|
+
const statuses = configuration.settings.statuses;
|
|
625
|
+
review = name === PROJECT_REVIEW_STATUS && optionId === configuration.reviewOptionId;
|
|
626
|
+
const canonicalStatus = review ? "In Progress" : PROJECT_DELIVERY_STATUSES.find((candidate) => statuses[candidate] === name);
|
|
627
|
+
if (canonicalStatus === void 0 || !review && configuration.statusOptionIds[canonicalStatus] !== optionId) {
|
|
628
|
+
throw new DeliveryError(`GitHub returned unsupported Project Status ${name}.`);
|
|
478
629
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
630
|
+
status = canonicalStatus;
|
|
631
|
+
statusOptionId = review ? configuration.statusOptionIds["In Progress"] : optionId;
|
|
632
|
+
}
|
|
633
|
+
return {
|
|
634
|
+
archived: item.isArchived === true,
|
|
635
|
+
contentId,
|
|
636
|
+
id: requireString(item.id, "GitHub omitted the delivery Project item id."),
|
|
637
|
+
status,
|
|
638
|
+
statusOptionId,
|
|
639
|
+
...review ? { review: true } : {}
|
|
640
|
+
};
|
|
486
641
|
}
|
|
487
642
|
async function readBackProjectArchiveState(input) {
|
|
488
|
-
|
|
489
|
-
|
|
643
|
+
const response = await input.graphql(
|
|
644
|
+
`
|
|
645
|
+
query ${input.archived ? "Archived" : "Restored"}ProjectDeliveryItemReadback($itemId: ID!) {
|
|
490
646
|
node(id: $itemId) {
|
|
491
647
|
... on ProjectV2Item {
|
|
492
648
|
id
|
|
@@ -496,31 +652,28 @@ async function readBackProjectArchiveState(input) {
|
|
|
496
652
|
}
|
|
497
653
|
}
|
|
498
654
|
}
|
|
499
|
-
`,
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
throw new DeliveryError(`Project ${state} readback did not report the exact issue item.`);
|
|
511
|
-
}
|
|
655
|
+
`,
|
|
656
|
+
{ itemId: input.itemId }
|
|
657
|
+
);
|
|
658
|
+
const state = input.archived ? "archived" : "restored";
|
|
659
|
+
const record = requireRecord(response, `GitHub returned invalid ${state} Project item readback.`);
|
|
660
|
+
const node = requireRecord(record.node, `GitHub omitted ${state} Project item readback.`);
|
|
661
|
+
const project = requireRecord(node.project, `GitHub omitted ${state} Project identity readback.`);
|
|
662
|
+
const content = requireRecord(node.content, `GitHub omitted ${state} Project item content readback.`);
|
|
663
|
+
if (node.id !== input.itemId || node.isArchived !== input.archived || project.id !== input.configuration.projectId || project.number !== input.configuration.projectNumber || content.id !== input.issueNodeId) {
|
|
664
|
+
throw new DeliveryError(`Project ${state} readback did not report the exact issue item.`);
|
|
665
|
+
}
|
|
512
666
|
}
|
|
513
667
|
async function readBackProjectItem(input) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
-
return { itemId: input.itemId, status: input.status };
|
|
668
|
+
const item = await readProjectItem(input);
|
|
669
|
+
if (item.archived || item.status !== input.status || item.statusOptionId !== input.configuration.statusOptionIds[input.status]) {
|
|
670
|
+
throw new DeliveryError(`Project Status readback did not report ${input.status} for the exact issue item.`);
|
|
671
|
+
}
|
|
672
|
+
return { itemId: input.itemId, status: input.status };
|
|
521
673
|
}
|
|
522
674
|
async function readProjectItem(input) {
|
|
523
|
-
|
|
675
|
+
const response = await input.graphql(
|
|
676
|
+
`
|
|
524
677
|
query ProjectDeliveryItemReadback($itemId: ID!, $statusField: String!) {
|
|
525
678
|
node(id: $itemId) {
|
|
526
679
|
... on ProjectV2Item {
|
|
@@ -534,85 +687,95 @@ async function readProjectItem(input) {
|
|
|
534
687
|
}
|
|
535
688
|
}
|
|
536
689
|
}
|
|
537
|
-
`,
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
if (item === null)
|
|
551
|
-
throw new DeliveryError('GitHub omitted Project item content readback.');
|
|
552
|
-
return item;
|
|
690
|
+
`,
|
|
691
|
+
{ itemId: input.itemId, statusField: input.configuration.settings.statusField }
|
|
692
|
+
);
|
|
693
|
+
const record = requireRecord(response, "GitHub returned invalid Project item readback.");
|
|
694
|
+
const node = requireRecord(record.node, "GitHub omitted Project item readback.");
|
|
695
|
+
const project = requireRecord(node.project, "GitHub omitted Project identity readback.");
|
|
696
|
+
const content = requireRecord(node.content, "GitHub omitted Project item content readback.");
|
|
697
|
+
if (node.id !== input.itemId || typeof node.isArchived !== "boolean" || project.id !== input.configuration.projectId || project.number !== input.configuration.projectNumber || content.id !== input.issueNodeId) {
|
|
698
|
+
throw new DeliveryError("Project Status readback did not report the exact issue item.");
|
|
699
|
+
}
|
|
700
|
+
const item = parseProjectItem(node, input.configuration, input.capacityRead);
|
|
701
|
+
if (item === null) throw new DeliveryError("GitHub omitted Project item content readback.");
|
|
702
|
+
return item;
|
|
553
703
|
}
|
|
554
704
|
function readOptions(raw, fieldName) {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
705
|
+
if (!Array.isArray(raw)) {
|
|
706
|
+
throw new DeliveryError(`${fieldName} options are malformed.`);
|
|
707
|
+
}
|
|
708
|
+
return raw.map((option) => {
|
|
709
|
+
const record = requireRecord(option, `${fieldName} option is malformed.`);
|
|
710
|
+
return {
|
|
711
|
+
id: requireString(record.id, `${fieldName} option id is missing.`),
|
|
712
|
+
name: requireString(record.name, `${fieldName} option name is missing.`)
|
|
713
|
+
};
|
|
714
|
+
});
|
|
565
715
|
}
|
|
566
716
|
function requireBoundIssueField(input) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
})
|
|
586
|
-
|
|
717
|
+
const field = requireExactlyOneField(input.fields, input.name);
|
|
718
|
+
if (field.__typename !== "ProjectV2SingleSelectField" || field.isIssueField !== true) {
|
|
719
|
+
throw new DeliveryError(`Project ${input.name} must bind the organization issue field.`);
|
|
720
|
+
}
|
|
721
|
+
if (Array.isArray(field.options) && field.options.length !== 0) {
|
|
722
|
+
throw new DeliveryError(`Project ${input.name} must not define Project-owned duplicate options.`);
|
|
723
|
+
}
|
|
724
|
+
const issueField = requireRecord(
|
|
725
|
+
field.issueField,
|
|
726
|
+
`Project ${input.name} omitted its bound organization issue field.`
|
|
727
|
+
);
|
|
728
|
+
const databaseId = typeof issueField.fullDatabaseId === "string" ? issueField.fullDatabaseId : String(issueField.fullDatabaseId);
|
|
729
|
+
if (issueField.__typename !== "IssueFieldSingleSelect" || issueField.name !== input.name || databaseId !== input.expectedDatabaseId) {
|
|
730
|
+
throw new DeliveryError(`Project ${input.name} must bind organization issue field ${input.expectedDatabaseId}.`);
|
|
731
|
+
}
|
|
732
|
+
assertExactOptionSet({
|
|
733
|
+
expected: input.expectedOptions,
|
|
734
|
+
fieldName: input.name,
|
|
735
|
+
options: readOptions(issueField.options, `organization ${input.name}`)
|
|
736
|
+
});
|
|
737
|
+
return field;
|
|
587
738
|
}
|
|
588
739
|
function requireExactlyOneField(fields, name) {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
740
|
+
const matches = fields.filter((field) => isRecord(field) && field.name === name);
|
|
741
|
+
if (matches.length !== 1) {
|
|
742
|
+
throw new DeliveryError(`Expected exactly one Project ${name} field, found ${String(matches.length)}.`);
|
|
743
|
+
}
|
|
744
|
+
return matches[0];
|
|
594
745
|
}
|
|
595
746
|
function requireItemStatus(item, configuration) {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
return item.status;
|
|
747
|
+
if (item.status === null || item.statusOptionId === null || configuration.statusOptionIds[item.status] !== item.statusOptionId) {
|
|
748
|
+
throw new DeliveryError("The issue delivery Project item has no canonical Project Status.");
|
|
749
|
+
}
|
|
750
|
+
return item.status;
|
|
602
751
|
}
|
|
603
752
|
function requireRecord(value, message) {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
return value;
|
|
753
|
+
if (!isRecord(value)) throw new DeliveryError(message);
|
|
754
|
+
return value;
|
|
607
755
|
}
|
|
608
756
|
function requireString(value, message) {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
return value;
|
|
757
|
+
if (typeof value !== "string" || value.length === 0) throw new DeliveryError(message);
|
|
758
|
+
return value;
|
|
612
759
|
}
|
|
613
760
|
function requireProjectSettings(settings) {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
return settings;
|
|
761
|
+
if (settings === void 0) throw new DeliveryError("Project delivery settings are required.");
|
|
762
|
+
return settings;
|
|
617
763
|
}
|
|
618
|
-
|
|
764
|
+
export {
|
|
765
|
+
PROJECT_DELIVERY_STATUSES,
|
|
766
|
+
PROJECT_REVIEW_STATUS,
|
|
767
|
+
archiveIssueProjectItem,
|
|
768
|
+
assertIssueProjectWritable,
|
|
769
|
+
ensureIssueProjectMembership,
|
|
770
|
+
getArchivedIssueProjectStatus,
|
|
771
|
+
getIssueProjectStatus,
|
|
772
|
+
getProjectDeliveryConfiguration,
|
|
773
|
+
projectSettingsFromDeliveryConfig,
|
|
774
|
+
readBackProjectItem,
|
|
775
|
+
readProjectDeliveryDefinition,
|
|
776
|
+
readProjectDeliveryItems,
|
|
777
|
+
resolveProjectDeliveryConfiguration,
|
|
778
|
+
restoreIssueProjectItem,
|
|
779
|
+
syncIssueProjectStatus
|
|
780
|
+
};
|
|
781
|
+
//# sourceMappingURL=projectDelivery.js.map
|