@useairfoil/producer-linear 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -0
- package/dist/index.d.mts +4027 -0
- package/dist/index.mjs +3 -0
- package/dist/main.d.mts +1 -0
- package/dist/main.mjs +1303 -0
- package/dist/main.mjs.map +1 -0
- package/dist/manifest.d.mts +114 -0
- package/dist/manifest.mjs +161 -0
- package/dist/manifest.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/src-Ci3_ltan.mjs +1691 -0
- package/dist/src-Ci3_ltan.mjs.map +1 -0
- package/package.json +45 -7
- package/src/client/client.ts +200 -0
- package/src/connector.ts +151 -0
- package/src/create-table.ts +5 -0
- package/src/demo/index.ts +137 -0
- package/src/demo/initiatives.ts +116 -0
- package/src/demo/issues.ts +320 -0
- package/src/demo/projects.ts +215 -0
- package/src/demo/setup.ts +151 -0
- package/src/demo/shared.ts +122 -0
- package/src/demo/teams.ts +173 -0
- package/src/index.ts +83 -0
- package/src/main.ts +22 -0
- package/src/manifest.ts +58 -0
- package/src/resources/comments.ts +32 -0
- package/src/resources/customers.ts +105 -0
- package/src/resources/documents.ts +31 -0
- package/src/resources/initiatives.ts +136 -0
- package/src/resources/issue-history.ts +119 -0
- package/src/resources/issues.ts +131 -0
- package/src/resources/pages.ts +264 -0
- package/src/resources/projects.ts +161 -0
- package/src/resources/releases.ts +114 -0
- package/src/resources/teams.ts +140 -0
- package/src/sandbox.ts +35 -0
- package/src/schemas/comments.ts +32 -0
- package/src/schemas/customers.ts +80 -0
- package/src/schemas/documents.ts +32 -0
- package/src/schemas/initiatives.ts +119 -0
- package/src/schemas/issues.ts +180 -0
- package/src/schemas/projects.ts +154 -0
- package/src/schemas/releases.ts +119 -0
- package/src/schemas/shared.ts +66 -0
- package/src/schemas/teams.ts +144 -0
- package/src/start.ts +47 -0
- package/src/tables.ts +83 -0
- package/src/webhook/route.ts +50 -0
- package/src/webhook/signature.ts +28 -0
|
@@ -0,0 +1,1691 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { LinearConfigDef, manifest } from "./manifest.mjs";
|
|
3
|
+
import { Connector, ConnectorError, Cursor, Fetch, Iceberg, Metrics, Resource, Telemetry, Webhook } from "@useairfoil/connector-kit";
|
|
4
|
+
import { Array, Config, Context, Data, DateTime, Duration, Effect, Layer, Option, Redacted, Result, Schedule, Schema, SchemaTransformation, Stream, String as String$1, Struct } from "effect";
|
|
5
|
+
import { HttpClient, HttpClientRequest, HttpClientResponse, HttpServerResponse } from "effect/http";
|
|
6
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
7
|
+
//#region src/client/client.ts
|
|
8
|
+
var client_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
LinearClient: () => LinearClient,
|
|
10
|
+
layer: () => layer$1,
|
|
11
|
+
layerConfig: () => layerConfig$1,
|
|
12
|
+
make: () => make$1
|
|
13
|
+
});
|
|
14
|
+
const endpoint = "https://api.linear.app/graphql";
|
|
15
|
+
const maxRetries = 5;
|
|
16
|
+
const retryBaseDelay = Duration.seconds(1);
|
|
17
|
+
const requestTimeout = Duration.minutes(2);
|
|
18
|
+
const limitRetry = Schedule.min([Schedule.exponential("1 minute"), Schedule.spaced("10 minutes")]);
|
|
19
|
+
var LinearClient = class extends Context.Service()("@useairfoil/producer-linear/LinearClient") {};
|
|
20
|
+
const ResponseSchema = Schema.Struct({
|
|
21
|
+
data: Schema.optional(Schema.Unknown),
|
|
22
|
+
errors: Schema.optional(Schema.Array(Schema.Struct({
|
|
23
|
+
message: Schema.String,
|
|
24
|
+
extensions: Schema.optional(Schema.Struct({ code: Schema.optional(Schema.String) }))
|
|
25
|
+
})))
|
|
26
|
+
});
|
|
27
|
+
var RateLimited = class extends Data.TaggedError("RateLimited") {};
|
|
28
|
+
const isNotFound = (message) => message.startsWith("Entity not found");
|
|
29
|
+
const operationName = (document) => /^\s*query\s+(\w+)/.exec(document)?.[1] ?? "query";
|
|
30
|
+
const make$1 = Effect.fnUntraced(function* (config) {
|
|
31
|
+
const client = (yield* HttpClient.HttpClient).pipe(HttpClient.mapRequest((request) => request.pipe(HttpClientRequest.acceptJson, HttpClientRequest.setHeader("Authorization", Redacted.value(config.apiKey)))), HttpClient.retryTransient({ schedule: Metrics.retrySchedule({
|
|
32
|
+
connector: manifest.name,
|
|
33
|
+
baseDelay: retryBaseDelay,
|
|
34
|
+
times: maxRetries
|
|
35
|
+
}) }));
|
|
36
|
+
const execute = (schema, document, variables = {}) => {
|
|
37
|
+
const operation = operationName(document);
|
|
38
|
+
return Effect.gen(function* () {
|
|
39
|
+
const response = yield* client.execute(HttpClientRequest.post(endpoint).pipe(HttpClientRequest.bodyJsonUnsafe({
|
|
40
|
+
query: document,
|
|
41
|
+
variables
|
|
42
|
+
}))).pipe(Effect.tapError((error) => Telemetry.annotateError("api_http", error)), Effect.mapError((error) => new ConnectorError({
|
|
43
|
+
message: `Linear API request failed for ${operation}`,
|
|
44
|
+
cause: error
|
|
45
|
+
})));
|
|
46
|
+
const body = yield* HttpClientResponse.schemaBodyJson(ResponseSchema)(response).pipe(Effect.tapError((error) => Telemetry.annotateError("api_status", error)), Effect.mapError((error) => new ConnectorError({
|
|
47
|
+
message: `Linear API returned ${response.status} for ${operation}`,
|
|
48
|
+
cause: error
|
|
49
|
+
})));
|
|
50
|
+
const errors = body.errors ?? [];
|
|
51
|
+
if (errors.some((error) => error.extensions?.code === "RATELIMITED")) return yield* new RateLimited({ message: `Linear rate limit reached for ${operation}` });
|
|
52
|
+
if (response.status === 401) return yield* new ConnectorError({ message: "Linear rejected the API key" });
|
|
53
|
+
if (errors.length > 0 && errors.every((error) => isNotFound(error.message))) return Option.none();
|
|
54
|
+
const [first] = errors;
|
|
55
|
+
if (first !== void 0 || response.status < 200 || response.status >= 300) {
|
|
56
|
+
const error = new ConnectorError({
|
|
57
|
+
message: `Linear API returned ${response.status} for ${operation}${first ? `: ${first.message}` : ""}`,
|
|
58
|
+
cause: errors
|
|
59
|
+
});
|
|
60
|
+
yield* Telemetry.annotateError("api_graphql", error);
|
|
61
|
+
return yield* error;
|
|
62
|
+
}
|
|
63
|
+
return Option.some(yield* Schema.decodeUnknownEffect(schema)(body.data).pipe(Effect.tapError((error) => Telemetry.annotateError("api_decode", error)), Effect.mapError((error) => new ConnectorError({
|
|
64
|
+
message: `Linear API response for ${operation} does not match the schema`,
|
|
65
|
+
cause: error
|
|
66
|
+
}))));
|
|
67
|
+
}).pipe(Effect.timeoutOrElse({
|
|
68
|
+
duration: requestTimeout,
|
|
69
|
+
orElse: () => Effect.fail(new ConnectorError({ message: `Linear API request timed out for ${operation}` }))
|
|
70
|
+
}), Effect.retry({
|
|
71
|
+
schedule: limitRetry.pipe(Schedule.tap(({ duration }) => Effect.logWarning("Linear rate limit reached, waiting to try again").pipe(Effect.annotateLogs({
|
|
72
|
+
operation,
|
|
73
|
+
waitMillis: Duration.toMillis(duration)
|
|
74
|
+
})))),
|
|
75
|
+
while: (error) => error._tag === "RateLimited"
|
|
76
|
+
}), Effect.catchTag("RateLimited", (error) => Effect.fail(new ConnectorError({ message: error.message }))), Effect.withSpan(Telemetry.SpanName.apiFetch, {
|
|
77
|
+
kind: "client",
|
|
78
|
+
attributes: { [Telemetry.Attr.apiPath]: `graphql:${operation}` }
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
const query = (schema, document, variables) => execute(schema, document, variables).pipe(Effect.flatMap(Option.match({
|
|
82
|
+
onNone: () => Effect.fail(new ConnectorError({ message: `Linear API found nothing for ${operationName(document)}` })),
|
|
83
|
+
onSome: Effect.succeed
|
|
84
|
+
})));
|
|
85
|
+
return LinearClient.of({
|
|
86
|
+
query,
|
|
87
|
+
find: execute
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
const layer$1 = (config) => Layer.effect(LinearClient)(make$1(config));
|
|
91
|
+
const layerConfig$1 = (config) => Layer.unwrap(Config.unwrap(config).pipe(Effect.map(layer$1)));
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/schemas/shared.ts
|
|
94
|
+
const field = (fieldId, description) => Iceberg.field(fieldId, { description });
|
|
95
|
+
const Timestamp = Schema.DateFromString;
|
|
96
|
+
/** Decodes a GraphQL Int as bigint for an Iceberg long. */
|
|
97
|
+
const Long = Schema.Int.pipe(Schema.decodeTo(Schema.BigInt, SchemaTransformation.transform({
|
|
98
|
+
decode: (value) => BigInt(value),
|
|
99
|
+
encode: (value) => Number(value)
|
|
100
|
+
})));
|
|
101
|
+
/** Decodes a linked object such as `assignee { id }` as its ID. */
|
|
102
|
+
const Ref = Schema.Struct({ id: Schema.String }).pipe(Schema.decodeTo(Schema.String, SchemaTransformation.transform({
|
|
103
|
+
decode: (ref) => ref.id,
|
|
104
|
+
encode: (id) => ({ id })
|
|
105
|
+
})));
|
|
106
|
+
const OptionalRef = Schema.NullOr(Ref);
|
|
107
|
+
const OptionalTimestamp = Schema.NullOr(Timestamp);
|
|
108
|
+
const OptionalString = Schema.NullOr(Schema.String);
|
|
109
|
+
const RefConnection = Schema.Struct({ nodes: Schema.Array(Schema.Struct({ id: Schema.String })) });
|
|
110
|
+
/** Decodes connection nodes as IDs. The query must fetch any extra pages. */
|
|
111
|
+
const RefList = (elementId) => RefConnection.pipe(Schema.decodeTo(Schema.Array(Schema.String.annotate({ fieldId: elementId })), SchemaTransformation.transform({
|
|
112
|
+
decode: (connection) => connection.nodes.map((node) => node.id),
|
|
113
|
+
encode: (ids) => ({ nodes: ids.map((id) => ({ id })) })
|
|
114
|
+
})));
|
|
115
|
+
const list = (elementId, item) => Schema.Array(item.annotate({ fieldId: elementId }));
|
|
116
|
+
/** Rows use updated_at as version; lifecycle webhooks use the webhook time. */
|
|
117
|
+
const common = (object) => ({
|
|
118
|
+
id: Schema.String.pipe(field(1, `${object} ID.`)),
|
|
119
|
+
version: Schema.Date.pipe(field(2, `Time Linear last changed the ${object.toLowerCase()}.`)),
|
|
120
|
+
created_at: Timestamp.pipe(field(3, `Time the ${object.toLowerCase()} was created.`)),
|
|
121
|
+
updated_at: Timestamp.pipe(field(4, `Time the ${object.toLowerCase()} was last updated.`)),
|
|
122
|
+
archived_at: Schema.NullOr(Timestamp).pipe(field(5, `Time the ${object.toLowerCase()} was archived or trashed.`))
|
|
123
|
+
});
|
|
124
|
+
const deleted = (object) => Schema.optional(Schema.Boolean).pipe(field(6, `Whether the ${object} was deleted in Linear.`));
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/schemas/comments.ts
|
|
127
|
+
const CommentSchema = Schema.Struct({
|
|
128
|
+
...common("Comment"),
|
|
129
|
+
_deleted: deleted("comment"),
|
|
130
|
+
body: Schema.String.pipe(field(10, "Comment text in markdown.")),
|
|
131
|
+
user_id: OptionalRef.pipe(field(11, "User who wrote the comment.")),
|
|
132
|
+
external_user_id: OptionalRef.pipe(field(12, "External user who wrote the comment.")),
|
|
133
|
+
issue_id: OptionalString.pipe(field(13, "Issue the comment is on.")),
|
|
134
|
+
project_id: OptionalString.pipe(field(14, "Project the comment is on.")),
|
|
135
|
+
project_update_id: OptionalString.pipe(field(15, "Project update the comment is on.")),
|
|
136
|
+
initiative_id: OptionalString.pipe(field(16, "Initiative the comment is on.")),
|
|
137
|
+
initiative_update_id: OptionalString.pipe(field(17, "Initiative update the comment is on.")),
|
|
138
|
+
document_content_id: OptionalString.pipe(field(18, "Document content the comment is on.")),
|
|
139
|
+
parent_id: OptionalString.pipe(field(19, "Comment this one replies to.")),
|
|
140
|
+
quoted_text: OptionalString.pipe(field(20, "Text the comment quotes.")),
|
|
141
|
+
edited_at: OptionalTimestamp.pipe(field(21, "Time the comment was last edited.")),
|
|
142
|
+
resolved_at: OptionalTimestamp.pipe(field(22, "Time the thread was resolved.")),
|
|
143
|
+
resolving_user_id: OptionalRef.pipe(field(23, "User who resolved the thread.")),
|
|
144
|
+
url: Schema.String.pipe(field(24, "Comment URL."))
|
|
145
|
+
}).annotate({ description: "Linear comments on issues, projects, initiatives, and updates." }).pipe(Iceberg.identifier("id"));
|
|
146
|
+
const CommentObjectSchema = CommentSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/resources/pages.ts
|
|
149
|
+
const changesInterval = Duration.minutes(5);
|
|
150
|
+
const hourly = Duration.hours(1);
|
|
151
|
+
const maxPagesPerRun = 20;
|
|
152
|
+
const changesOverlap = Duration.minutes(1);
|
|
153
|
+
/** Keeps item types inferred in the callbacks. */
|
|
154
|
+
const listSpec = (spec) => spec;
|
|
155
|
+
const rowsOf = (toRow) => (items) => Effect.succeed(items.map(toRow));
|
|
156
|
+
const PageInfoSchema = Schema.Struct({
|
|
157
|
+
hasNextPage: Schema.Boolean,
|
|
158
|
+
endCursor: Schema.NullOr(Schema.String)
|
|
159
|
+
});
|
|
160
|
+
const readPage = (client, spec, options) => client.query(Schema.Struct({ page: Schema.Struct({
|
|
161
|
+
nodes: Schema.Array(spec.item),
|
|
162
|
+
pageInfo: PageInfoSchema
|
|
163
|
+
}) }).pipe(Schema.encodeKeys({ page: spec.connection })), `query ${String$1.capitalize(spec.connection)}($first: Int!, $after: String, $orderBy: PaginationOrderBy) {
|
|
164
|
+
${spec.connection}(first: $first, after: $after, orderBy: $orderBy, includeArchived: true) {
|
|
165
|
+
nodes { ${spec.fields} }
|
|
166
|
+
pageInfo { hasNextPage endCursor }
|
|
167
|
+
}
|
|
168
|
+
}`, {
|
|
169
|
+
first: options.first ?? spec.first ?? 250,
|
|
170
|
+
after: Option.getOrNull(options.after),
|
|
171
|
+
orderBy: options.orderBy
|
|
172
|
+
}).pipe(Effect.map(({ page }) => ({
|
|
173
|
+
items: page.nodes,
|
|
174
|
+
next: page.pageInfo.hasNextPage ? Option.fromNullishOr(page.pageInfo.endCursor) : Option.none()
|
|
175
|
+
})));
|
|
176
|
+
const listAll = (client, spec) => Stream.paginate(Option.none(), (after) => readPage(client, spec, {
|
|
177
|
+
orderBy: "createdAt",
|
|
178
|
+
after
|
|
179
|
+
}).pipe(Effect.map(({ items, next }) => [items, Option.map(next, Option.some)]))).pipe(Stream.runCollect);
|
|
180
|
+
const checkList = (client, spec) => readPage(client, spec, {
|
|
181
|
+
orderBy: "createdAt",
|
|
182
|
+
after: Option.none(),
|
|
183
|
+
first: 1
|
|
184
|
+
}).pipe(Effect.flatMap(({ items }) => spec.rows(items)), Effect.asVoid);
|
|
185
|
+
/** Small lists are read in full every hour. */
|
|
186
|
+
const listSources = (client, spec) => {
|
|
187
|
+
const read = listAll(client, spec).pipe(Effect.flatMap(spec.rows));
|
|
188
|
+
return {
|
|
189
|
+
check: checkList(client, spec),
|
|
190
|
+
backfill: Fetch.page({
|
|
191
|
+
pageCursor: Cursor.string(),
|
|
192
|
+
cutoff: Cursor.isoDateTime(),
|
|
193
|
+
fetch: () => read.pipe(Effect.map((rows) => ({
|
|
194
|
+
rows,
|
|
195
|
+
hasMore: false
|
|
196
|
+
})))
|
|
197
|
+
}),
|
|
198
|
+
changes: Fetch.changes({
|
|
199
|
+
cursor: Cursor.string(),
|
|
200
|
+
interval: hourly,
|
|
201
|
+
fetch: () => Effect.all([read, DateTime.now]).pipe(Effect.map(([rows, now]) => ({
|
|
202
|
+
rows,
|
|
203
|
+
cursor: DateTime.formatIso(now)
|
|
204
|
+
})))
|
|
205
|
+
})
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
/** Changes pick up items created during backfill. */
|
|
209
|
+
const backfillList = (client, spec) => Fetch.page({
|
|
210
|
+
pageCursor: Cursor.string(),
|
|
211
|
+
cutoff: Cursor.isoDateTime(),
|
|
212
|
+
fetch: ({ pageCursor }) => Effect.gen(function* () {
|
|
213
|
+
const page = yield* readPage(client, spec, {
|
|
214
|
+
orderBy: "createdAt",
|
|
215
|
+
after: Option.fromNullishOr(typeof pageCursor === "string" ? pageCursor : void 0)
|
|
216
|
+
});
|
|
217
|
+
return {
|
|
218
|
+
rows: yield* spec.rows(page.items),
|
|
219
|
+
hasMore: Option.isSome(page.next),
|
|
220
|
+
...Option.match(page.next, {
|
|
221
|
+
onNone: () => ({}),
|
|
222
|
+
onSome: (nextPageCursor) => ({ nextPageCursor })
|
|
223
|
+
})
|
|
224
|
+
};
|
|
225
|
+
})
|
|
226
|
+
});
|
|
227
|
+
/**
|
|
228
|
+
* `since` is when the last run started. `pending` is set while a run is split:
|
|
229
|
+
* `until` is the start of that run, and `after` the page to go on from.
|
|
230
|
+
*/
|
|
231
|
+
const ChangesCursorSchema = Schema.Struct({
|
|
232
|
+
since: Schema.DateTimeUtcFromString,
|
|
233
|
+
pending: Schema.optional(Schema.Struct({
|
|
234
|
+
until: Schema.DateTimeUtcFromString,
|
|
235
|
+
after: Schema.String
|
|
236
|
+
}))
|
|
237
|
+
});
|
|
238
|
+
const ChangesCursorCodec = Schema.Union([Schema.fromJsonString(ChangesCursorSchema), Schema.DateTimeUtcFromString.pipe(Schema.decodeTo(Schema.toType(ChangesCursorSchema), SchemaTransformation.transform({
|
|
239
|
+
decode: (since) => ({ since }),
|
|
240
|
+
encode: (cursor) => cursor.since
|
|
241
|
+
})))]);
|
|
242
|
+
const cursorError = (cause) => new ConnectorError({
|
|
243
|
+
message: "Invalid Linear changes cursor",
|
|
244
|
+
cause
|
|
245
|
+
});
|
|
246
|
+
/**
|
|
247
|
+
* Newest first: an edit during paging is read again on the next run.
|
|
248
|
+
*/
|
|
249
|
+
const changesList = (client, spec) => Fetch.changes({
|
|
250
|
+
cursor: Cursor.string(),
|
|
251
|
+
interval: changesInterval,
|
|
252
|
+
fetch: ({ cursor }) => Effect.gen(function* () {
|
|
253
|
+
const state = yield* Schema.decodeUnknownEffect(ChangesCursorCodec)(String(cursor)).pipe(Effect.mapError(cursorError));
|
|
254
|
+
const until = state.pending?.until ?? (yield* DateTime.now);
|
|
255
|
+
const from = DateTime.toDateUtc(DateTime.subtractDuration(state.since, changesOverlap));
|
|
256
|
+
const isRecent = (item) => spec.updatedAt(item).getTime() >= from.getTime();
|
|
257
|
+
const pages = yield* Stream.paginate(Option.fromNullishOr(state.pending?.after), (after) => Effect.gen(function* () {
|
|
258
|
+
const page = yield* readPage(client, spec, {
|
|
259
|
+
orderBy: "updatedAt",
|
|
260
|
+
after
|
|
261
|
+
});
|
|
262
|
+
const recent = page.items.filter(isRecent);
|
|
263
|
+
const next = recent.length === page.items.length ? page.next : Option.none();
|
|
264
|
+
return [[{
|
|
265
|
+
rows: yield* spec.rows(recent),
|
|
266
|
+
next
|
|
267
|
+
}], Option.map(next, Option.some)];
|
|
268
|
+
})).pipe(Stream.take(maxPagesPerRun), Stream.runCollect);
|
|
269
|
+
const rows = pages.flatMap((page) => page.rows);
|
|
270
|
+
const after = Option.flatMap(Array.last(pages), (page) => page.next);
|
|
271
|
+
const next = pages.length === maxPagesPerRun && Option.isSome(after) ? {
|
|
272
|
+
since: state.since,
|
|
273
|
+
pending: {
|
|
274
|
+
until,
|
|
275
|
+
after: after.value
|
|
276
|
+
}
|
|
277
|
+
} : { since: until };
|
|
278
|
+
return {
|
|
279
|
+
rows,
|
|
280
|
+
cursor: yield* Schema.encodeEffect(Schema.fromJsonString(ChangesCursorSchema))(next).pipe(Effect.mapError(cursorError)),
|
|
281
|
+
hasMore: next.pending !== void 0
|
|
282
|
+
};
|
|
283
|
+
})
|
|
284
|
+
});
|
|
285
|
+
const WebhookPayloadSchema = Schema.Struct({
|
|
286
|
+
data: Schema.Struct({ id: Schema.String }),
|
|
287
|
+
webhookTimestamp: Schema.Number
|
|
288
|
+
});
|
|
289
|
+
/**
|
|
290
|
+
* Archive and trash also send `remove`, without changing `updatedAt`.
|
|
291
|
+
* Read the item again; delete only if it's gone. Use the webhook time as the version.
|
|
292
|
+
*/
|
|
293
|
+
const webhookList = (client, spec) => ({
|
|
294
|
+
schema: WebhookPayloadSchema,
|
|
295
|
+
handler: ({ payload }) => Effect.gen(function* () {
|
|
296
|
+
const version = new Date(payload.webhookTimestamp);
|
|
297
|
+
const single = spec.single ?? spec.connection;
|
|
298
|
+
const found = yield* client.find(Schema.Struct({ item: spec.item }).pipe(Schema.encodeKeys({ item: single })), `query ${String$1.capitalize(single)}($id: String!) {
|
|
299
|
+
${single}(id: $id) { ${spec.fields} }
|
|
300
|
+
}`, { id: payload.data.id });
|
|
301
|
+
return yield* Option.match(found, {
|
|
302
|
+
onNone: () => Effect.succeed([{
|
|
303
|
+
id: payload.data.id,
|
|
304
|
+
version,
|
|
305
|
+
_deleted: true
|
|
306
|
+
}]),
|
|
307
|
+
onSome: ({ item }) => spec.rows([item]).pipe(Effect.map((rows) => rows.map((row) => ({
|
|
308
|
+
...row,
|
|
309
|
+
version
|
|
310
|
+
}))))
|
|
311
|
+
});
|
|
312
|
+
})
|
|
313
|
+
});
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/resources/comments.ts
|
|
316
|
+
const commentSpec = listSpec({
|
|
317
|
+
connection: "comments",
|
|
318
|
+
single: "comment",
|
|
319
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
320
|
+
body user_id: user { id } external_user_id: externalUser { id }
|
|
321
|
+
issue_id: issueId project_id: projectId project_update_id: projectUpdateId
|
|
322
|
+
initiative_id: initiativeId initiative_update_id: initiativeUpdateId
|
|
323
|
+
document_content_id: documentContentId parent_id: parentId quoted_text: quotedText
|
|
324
|
+
edited_at: editedAt resolved_at: resolvedAt resolving_user_id: resolvingUser { id } url`,
|
|
325
|
+
item: CommentObjectSchema,
|
|
326
|
+
updatedAt: (comment) => comment.updated_at,
|
|
327
|
+
rows: rowsOf((comment) => ({
|
|
328
|
+
...comment,
|
|
329
|
+
version: comment.updated_at,
|
|
330
|
+
_deleted: false
|
|
331
|
+
}))
|
|
332
|
+
});
|
|
333
|
+
const makeComments = (client) => Resource.entity({
|
|
334
|
+
name: "comments",
|
|
335
|
+
rowSchema: CommentSchema,
|
|
336
|
+
version: "version",
|
|
337
|
+
check: checkList(client, commentSpec),
|
|
338
|
+
backfill: backfillList(client, commentSpec),
|
|
339
|
+
changes: changesList(client, commentSpec),
|
|
340
|
+
webhook: webhookList(client, commentSpec)
|
|
341
|
+
});
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/schemas/customers.ts
|
|
344
|
+
const CustomerSchema = Schema.Struct({
|
|
345
|
+
...common("Customer"),
|
|
346
|
+
_deleted: deleted("customer"),
|
|
347
|
+
name: Schema.String.pipe(field(10, "Customer name.")),
|
|
348
|
+
domains: list(101, Schema.String).pipe(field(11, "Email domains of the customer.")),
|
|
349
|
+
external_ids: list(102, Schema.String).pipe(field(12, "IDs in other systems.")),
|
|
350
|
+
logo_url: OptionalString.pipe(field(13, "Logo URL.")),
|
|
351
|
+
owner_id: OptionalRef.pipe(field(14, "User who owns the customer.")),
|
|
352
|
+
status_id: Ref.pipe(field(15, "Customer status.")),
|
|
353
|
+
tier_id: OptionalRef.pipe(field(16, "Customer tier.")),
|
|
354
|
+
revenue: Schema.NullOr(Long).pipe(field(17, "Annual revenue.")),
|
|
355
|
+
size: Schema.NullOr(Schema.Finite).pipe(field(18, "Company size.")),
|
|
356
|
+
approximate_need_count: Schema.Finite.pipe(field(19, "About how many requests it has.")),
|
|
357
|
+
url: Schema.String.pipe(field(20, "Customer URL."))
|
|
358
|
+
}).annotate({ description: "Linear customers." }).pipe(Iceberg.identifier("id"));
|
|
359
|
+
const CustomerObjectSchema = CustomerSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
360
|
+
const CustomerNeedSchema = Schema.Struct({
|
|
361
|
+
...common("Request"),
|
|
362
|
+
_deleted: deleted("request"),
|
|
363
|
+
customer_id: OptionalRef.pipe(field(10, "Customer.")),
|
|
364
|
+
issue_id: OptionalRef.pipe(field(11, "Issue the request is linked to.")),
|
|
365
|
+
project_id: OptionalRef.pipe(field(12, "Project the request is linked to.")),
|
|
366
|
+
original_issue_id: OptionalRef.pipe(field(13, "Issue the request was first linked to.")),
|
|
367
|
+
comment_id: OptionalRef.pipe(field(14, "Comment the request came from.")),
|
|
368
|
+
attachment_id: OptionalRef.pipe(field(15, "Attachment the request came from.")),
|
|
369
|
+
creator_id: OptionalRef.pipe(field(16, "User who added the request.")),
|
|
370
|
+
body: OptionalString.pipe(field(17, "Request text in markdown.")),
|
|
371
|
+
priority: Schema.Finite.pipe(field(18, "0 normal, 1 important.")),
|
|
372
|
+
url: OptionalString.pipe(field(19, "Source URL."))
|
|
373
|
+
}).annotate({ description: "Linear customer requests, linked to issues or projects." }).pipe(Iceberg.identifier("id"));
|
|
374
|
+
const CustomerNeedObjectSchema = CustomerNeedSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
375
|
+
const levelFields$1 = (object) => ({
|
|
376
|
+
...common(object),
|
|
377
|
+
name: Schema.String.pipe(field(10, "Name.")),
|
|
378
|
+
display_name: Schema.String.pipe(field(11, "Name shown in Linear.")),
|
|
379
|
+
description: OptionalString.pipe(field(12, "Description.")),
|
|
380
|
+
color: Schema.String.pipe(field(13, "Color, as hex.")),
|
|
381
|
+
position: Schema.Finite.pipe(field(14, "Order in the list."))
|
|
382
|
+
});
|
|
383
|
+
const CustomerStatusSchema = Schema.Struct(levelFields$1("Status")).annotate({ description: "Linear customer statuses. Names the IDs in `customers.status_id`." }).pipe(Iceberg.identifier("id"));
|
|
384
|
+
const CustomerStatusObjectSchema = CustomerStatusSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
385
|
+
const CustomerTierSchema = Schema.Struct(levelFields$1("Tier")).annotate({ description: "Linear customer tiers. Names the IDs in `customers.tier_id`." }).pipe(Iceberg.identifier("id"));
|
|
386
|
+
const CustomerTierObjectSchema = CustomerTierSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region src/resources/customers.ts
|
|
389
|
+
const customerSpec = listSpec({
|
|
390
|
+
connection: "customers",
|
|
391
|
+
single: "customer",
|
|
392
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
393
|
+
name domains external_ids: externalIds logo_url: logoUrl owner_id: owner { id }
|
|
394
|
+
status_id: status { id } tier_id: tier { id } revenue size
|
|
395
|
+
approximate_need_count: approximateNeedCount url`,
|
|
396
|
+
item: CustomerObjectSchema,
|
|
397
|
+
updatedAt: (customer) => customer.updated_at,
|
|
398
|
+
rows: rowsOf((customer) => ({
|
|
399
|
+
...customer,
|
|
400
|
+
version: customer.updated_at,
|
|
401
|
+
_deleted: false
|
|
402
|
+
}))
|
|
403
|
+
});
|
|
404
|
+
const makeCustomers = (client) => Resource.entity({
|
|
405
|
+
name: "customers",
|
|
406
|
+
rowSchema: CustomerSchema,
|
|
407
|
+
version: "version",
|
|
408
|
+
check: checkList(client, customerSpec),
|
|
409
|
+
backfill: backfillList(client, customerSpec),
|
|
410
|
+
changes: changesList(client, customerSpec),
|
|
411
|
+
webhook: webhookList(client, customerSpec)
|
|
412
|
+
});
|
|
413
|
+
const customerNeedSpec = listSpec({
|
|
414
|
+
connection: "customerNeeds",
|
|
415
|
+
single: "customerNeed",
|
|
416
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
417
|
+
customer_id: customer { id } issue_id: issue { id } project_id: project { id }
|
|
418
|
+
original_issue_id: originalIssue { id } comment_id: comment { id }
|
|
419
|
+
attachment_id: attachment { id } creator_id: creator { id } body priority url`,
|
|
420
|
+
item: CustomerNeedObjectSchema,
|
|
421
|
+
updatedAt: (need) => need.updated_at,
|
|
422
|
+
rows: rowsOf((need) => ({
|
|
423
|
+
...need,
|
|
424
|
+
version: need.updated_at,
|
|
425
|
+
_deleted: false
|
|
426
|
+
}))
|
|
427
|
+
});
|
|
428
|
+
const makeCustomerNeeds = (client) => Resource.entity({
|
|
429
|
+
name: "customer_needs",
|
|
430
|
+
rowSchema: CustomerNeedSchema,
|
|
431
|
+
version: "version",
|
|
432
|
+
check: checkList(client, customerNeedSpec),
|
|
433
|
+
backfill: backfillList(client, customerNeedSpec),
|
|
434
|
+
changes: changesList(client, customerNeedSpec),
|
|
435
|
+
webhook: webhookList(client, customerNeedSpec)
|
|
436
|
+
});
|
|
437
|
+
const levelFields = `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt name display_name: displayName description color position`;
|
|
438
|
+
const customerStatusSpec = listSpec({
|
|
439
|
+
connection: "customerStatuses",
|
|
440
|
+
fields: levelFields,
|
|
441
|
+
item: CustomerStatusObjectSchema,
|
|
442
|
+
updatedAt: (status) => status.updated_at,
|
|
443
|
+
rows: rowsOf((status) => ({
|
|
444
|
+
...status,
|
|
445
|
+
version: status.updated_at
|
|
446
|
+
}))
|
|
447
|
+
});
|
|
448
|
+
const makeCustomerStatuses = (client) => Resource.entity({
|
|
449
|
+
name: "customer_statuses",
|
|
450
|
+
rowSchema: CustomerStatusSchema,
|
|
451
|
+
version: "version",
|
|
452
|
+
...listSources(client, customerStatusSpec)
|
|
453
|
+
});
|
|
454
|
+
const customerTierSpec = listSpec({
|
|
455
|
+
connection: "customerTiers",
|
|
456
|
+
fields: levelFields,
|
|
457
|
+
item: CustomerTierObjectSchema,
|
|
458
|
+
updatedAt: (tier) => tier.updated_at,
|
|
459
|
+
rows: rowsOf((tier) => ({
|
|
460
|
+
...tier,
|
|
461
|
+
version: tier.updated_at
|
|
462
|
+
}))
|
|
463
|
+
});
|
|
464
|
+
const makeCustomerTiers = (client) => Resource.entity({
|
|
465
|
+
name: "customer_tiers",
|
|
466
|
+
rowSchema: CustomerTierSchema,
|
|
467
|
+
version: "version",
|
|
468
|
+
...listSources(client, customerTierSpec)
|
|
469
|
+
});
|
|
470
|
+
//#endregion
|
|
471
|
+
//#region src/schemas/documents.ts
|
|
472
|
+
const DocumentSchema = Schema.Struct({
|
|
473
|
+
...common("Document"),
|
|
474
|
+
_deleted: deleted("document"),
|
|
475
|
+
title: Schema.String.pipe(field(10, "Title.")),
|
|
476
|
+
content: OptionalString.pipe(field(11, "Content in markdown.")),
|
|
477
|
+
url: Schema.String.pipe(field(12, "Document URL.")),
|
|
478
|
+
icon: OptionalString.pipe(field(13, "Icon.")),
|
|
479
|
+
color: OptionalString.pipe(field(14, "Icon color.")),
|
|
480
|
+
creator_id: OptionalRef.pipe(field(15, "User who made the document.")),
|
|
481
|
+
updated_by_id: OptionalRef.pipe(field(16, "User who last changed the document.")),
|
|
482
|
+
project_id: OptionalRef.pipe(field(17, "Project the document is in.")),
|
|
483
|
+
initiative_id: OptionalRef.pipe(field(18, "Initiative the document is in.")),
|
|
484
|
+
issue_id: OptionalRef.pipe(field(19, "Issue the document is in.")),
|
|
485
|
+
cycle_id: OptionalRef.pipe(field(20, "Cycle the document is in.")),
|
|
486
|
+
team_id: OptionalRef.pipe(field(21, "Team the document is in.")),
|
|
487
|
+
parent_document_id: OptionalRef.pipe(field(22, "Parent document.")),
|
|
488
|
+
hidden_at: OptionalTimestamp.pipe(field(23, "Time the document was hidden.")),
|
|
489
|
+
trashed: Schema.NullOr(Schema.Boolean).pipe(field(24, "Whether the document is in the trash."))
|
|
490
|
+
}).annotate({ description: "Linear documents, including archived and trashed ones." }).pipe(Iceberg.identifier("id"));
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region src/resources/documents.ts
|
|
493
|
+
const documentSpec = listSpec({
|
|
494
|
+
connection: "documents",
|
|
495
|
+
single: "document",
|
|
496
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
497
|
+
title content url icon color creator_id: creator { id } updated_by_id: updatedBy { id }
|
|
498
|
+
project_id: project { id } initiative_id: initiative { id } issue_id: issue { id }
|
|
499
|
+
cycle_id: cycle { id } team_id: team { id } parent_document_id: parentDocument { id }
|
|
500
|
+
hidden_at: hiddenAt trashed`,
|
|
501
|
+
item: DocumentSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"])),
|
|
502
|
+
updatedAt: (document) => document.updated_at,
|
|
503
|
+
rows: rowsOf((document) => ({
|
|
504
|
+
...document,
|
|
505
|
+
version: document.updated_at,
|
|
506
|
+
_deleted: false
|
|
507
|
+
}))
|
|
508
|
+
});
|
|
509
|
+
const makeDocuments = (client) => Resource.entity({
|
|
510
|
+
name: "documents",
|
|
511
|
+
rowSchema: DocumentSchema,
|
|
512
|
+
version: "version",
|
|
513
|
+
check: checkList(client, documentSpec),
|
|
514
|
+
backfill: backfillList(client, documentSpec),
|
|
515
|
+
changes: changesList(client, documentSpec),
|
|
516
|
+
webhook: webhookList(client, documentSpec)
|
|
517
|
+
});
|
|
518
|
+
//#endregion
|
|
519
|
+
//#region src/schemas/initiatives.ts
|
|
520
|
+
const InitiativeSchema = Schema.Struct({
|
|
521
|
+
...common("Initiative"),
|
|
522
|
+
_deleted: deleted("initiative"),
|
|
523
|
+
name: Schema.String.pipe(field(10, "Initiative name.")),
|
|
524
|
+
description: OptionalString.pipe(field(11, "Short summary.")),
|
|
525
|
+
content: OptionalString.pipe(field(12, "Initiative overview in markdown.")),
|
|
526
|
+
url: Schema.String.pipe(field(13, "Initiative URL.")),
|
|
527
|
+
icon: OptionalString.pipe(field(14, "Icon.")),
|
|
528
|
+
color: OptionalString.pipe(field(15, "Color, as hex.")),
|
|
529
|
+
status: Schema.String.pipe(field(16, "Status: Planned, Active, or Completed.")),
|
|
530
|
+
health: OptionalString.pipe(field(17, "Health from the latest update.")),
|
|
531
|
+
health_updated_at: OptionalTimestamp.pipe(field(18, "Time the health last changed.")),
|
|
532
|
+
priority: Long.pipe(field(19, "0 none, 1 urgent, 2 high, 3 medium, 4 low.")),
|
|
533
|
+
owner_id: OptionalRef.pipe(field(20, "Initiative owner.")),
|
|
534
|
+
creator_id: OptionalRef.pipe(field(21, "User who made the initiative.")),
|
|
535
|
+
parent_initiative_id: OptionalRef.pipe(field(22, "Parent initiative.")),
|
|
536
|
+
target_date: OptionalString.pipe(field(23, "Target date, as YYYY-MM-DD.")),
|
|
537
|
+
started_at: OptionalTimestamp.pipe(field(24, "Time the initiative started.")),
|
|
538
|
+
completed_at: OptionalTimestamp.pipe(field(25, "Time the initiative was completed.")),
|
|
539
|
+
canceled_at: OptionalTimestamp.pipe(field(26, "Time the initiative was canceled.")),
|
|
540
|
+
label_ids: list(101, Schema.String).pipe(field(27, "Initiative labels.")),
|
|
541
|
+
visibility: Schema.String.pipe(field(28, "Who can see the initiative.")),
|
|
542
|
+
trashed: Schema.NullOr(Schema.Boolean).pipe(field(29, "Whether the initiative is in the trash."))
|
|
543
|
+
}).annotate({ description: "Linear initiatives, including archived and trashed ones." }).pipe(Iceberg.identifier("id"));
|
|
544
|
+
const InitiativeObjectSchema = InitiativeSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
545
|
+
const InitiativeUpdateSchema = Schema.Struct({
|
|
546
|
+
...common("Update"),
|
|
547
|
+
_deleted: deleted("update"),
|
|
548
|
+
initiative_id: Ref.pipe(field(10, "Initiative.")),
|
|
549
|
+
user_id: Ref.pipe(field(11, "User who posted the update.")),
|
|
550
|
+
body: Schema.String.pipe(field(12, "Update text in markdown.")),
|
|
551
|
+
health: Schema.String.pipe(field(13, "Health: onTrack, atRisk, or offTrack.")),
|
|
552
|
+
url: Schema.String.pipe(field(14, "Update URL.")),
|
|
553
|
+
edited_at: OptionalTimestamp.pipe(field(15, "Time the update was last edited.")),
|
|
554
|
+
comment_count: Long.pipe(field(16, "Comments on the update."))
|
|
555
|
+
}).annotate({ description: "Linear initiative updates: status posts with a health." }).pipe(Iceberg.identifier("id"));
|
|
556
|
+
const InitiativeUpdateObjectSchema = InitiativeUpdateSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
557
|
+
const InitiativeLabelSchema = Schema.Struct({
|
|
558
|
+
...common("Label"),
|
|
559
|
+
name: Schema.String.pipe(field(10, "Label name.")),
|
|
560
|
+
description: OptionalString.pipe(field(11, "Label description.")),
|
|
561
|
+
color: Schema.String.pipe(field(12, "Label color, as hex.")),
|
|
562
|
+
is_group: Schema.Boolean.pipe(field(13, "Whether the label groups other labels.")),
|
|
563
|
+
parent_id: OptionalRef.pipe(field(14, "Label group.")),
|
|
564
|
+
creator_id: OptionalRef.pipe(field(15, "User who made the label.")),
|
|
565
|
+
retired_at: OptionalTimestamp.pipe(field(16, "Time the label was retired."))
|
|
566
|
+
}).annotate({ description: "Linear initiative labels. Names the IDs in `initiatives.label_ids`." }).pipe(Iceberg.identifier("id"));
|
|
567
|
+
const InitiativeLabelObjectSchema = InitiativeLabelSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
568
|
+
const InitiativeRelationSchema = Schema.Struct({
|
|
569
|
+
...common("Relation"),
|
|
570
|
+
initiative_id: Ref.pipe(field(10, "Initiative the relation starts from.")),
|
|
571
|
+
related_initiative_id: Ref.pipe(field(11, "Related initiative.")),
|
|
572
|
+
sort_order: Schema.Finite.pipe(field(12, "Order.")),
|
|
573
|
+
user_id: OptionalRef.pipe(field(13, "User who made the relation."))
|
|
574
|
+
}).annotate({ description: "Linear initiative relations. Deleted relations aren't seen." }).pipe(Iceberg.identifier("id"));
|
|
575
|
+
const InitiativeRelationObjectSchema = InitiativeRelationSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
576
|
+
const InitiativeToProjectSchema = Schema.Struct({
|
|
577
|
+
...common("Link"),
|
|
578
|
+
initiative_id: Ref.pipe(field(10, "Initiative.")),
|
|
579
|
+
project_id: Ref.pipe(field(11, "Project.")),
|
|
580
|
+
sort_order: Schema.String.pipe(field(12, "Order within the initiative."))
|
|
581
|
+
}).annotate({ description: "Links between Linear initiatives and projects. Removed links aren't seen." }).pipe(Iceberg.identifier("id"));
|
|
582
|
+
const InitiativeToProjectObjectSchema = InitiativeToProjectSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/resources/initiatives.ts
|
|
585
|
+
const initiativeSpec = listSpec({
|
|
586
|
+
connection: "initiatives",
|
|
587
|
+
single: "initiative",
|
|
588
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
589
|
+
name description content url icon color status health
|
|
590
|
+
health_updated_at: healthUpdatedAt priority owner_id: owner { id } creator_id: creator { id }
|
|
591
|
+
parent_initiative_id: parentInitiative { id } target_date: targetDate
|
|
592
|
+
started_at: startedAt completed_at: completedAt canceled_at: canceledAt
|
|
593
|
+
label_ids: labelIds visibility trashed`,
|
|
594
|
+
item: InitiativeObjectSchema,
|
|
595
|
+
updatedAt: (initiative) => initiative.updated_at,
|
|
596
|
+
rows: rowsOf((initiative) => ({
|
|
597
|
+
...initiative,
|
|
598
|
+
version: initiative.updated_at,
|
|
599
|
+
_deleted: false
|
|
600
|
+
}))
|
|
601
|
+
});
|
|
602
|
+
const makeInitiatives = (client) => Resource.entity({
|
|
603
|
+
name: "initiatives",
|
|
604
|
+
rowSchema: InitiativeSchema,
|
|
605
|
+
version: "version",
|
|
606
|
+
check: checkList(client, initiativeSpec),
|
|
607
|
+
backfill: backfillList(client, initiativeSpec),
|
|
608
|
+
changes: changesList(client, initiativeSpec),
|
|
609
|
+
webhook: webhookList(client, initiativeSpec)
|
|
610
|
+
});
|
|
611
|
+
const initiativeUpdateSpec = listSpec({
|
|
612
|
+
connection: "initiativeUpdates",
|
|
613
|
+
single: "initiativeUpdate",
|
|
614
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
615
|
+
initiative_id: initiative { id } user_id: user { id } body health url
|
|
616
|
+
edited_at: editedAt comment_count: commentCount`,
|
|
617
|
+
item: InitiativeUpdateObjectSchema,
|
|
618
|
+
updatedAt: (update) => update.updated_at,
|
|
619
|
+
rows: rowsOf((update) => ({
|
|
620
|
+
...update,
|
|
621
|
+
version: update.updated_at,
|
|
622
|
+
_deleted: false
|
|
623
|
+
}))
|
|
624
|
+
});
|
|
625
|
+
const makeInitiativeUpdates = (client) => Resource.entity({
|
|
626
|
+
name: "initiative_updates",
|
|
627
|
+
rowSchema: InitiativeUpdateSchema,
|
|
628
|
+
version: "version",
|
|
629
|
+
check: checkList(client, initiativeUpdateSpec),
|
|
630
|
+
backfill: backfillList(client, initiativeUpdateSpec),
|
|
631
|
+
changes: changesList(client, initiativeUpdateSpec),
|
|
632
|
+
webhook: webhookList(client, initiativeUpdateSpec)
|
|
633
|
+
});
|
|
634
|
+
const initiativeLabelSpec = listSpec({
|
|
635
|
+
connection: "initiativeLabels",
|
|
636
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
637
|
+
name description color is_group: isGroup parent_id: parent { id }
|
|
638
|
+
creator_id: creator { id } retired_at: retiredAt`,
|
|
639
|
+
item: InitiativeLabelObjectSchema,
|
|
640
|
+
updatedAt: (label) => label.updated_at,
|
|
641
|
+
rows: rowsOf((label) => ({
|
|
642
|
+
...label,
|
|
643
|
+
version: label.updated_at
|
|
644
|
+
}))
|
|
645
|
+
});
|
|
646
|
+
const makeInitiativeLabels = (client) => Resource.entity({
|
|
647
|
+
name: "initiative_labels",
|
|
648
|
+
rowSchema: InitiativeLabelSchema,
|
|
649
|
+
version: "version",
|
|
650
|
+
...listSources(client, initiativeLabelSpec)
|
|
651
|
+
});
|
|
652
|
+
const initiativeRelationSpec = listSpec({
|
|
653
|
+
connection: "initiativeRelations",
|
|
654
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
655
|
+
initiative_id: initiative { id } related_initiative_id: relatedInitiative { id }
|
|
656
|
+
sort_order: sortOrder user_id: user { id }`,
|
|
657
|
+
item: InitiativeRelationObjectSchema,
|
|
658
|
+
updatedAt: (relation) => relation.updated_at,
|
|
659
|
+
rows: rowsOf((relation) => ({
|
|
660
|
+
...relation,
|
|
661
|
+
version: relation.updated_at
|
|
662
|
+
}))
|
|
663
|
+
});
|
|
664
|
+
const makeInitiativeRelations = (client) => Resource.entity({
|
|
665
|
+
name: "initiative_relations",
|
|
666
|
+
rowSchema: InitiativeRelationSchema,
|
|
667
|
+
version: "version",
|
|
668
|
+
check: checkList(client, initiativeRelationSpec),
|
|
669
|
+
backfill: backfillList(client, initiativeRelationSpec),
|
|
670
|
+
changes: changesList(client, initiativeRelationSpec)
|
|
671
|
+
});
|
|
672
|
+
const initiativeToProjectSpec = listSpec({
|
|
673
|
+
connection: "initiativeToProjects",
|
|
674
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt initiative_id: initiative { id } project_id: project { id } sort_order: sortOrder`,
|
|
675
|
+
item: InitiativeToProjectObjectSchema,
|
|
676
|
+
updatedAt: (link) => link.updated_at,
|
|
677
|
+
rows: rowsOf((link) => ({
|
|
678
|
+
...link,
|
|
679
|
+
version: link.updated_at
|
|
680
|
+
}))
|
|
681
|
+
});
|
|
682
|
+
const makeInitiativeToProjects = (client) => Resource.entity({
|
|
683
|
+
name: "initiative_to_projects",
|
|
684
|
+
rowSchema: InitiativeToProjectSchema,
|
|
685
|
+
version: "version",
|
|
686
|
+
check: checkList(client, initiativeToProjectSpec),
|
|
687
|
+
backfill: backfillList(client, initiativeToProjectSpec),
|
|
688
|
+
changes: changesList(client, initiativeToProjectSpec)
|
|
689
|
+
});
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region src/schemas/issues.ts
|
|
692
|
+
const IssueSchema = Schema.Struct({
|
|
693
|
+
...common("Issue"),
|
|
694
|
+
_deleted: deleted("issue"),
|
|
695
|
+
identifier: Schema.String.pipe(field(10, "Readable ID, such as ENG-123.")),
|
|
696
|
+
number: Schema.Finite.pipe(field(11, "Issue number within its team.")),
|
|
697
|
+
title: Schema.String.pipe(field(12, "Issue title.")),
|
|
698
|
+
description: OptionalString.pipe(field(13, "Description in markdown.")),
|
|
699
|
+
url: Schema.String.pipe(field(14, "Issue URL.")),
|
|
700
|
+
branch_name: Schema.String.pipe(field(15, "Suggested Git branch name.")),
|
|
701
|
+
priority: Schema.Finite.pipe(field(16, "0 none, 1 urgent, 2 high, 3 medium, 4 low.")),
|
|
702
|
+
priority_label: Schema.String.pipe(field(17, "Priority name.")),
|
|
703
|
+
estimate: Schema.NullOr(Schema.Finite).pipe(field(18, "Estimate, on the team's scale.")),
|
|
704
|
+
due_date: OptionalString.pipe(field(19, "Due date, as YYYY-MM-DD.")),
|
|
705
|
+
creator_id: OptionalRef.pipe(field(20, "User who created the issue.")),
|
|
706
|
+
assignee_id: OptionalRef.pipe(field(21, "Assigned user.")),
|
|
707
|
+
delegate_id: OptionalRef.pipe(field(22, "Agent user working on the issue.")),
|
|
708
|
+
snoozed_by_id: OptionalRef.pipe(field(23, "User who snoozed the issue.")),
|
|
709
|
+
state_id: Ref.pipe(field(24, "Workflow state.")),
|
|
710
|
+
team_id: Ref.pipe(field(25, "Team the issue belongs to.")),
|
|
711
|
+
project_id: OptionalRef.pipe(field(26, "Project.")),
|
|
712
|
+
project_milestone_id: OptionalRef.pipe(field(27, "Project milestone.")),
|
|
713
|
+
cycle_id: OptionalRef.pipe(field(28, "Cycle.")),
|
|
714
|
+
parent_id: OptionalRef.pipe(field(29, "Parent issue.")),
|
|
715
|
+
source_comment_id: OptionalRef.pipe(field(30, "Comment the issue was made from.")),
|
|
716
|
+
external_user_creator_id: OptionalRef.pipe(field(31, "External user who created the issue through an integration.")),
|
|
717
|
+
label_ids: list(101, Schema.String).pipe(field(32, "Labels.")),
|
|
718
|
+
previous_identifiers: list(102, Schema.String).pipe(field(33, "Earlier readable IDs, from before the issue moved team.")),
|
|
719
|
+
started_at: OptionalTimestamp.pipe(field(34, "Time the issue moved to a started state.")),
|
|
720
|
+
completed_at: OptionalTimestamp.pipe(field(35, "Time the issue was completed.")),
|
|
721
|
+
canceled_at: OptionalTimestamp.pipe(field(36, "Time the issue was canceled.")),
|
|
722
|
+
started_triage_at: OptionalTimestamp.pipe(field(37, "Time the issue entered triage.")),
|
|
723
|
+
triaged_at: OptionalTimestamp.pipe(field(38, "Time the issue left triage.")),
|
|
724
|
+
auto_closed_at: OptionalTimestamp.pipe(field(39, "Time the issue was closed automatically.")),
|
|
725
|
+
auto_archived_at: OptionalTimestamp.pipe(field(40, "Time the issue was archived automatically.")),
|
|
726
|
+
added_to_cycle_at: OptionalTimestamp.pipe(field(41, "Time the issue was added to its cycle.")),
|
|
727
|
+
added_to_project_at: OptionalTimestamp.pipe(field(42, "Time the issue was added to its project.")),
|
|
728
|
+
added_to_team_at: OptionalTimestamp.pipe(field(43, "Time the issue was added to its team.")),
|
|
729
|
+
snoozed_until_at: OptionalTimestamp.pipe(field(44, "Time the issue is snoozed until.")),
|
|
730
|
+
sla_type: OptionalString.pipe(field(45, "SLA type.")),
|
|
731
|
+
sla_started_at: OptionalTimestamp.pipe(field(46, "Time the SLA started.")),
|
|
732
|
+
sla_breaches_at: OptionalTimestamp.pipe(field(47, "Time the SLA breaches.")),
|
|
733
|
+
customer_ticket_count: Long.pipe(field(48, "Linked support tickets.")),
|
|
734
|
+
integration_source_type: OptionalString.pipe(field(49, "Integration that created the issue.")),
|
|
735
|
+
trashed: Schema.NullOr(Schema.Boolean).pipe(field(50, "Whether the issue is in the trash."))
|
|
736
|
+
}).annotate({ description: "Linear issues, including archived and trashed ones." }).pipe(Iceberg.identifier("id"));
|
|
737
|
+
const IssueObjectSchema = IssueSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
738
|
+
const IssueHistorySchema = Schema.Struct({
|
|
739
|
+
...common("History entry"),
|
|
740
|
+
issue_id: Schema.String.pipe(field(10, "Issue that changed.")),
|
|
741
|
+
actor_id: OptionalString.pipe(field(11, "User who made the change.")),
|
|
742
|
+
from_state_id: OptionalString.pipe(field(12, "Workflow state before.")),
|
|
743
|
+
to_state_id: OptionalString.pipe(field(13, "Workflow state after.")),
|
|
744
|
+
from_assignee_id: OptionalString.pipe(field(14, "Assignee before.")),
|
|
745
|
+
to_assignee_id: OptionalString.pipe(field(15, "Assignee after.")),
|
|
746
|
+
from_cycle_id: OptionalString.pipe(field(16, "Cycle before.")),
|
|
747
|
+
to_cycle_id: OptionalString.pipe(field(17, "Cycle after.")),
|
|
748
|
+
from_project_id: OptionalString.pipe(field(18, "Project before.")),
|
|
749
|
+
to_project_id: OptionalString.pipe(field(19, "Project after.")),
|
|
750
|
+
from_parent_id: OptionalString.pipe(field(20, "Parent issue before.")),
|
|
751
|
+
to_parent_id: OptionalString.pipe(field(21, "Parent issue after.")),
|
|
752
|
+
from_team_id: OptionalString.pipe(field(22, "Team before.")),
|
|
753
|
+
to_team_id: OptionalString.pipe(field(23, "Team after.")),
|
|
754
|
+
from_priority: Schema.NullOr(Schema.Finite).pipe(field(24, "Priority before.")),
|
|
755
|
+
to_priority: Schema.NullOr(Schema.Finite).pipe(field(25, "Priority after.")),
|
|
756
|
+
from_estimate: Schema.NullOr(Schema.Finite).pipe(field(26, "Estimate before.")),
|
|
757
|
+
to_estimate: Schema.NullOr(Schema.Finite).pipe(field(27, "Estimate after.")),
|
|
758
|
+
from_due_date: OptionalString.pipe(field(28, "Due date before, as YYYY-MM-DD.")),
|
|
759
|
+
to_due_date: OptionalString.pipe(field(29, "Due date after, as YYYY-MM-DD.")),
|
|
760
|
+
from_title: OptionalString.pipe(field(30, "Title before.")),
|
|
761
|
+
to_title: OptionalString.pipe(field(31, "Title after.")),
|
|
762
|
+
added_label_ids: Schema.NullOr(list(101, Schema.String)).pipe(field(32, "Labels added.")),
|
|
763
|
+
removed_label_ids: Schema.NullOr(list(102, Schema.String)).pipe(field(33, "Labels removed.")),
|
|
764
|
+
attachment_id: OptionalString.pipe(field(34, "Attachment linked or unlinked.")),
|
|
765
|
+
customer_need_id: OptionalString.pipe(field(35, "Customer request linked or unlinked.")),
|
|
766
|
+
to_converted_project_id: OptionalString.pipe(field(36, "Project the issue became.")),
|
|
767
|
+
updated_description: Schema.NullOr(Schema.Boolean).pipe(field(37, "Whether the description changed.")),
|
|
768
|
+
archived: Schema.NullOr(Schema.Boolean).pipe(field(38, "Whether the issue was archived.")),
|
|
769
|
+
trashed: Schema.NullOr(Schema.Boolean).pipe(field(39, "Whether the issue was trashed.")),
|
|
770
|
+
auto_archived: Schema.NullOr(Schema.Boolean).pipe(field(40, "Whether the issue was archived automatically.")),
|
|
771
|
+
auto_closed: Schema.NullOr(Schema.Boolean).pipe(field(41, "Whether the issue was closed automatically."))
|
|
772
|
+
}).annotate({ description: "Linear issue history. One row per change to an issue." }).pipe(Iceberg.identifier("id"));
|
|
773
|
+
const IssueHistoryObjectSchema = IssueHistorySchema.mapFields((fields) => Struct.omit(fields, ["version", "issue_id"]));
|
|
774
|
+
const IssueRelationSchema = Schema.Struct({
|
|
775
|
+
...common("Relation"),
|
|
776
|
+
issue_id: Ref.pipe(field(10, "Issue the relation starts from.")),
|
|
777
|
+
related_issue_id: Ref.pipe(field(11, "Related issue.")),
|
|
778
|
+
type: Schema.String.pipe(field(12, "Relation type: blocks, duplicate, related, or similar."))
|
|
779
|
+
}).annotate({ description: "Linear issue relations. Deleted relations aren't seen." }).pipe(Iceberg.identifier("id"));
|
|
780
|
+
const IssueRelationObjectSchema = IssueRelationSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
781
|
+
const AttachmentSchema = Schema.Struct({
|
|
782
|
+
...common("Attachment"),
|
|
783
|
+
_deleted: deleted("attachment"),
|
|
784
|
+
issue_id: Ref.pipe(field(10, "Issue the attachment is on.")),
|
|
785
|
+
creator_id: OptionalRef.pipe(field(11, "User who added it.")),
|
|
786
|
+
external_user_creator_id: OptionalRef.pipe(field(12, "External user who added it.")),
|
|
787
|
+
title: Schema.String.pipe(field(13, "Title.")),
|
|
788
|
+
subtitle: OptionalString.pipe(field(14, "Subtitle.")),
|
|
789
|
+
url: Schema.String.pipe(field(15, "Linked URL, such as a pull request or ticket.")),
|
|
790
|
+
source_type: OptionalString.pipe(field(16, "Source, such as github or zendesk."))
|
|
791
|
+
}).annotate({ description: "Linear issue attachments: links to pull requests, tickets, and more." }).pipe(Iceberg.identifier("id"));
|
|
792
|
+
const AttachmentObjectSchema = AttachmentSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
793
|
+
const IssueLabelSchema = Schema.Struct({
|
|
794
|
+
...common("Label"),
|
|
795
|
+
_deleted: deleted("label"),
|
|
796
|
+
name: Schema.String.pipe(field(10, "Label name.")),
|
|
797
|
+
description: OptionalString.pipe(field(11, "Label description.")),
|
|
798
|
+
color: Schema.String.pipe(field(12, "Label color, as hex.")),
|
|
799
|
+
is_group: Schema.Boolean.pipe(field(13, "Whether the label groups other labels.")),
|
|
800
|
+
parent_id: OptionalRef.pipe(field(14, "Label group.")),
|
|
801
|
+
team_id: OptionalRef.pipe(field(15, "Team, or null for a workspace label.")),
|
|
802
|
+
creator_id: OptionalRef.pipe(field(16, "User who made the label.")),
|
|
803
|
+
retired_at: OptionalTimestamp.pipe(field(17, "Time the label was retired."))
|
|
804
|
+
}).annotate({ description: "Linear issue labels. Names the IDs in `issues.label_ids`." }).pipe(Iceberg.identifier("id"));
|
|
805
|
+
const IssueLabelObjectSchema = IssueLabelSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region src/resources/issue-history.ts
|
|
808
|
+
const historyFields = `
|
|
809
|
+
id created_at: createdAt updated_at: updatedAt archived_at: archivedAt actor_id: actorId
|
|
810
|
+
from_state_id: fromStateId to_state_id: toStateId
|
|
811
|
+
from_assignee_id: fromAssigneeId to_assignee_id: toAssigneeId
|
|
812
|
+
from_cycle_id: fromCycleId to_cycle_id: toCycleId
|
|
813
|
+
from_project_id: fromProjectId to_project_id: toProjectId
|
|
814
|
+
from_parent_id: fromParentId to_parent_id: toParentId from_team_id: fromTeamId to_team_id: toTeamId
|
|
815
|
+
from_priority: fromPriority to_priority: toPriority
|
|
816
|
+
from_estimate: fromEstimate to_estimate: toEstimate
|
|
817
|
+
from_due_date: fromDueDate to_due_date: toDueDate from_title: fromTitle to_title: toTitle
|
|
818
|
+
added_label_ids: addedLabelIds removed_label_ids: removedLabelIds
|
|
819
|
+
attachment_id: attachmentId customer_need_id: customerNeedId
|
|
820
|
+
to_converted_project_id: toConvertedProjectId updated_description: updatedDescription
|
|
821
|
+
archived trashed auto_archived: autoArchived auto_closed: autoClosed`;
|
|
822
|
+
const HistoryPageSchema = Schema.Struct({
|
|
823
|
+
nodes: Schema.Array(IssueHistoryObjectSchema),
|
|
824
|
+
pageInfo: Schema.Struct({
|
|
825
|
+
hasNextPage: Schema.Boolean,
|
|
826
|
+
endCursor: Schema.NullOr(Schema.String)
|
|
827
|
+
})
|
|
828
|
+
});
|
|
829
|
+
const IssueWithHistorySchema = Schema.Struct({
|
|
830
|
+
id: Schema.String,
|
|
831
|
+
updated_at: Timestamp,
|
|
832
|
+
history: HistoryPageSchema
|
|
833
|
+
});
|
|
834
|
+
const nextCursor = ({ pageInfo }) => pageInfo.hasNextPage ? Option.fromNullishOr(pageInfo.endCursor) : Option.none();
|
|
835
|
+
/** Returns the history after the first page, without repeating that page. */
|
|
836
|
+
const readMore = (client, issueId, first) => Option.match(nextCursor(first), {
|
|
837
|
+
onNone: () => Effect.succeed([]),
|
|
838
|
+
onSome: (cursor) => Stream.paginate(cursor, (after) => client.query(Schema.Struct({ issue: Schema.Struct({ history: HistoryPageSchema }) }), `query IssueHistory($id: String!, $after: String) {
|
|
839
|
+
issue(id: $id) { history(first: 250, after: $after) { nodes { ${historyFields} } pageInfo { hasNextPage endCursor } } }
|
|
840
|
+
}`, {
|
|
841
|
+
id: issueId,
|
|
842
|
+
after
|
|
843
|
+
}).pipe(Effect.map(({ issue }) => [issue.history.nodes, nextCursor(issue.history)]))).pipe(Stream.runCollect)
|
|
844
|
+
});
|
|
845
|
+
/** Linear has no top-level history query. */
|
|
846
|
+
const historySpec = (client) => listSpec({
|
|
847
|
+
connection: "issues",
|
|
848
|
+
fields: `id updated_at: updatedAt history(first: 50) { nodes { ${historyFields} } pageInfo { hasNextPage endCursor } }`,
|
|
849
|
+
item: IssueWithHistorySchema,
|
|
850
|
+
first: 25,
|
|
851
|
+
updatedAt: (issue) => issue.updated_at,
|
|
852
|
+
rows: (issues) => Effect.forEach(issues, (issue) => readMore(client, issue.id, issue.history).pipe(Effect.map((more) => [...issue.history.nodes, ...more].map((entry) => ({
|
|
853
|
+
...entry,
|
|
854
|
+
issue_id: issue.id,
|
|
855
|
+
version: entry.updated_at
|
|
856
|
+
}))))).pipe(Effect.map((rows) => rows.flat()))
|
|
857
|
+
});
|
|
858
|
+
const makeIssueHistory = (client) => {
|
|
859
|
+
const spec = historySpec(client);
|
|
860
|
+
return Resource.entity({
|
|
861
|
+
name: "issue_history",
|
|
862
|
+
rowSchema: IssueHistorySchema,
|
|
863
|
+
version: "version",
|
|
864
|
+
check: checkList(client, spec),
|
|
865
|
+
backfill: backfillList(client, spec),
|
|
866
|
+
changes: changesList(client, spec),
|
|
867
|
+
webhook: {
|
|
868
|
+
schema: Schema.Struct({ data: Schema.Struct({ id: Schema.String }) }),
|
|
869
|
+
handler: ({ payload }) => client.find(Schema.Struct({ issue: IssueWithHistorySchema }), `query IssueHistory($id: String!) {
|
|
870
|
+
issue(id: $id) { ${spec.fields} }
|
|
871
|
+
}`, { id: payload.data.id }).pipe(Effect.flatMap(Option.match({
|
|
872
|
+
onNone: () => Effect.succeed([]),
|
|
873
|
+
onSome: ({ issue }) => spec.rows([issue])
|
|
874
|
+
})))
|
|
875
|
+
}
|
|
876
|
+
});
|
|
877
|
+
};
|
|
878
|
+
//#endregion
|
|
879
|
+
//#region src/resources/issues.ts
|
|
880
|
+
const issueSpec = listSpec({
|
|
881
|
+
connection: "issues",
|
|
882
|
+
single: "issue",
|
|
883
|
+
fields: `
|
|
884
|
+
id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
885
|
+
identifier number title description url branch_name: branchName
|
|
886
|
+
priority priority_label: priorityLabel estimate due_date: dueDate
|
|
887
|
+
creator_id: creator { id } assignee_id: assignee { id } delegate_id: delegate { id }
|
|
888
|
+
snoozed_by_id: snoozedBy { id } state_id: state { id } team_id: team { id }
|
|
889
|
+
project_id: project { id } project_milestone_id: projectMilestone { id }
|
|
890
|
+
cycle_id: cycle { id } parent_id: parent { id } source_comment_id: sourceComment { id }
|
|
891
|
+
external_user_creator_id: externalUserCreator { id }
|
|
892
|
+
label_ids: labelIds previous_identifiers: previousIdentifiers
|
|
893
|
+
started_at: startedAt completed_at: completedAt canceled_at: canceledAt
|
|
894
|
+
started_triage_at: startedTriageAt triaged_at: triagedAt auto_closed_at: autoClosedAt
|
|
895
|
+
auto_archived_at: autoArchivedAt added_to_cycle_at: addedToCycleAt
|
|
896
|
+
added_to_project_at: addedToProjectAt added_to_team_at: addedToTeamAt
|
|
897
|
+
snoozed_until_at: snoozedUntilAt sla_type: slaType sla_started_at: slaStartedAt
|
|
898
|
+
sla_breaches_at: slaBreachesAt customer_ticket_count: customerTicketCount
|
|
899
|
+
integration_source_type: integrationSourceType trashed`,
|
|
900
|
+
item: IssueObjectSchema,
|
|
901
|
+
updatedAt: (issue) => issue.updated_at,
|
|
902
|
+
rows: rowsOf((issue) => ({
|
|
903
|
+
...issue,
|
|
904
|
+
version: issue.updated_at,
|
|
905
|
+
_deleted: false
|
|
906
|
+
}))
|
|
907
|
+
});
|
|
908
|
+
const makeIssues = (client) => Resource.entity({
|
|
909
|
+
name: "issues",
|
|
910
|
+
rowSchema: IssueSchema,
|
|
911
|
+
version: "version",
|
|
912
|
+
check: checkList(client, issueSpec),
|
|
913
|
+
backfill: backfillList(client, issueSpec),
|
|
914
|
+
changes: changesList(client, issueSpec),
|
|
915
|
+
webhook: webhookList(client, issueSpec)
|
|
916
|
+
});
|
|
917
|
+
const issueRelationSpec = listSpec({
|
|
918
|
+
connection: "issueRelations",
|
|
919
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
920
|
+
issue_id: issue { id } related_issue_id: relatedIssue { id } type`,
|
|
921
|
+
item: IssueRelationObjectSchema,
|
|
922
|
+
updatedAt: (relation) => relation.updated_at,
|
|
923
|
+
rows: rowsOf((relation) => ({
|
|
924
|
+
...relation,
|
|
925
|
+
version: relation.updated_at
|
|
926
|
+
}))
|
|
927
|
+
});
|
|
928
|
+
const makeIssueRelations = (client) => Resource.entity({
|
|
929
|
+
name: "issue_relations",
|
|
930
|
+
rowSchema: IssueRelationSchema,
|
|
931
|
+
version: "version",
|
|
932
|
+
check: checkList(client, issueRelationSpec),
|
|
933
|
+
backfill: backfillList(client, issueRelationSpec),
|
|
934
|
+
changes: changesList(client, issueRelationSpec)
|
|
935
|
+
});
|
|
936
|
+
const attachmentSpec = listSpec({
|
|
937
|
+
connection: "attachments",
|
|
938
|
+
single: "attachment",
|
|
939
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
940
|
+
issue_id: issue { id } creator_id: creator { id }
|
|
941
|
+
external_user_creator_id: externalUserCreator { id }
|
|
942
|
+
title subtitle url source_type: sourceType`,
|
|
943
|
+
item: AttachmentObjectSchema,
|
|
944
|
+
updatedAt: (attachment) => attachment.updated_at,
|
|
945
|
+
rows: rowsOf((attachment) => ({
|
|
946
|
+
...attachment,
|
|
947
|
+
version: attachment.updated_at,
|
|
948
|
+
_deleted: false
|
|
949
|
+
}))
|
|
950
|
+
});
|
|
951
|
+
const makeAttachments = (client) => Resource.entity({
|
|
952
|
+
name: "attachments",
|
|
953
|
+
rowSchema: AttachmentSchema,
|
|
954
|
+
version: "version",
|
|
955
|
+
check: checkList(client, attachmentSpec),
|
|
956
|
+
backfill: backfillList(client, attachmentSpec),
|
|
957
|
+
changes: changesList(client, attachmentSpec),
|
|
958
|
+
webhook: webhookList(client, attachmentSpec)
|
|
959
|
+
});
|
|
960
|
+
const issueLabelSpec = listSpec({
|
|
961
|
+
connection: "issueLabels",
|
|
962
|
+
single: "issueLabel",
|
|
963
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
964
|
+
name description color is_group: isGroup parent_id: parent { id } team_id: team { id }
|
|
965
|
+
creator_id: creator { id } retired_at: retiredAt`,
|
|
966
|
+
item: IssueLabelObjectSchema,
|
|
967
|
+
updatedAt: (label) => label.updated_at,
|
|
968
|
+
rows: rowsOf((label) => ({
|
|
969
|
+
...label,
|
|
970
|
+
version: label.updated_at,
|
|
971
|
+
_deleted: false
|
|
972
|
+
}))
|
|
973
|
+
});
|
|
974
|
+
const makeIssueLabels = (client) => Resource.entity({
|
|
975
|
+
name: "issue_labels",
|
|
976
|
+
rowSchema: IssueLabelSchema,
|
|
977
|
+
version: "version",
|
|
978
|
+
...listSources(client, issueLabelSpec),
|
|
979
|
+
webhook: webhookList(client, issueLabelSpec)
|
|
980
|
+
});
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region src/schemas/projects.ts
|
|
983
|
+
const ProjectSchema = Schema.Struct({
|
|
984
|
+
...common("Project"),
|
|
985
|
+
_deleted: deleted("project"),
|
|
986
|
+
name: Schema.String.pipe(field(10, "Project name.")),
|
|
987
|
+
description: Schema.String.pipe(field(11, "Short summary.")),
|
|
988
|
+
content: OptionalString.pipe(field(12, "Project overview in markdown.")),
|
|
989
|
+
url: Schema.String.pipe(field(13, "Project URL.")),
|
|
990
|
+
icon: OptionalString.pipe(field(14, "Icon.")),
|
|
991
|
+
color: Schema.String.pipe(field(15, "Color, as hex.")),
|
|
992
|
+
status_id: Ref.pipe(field(16, "Project status.")),
|
|
993
|
+
priority: Long.pipe(field(17, "0 none, 1 urgent, 2 high, 3 medium, 4 low.")),
|
|
994
|
+
priority_label: Schema.String.pipe(field(18, "Priority name.")),
|
|
995
|
+
health: OptionalString.pipe(field(19, "Health from the latest update.")),
|
|
996
|
+
health_updated_at: OptionalTimestamp.pipe(field(20, "Time the health last changed.")),
|
|
997
|
+
progress: Schema.Finite.pipe(field(21, "Share of the scope completed, from 0 to 1.")),
|
|
998
|
+
scope: Schema.Finite.pipe(field(22, "Total estimate of the project's issues.")),
|
|
999
|
+
lead_id: OptionalRef.pipe(field(23, "Project lead.")),
|
|
1000
|
+
creator_id: OptionalRef.pipe(field(24, "User who made the project.")),
|
|
1001
|
+
converted_from_issue_id: OptionalRef.pipe(field(25, "Issue the project was made from.")),
|
|
1002
|
+
start_date: OptionalString.pipe(field(26, "Start date, as YYYY-MM-DD.")),
|
|
1003
|
+
target_date: OptionalString.pipe(field(27, "Target date, as YYYY-MM-DD.")),
|
|
1004
|
+
started_at: OptionalTimestamp.pipe(field(28, "Time the project started.")),
|
|
1005
|
+
completed_at: OptionalTimestamp.pipe(field(29, "Time the project was completed.")),
|
|
1006
|
+
canceled_at: OptionalTimestamp.pipe(field(30, "Time the project was canceled.")),
|
|
1007
|
+
auto_archived_at: OptionalTimestamp.pipe(field(31, "Time the project was archived automatically.")),
|
|
1008
|
+
label_ids: list(101, Schema.String).pipe(field(32, "Project labels.")),
|
|
1009
|
+
team_ids: RefList(102).pipe(field(33, "Teams the project belongs to. Reads up to 50.")),
|
|
1010
|
+
member_ids: RefList(103).pipe(field(34, "Project members. Reads up to 100.")),
|
|
1011
|
+
trashed: Schema.NullOr(Schema.Boolean).pipe(field(35, "Whether the project is in the trash."))
|
|
1012
|
+
}).annotate({ description: "Linear projects, including archived and trashed ones." }).pipe(Iceberg.identifier("id"));
|
|
1013
|
+
const ProjectObjectSchema = ProjectSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
1014
|
+
const ProjectMilestoneSchema = Schema.Struct({
|
|
1015
|
+
...common("Milestone"),
|
|
1016
|
+
name: Schema.String.pipe(field(10, "Milestone name.")),
|
|
1017
|
+
description: OptionalString.pipe(field(11, "Description in markdown.")),
|
|
1018
|
+
project_id: Ref.pipe(field(12, "Project.")),
|
|
1019
|
+
target_date: OptionalString.pipe(field(13, "Target date, as YYYY-MM-DD.")),
|
|
1020
|
+
status: Schema.String.pipe(field(14, "Status: unstarted, next, overdue, or done.")),
|
|
1021
|
+
progress: Schema.Finite.pipe(field(15, "Share of the scope completed, from 0 to 1.")),
|
|
1022
|
+
sort_order: Schema.Finite.pipe(field(16, "Order within the project."))
|
|
1023
|
+
}).annotate({ description: "Linear project milestones. Deleted milestones aren't seen." }).pipe(Iceberg.identifier("id"));
|
|
1024
|
+
const ProjectMilestoneObjectSchema = ProjectMilestoneSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1025
|
+
const ProjectUpdateSchema = Schema.Struct({
|
|
1026
|
+
...common("Update"),
|
|
1027
|
+
_deleted: deleted("update"),
|
|
1028
|
+
project_id: Ref.pipe(field(10, "Project.")),
|
|
1029
|
+
user_id: Ref.pipe(field(11, "User who posted the update.")),
|
|
1030
|
+
body: Schema.String.pipe(field(12, "Update text in markdown.")),
|
|
1031
|
+
health: Schema.String.pipe(field(13, "Health: onTrack, atRisk, or offTrack.")),
|
|
1032
|
+
url: Schema.String.pipe(field(14, "Update URL.")),
|
|
1033
|
+
edited_at: OptionalTimestamp.pipe(field(15, "Time the update was last edited.")),
|
|
1034
|
+
comment_count: Long.pipe(field(16, "Comments on the update."))
|
|
1035
|
+
}).annotate({ description: "Linear project updates: status posts with a health." }).pipe(Iceberg.identifier("id"));
|
|
1036
|
+
const ProjectUpdateObjectSchema = ProjectUpdateSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
1037
|
+
const ProjectStatusSchema = Schema.Struct({
|
|
1038
|
+
...common("Status"),
|
|
1039
|
+
name: Schema.String.pipe(field(10, "Status name.")),
|
|
1040
|
+
type: Schema.String.pipe(field(11, "Status type: backlog, planned, started, paused, completed, or canceled.")),
|
|
1041
|
+
color: Schema.String.pipe(field(12, "Color, as hex.")),
|
|
1042
|
+
description: OptionalString.pipe(field(13, "Description.")),
|
|
1043
|
+
position: Schema.Finite.pipe(field(14, "Order in the list."))
|
|
1044
|
+
}).annotate({ description: "Linear project statuses. Names the IDs in `projects.status_id`." }).pipe(Iceberg.identifier("id"));
|
|
1045
|
+
const ProjectStatusObjectSchema = ProjectStatusSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1046
|
+
const ProjectLabelSchema = Schema.Struct({
|
|
1047
|
+
...common("Label"),
|
|
1048
|
+
_deleted: deleted("label"),
|
|
1049
|
+
name: Schema.String.pipe(field(10, "Label name.")),
|
|
1050
|
+
description: OptionalString.pipe(field(11, "Label description.")),
|
|
1051
|
+
color: Schema.String.pipe(field(12, "Label color, as hex.")),
|
|
1052
|
+
is_group: Schema.Boolean.pipe(field(13, "Whether the label groups other labels.")),
|
|
1053
|
+
parent_id: OptionalRef.pipe(field(14, "Label group.")),
|
|
1054
|
+
creator_id: OptionalRef.pipe(field(15, "User who made the label.")),
|
|
1055
|
+
retired_at: OptionalTimestamp.pipe(field(16, "Time the label was retired."))
|
|
1056
|
+
}).annotate({ description: "Linear project labels. Names the IDs in `projects.label_ids`." }).pipe(Iceberg.identifier("id"));
|
|
1057
|
+
const ProjectLabelObjectSchema = ProjectLabelSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
1058
|
+
const ProjectRelationSchema = Schema.Struct({
|
|
1059
|
+
...common("Relation"),
|
|
1060
|
+
type: Schema.String.pipe(field(10, "Relation type, such as dependency.")),
|
|
1061
|
+
project_id: Ref.pipe(field(11, "Project the relation starts from.")),
|
|
1062
|
+
project_milestone_id: OptionalRef.pipe(field(12, "Milestone the relation starts from.")),
|
|
1063
|
+
anchor_type: Schema.String.pipe(field(13, "Which end of the project it starts from.")),
|
|
1064
|
+
related_project_id: Ref.pipe(field(14, "Related project.")),
|
|
1065
|
+
related_project_milestone_id: OptionalRef.pipe(field(15, "Related milestone.")),
|
|
1066
|
+
related_anchor_type: Schema.String.pipe(field(16, "Which end of the related project.")),
|
|
1067
|
+
user_id: OptionalRef.pipe(field(17, "User who made the relation."))
|
|
1068
|
+
}).annotate({ description: "Linear project dependencies. Deleted relations aren't seen." }).pipe(Iceberg.identifier("id"));
|
|
1069
|
+
const ProjectRelationObjectSchema = ProjectRelationSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1070
|
+
//#endregion
|
|
1071
|
+
//#region src/resources/projects.ts
|
|
1072
|
+
const projectSpec = listSpec({
|
|
1073
|
+
connection: "projects",
|
|
1074
|
+
single: "project",
|
|
1075
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
1076
|
+
name description content url icon color status_id: status { id } priority
|
|
1077
|
+
priority_label: priorityLabel health health_updated_at: healthUpdatedAt progress scope
|
|
1078
|
+
lead_id: lead { id } creator_id: creator { id }
|
|
1079
|
+
converted_from_issue_id: convertedFromIssue { id } start_date: startDate
|
|
1080
|
+
target_date: targetDate started_at: startedAt completed_at: completedAt
|
|
1081
|
+
canceled_at: canceledAt auto_archived_at: autoArchivedAt label_ids: labelIds
|
|
1082
|
+
team_ids: teams(first: 50) { nodes { id } } member_ids: members(first: 100) { nodes { id } }
|
|
1083
|
+
trashed`,
|
|
1084
|
+
item: ProjectObjectSchema,
|
|
1085
|
+
first: 50,
|
|
1086
|
+
updatedAt: (project) => project.updated_at,
|
|
1087
|
+
rows: rowsOf((project) => ({
|
|
1088
|
+
...project,
|
|
1089
|
+
version: project.updated_at,
|
|
1090
|
+
_deleted: false
|
|
1091
|
+
}))
|
|
1092
|
+
});
|
|
1093
|
+
const makeProjects = (client) => Resource.entity({
|
|
1094
|
+
name: "projects",
|
|
1095
|
+
rowSchema: ProjectSchema,
|
|
1096
|
+
version: "version",
|
|
1097
|
+
check: checkList(client, projectSpec),
|
|
1098
|
+
backfill: backfillList(client, projectSpec),
|
|
1099
|
+
changes: changesList(client, projectSpec),
|
|
1100
|
+
webhook: webhookList(client, projectSpec)
|
|
1101
|
+
});
|
|
1102
|
+
const projectMilestoneSpec = listSpec({
|
|
1103
|
+
connection: "projectMilestones",
|
|
1104
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
1105
|
+
name description project_id: project { id } target_date: targetDate status progress
|
|
1106
|
+
sort_order: sortOrder`,
|
|
1107
|
+
item: ProjectMilestoneObjectSchema,
|
|
1108
|
+
updatedAt: (milestone) => milestone.updated_at,
|
|
1109
|
+
rows: rowsOf((milestone) => ({
|
|
1110
|
+
...milestone,
|
|
1111
|
+
version: milestone.updated_at
|
|
1112
|
+
}))
|
|
1113
|
+
});
|
|
1114
|
+
const makeProjectMilestones = (client) => Resource.entity({
|
|
1115
|
+
name: "project_milestones",
|
|
1116
|
+
rowSchema: ProjectMilestoneSchema,
|
|
1117
|
+
version: "version",
|
|
1118
|
+
check: checkList(client, projectMilestoneSpec),
|
|
1119
|
+
backfill: backfillList(client, projectMilestoneSpec),
|
|
1120
|
+
changes: changesList(client, projectMilestoneSpec)
|
|
1121
|
+
});
|
|
1122
|
+
const projectUpdateSpec = listSpec({
|
|
1123
|
+
connection: "projectUpdates",
|
|
1124
|
+
single: "projectUpdate",
|
|
1125
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
1126
|
+
project_id: project { id } user_id: user { id } body health url edited_at: editedAt
|
|
1127
|
+
comment_count: commentCount`,
|
|
1128
|
+
item: ProjectUpdateObjectSchema,
|
|
1129
|
+
updatedAt: (update) => update.updated_at,
|
|
1130
|
+
rows: rowsOf((update) => ({
|
|
1131
|
+
...update,
|
|
1132
|
+
version: update.updated_at,
|
|
1133
|
+
_deleted: false
|
|
1134
|
+
}))
|
|
1135
|
+
});
|
|
1136
|
+
const makeProjectUpdates = (client) => Resource.entity({
|
|
1137
|
+
name: "project_updates",
|
|
1138
|
+
rowSchema: ProjectUpdateSchema,
|
|
1139
|
+
version: "version",
|
|
1140
|
+
check: checkList(client, projectUpdateSpec),
|
|
1141
|
+
backfill: backfillList(client, projectUpdateSpec),
|
|
1142
|
+
changes: changesList(client, projectUpdateSpec),
|
|
1143
|
+
webhook: webhookList(client, projectUpdateSpec)
|
|
1144
|
+
});
|
|
1145
|
+
const projectStatusSpec = listSpec({
|
|
1146
|
+
connection: "projectStatuses",
|
|
1147
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt name type color description position`,
|
|
1148
|
+
item: ProjectStatusObjectSchema,
|
|
1149
|
+
updatedAt: (status) => status.updated_at,
|
|
1150
|
+
rows: rowsOf((status) => ({
|
|
1151
|
+
...status,
|
|
1152
|
+
version: status.updated_at
|
|
1153
|
+
}))
|
|
1154
|
+
});
|
|
1155
|
+
const makeProjectStatuses = (client) => Resource.entity({
|
|
1156
|
+
name: "project_statuses",
|
|
1157
|
+
rowSchema: ProjectStatusSchema,
|
|
1158
|
+
version: "version",
|
|
1159
|
+
...listSources(client, projectStatusSpec)
|
|
1160
|
+
});
|
|
1161
|
+
const projectLabelSpec = listSpec({
|
|
1162
|
+
connection: "projectLabels",
|
|
1163
|
+
single: "projectLabel",
|
|
1164
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
1165
|
+
name description color is_group: isGroup parent_id: parent { id }
|
|
1166
|
+
creator_id: creator { id } retired_at: retiredAt`,
|
|
1167
|
+
item: ProjectLabelObjectSchema,
|
|
1168
|
+
updatedAt: (label) => label.updated_at,
|
|
1169
|
+
rows: rowsOf((label) => ({
|
|
1170
|
+
...label,
|
|
1171
|
+
version: label.updated_at,
|
|
1172
|
+
_deleted: false
|
|
1173
|
+
}))
|
|
1174
|
+
});
|
|
1175
|
+
const makeProjectLabels = (client) => Resource.entity({
|
|
1176
|
+
name: "project_labels",
|
|
1177
|
+
rowSchema: ProjectLabelSchema,
|
|
1178
|
+
version: "version",
|
|
1179
|
+
...listSources(client, projectLabelSpec),
|
|
1180
|
+
webhook: webhookList(client, projectLabelSpec)
|
|
1181
|
+
});
|
|
1182
|
+
const projectRelationSpec = listSpec({
|
|
1183
|
+
connection: "projectRelations",
|
|
1184
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
1185
|
+
type project_id: project { id } project_milestone_id: projectMilestone { id }
|
|
1186
|
+
anchor_type: anchorType related_project_id: relatedProject { id }
|
|
1187
|
+
related_project_milestone_id: relatedProjectMilestone { id }
|
|
1188
|
+
related_anchor_type: relatedAnchorType user_id: user { id }`,
|
|
1189
|
+
item: ProjectRelationObjectSchema,
|
|
1190
|
+
updatedAt: (relation) => relation.updated_at,
|
|
1191
|
+
rows: rowsOf((relation) => ({
|
|
1192
|
+
...relation,
|
|
1193
|
+
version: relation.updated_at
|
|
1194
|
+
}))
|
|
1195
|
+
});
|
|
1196
|
+
const makeProjectRelations = (client) => Resource.entity({
|
|
1197
|
+
name: "project_relations",
|
|
1198
|
+
rowSchema: ProjectRelationSchema,
|
|
1199
|
+
version: "version",
|
|
1200
|
+
check: checkList(client, projectRelationSpec),
|
|
1201
|
+
backfill: backfillList(client, projectRelationSpec),
|
|
1202
|
+
changes: changesList(client, projectRelationSpec)
|
|
1203
|
+
});
|
|
1204
|
+
//#endregion
|
|
1205
|
+
//#region src/schemas/releases.ts
|
|
1206
|
+
const ReleaseSchema = Schema.Struct({
|
|
1207
|
+
...common("Release"),
|
|
1208
|
+
name: Schema.String.pipe(field(10, "Release name.")),
|
|
1209
|
+
description: OptionalString.pipe(field(11, "Description.")),
|
|
1210
|
+
release_version: OptionalString.pipe(field(12, "Version, such as 1.2.0.")),
|
|
1211
|
+
url: Schema.String.pipe(field(13, "Release URL.")),
|
|
1212
|
+
commit_sha: OptionalString.pipe(field(14, "Commit SHA.")),
|
|
1213
|
+
pipeline_id: Ref.pipe(field(15, "Release pipeline.")),
|
|
1214
|
+
stage_id: Ref.pipe(field(16, "Release stage.")),
|
|
1215
|
+
creator_id: OptionalRef.pipe(field(17, "User who made the release.")),
|
|
1216
|
+
start_date: OptionalString.pipe(field(18, "Start date, as YYYY-MM-DD.")),
|
|
1217
|
+
target_date: OptionalString.pipe(field(19, "Target date, as YYYY-MM-DD.")),
|
|
1218
|
+
started_at: OptionalTimestamp.pipe(field(20, "Time the release started.")),
|
|
1219
|
+
completed_at: OptionalTimestamp.pipe(field(21, "Time the release was completed.")),
|
|
1220
|
+
canceled_at: OptionalTimestamp.pipe(field(22, "Time the release was canceled.")),
|
|
1221
|
+
trashed: Schema.NullOr(Schema.Boolean).pipe(field(23, "Whether the release is in the trash."))
|
|
1222
|
+
}).annotate({ description: "Linear releases. Needs the Business plan." }).pipe(Iceberg.identifier("id"));
|
|
1223
|
+
const ReleaseObjectSchema = ReleaseSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1224
|
+
const ReleaseNoteSchema = Schema.Struct({
|
|
1225
|
+
...common("Release note"),
|
|
1226
|
+
title: OptionalString.pipe(field(10, "Release note title.")),
|
|
1227
|
+
content: Schema.NullOr(Schema.Struct({ content: OptionalString })).pipe(Schema.decodeTo(OptionalString, SchemaTransformation.transform({
|
|
1228
|
+
decode: (document) => document?.content ?? null,
|
|
1229
|
+
encode: (content) => content === null ? null : { content }
|
|
1230
|
+
})), field(11, "Release note body in markdown.")),
|
|
1231
|
+
url: Schema.String.pipe(field(12, "Release note URL.")),
|
|
1232
|
+
pipeline_id: Ref.pipe(field(13, "Release pipeline.")),
|
|
1233
|
+
release_ids: list(101, Ref).pipe(field(14, "Releases covered by the note."))
|
|
1234
|
+
}).annotate({ description: "Linear release notes. Needs the Business plan." }).pipe(Iceberg.identifier("id"));
|
|
1235
|
+
const ReleaseNoteObjectSchema = ReleaseNoteSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1236
|
+
const ReleasePipelineSchema = Schema.Struct({
|
|
1237
|
+
...common("Pipeline"),
|
|
1238
|
+
name: Schema.String.pipe(field(10, "Pipeline name.")),
|
|
1239
|
+
type: Schema.String.pipe(field(11, "Pipeline type.")),
|
|
1240
|
+
is_production: Schema.Boolean.pipe(field(12, "Whether it releases to production.")),
|
|
1241
|
+
url: Schema.String.pipe(field(13, "Pipeline URL.")),
|
|
1242
|
+
include_path_patterns: list(101, Schema.String).pipe(field(14, "File paths that count toward the pipeline.")),
|
|
1243
|
+
approximate_release_count: Long.pipe(field(15, "About how many releases it has.")),
|
|
1244
|
+
trashed: Schema.NullOr(Schema.Boolean).pipe(field(16, "Whether the pipeline is in the trash."))
|
|
1245
|
+
}).annotate({ description: "Linear release pipelines. Needs the Business plan." }).pipe(Iceberg.identifier("id"));
|
|
1246
|
+
const ReleasePipelineObjectSchema = ReleasePipelineSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1247
|
+
const ReleaseStageSchema = Schema.Struct({
|
|
1248
|
+
...common("Stage"),
|
|
1249
|
+
name: Schema.String.pipe(field(10, "Stage name.")),
|
|
1250
|
+
type: Schema.String.pipe(field(11, "Stage type.")),
|
|
1251
|
+
color: Schema.String.pipe(field(12, "Color, as hex.")),
|
|
1252
|
+
position: Schema.Finite.pipe(field(13, "Order in the pipeline.")),
|
|
1253
|
+
frozen: Schema.Boolean.pipe(field(14, "Whether the stage is frozen.")),
|
|
1254
|
+
pipeline_id: Ref.pipe(field(15, "Release pipeline."))
|
|
1255
|
+
}).annotate({ description: "Linear release stages. Needs the Business plan." }).pipe(Iceberg.identifier("id"));
|
|
1256
|
+
const ReleaseStageObjectSchema = ReleaseStageSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1257
|
+
const IssueToReleaseSchema = Schema.Struct({
|
|
1258
|
+
...common("Link"),
|
|
1259
|
+
issue_id: Ref.pipe(field(10, "Issue.")),
|
|
1260
|
+
release_id: Ref.pipe(field(11, "Release."))
|
|
1261
|
+
}).annotate({ description: "Links between Linear issues and releases. Needs the Business plan." }).pipe(Iceberg.identifier("id"));
|
|
1262
|
+
const IssueToReleaseObjectSchema = IssueToReleaseSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1263
|
+
//#endregion
|
|
1264
|
+
//#region src/resources/releases.ts
|
|
1265
|
+
const releaseSpec = listSpec({
|
|
1266
|
+
connection: "releases",
|
|
1267
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
1268
|
+
name description release_version: version url commit_sha: commitSha
|
|
1269
|
+
pipeline_id: pipeline { id } stage_id: stage { id } creator_id: creator { id }
|
|
1270
|
+
start_date: startDate target_date: targetDate started_at: startedAt
|
|
1271
|
+
completed_at: completedAt canceled_at: canceledAt trashed`,
|
|
1272
|
+
item: ReleaseObjectSchema,
|
|
1273
|
+
updatedAt: (release) => release.updated_at,
|
|
1274
|
+
rows: rowsOf((release) => ({
|
|
1275
|
+
...release,
|
|
1276
|
+
version: release.updated_at
|
|
1277
|
+
}))
|
|
1278
|
+
});
|
|
1279
|
+
const makeReleases = (client) => Resource.entity({
|
|
1280
|
+
name: "releases",
|
|
1281
|
+
rowSchema: ReleaseSchema,
|
|
1282
|
+
version: "version",
|
|
1283
|
+
check: checkList(client, releaseSpec),
|
|
1284
|
+
backfill: backfillList(client, releaseSpec),
|
|
1285
|
+
changes: changesList(client, releaseSpec)
|
|
1286
|
+
});
|
|
1287
|
+
const releaseNoteSpec = listSpec({
|
|
1288
|
+
connection: "releaseNotes",
|
|
1289
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
1290
|
+
title content: documentContent { content } url pipeline_id: pipeline { id }
|
|
1291
|
+
release_ids: releases { id }`,
|
|
1292
|
+
item: ReleaseNoteObjectSchema,
|
|
1293
|
+
updatedAt: (note) => note.updated_at,
|
|
1294
|
+
rows: rowsOf((note) => ({
|
|
1295
|
+
...note,
|
|
1296
|
+
version: note.updated_at
|
|
1297
|
+
}))
|
|
1298
|
+
});
|
|
1299
|
+
const makeReleaseNotes = (client) => Resource.entity({
|
|
1300
|
+
name: "release_notes",
|
|
1301
|
+
rowSchema: ReleaseNoteSchema,
|
|
1302
|
+
version: "version",
|
|
1303
|
+
check: checkList(client, releaseNoteSpec),
|
|
1304
|
+
backfill: backfillList(client, releaseNoteSpec),
|
|
1305
|
+
changes: changesList(client, releaseNoteSpec)
|
|
1306
|
+
});
|
|
1307
|
+
const releasePipelineSpec = listSpec({
|
|
1308
|
+
connection: "releasePipelines",
|
|
1309
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
1310
|
+
name type is_production: isProduction url include_path_patterns: includePathPatterns
|
|
1311
|
+
approximate_release_count: approximateReleaseCount trashed`,
|
|
1312
|
+
item: ReleasePipelineObjectSchema,
|
|
1313
|
+
updatedAt: (pipeline) => pipeline.updated_at,
|
|
1314
|
+
rows: rowsOf((pipeline) => ({
|
|
1315
|
+
...pipeline,
|
|
1316
|
+
version: pipeline.updated_at
|
|
1317
|
+
}))
|
|
1318
|
+
});
|
|
1319
|
+
const makeReleasePipelines = (client) => Resource.entity({
|
|
1320
|
+
name: "release_pipelines",
|
|
1321
|
+
rowSchema: ReleasePipelineSchema,
|
|
1322
|
+
version: "version",
|
|
1323
|
+
...listSources(client, releasePipelineSpec)
|
|
1324
|
+
});
|
|
1325
|
+
const releaseStageSpec = listSpec({
|
|
1326
|
+
connection: "releaseStages",
|
|
1327
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt name type color position frozen pipeline_id: pipeline { id }`,
|
|
1328
|
+
item: ReleaseStageObjectSchema,
|
|
1329
|
+
updatedAt: (stage) => stage.updated_at,
|
|
1330
|
+
rows: rowsOf((stage) => ({
|
|
1331
|
+
...stage,
|
|
1332
|
+
version: stage.updated_at
|
|
1333
|
+
}))
|
|
1334
|
+
});
|
|
1335
|
+
const makeReleaseStages = (client) => Resource.entity({
|
|
1336
|
+
name: "release_stages",
|
|
1337
|
+
rowSchema: ReleaseStageSchema,
|
|
1338
|
+
version: "version",
|
|
1339
|
+
...listSources(client, releaseStageSpec)
|
|
1340
|
+
});
|
|
1341
|
+
const issueToReleaseSpec = listSpec({
|
|
1342
|
+
connection: "issueToReleases",
|
|
1343
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt issue_id: issue { id } release_id: release { id }`,
|
|
1344
|
+
item: IssueToReleaseObjectSchema,
|
|
1345
|
+
updatedAt: (link) => link.updated_at,
|
|
1346
|
+
rows: rowsOf((link) => ({
|
|
1347
|
+
...link,
|
|
1348
|
+
version: link.updated_at
|
|
1349
|
+
}))
|
|
1350
|
+
});
|
|
1351
|
+
const makeIssueToReleases = (client) => Resource.entity({
|
|
1352
|
+
name: "issue_to_releases",
|
|
1353
|
+
rowSchema: IssueToReleaseSchema,
|
|
1354
|
+
version: "version",
|
|
1355
|
+
check: checkList(client, issueToReleaseSpec),
|
|
1356
|
+
backfill: backfillList(client, issueToReleaseSpec),
|
|
1357
|
+
changes: changesList(client, issueToReleaseSpec)
|
|
1358
|
+
});
|
|
1359
|
+
//#endregion
|
|
1360
|
+
//#region src/schemas/teams.ts
|
|
1361
|
+
const TeamSchema = Schema.Struct({
|
|
1362
|
+
...common("Team"),
|
|
1363
|
+
name: Schema.String.pipe(field(10, "Team name.")),
|
|
1364
|
+
key: Schema.String.pipe(field(11, "Team key, used in issue IDs such as ENG-123.")),
|
|
1365
|
+
display_name: Schema.String.pipe(field(12, "Name shown in Linear.")),
|
|
1366
|
+
description: OptionalString.pipe(field(13, "Team description.")),
|
|
1367
|
+
visibility: Schema.String.pipe(field(14, "Who can see the team.")),
|
|
1368
|
+
parent_id: OptionalRef.pipe(field(15, "Parent team.")),
|
|
1369
|
+
timezone: Schema.String.pipe(field(16, "Team timezone.")),
|
|
1370
|
+
cycles_enabled: Schema.Boolean.pipe(field(17, "Whether the team uses cycles.")),
|
|
1371
|
+
cycle_duration: Schema.Finite.pipe(field(18, "Cycle length in weeks.")),
|
|
1372
|
+
cycle_cooldown_time: Schema.Finite.pipe(field(19, "Weeks between cycles.")),
|
|
1373
|
+
cycle_start_day: Schema.Finite.pipe(field(20, "Day cycles start, 0 for Sunday.")),
|
|
1374
|
+
triage_enabled: Schema.Boolean.pipe(field(21, "Whether the team uses triage.")),
|
|
1375
|
+
issue_estimation_type: Schema.String.pipe(field(22, "Estimate scale.")),
|
|
1376
|
+
default_issue_estimate: Schema.Finite.pipe(field(23, "Default estimate.")),
|
|
1377
|
+
auto_archive_period: Schema.Finite.pipe(field(24, "Months before closed issues are archived.")),
|
|
1378
|
+
auto_close_period: Schema.NullOr(Schema.Finite).pipe(field(25, "Months before stale issues are closed.")),
|
|
1379
|
+
retired_at: OptionalTimestamp.pipe(field(26, "Time the team was retired."))
|
|
1380
|
+
}).annotate({ description: "Linear teams." }).pipe(Iceberg.identifier("id"));
|
|
1381
|
+
const TeamObjectSchema = TeamSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1382
|
+
const TeamMembershipSchema = Schema.Struct({
|
|
1383
|
+
...common("Membership"),
|
|
1384
|
+
team_id: Ref.pipe(field(10, "Team.")),
|
|
1385
|
+
user_id: Ref.pipe(field(11, "User.")),
|
|
1386
|
+
owner: Schema.Boolean.pipe(field(12, "Whether the user owns the team."))
|
|
1387
|
+
}).annotate({ description: "Linear team members. Removed members aren't seen." }).pipe(Iceberg.identifier("id"));
|
|
1388
|
+
const TeamMembershipObjectSchema = TeamMembershipSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1389
|
+
const WorkflowStateSchema = Schema.Struct({
|
|
1390
|
+
...common("Workflow state"),
|
|
1391
|
+
name: Schema.String.pipe(field(10, "State name.")),
|
|
1392
|
+
type: Schema.String.pipe(field(11, "State type: triage, backlog, unstarted, started, completed, or canceled.")),
|
|
1393
|
+
color: Schema.String.pipe(field(12, "State color, as hex.")),
|
|
1394
|
+
description: OptionalString.pipe(field(13, "State description.")),
|
|
1395
|
+
position: Schema.Finite.pipe(field(14, "Order within the team.")),
|
|
1396
|
+
team_id: Ref.pipe(field(15, "Team."))
|
|
1397
|
+
}).annotate({ description: "Linear workflow states. Names the IDs in `issues.state_id`." }).pipe(Iceberg.identifier("id"));
|
|
1398
|
+
const WorkflowStateObjectSchema = WorkflowStateSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1399
|
+
const UserSchema = Schema.Struct({
|
|
1400
|
+
...common("User"),
|
|
1401
|
+
_deleted: deleted("user"),
|
|
1402
|
+
name: Schema.String.pipe(field(10, "Full name.")),
|
|
1403
|
+
display_name: Schema.String.pipe(field(11, "Display name.")),
|
|
1404
|
+
email: Schema.String.pipe(field(12, "Email address.")),
|
|
1405
|
+
avatar_url: OptionalString.pipe(field(13, "Avatar image URL.")),
|
|
1406
|
+
title: OptionalString.pipe(field(14, "Job title.")),
|
|
1407
|
+
timezone: OptionalString.pipe(field(15, "Timezone.")),
|
|
1408
|
+
active: Schema.Boolean.pipe(field(16, "Whether the user is active.")),
|
|
1409
|
+
admin: Schema.Boolean.pipe(field(17, "Whether the user is an admin.")),
|
|
1410
|
+
owner: Schema.Boolean.pipe(field(18, "Whether the user owns the workspace.")),
|
|
1411
|
+
guest: Schema.Boolean.pipe(field(19, "Whether the user is a guest.")),
|
|
1412
|
+
app: Schema.Boolean.pipe(field(20, "Whether the user is an app or agent.")),
|
|
1413
|
+
last_seen: OptionalTimestamp.pipe(field(21, "Time the user was last online.")),
|
|
1414
|
+
url: Schema.String.pipe(field(22, "Profile URL."))
|
|
1415
|
+
}).annotate({ description: "Linear users." }).pipe(Iceberg.identifier("id"));
|
|
1416
|
+
const UserObjectSchema = UserSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
1417
|
+
const ExternalUserSchema = Schema.Struct({
|
|
1418
|
+
...common("External user"),
|
|
1419
|
+
name: Schema.String.pipe(field(10, "Name.")),
|
|
1420
|
+
display_name: Schema.String.pipe(field(11, "Display name.")),
|
|
1421
|
+
email: OptionalString.pipe(field(12, "Email address.")),
|
|
1422
|
+
avatar_url: OptionalString.pipe(field(13, "Avatar image URL.")),
|
|
1423
|
+
last_seen: OptionalTimestamp.pipe(field(14, "Time the user was last seen."))
|
|
1424
|
+
}).annotate({ description: "People from integrations, such as Slack, who create issues and comments." }).pipe(Iceberg.identifier("id"));
|
|
1425
|
+
const ExternalUserObjectSchema = ExternalUserSchema.mapFields((fields) => Struct.omit(fields, ["version"]));
|
|
1426
|
+
const CycleSchema = Schema.Struct({
|
|
1427
|
+
...common("Cycle"),
|
|
1428
|
+
_deleted: deleted("cycle"),
|
|
1429
|
+
number: Schema.Finite.pipe(field(10, "Cycle number within its team.")),
|
|
1430
|
+
name: OptionalString.pipe(field(11, "Cycle name.")),
|
|
1431
|
+
description: OptionalString.pipe(field(12, "Cycle description.")),
|
|
1432
|
+
team_id: Ref.pipe(field(13, "Team.")),
|
|
1433
|
+
starts_at: Timestamp.pipe(field(14, "Time the cycle starts.")),
|
|
1434
|
+
ends_at: Timestamp.pipe(field(15, "Time the cycle ends.")),
|
|
1435
|
+
completed_at: OptionalTimestamp.pipe(field(16, "Time the cycle was completed.")),
|
|
1436
|
+
auto_archived_at: OptionalTimestamp.pipe(field(17, "Time the cycle was archived automatically.")),
|
|
1437
|
+
progress: Schema.Finite.pipe(field(18, "Share of the scope completed, from 0 to 1."))
|
|
1438
|
+
}).annotate({ description: "Linear cycles." }).pipe(Iceberg.identifier("id"));
|
|
1439
|
+
const CycleObjectSchema = CycleSchema.mapFields((fields) => Struct.omit(fields, ["version", "_deleted"]));
|
|
1440
|
+
//#endregion
|
|
1441
|
+
//#region src/resources/teams.ts
|
|
1442
|
+
const teamSpec = listSpec({
|
|
1443
|
+
connection: "teams",
|
|
1444
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
1445
|
+
name key display_name: displayName description visibility parent_id: parent { id }
|
|
1446
|
+
timezone cycles_enabled: cyclesEnabled cycle_duration: cycleDuration
|
|
1447
|
+
cycle_cooldown_time: cycleCooldownTime cycle_start_day: cycleStartDay
|
|
1448
|
+
triage_enabled: triageEnabled issue_estimation_type: issueEstimationType
|
|
1449
|
+
default_issue_estimate: defaultIssueEstimate auto_archive_period: autoArchivePeriod
|
|
1450
|
+
auto_close_period: autoClosePeriod retired_at: retiredAt`,
|
|
1451
|
+
item: TeamObjectSchema,
|
|
1452
|
+
updatedAt: (team) => team.updated_at,
|
|
1453
|
+
rows: rowsOf((team) => ({
|
|
1454
|
+
...team,
|
|
1455
|
+
version: team.updated_at
|
|
1456
|
+
}))
|
|
1457
|
+
});
|
|
1458
|
+
const makeTeams = (client) => Resource.entity({
|
|
1459
|
+
name: "teams",
|
|
1460
|
+
rowSchema: TeamSchema,
|
|
1461
|
+
version: "version",
|
|
1462
|
+
...listSources(client, teamSpec)
|
|
1463
|
+
});
|
|
1464
|
+
const teamMembershipSpec = listSpec({
|
|
1465
|
+
connection: "teamMemberships",
|
|
1466
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt team_id: team { id } user_id: user { id } owner`,
|
|
1467
|
+
item: TeamMembershipObjectSchema,
|
|
1468
|
+
updatedAt: (membership) => membership.updated_at,
|
|
1469
|
+
rows: rowsOf((membership) => ({
|
|
1470
|
+
...membership,
|
|
1471
|
+
version: membership.updated_at
|
|
1472
|
+
}))
|
|
1473
|
+
});
|
|
1474
|
+
const makeTeamMemberships = (client) => Resource.entity({
|
|
1475
|
+
name: "team_memberships",
|
|
1476
|
+
rowSchema: TeamMembershipSchema,
|
|
1477
|
+
version: "version",
|
|
1478
|
+
...listSources(client, teamMembershipSpec)
|
|
1479
|
+
});
|
|
1480
|
+
const workflowStateSpec = listSpec({
|
|
1481
|
+
connection: "workflowStates",
|
|
1482
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt name type color description position team_id: team { id }`,
|
|
1483
|
+
item: WorkflowStateObjectSchema,
|
|
1484
|
+
updatedAt: (state) => state.updated_at,
|
|
1485
|
+
rows: rowsOf((state) => ({
|
|
1486
|
+
...state,
|
|
1487
|
+
version: state.updated_at
|
|
1488
|
+
}))
|
|
1489
|
+
});
|
|
1490
|
+
const makeWorkflowStates = (client) => Resource.entity({
|
|
1491
|
+
name: "workflow_states",
|
|
1492
|
+
rowSchema: WorkflowStateSchema,
|
|
1493
|
+
version: "version",
|
|
1494
|
+
...listSources(client, workflowStateSpec)
|
|
1495
|
+
});
|
|
1496
|
+
const userSpec = listSpec({
|
|
1497
|
+
connection: "users",
|
|
1498
|
+
single: "user",
|
|
1499
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
1500
|
+
name display_name: displayName email avatar_url: avatarUrl title timezone
|
|
1501
|
+
active admin owner guest app last_seen: lastSeen url`,
|
|
1502
|
+
item: UserObjectSchema,
|
|
1503
|
+
updatedAt: (user) => user.updated_at,
|
|
1504
|
+
rows: rowsOf((user) => ({
|
|
1505
|
+
...user,
|
|
1506
|
+
version: user.updated_at,
|
|
1507
|
+
_deleted: false
|
|
1508
|
+
}))
|
|
1509
|
+
});
|
|
1510
|
+
const makeUsers = (client) => Resource.entity({
|
|
1511
|
+
name: "users",
|
|
1512
|
+
rowSchema: UserSchema,
|
|
1513
|
+
version: "version",
|
|
1514
|
+
...listSources(client, userSpec),
|
|
1515
|
+
webhook: webhookList(client, userSpec)
|
|
1516
|
+
});
|
|
1517
|
+
const externalUserSpec = listSpec({
|
|
1518
|
+
connection: "externalUsers",
|
|
1519
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt name display_name: displayName email avatar_url: avatarUrl last_seen: lastSeen`,
|
|
1520
|
+
item: ExternalUserObjectSchema,
|
|
1521
|
+
updatedAt: (user) => user.updated_at,
|
|
1522
|
+
rows: rowsOf((user) => ({
|
|
1523
|
+
...user,
|
|
1524
|
+
version: user.updated_at
|
|
1525
|
+
}))
|
|
1526
|
+
});
|
|
1527
|
+
const makeExternalUsers = (client) => Resource.entity({
|
|
1528
|
+
name: "external_users",
|
|
1529
|
+
rowSchema: ExternalUserSchema,
|
|
1530
|
+
version: "version",
|
|
1531
|
+
...listSources(client, externalUserSpec)
|
|
1532
|
+
});
|
|
1533
|
+
const cycleSpec = listSpec({
|
|
1534
|
+
connection: "cycles",
|
|
1535
|
+
single: "cycle",
|
|
1536
|
+
fields: `id created_at: createdAt updated_at: updatedAt archived_at: archivedAt
|
|
1537
|
+
number name description team_id: team { id } starts_at: startsAt ends_at: endsAt
|
|
1538
|
+
completed_at: completedAt auto_archived_at: autoArchivedAt progress`,
|
|
1539
|
+
item: CycleObjectSchema,
|
|
1540
|
+
updatedAt: (cycle) => cycle.updated_at,
|
|
1541
|
+
rows: rowsOf((cycle) => ({
|
|
1542
|
+
...cycle,
|
|
1543
|
+
version: cycle.updated_at,
|
|
1544
|
+
_deleted: false
|
|
1545
|
+
}))
|
|
1546
|
+
});
|
|
1547
|
+
const makeCycles = (client) => Resource.entity({
|
|
1548
|
+
name: "cycles",
|
|
1549
|
+
rowSchema: CycleSchema,
|
|
1550
|
+
version: "version",
|
|
1551
|
+
check: checkList(client, cycleSpec),
|
|
1552
|
+
backfill: backfillList(client, cycleSpec),
|
|
1553
|
+
changes: changesList(client, cycleSpec),
|
|
1554
|
+
webhook: webhookList(client, cycleSpec)
|
|
1555
|
+
});
|
|
1556
|
+
//#endregion
|
|
1557
|
+
//#region src/webhook/signature.ts
|
|
1558
|
+
const maxAgeMillis = 6e4;
|
|
1559
|
+
const verifySignature = (options) => Effect.gen(function* () {
|
|
1560
|
+
const expected = createHmac("sha256", options.secret).update(options.rawBody).digest();
|
|
1561
|
+
const provided = Buffer.from(options.header ?? "", "hex");
|
|
1562
|
+
if (provided.length !== expected.length || !timingSafeEqual(provided, expected)) return yield* new ConnectorError({ message: "Invalid Linear webhook signature" });
|
|
1563
|
+
const now = yield* DateTime.nowAsDate;
|
|
1564
|
+
if (options.timestamp === void 0 || Math.abs(now.getTime() - options.timestamp) > maxAgeMillis) return yield* new ConnectorError({ message: "Linear webhook is too old" });
|
|
1565
|
+
});
|
|
1566
|
+
//#endregion
|
|
1567
|
+
//#region src/webhook/route.ts
|
|
1568
|
+
const webhookPath = "/webhooks/linear";
|
|
1569
|
+
const WebhookEventSchema = Schema.Struct({
|
|
1570
|
+
type: Schema.String,
|
|
1571
|
+
action: Schema.String,
|
|
1572
|
+
webhookTimestamp: Schema.Number,
|
|
1573
|
+
data: Schema.Struct({ id: Schema.String })
|
|
1574
|
+
});
|
|
1575
|
+
const makeWebhookRoute = (options) => Webhook.route({
|
|
1576
|
+
path: webhookPath,
|
|
1577
|
+
ackMode: "after-enqueue",
|
|
1578
|
+
schema: WebhookEventSchema,
|
|
1579
|
+
handler: ({ request, rawBody, payload, to }) => Effect.gen(function* () {
|
|
1580
|
+
const verified = yield* verifySignature({
|
|
1581
|
+
rawBody,
|
|
1582
|
+
header: request.headers["linear-signature"],
|
|
1583
|
+
secret: options.secret,
|
|
1584
|
+
timestamp: payload.webhookTimestamp
|
|
1585
|
+
}).pipe(Effect.result);
|
|
1586
|
+
if (Result.isFailure(verified)) return HttpServerResponse.jsonUnsafe({
|
|
1587
|
+
ok: false,
|
|
1588
|
+
error: verified.failure.message
|
|
1589
|
+
}, { status: 401 });
|
|
1590
|
+
const resource = options.targets.get(payload.type);
|
|
1591
|
+
if (payload.action === "remove" || payload.action === "restore") {
|
|
1592
|
+
if (resource !== void 0) yield* to(resource, payload);
|
|
1593
|
+
if (payload.type === "Issue") yield* to(options.issueHistory, payload);
|
|
1594
|
+
}
|
|
1595
|
+
return HttpServerResponse.jsonUnsafe({ ok: true });
|
|
1596
|
+
})
|
|
1597
|
+
});
|
|
1598
|
+
//#endregion
|
|
1599
|
+
//#region src/connector.ts
|
|
1600
|
+
var connector_exports = /* @__PURE__ */ __exportAll({
|
|
1601
|
+
LinearConfigDef: () => LinearConfigDef,
|
|
1602
|
+
LinearConnector: () => LinearConnector,
|
|
1603
|
+
layer: () => layer,
|
|
1604
|
+
layerConfig: () => layerConfig,
|
|
1605
|
+
make: () => make,
|
|
1606
|
+
manifest: () => manifest
|
|
1607
|
+
});
|
|
1608
|
+
const make = Effect.fnUntraced(function* (config) {
|
|
1609
|
+
const client = yield* LinearClient;
|
|
1610
|
+
const Issues = makeIssues(client);
|
|
1611
|
+
const IssueHistory = makeIssueHistory(client);
|
|
1612
|
+
const Comments = makeComments(client);
|
|
1613
|
+
const Attachments = makeAttachments(client);
|
|
1614
|
+
const IssueLabels = makeIssueLabels(client);
|
|
1615
|
+
const Users = makeUsers(client);
|
|
1616
|
+
const Cycles = makeCycles(client);
|
|
1617
|
+
const Projects = makeProjects(client);
|
|
1618
|
+
const ProjectUpdates = makeProjectUpdates(client);
|
|
1619
|
+
const ProjectLabels = makeProjectLabels(client);
|
|
1620
|
+
const Initiatives = makeInitiatives(client);
|
|
1621
|
+
const InitiativeUpdates = makeInitiativeUpdates(client);
|
|
1622
|
+
const Documents = makeDocuments(client);
|
|
1623
|
+
const Customers = makeCustomers(client);
|
|
1624
|
+
const CustomerNeeds = makeCustomerNeeds(client);
|
|
1625
|
+
return Connector.define({
|
|
1626
|
+
name: "producer-linear",
|
|
1627
|
+
title: "Linear",
|
|
1628
|
+
resources: [
|
|
1629
|
+
Issues,
|
|
1630
|
+
IssueHistory,
|
|
1631
|
+
Comments,
|
|
1632
|
+
makeIssueRelations(client),
|
|
1633
|
+
Attachments,
|
|
1634
|
+
IssueLabels,
|
|
1635
|
+
makeWorkflowStates(client),
|
|
1636
|
+
makeTeams(client),
|
|
1637
|
+
makeTeamMemberships(client),
|
|
1638
|
+
Users,
|
|
1639
|
+
makeExternalUsers(client),
|
|
1640
|
+
Cycles,
|
|
1641
|
+
Projects,
|
|
1642
|
+
makeProjectMilestones(client),
|
|
1643
|
+
ProjectUpdates,
|
|
1644
|
+
makeProjectStatuses(client),
|
|
1645
|
+
ProjectLabels,
|
|
1646
|
+
makeProjectRelations(client),
|
|
1647
|
+
Initiatives,
|
|
1648
|
+
InitiativeUpdates,
|
|
1649
|
+
makeInitiativeLabels(client),
|
|
1650
|
+
makeInitiativeRelations(client),
|
|
1651
|
+
makeInitiativeToProjects(client),
|
|
1652
|
+
Documents,
|
|
1653
|
+
Customers,
|
|
1654
|
+
CustomerNeeds,
|
|
1655
|
+
makeCustomerStatuses(client),
|
|
1656
|
+
makeCustomerTiers(client),
|
|
1657
|
+
makeReleases(client),
|
|
1658
|
+
makeReleaseNotes(client),
|
|
1659
|
+
makeReleasePipelines(client),
|
|
1660
|
+
makeReleaseStages(client),
|
|
1661
|
+
makeIssueToReleases(client)
|
|
1662
|
+
],
|
|
1663
|
+
webhooks: [makeWebhookRoute({
|
|
1664
|
+
secret: Redacted.value(config.webhookSecret),
|
|
1665
|
+
issueHistory: IssueHistory,
|
|
1666
|
+
targets: /* @__PURE__ */ new Map([
|
|
1667
|
+
["Issue", Issues],
|
|
1668
|
+
["Comment", Comments],
|
|
1669
|
+
["Attachment", Attachments],
|
|
1670
|
+
["IssueLabel", IssueLabels],
|
|
1671
|
+
["User", Users],
|
|
1672
|
+
["Cycle", Cycles],
|
|
1673
|
+
["Project", Projects],
|
|
1674
|
+
["ProjectUpdate", ProjectUpdates],
|
|
1675
|
+
["ProjectLabel", ProjectLabels],
|
|
1676
|
+
["Initiative", Initiatives],
|
|
1677
|
+
["InitiativeUpdate", InitiativeUpdates],
|
|
1678
|
+
["Document", Documents],
|
|
1679
|
+
["Customer", Customers],
|
|
1680
|
+
["CustomerNeed", CustomerNeeds]
|
|
1681
|
+
])
|
|
1682
|
+
})]
|
|
1683
|
+
});
|
|
1684
|
+
});
|
|
1685
|
+
var LinearConnector = class extends Context.Service()("@useairfoil/producer-linear/LinearConnector") {};
|
|
1686
|
+
const layer = (config) => Layer.effect(LinearConnector)(make(config).pipe(Effect.annotateLogs({ component: "linear" }))).pipe(Layer.provide(layer$1(config)));
|
|
1687
|
+
const layerConfig = (config) => Layer.unwrap(Config.unwrap(config).pipe(Effect.map(layer)));
|
|
1688
|
+
//#endregion
|
|
1689
|
+
export { InitiativeToProjectSchema as A, IssueHistorySchema as C, InitiativeLabelSchema as D, IssueSchema as E, CustomerStatusSchema as F, CustomerTierSchema as I, CommentSchema as L, DocumentSchema as M, CustomerNeedSchema as N, InitiativeRelationSchema as O, CustomerSchema as P, client_exports as R, AttachmentSchema as S, IssueRelationSchema as T, ProjectMilestoneSchema as _, CycleSchema as a, ProjectStatusSchema as b, TeamSchema as c, IssueToReleaseSchema as d, ReleaseNoteSchema as f, ProjectLabelSchema as g, ReleaseStageSchema as h, webhookPath as i, InitiativeUpdateSchema as j, InitiativeSchema as k, UserSchema as l, ReleaseSchema as m, connector_exports as n, ExternalUserSchema as o, ReleasePipelineSchema as p, layerConfig as r, TeamMembershipSchema as s, LinearConnector as t, WorkflowStateSchema as u, ProjectRelationSchema as v, IssueLabelSchema as w, ProjectUpdateSchema as x, ProjectSchema as y };
|
|
1690
|
+
|
|
1691
|
+
//# sourceMappingURL=src-Ci3_ltan.mjs.map
|