GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(issues): keep Linear package internals private and drop trac… · pingdotgg/t3code@3a125b2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/issue
    • IssueTrackerConnections.ts
  • packages/issue-tracker-linear/src/server
    • LinearApi.ts
    • LinearIssueTracker.test.ts
    • LinearIssueTracker.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/issue/IssueTrackerConnections.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/issue/IssueTrackerConnections.ts
+10-23Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import * as Option from "effect/Option";
1616
import * as DateTime from "effect/DateTime";
1717
import {
1818
IssueTrackerConnectionError,
19+
IssueTrackerKind,
1920
type IssueTrackerBindProjectInput,
2021
type IssueTrackerConnectInput,
2122
type IssueTrackerConnection,
2223
type IssueTrackerConnectionList,
23-
type IssueTrackerKind,
2424
} from "@t3tools/contracts";
2525
import type { StandaloneIssueTrackerApi } from "@t3tools/issue-tracker-core/server/IssueTracker";
2626

@@ -70,6 +70,9 @@ export const make = Effect.gen(function* () {
7070
: Effect.succeed(found);
7171
};
7272

73+
/** The kind an error about no tracker in particular is filed under. */
74+
const anyTracker = registry.standalone[0]?.kind ?? IssueTrackerKind.make("none");
75+
7376
const secretFailure = (tracker: IssueTrackerKind, detail: string) => (cause: unknown) =>
7477
new IssueTrackerConnectionError({ tracker, reason: "failed", detail, cause });
7578

@@ -116,16 +119,8 @@ export const make = Effect.gen(function* () {
116119
trackers: Effect.forEach(registry.standalone, current, { concurrency: 4 }),
117120
bindings: bindings.list.pipe(
118121
Effect.map((bound) => Object.fromEntries(bound)),
119-
Effect.mapError(
120-
(cause) =>
121-
// No single tracker is at fault; the first registered one carries the report.
122-
new IssueTrackerConnectionError({
123-
tracker: registry.standalone[0]?.kind ?? ("unknown" as IssueTrackerKind),
124-
reason: "failed",
125-
detail: "The project bindings could not be read.",
126-
cause,
127-
}),
128-
),
122+
// No single tracker is at fault; the first registered one carries the report.
123+
Effect.mapError(secretFailure(anyTracker, "The project bindings could not be read.")),
129124
),
130125
});
131126

@@ -172,21 +167,13 @@ export const make = Effect.gen(function* () {
172167

173168
const bindProject: IssueTrackerConnections["Service"]["bindProject"] = (input) =>
174169
Effect.gen(function* () {
175-
const api = input.binding === null ? null : yield* requireTracker(input.binding.tracker);
170+
// Unbinding names no tracker; the first registered one carries any report.
171+
const tracker =
172+
input.binding === null ? anyTracker : (yield* requireTracker(input.binding.tracker)).kind;
176173
const updatedAt = DateTime.formatIso(yield* DateTime.now);
177174
yield* bindings
178175
.set({ projectId: input.projectId, binding: input.binding, updatedAt })
179-
.pipe(
180-
Effect.mapError(
181-
secretFailure(
182-
api?.kind ??
183-
input.binding?.tracker ??
184-
registry.standalone[0]?.kind ??
185-
("unknown" as IssueTrackerKind),
186-
"The project binding could not be saved.",
187-
),
188-
),
189-
);
176+
.pipe(Effect.mapError(secretFailure(tracker, "The project binding could not be saved.")));
190177
});
191178

192179
return IssueTrackerConnections.of({ list, connect, bindProject });
Collapse file

‎packages/issue-tracker-linear/src/server/LinearApi.ts‎

Copy file name to clipboardExpand all lines: packages/issue-tracker-linear/src/server/LinearApi.ts
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import * as IssueTrackerHost from "@t3tools/issue-tracker-core/server/IssueTrack
2222
import { retryAtFromHeader } from "@t3tools/source-control-core/server/SourceControlRateLimit";
2323

2424
export const KIND = IssueTrackerKind.make("linear");
25-
export const DEFAULT_API_URL = "https://api.linear.app/graphql";
25+
const DEFAULT_API_URL = "https://api.linear.app/graphql";
2626

2727
const LinearApiConfig = Config.all({
2828
apiUrl: Config.String("T3CODE_LINEAR_API_URL").pipe(Config.withDefault(DEFAULT_API_URL)),
@@ -39,12 +39,12 @@ export const LinearUser = Schema.Struct({
3939
});
4040
export type LinearUser = typeof LinearUser.Type;
4141

42-
export const LinearTeam = Schema.Struct({
42+
const LinearTeam = Schema.Struct({
4343
id: Schema.String,
4444
key: Schema.String,
4545
name: Schema.String,
4646
});
47-
export type LinearTeam = typeof LinearTeam.Type;
47+
type LinearTeam = typeof LinearTeam.Type;
4848

4949
/** `type` is one of Linear's categories: triage, backlog, unstarted, started, completed, canceled. */
5050
export const LinearWorkflowState = Schema.Struct({
@@ -55,13 +55,13 @@ export const LinearWorkflowState = Schema.Struct({
5555
});
5656
export type LinearWorkflowState = typeof LinearWorkflowState.Type;
5757

58-
export const LinearLabel = Schema.Struct({
58+
const LinearLabel = Schema.Struct({
5959
id: Schema.String,
6060
name: Schema.String,
6161
color: Schema.NullOr(Schema.String),
6262
description: Schema.optional(Schema.NullOr(Schema.String)),
6363
});
64-
export type LinearLabel = typeof LinearLabel.Type;
64+
type LinearLabel = typeof LinearLabel.Type;
6565

6666
export const LinearReaction = Schema.Struct({
6767
id: Schema.String,
@@ -149,14 +149,14 @@ export const LinearTemplate = Schema.Struct({
149149
});
150150
export type LinearTemplate = typeof LinearTemplate.Type;
151151

152-
export const LinearIssueDetail = Schema.Struct({
152+
const LinearIssueDetail = Schema.Struct({
153153
...LinearIssue.fields,
154154
comments: Connection(LinearComment),
155155
reactions: Schema.Array(LinearReaction),
156156
attachments: Schema.Struct({ nodes: Schema.Array(LinearAttachment) }),
157157
history: Schema.Struct({ nodes: Schema.Array(LinearHistoryEntry) }),
158158
});
159-
export type LinearIssueDetail = typeof LinearIssueDetail.Type;
159+
type LinearIssueDetail = typeof LinearIssueDetail.Type;
160160

161161
// --- Documents -----------------------------------------------------------------------------
162162

@@ -270,14 +270,14 @@ const IssueData = Schema.Struct({ issue: Schema.NullOr(LinearIssueDetail) });
270270
const CommentsData = Schema.Struct({
271271
issue: Schema.NullOr(Schema.Struct({ comments: Connection(LinearComment) })),
272272
});
273-
export const LinearTeamDetail = Schema.Struct({
273+
const LinearTeamDetail = Schema.Struct({
274274
...LinearTeam.fields,
275275
states: Connection(LinearWorkflowState),
276276
labels: Connection(LinearLabel),
277277
members: Connection(LinearUser),
278278
templates: Schema.Struct({ nodes: Schema.Array(LinearTemplate) }),
279279
});
280-
export type LinearTeamDetail = typeof LinearTeamDetail.Type;
280+
type LinearTeamDetail = typeof LinearTeamDetail.Type;
281281
const TeamData = Schema.Struct({
282282
teams: Schema.Struct({ nodes: Schema.Array(LinearTeamDetail) }),
283283
issueLabels: Connection(LinearLabel),
Collapse file

‎packages/issue-tracker-linear/src/server/LinearIssueTracker.test.ts‎

Copy file name to clipboardExpand all lines: packages/issue-tracker-linear/src/server/LinearIssueTracker.test.ts
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as Layer from "effect/Layer";
44
import * as Option from "effect/Option";
55
import { HttpClient, HttpClientResponse } from "effect/http";
66
import { IssueTrackerKind } from "@t3tools/contracts";
7+
import type { StandaloneIssueTrackerApi } from "@t3tools/issue-tracker-core/server/IssueTracker";
78
import * as IssueTrackerHost from "@t3tools/issue-tracker-core/server/IssueTrackerHost";
89

910
import * as LinearApi from "./LinearApi.ts";
@@ -59,7 +60,7 @@ function fakeLinear(
5960
const http = Layer.succeed(
6061
HttpClient.HttpClient,
6162
HttpClient.make((request) =>
62-
Effect.gen(function* () {
63+
Effect.sync(() => {
6364
const body = request.body;
6465
const text =
6566
body._tag === "Uint8Array" ? new TextDecoder().decode(body.body) : String(body._tag);
@@ -90,7 +91,9 @@ function fakeLinear(
9091
credentials: { get: () => Effect.succeed(Option.fromNullishOr(stored)) },
9192
}),
9293
);
94+
// Every optional write is implemented here; the type says so for the calls below.
9395
const tracker = LinearIssueTracker.make.pipe(
96+
Effect.map((api) => api as Required<StandaloneIssueTrackerApi>),
9497
Effect.provide(LinearApi.layer.pipe(Layer.provide(Layer.merge(http, host)))),
9598
);
9699
return { tracker, requests };
Collapse file

‎packages/issue-tracker-linear/src/server/LinearIssueTracker.ts‎

Copy file name to clipboardExpand all lines: packages/issue-tracker-linear/src/server/LinearIssueTracker.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function toComment(comment: LinearApi.LinearComment, viewerId: string | null): I
179179
};
180180
}
181181

182-
export function toEvents(history: ReadonlyArray<LinearApi.LinearHistoryEntry>): IssueEvent[] {
182+
function toEvents(history: ReadonlyArray<LinearApi.LinearHistoryEntry>): IssueEvent[] {
183183
const events: IssueEvent[] = [];
184184
for (const entry of history) {
185185
const actor = entry.actor === null ? null : toActor(entry.actor);
@@ -212,7 +212,7 @@ const PULL_REQUEST_URL =
212212
/^https:\/\/(?:github\.com\/([^/]+\/[^/]+)\/pull|gitlab\.com\/(.+?)\/-\/merge_requests)\/(\d+)\/?(?:[?#]|$)/u;
213213

214214
/** Linear's GitHub and GitLab integrations record change requests as attachments. */
215-
export function toLinkedPullRequests(
215+
function toLinkedPullRequests(
216216
attachments: ReadonlyArray<LinearApi.LinearAttachment>,
217217
): IssueLinkedPullRequest[] {
218218
const seen = new Set<string>();

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.