@tool-bridge/server 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{airtable-S3T4TAN7.js → airtable-NOSOMOVB.js} +106 -114
- package/dist/{alt_text_generator_ai-4DIRIDKL.js → alt_text_generator_ai-BHIJ4LW5.js} +25 -16
- package/dist/{amap-LGVGNPML.js → amap-QRLP4TWZ.js} +114 -123
- package/dist/{anthropic-27RFZO35.js → anthropic-IEOI36EV.js} +34 -56
- package/dist/{apify-6WLYAIAS.js → apify-3CCYTQVK.js} +31 -49
- package/dist/{brave_search-K2SVJ66F.js → brave_search-PZNYDQG7.js} +52 -77
- package/dist/chunk-JXHMDBAY.js +45 -0
- package/dist/chunk-LMLX3DJF.js +50 -0
- package/dist/{chunk-YB2FLNWI.js → chunk-RVWZN3CI.js} +2103 -1775
- package/dist/{chunk-BB6ZLMTU.js → chunk-TLNUIPFZ.js} +492 -300
- package/dist/chunk-U5UHT7CX.js +977 -0
- package/dist/chunk-U67V476Y.js +35 -0
- package/dist/chunk-WW2IMPQK.js +283 -0
- package/dist/{chunk-VK3V2WTY.js → chunk-YASUMV2K.js} +4 -6
- package/dist/{circleci-WV3ITU7Q.js → circleci-VSJ4O5FC.js} +36 -55
- package/dist/{clerk-NFQEFKS4.js → clerk-CC2JZBZI.js} +60 -80
- package/dist/{cloudflare_dns-2RK5ASBJ.js → cloudflare_dns-PJEBSEYQ.js} +90 -113
- package/dist/{cohere-5KEW7LWT.js → cohere-KBACYSPF.js} +33 -49
- package/dist/{confluence-SZE63S46.js → confluence-2PX3O7G5.js} +79 -115
- package/dist/{convertapi-QPG2JC5K.js → convertapi-BVOTD2PJ.js} +13 -16
- package/dist/{currencyapi-UO2APQRY.js → currencyapi-6ZQ2VNQ7.js} +30 -53
- package/dist/{deepseek-LJELIMM3.js → deepseek-MB3WVVTB.js} +30 -38
- package/dist/{docker_hub-2MFXSBOF.js → docker_hub-7CLQL2IJ.js} +141 -157
- package/dist/{dropbox-GQYNTTVA.js → dropbox-VFYDVUNK.js} +134 -141
- package/dist/{dub-KI2LHXST.js → dub-QN3EETJY.js} +61 -93
- package/dist/{e2b-WO6ISY3C.js → e2b-NKC3Y776.js} +39 -69
- package/dist/{exa-IZ7B3BPT.js → exa-KKZ6F25K.js} +49 -77
- package/dist/{fal_ai-LTMF36GJ.js → fal_ai-25LYJD2O.js} +37 -44
- package/dist/{feishu-WM7SLSFD.js → feishu-NRT55B3Q.js} +4 -6
- package/dist/{feishu_custom_bot-66W3MXH2.js → feishu_custom_bot-3W3XXUG4.js} +4 -5
- package/dist/{figma-2Z274VQZ.js → figma-4FLP35TC.js} +56 -81
- package/dist/{firehydrant-IFI4R65V.js → firehydrant-BLXPLZ3X.js} +40 -53
- package/dist/{fixer-BCCZEB3D.js → fixer-4OR62TGE.js} +31 -43
- package/dist/{fly-755FXYB5.js → fly-MYCKOZZK.js} +50 -66
- package/dist/{front-4FZKKXXK.js → front-3DFYVMF3.js} +43 -66
- package/dist/{geocodio-WYKDJ3DP.js → geocodio-CXMD6VKA.js} +37 -63
- package/dist/{ghost-5BNQTCOH.js → ghost-4UUE737W.js} +51 -57
- package/dist/{github-ULELF5VX.js → github-WFS2ON2N.js} +48 -41
- package/dist/{gmail-G34WT64J.js → gmail-KW7FXA7A.js} +26 -36
- package/dist/{googlecalendar-BQU255SC.js → googlecalendar-AMH5JQMC.js} +57 -78
- package/dist/{googledocs-HPCNQXYJ.js → googledocs-R5VA6CKD.js} +14 -22
- package/dist/{grafana-VOV24FIC.js → grafana-IT6DWIVB.js} +95 -122
- package/dist/{graphhopper-D5RXW6AP.js → graphhopper-TYFDJZWC.js} +32 -46
- package/dist/index.d.ts +57 -50
- package/dist/index.js +4 -3
- package/dist/{ip2proxy-DAYO7EKZ.js → ip2proxy-GJ4HXVXO.js} +35 -42
- package/dist/{ipgeolocation_io-XD4PSLII.js → ipgeolocation_io-OAGR6PRF.js} +40 -60
- package/dist/{ipqualityscore-K27QEAWK.js → ipqualityscore-BCKAMDGL.js} +30 -42
- package/dist/{jina_ai-E6UXFV2P.js → jina_ai-N3NXRVIZ.js} +32 -58
- package/dist/{jira-ZDSXGQ6W.js → jira-CHLBKWLO.js} +116 -126
- package/dist/{langsmith-TIFJRREW.js → langsmith-OIKOTPY3.js} +101 -121
- package/dist/{lemlist-DASEMJMA.js → lemlist-VAKYPKS3.js} +57 -68
- package/dist/{linear-KE6UP4SP.js → linear-Q6QTPJ5R.js} +109 -118
- package/dist/{logsnag-IMNDN4R5.js → logsnag-SQOQBTES.js} +31 -48
- package/dist/main.js +103 -102
- package/dist/{mattermost-HHHMUXQA.js → mattermost-G2KBEICM.js} +45 -62
- package/dist/{mem0-D2FGGOIY.js → mem0-D2FPLYDX.js} +72 -98
- package/dist/{memos-4OVIGFPH.js → memos-76PTWV5V.js} +68 -122
- package/dist/{metabase-33WCX5YD.js → metabase-TWSIDVBM.js} +47 -60
- package/dist/{mistral_ai-QIMZ2JYL.js → mistral_ai-TP7TQUEJ.js} +35 -40
- package/dist/{mother_duck-M6VWS2VH.js → mother_duck-UXY5THYU.js} +42 -62
- package/dist/{ngrok-Z2PKQBHH.js → ngrok-RZW2ISJK.js} +42 -58
- package/dist/{notes-SS4RPC4K.js → notes-B2I6FWK2.js} +3 -5
- package/dist/{notion-FJCNQ6I7.js → notion-QOKRUE6M.js} +83 -97
- package/dist/{open_exchange_rates-WU57WTT5.js → open_exchange_rates-ODLFWEJ7.js} +35 -39
- package/dist/{openai-JODZ4GKT.js → openai-ZPBPPPGT.js} +51 -55
- package/dist/{opengraph_io-SQRAUSV5.js → opengraph_io-EOI5UJKT.js} +61 -79
- package/dist/{openrouter-Q5XXEJZ7.js → openrouter-BUWLF3BG.js} +41 -55
- package/dist/{outline-RT2EHJ2X.js → outline-NXS3QRXO.js} +89 -104
- package/dist/{paddle-OF2V7GAC.js → paddle-T4MSKQ76.js} +34 -49
- package/dist/{perplexity-LNZEWLHG.js → perplexity-WW5N2LW7.js} +33 -50
- package/dist/{pinecone-JSJIXZYN.js → pinecone-RY5AZPQM.js} +65 -91
- package/dist/{pipedrive-D4CKVUXR.js → pipedrive-OHYQNZTU.js} +37 -59
- package/dist/{polar-M7ZYP6UR.js → polar-XZIAHXS5.js} +43 -53
- package/dist/{posthog-YV7CZOH4.js → posthog-DTPTWORY.js} +58 -77
- package/dist/{postmark-KYHLECRG.js → postmark-F4UCQKC3.js} +52 -71
- package/dist/{prerender-HCMHBKV2.js → prerender-P3Y2MLIC.js} +32 -50
- package/dist/{pubmed-WYVLCCN3.js → pubmed-RHU3GXFB.js} +28 -60
- package/dist/{railway-TWIRD5KR.js → railway-VB6SRLI6.js} +32 -39
- package/dist/{readwise-UZ467IQ7.js → readwise-DIMSKJZR.js} +62 -78
- package/dist/{render-MECUC5CC.js → render-XCCDCEEK.js} +48 -64
- package/dist/{replicate-A5MEK3SW.js → replicate-IUEOQ4JC.js} +41 -58
- package/dist/{resend-BC6EAWJQ.js → resend-N5MJZH5E.js} +27 -37
- package/dist/{rootly-ZM3QDUIS.js → rootly-25T4NBTU.js} +64 -76
- package/dist/{scrapfly-WAML42QJ.js → scrapfly-PK4XFXUA.js} +45 -51
- package/dist/{scrapingbee-DG7PET3V.js → scrapingbee-ITPBMWQU.js} +25 -33
- package/dist/{screenshot_fyi-HY6WTHIO.js → screenshot_fyi-5U6ZYPKR.js} +29 -47
- package/dist/{semantic_scholar-C5IZA7IP.js → semantic_scholar-BJGCI2MU.js} +37 -56
- package/dist/{sentry-OKBPSTDM.js → sentry-63IC263P.js} +66 -85
- package/dist/{shodan-PPC6DYU4.js → shodan-2WBIFHFN.js} +42 -53
- package/dist/{shopify-EWGUHBXO.js → shopify-XLLJRAGM.js} +32 -49
- package/dist/{stripe-6RPDPC5W.js → stripe-WLVCY3UN.js} +4 -5
- package/dist/{supabase-SK7DQ42N.js → supabase-BKNZ35ER.js} +69 -88
- package/dist/{tavily-YCG5VQMH.js → tavily-YFSDEUTL.js} +37 -62
- package/dist/{telegram-2OES5FYB.js → telegram-FC35W74G.js} +168 -177
- package/dist/{telnyx-POOSBBR4.js → telnyx-MI32XZUG.js} +30 -50
- package/dist/{todoist-M7YD6YSS.js → todoist-4ZFJKZC6.js} +77 -89
- package/dist/{trello-IS6V5W3E.js → trello-UOGFNMK4.js} +108 -122
- package/dist/{turso-RCFHUFVH.js → turso-YTSTW3ZS.js} +52 -64
- package/dist/{twilio-OS2RXFGO.js → twilio-XAJDFUQH.js} +48 -55
- package/dist/{umami-PQ2SJ2LN.js → umami-ZVIUBPAI.js} +49 -69
- package/dist/{unsplash-C6BPZO4E.js → unsplash-IU3PLDNS.js} +35 -52
- package/dist/{upstash_redis-WH6UER7H.js → upstash_redis-3EYJW7SY.js} +28 -40
- package/dist/{uptimerobot-M3YZGS6Z.js → uptimerobot-PJG2ASRU.js} +11 -12
- package/dist/{v2ex-R4JWTEHN.js → v2ex-KFQWWGFC.js} +36 -61
- package/dist/{vercel-FZVYUOQD.js → vercel-I2ZDOQRL.js} +124 -150
- package/dist/{webapi-VLM4IKVB.js → webapi-GW5QXWXE.js} +1 -1
- package/dist/{wolfram_alpha_api-2KOLO5DC.js → wolfram_alpha_api-BNXOJMB6.js} +26 -34
- package/dist/{wordpress-XRWGO6LG.js → wordpress-36D7BSMP.js} +87 -104
- package/dist/{workos-WR4NKOYL.js → workos-6X4JJRRC.js} +37 -56
- package/dist/{zhihu-BKZIB3WA.js → zhihu-CIXKCHIU.js} +35 -57
- package/package.json +5 -5
- package/dist/chunk-2O27H4Y2.js +0 -183
- package/dist/chunk-GKX72JMJ.js +0 -378
- package/dist/chunk-MLKGABMK.js +0 -9
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asJsonObject,
|
|
3
|
+
booleanValue,
|
|
4
|
+
compactDefined
|
|
5
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
6
|
import {
|
|
2
7
|
createProviderPlugin,
|
|
3
8
|
requireApiKey,
|
|
4
9
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YASUMV2K.js";
|
|
6
11
|
import {
|
|
7
12
|
guardedFetch
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
13
|
+
} from "./chunk-U5UHT7CX.js";
|
|
10
14
|
import {
|
|
11
15
|
TBError,
|
|
12
16
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-RVWZN3CI.js";
|
|
18
|
+
import "./chunk-U67V476Y.js";
|
|
15
19
|
|
|
16
20
|
// ../plugins/src/linear/api.ts
|
|
17
21
|
var SERVICE = "linear";
|
|
@@ -240,27 +244,14 @@ var detailedIssueFields = `
|
|
|
240
244
|
${reactionFields}
|
|
241
245
|
}
|
|
242
246
|
`;
|
|
243
|
-
function asRecord(value) {
|
|
244
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
245
|
-
}
|
|
246
247
|
function str(value) {
|
|
247
248
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
248
249
|
}
|
|
249
250
|
function num(value) {
|
|
250
251
|
return typeof value === "number" ? value : void 0;
|
|
251
252
|
}
|
|
252
|
-
function bool(value) {
|
|
253
|
-
return typeof value === "boolean" ? value : void 0;
|
|
254
|
-
}
|
|
255
|
-
function compact(input) {
|
|
256
|
-
const output = {};
|
|
257
|
-
for (const [key, value] of Object.entries(input)) {
|
|
258
|
-
if (value !== void 0) output[key] = value;
|
|
259
|
-
}
|
|
260
|
-
return output;
|
|
261
|
-
}
|
|
262
253
|
function nodesOf(connection) {
|
|
263
|
-
const nodes =
|
|
254
|
+
const nodes = asJsonObject(connection)?.nodes;
|
|
264
255
|
return Array.isArray(nodes) ? nodes : [];
|
|
265
256
|
}
|
|
266
257
|
function basenameFromUrl(url) {
|
|
@@ -279,7 +270,7 @@ async function readJson(response) {
|
|
|
279
270
|
const text = await response.text().catch(() => "");
|
|
280
271
|
if (text === "") return {};
|
|
281
272
|
try {
|
|
282
|
-
return
|
|
273
|
+
return asJsonObject(JSON.parse(text)) ?? { message: text };
|
|
283
274
|
} catch {
|
|
284
275
|
return { message: text };
|
|
285
276
|
}
|
|
@@ -288,7 +279,7 @@ function extractErrorMessage(body) {
|
|
|
288
279
|
const direct = str(body.message);
|
|
289
280
|
if (direct !== void 0) return direct;
|
|
290
281
|
if (Array.isArray(body.errors) && body.errors.length > 0) {
|
|
291
|
-
const joined = body.errors.map((error) => str(
|
|
282
|
+
const joined = body.errors.map((error) => str(asJsonObject(error)?.message)).filter((message) => message !== void 0).join("; ");
|
|
292
283
|
if (joined !== "") return joined;
|
|
293
284
|
}
|
|
294
285
|
return "linear \u8BF7\u6C42\u5931\u8D25";
|
|
@@ -319,7 +310,7 @@ async function graphqlRequest(ctx, query, variables) {
|
|
|
319
310
|
"authorization": authorization,
|
|
320
311
|
"content-type": "application/json"
|
|
321
312
|
},
|
|
322
|
-
body: JSON.stringify(
|
|
313
|
+
body: JSON.stringify(compactDefined({ query, variables }))
|
|
323
314
|
});
|
|
324
315
|
body = await readJson(response);
|
|
325
316
|
} catch (error) {
|
|
@@ -327,12 +318,12 @@ async function graphqlRequest(ctx, query, variables) {
|
|
|
327
318
|
throw upstreamError(502, error instanceof Error ? `linear \u8BF7\u6C42\u5931\u8D25: ${error.message}` : "linear \u8BF7\u6C42\u5931\u8D25");
|
|
328
319
|
}
|
|
329
320
|
if (!response.ok) throw upstreamError(response.status, extractErrorMessage(body));
|
|
330
|
-
const errors = Array.isArray(body.errors) ? body.errors.map((error) =>
|
|
321
|
+
const errors = Array.isArray(body.errors) ? body.errors.map((error) => asJsonObject(error) ?? { message: String(error) }) : void 0;
|
|
331
322
|
return {
|
|
332
323
|
// `data: null` 与"没有 data 字段"要分开:前者是 GraphQL 明确说"这次没有数据"。
|
|
333
|
-
data: body.data === null ? null :
|
|
324
|
+
data: body.data === null ? null : asJsonObject(body.data),
|
|
334
325
|
errors,
|
|
335
|
-
extensions:
|
|
326
|
+
extensions: asJsonObject(body.extensions)
|
|
336
327
|
};
|
|
337
328
|
}
|
|
338
329
|
async function operation(ctx, query, variables) {
|
|
@@ -348,7 +339,7 @@ async function operation(ctx, query, variables) {
|
|
|
348
339
|
async function rawDocument(ctx, document, variables) {
|
|
349
340
|
const response = await graphqlRequest(ctx, document, variables);
|
|
350
341
|
const hasErrors = response.errors !== void 0 && response.errors.length > 0;
|
|
351
|
-
return
|
|
342
|
+
return compactDefined({
|
|
352
343
|
data: response.data === null ? null : response.data,
|
|
353
344
|
errors: response.errors,
|
|
354
345
|
extensions: response.extensions,
|
|
@@ -363,17 +354,17 @@ async function fetchAllNodes(ctx, query, extract) {
|
|
|
363
354
|
throw upstreamError(502, `linear \u7FFB\u9875\u8D85\u8FC7 ${MAX_PAGES} \u9875,\u4E0A\u6E38\u6E38\u6807\u53EF\u80FD\u6CA1\u6709\u63A8\u8FDB`);
|
|
364
355
|
}
|
|
365
356
|
const data = await operation(ctx, query, { after });
|
|
366
|
-
const connection =
|
|
357
|
+
const connection = asJsonObject(extract(data));
|
|
367
358
|
if (connection === void 0) return nodes;
|
|
368
359
|
nodes.push(...nodesOf(connection));
|
|
369
|
-
const pageInfo =
|
|
360
|
+
const pageInfo = asJsonObject(connection.pageInfo);
|
|
370
361
|
const endCursor = str(pageInfo?.endCursor);
|
|
371
362
|
if (pageInfo?.hasNextPage !== true || endCursor === void 0) return nodes;
|
|
372
363
|
after = endCursor;
|
|
373
364
|
}
|
|
374
365
|
}
|
|
375
366
|
function requireEntity(value, message) {
|
|
376
|
-
const record =
|
|
367
|
+
const record = asJsonObject(value);
|
|
377
368
|
if (record === void 0) throw new TBError("invalid_argument", message);
|
|
378
369
|
return record;
|
|
379
370
|
}
|
|
@@ -523,7 +514,7 @@ async function fetchViewer(ctx) {
|
|
|
523
514
|
}
|
|
524
515
|
}
|
|
525
516
|
`, {});
|
|
526
|
-
const viewer =
|
|
517
|
+
const viewer = asJsonObject(payload.viewer);
|
|
527
518
|
if (viewer === void 0) throw upstreamError(502, "linear viewer \u67E5\u8BE2\u56DE\u4E86\u7A7A\u54CD\u5E94");
|
|
528
519
|
return viewer;
|
|
529
520
|
}
|
|
@@ -609,7 +600,7 @@ async function resolveAssigneeFilterId(ctx, assigneeId) {
|
|
|
609
600
|
return String((await fetchViewer(ctx)).id);
|
|
610
601
|
}
|
|
611
602
|
function buildIssuesFilter(projectId, assigneeId) {
|
|
612
|
-
const filter =
|
|
603
|
+
const filter = compactDefined({
|
|
613
604
|
project: projectId === void 0 ? void 0 : { id: { eq: projectId } },
|
|
614
605
|
assignee: assigneeId === void 0 ? void 0 : { id: { eq: assigneeId } }
|
|
615
606
|
});
|
|
@@ -626,30 +617,30 @@ async function resolveProjectStatusId(ctx, statusType) {
|
|
|
626
617
|
}
|
|
627
618
|
}
|
|
628
619
|
`, {});
|
|
629
|
-
const statuses =
|
|
620
|
+
const statuses = asJsonObject(payload.organization)?.projectStatuses;
|
|
630
621
|
const list = Array.isArray(statuses) ? statuses : [];
|
|
631
|
-
const matched = list.map((item) =>
|
|
622
|
+
const matched = list.map((item) => asJsonObject(item)).find((item) => item?.type === statusType);
|
|
632
623
|
const id = str(matched?.id);
|
|
633
624
|
if (id === void 0) throw new TBError("invalid_argument", `linear \u6CA1\u6709 state \u4E3A ${statusType} \u7684 project status`);
|
|
634
625
|
return id;
|
|
635
626
|
}
|
|
636
627
|
function mutationEntityId(payload, entityKey, message) {
|
|
637
|
-
const record =
|
|
638
|
-
const id = str(
|
|
628
|
+
const record = asJsonObject(payload);
|
|
629
|
+
const id = str(asJsonObject(record?.[entityKey])?.id);
|
|
639
630
|
if (record?.success !== true || id === void 0) throw upstreamError(502, message);
|
|
640
631
|
return id;
|
|
641
632
|
}
|
|
642
633
|
function archiveEntityId(payload, message) {
|
|
643
|
-
const record =
|
|
644
|
-
const id = str(
|
|
634
|
+
const record = asJsonObject(payload);
|
|
635
|
+
const id = str(asJsonObject(record?.entity)?.id);
|
|
645
636
|
if (record?.success !== true || id === void 0) throw upstreamError(502, message);
|
|
646
637
|
return id;
|
|
647
638
|
}
|
|
648
639
|
function requireSuccess(payload, message) {
|
|
649
|
-
if (
|
|
640
|
+
if (asJsonObject(payload)?.success !== true) throw upstreamError(502, message);
|
|
650
641
|
}
|
|
651
642
|
function mapPageInfo(pageInfo) {
|
|
652
|
-
const info =
|
|
643
|
+
const info = asJsonObject(pageInfo);
|
|
653
644
|
return {
|
|
654
645
|
startCursor: info?.startCursor ?? null,
|
|
655
646
|
endCursor: info?.endCursor ?? null,
|
|
@@ -658,35 +649,35 @@ function mapPageInfo(pageInfo) {
|
|
|
658
649
|
};
|
|
659
650
|
}
|
|
660
651
|
function mapSnakePageInfo(pageInfo) {
|
|
661
|
-
const info =
|
|
652
|
+
const info = asJsonObject(pageInfo);
|
|
662
653
|
return {
|
|
663
654
|
end_cursor: info?.endCursor ?? null,
|
|
664
655
|
has_next_page: Boolean(info?.hasNextPage)
|
|
665
656
|
};
|
|
666
657
|
}
|
|
667
658
|
function mapUser(user) {
|
|
668
|
-
const record =
|
|
659
|
+
const record = asJsonObject(user);
|
|
669
660
|
if (record === void 0) return null;
|
|
670
|
-
return
|
|
661
|
+
return compactDefined({
|
|
671
662
|
id: str(record.id),
|
|
672
663
|
name: str(record.name),
|
|
673
664
|
displayName: str(record.displayName),
|
|
674
665
|
email: str(record.email),
|
|
675
666
|
avatarUrl: str(record.avatarUrl),
|
|
676
|
-
active:
|
|
677
|
-
admin:
|
|
667
|
+
active: booleanValue(record.active),
|
|
668
|
+
admin: booleanValue(record.admin),
|
|
678
669
|
createdAt: str(record.createdAt)
|
|
679
670
|
});
|
|
680
671
|
}
|
|
681
672
|
function mapTeam(team) {
|
|
682
|
-
const record =
|
|
673
|
+
const record = asJsonObject(team);
|
|
683
674
|
if (record === void 0) return null;
|
|
684
|
-
return
|
|
675
|
+
return compactDefined({ id: str(record.id), name: str(record.name), key: str(record.key) });
|
|
685
676
|
}
|
|
686
677
|
function mapWorkflowState(state) {
|
|
687
|
-
const record =
|
|
678
|
+
const record = asJsonObject(state);
|
|
688
679
|
if (record === void 0) return null;
|
|
689
|
-
return
|
|
680
|
+
return compactDefined({
|
|
690
681
|
id: str(record.id),
|
|
691
682
|
name: str(record.name),
|
|
692
683
|
type: str(record.type),
|
|
@@ -695,22 +686,22 @@ function mapWorkflowState(state) {
|
|
|
695
686
|
});
|
|
696
687
|
}
|
|
697
688
|
function mapLabel(label) {
|
|
698
|
-
const record =
|
|
689
|
+
const record = asJsonObject(label);
|
|
699
690
|
if (record === void 0) return null;
|
|
700
|
-
const parent =
|
|
701
|
-
return
|
|
691
|
+
const parent = asJsonObject(record.parent);
|
|
692
|
+
return compactDefined({
|
|
702
693
|
id: str(record.id),
|
|
703
694
|
name: str(record.name),
|
|
704
695
|
color: str(record.color),
|
|
705
696
|
description: str(record.description),
|
|
706
|
-
is_group:
|
|
707
|
-
parent: parent === void 0 ? null :
|
|
697
|
+
is_group: booleanValue(record.isGroup),
|
|
698
|
+
parent: parent === void 0 ? null : compactDefined({ id: str(parent.id), name: str(parent.name) })
|
|
708
699
|
});
|
|
709
700
|
}
|
|
710
701
|
function mapCycle(cycle) {
|
|
711
|
-
const record =
|
|
702
|
+
const record = asJsonObject(cycle);
|
|
712
703
|
if (record === void 0) return null;
|
|
713
|
-
return
|
|
704
|
+
return compactDefined({
|
|
714
705
|
id: str(record.id),
|
|
715
706
|
name: str(record.name),
|
|
716
707
|
number: num(record.number),
|
|
@@ -718,16 +709,16 @@ function mapCycle(cycle) {
|
|
|
718
709
|
startsAt: str(record.startsAt),
|
|
719
710
|
endsAt: str(record.endsAt),
|
|
720
711
|
completedAt: str(record.completedAt),
|
|
721
|
-
isActive:
|
|
722
|
-
isFuture:
|
|
723
|
-
isPast:
|
|
712
|
+
isActive: booleanValue(record.isActive),
|
|
713
|
+
isFuture: booleanValue(record.isFuture),
|
|
714
|
+
isPast: booleanValue(record.isPast),
|
|
724
715
|
team: mapTeam(record.team)
|
|
725
716
|
});
|
|
726
717
|
}
|
|
727
718
|
function mapProjectStatus(status) {
|
|
728
|
-
const record =
|
|
719
|
+
const record = asJsonObject(status);
|
|
729
720
|
if (record === void 0) return null;
|
|
730
|
-
return
|
|
721
|
+
return compactDefined({
|
|
731
722
|
id: str(record.id),
|
|
732
723
|
name: str(record.name),
|
|
733
724
|
type: str(record.type),
|
|
@@ -736,9 +727,9 @@ function mapProjectStatus(status) {
|
|
|
736
727
|
});
|
|
737
728
|
}
|
|
738
729
|
function mapProject(project, options = {}) {
|
|
739
|
-
const record =
|
|
730
|
+
const record = asJsonObject(project);
|
|
740
731
|
if (record === void 0) return null;
|
|
741
|
-
return
|
|
732
|
+
return compactDefined({
|
|
742
733
|
id: str(record.id),
|
|
743
734
|
name: str(record.name),
|
|
744
735
|
description: str(record.description),
|
|
@@ -764,8 +755,8 @@ function mapProject(project, options = {}) {
|
|
|
764
755
|
members: options.includeMembers === true && record.members !== void 0 ? { nodes: nodesOf(record.members).map(mapUser) } : void 0,
|
|
765
756
|
initiatives: options.includeInitiatives === true && record.initiatives !== void 0 ? {
|
|
766
757
|
nodes: nodesOf(record.initiatives).map((initiative) => {
|
|
767
|
-
const item =
|
|
768
|
-
return
|
|
758
|
+
const item = asJsonObject(initiative) ?? {};
|
|
759
|
+
return compactDefined({
|
|
769
760
|
id: str(item.id),
|
|
770
761
|
name: str(item.name),
|
|
771
762
|
description: str(item.description),
|
|
@@ -776,43 +767,43 @@ function mapProject(project, options = {}) {
|
|
|
776
767
|
});
|
|
777
768
|
}
|
|
778
769
|
function mapAttachment(attachment) {
|
|
779
|
-
const record =
|
|
770
|
+
const record = asJsonObject(attachment);
|
|
780
771
|
if (record === void 0) return null;
|
|
781
|
-
const issue =
|
|
782
|
-
return
|
|
772
|
+
const issue = asJsonObject(record.issue);
|
|
773
|
+
return compactDefined({
|
|
783
774
|
id: str(record.id),
|
|
784
775
|
title: str(record.title),
|
|
785
776
|
subtitle: str(record.subtitle),
|
|
786
777
|
url: str(record.url),
|
|
787
778
|
sourceType: str(record.sourceType),
|
|
788
|
-
metadata:
|
|
789
|
-
source:
|
|
790
|
-
issue: issue === void 0 ? null :
|
|
779
|
+
metadata: asJsonObject(record.metadata),
|
|
780
|
+
source: asJsonObject(record.source),
|
|
781
|
+
issue: issue === void 0 ? null : compactDefined({ id: str(issue.id), identifier: str(issue.identifier), title: str(issue.title) }),
|
|
791
782
|
createdAt: str(record.createdAt),
|
|
792
783
|
updatedAt: str(record.updatedAt)
|
|
793
784
|
});
|
|
794
785
|
}
|
|
795
786
|
function mapReaction(reaction) {
|
|
796
|
-
const record =
|
|
787
|
+
const record = asJsonObject(reaction);
|
|
797
788
|
if (record === void 0) return null;
|
|
798
|
-
const comment =
|
|
799
|
-
const issue =
|
|
800
|
-
const projectUpdate =
|
|
801
|
-
return
|
|
789
|
+
const comment = asJsonObject(record.comment);
|
|
790
|
+
const issue = asJsonObject(record.issue);
|
|
791
|
+
const projectUpdate = asJsonObject(record.projectUpdate);
|
|
792
|
+
return compactDefined({
|
|
802
793
|
id: str(record.id),
|
|
803
794
|
emoji: str(record.emoji),
|
|
804
795
|
createdAt: str(record.createdAt),
|
|
805
796
|
updatedAt: str(record.updatedAt),
|
|
806
797
|
user: mapUser(record.user),
|
|
807
798
|
comment: comment === void 0 ? null : { id: str(comment.id) },
|
|
808
|
-
issue: issue === void 0 ? null :
|
|
799
|
+
issue: issue === void 0 ? null : compactDefined({ id: str(issue.id), identifier: str(issue.identifier) }),
|
|
809
800
|
projectUpdate: projectUpdate === void 0 ? null : { id: str(projectUpdate.id) }
|
|
810
801
|
});
|
|
811
802
|
}
|
|
812
803
|
function mapComment(comment) {
|
|
813
|
-
const record =
|
|
804
|
+
const record = asJsonObject(comment);
|
|
814
805
|
if (record === void 0) return null;
|
|
815
|
-
return
|
|
806
|
+
return compactDefined({
|
|
816
807
|
id: str(record.id),
|
|
817
808
|
body: str(record.body),
|
|
818
809
|
url: str(record.url),
|
|
@@ -830,9 +821,9 @@ function mapComment(comment) {
|
|
|
830
821
|
});
|
|
831
822
|
}
|
|
832
823
|
function mapIssueSummary(issue) {
|
|
833
|
-
const record =
|
|
824
|
+
const record = asJsonObject(issue);
|
|
834
825
|
if (record === void 0) return null;
|
|
835
|
-
return
|
|
826
|
+
return compactDefined({
|
|
836
827
|
id: str(record.id),
|
|
837
828
|
identifier: str(record.identifier),
|
|
838
829
|
title: str(record.title),
|
|
@@ -854,41 +845,41 @@ function mapIssueSummary(issue) {
|
|
|
854
845
|
function mapDetailedIssue(issue) {
|
|
855
846
|
const base = mapIssueSummary(issue);
|
|
856
847
|
if (base === null) return null;
|
|
857
|
-
const record =
|
|
858
|
-
const parent =
|
|
859
|
-
return
|
|
848
|
+
const record = asJsonObject(issue) ?? {};
|
|
849
|
+
const parent = asJsonObject(record.parent);
|
|
850
|
+
return compactDefined({
|
|
860
851
|
...base,
|
|
861
852
|
creator: mapUser(record.creator),
|
|
862
853
|
cycle: mapCycle(record.cycle),
|
|
863
|
-
parent: parent === void 0 ? null :
|
|
854
|
+
parent: parent === void 0 ? null : compactDefined({ id: str(parent.id), identifier: str(parent.identifier), title: str(parent.title) }),
|
|
864
855
|
attachments: {
|
|
865
856
|
nodes: nodesOf(record.attachments).map(mapAttachment),
|
|
866
|
-
pageInfo: mapPageInfo(
|
|
857
|
+
pageInfo: mapPageInfo(asJsonObject(record.attachments)?.pageInfo)
|
|
867
858
|
},
|
|
868
859
|
comments: {
|
|
869
860
|
nodes: nodesOf(record.comments).map(mapComment),
|
|
870
|
-
pageInfo: mapPageInfo(
|
|
861
|
+
pageInfo: mapPageInfo(asJsonObject(record.comments)?.pageInfo)
|
|
871
862
|
},
|
|
872
863
|
subscribers: {
|
|
873
864
|
nodes: nodesOf(record.subscribers).map(mapUser),
|
|
874
|
-
pageInfo: mapPageInfo(
|
|
865
|
+
pageInfo: mapPageInfo(asJsonObject(record.subscribers)?.pageInfo)
|
|
875
866
|
},
|
|
876
867
|
reactions: Array.isArray(record.reactions) ? record.reactions.map(mapReaction) : []
|
|
877
868
|
});
|
|
878
869
|
}
|
|
879
870
|
function mapDraft(draft) {
|
|
880
|
-
const record =
|
|
871
|
+
const record = asJsonObject(draft);
|
|
881
872
|
if (record === void 0) return null;
|
|
882
|
-
const issue =
|
|
883
|
-
const project =
|
|
884
|
-
const projectUpdate =
|
|
885
|
-
return
|
|
873
|
+
const issue = asJsonObject(record.issue);
|
|
874
|
+
const project = asJsonObject(record.project);
|
|
875
|
+
const projectUpdate = asJsonObject(record.projectUpdate);
|
|
876
|
+
return compactDefined({
|
|
886
877
|
id: str(record.id),
|
|
887
|
-
data:
|
|
878
|
+
data: asJsonObject(record.data),
|
|
888
879
|
bodyData: str(record.bodyData),
|
|
889
880
|
createdAt: str(record.createdAt),
|
|
890
881
|
updatedAt: str(record.updatedAt),
|
|
891
|
-
isAutogenerated:
|
|
882
|
+
isAutogenerated: booleanValue(record.isAutogenerated),
|
|
892
883
|
team: mapTeam(record.team),
|
|
893
884
|
issue: issue === void 0 ? null : { id: str(issue.id) },
|
|
894
885
|
project: project === void 0 ? null : { id: str(project.id) },
|
|
@@ -907,7 +898,7 @@ async function createAttachment(input, ctx) {
|
|
|
907
898
|
}
|
|
908
899
|
}
|
|
909
900
|
`, {
|
|
910
|
-
input:
|
|
901
|
+
input: compactDefined({
|
|
911
902
|
issueId: input.issue_id,
|
|
912
903
|
title: input.title,
|
|
913
904
|
url: input.url,
|
|
@@ -918,7 +909,7 @@ async function createAttachment(input, ctx) {
|
|
|
918
909
|
const attachment = await fetchAttachmentById(ctx, attachmentId);
|
|
919
910
|
return {
|
|
920
911
|
id: attachment.id,
|
|
921
|
-
issue_id:
|
|
912
|
+
issue_id: asJsonObject(attachment.issue)?.id ?? input.issue_id,
|
|
922
913
|
title: attachment.title,
|
|
923
914
|
url: attachment.url,
|
|
924
915
|
subtitle: attachment.subtitle ?? null
|
|
@@ -971,7 +962,7 @@ async function createLinearIssue(input, ctx) {
|
|
|
971
962
|
}
|
|
972
963
|
}
|
|
973
964
|
`, {
|
|
974
|
-
input:
|
|
965
|
+
input: compactDefined({
|
|
975
966
|
title: input.title,
|
|
976
967
|
teamId: input.team_id,
|
|
977
968
|
cycleId: str(input.cycle_id),
|
|
@@ -1021,8 +1012,8 @@ async function createLinearIssueRelation(input, ctx) {
|
|
|
1021
1012
|
const relation = await fetchIssueRelationById(ctx, relationId);
|
|
1022
1013
|
return {
|
|
1023
1014
|
id: relation.id,
|
|
1024
|
-
issue_id:
|
|
1025
|
-
related_issue_id:
|
|
1015
|
+
issue_id: asJsonObject(relation.issue)?.id ?? input.issue_id,
|
|
1016
|
+
related_issue_id: asJsonObject(relation.relatedIssue)?.id ?? input.related_issue_id,
|
|
1026
1017
|
relation_type: relation.type ?? input.relation_type
|
|
1027
1018
|
};
|
|
1028
1019
|
}
|
|
@@ -1037,7 +1028,7 @@ async function createLinearLabel(input, ctx) {
|
|
|
1037
1028
|
}
|
|
1038
1029
|
}
|
|
1039
1030
|
`, {
|
|
1040
|
-
input:
|
|
1031
|
+
input: compactDefined({
|
|
1041
1032
|
teamId: input.team_id,
|
|
1042
1033
|
name: input.name,
|
|
1043
1034
|
color: input.color,
|
|
@@ -1048,7 +1039,7 @@ async function createLinearLabel(input, ctx) {
|
|
|
1048
1039
|
const label = await fetchIssueLabelById(ctx, labelId);
|
|
1049
1040
|
return {
|
|
1050
1041
|
id: label.id,
|
|
1051
|
-
team_id:
|
|
1042
|
+
team_id: asJsonObject(label.team)?.id ?? input.team_id,
|
|
1052
1043
|
name: label.name,
|
|
1053
1044
|
color: label.color ?? input.color,
|
|
1054
1045
|
description: label.description ?? null
|
|
@@ -1067,7 +1058,7 @@ async function createLinearProject(input, ctx) {
|
|
|
1067
1058
|
`, {
|
|
1068
1059
|
// 入参声明里还有 `status_id` 与 `state`,上游**不往 create 里发**(只有 update 认它们)。
|
|
1069
1060
|
// 保留这个取舍:替上游发一个没验证过的字段,失败方式会比"这个字段没生效"更难查。
|
|
1070
|
-
input:
|
|
1061
|
+
input: compactDefined({
|
|
1071
1062
|
icon: str(input.icon),
|
|
1072
1063
|
name: input.name,
|
|
1073
1064
|
color: str(input.color),
|
|
@@ -1094,7 +1085,7 @@ async function createProjectMilestone(input, ctx) {
|
|
|
1094
1085
|
}
|
|
1095
1086
|
}
|
|
1096
1087
|
`, {
|
|
1097
|
-
input:
|
|
1088
|
+
input: compactDefined({
|
|
1098
1089
|
name: input.name,
|
|
1099
1090
|
projectId: input.project_id,
|
|
1100
1091
|
sortOrder: input.sort_order,
|
|
@@ -1110,7 +1101,7 @@ async function createProjectMilestone(input, ctx) {
|
|
|
1110
1101
|
const milestone = await fetchProjectMilestoneById(ctx, milestoneId);
|
|
1111
1102
|
return {
|
|
1112
1103
|
id: milestone.id,
|
|
1113
|
-
project_id:
|
|
1104
|
+
project_id: asJsonObject(milestone.project)?.id ?? input.project_id,
|
|
1114
1105
|
name: milestone.name,
|
|
1115
1106
|
target_date: milestone.targetDate ?? null
|
|
1116
1107
|
};
|
|
@@ -1126,7 +1117,7 @@ async function createProjectUpdate(input, ctx) {
|
|
|
1126
1117
|
}
|
|
1127
1118
|
}
|
|
1128
1119
|
`, {
|
|
1129
|
-
input:
|
|
1120
|
+
input: compactDefined({
|
|
1130
1121
|
body: input.body,
|
|
1131
1122
|
health: str(input.health),
|
|
1132
1123
|
projectId: input.project_id,
|
|
@@ -1141,7 +1132,7 @@ async function createProjectUpdate(input, ctx) {
|
|
|
1141
1132
|
const projectUpdate = await fetchProjectUpdateById(ctx, projectUpdateId);
|
|
1142
1133
|
return {
|
|
1143
1134
|
id: projectUpdate.id,
|
|
1144
|
-
project_id:
|
|
1135
|
+
project_id: asJsonObject(projectUpdate.project)?.id ?? input.project_id,
|
|
1145
1136
|
body: projectUpdate.body ?? null,
|
|
1146
1137
|
health: projectUpdate.health ?? null,
|
|
1147
1138
|
is_diff_hidden: Boolean(projectUpdate.isDiffHidden)
|
|
@@ -1184,7 +1175,7 @@ async function getAttachment(input, ctx) {
|
|
|
1184
1175
|
}
|
|
1185
1176
|
const attachments = await fetchIssueAttachments(ctx, input.issue_id);
|
|
1186
1177
|
const matched = attachments.find((item) => {
|
|
1187
|
-
const attachment =
|
|
1178
|
+
const attachment = asJsonObject(item);
|
|
1188
1179
|
if (attachmentId !== void 0 && attachment?.id === attachmentId) return true;
|
|
1189
1180
|
if (fileName !== void 0 && attachment?.title === fileName) return true;
|
|
1190
1181
|
return fileName !== void 0 && basenameFromUrl(String(attachment?.url ?? "")) === fileName;
|
|
@@ -1214,7 +1205,7 @@ async function getIssueDefaults(input, ctx) {
|
|
|
1214
1205
|
}
|
|
1215
1206
|
`, { id: input.team_id });
|
|
1216
1207
|
const team = requireEntity(data.team, "linear team \u4E0D\u5B58\u5728");
|
|
1217
|
-
const defaultState =
|
|
1208
|
+
const defaultState = asJsonObject(team.defaultIssueState);
|
|
1218
1209
|
return {
|
|
1219
1210
|
team: {
|
|
1220
1211
|
defaultIssueState: defaultState === void 0 ? null : { id: String(defaultState.id), name: String(defaultState.name) },
|
|
@@ -1254,7 +1245,7 @@ async function listIssuesByTeamId(input, ctx) {
|
|
|
1254
1245
|
includeArchived: input.include_archived
|
|
1255
1246
|
});
|
|
1256
1247
|
const team = requireEntity(payload.team, "linear team \u4E0D\u5B58\u5728");
|
|
1257
|
-
const issues =
|
|
1248
|
+
const issues = asJsonObject(team.issues);
|
|
1258
1249
|
return {
|
|
1259
1250
|
team: mapTeam(team),
|
|
1260
1251
|
issues: nodesOf(issues).map(mapIssueSummary),
|
|
@@ -1297,7 +1288,7 @@ async function listIssueDrafts(input, ctx) {
|
|
|
1297
1288
|
}
|
|
1298
1289
|
}
|
|
1299
1290
|
`, { after: str(input.after), first: input.first });
|
|
1300
|
-
const drafts =
|
|
1291
|
+
const drafts = asJsonObject(asJsonObject(payload.viewer)?.drafts);
|
|
1301
1292
|
return { drafts: nodesOf(drafts).map(mapDraft), page_info: mapPageInfo(drafts?.pageInfo) };
|
|
1302
1293
|
}
|
|
1303
1294
|
async function listLinearCycles(_input, ctx) {
|
|
@@ -1333,7 +1324,7 @@ async function listLinearIssues(input, ctx) {
|
|
|
1333
1324
|
first: input.first,
|
|
1334
1325
|
filter: buildIssuesFilter(str(input.project_id), assigneeId)
|
|
1335
1326
|
});
|
|
1336
|
-
const issues =
|
|
1327
|
+
const issues = asJsonObject(payload.issues);
|
|
1337
1328
|
return { issues: nodesOf(issues).map(mapIssueSummary), page_info: mapPageInfo(issues?.pageInfo) };
|
|
1338
1329
|
}
|
|
1339
1330
|
async function listLinearLabels(input, ctx) {
|
|
@@ -1378,12 +1369,12 @@ async function listLinearTeams(input, ctx) {
|
|
|
1378
1369
|
const teams = await fetchAllNodes(ctx, LIST_TEAMS_QUERY, (data) => data.teams);
|
|
1379
1370
|
const projectId = str(input.project_id);
|
|
1380
1371
|
const detailedTeams = await mapWithConcurrency(teams, 5, async (team) => {
|
|
1381
|
-
const teamId = str(
|
|
1382
|
-
const detailed = teamId === void 0 ?
|
|
1372
|
+
const teamId = str(asJsonObject(team)?.id);
|
|
1373
|
+
const detailed = teamId === void 0 ? asJsonObject(team) ?? {} : await fetchTeamDetails(ctx, teamId);
|
|
1383
1374
|
return {
|
|
1384
1375
|
...mapTeam(detailed),
|
|
1385
1376
|
members: nodesOf(detailed.members).map(mapUser),
|
|
1386
|
-
projects: nodesOf(detailed.projects).filter((project) => projectId === void 0 || String(
|
|
1377
|
+
projects: nodesOf(detailed.projects).filter((project) => projectId === void 0 || String(asJsonObject(project)?.id) === projectId).map((project) => mapProject(project))
|
|
1387
1378
|
};
|
|
1388
1379
|
});
|
|
1389
1380
|
return { teams: detailedTeams };
|
|
@@ -1406,7 +1397,7 @@ async function listLinearUsers(input, ctx) {
|
|
|
1406
1397
|
}
|
|
1407
1398
|
}
|
|
1408
1399
|
`, { after: str(input.after), first: input.first });
|
|
1409
|
-
const users =
|
|
1400
|
+
const users = asJsonObject(payload.users);
|
|
1410
1401
|
return { users: nodesOf(users).map(mapUser), page_info: mapPageInfo(users?.pageInfo) };
|
|
1411
1402
|
}
|
|
1412
1403
|
async function removeIssueLabel(input, ctx) {
|
|
@@ -1466,7 +1457,7 @@ async function searchIssues(input, ctx) {
|
|
|
1466
1457
|
// 入参叫 query,GraphQL 变量叫 term —— 别顺手改名。
|
|
1467
1458
|
term: input.query
|
|
1468
1459
|
});
|
|
1469
|
-
const results =
|
|
1460
|
+
const results = asJsonObject(payload.searchIssues);
|
|
1470
1461
|
return {
|
|
1471
1462
|
issues: nodesOf(results).map(mapIssueSummary),
|
|
1472
1463
|
page_info: mapPageInfo(results?.pageInfo),
|
|
@@ -1485,7 +1476,7 @@ async function updateIssue(input, ctx) {
|
|
|
1485
1476
|
}
|
|
1486
1477
|
`, {
|
|
1487
1478
|
id: input.issueId,
|
|
1488
|
-
input:
|
|
1479
|
+
input: compactDefined({
|
|
1489
1480
|
title: str(input.title),
|
|
1490
1481
|
teamId: str(input.teamId),
|
|
1491
1482
|
cycleId: str(input.cycleId),
|
|
@@ -1531,7 +1522,7 @@ async function updateLinearProject(input, ctx) {
|
|
|
1531
1522
|
}
|
|
1532
1523
|
`, {
|
|
1533
1524
|
id: input.project_id,
|
|
1534
|
-
input:
|
|
1525
|
+
input: compactDefined({
|
|
1535
1526
|
icon: str(input.icon),
|
|
1536
1527
|
name: str(input.name),
|
|
1537
1528
|
color: str(input.color),
|