@lobu/runtime-device 21.2.1 → 23.0.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/component.json +1 -1
- package/dist/dependencies.bun.lock +91 -83
- package/npm-shrinkwrap.json +492 -438
- package/package.json +12 -2
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +1 -1
- package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +5 -6
- package/vendor/cli/dist/commands/_lib/apply/client.d.ts +1 -0
- package/vendor/cli/dist/commands/_lib/apply/client.js +26 -7
- package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +9 -1
- package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +1 -0
- package/vendor/cli/dist/commands/_lib/apply/diff.js +46 -4
- package/vendor/cli/dist/commands/_lib/apply/map-config.js +18 -38
- package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +5 -17
- package/vendor/cli/dist/commands/init.d.ts +0 -2
- package/vendor/cli/dist/commands/init.js +0 -27
- package/vendor/cli/dist/commands/login.d.ts +17 -0
- package/vendor/cli/dist/commands/login.js +43 -17
- package/vendor/cli/dist/commands/memory/_lib/errors.d.ts +0 -8
- package/vendor/cli/dist/commands/memory/_lib/errors.js +0 -12
- package/vendor/cli/dist/commands/memory/_lib/mcp.js +6 -6
- package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +4 -10
- package/vendor/cli/dist/config/define.d.ts +21 -15
- package/vendor/cli/dist/config/define.js +2 -2
- package/vendor/cli/dist/connectors/README.md +21 -6
- package/vendor/cli/dist/connectors/_google/actions.ts +270 -0
- package/vendor/cli/dist/connectors/_google/discovery/calendar_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/chat_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/docs_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/drive_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/gmail_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/people_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/sheets_v4.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/tasks_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/youtube_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery.ts +442 -0
- package/vendor/cli/dist/connectors/_google/errors.ts +91 -0
- package/vendor/cli/dist/connectors/_google/list-feed.ts +223 -0
- package/vendor/cli/dist/connectors/_google/policies.ts +127 -0
- package/vendor/cli/dist/connectors/agentid.ts +43 -0
- package/vendor/cli/dist/connectors/chat-user-identity.ts +2 -1
- package/vendor/cli/dist/connectors/github-automation-events.ts +9 -0
- package/vendor/cli/dist/connectors/github-identity.ts +28 -3
- package/vendor/cli/dist/connectors/github.ts +101 -59
- package/vendor/cli/dist/connectors/google_calendar.ts +207 -719
- package/vendor/cli/dist/connectors/google_drive.ts +16 -2
- package/vendor/cli/dist/connectors/google_gmail.ts +52 -33
- package/vendor/cli/dist/connectors/herdr.ts +406 -0
- package/vendor/cli/dist/connectors/jira-helpers.ts +313 -0
- package/vendor/cli/dist/connectors/jira.ts +35 -227
- package/vendor/cli/dist/connectors/linear.ts +7 -4
- package/vendor/cli/dist/connectors/linkedin-browser-script.ts +13 -0
- package/vendor/cli/dist/connectors/linkedin-draft-page.js +104 -0
- package/vendor/cli/dist/connectors/linkedin-drafts.ts +73 -0
- package/vendor/cli/dist/connectors/linkedin-identity.ts +32 -0
- package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +1185 -0
- package/vendor/cli/dist/connectors/linkedin-inbox.ts +156 -0
- package/vendor/cli/dist/connectors/linkedin-like.ts +114 -0
- package/vendor/cli/dist/connectors/linkedin-takeout.ts +577 -0
- package/vendor/cli/dist/connectors/linkedin.ts +3998 -0
- package/vendor/cli/dist/connectors/postgres.ts +27 -2
- package/vendor/cli/dist/connectors/takeout-utils.ts +240 -0
- package/vendor/cli/dist/connectors/tiktok-inbox-page.js +230 -0
- package/vendor/cli/dist/connectors/tiktok-web-page.js +217 -0
- package/vendor/cli/dist/connectors/tiktok_web.ts +319 -0
- package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +285 -567
- package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +74 -455
- package/vendor/cli/dist/connectors/whatsapp-web-identity.ts +135 -0
- package/vendor/cli/dist/connectors/whatsapp_web.ts +159 -618
- package/vendor/cli/dist/connectors/x-dm-adapter.js +556 -0
- package/vendor/cli/dist/connectors/x-identity.ts +31 -2
- package/vendor/cli/dist/connectors/x.ts +539 -253
- package/vendor/cli/dist/index.js +1 -37
- package/vendor/cli/dist/internal/context.d.ts +10 -0
- package/vendor/cli/dist/internal/context.js +26 -16
- package/vendor/cli/dist/internal/node-version.d.ts +1 -1
- package/vendor/cli/dist/internal/node-version.js +1 -1
- package/vendor/cli/dist/internal/oauth.d.ts +3 -1
- package/vendor/cli/dist/internal/oauth.js +4 -3
- package/vendor/cli/dist/internal/runtime-components.d.ts +9 -0
- package/vendor/cli/dist/internal/runtime-components.js +67 -2
- package/vendor/cli/dist/mac-auth.js +17 -1
- package/vendor/cli/dist/providers.json +1 -1
- package/vendor/cli/dist/runtime-components.json +4 -4
- package/vendor/cli/dist/templates/AGENTS.md.tmpl +12 -5
- package/vendor/cli/dist/templates/README.md.tmpl +1 -1
- package/vendor/cli/dist/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
- package/vendor/cli/dist/vendor/ora/index.d.ts +332 -0
- package/vendor/cli/dist/vendor/ora/index.js +424 -0
- package/vendor/cli/dist/vendor/ora/license +9 -0
- package/vendor/cli/dist/vendor/ora/package.json +64 -0
- package/vendor/cli/dist/vendor/ora/readme.md +329 -0
- package/vendor/cli/package.json +2 -2
- package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
- package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
- package/vendor/connector-sdk/dist/browser-requirement.d.ts +36 -0
- package/vendor/connector-sdk/dist/browser-requirement.js +60 -0
- package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
- package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
- package/vendor/connector-sdk/dist/connector-runtime.d.ts +3 -1
- package/vendor/connector-sdk/dist/connector-runtime.js +10 -0
- package/vendor/connector-sdk/dist/connector-types.d.ts +169 -45
- package/vendor/connector-sdk/dist/define-connector.d.ts +4 -2
- package/vendor/connector-sdk/dist/define-connector.js +3 -0
- package/vendor/connector-sdk/dist/index.d.ts +8 -2
- package/vendor/connector-sdk/dist/index.js +3 -0
- package/vendor/connector-sdk/dist/reaction-client-types.d.ts +16 -21
- package/vendor/connector-sdk/dist/reaction-client-types.typecheck.d.ts +5 -0
- package/vendor/connector-sdk/package.json +13 -1
- package/vendor/connector-worker/dist/agent-turn/guest-entry.js +43 -30
- package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +416 -330
- package/vendor/connector-worker/dist/agent-turn/memory.d.ts +3 -2
- package/vendor/connector-worker/dist/agent-turn/memory.js +3 -20
- package/vendor/connector-worker/dist/agent-turn/types.d.ts +3 -15
- package/vendor/connector-worker/dist/agent-turn/workspace.d.ts +2 -2
- package/vendor/connector-worker/dist/agent-turn/workspace.js +2 -4
- package/vendor/connector-worker/dist/daemon/action-monitor.d.ts +12 -0
- package/vendor/connector-worker/dist/daemon/action-monitor.js +25 -0
- package/vendor/connector-worker/dist/daemon/agent-turn.js +0 -9
- package/vendor/connector-worker/dist/daemon/automation.d.ts +4 -11
- package/vendor/connector-worker/dist/daemon/automation.js +6 -6
- package/vendor/connector-worker/dist/daemon/builtins/index.d.ts +12 -0
- package/vendor/connector-worker/dist/daemon/builtins/index.js +61 -1
- package/vendor/connector-worker/dist/daemon/builtins/os-shell.d.ts +2 -1
- package/vendor/connector-worker/dist/daemon/builtins/os-shell.js +40 -27
- package/vendor/connector-worker/dist/daemon/client.d.ts +6 -4
- package/vendor/connector-worker/dist/daemon/client.js +3 -3
- package/vendor/connector-worker/dist/daemon/device-concurrency.d.ts +8 -0
- package/vendor/connector-worker/dist/daemon/device-concurrency.js +13 -0
- package/vendor/connector-worker/dist/daemon/executor.d.ts +1 -1
- package/vendor/connector-worker/dist/daemon/executor.js +48 -120
- package/vendor/connector-worker/dist/daemon/log.d.ts +2 -0
- package/vendor/connector-worker/dist/daemon/log.js +23 -2
- package/vendor/connector-worker/dist/daemon/mac-device-daemon.d.ts +23 -6
- package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +57 -23
- package/vendor/connector-worker/dist/daemon/native-bridge/client.d.ts +6 -0
- package/vendor/connector-worker/dist/daemon/native-bridge/client.js +15 -0
- package/vendor/connector-worker/dist/daemon/native-bridge/executor.js +29 -25
- package/vendor/connector-worker/dist/daemon/native-bridge/protocol.d.ts +1 -1
- package/vendor/connector-worker/dist/daemon/native-bridge/protocol.js +1 -0
- package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +3 -0
- package/vendor/connector-worker/dist/daemon/poll-loop.js +5 -1
- package/vendor/connector-worker/dist/daemon/start.d.ts +1 -0
- package/vendor/connector-worker/dist/daemon/start.js +15 -20
- package/vendor/connector-worker/dist/daemon/terminal-failure.js +0 -11
- package/vendor/connector-worker/dist/daemon/worker-id.d.ts +17 -0
- package/vendor/connector-worker/dist/daemon/worker-id.js +22 -0
- package/vendor/connector-worker/dist/executor/interface.d.ts +34 -2
- package/vendor/connector-worker/dist/executor/isolate.js +66 -15
- package/vendor/connector-worker/dist/executor/redact.d.ts +1 -0
- package/vendor/connector-worker/dist/executor/redact.js +97 -26
- package/vendor/connector-worker/dist/executor/runtime.d.ts +7 -0
- package/vendor/connector-worker/dist/executor/runtime.js +26 -0
- package/vendor/connector-worker/dist/isolate/bridge.js +3 -1
- package/vendor/connector-worker/dist/mac-device-daemon.js +24 -29
- package/vendor/connector-worker/package.json +2 -2
- package/vendor/core/dist/agent-policy.js +1 -1
- package/vendor/core/dist/agent-store.d.ts +2 -0
- package/vendor/core/dist/agent-tooling.d.ts +1 -1
- package/vendor/core/dist/agent-tooling.js +1 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +2 -1
- package/vendor/core/dist/connector-query-errors.d.ts +32 -0
- package/vendor/core/dist/connector-query-errors.js +41 -1
- package/vendor/core/dist/contracts/agent-settings.d.ts +0 -11
- package/vendor/core/dist/contracts/agent-settings.js +1 -7
- package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +93 -0
- package/vendor/core/dist/contracts/tools/collection-presentation.js +88 -0
- package/vendor/core/dist/contracts/tools/collection-selection.d.ts +47 -0
- package/vendor/core/dist/contracts/tools/collection-selection.js +74 -0
- package/vendor/core/dist/contracts/tools/manage-agents.d.ts +10 -4
- package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +1 -1
- package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +5 -1
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +19 -4
- package/vendor/core/dist/contracts/tools/manage-automations.js +25 -8
- package/vendor/core/dist/contracts/tools/manage-connections.d.ts +1 -0
- package/vendor/core/dist/contracts/tools/manage-connections.js +3 -0
- package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +11 -0
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +42 -3
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +181 -152
- package/vendor/core/dist/contracts/tools/manage-entity.js +118 -162
- package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
- package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +41 -3
- package/vendor/core/dist/contracts/tools/manage-operations.js +40 -2
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +182 -7
- package/vendor/core/dist/contracts/tools/manage-views.js +49 -13
- package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +11 -2
- package/vendor/core/dist/contracts/tools/read-knowledge.js +23 -3
- package/vendor/core/dist/contracts/tools/save-memory.d.ts +3 -6
- package/vendor/core/dist/contracts/tools/save-memory.js +2 -6
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +2 -1
- package/vendor/core/dist/contracts/tools/view-attach.js +7 -2
- package/vendor/core/dist/contracts/worker/protocol.d.ts +130 -159
- package/vendor/core/dist/contracts/worker/protocol.js +88 -76
- package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
- package/vendor/core/dist/device-pin-tombstones.js +57 -0
- package/vendor/core/dist/index.d.ts +5 -5
- package/vendor/core/dist/index.js +4 -6
- package/vendor/core/dist/json-template.d.ts +6 -10
- package/vendor/core/dist/json-template.js +5 -9
- package/vendor/core/dist/logger.js +17 -26
- package/vendor/core/dist/shell-safety.d.ts +9 -0
- package/vendor/core/dist/shell-safety.js +154 -0
- package/vendor/core/dist/suggestions.d.ts +1 -1
- package/vendor/core/dist/suggestions.js +1 -1
- package/vendor/core/dist/tool-trace-summary.d.ts +1 -1
- package/vendor/core/dist/tool-trace-summary.js +1 -1
- package/vendor/core/dist/types.d.ts +1 -3
- package/vendor/core/dist/utils/diagnostic-scrubber.d.ts +7 -0
- package/vendor/core/dist/utils/diagnostic-scrubber.js +437 -0
- package/vendor/core/dist/worker/auth.d.ts +44 -6
- package/vendor/core/dist/worker/auth.js +44 -11
- package/vendor/core/dist/worker/wire.d.ts +0 -10
- package/vendor/core/package.json +20 -11
- package/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
- package/vendor/ora/index.d.ts +332 -0
- package/vendor/ora/index.js +424 -0
- package/vendor/ora/license +9 -0
- package/vendor/ora/package.json +53 -0
- package/vendor/ora/readme.md +329 -0
- package/vendor/cli/dist/commands/telemetry.d.ts +0 -10
- package/vendor/cli/dist/commands/telemetry.js +0 -66
- package/vendor/connector-worker/dist/daemon/device-chat.d.ts +0 -9
- package/vendor/connector-worker/dist/daemon/device-chat.js +0 -61
- package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
- package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
- package/vendor/core/dist/sentry.d.ts +0 -26
- package/vendor/core/dist/sentry.js +0 -133
- package/vendor/core/dist/tool-policy.d.ts +0 -74
- package/vendor/core/dist/tool-policy.js +0 -305
- package/vendor/core/dist/utils/sentry-scrubber.d.ts +0 -29
- package/vendor/core/dist/utils/sentry-scrubber.js +0 -228
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Jira helpers, connector-owned.
|
|
3
|
+
*
|
|
4
|
+
* The bundled Jira connector (`jira.ts`) and the server's Atlassian Rovo MCP
|
|
5
|
+
* feed adapter (`packages/server/src/operations/atlassian-mcp-feed.ts`) read
|
|
6
|
+
* the same source (Jira Cloud issues via JQL) and must agree on the JQL
|
|
7
|
+
* builder, the stable row shape, and ADF-to-text conversion. This module owns
|
|
8
|
+
* that shared knowledge; transport (REST vs MCP tool call) stays with each
|
|
9
|
+
* consumer. Server imports it as `@lobu/connectors/jira-helpers`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Stable column set returned by Jira direct source reads. */
|
|
13
|
+
export const JIRA_ISSUE_COLUMNS = [
|
|
14
|
+
{ name: 'id', type: 'string' },
|
|
15
|
+
{ name: 'key', type: 'string' },
|
|
16
|
+
{ name: 'summary', type: 'string' },
|
|
17
|
+
{ name: 'status', type: 'string' },
|
|
18
|
+
{ name: 'assignee', type: 'string' },
|
|
19
|
+
{ name: 'reporter', type: 'string' },
|
|
20
|
+
{ name: 'priority', type: 'string' },
|
|
21
|
+
{ name: 'project_key', type: 'string' },
|
|
22
|
+
{ name: 'project_name', type: 'string' },
|
|
23
|
+
{ name: 'labels', type: 'string' },
|
|
24
|
+
{ name: 'created_at', type: 'string' },
|
|
25
|
+
{ name: 'updated_at', type: 'string' },
|
|
26
|
+
{ name: 'description', type: 'string' },
|
|
27
|
+
{ name: 'url', type: 'string' },
|
|
28
|
+
] as const;
|
|
29
|
+
|
|
30
|
+
/** Issue fields requested from `/rest/api/3/search/jql`. */
|
|
31
|
+
export const JIRA_ISSUE_FIELDS =
|
|
32
|
+
'summary,description,status,assignee,reporter,priority,project,labels,created,updated';
|
|
33
|
+
|
|
34
|
+
/** Sort columns the live path can honor by rewriting ORDER BY. */
|
|
35
|
+
export const JIRA_SORT_COLUMNS: Record<string, string> = {
|
|
36
|
+
updated: 'updated',
|
|
37
|
+
updated_at: 'updated',
|
|
38
|
+
created: 'created',
|
|
39
|
+
created_at: 'created',
|
|
40
|
+
key: 'key',
|
|
41
|
+
priority: 'priority',
|
|
42
|
+
status: 'status',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const ADF_BLOCK_TYPES = new Set([
|
|
46
|
+
'blockquote',
|
|
47
|
+
'bulletList',
|
|
48
|
+
'codeBlock',
|
|
49
|
+
'heading',
|
|
50
|
+
'listItem',
|
|
51
|
+
'orderedList',
|
|
52
|
+
'paragraph',
|
|
53
|
+
'rule',
|
|
54
|
+
'table',
|
|
55
|
+
'tableCell',
|
|
56
|
+
'tableHeader',
|
|
57
|
+
'tableRow',
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
export function jiraAsString(value: unknown): string | undefined {
|
|
61
|
+
return typeof value === 'string' && value.trim().length > 0
|
|
62
|
+
? value.trim()
|
|
63
|
+
: undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function jiraActorName(user: unknown): string | undefined {
|
|
67
|
+
if (!user || typeof user !== 'object') {
|
|
68
|
+
return typeof user === 'string' && user.trim() ? user.trim() : undefined;
|
|
69
|
+
}
|
|
70
|
+
const record = user as Record<string, unknown>;
|
|
71
|
+
return (
|
|
72
|
+
jiraAsString(record.displayName) ??
|
|
73
|
+
jiraAsString(record.emailAddress) ??
|
|
74
|
+
jiraAsString(record.name)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function jiraNamedField(value: unknown): string | undefined {
|
|
79
|
+
if (typeof value === 'string') return jiraAsString(value);
|
|
80
|
+
if (!value || typeof value !== 'object') return undefined;
|
|
81
|
+
return jiraAsString((value as Record<string, unknown>).name);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Jira v3 descriptions/comment bodies use the Atlassian Document Format (ADF) —
|
|
86
|
+
* a nested JSON node tree. Flatten its text nodes to plain text. Strings (older
|
|
87
|
+
* payloads) pass through unchanged.
|
|
88
|
+
*
|
|
89
|
+
* Block nodes join with `"\n"` so paragraphs do not glue together; inline
|
|
90
|
+
* nodes (and `hardBreak`, which already contributes its own newline) join
|
|
91
|
+
* cleanly.
|
|
92
|
+
*/
|
|
93
|
+
export function adfToText(value: unknown): string {
|
|
94
|
+
if (typeof value === 'string') return value;
|
|
95
|
+
if (!value || typeof value !== 'object') return '';
|
|
96
|
+
const node = value as { type?: string; text?: string; content?: unknown[] };
|
|
97
|
+
// Soft line break inside a paragraph (not a block boundary).
|
|
98
|
+
if (node.type === 'hardBreak') return '\n';
|
|
99
|
+
if (typeof node.text === 'string') return node.text;
|
|
100
|
+
if (Array.isArray(node.content)) {
|
|
101
|
+
let out = '';
|
|
102
|
+
for (const child of node.content) {
|
|
103
|
+
const text = adfToText(child);
|
|
104
|
+
if (!text) continue;
|
|
105
|
+
const childType =
|
|
106
|
+
child && typeof child === 'object'
|
|
107
|
+
? (child as { type?: string }).type
|
|
108
|
+
: undefined;
|
|
109
|
+
// hardBreak already contributes '\n' as its text; don't insert a second.
|
|
110
|
+
if (out && childType && ADF_BLOCK_TYPES.has(childType)) out += '\n';
|
|
111
|
+
out += text;
|
|
112
|
+
}
|
|
113
|
+
return out.trim();
|
|
114
|
+
}
|
|
115
|
+
return '';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Peel a trailing `ORDER BY …` so caller JQL can be AND-composed without
|
|
120
|
+
* wrapping the sort clause.
|
|
121
|
+
*/
|
|
122
|
+
export function splitTrailingOrderBy(jql: string): {
|
|
123
|
+
body: string;
|
|
124
|
+
orderBy: string | null;
|
|
125
|
+
} {
|
|
126
|
+
let quote: '"' | "'" | null = null;
|
|
127
|
+
let escaped = false;
|
|
128
|
+
let depth = 0;
|
|
129
|
+
for (let i = 0; i < jql.length; i += 1) {
|
|
130
|
+
const char = jql[i];
|
|
131
|
+
if (quote) {
|
|
132
|
+
if (escaped) {
|
|
133
|
+
escaped = false;
|
|
134
|
+
} else if (char === '\\') {
|
|
135
|
+
escaped = true;
|
|
136
|
+
} else if (char === quote) {
|
|
137
|
+
quote = null;
|
|
138
|
+
}
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (char === '"' || char === "'") {
|
|
142
|
+
quote = char;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (char === '(') {
|
|
146
|
+
depth += 1;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (char === ')') {
|
|
150
|
+
depth = Math.max(0, depth - 1);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (
|
|
154
|
+
depth === 0 &&
|
|
155
|
+
(i === 0 || /\s/.test(jql[i - 1])) &&
|
|
156
|
+
/^order\s+by\b/i.test(jql.slice(i))
|
|
157
|
+
) {
|
|
158
|
+
return { body: jql.slice(0, i).trim(), orderBy: jql.slice(i).trim() };
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return { body: jql.trim(), orderBy: null };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function buildJiraJql(args: {
|
|
165
|
+
baseQuery: string;
|
|
166
|
+
query?: string;
|
|
167
|
+
sort?: { column: string; order: 'asc' | 'desc' };
|
|
168
|
+
defaultWhenEmpty?: string;
|
|
169
|
+
window?: { start: string; end: string };
|
|
170
|
+
}): string {
|
|
171
|
+
const trimmed = args.baseQuery.trim();
|
|
172
|
+
// Keep an omitted scope bounded instead of scanning the whole site.
|
|
173
|
+
const jql =
|
|
174
|
+
trimmed.length > 0
|
|
175
|
+
? trimmed
|
|
176
|
+
: (args.defaultWhenEmpty ?? 'updated >= -90d');
|
|
177
|
+
|
|
178
|
+
// If the base is only ORDER BY, treat the restriction as empty and keep sort.
|
|
179
|
+
let { body, orderBy } = splitTrailingOrderBy(jql);
|
|
180
|
+
if (!body && orderBy) {
|
|
181
|
+
body = args.window
|
|
182
|
+
? (args.defaultWhenEmpty ?? '')
|
|
183
|
+
: (args.defaultWhenEmpty ?? 'updated >= -90d');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const callerQuery = args.query?.trim() ?? '';
|
|
187
|
+
if (callerQuery) {
|
|
188
|
+
const caller = splitTrailingOrderBy(callerQuery);
|
|
189
|
+
if (caller.body) {
|
|
190
|
+
body = body.length > 0 ? `(${body}) AND (${caller.body})` : caller.body;
|
|
191
|
+
}
|
|
192
|
+
if (caller.orderBy) {
|
|
193
|
+
throw new Error(
|
|
194
|
+
'Jira source read query cannot contain ORDER BY; use the separate sort field',
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (args.window) {
|
|
200
|
+
const bounds = `updated >= ${Date.parse(args.window.start)} AND updated < ${Date.parse(args.window.end)}`;
|
|
201
|
+
body = body ? `(${body}) AND (${bounds})` : bounds;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (orderBy) {
|
|
205
|
+
if (args.sort) {
|
|
206
|
+
throw new Error(
|
|
207
|
+
'Jira source read: cannot apply sort when the base JQL already contains ORDER BY',
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
return body.length > 0 ? `${body} ${orderBy}` : orderBy;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (args.sort) {
|
|
214
|
+
const field = JIRA_SORT_COLUMNS[args.sort.column];
|
|
215
|
+
if (!field) {
|
|
216
|
+
throw new Error(
|
|
217
|
+
`Jira source read sort column '${args.sort.column}' is unsupported; ` +
|
|
218
|
+
`use one of: ${Object.keys(JIRA_SORT_COLUMNS).join(', ')}`,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
const dir = args.sort.order === 'asc' ? 'ASC' : 'DESC';
|
|
222
|
+
return body.length > 0
|
|
223
|
+
? `${body} ORDER BY ${field} ${dir}`
|
|
224
|
+
: `ORDER BY ${field} ${dir}`;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return body.length > 0
|
|
228
|
+
? `${body} ORDER BY updated DESC`
|
|
229
|
+
: `${args.defaultWhenEmpty || 'updated >= -90d'} ORDER BY updated DESC`;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function jiraIssueUrl(
|
|
233
|
+
issue: Record<string, unknown>,
|
|
234
|
+
fields: Record<string, unknown>,
|
|
235
|
+
config: Record<string, unknown>,
|
|
236
|
+
): string | undefined {
|
|
237
|
+
const key = jiraAsString(issue.key);
|
|
238
|
+
const siteUrl = jiraAsString(config.site_url);
|
|
239
|
+
const cloudId = jiraAsString(config.cloud_id);
|
|
240
|
+
const siteCloudId = jiraAsString(config.site_cloud_id);
|
|
241
|
+
// Only rewrite to /browse when site_url was discovered for THIS cloud_id.
|
|
242
|
+
// A feed-level cloud_id override must not inherit another site's host.
|
|
243
|
+
if (siteUrl && key && cloudId && siteCloudId && cloudId === siteCloudId) {
|
|
244
|
+
return `${siteUrl.replace(/\/+$/, '')}/browse/${encodeURIComponent(key)}`;
|
|
245
|
+
}
|
|
246
|
+
return (
|
|
247
|
+
jiraAsString(issue.self) ??
|
|
248
|
+
jiraAsString(fields.url) ??
|
|
249
|
+
jiraAsString(issue.url)
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Map one Jira issue (REST-shaped `{ id, key, fields }` or flattened MCP
|
|
255
|
+
* payload) onto the stable issue row. Returns null when the payload carries
|
|
256
|
+
* no usable issue identity.
|
|
257
|
+
*/
|
|
258
|
+
export function mapJiraIssueToRow(
|
|
259
|
+
raw: unknown,
|
|
260
|
+
config: Record<string, unknown> = {},
|
|
261
|
+
): Record<string, unknown> | null {
|
|
262
|
+
if (!raw || typeof raw !== 'object') return null;
|
|
263
|
+
const issue = raw as Record<string, unknown>;
|
|
264
|
+
const fields =
|
|
265
|
+
issue.fields && typeof issue.fields === 'object'
|
|
266
|
+
? (issue.fields as Record<string, unknown>)
|
|
267
|
+
: issue;
|
|
268
|
+
const id =
|
|
269
|
+
jiraAsString(issue.id) ??
|
|
270
|
+
jiraAsString(issue.key) ??
|
|
271
|
+
jiraAsString(fields.id);
|
|
272
|
+
if (!id) return null;
|
|
273
|
+
const labelsRaw = fields.labels ?? issue.labels;
|
|
274
|
+
const labels = Array.isArray(labelsRaw)
|
|
275
|
+
? labelsRaw
|
|
276
|
+
.filter((label): label is string => typeof label === 'string')
|
|
277
|
+
.join(', ') || null
|
|
278
|
+
: (jiraAsString(labelsRaw) ?? null);
|
|
279
|
+
const project =
|
|
280
|
+
fields.project && typeof fields.project === 'object'
|
|
281
|
+
? (fields.project as Record<string, unknown>)
|
|
282
|
+
: undefined;
|
|
283
|
+
return {
|
|
284
|
+
id,
|
|
285
|
+
key: jiraAsString(issue.key) ?? jiraAsString(fields.key) ?? null,
|
|
286
|
+
summary:
|
|
287
|
+
jiraAsString(fields.summary) ?? jiraAsString(issue.summary) ?? null,
|
|
288
|
+
status:
|
|
289
|
+
jiraNamedField(fields.status) ?? jiraNamedField(issue.status) ?? null,
|
|
290
|
+
assignee:
|
|
291
|
+
jiraActorName(fields.assignee ?? issue.assignee) ?? null,
|
|
292
|
+
reporter:
|
|
293
|
+
jiraActorName(fields.reporter ?? issue.reporter) ?? null,
|
|
294
|
+
priority:
|
|
295
|
+
jiraNamedField(fields.priority) ?? jiraNamedField(issue.priority) ?? null,
|
|
296
|
+
project_key:
|
|
297
|
+
jiraAsString(project?.key) ??
|
|
298
|
+
jiraAsString(fields.projectKey) ??
|
|
299
|
+
jiraAsString(issue.project_key) ??
|
|
300
|
+
null,
|
|
301
|
+
project_name:
|
|
302
|
+
jiraAsString(project?.name) ??
|
|
303
|
+
jiraAsString(fields.projectName) ??
|
|
304
|
+
null,
|
|
305
|
+
labels,
|
|
306
|
+
created_at:
|
|
307
|
+
jiraAsString(fields.created) ?? jiraAsString(issue.created) ?? null,
|
|
308
|
+
updated_at:
|
|
309
|
+
jiraAsString(fields.updated) ?? jiraAsString(issue.updated) ?? null,
|
|
310
|
+
description: adfToText(fields.description ?? issue.description) || null,
|
|
311
|
+
url: jiraIssueUrl(issue, fields, config) ?? null,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Jira Connector (V1 runtime)
|
|
3
3
|
*
|
|
4
|
-
* Reads Jira Cloud issues via JQL and can sync them into events.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Reads Jira Cloud issues via JQL and can sync them into events. App-level
|
|
5
|
+
* webhook deliveries are verified and routed to the owning install, but the
|
|
6
|
+
* connector declares no webhook event type, so they trigger nothing yet.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { randomBytes } from 'node:crypto';
|
|
@@ -21,6 +21,15 @@ import {
|
|
|
21
21
|
type WebhookRegistration,
|
|
22
22
|
type WebhookRegistrationContext,
|
|
23
23
|
} from '@lobu/connector-sdk';
|
|
24
|
+
import {
|
|
25
|
+
adfToText,
|
|
26
|
+
buildJiraJql,
|
|
27
|
+
JIRA_ISSUE_COLUMNS,
|
|
28
|
+
JIRA_ISSUE_FIELDS,
|
|
29
|
+
jiraActorName,
|
|
30
|
+
jiraAsString,
|
|
31
|
+
mapJiraIssueToRow,
|
|
32
|
+
} from './jira-helpers.js';
|
|
24
33
|
|
|
25
34
|
// ---------------------------------------------------------------------------
|
|
26
35
|
// Types
|
|
@@ -108,193 +117,6 @@ interface JiraSearchResponse {
|
|
|
108
117
|
isLast?: boolean;
|
|
109
118
|
}
|
|
110
119
|
|
|
111
|
-
/** Stable column set returned by direct source reads. */
|
|
112
|
-
const JIRA_ISSUE_COLUMNS = [
|
|
113
|
-
{ name: 'id', type: 'string' },
|
|
114
|
-
{ name: 'key', type: 'string' },
|
|
115
|
-
{ name: 'summary', type: 'string' },
|
|
116
|
-
{ name: 'status', type: 'string' },
|
|
117
|
-
{ name: 'assignee', type: 'string' },
|
|
118
|
-
{ name: 'reporter', type: 'string' },
|
|
119
|
-
{ name: 'priority', type: 'string' },
|
|
120
|
-
{ name: 'project_key', type: 'string' },
|
|
121
|
-
{ name: 'project_name', type: 'string' },
|
|
122
|
-
{ name: 'labels', type: 'string' },
|
|
123
|
-
{ name: 'created_at', type: 'string' },
|
|
124
|
-
{ name: 'updated_at', type: 'string' },
|
|
125
|
-
{ name: 'description', type: 'string' },
|
|
126
|
-
{ name: 'url', type: 'string' },
|
|
127
|
-
] as const;
|
|
128
|
-
|
|
129
|
-
const ISSUE_FIELDS =
|
|
130
|
-
'summary,description,status,assignee,reporter,priority,project,labels,created,updated';
|
|
131
|
-
|
|
132
|
-
/** Sort columns the live path can honor by rewriting ORDER BY. */
|
|
133
|
-
const SORT_COLUMNS: Record<string, string> = {
|
|
134
|
-
updated: 'updated',
|
|
135
|
-
updated_at: 'updated',
|
|
136
|
-
created: 'created',
|
|
137
|
-
created_at: 'created',
|
|
138
|
-
key: 'key',
|
|
139
|
-
priority: 'priority',
|
|
140
|
-
status: 'status',
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const ADF_BLOCK_TYPES = new Set([
|
|
144
|
-
'blockquote',
|
|
145
|
-
'bulletList',
|
|
146
|
-
'codeBlock',
|
|
147
|
-
'heading',
|
|
148
|
-
'listItem',
|
|
149
|
-
'orderedList',
|
|
150
|
-
'paragraph',
|
|
151
|
-
'rule',
|
|
152
|
-
'table',
|
|
153
|
-
'tableCell',
|
|
154
|
-
'tableHeader',
|
|
155
|
-
'tableRow',
|
|
156
|
-
]);
|
|
157
|
-
|
|
158
|
-
function asString(value: unknown): string | undefined {
|
|
159
|
-
return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function actorName(user: JiraUser | null | undefined): string | undefined {
|
|
163
|
-
return user?.displayName ?? user?.emailAddress ?? undefined;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Jira v3 descriptions/comment bodies use the Atlassian Document Format (ADF) —
|
|
168
|
-
* a nested JSON node tree. Flatten its text nodes to plain text. Strings (older
|
|
169
|
-
* payloads) pass through unchanged.
|
|
170
|
-
*/
|
|
171
|
-
function adfToText(value: unknown): string {
|
|
172
|
-
if (typeof value === 'string') return value;
|
|
173
|
-
if (!value || typeof value !== 'object') return '';
|
|
174
|
-
const node = value as { type?: string; text?: string; content?: unknown[] };
|
|
175
|
-
// Soft line break inside a paragraph (not a block boundary).
|
|
176
|
-
if (node.type === 'hardBreak') return '\n';
|
|
177
|
-
if (typeof node.text === 'string') return node.text;
|
|
178
|
-
if (Array.isArray(node.content)) {
|
|
179
|
-
let out = '';
|
|
180
|
-
for (const child of node.content) {
|
|
181
|
-
const text = adfToText(child);
|
|
182
|
-
if (!text) continue;
|
|
183
|
-
const childType =
|
|
184
|
-
child && typeof child === 'object' ? (child as { type?: string }).type : undefined;
|
|
185
|
-
// hardBreak already contributes '\n' as its text; don't insert a second.
|
|
186
|
-
if (out && childType && ADF_BLOCK_TYPES.has(childType)) out += '\n';
|
|
187
|
-
out += text;
|
|
188
|
-
}
|
|
189
|
-
return out.trim();
|
|
190
|
-
}
|
|
191
|
-
return '';
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Peel a trailing `ORDER BY …` so caller JQL can be AND-composed without
|
|
196
|
-
* wrapping the sort clause.
|
|
197
|
-
*/
|
|
198
|
-
function splitTrailingOrderBy(jql: string): { body: string; orderBy: string | null } {
|
|
199
|
-
let quote: '"' | "'" | null = null;
|
|
200
|
-
let escaped = false;
|
|
201
|
-
let depth = 0;
|
|
202
|
-
for (let i = 0; i < jql.length; i += 1) {
|
|
203
|
-
const char = jql[i];
|
|
204
|
-
if (quote) {
|
|
205
|
-
if (escaped) {
|
|
206
|
-
escaped = false;
|
|
207
|
-
} else if (char === '\\') {
|
|
208
|
-
escaped = true;
|
|
209
|
-
} else if (char === quote) {
|
|
210
|
-
quote = null;
|
|
211
|
-
}
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
if (char === '"' || char === "'") {
|
|
215
|
-
quote = char;
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
if (char === '(') {
|
|
219
|
-
depth += 1;
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
if (char === ')') {
|
|
223
|
-
depth = Math.max(0, depth - 1);
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
if (
|
|
227
|
-
depth === 0 &&
|
|
228
|
-
(i === 0 || /\s/.test(jql[i - 1])) &&
|
|
229
|
-
/^order\s+by\b/i.test(jql.slice(i))
|
|
230
|
-
) {
|
|
231
|
-
return { body: jql.slice(0, i).trim(), orderBy: jql.slice(i).trim() };
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return { body: jql.trim(), orderBy: null };
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function buildJiraJql(args: {
|
|
238
|
-
baseQuery: string;
|
|
239
|
-
query?: string;
|
|
240
|
-
sort?: { column: string; order: 'asc' | 'desc' };
|
|
241
|
-
defaultWhenEmpty?: string;
|
|
242
|
-
window?: { start: string; end: string };
|
|
243
|
-
}): string {
|
|
244
|
-
const trimmed = args.baseQuery.trim();
|
|
245
|
-
// Keep an omitted scope bounded instead of scanning the whole site.
|
|
246
|
-
const jql = trimmed.length > 0 ? trimmed : (args.defaultWhenEmpty ?? 'updated >= -90d');
|
|
247
|
-
|
|
248
|
-
// If the base is only ORDER BY, treat the restriction as empty and keep sort.
|
|
249
|
-
let { body, orderBy } = splitTrailingOrderBy(jql);
|
|
250
|
-
if (!body && orderBy) {
|
|
251
|
-
body = args.defaultWhenEmpty ?? 'updated >= -90d';
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const callerQuery = args.query?.trim() ?? '';
|
|
255
|
-
if (callerQuery) {
|
|
256
|
-
const caller = splitTrailingOrderBy(callerQuery);
|
|
257
|
-
if (caller.body) {
|
|
258
|
-
body = body.length > 0 ? `(${body}) AND (${caller.body})` : caller.body;
|
|
259
|
-
}
|
|
260
|
-
if (caller.orderBy) {
|
|
261
|
-
throw new Error(
|
|
262
|
-
'Jira source read query cannot contain ORDER BY; use the separate sort field',
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (args.window) {
|
|
268
|
-
const bounds = `updated >= ${Date.parse(args.window.start)} AND updated < ${Date.parse(args.window.end)}`;
|
|
269
|
-
body = body ? `(${body}) AND (${bounds})` : bounds;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// `body` is non-empty from here on: an empty base fell back to
|
|
273
|
-
// `defaultWhenEmpty`, and the caller query can further restrict it.
|
|
274
|
-
if (orderBy) {
|
|
275
|
-
if (args.sort) {
|
|
276
|
-
throw new Error(
|
|
277
|
-
'Jira source read: cannot apply sort when the base JQL already contains ORDER BY',
|
|
278
|
-
);
|
|
279
|
-
}
|
|
280
|
-
return `${body} ${orderBy}`;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (args.sort) {
|
|
284
|
-
const field = SORT_COLUMNS[args.sort.column];
|
|
285
|
-
if (!field) {
|
|
286
|
-
throw new Error(
|
|
287
|
-
`Jira source read sort column '${args.sort.column}' is unsupported; ` +
|
|
288
|
-
`use one of: ${Object.keys(SORT_COLUMNS).join(', ')}`,
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
const dir = args.sort.order === 'asc' ? 'ASC' : 'DESC';
|
|
292
|
-
return `${body} ORDER BY ${field} ${dir}`;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return `${body} ORDER BY updated DESC`;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
120
|
// ---------------------------------------------------------------------------
|
|
299
121
|
// Connector
|
|
300
122
|
// ---------------------------------------------------------------------------
|
|
@@ -304,8 +126,8 @@ export default class JiraConnector extends ConnectorRuntime<JiraCheckpoint, Jira
|
|
|
304
126
|
key: 'jira',
|
|
305
127
|
name: 'Jira',
|
|
306
128
|
description:
|
|
307
|
-
'Syncs and live-reads Jira Cloud issues via JQL
|
|
308
|
-
version: '1.1.
|
|
129
|
+
'Syncs and live-reads Jira Cloud issues via JQL.',
|
|
130
|
+
version: '1.1.5',
|
|
309
131
|
faviconDomain: 'atlassian.com',
|
|
310
132
|
webhook: {
|
|
311
133
|
// Jira Connect app webhooks HMAC-sign the raw body with the installation
|
|
@@ -463,11 +285,11 @@ export default class JiraConnector extends ConnectorRuntime<JiraCheckpoint, Jira
|
|
|
463
285
|
throw new Error('Jira source reads require Atlassian OAuth credentials.');
|
|
464
286
|
}
|
|
465
287
|
|
|
466
|
-
const baseQuery =
|
|
288
|
+
const baseQuery = jiraAsString(ctx.config.query) ?? jiraAsString(ctx.config.jql) ?? '';
|
|
467
289
|
|
|
468
290
|
const jql = buildJiraJql({
|
|
469
291
|
baseQuery,
|
|
470
|
-
query:
|
|
292
|
+
query: jiraAsString(ctx.query),
|
|
471
293
|
window: ctx.window,
|
|
472
294
|
...(ctx.window ? { defaultWhenEmpty: '' } : {}),
|
|
473
295
|
sort: ctx.sort,
|
|
@@ -492,7 +314,7 @@ export default class JiraConnector extends ConnectorRuntime<JiraCheckpoint, Jira
|
|
|
492
314
|
const params = new URLSearchParams({
|
|
493
315
|
jql,
|
|
494
316
|
maxResults: String(Math.min(this.PAGE_SIZE, limit)),
|
|
495
|
-
fields:
|
|
317
|
+
fields: JIRA_ISSUE_FIELDS,
|
|
496
318
|
});
|
|
497
319
|
if (ctx.cursor) params.set('nextPageToken', ctx.cursor);
|
|
498
320
|
const data = await http.json<JiraSearchResponse>(
|
|
@@ -540,7 +362,7 @@ export default class JiraConnector extends ConnectorRuntime<JiraCheckpoint, Jira
|
|
|
540
362
|
end: new Date().toISOString(),
|
|
541
363
|
};
|
|
542
364
|
const jql = buildJiraJql({
|
|
543
|
-
baseQuery:
|
|
365
|
+
baseQuery: jiraAsString(ctx.config.query) ?? jiraAsString(ctx.config.jql) ?? '',
|
|
544
366
|
defaultWhenEmpty: `updated >= -${lookbackDays}d`,
|
|
545
367
|
window,
|
|
546
368
|
});
|
|
@@ -559,7 +381,7 @@ export default class JiraConnector extends ConnectorRuntime<JiraCheckpoint, Jira
|
|
|
559
381
|
const params = new URLSearchParams({
|
|
560
382
|
jql,
|
|
561
383
|
maxResults: String(this.PAGE_SIZE),
|
|
562
|
-
fields:
|
|
384
|
+
fields: JIRA_ISSUE_FIELDS,
|
|
563
385
|
});
|
|
564
386
|
if (pageToken) {
|
|
565
387
|
seenTokens.add(pageToken);
|
|
@@ -612,7 +434,7 @@ export default class JiraConnector extends ConnectorRuntime<JiraCheckpoint, Jira
|
|
|
612
434
|
}
|
|
613
435
|
|
|
614
436
|
// -------------------------------------------------------------------------
|
|
615
|
-
// Webhooks (subscription lifecycle —
|
|
437
|
+
// Webhooks (subscription lifecycle — per-connection deliveries are stored raw)
|
|
616
438
|
// -------------------------------------------------------------------------
|
|
617
439
|
|
|
618
440
|
async registerWebhook(
|
|
@@ -675,24 +497,10 @@ export default class JiraConnector extends ConnectorRuntime<JiraCheckpoint, Jira
|
|
|
675
497
|
config: JiraConfig,
|
|
676
498
|
): Record<string, unknown> | null {
|
|
677
499
|
if (!issue?.id) return null;
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
key: issue.key ?? null,
|
|
683
|
-
summary: fields.summary ?? null,
|
|
684
|
-
status: fields.status?.name ?? null,
|
|
685
|
-
assignee: actorName(fields.assignee) ?? null,
|
|
686
|
-
reporter: actorName(fields.reporter) ?? null,
|
|
687
|
-
priority: fields.priority?.name ?? null,
|
|
688
|
-
project_key: fields.project?.key ?? null,
|
|
689
|
-
project_name: fields.project?.name ?? null,
|
|
690
|
-
labels,
|
|
691
|
-
created_at: fields.created ?? null,
|
|
692
|
-
updated_at: fields.updated ?? null,
|
|
693
|
-
description: adfToText(fields.description) || null,
|
|
694
|
-
url: this.issueUrl(issue, config) ?? null,
|
|
695
|
-
};
|
|
500
|
+
return mapJiraIssueToRow(
|
|
501
|
+
issue,
|
|
502
|
+
config as unknown as Record<string, unknown>,
|
|
503
|
+
);
|
|
696
504
|
}
|
|
697
505
|
|
|
698
506
|
private issueEvent(issue: JiraIssue | undefined, config: JiraConfig): EventEnvelope | null {
|
|
@@ -705,25 +513,25 @@ export default class JiraConnector extends ConnectorRuntime<JiraCheckpoint, Jira
|
|
|
705
513
|
origin_id: `jira_issue_${issue.id}`,
|
|
706
514
|
title: fields.summary ?? issue.key ?? undefined,
|
|
707
515
|
payload_text: adfToText(fields.description),
|
|
708
|
-
author_name:
|
|
516
|
+
author_name: jiraActorName(fields.reporter ?? fields.assignee),
|
|
709
517
|
source_url: this.issueUrl(issue, config),
|
|
710
518
|
occurred_at: createdAt,
|
|
711
519
|
origin_type: 'issue',
|
|
712
520
|
metadata: {
|
|
713
521
|
key: issue.key ?? null,
|
|
714
522
|
status: fields.status?.name ?? null,
|
|
715
|
-
assignee:
|
|
716
|
-
reporter:
|
|
523
|
+
assignee: jiraActorName(fields.assignee) ?? null,
|
|
524
|
+
reporter: jiraActorName(fields.reporter) ?? null,
|
|
717
525
|
updated_at: fields.updated ?? null,
|
|
718
526
|
},
|
|
719
527
|
};
|
|
720
528
|
}
|
|
721
529
|
|
|
722
530
|
private issueUrl(issue: JiraIssue | undefined, config?: JiraConfig): string | undefined {
|
|
723
|
-
const siteUrl =
|
|
724
|
-
const key =
|
|
725
|
-
const cloudId =
|
|
726
|
-
const siteCloudId =
|
|
531
|
+
const siteUrl = jiraAsString(config?.site_url);
|
|
532
|
+
const key = jiraAsString(issue?.key);
|
|
533
|
+
const cloudId = jiraAsString(config?.cloud_id);
|
|
534
|
+
const siteCloudId = jiraAsString(config?.site_cloud_id);
|
|
727
535
|
// Only rewrite to /browse when site_url was discovered for THIS cloud_id.
|
|
728
536
|
// A feed-level cloud_id override must not inherit another site's host.
|
|
729
537
|
if (siteUrl && key && cloudId && siteCloudId && cloudId === siteCloudId) {
|
|
@@ -756,7 +564,7 @@ export default class JiraConnector extends ConnectorRuntime<JiraCheckpoint, Jira
|
|
|
756
564
|
sessionState: Record<string, unknown> | null | undefined,
|
|
757
565
|
credentials: SyncCredentials | null | undefined,
|
|
758
566
|
): Promise<string> {
|
|
759
|
-
const fromConfig =
|
|
567
|
+
const fromConfig = jiraAsString(config.cloud_id) ?? jiraAsString(sessionState?.cloud_id);
|
|
760
568
|
if (fromConfig) return fromConfig;
|
|
761
569
|
|
|
762
570
|
if (!credentials?.accessToken) {
|
|
@@ -804,7 +612,7 @@ export default class JiraConnector extends ConnectorRuntime<JiraCheckpoint, Jira
|
|
|
804
612
|
? distinctUsable[0]
|
|
805
613
|
: null;
|
|
806
614
|
|
|
807
|
-
const id =
|
|
615
|
+
const id = jiraAsString(site?.id);
|
|
808
616
|
if (!id) {
|
|
809
617
|
if (jiraScoped.length > 1 || distinctUsable.length > 1) {
|
|
810
618
|
throw new Error(
|
|
@@ -819,8 +627,8 @@ export default class JiraConnector extends ConnectorRuntime<JiraCheckpoint, Jira
|
|
|
819
627
|
// Cache on this job's config so subsequent calls in the same run skip the hop.
|
|
820
628
|
config.cloud_id = id;
|
|
821
629
|
config.site_cloud_id = id;
|
|
822
|
-
const siteUrl =
|
|
823
|
-
const siteName =
|
|
630
|
+
const siteUrl = jiraAsString(site?.url);
|
|
631
|
+
const siteName = jiraAsString(site?.name);
|
|
824
632
|
if (siteUrl) config.site_url = siteUrl;
|
|
825
633
|
else delete config.site_url;
|
|
826
634
|
if (siteName) config.site_name = siteName;
|