@knpkv/codecommit-core 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/AwsClient/AwsClientGated.d.ts.map +1 -1
  2. package/dist/AwsClient/AwsClientGated.js +0 -2
  3. package/dist/AwsClient/AwsClientGated.js.map +1 -1
  4. package/dist/AwsClient/approvalRuleContent.d.ts +2 -1
  5. package/dist/AwsClient/approvalRuleContent.d.ts.map +1 -1
  6. package/dist/AwsClient/approvalRuleContent.js +25 -18
  7. package/dist/AwsClient/approvalRuleContent.js.map +1 -1
  8. package/dist/AwsClient/getCallerIdentity.d.ts +2 -0
  9. package/dist/AwsClient/getCallerIdentity.d.ts.map +1 -1
  10. package/dist/AwsClient/getCallerIdentity.js +8 -4
  11. package/dist/AwsClient/getCallerIdentity.js.map +1 -1
  12. package/dist/AwsClient/getPullRequest.d.ts.map +1 -1
  13. package/dist/AwsClient/getPullRequest.js +19 -10
  14. package/dist/AwsClient/getPullRequest.js.map +1 -1
  15. package/dist/AwsClient/getPullRequests.d.ts +30 -23
  16. package/dist/AwsClient/getPullRequests.d.ts.map +1 -1
  17. package/dist/AwsClient/getPullRequests.js +47 -32
  18. package/dist/AwsClient/getPullRequests.js.map +1 -1
  19. package/dist/AwsClient/index.d.ts +1 -10
  20. package/dist/AwsClient/index.d.ts.map +1 -1
  21. package/dist/AwsClient/index.js +0 -1
  22. package/dist/AwsClient/index.js.map +1 -1
  23. package/dist/AwsClient/internal.d.ts +11 -1
  24. package/dist/AwsClient/internal.d.ts.map +1 -1
  25. package/dist/AwsClient/internal.js +7 -0
  26. package/dist/AwsClient/internal.js.map +1 -1
  27. package/dist/AwsClientConfig/internal/ProfileCredentialProvider.d.ts +2 -17
  28. package/dist/AwsClientConfig/internal/ProfileCredentialProvider.d.ts.map +1 -1
  29. package/dist/AwsClientConfig/internal/ProfileCredentialProvider.js +2 -6
  30. package/dist/AwsClientConfig/internal/ProfileCredentialProvider.js.map +1 -1
  31. package/dist/AwsClientConfig.js +1 -1
  32. package/dist/AwsClientConfig.js.map +1 -1
  33. package/dist/AwsCredentialErrors.d.ts +8 -0
  34. package/dist/AwsCredentialErrors.d.ts.map +1 -0
  35. package/dist/AwsCredentialErrors.js +40 -0
  36. package/dist/AwsCredentialErrors.js.map +1 -0
  37. package/dist/AwsProfileCredentials.d.ts +23 -0
  38. package/dist/AwsProfileCredentials.d.ts.map +1 -0
  39. package/dist/AwsProfileCredentials.js +29 -0
  40. package/dist/AwsProfileCredentials.js.map +1 -0
  41. package/dist/CacheService/Database.d.ts +1 -1
  42. package/dist/CacheService/Database.d.ts.map +1 -1
  43. package/dist/CacheService/Database.js +6 -2
  44. package/dist/CacheService/Database.js.map +1 -1
  45. package/dist/CacheService/diff.d.ts +10 -0
  46. package/dist/CacheService/diff.d.ts.map +1 -1
  47. package/dist/CacheService/diff.js +12 -1
  48. package/dist/CacheService/diff.js.map +1 -1
  49. package/dist/CacheService/migrations/0022_pull_request_approval_unknown.d.ts +9 -0
  50. package/dist/CacheService/migrations/0022_pull_request_approval_unknown.d.ts.map +1 -0
  51. package/dist/CacheService/migrations/0022_pull_request_approval_unknown.js +8 -0
  52. package/dist/CacheService/migrations/0022_pull_request_approval_unknown.js.map +1 -0
  53. package/dist/CacheService/migrations/0023_pull_request_row_versions.d.ts +17 -0
  54. package/dist/CacheService/migrations/0023_pull_request_row_versions.d.ts.map +1 -0
  55. package/dist/CacheService/migrations/0023_pull_request_row_versions.js +37 -0
  56. package/dist/CacheService/migrations/0023_pull_request_row_versions.js.map +1 -0
  57. package/dist/CacheService/repos/PullRequestRepo/index.d.ts +34 -8
  58. package/dist/CacheService/repos/PullRequestRepo/index.d.ts.map +1 -1
  59. package/dist/CacheService/repos/PullRequestRepo/index.js +1 -1
  60. package/dist/CacheService/repos/PullRequestRepo/index.js.map +1 -1
  61. package/dist/CacheService/repos/PullRequestRepo/internal.d.ts +69 -2
  62. package/dist/CacheService/repos/PullRequestRepo/internal.d.ts.map +1 -1
  63. package/dist/CacheService/repos/PullRequestRepo/internal.js +73 -2
  64. package/dist/CacheService/repos/PullRequestRepo/internal.js.map +1 -1
  65. package/dist/CacheService/repos/PullRequestRepo/mutations.d.ts +39 -16
  66. package/dist/CacheService/repos/PullRequestRepo/mutations.d.ts.map +1 -1
  67. package/dist/CacheService/repos/PullRequestRepo/mutations.js +61 -92
  68. package/dist/CacheService/repos/PullRequestRepo/mutations.js.map +1 -1
  69. package/dist/CacheService/repos/PullRequestRepo/queries.d.ts +24 -0
  70. package/dist/CacheService/repos/PullRequestRepo/queries.d.ts.map +1 -1
  71. package/dist/CacheService/repos/PullRequestRepo/queries.js +10 -3
  72. package/dist/CacheService/repos/PullRequestRepo/queries.js.map +1 -1
  73. package/dist/CacheService/repos/PullRequestRepo/rowWrites.d.ts +131 -0
  74. package/dist/CacheService/repos/PullRequestRepo/rowWrites.d.ts.map +1 -0
  75. package/dist/CacheService/repos/PullRequestRepo/rowWrites.js +214 -0
  76. package/dist/CacheService/repos/PullRequestRepo/rowWrites.js.map +1 -0
  77. package/dist/CacheService/repos/StatsRepo/internal.d.ts +0 -1
  78. package/dist/CacheService/repos/StatsRepo/internal.d.ts.map +1 -1
  79. package/dist/CacheService/repos/StatsRepo/internal.js.map +1 -1
  80. package/dist/CacheService/repos/StatsRepo/queries.d.ts.map +1 -1
  81. package/dist/CacheService/repos/StatsRepo/queries.js +2 -1
  82. package/dist/CacheService/repos/StatsRepo/queries.js.map +1 -1
  83. package/dist/CacheService/repos/StatsRepo/reviewerData.d.ts.map +1 -1
  84. package/dist/CacheService/repos/StatsRepo/reviewerData.js +1 -2
  85. package/dist/CacheService/repos/StatsRepo/reviewerData.js.map +1 -1
  86. package/dist/Domain.d.ts +153 -7
  87. package/dist/Domain.d.ts.map +1 -1
  88. package/dist/Domain.js +107 -1
  89. package/dist/Domain.js.map +1 -1
  90. package/dist/HealthScore.d.ts +1 -1
  91. package/dist/HealthScore.d.ts.map +1 -1
  92. package/dist/HealthScore.js +20 -5
  93. package/dist/HealthScore.js.map +1 -1
  94. package/dist/IdentityLifecycle.d.ts +288 -0
  95. package/dist/IdentityLifecycle.d.ts.map +1 -0
  96. package/dist/IdentityLifecycle.js +125 -0
  97. package/dist/IdentityLifecycle.js.map +1 -0
  98. package/dist/PRService/internal.d.ts +17 -1
  99. package/dist/PRService/internal.d.ts.map +1 -1
  100. package/dist/PRService/internal.js +8 -0
  101. package/dist/PRService/internal.js.map +1 -1
  102. package/dist/PRService/refresh.d.ts.map +1 -1
  103. package/dist/PRService/refresh.js +2 -1
  104. package/dist/PRService/refresh.js.map +1 -1
  105. package/dist/PRService/refreshDiffs.d.ts.map +1 -1
  106. package/dist/PRService/refreshDiffs.js +8 -5
  107. package/dist/PRService/refreshDiffs.js.map +1 -1
  108. package/dist/PRService/refreshEnrich.d.ts.map +1 -1
  109. package/dist/PRService/refreshEnrich.js +26 -45
  110. package/dist/PRService/refreshEnrich.js.map +1 -1
  111. package/dist/PRService/refreshFetch.d.ts +3 -1
  112. package/dist/PRService/refreshFetch.d.ts.map +1 -1
  113. package/dist/PRService/refreshFetch.js +108 -74
  114. package/dist/PRService/refreshFetch.js.map +1 -1
  115. package/dist/PRService/refreshHistory.d.ts.map +1 -1
  116. package/dist/PRService/refreshHistory.js +19 -11
  117. package/dist/PRService/refreshHistory.js.map +1 -1
  118. package/dist/PRService/refreshResolve.d.ts +10 -0
  119. package/dist/PRService/refreshResolve.d.ts.map +1 -1
  120. package/dist/PRService/refreshResolve.js +43 -28
  121. package/dist/PRService/refreshResolve.js.map +1 -1
  122. package/dist/PRService/refreshScore.d.ts.map +1 -1
  123. package/dist/PRService/refreshScore.js +4 -2
  124. package/dist/PRService/refreshScore.js.map +1 -1
  125. package/dist/PRService/refreshSinglePR.d.ts.map +1 -1
  126. package/dist/PRService/refreshSinglePR.js +44 -25
  127. package/dist/PRService/refreshSinglePR.js.map +1 -1
  128. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as SqlClient from "effect/sql/SqlClient";
3
+ /**
4
+ * Why the last approval evaluation failed, as the reason's tag; NULL when it succeeded. While set,
5
+ * `is_approved` is only the last known value.
6
+ */
7
+ export default Effect.flatMap(SqlClient.SqlClient, (sql) => sql `ALTER TABLE pull_requests ADD COLUMN approval_unknown_reason TEXT`);
8
+ //# sourceMappingURL=0022_pull_request_approval_unknown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0022_pull_request_approval_unknown.js","sourceRoot":"","sources":["../../../src/CacheService/migrations/0022_pull_request_approval_unknown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;GAGG;AACH,eAAe,MAAM,CAAC,OAAO,CAC3B,SAAS,CAAC,SAAS,EACnB,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAA,mEAAmE,CAChF,CAAA"}
@@ -0,0 +1,17 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as SqlClient from "effect/sql/SqlClient";
3
+ /**
4
+ * Row versions for `pull_requests`, one per column group, each (provider last activity, observation)
5
+ * compared in that order: `last_modified_date`/`observation_seq` for the row, and
6
+ * `approval_version`/`approval_observation_seq` for the approval (`is_approved`,
7
+ * `approval_unknown_reason`, `approval_rules`), which an approval re-read writes on its own. The
8
+ * observation comes from `observation_sequence`, incremented once per read before the provider call,
9
+ * so two reads of the same provider revision are still ordered by when they began.
10
+ *
11
+ * `pull_request_tombstones` keeps the version at which a row was deleted: an insert observed at or
12
+ * before it is a no-op, so a slower read can't bring a deleted pull request back, while a newer one
13
+ * can. A tombstone expires by `deleted_at`, the cache clock.
14
+ */
15
+ declare const _default: Effect.Effect<void, import("effect/sql/SqlError").SqlError, SqlClient.SqlClient>;
16
+ export default _default;
17
+ //# sourceMappingURL=0023_pull_request_row_versions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0023_pull_request_row_versions.d.ts","sourceRoot":"","sources":["../../../src/CacheService/migrations/0023_pull_request_row_versions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;;;;;;;GAWG"}
@@ -0,0 +1,37 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as SqlClient from "effect/sql/SqlClient";
3
+ /**
4
+ * Row versions for `pull_requests`, one per column group, each (provider last activity, observation)
5
+ * compared in that order: `last_modified_date`/`observation_seq` for the row, and
6
+ * `approval_version`/`approval_observation_seq` for the approval (`is_approved`,
7
+ * `approval_unknown_reason`, `approval_rules`), which an approval re-read writes on its own. The
8
+ * observation comes from `observation_sequence`, incremented once per read before the provider call,
9
+ * so two reads of the same provider revision are still ordered by when they began.
10
+ *
11
+ * `pull_request_tombstones` keeps the version at which a row was deleted: an insert observed at or
12
+ * before it is a no-op, so a slower read can't bring a deleted pull request back, while a newer one
13
+ * can. A tombstone expires by `deleted_at`, the cache clock.
14
+ */
15
+ export default Effect.flatMap(SqlClient.SqlClient, (sql) => Effect.all([
16
+ sql `ALTER TABLE pull_requests ADD COLUMN observation_seq INTEGER NOT NULL DEFAULT 0`,
17
+ sql `ALTER TABLE pull_requests ADD COLUMN approval_version TEXT NOT NULL DEFAULT ''`,
18
+ sql `ALTER TABLE pull_requests ADD COLUMN approval_observation_seq INTEGER NOT NULL DEFAULT 0`,
19
+ sql `UPDATE pull_requests SET approval_version = last_modified_date`,
20
+ sql `CREATE TABLE IF NOT EXISTS observation_sequence (
21
+ id INTEGER PRIMARY KEY CHECK (id = 1),
22
+ value INTEGER NOT NULL
23
+ )`,
24
+ sql `INSERT OR IGNORE INTO observation_sequence (id, value) VALUES (1, 0)`,
25
+ sql `CREATE TABLE IF NOT EXISTS pull_request_tombstones (
26
+ aws_account_id TEXT NOT NULL,
27
+ id TEXT NOT NULL,
28
+ repository_name TEXT NOT NULL,
29
+ account_region TEXT NOT NULL,
30
+ version TEXT NOT NULL,
31
+ observation_seq INTEGER NOT NULL,
32
+ -- When the row was deleted, on the cache clock: tombstones expire by it, like fetched_at.
33
+ deleted_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
34
+ PRIMARY KEY (aws_account_id, id, repository_name, account_region)
35
+ )`
36
+ ], { discard: true }));
37
+ //# sourceMappingURL=0023_pull_request_row_versions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0023_pull_request_row_versions.js","sourceRoot":"","sources":["../../../src/CacheService/migrations/0023_pull_request_row_versions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;;;;;;;GAWG;AACH,eAAe,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CACzD,MAAM,CAAC,GAAG,CAAC;IACT,GAAG,CAAA,iFAAiF;IACpF,GAAG,CAAA,gFAAgF;IACnF,GAAG,CAAA,0FAA0F;IAC7F,GAAG,CAAA,gEAAgE;IACnE,GAAG,CAAA;;;MAGD;IACF,GAAG,CAAA,sEAAsE;IACzE,GAAG,CAAA;;;;;;;;;;MAUD;CACH,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA"}
@@ -12,19 +12,21 @@ import type { Success } from "effect/Effect";
12
12
  import * as SqlClient from "effect/sql/SqlClient";
13
13
  import { EventsHub } from "../../EventsHub.js";
14
14
  import * as Q from "./queries.js";
15
- export { CachedPullRequest, type SearchResult, UpsertInput } from "./internal.js";
15
+ export { approvalColumnsOf, type ApprovalRead, CachedPullRequest, type SearchResult, UpsertInput, versionsOf } from "./internal.js";
16
16
  export type { CachedPullRequest as CachedPullRequestType } from "./internal.js";
17
+ export type { UpsertResult } from "./mutations.js";
17
18
  export { PullRequestAmbiguityError } from "./queries.js";
19
+ export type { ApprovalGroup, DerivedColumns, GroupsWritten, RowGroup, RowVersion, RowVersions } from "./rowWrites.js";
18
20
  declare const makePullRequestRepo: Effect.Effect<{
19
- upsert: (input: import("./internal.js").UpsertInput) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
20
- upsertMany: (prs: ReadonlyArray<import("./internal.js").UpsertInput>) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
21
+ observe: () => Effect.Effect<number, import("../../CacheError.ts").CacheError, never>;
22
+ upsert: (input: import("./internal.js").UpsertInput, observation: number) => Effect.Effect<import("./mutations.js").UpsertResult, import("../../CacheError.ts").CacheError, never>;
23
+ upsertRead: (input: import("./internal.js").UpsertInput, read: Parameters<typeof import("./internal.js").rowGroupOfRead>[0] & import("./internal.js").ApprovalRead, observation: number) => Effect.Effect<import("./mutations.js").UpsertResult, import("../../CacheError.ts").CacheError, never>;
24
+ upsertMany: (prs: ReadonlyArray<import("./internal.js").UpsertInput>, observation: number) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
25
+ writeRead: (awsAccountId: string, id: string, read: Parameters<typeof import("./internal.js").rowGroupOfRead>[0] & import("./internal.js").ApprovalRead, observation: number, coordinates?: import("./mutations.js").PullRequestCoordinates) => Effect.Effect<import("./rowWrites.js").GroupsWritten, import("../../CacheError.ts").CacheError, never>;
26
+ writeDerived: (awsAccountId: string, id: string, observed: import("./rowWrites.js").RowVersions, columns: import("./rowWrites.js").DerivedColumns, coordinates?: import("./mutations.js").PullRequestCoordinates) => Effect.Effect<boolean, import("../../CacheError.ts").CacheError, never>;
21
27
  deleteStale: (olderThan: string) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
22
28
  deleteStaleOpen: (olderThan: string) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
23
- deleteOne: (awsAccountId: string, id: string, coordinates?: import("./mutations.js").PullRequestCoordinates) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
24
- updateDiffStats: (awsAccountId: string, id: string, filesAdded: number, filesModified: number, filesDeleted: number, coordinates?: import("./mutations.js").PullRequestCoordinates) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
25
- updateStatusAndClosedAt: (awsAccountId: string, id: string, status: string, closedAt: string, mergedBy?: string, approvedBy?: ReadonlyArray<string>, coordinates?: import("./mutations.js").PullRequestCoordinates) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
26
- updateCommentCount: (awsAccountId: string, id: string, count: number | null, coordinates?: import("./mutations.js").PullRequestCoordinates) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
27
- updateHealthScore: (awsAccountId: string, id: string, score: number, coordinates?: import("./mutations.js").PullRequestCoordinates) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
29
+ deleteOne: (awsAccountId: string, id: string, observation: number, coordinates?: import("./mutations.js").PullRequestCoordinates) => Effect.Effect<boolean, import("../../CacheError.ts").CacheError, never>;
28
30
  refreshCommentedBy: () => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
29
31
  propagateRepoAccountId: () => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
30
32
  findAll: () => Effect.Effect<{
@@ -39,11 +41,15 @@ declare const makePullRequestRepo: Effect.Effect<{
39
41
  readonly repositoryName: string & import("effect/Brand").Brand<"RepositoryName">;
40
42
  readonly creationDate: Date;
41
43
  readonly lastModifiedDate: Date;
44
+ readonly observationSeq: number;
45
+ readonly approvalVersion: Date;
46
+ readonly approvalObservationSeq: number;
42
47
  readonly status: "CLOSED" | "MERGED" | "OPEN";
43
48
  readonly sourceBranch: string;
44
49
  readonly destinationBranch: string;
45
50
  readonly isMergeable: boolean;
46
51
  readonly isApproved: boolean;
52
+ readonly approvalUnknownReason: "NotPermitted" | "ProviderFailed" | "Throttled" | null;
47
53
  readonly commentCount: number | null;
48
54
  readonly healthScore: number | null;
49
55
  readonly link: string;
@@ -70,11 +76,15 @@ declare const makePullRequestRepo: Effect.Effect<{
70
76
  readonly repositoryName: string & import("effect/Brand").Brand<"RepositoryName">;
71
77
  readonly creationDate: Date;
72
78
  readonly lastModifiedDate: Date;
79
+ readonly observationSeq: number;
80
+ readonly approvalVersion: Date;
81
+ readonly approvalObservationSeq: number;
73
82
  readonly status: "CLOSED" | "MERGED" | "OPEN";
74
83
  readonly sourceBranch: string;
75
84
  readonly destinationBranch: string;
76
85
  readonly isMergeable: boolean;
77
86
  readonly isApproved: boolean;
87
+ readonly approvalUnknownReason: "NotPermitted" | "ProviderFailed" | "Throttled" | null;
78
88
  readonly commentCount: number | null;
79
89
  readonly healthScore: number | null;
80
90
  readonly link: string;
@@ -101,11 +111,15 @@ declare const makePullRequestRepo: Effect.Effect<{
101
111
  readonly repositoryName: string & import("effect/Brand").Brand<"RepositoryName">;
102
112
  readonly creationDate: Date;
103
113
  readonly lastModifiedDate: Date;
114
+ readonly observationSeq: number;
115
+ readonly approvalVersion: Date;
116
+ readonly approvalObservationSeq: number;
104
117
  readonly status: "CLOSED" | "MERGED" | "OPEN";
105
118
  readonly sourceBranch: string;
106
119
  readonly destinationBranch: string;
107
120
  readonly isMergeable: boolean;
108
121
  readonly isApproved: boolean;
122
+ readonly approvalUnknownReason: "NotPermitted" | "ProviderFailed" | "Throttled" | null;
109
123
  readonly commentCount: number | null;
110
124
  readonly healthScore: number | null;
111
125
  readonly link: string;
@@ -132,11 +146,15 @@ declare const makePullRequestRepo: Effect.Effect<{
132
146
  readonly repositoryName: string & import("effect/Brand").Brand<"RepositoryName">;
133
147
  readonly creationDate: Date;
134
148
  readonly lastModifiedDate: Date;
149
+ readonly observationSeq: number;
150
+ readonly approvalVersion: Date;
151
+ readonly approvalObservationSeq: number;
135
152
  readonly status: "CLOSED" | "MERGED" | "OPEN";
136
153
  readonly sourceBranch: string;
137
154
  readonly destinationBranch: string;
138
155
  readonly isMergeable: boolean;
139
156
  readonly isApproved: boolean;
157
+ readonly approvalUnknownReason: "NotPermitted" | "ProviderFailed" | "Throttled" | null;
140
158
  readonly commentCount: number | null;
141
159
  readonly healthScore: number | null;
142
160
  readonly link: string;
@@ -161,6 +179,10 @@ declare const makePullRequestRepo: Effect.Effect<{
161
179
  readonly repositoryName: string;
162
180
  readonly accountProfile: string & import("effect/Brand").Brand<"AwsProfileName">;
163
181
  readonly accountRegion: string & import("effect/Brand").Brand<"AwsRegion">;
182
+ readonly lastModifiedDate: Date;
183
+ readonly observationSeq: number;
184
+ readonly approvalVersion: Date;
185
+ readonly approvalObservationSeq: number;
164
186
  }[], import("../../CacheError.ts").CacheError, never>;
165
187
  findOpenInRange: (weekStart: string, weekEnd: string) => Effect.Effect<{
166
188
  readonly id: string;
@@ -168,6 +190,10 @@ declare const makePullRequestRepo: Effect.Effect<{
168
190
  readonly repositoryName: string;
169
191
  readonly accountProfile: string & import("effect/Brand").Brand<"AwsProfileName">;
170
192
  readonly accountRegion: string & import("effect/Brand").Brand<"AwsRegion">;
193
+ readonly lastModifiedDate: Date;
194
+ readonly observationSeq: number;
195
+ readonly approvalVersion: Date;
196
+ readonly approvalObservationSeq: number;
171
197
  }[], import("../../CacheError.ts").CacheError, never>;
172
198
  }, never, EventsHub | SqlClient.SqlClient>;
173
199
  export interface PullRequestRepoContract extends Success<typeof makePullRequestRepo> {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/CacheService/repos/PullRequestRepo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD,OAAO,EAAE,SAAS,EAAc,MAAM,oBAAoB,CAAA;AAE1D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAEjC,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,WAAW,EAAE,MAAM,eAA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AE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAErH,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0CAgBvB,CAAA;AAEF,MAAM,WAAW,uBAAwB,SAAQ,OAAO,CAAC,OAAO,mBAAmB,CAAC;CAAG;;AAEvF,qBAAa,eAAgB,SAAQ,oBAGf;IACpB,MAAM,CAAC,QAAQ,CAAC,OAAO,8MAEtB;CACF"}
@@ -13,7 +13,7 @@ import { DatabaseLive } from "../../Database.js";
13
13
  import { EventsHub, RepoChange } from "../../EventsHub.js";
14
14
  import { mutations } from "./mutations.js";
15
15
  import * as Q from "./queries.js";
16
- export { CachedPullRequest, UpsertInput } from "./internal.js";
16
+ export { approvalColumnsOf, CachedPullRequest, UpsertInput, versionsOf } from "./internal.js";
17
17
  export { PullRequestAmbiguityError } from "./queries.js";
18
18
  const makePullRequestRepo = Effect.gen(function* () {
19
19
  const sql = yield* SqlClient.SqlClient;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/CacheService/repos/PullRequestRepo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE/C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,CAAC,MAAM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,CAAC,GAAG,CAAC;QACvC,GAAG,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC;KAC3B,CAAA;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAC,CAAA;AAIF,MAAM,OAAO,eAAgB,SAAQ,OAAO,CAAC,OAAO,EAGjD,CAAC,iBAAiB,CAAC;IACpB,MAAM,CAAU,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAC/E,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAC/D,CAAA;CACF"}
@@ -12,10 +12,15 @@
12
12
  * @category CacheService
13
13
  */
14
14
  import { Effect, Schema } from "effect";
15
- import { ApprovalRule } from "../../../Domain.js";
15
+ import { ApprovalRule, type ApprovalUnknownReason } from "../../../Domain.js";
16
16
  import { CacheError } from "../../CacheError.js";
17
+ import type { ApprovalGroup, RowGroup, RowVersions } from "./rowWrites.js";
17
18
  /** DB column `TEXT` (comma-separated) <-> `readonly string[]` */
18
19
  export declare const CommaSeparatedArray: Schema.decodeTo<Schema.$Array<Schema.String>, Schema.NullOr<Schema.String>, never, never>;
20
+ /**
21
+ * The `approval_unknown_reason` column: the reason's tag, or NULL when the last evaluation succeeded.
22
+ */
23
+ export declare const ApprovalUnknownColumn: Schema.NullOr<Schema.Literals<readonly ["NotPermitted", "Throttled", "ProviderFailed"]>>;
19
24
  export declare const CachedPullRequest: Schema.Struct<{
20
25
  readonly id: Schema.brand<Schema.String, "PullRequestId">;
21
26
  readonly awsAccountId: Schema.String;
@@ -28,11 +33,17 @@ export declare const CachedPullRequest: Schema.Struct<{
28
33
  readonly repositoryName: Schema.brand<Schema.String, "RepositoryName">;
29
34
  readonly creationDate: Schema.DateFromString;
30
35
  readonly lastModifiedDate: Schema.DateFromString;
36
+ /** With `lastModifiedDate`, the row group's version: the observation that last wrote it. */
37
+ readonly observationSeq: Schema.Number;
38
+ /** The approval group's version: the provider last activity and observation that last wrote it. */
39
+ readonly approvalVersion: Schema.DateFromString;
40
+ readonly approvalObservationSeq: Schema.Number;
31
41
  readonly status: Schema.Literals<readonly ["OPEN", "CLOSED", "MERGED"]>;
32
42
  readonly sourceBranch: Schema.String;
33
43
  readonly destinationBranch: Schema.String;
34
44
  readonly isMergeable: Schema.decodeTo<Schema.Boolean, Schema.Number, never, never>;
35
45
  readonly isApproved: Schema.decodeTo<Schema.Boolean, Schema.Number, never, never>;
46
+ readonly approvalUnknownReason: Schema.NullOr<Schema.Literals<readonly ["NotPermitted", "Throttled", "ProviderFailed"]>>;
36
47
  readonly commentCount: Schema.NullOr<Schema.Number>;
37
48
  readonly healthScore: Schema.NullOr<Schema.Number>;
38
49
  readonly link: Schema.String;
@@ -70,13 +81,69 @@ export declare const UpsertInput: Schema.Struct<{
70
81
  readonly destinationBranch: Schema.String;
71
82
  readonly isMergeable: Schema.Number;
72
83
  readonly isApproved: Schema.Number;
84
+ readonly approvalUnknownReason: Schema.NullOr<Schema.Literals<readonly ["NotPermitted", "Throttled", "ProviderFailed"]>>;
73
85
  readonly commentCount: Schema.NullOr<Schema.Number>;
74
86
  readonly link: Schema.String;
75
87
  readonly approvedBy: Schema.$Array<Schema.String>;
76
88
  readonly approvedByArns: Schema.$Array<Schema.String>;
77
- readonly approvalRules: Schema.withDecodingDefaultTypeKey<Schema.$Array<typeof ApprovalRule>, never>;
89
+ readonly approvalRules: Schema.withDecodingDefaultTypeKey<Schema.$Array<Schema.Struct<{
90
+ readonly ruleName: Schema.String;
91
+ readonly requiredApprovals: Schema.Number;
92
+ readonly poolMembers: Schema.$Array<Schema.String>;
93
+ readonly poolMemberArns: Schema.withDecodingDefaultTypeKey<Schema.$Array<Schema.String>, never>;
94
+ readonly satisfied: Schema.Boolean;
95
+ readonly fromTemplate: Schema.optional<Schema.String>;
96
+ }>>, never>;
78
97
  }>;
79
98
  export type UpsertInput = typeof UpsertInput.Type;
99
+ /**
100
+ * A provider read's approval, as `recordApprovalEvaluation` and `approvalColumnsOf` take it: the
101
+ * evaluated value and its complete rules, or the reason evaluation failed. A `PullRequestDetail` is one.
102
+ */
103
+ export interface ApprovalRead {
104
+ readonly isApproved: boolean;
105
+ readonly approvalRules: UpsertInput["approvalRules"];
106
+ readonly approvalUnknown?: ApprovalUnknownReason | undefined;
107
+ }
108
+ /** Both groups' versions as a read of the row saw them: what a recomputed write must still find. */
109
+ export declare const versionsOf: (row: {
110
+ readonly lastModifiedDate: Date;
111
+ readonly observationSeq: number;
112
+ readonly approvalVersion: Date;
113
+ readonly approvalObservationSeq: number;
114
+ }) => RowVersions;
115
+ /**
116
+ * A listed pull request's row group, complete. The listing reads open pull requests, so no merger and
117
+ * no closing time are authoritative values, not gaps.
118
+ */
119
+ export declare const rowGroupOfListing: (input: UpsertInput) => RowGroup;
120
+ /** A listed pull request's approval group, complete. */
121
+ export declare const approvalGroupOfListing: (input: UpsertInput) => ApprovalGroup;
122
+ /** A provider re-read's row group, complete: a closed or merged read also carries when and by whom. */
123
+ export declare const rowGroupOfRead: (read: {
124
+ readonly title: string;
125
+ readonly description?: string | undefined;
126
+ readonly author: string;
127
+ readonly status: string;
128
+ readonly creationDate: Date;
129
+ readonly lastActivityDate: Date;
130
+ readonly sourceBranch: string;
131
+ readonly destinationBranch: string;
132
+ readonly isMergeable: boolean;
133
+ readonly approvedBy: ReadonlyArray<string>;
134
+ readonly approvedByArns: ReadonlyArray<string>;
135
+ readonly mergedBy?: string | undefined;
136
+ }) => RowGroup;
137
+ /** A provider read's approval group, complete. */
138
+ export declare const approvalGroupOfRead: (read: ApprovalRead) => ApprovalGroup;
139
+ /**
140
+ * The approval columns an upsert input carries for a provider read. While approval is unknown,
141
+ * `isApproved` is a placeholder: the write keeps an existing row's last known value.
142
+ */
143
+ export declare const approvalColumnsOf: (read: ApprovalRead) => {
144
+ isApproved: number;
145
+ approvalUnknownReason: "NotPermitted" | "ProviderFailed" | "Throttled" | null;
146
+ };
80
147
  /** Wrap an Effect with CacheError mapping and a span. */
81
148
  export declare const cacheError: (op: string) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, CacheError, Exclude<R, import("effect/Tracer").ParentSpan>>;
82
149
  /** Join a string array for the approved_by TEXT column. */
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../src/CacheService/repos/PullRequestRepo/internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAgB,MAAM,QAAQ,CAAA;AACrD,OAAO,EAAE,YAAY,EAAoD,MAAM,oBAAoB,CAAA;AACnG,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,2FAK/B,CAAA;AAwBD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8B5B,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAA;AAE7D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;EAsBtB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA;AAEjD,yDAAyD;AACzD,eAAO,MAAM,UAAU,OAAQ,MAAM,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,iFAI/E,CAAA;AAEH,2DAA2D;AAC3D,eAAO,MAAM,cAAc,QAAS,aAAa,CAAC,MAAM,CAAC,kBAA4C,CAAA"}
1
+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CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,iFAI/E,CAAA;AAEH,2DAA2D;AAC3D,eAAO,MAAM,cAAc,QAAS,aAAa,CAAC,MAAM,CAAC,kBAA4C,CAAA"}
@@ -12,7 +12,7 @@
12
12
  * @category CacheService
13
13
  */
14
14
  import { Effect, Schema, SchemaGetter } from "effect";
15
- import { ApprovalRule, PullRequestId, PullRequestStatus, RepositoryName } from "../../../Domain.js";
15
+ import { ApprovalRule, ApprovalUnknownTag, PullRequestId, PullRequestStatus, RepositoryName } from "../../../Domain.js";
16
16
  import { CacheError } from "../../CacheError.js";
17
17
  /** DB column `TEXT` (comma-separated) <-> `readonly string[]` */
18
18
  export const CommaSeparatedArray = Schema.NullOr(Schema.String).pipe(Schema.decodeTo(Schema.Array(Schema.String), {
@@ -37,6 +37,10 @@ const ApprovalRulesFromJson = Schema.NullOr(Schema.String).pipe(Schema.decodeTo(
37
37
  }),
38
38
  encode: SchemaGetter.transform((arr) => (arr.length > 0 ? JSON.stringify(arr) : null))
39
39
  }));
40
+ /**
41
+ * The `approval_unknown_reason` column: the reason's tag, or NULL when the last evaluation succeeded.
42
+ */
43
+ export const ApprovalUnknownColumn = Schema.NullOr(ApprovalUnknownTag);
40
44
  export const CachedPullRequest = Schema.Struct({
41
45
  id: PullRequestId,
42
46
  awsAccountId: Schema.String,
@@ -49,11 +53,17 @@ export const CachedPullRequest = Schema.Struct({
49
53
  repositoryName: RepositoryName,
50
54
  creationDate: Schema.DateFromString,
51
55
  lastModifiedDate: Schema.DateFromString,
56
+ /** With `lastModifiedDate`, the row group's version: the observation that last wrote it. */
57
+ observationSeq: Schema.Number,
58
+ /** The approval group's version: the provider last activity and observation that last wrote it. */
59
+ approvalVersion: Schema.DateFromString,
60
+ approvalObservationSeq: Schema.Number,
52
61
  status: PullRequestStatus,
53
62
  sourceBranch: Schema.String,
54
63
  destinationBranch: Schema.String,
55
64
  isMergeable: BooleanFromNumber,
56
65
  isApproved: BooleanFromNumber,
66
+ approvalUnknownReason: ApprovalUnknownColumn,
57
67
  commentCount: Schema.NullOr(Schema.Number),
58
68
  healthScore: Schema.NullOr(Schema.Number),
59
69
  link: Schema.String,
@@ -85,11 +95,72 @@ export const UpsertInput = Schema.Struct({
85
95
  destinationBranch: Schema.String,
86
96
  isMergeable: Schema.Number,
87
97
  isApproved: Schema.Number,
98
+ approvalUnknownReason: ApprovalUnknownColumn,
88
99
  commentCount: Schema.NullOr(Schema.Number),
89
100
  link: Schema.String,
90
101
  approvedBy: Schema.Array(Schema.String),
91
102
  approvedByArns: Schema.Array(Schema.String),
92
- approvalRules: Schema.Array(ApprovalRule).pipe(Schema.withDecodingDefaultTypeKey(Effect.succeed([])))
103
+ // The rule's plain shape, not the class: callers pass the provider's rules as plain objects, and the
104
+ // cache stores them as JSON either way.
105
+ approvalRules: Schema.Array(Schema.Struct(ApprovalRule.fields)).pipe(Schema.withDecodingDefaultTypeKey(Effect.succeed([])))
106
+ });
107
+ /** Both groups' versions as a read of the row saw them: what a recomputed write must still find. */
108
+ export const versionsOf = (row) => ({
109
+ row: { lastActivity: row.lastModifiedDate, observation: row.observationSeq },
110
+ approval: { lastActivity: row.approvalVersion, observation: row.approvalObservationSeq }
111
+ });
112
+ /**
113
+ * A listed pull request's row group, complete. The listing reads open pull requests, so no merger and
114
+ * no closing time are authoritative values, not gaps.
115
+ */
116
+ export const rowGroupOfListing = (input) => ({
117
+ title: input.title,
118
+ description: input.description,
119
+ author: input.author,
120
+ status: input.status,
121
+ creationDate: input.creationDate,
122
+ sourceBranch: input.sourceBranch,
123
+ destinationBranch: input.destinationBranch,
124
+ isMergeable: input.isMergeable === 1,
125
+ approvedBy: input.approvedBy,
126
+ approvedByArns: input.approvedByArns,
127
+ mergedBy: null,
128
+ closedAt: null
129
+ });
130
+ /** A listed pull request's approval group, complete. */
131
+ export const approvalGroupOfListing = (input) => ({
132
+ isApproved: input.isApproved === 1,
133
+ approvalRules: input.approvalRules,
134
+ unknownReason: input.approvalUnknownReason
135
+ });
136
+ /** A provider re-read's row group, complete: a closed or merged read also carries when and by whom. */
137
+ export const rowGroupOfRead = (read) => ({
138
+ title: read.title,
139
+ description: read.description ?? null,
140
+ author: read.author,
141
+ status: read.status,
142
+ creationDate: read.creationDate.toISOString(),
143
+ sourceBranch: read.sourceBranch,
144
+ destinationBranch: read.destinationBranch,
145
+ isMergeable: read.isMergeable,
146
+ approvedBy: read.approvedBy,
147
+ approvedByArns: read.approvedByArns,
148
+ mergedBy: read.mergedBy ?? null,
149
+ closedAt: read.status === "OPEN" ? null : read.lastActivityDate.toISOString()
150
+ });
151
+ /** A provider read's approval group, complete. */
152
+ export const approvalGroupOfRead = (read) => ({
153
+ isApproved: read.isApproved,
154
+ approvalRules: read.approvalRules,
155
+ unknownReason: read.approvalUnknown?._tag ?? null
156
+ });
157
+ /**
158
+ * The approval columns an upsert input carries for a provider read. While approval is unknown,
159
+ * `isApproved` is a placeholder: the write keeps an existing row's last known value.
160
+ */
161
+ export const approvalColumnsOf = (read) => ({
162
+ isApproved: read.approvalUnknown === undefined && read.isApproved ? 1 : 0,
163
+ approvalUnknownReason: read.approvalUnknown?._tag ?? null
93
164
  });
94
165
  /** Wrap an Effect with CacheError mapping and a span. */
95
166
  export const cacheError = (op) => (effect) => effect.pipe(Effect.mapError((cause) => new CacheError({ operation: `PullRequestRepo.${op}`, cause })), Effect.withSpan(`PullRequestRepo.${op}`));
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../../src/CacheService/repos/PullRequestRepo/internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnG,OAAO,EAAE,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,MAAM,cAAc,GAAG,CAAC,GAA0B,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA"}
@@ -4,34 +4,57 @@
4
4
  * SQL write operations for the pull_requests table. Each function takes `sql`
5
5
  * and `publish` (change event) and returns the mutation implementations.
6
6
  *
7
- * Provides upsert (INSERT ON CONFLICT UPDATE with column-specific merge
8
- * strategy), stale cleanup, diff stats updates, status transitions,
9
- * comment count updates, health score updates, and commented-by refresh.
10
- *
11
- * **Gotchas**
12
- *
13
- * - approval_rules uses `= excluded` (no COALESCE) — always fresh from API
14
- * - repo_account_id uses COALESCE — preserves across partial updates
7
+ * Every write goes through `rowWrites`: provider reads write whole column groups under their versions
8
+ * (`upsert` for a listing, `writeRead` for a re-read), recomputed values go through `writeDerived`,
9
+ * which applies only to the row as it was read, and a not-found read deletes through `deleteOne`.
15
10
  *
16
11
  * @category CacheService
17
12
  */
13
+ import type { Option } from "effect";
18
14
  import { Effect } from "effect";
19
15
  import type * as SqlClient from "effect/sql/SqlClient";
20
- import { UpsertInput } from "./internal.js";
16
+ import { type ApprovalRead, CachedPullRequest, rowGroupOfRead, UpsertInput } from "./internal.js";
17
+ import { type DerivedColumns, type GroupsWritten, type RowVersions } from "./rowWrites.js";
18
+ /** What an upsert wrote, and the row it replaced (none for a pull request seen for the first time). */
19
+ export interface UpsertResult extends GroupsWritten {
20
+ readonly replaced: Option.Option<CachedPullRequest>;
21
+ }
21
22
  export interface PullRequestCoordinates {
22
23
  readonly repositoryName: string;
23
24
  readonly accountRegion: string;
24
25
  }
25
26
  export declare const mutations: (sql: SqlClient.SqlClient, publish: Effect.Effect<void>) => {
26
- upsert: (input: UpsertInput) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
27
- upsertMany: (prs: ReadonlyArray<UpsertInput>) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
27
+ /** The next observation number: take it before the provider read whose results a write carries. */
28
+ observe: () => Effect.Effect<number, import("../../CacheError.ts").CacheError, never>;
29
+ /**
30
+ * Write a listed pull request observed by `observation`: its row and approval groups, each unless
31
+ * that group is newer. The result says which were written; a group not written means a newer read
32
+ * already reached it.
33
+ */
34
+ upsert: (input: UpsertInput, observation: number) => Effect.Effect<UpsertResult, import("../../CacheError.ts").CacheError, never>;
35
+ /**
36
+ * Write a pull request read in full (a single-PR refresh): like `upsert`, but both groups come
37
+ * from `read`, so a merged or closed read carries its merger and closing time.
38
+ */
39
+ upsertRead: (input: UpsertInput, read: Parameters<typeof rowGroupOfRead>[0] & ApprovalRead, observation: number) => Effect.Effect<UpsertResult, import("../../CacheError.ts").CacheError, never>;
40
+ upsertMany: (prs: ReadonlyArray<UpsertInput>, observation: number) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
41
+ /**
42
+ * Write a provider re-read of a cached pull request, observed by `observation`: its whole row group
43
+ * (including a closed or merged status) and approval group, each unless that group is newer.
44
+ */
45
+ writeRead: (awsAccountId: string, id: string, read: Parameters<typeof rowGroupOfRead>[0] & ApprovalRead, observation: number, coordinates?: PullRequestCoordinates) => Effect.Effect<GroupsWritten, import("../../CacheError.ts").CacheError, never>;
46
+ /**
47
+ * Write values recomputed from a cached row (diff stats, comment count, health score), only while
48
+ * the row still holds `observed`, the versions it was read at. True when written.
49
+ */
50
+ writeDerived: (awsAccountId: string, id: string, observed: RowVersions, columns: DerivedColumns, coordinates?: PullRequestCoordinates) => Effect.Effect<boolean, import("../../CacheError.ts").CacheError, never>;
28
51
  deleteStale: (olderThan: string) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
29
52
  deleteStaleOpen: (olderThan: string) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
30
- deleteOne: (awsAccountId: string, id: string, coordinates?: PullRequestCoordinates) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
31
- updateDiffStats: (awsAccountId: string, id: string, filesAdded: number, filesModified: number, filesDeleted: number, coordinates?: PullRequestCoordinates) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
32
- updateStatusAndClosedAt: (awsAccountId: string, id: string, status: string, closedAt: string, mergedBy?: string, approvedBy?: ReadonlyArray<string>, coordinates?: PullRequestCoordinates) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
33
- updateCommentCount: (awsAccountId: string, id: string, count: number | null, coordinates?: PullRequestCoordinates) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
34
- updateHealthScore: (awsAccountId: string, id: string, score: number, coordinates?: PullRequestCoordinates) => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
53
+ /**
54
+ * Delete a row the provider answered "does not exist" for, in a read begun at `observation`,
55
+ * unless a read that began later has written it since. True when the row was deleted.
56
+ */
57
+ deleteOne: (awsAccountId: string, id: string, observation: number, coordinates?: PullRequestCoordinates) => Effect.Effect<boolean, import("../../CacheError.ts").CacheError, never>;
35
58
  refreshCommentedBy: () => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
36
59
  propagateRepoAccountId: () => Effect.Effect<void, import("../../CacheError.ts").CacheError, never>;
37
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../../src/CacheService/repos/PullRequestRepo/mutations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAA;AACvC,OAAO,KAAK,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAGtD,OAAO,EAA8B,WAAW,EAAE,MAAM,eAAe,CAAA;AAGvE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B;AAED,eAAO,MAAM,SAAS,QAAS,SAAS,CAAC,SAAS,WAAW,MAAM,CAAC,MAAM,CAAC,IAAI,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