@kosha-ai/integration-atlassian 0.5.0 → 0.5.1
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/atlassian-oauth.d.ts +1 -0
- package/dist/lib/atlassian-oauth.d.ts.map +1 -1
- package/dist/lib/atlassian-oauth.js +7 -1
- package/dist/lib/integration-atlassian.d.ts +12 -0
- package/dist/lib/integration-atlassian.d.ts.map +1 -0
- package/dist/lib/integration-atlassian.js +58 -0
- package/dist/lib/scopes.d.ts +12 -0
- package/dist/lib/scopes.d.ts.map +1 -0
- package/dist/lib/scopes.js +283 -0
- package/docs/setup.md +8 -6
- package/migrations/002_rename_key/migration.sql +53 -0
- package/migrations/003_scopes/migration.sql +2 -0
- package/package.json +5 -5
- package/dist/lib/integration-atlassian-jira.d.ts +0 -12
- package/dist/lib/integration-atlassian-jira.d.ts.map +0 -1
- package/dist/lib/integration-atlassian-jira.js +0 -72
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { atlassian, atlassian as default, type AtlassianIntegrationOptions, } from './lib/integration-atlassian.js';
|
|
2
2
|
export { atlassianOAuth, getAccessibleResources, selectResource, type AccessibleResource, type AtlassianOAuthOptions, } from './lib/atlassian-oauth.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,IAAI,OAAO,EACpB,KAAK,2BAA2B,GACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,GAC3B,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { atlassian, atlassian as default, } from './lib/integration-atlassian.js';
|
|
2
2
|
export { atlassianOAuth, getAccessibleResources, selectResource, } from './lib/atlassian-oauth.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atlassian-oauth.d.ts","sourceRoot":"","sources":["../../src/lib/atlassian-oauth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAUtE,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"atlassian-oauth.d.ts","sourceRoot":"","sources":["../../src/lib/atlassian-oauth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAUtE,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,qBAAqB,GAC7B,oBAAoB,CAqCtB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAe/B;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,kBAAkB,EAAE,EAC/B,OAAO,CAAC,EAAE,MAAM,GACf,kBAAkB,CAgBpB"}
|
|
@@ -26,10 +26,16 @@ export function atlassianOAuth(options) {
|
|
|
26
26
|
prompt: 'consent',
|
|
27
27
|
},
|
|
28
28
|
scopesAvailable: options.scopesAvailable,
|
|
29
|
+
scopesRequested: options.scopesRequested,
|
|
29
30
|
});
|
|
30
31
|
const originalBuildAuthorizationUrl = auth.buildAuthorizationUrl;
|
|
31
32
|
auth.buildAuthorizationUrl = (args) => {
|
|
32
|
-
const
|
|
33
|
+
const configuredScopes = args.client.fields['scopes'];
|
|
34
|
+
const requestedScopes = Array.isArray(configuredScopes)
|
|
35
|
+
? configuredScopes.filter((scope) => typeof scope === 'string' &&
|
|
36
|
+
options.scopesAvailable.includes(scope))
|
|
37
|
+
: args.client.scopes;
|
|
38
|
+
const scopes = Array.from(new Set([...requestedScopes, OFFLINE_ACCESS]));
|
|
33
39
|
return originalBuildAuthorizationUrl({
|
|
34
40
|
...args,
|
|
35
41
|
client: { ...args.client, scopes },
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { KoshaIntegration } from '@kosha-ai/integration-sdk';
|
|
2
|
+
export interface AtlassianIntegrationOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Pin the connection to one Atlassian site instead of taking the first one the
|
|
5
|
+
* granting user has access to. Match against the site's URL as returned by
|
|
6
|
+
* `accessible-resources` (e.g. `https://acme.atlassian.net`).
|
|
7
|
+
*/
|
|
8
|
+
siteUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function atlassian(options?: AtlassianIntegrationOptions): KoshaIntegration;
|
|
11
|
+
export default atlassian;
|
|
12
|
+
//# sourceMappingURL=integration-atlassian.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration-atlassian.d.ts","sourceRoot":"","sources":["../../src/lib/integration-atlassian.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAelE,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,SAAS,CACvB,OAAO,GAAE,2BAAgC,GACxC,gBAAgB,CA0DlB;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { defineIntegration, packageDirs } from '@kosha-ai/integration-sdk';
|
|
2
|
+
import { atlassianOAuth, getAccessibleResources, selectResource, } from './atlassian-oauth.js';
|
|
3
|
+
import { ATLASSIAN_DEFAULT_SCOPES, ATLASSIAN_SCOPE_OPTIONS, ATLASSIAN_SCOPES, } from './scopes.js';
|
|
4
|
+
const { docsPath, migrationsPath } = packageDirs(import.meta.url);
|
|
5
|
+
export function atlassian(options = {}) {
|
|
6
|
+
const auth = atlassianOAuth({
|
|
7
|
+
scopesAvailable: ATLASSIAN_SCOPES,
|
|
8
|
+
scopesRequested: ATLASSIAN_DEFAULT_SCOPES,
|
|
9
|
+
});
|
|
10
|
+
return defineIntegration({
|
|
11
|
+
key: 'atlassian',
|
|
12
|
+
name: 'Atlassian',
|
|
13
|
+
docsUrl: 'https://developer.atlassian.com/cloud/jira/platform/rest/v3/',
|
|
14
|
+
docsPath,
|
|
15
|
+
migrationsPath,
|
|
16
|
+
auth,
|
|
17
|
+
configFields: [
|
|
18
|
+
{
|
|
19
|
+
key: 'scopes',
|
|
20
|
+
label: 'Scopes',
|
|
21
|
+
type: 'select',
|
|
22
|
+
required: true,
|
|
23
|
+
options: ATLASSIAN_SCOPE_OPTIONS,
|
|
24
|
+
help: 'Select the Jira and Confluence permissions this configuration should request during OAuth. offline_access is added automatically.',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
api: {
|
|
28
|
+
// Match Nango: keep the proxy base generic. Callers choose the product
|
|
29
|
+
// path in the endpoint, e.g. /ex/jira/{cloudId}/... or
|
|
30
|
+
// /ex/confluence/{cloudId}/....
|
|
31
|
+
resolveBaseUrl: () => 'https://api.atlassian.com',
|
|
32
|
+
authHeaders: ({ accessToken }) => ({
|
|
33
|
+
Authorization: `Bearer ${accessToken}`,
|
|
34
|
+
Accept: 'application/json',
|
|
35
|
+
}),
|
|
36
|
+
egress: [{ hosts: ['api.atlassian.com'] }],
|
|
37
|
+
},
|
|
38
|
+
identity: {
|
|
39
|
+
async fetchAccount({ accessToken }) {
|
|
40
|
+
const resources = await getAccessibleResources(accessToken);
|
|
41
|
+
const site = selectResource(resources, options.siteUrl);
|
|
42
|
+
return {
|
|
43
|
+
// An Atlassian OAuth connection is scoped to an accessible Cloud
|
|
44
|
+
// resource. No product-specific API call is needed during OAuth.
|
|
45
|
+
externalAccountId: site.id,
|
|
46
|
+
label: site.name,
|
|
47
|
+
metadata: {
|
|
48
|
+
cloudId: site.id,
|
|
49
|
+
siteUrl: site.url,
|
|
50
|
+
siteName: site.name,
|
|
51
|
+
scopes: site.scopes,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export default atlassian;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jira Cloud OAuth 2.0 (3LO) scopes published by Atlassian. Keep
|
|
3
|
+
* `offline_access` out of this list because it is always added by the OAuth
|
|
4
|
+
* implementation and is not a Jira API permission.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ATLASSIAN_SCOPES: string[];
|
|
7
|
+
export declare const ATLASSIAN_SCOPE_OPTIONS: {
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}[];
|
|
11
|
+
export declare const ATLASSIAN_DEFAULT_SCOPES: string[];
|
|
12
|
+
//# sourceMappingURL=scopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../src/lib/scopes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,UAgR5B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;GAGjC,CAAC;AAEJ,eAAO,MAAM,wBAAwB,UAAqB,CAAC"}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jira Cloud OAuth 2.0 (3LO) scopes published by Atlassian. Keep
|
|
3
|
+
* `offline_access` out of this list because it is always added by the OAuth
|
|
4
|
+
* implementation and is not a Jira API permission.
|
|
5
|
+
*/
|
|
6
|
+
export const ATLASSIAN_SCOPES = [
|
|
7
|
+
'read:jira-user',
|
|
8
|
+
'read:jira-work',
|
|
9
|
+
'write:jira-work',
|
|
10
|
+
'manage:jira-project',
|
|
11
|
+
'manage:jira-configuration',
|
|
12
|
+
'manage:jira-webhook',
|
|
13
|
+
'read:application-role:jira',
|
|
14
|
+
'read:audit-log:jira',
|
|
15
|
+
'read:avatar:jira',
|
|
16
|
+
'write:avatar:jira',
|
|
17
|
+
'delete:avatar:jira',
|
|
18
|
+
'read:project.avatar:jira',
|
|
19
|
+
'write:project.avatar:jira',
|
|
20
|
+
'delete:project.avatar:jira',
|
|
21
|
+
'read:dashboard:jira',
|
|
22
|
+
'write:dashboard:jira',
|
|
23
|
+
'delete:dashboard:jira',
|
|
24
|
+
'read:dashboard.property:jira',
|
|
25
|
+
'write:dashboard.property:jira',
|
|
26
|
+
'delete:dashboard.property:jira',
|
|
27
|
+
'read:filter:jira',
|
|
28
|
+
'write:filter:jira',
|
|
29
|
+
'delete:filter:jira',
|
|
30
|
+
'read:filter.column:jira',
|
|
31
|
+
'write:filter.column:jira',
|
|
32
|
+
'delete:filter.column:jira',
|
|
33
|
+
'read:filter.default-share-scope:jira',
|
|
34
|
+
'write:filter.default-share-scope:jira',
|
|
35
|
+
'read:group:jira',
|
|
36
|
+
'write:group:jira',
|
|
37
|
+
'delete:group:jira',
|
|
38
|
+
'read:license:jira',
|
|
39
|
+
'read:issue:jira',
|
|
40
|
+
'write:issue:jira',
|
|
41
|
+
'delete:issue:jira',
|
|
42
|
+
'read:issue-meta:jira',
|
|
43
|
+
'send:notification:jira',
|
|
44
|
+
'read:attachment:jira',
|
|
45
|
+
'write:attachment:jira',
|
|
46
|
+
'delete:attachment:jira',
|
|
47
|
+
'read:comment:jira',
|
|
48
|
+
'write:comment:jira',
|
|
49
|
+
'delete:comment:jira',
|
|
50
|
+
'read:comment.property:jira',
|
|
51
|
+
'write:comment.property:jira',
|
|
52
|
+
'delete:comment.property:jira',
|
|
53
|
+
'read:field:jira',
|
|
54
|
+
'write:field:jira',
|
|
55
|
+
'delete:field:jira',
|
|
56
|
+
'read:field.default-value:jira',
|
|
57
|
+
'write:field.default-value:jira',
|
|
58
|
+
'read:field.option:jira',
|
|
59
|
+
'write:field.option:jira',
|
|
60
|
+
'delete:field.option:jira',
|
|
61
|
+
'read:field-configuration-scheme:jira',
|
|
62
|
+
'write:field-configuration-scheme:jira',
|
|
63
|
+
'delete:field-configuration-scheme:jira',
|
|
64
|
+
'read:custom-field-contextual-configuration:jira',
|
|
65
|
+
'write:custom-field-contextual-configuration:jira',
|
|
66
|
+
'read:field-configuration:jira',
|
|
67
|
+
'write:field-configuration:jira',
|
|
68
|
+
'delete:field-configuration:jira',
|
|
69
|
+
'read:field.options:jira',
|
|
70
|
+
'read:issue-link:jira',
|
|
71
|
+
'write:issue-link:jira',
|
|
72
|
+
'delete:issue-link:jira',
|
|
73
|
+
'read:issue-link-type:jira',
|
|
74
|
+
'write:issue-link-type:jira',
|
|
75
|
+
'delete:issue-link-type:jira',
|
|
76
|
+
'read:notification-scheme:jira',
|
|
77
|
+
'read:priority:jira',
|
|
78
|
+
'read:issue.property:jira',
|
|
79
|
+
'write:issue.property:jira',
|
|
80
|
+
'delete:issue.property:jira',
|
|
81
|
+
'read:issue.remote-link:jira',
|
|
82
|
+
'write:issue.remote-link:jira',
|
|
83
|
+
'delete:issue.remote-link:jira',
|
|
84
|
+
'read:resolution:jira',
|
|
85
|
+
'read:issue-details:jira',
|
|
86
|
+
'read:issue-security-scheme:jira',
|
|
87
|
+
'read:issue-type:jira',
|
|
88
|
+
'write:issue-type:jira',
|
|
89
|
+
'delete:issue-type:jira',
|
|
90
|
+
'read:issue-type-scheme:jira',
|
|
91
|
+
'write:issue-type-scheme:jira',
|
|
92
|
+
'delete:issue-type-scheme:jira',
|
|
93
|
+
'read:issue-type-screen-scheme:jira',
|
|
94
|
+
'write:issue-type-screen-scheme:jira',
|
|
95
|
+
'delete:issue-type-screen-scheme:jira',
|
|
96
|
+
'read:issue-type.property:jira',
|
|
97
|
+
'write:issue-type.property:jira',
|
|
98
|
+
'delete:issue-type.property:jira',
|
|
99
|
+
'read:issue.watcher:jira',
|
|
100
|
+
'write:issue.watcher:jira',
|
|
101
|
+
'read:issue-worklog:jira',
|
|
102
|
+
'write:issue-worklog:jira',
|
|
103
|
+
'delete:issue-worklog:jira',
|
|
104
|
+
'read:issue-worklog.property:jira',
|
|
105
|
+
'write:issue-worklog.property:jira',
|
|
106
|
+
'delete:issue-worklog.property:jira',
|
|
107
|
+
'read:issue-field-values:jira',
|
|
108
|
+
'read:issue-security-level:jira',
|
|
109
|
+
'read:issue-status:jira',
|
|
110
|
+
'read:issue-type-hierarchy:jira',
|
|
111
|
+
'read:issue-type-transition:jira',
|
|
112
|
+
'read:issue.changelog:jira',
|
|
113
|
+
'read:issue.transition:jira',
|
|
114
|
+
'write:issue.vote:jira',
|
|
115
|
+
'read:issue-event:jira',
|
|
116
|
+
'read:jira-expressions:jira',
|
|
117
|
+
'read:user:jira',
|
|
118
|
+
'read:user.columns:jira',
|
|
119
|
+
'read:label:jira',
|
|
120
|
+
'read:permission:jira',
|
|
121
|
+
'write:permission:jira',
|
|
122
|
+
'delete:permission:jira',
|
|
123
|
+
'read:permission-scheme:jira',
|
|
124
|
+
'write:permission-scheme:jira',
|
|
125
|
+
'delete:permission-scheme:jira',
|
|
126
|
+
'read:project:jira',
|
|
127
|
+
'write:project:jira',
|
|
128
|
+
'delete:project:jira',
|
|
129
|
+
'read:project-category:jira',
|
|
130
|
+
'write:project-category:jira',
|
|
131
|
+
'delete:project-category:jira',
|
|
132
|
+
'read:project.component:jira',
|
|
133
|
+
'write:project.component:jira',
|
|
134
|
+
'delete:project.component:jira',
|
|
135
|
+
'read:project.property:jira',
|
|
136
|
+
'write:project.property:jira',
|
|
137
|
+
'delete:project.property:jira',
|
|
138
|
+
'read:project-role:jira',
|
|
139
|
+
'write:project-role:jira',
|
|
140
|
+
'delete:project-role:jira',
|
|
141
|
+
'read:project-version:jira',
|
|
142
|
+
'write:project-version:jira',
|
|
143
|
+
'delete:project-version:jira',
|
|
144
|
+
'read:project.feature:jira',
|
|
145
|
+
'write:project.feature:jira',
|
|
146
|
+
'read:screen:jira',
|
|
147
|
+
'write:screen:jira',
|
|
148
|
+
'delete:screen:jira',
|
|
149
|
+
'read:screen-scheme:jira',
|
|
150
|
+
'write:screen-scheme:jira',
|
|
151
|
+
'delete:screen-scheme:jira',
|
|
152
|
+
'read:screen-field:jira',
|
|
153
|
+
'read:screen-tab:jira',
|
|
154
|
+
'write:screen-tab:jira',
|
|
155
|
+
'delete:screen-tab:jira',
|
|
156
|
+
'read:screenable-field:jira',
|
|
157
|
+
'write:screenable-field:jira',
|
|
158
|
+
'delete:screenable-field:jira',
|
|
159
|
+
'read:issue.time-tracking:jira',
|
|
160
|
+
'write:issue.time-tracking:jira',
|
|
161
|
+
'read:user.property:jira',
|
|
162
|
+
'write:user.property:jira',
|
|
163
|
+
'delete:user.property:jira',
|
|
164
|
+
'read:webhook:jira',
|
|
165
|
+
'write:webhook:jira',
|
|
166
|
+
'delete:webhook:jira',
|
|
167
|
+
'read:workflow:jira',
|
|
168
|
+
'write:workflow:jira',
|
|
169
|
+
'delete:workflow:jira',
|
|
170
|
+
'read:workflow-scheme:jira',
|
|
171
|
+
'write:workflow-scheme:jira',
|
|
172
|
+
'delete:workflow-scheme:jira',
|
|
173
|
+
'read:status:jira',
|
|
174
|
+
'read:workflow.property:jira',
|
|
175
|
+
'write:workflow.property:jira',
|
|
176
|
+
'delete:workflow.property:jira',
|
|
177
|
+
'delete:async-task:jira',
|
|
178
|
+
'read:instance-configuration:jira',
|
|
179
|
+
'write:instance-configuration:jira',
|
|
180
|
+
'read:jql:jira',
|
|
181
|
+
'validate:jql:jira',
|
|
182
|
+
'read:project-type:jira',
|
|
183
|
+
'read:project.email:jira',
|
|
184
|
+
'write:project.email:jira',
|
|
185
|
+
'read:role:jira',
|
|
186
|
+
'read:user-configuration:jira',
|
|
187
|
+
'write:user-configuration:jira',
|
|
188
|
+
'delete:user-configuration:jira',
|
|
189
|
+
'read:email-address:jira',
|
|
190
|
+
// Confluence classic scopes.
|
|
191
|
+
'write:confluence-content',
|
|
192
|
+
'read:confluence-space.summary',
|
|
193
|
+
'write:confluence-space',
|
|
194
|
+
'write:confluence-file',
|
|
195
|
+
'read:confluence-props',
|
|
196
|
+
'write:confluence-props',
|
|
197
|
+
'manage:confluence-configuration',
|
|
198
|
+
'read:confluence-content.all',
|
|
199
|
+
'read:confluence-content.summary',
|
|
200
|
+
'search:confluence',
|
|
201
|
+
'read:confluence-content.permission',
|
|
202
|
+
'read:confluence-user',
|
|
203
|
+
'read:confluence-groups',
|
|
204
|
+
'write:confluence-groups',
|
|
205
|
+
'readonly:content.attachment:confluence',
|
|
206
|
+
// Confluence granular scopes.
|
|
207
|
+
'read:content:confluence',
|
|
208
|
+
'read:content-details:confluence',
|
|
209
|
+
'write:content:confluence',
|
|
210
|
+
'delete:content:confluence',
|
|
211
|
+
'read:space-details:confluence',
|
|
212
|
+
'read:analytics.content:confluence',
|
|
213
|
+
'read:audit-log:confluence',
|
|
214
|
+
'write:audit-log:confluence',
|
|
215
|
+
'read:configuration:confluence',
|
|
216
|
+
'write:configuration:confluence',
|
|
217
|
+
'read:page:confluence',
|
|
218
|
+
'write:page:confluence',
|
|
219
|
+
'delete:page:confluence',
|
|
220
|
+
'read:blogpost:confluence',
|
|
221
|
+
'write:blogpost:confluence',
|
|
222
|
+
'delete:blogpost:confluence',
|
|
223
|
+
'read:whiteboard:confluence',
|
|
224
|
+
'write:whiteboard:confluence',
|
|
225
|
+
'delete:whiteboard:confluence',
|
|
226
|
+
'read:database:confluence',
|
|
227
|
+
'write:database:confluence',
|
|
228
|
+
'delete:database:confluence',
|
|
229
|
+
'read:embed:confluence',
|
|
230
|
+
'write:embed:confluence',
|
|
231
|
+
'delete:embed:confluence',
|
|
232
|
+
'read:folder:confluence',
|
|
233
|
+
'write:folder:confluence',
|
|
234
|
+
'delete:folder:confluence',
|
|
235
|
+
'read:custom-content:confluence',
|
|
236
|
+
'write:custom-content:confluence',
|
|
237
|
+
'delete:custom-content:confluence',
|
|
238
|
+
'read:attachment:confluence',
|
|
239
|
+
'write:attachment:confluence',
|
|
240
|
+
'delete:attachment:confluence',
|
|
241
|
+
'read:comment:confluence',
|
|
242
|
+
'write:comment:confluence',
|
|
243
|
+
'delete:comment:confluence',
|
|
244
|
+
'read:template:confluence',
|
|
245
|
+
'write:template:confluence',
|
|
246
|
+
'read:label:confluence',
|
|
247
|
+
'write:label:confluence',
|
|
248
|
+
'read:content.permission:confluence',
|
|
249
|
+
'read:content.property:confluence',
|
|
250
|
+
'write:content.property:confluence',
|
|
251
|
+
'read:content.restriction:confluence',
|
|
252
|
+
'write:content.restriction:confluence',
|
|
253
|
+
'read:content.metadata:confluence',
|
|
254
|
+
'read:hierarchical-content:confluence',
|
|
255
|
+
'read:watcher:confluence',
|
|
256
|
+
'write:watcher:confluence',
|
|
257
|
+
'read:group:confluence',
|
|
258
|
+
'write:group:confluence',
|
|
259
|
+
'read:inlinetask:confluence',
|
|
260
|
+
'write:inlinetask:confluence',
|
|
261
|
+
'read:relation:confluence',
|
|
262
|
+
'write:relation:confluence',
|
|
263
|
+
'read:space:confluence',
|
|
264
|
+
'write:space:confluence',
|
|
265
|
+
'delete:space:confluence',
|
|
266
|
+
'read:space.permission:confluence',
|
|
267
|
+
'write:space.permission:confluence',
|
|
268
|
+
'read:space.property:confluence',
|
|
269
|
+
'write:space.property:confluence',
|
|
270
|
+
'read:user.property:confluence',
|
|
271
|
+
'write:user.property:confluence',
|
|
272
|
+
'read:space.setting:confluence',
|
|
273
|
+
'write:space.setting:confluence',
|
|
274
|
+
'read:user:confluence',
|
|
275
|
+
'read:task:confluence',
|
|
276
|
+
'write:task:confluence',
|
|
277
|
+
'read:email-address:confluence',
|
|
278
|
+
];
|
|
279
|
+
export const ATLASSIAN_SCOPE_OPTIONS = ATLASSIAN_SCOPES.map((scope) => ({
|
|
280
|
+
label: scope,
|
|
281
|
+
value: scope,
|
|
282
|
+
}));
|
|
283
|
+
export const ATLASSIAN_DEFAULT_SCOPES = ['offline_access'];
|
package/docs/setup.md
CHANGED
|
@@ -47,9 +47,9 @@ this package on every authorization — you don't add it here.
|
|
|
47
47
|
|
|
48
48
|
1. Go to **Authorization** in the sidebar.
|
|
49
49
|
2. Under **Callback URLs**, add your Kosha instance's connect callback for
|
|
50
|
-
this provider: `{KOSHA_PUBLIC_URL}/api/connect/callback/atlassian
|
|
50
|
+
this provider: `{KOSHA_PUBLIC_URL}/api/connect/callback/atlassian`
|
|
51
51
|
(for local testing this is typically
|
|
52
|
-
`http://localhost:3333/api/connect/callback/atlassian
|
|
52
|
+
`http://localhost:3333/api/connect/callback/atlassian`).
|
|
53
53
|
3. Click **Save changes**.
|
|
54
54
|
|
|
55
55
|

|
|
@@ -89,10 +89,12 @@ site per connection:
|
|
|
89
89
|
integration:
|
|
90
90
|
|
|
91
91
|
```ts
|
|
92
|
-
import {
|
|
92
|
+
import { atlassian } from '@kosha-ai/integration-atlassian';
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
atlassian({ siteUrl: 'https://acme.atlassian.net' });
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
The resolved site's cloudId is stored on the connection
|
|
98
|
-
|
|
97
|
+
The resolved site's cloudId is stored on the connection. The proxy base remains
|
|
98
|
+
`https://api.atlassian.com`, and each API request supplies its product path:
|
|
99
|
+
`/ex/jira/{cloudId}/...` for Jira or `/ex/confluence/{cloudId}/...` for
|
|
100
|
+
Confluence.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
-- The public integration key changed from `atlassian-jira` to `atlassian`.
|
|
2
|
+
-- Keep existing configurations and connections when the package is upgraded.
|
|
3
|
+
ALTER TABLE "atlassian_jira_configuration"
|
|
4
|
+
RENAME TO "atlassian_configuration";
|
|
5
|
+
|
|
6
|
+
ALTER TABLE "atlassian_jira_connection"
|
|
7
|
+
RENAME TO "atlassian_connection";
|
|
8
|
+
|
|
9
|
+
ALTER TABLE "atlassian_configuration"
|
|
10
|
+
RENAME CONSTRAINT "atlassian_jira_configuration_pkey"
|
|
11
|
+
TO "atlassian_configuration_pkey";
|
|
12
|
+
|
|
13
|
+
ALTER TABLE "atlassian_connection"
|
|
14
|
+
RENAME CONSTRAINT "atlassian_jira_connection_pkey"
|
|
15
|
+
TO "atlassian_connection_pkey";
|
|
16
|
+
|
|
17
|
+
ALTER INDEX "atlassian_jira_configuration_environmentId_slug_key"
|
|
18
|
+
RENAME TO "atlassian_configuration_environmentId_slug_key";
|
|
19
|
+
|
|
20
|
+
ALTER INDEX "atlassian_jira_configuration_environmentId_idx"
|
|
21
|
+
RENAME TO "atlassian_configuration_environmentId_idx";
|
|
22
|
+
|
|
23
|
+
ALTER INDEX "atlassian_jira_connection_environmentId_configurationId_use_key"
|
|
24
|
+
RENAME TO "atlassian_connection_environmentId_configurationId_use_key";
|
|
25
|
+
|
|
26
|
+
ALTER INDEX "atlassian_jira_connection_environmentId_idx"
|
|
27
|
+
RENAME TO "atlassian_connection_environmentId_idx";
|
|
28
|
+
|
|
29
|
+
ALTER INDEX "atlassian_jira_connection_configurationId_idx"
|
|
30
|
+
RENAME TO "atlassian_connection_configurationId_idx";
|
|
31
|
+
|
|
32
|
+
ALTER INDEX "atlassian_jira_connection_userId_idx"
|
|
33
|
+
RENAME TO "atlassian_connection_userId_idx";
|
|
34
|
+
|
|
35
|
+
ALTER TABLE "atlassian_configuration"
|
|
36
|
+
RENAME CONSTRAINT "atlassian_jira_configuration_environmentId_fkey"
|
|
37
|
+
TO "atlassian_configuration_environmentId_fkey";
|
|
38
|
+
|
|
39
|
+
ALTER TABLE "atlassian_connection"
|
|
40
|
+
RENAME CONSTRAINT "atlassian_jira_connection_accountId_fkey"
|
|
41
|
+
TO "atlassian_connection_accountId_fkey";
|
|
42
|
+
|
|
43
|
+
ALTER TABLE "atlassian_connection"
|
|
44
|
+
RENAME CONSTRAINT "atlassian_jira_connection_userId_fkey"
|
|
45
|
+
TO "atlassian_connection_userId_fkey";
|
|
46
|
+
|
|
47
|
+
ALTER TABLE "atlassian_connection"
|
|
48
|
+
RENAME CONSTRAINT "atlassian_jira_connection_environmentId_fkey"
|
|
49
|
+
TO "atlassian_connection_environmentId_fkey";
|
|
50
|
+
|
|
51
|
+
ALTER TABLE "atlassian_connection"
|
|
52
|
+
RENAME CONSTRAINT "atlassian_jira_connection_configurationId_fkey"
|
|
53
|
+
TO "atlassian_connection_configurationId_fkey";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosha-ai/integration-atlassian",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "Atlassian
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "Atlassian integration for Kosha",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kosha",
|
|
7
7
|
"atlassian",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
},
|
|
48
48
|
"kosha": {
|
|
49
49
|
"kind": "integration",
|
|
50
|
-
"key": "atlassian
|
|
50
|
+
"key": "atlassian"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@kosha-ai/integration-sdk": "0.5.
|
|
53
|
+
"@kosha-ai/integration-sdk": "0.5.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@kosha-ai/integration-sdk": "0.5.
|
|
56
|
+
"@kosha-ai/integration-sdk": "0.5.1"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { KoshaIntegration } from '@kosha-ai/integration-sdk';
|
|
2
|
-
export interface AtlassianJiraIntegrationOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Pin the connection to one Jira site instead of taking the first one the
|
|
5
|
-
* granting user has access to. Match against the site's URL as returned by
|
|
6
|
-
* `accessible-resources` (e.g. `https://acme.atlassian.net`).
|
|
7
|
-
*/
|
|
8
|
-
siteUrl?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare function atlassianJira(options?: AtlassianJiraIntegrationOptions): KoshaIntegration;
|
|
11
|
-
export default atlassianJira;
|
|
12
|
-
//# sourceMappingURL=integration-atlassian-jira.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"integration-atlassian-jira.d.ts","sourceRoot":"","sources":["../../src/lib/integration-atlassian-jira.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAUlE,MAAM,WAAW,+BAA+B;IAC9C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAqBD,wBAAgB,aAAa,CAC3B,OAAO,GAAE,+BAAoC,GAC5C,gBAAgB,CAkElB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { defineIntegration, packageDirs } from '@kosha-ai/integration-sdk';
|
|
2
|
-
import { atlassianOAuth, getAccessibleResources, selectResource, } from './atlassian-oauth.js';
|
|
3
|
-
const { docsPath, migrationsPath } = packageDirs(import.meta.url);
|
|
4
|
-
/**
|
|
5
|
-
* Least-privilege scope set for the operations Gather and Alkahest actually
|
|
6
|
-
* perform against Jira: read/write issues and projects, read the current
|
|
7
|
-
* user, and manage the webhooks that drive incremental sync. Nothing here
|
|
8
|
-
* grants Jira Service Management, admin, or Confluence access.
|
|
9
|
-
*/
|
|
10
|
-
const SCOPES = [
|
|
11
|
-
'read:jira-work',
|
|
12
|
-
'write:jira-work',
|
|
13
|
-
'read:jira-user',
|
|
14
|
-
'manage:jira-webhook',
|
|
15
|
-
];
|
|
16
|
-
export function atlassianJira(options = {}) {
|
|
17
|
-
const auth = atlassianOAuth({ scopesAvailable: SCOPES });
|
|
18
|
-
return defineIntegration({
|
|
19
|
-
key: 'atlassian-jira',
|
|
20
|
-
name: 'Jira',
|
|
21
|
-
docsUrl: 'https://developer.atlassian.com/cloud/jira/platform/rest/v3/',
|
|
22
|
-
docsPath,
|
|
23
|
-
migrationsPath,
|
|
24
|
-
auth,
|
|
25
|
-
api: {
|
|
26
|
-
// Every Jira Cloud REST call is routed through this per-site path —
|
|
27
|
-
// there is no host that works without a resolved cloudId, so there is
|
|
28
|
-
// no static baseUrl to fall back to.
|
|
29
|
-
resolveBaseUrl: ({ metadata }) => {
|
|
30
|
-
const cloudId = metadata?.['cloudId'];
|
|
31
|
-
return typeof cloudId === 'string'
|
|
32
|
-
? `https://api.atlassian.com/ex/jira/${cloudId}`
|
|
33
|
-
: undefined;
|
|
34
|
-
},
|
|
35
|
-
authHeaders: ({ accessToken }) => ({
|
|
36
|
-
Authorization: `Bearer ${accessToken}`,
|
|
37
|
-
Accept: 'application/json',
|
|
38
|
-
}),
|
|
39
|
-
egress: [{ hosts: ['api.atlassian.com'] }],
|
|
40
|
-
},
|
|
41
|
-
identity: {
|
|
42
|
-
async fetchAccount({ accessToken }) {
|
|
43
|
-
const resources = await getAccessibleResources(accessToken);
|
|
44
|
-
const site = selectResource(resources, options.siteUrl);
|
|
45
|
-
const response = await fetch(`https://api.atlassian.com/ex/jira/${site.id}/rest/api/3/myself`, {
|
|
46
|
-
headers: {
|
|
47
|
-
Authorization: `Bearer ${accessToken}`,
|
|
48
|
-
Accept: 'application/json',
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
if (!response.ok) {
|
|
52
|
-
throw new Error(`Failed to fetch Jira current user: HTTP ${response.status}`);
|
|
53
|
-
}
|
|
54
|
-
const user = (await response.json());
|
|
55
|
-
return {
|
|
56
|
-
// Composite id: the same Atlassian account can hold a connection
|
|
57
|
-
// per site, and cloudId alone would collide across sites while
|
|
58
|
-
// accountId alone would collide across a user's sites.
|
|
59
|
-
externalAccountId: `${site.id}:${user.accountId}`,
|
|
60
|
-
label: `${user.displayName} — ${site.name}`,
|
|
61
|
-
metadata: {
|
|
62
|
-
cloudId: site.id,
|
|
63
|
-
siteUrl: site.url,
|
|
64
|
-
siteName: site.name,
|
|
65
|
-
accountId: user.accountId,
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
export default atlassianJira;
|