@stoneforge/quarry 1.12.0 → 1.13.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/README.md +2 -0
- package/dist/cli/commands/auto-link-helper.d.ts +33 -0
- package/dist/cli/commands/auto-link-helper.d.ts.map +1 -0
- package/dist/cli/commands/auto-link-helper.js +73 -0
- package/dist/cli/commands/auto-link-helper.js.map +1 -0
- package/dist/cli/commands/crud.d.ts +1 -0
- package/dist/cli/commands/crud.d.ts.map +1 -1
- package/dist/cli/commands/crud.js +44 -5
- package/dist/cli/commands/crud.js.map +1 -1
- package/dist/cli/commands/external-sync.d.ts +17 -0
- package/dist/cli/commands/external-sync.d.ts.map +1 -0
- package/dist/cli/commands/external-sync.js +1647 -0
- package/dist/cli/commands/external-sync.js.map +1 -0
- package/dist/cli/runner.d.ts.map +1 -1
- package/dist/cli/runner.js +3 -0
- package/dist/cli/runner.js.map +1 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +28 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/defaults.d.ts +13 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +21 -0
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/file.d.ts.map +1 -1
- package/dist/config/file.js +61 -0
- package/dist/config/file.js.map +1 -1
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +2 -2
- package/dist/config/index.js.map +1 -1
- package/dist/config/merge.d.ts.map +1 -1
- package/dist/config/merge.js +46 -1
- package/dist/config/merge.js.map +1 -1
- package/dist/config/types.d.ts +63 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +30 -0
- package/dist/config/types.js.map +1 -1
- package/dist/config/validation.d.ts.map +1 -1
- package/dist/config/validation.js +51 -1
- package/dist/config/validation.js.map +1 -1
- package/dist/external-sync/adapters/task-sync-adapter.d.ts +177 -0
- package/dist/external-sync/adapters/task-sync-adapter.d.ts.map +1 -0
- package/dist/external-sync/adapters/task-sync-adapter.js +353 -0
- package/dist/external-sync/adapters/task-sync-adapter.js.map +1 -0
- package/dist/external-sync/auto-link.d.ts +66 -0
- package/dist/external-sync/auto-link.d.ts.map +1 -0
- package/dist/external-sync/auto-link.js +98 -0
- package/dist/external-sync/auto-link.js.map +1 -0
- package/dist/external-sync/conflict-resolver.d.ts +170 -0
- package/dist/external-sync/conflict-resolver.d.ts.map +1 -0
- package/dist/external-sync/conflict-resolver.js +580 -0
- package/dist/external-sync/conflict-resolver.js.map +1 -0
- package/dist/external-sync/index.d.ts +20 -0
- package/dist/external-sync/index.d.ts.map +1 -0
- package/dist/external-sync/index.js +20 -0
- package/dist/external-sync/index.js.map +1 -0
- package/dist/external-sync/provider-registry.d.ts +109 -0
- package/dist/external-sync/provider-registry.d.ts.map +1 -0
- package/dist/external-sync/provider-registry.js +188 -0
- package/dist/external-sync/provider-registry.js.map +1 -0
- package/dist/external-sync/providers/github/github-api.d.ts +271 -0
- package/dist/external-sync/providers/github/github-api.d.ts.map +1 -0
- package/dist/external-sync/providers/github/github-api.js +366 -0
- package/dist/external-sync/providers/github/github-api.js.map +1 -0
- package/dist/external-sync/providers/github/github-field-map.d.ts +76 -0
- package/dist/external-sync/providers/github/github-field-map.d.ts.map +1 -0
- package/dist/external-sync/providers/github/github-field-map.js +157 -0
- package/dist/external-sync/providers/github/github-field-map.js.map +1 -0
- package/dist/external-sync/providers/github/github-provider.d.ts +36 -0
- package/dist/external-sync/providers/github/github-provider.d.ts.map +1 -0
- package/dist/external-sync/providers/github/github-provider.js +212 -0
- package/dist/external-sync/providers/github/github-provider.js.map +1 -0
- package/dist/external-sync/providers/github/github-task-adapter.d.ts +135 -0
- package/dist/external-sync/providers/github/github-task-adapter.d.ts.map +1 -0
- package/dist/external-sync/providers/github/github-task-adapter.js +374 -0
- package/dist/external-sync/providers/github/github-task-adapter.js.map +1 -0
- package/dist/external-sync/providers/github/index.d.ts +12 -0
- package/dist/external-sync/providers/github/index.d.ts.map +1 -0
- package/dist/external-sync/providers/github/index.js +15 -0
- package/dist/external-sync/providers/github/index.js.map +1 -0
- package/dist/external-sync/providers/index.d.ts +9 -0
- package/dist/external-sync/providers/index.d.ts.map +1 -0
- package/dist/external-sync/providers/index.js +10 -0
- package/dist/external-sync/providers/index.js.map +1 -0
- package/dist/external-sync/providers/linear/index.d.ts +19 -0
- package/dist/external-sync/providers/linear/index.d.ts.map +1 -0
- package/dist/external-sync/providers/linear/index.js +19 -0
- package/dist/external-sync/providers/linear/index.js.map +1 -0
- package/dist/external-sync/providers/linear/linear-api.d.ts +252 -0
- package/dist/external-sync/providers/linear/linear-api.d.ts.map +1 -0
- package/dist/external-sync/providers/linear/linear-api.js +522 -0
- package/dist/external-sync/providers/linear/linear-api.js.map +1 -0
- package/dist/external-sync/providers/linear/linear-field-map.d.ts +135 -0
- package/dist/external-sync/providers/linear/linear-field-map.d.ts.map +1 -0
- package/dist/external-sync/providers/linear/linear-field-map.js +338 -0
- package/dist/external-sync/providers/linear/linear-field-map.js.map +1 -0
- package/dist/external-sync/providers/linear/linear-provider.d.ts +52 -0
- package/dist/external-sync/providers/linear/linear-provider.d.ts.map +1 -0
- package/dist/external-sync/providers/linear/linear-provider.js +169 -0
- package/dist/external-sync/providers/linear/linear-provider.js.map +1 -0
- package/dist/external-sync/providers/linear/linear-task-adapter.d.ts +190 -0
- package/dist/external-sync/providers/linear/linear-task-adapter.d.ts.map +1 -0
- package/dist/external-sync/providers/linear/linear-task-adapter.js +521 -0
- package/dist/external-sync/providers/linear/linear-task-adapter.js.map +1 -0
- package/dist/external-sync/providers/linear/linear-types.d.ts +114 -0
- package/dist/external-sync/providers/linear/linear-types.d.ts.map +1 -0
- package/dist/external-sync/providers/linear/linear-types.js +10 -0
- package/dist/external-sync/providers/linear/linear-types.js.map +1 -0
- package/dist/external-sync/sync-engine.d.ts +298 -0
- package/dist/external-sync/sync-engine.d.ts.map +1 -0
- package/dist/external-sync/sync-engine.js +785 -0
- package/dist/external-sync/sync-engine.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/services/inbox.js +1 -1
- package/dist/sync/hash.d.ts +5 -0
- package/dist/sync/hash.d.ts.map +1 -1
- package/dist/sync/hash.js +21 -2
- package/dist/sync/hash.js.map +1 -1
- package/package.json +11 -5
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Provider
|
|
3
|
+
*
|
|
4
|
+
* Full implementation of the GitHub ExternalProvider.
|
|
5
|
+
* Handles connection testing via the GitHub API and provides
|
|
6
|
+
* a TaskSyncAdapter for bidirectional task/issue synchronization.
|
|
7
|
+
*
|
|
8
|
+
* The provider uses a lazy-initialized GitHubTaskAdapter that
|
|
9
|
+
* requires a ProviderConfig with a valid token before use.
|
|
10
|
+
*
|
|
11
|
+
* Also exports the placeholder provider for backward compatibility
|
|
12
|
+
* with systems that register the provider before configuration.
|
|
13
|
+
*/
|
|
14
|
+
import { GitHubTaskAdapter } from './github-task-adapter.js';
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// GitHub Provider (Full Implementation)
|
|
17
|
+
// ============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* GitHub ExternalProvider implementation.
|
|
20
|
+
*
|
|
21
|
+
* Provides connection testing and a TaskSyncAdapter for GitHub Issues.
|
|
22
|
+
* The task adapter is created on demand with the configured token.
|
|
23
|
+
*
|
|
24
|
+
* Usage:
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const provider = createGitHubProvider({ token: 'ghp_...' });
|
|
27
|
+
* const connected = await provider.testConnection(config);
|
|
28
|
+
* const adapter = provider.getTaskAdapter();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
class GitHubProvider {
|
|
32
|
+
name = 'github';
|
|
33
|
+
displayName = 'GitHub';
|
|
34
|
+
supportedAdapters = ['task'];
|
|
35
|
+
taskAdapter = null;
|
|
36
|
+
config;
|
|
37
|
+
constructor(config) {
|
|
38
|
+
this.config = config;
|
|
39
|
+
// Initialize the task adapter if a token is available
|
|
40
|
+
if (config.token) {
|
|
41
|
+
this.taskAdapter = new GitHubTaskAdapter({
|
|
42
|
+
token: config.token,
|
|
43
|
+
apiBaseUrl: config.apiBaseUrl,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Test whether the GitHub connection is valid by calling GET /user.
|
|
49
|
+
*
|
|
50
|
+
* This verifies that the configured token is valid and has the
|
|
51
|
+
* necessary permissions to access the GitHub API.
|
|
52
|
+
*
|
|
53
|
+
* @param config - Provider configuration with token to test
|
|
54
|
+
* @returns true if the connection is valid, false otherwise
|
|
55
|
+
*/
|
|
56
|
+
async testConnection(config) {
|
|
57
|
+
if (!config.token) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const baseUrl = (config.apiBaseUrl ?? 'https://api.github.com').replace(/\/$/, '');
|
|
61
|
+
try {
|
|
62
|
+
const response = await fetch(`${baseUrl}/user`, {
|
|
63
|
+
method: 'GET',
|
|
64
|
+
headers: {
|
|
65
|
+
Authorization: `Bearer ${config.token}`,
|
|
66
|
+
Accept: 'application/vnd.github+json',
|
|
67
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
return response.ok;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// Network errors, DNS failures, etc.
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the GitHubTaskAdapter instance.
|
|
79
|
+
*
|
|
80
|
+
* The adapter is initialized with the token from the provider config.
|
|
81
|
+
* Throws if no token was configured (provider not yet set up).
|
|
82
|
+
*
|
|
83
|
+
* @returns GitHubTaskAdapter for GitHub Issues sync
|
|
84
|
+
* @throws Error if no token is configured
|
|
85
|
+
*/
|
|
86
|
+
getTaskAdapter() {
|
|
87
|
+
if (!this.taskAdapter) {
|
|
88
|
+
throw new Error('GitHub provider is not configured. Set a token via provider config before using the task adapter.');
|
|
89
|
+
}
|
|
90
|
+
return this.taskAdapter;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// Placeholder Provider (Backward Compatibility)
|
|
95
|
+
// ============================================================================
|
|
96
|
+
/**
|
|
97
|
+
* Placeholder TaskSyncAdapter for GitHub.
|
|
98
|
+
* All methods throw to indicate they are not yet implemented.
|
|
99
|
+
* Used when the provider is registered without configuration.
|
|
100
|
+
*/
|
|
101
|
+
class GitHubPlaceholderTaskAdapter {
|
|
102
|
+
static PLACEHOLDER_MESSAGE = 'GitHub task sync adapter is not configured. Set a token via provider config to enable sync.';
|
|
103
|
+
async getIssue(_project, _externalId) {
|
|
104
|
+
throw new Error(GitHubPlaceholderTaskAdapter.PLACEHOLDER_MESSAGE);
|
|
105
|
+
}
|
|
106
|
+
async listIssuesSince(_project, _since) {
|
|
107
|
+
throw new Error(GitHubPlaceholderTaskAdapter.PLACEHOLDER_MESSAGE);
|
|
108
|
+
}
|
|
109
|
+
async createIssue(_project, _issue) {
|
|
110
|
+
throw new Error(GitHubPlaceholderTaskAdapter.PLACEHOLDER_MESSAGE);
|
|
111
|
+
}
|
|
112
|
+
async updateIssue(_project, _externalId, _updates) {
|
|
113
|
+
throw new Error(GitHubPlaceholderTaskAdapter.PLACEHOLDER_MESSAGE);
|
|
114
|
+
}
|
|
115
|
+
getFieldMapConfig() {
|
|
116
|
+
return {
|
|
117
|
+
provider: 'github',
|
|
118
|
+
fields: [
|
|
119
|
+
{
|
|
120
|
+
localField: 'title',
|
|
121
|
+
externalField: 'title',
|
|
122
|
+
direction: 'bidirectional',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
localField: 'descriptionRef',
|
|
126
|
+
externalField: 'body',
|
|
127
|
+
direction: 'bidirectional',
|
|
128
|
+
toExternal: 'hydrateDescription',
|
|
129
|
+
toLocal: 'createDescriptionDoc',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
localField: 'status',
|
|
133
|
+
externalField: 'state',
|
|
134
|
+
direction: 'bidirectional',
|
|
135
|
+
toExternal: 'statusToGitHubState',
|
|
136
|
+
toLocal: 'gitHubStateToStatus',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
localField: 'tags',
|
|
140
|
+
externalField: 'labels',
|
|
141
|
+
direction: 'bidirectional',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
localField: 'priority',
|
|
145
|
+
externalField: 'labels',
|
|
146
|
+
direction: 'bidirectional',
|
|
147
|
+
toExternal: 'priorityToLabel',
|
|
148
|
+
toLocal: 'labelToPriority',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
localField: 'taskType',
|
|
152
|
+
externalField: 'labels',
|
|
153
|
+
direction: 'bidirectional',
|
|
154
|
+
toExternal: 'taskTypeToLabel',
|
|
155
|
+
toLocal: 'labelToTaskType',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
localField: 'assignee',
|
|
159
|
+
externalField: 'assignees',
|
|
160
|
+
direction: 'bidirectional',
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Placeholder GitHub ExternalProvider.
|
|
168
|
+
*
|
|
169
|
+
* Used when the provider is registered in the registry before configuration.
|
|
170
|
+
* Connection testing always returns false. The task adapter throws on all operations.
|
|
171
|
+
*/
|
|
172
|
+
class GitHubPlaceholderProvider {
|
|
173
|
+
name = 'github';
|
|
174
|
+
displayName = 'GitHub';
|
|
175
|
+
supportedAdapters = ['task'];
|
|
176
|
+
taskAdapter = new GitHubPlaceholderTaskAdapter();
|
|
177
|
+
async testConnection(_config) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
getTaskAdapter() {
|
|
181
|
+
return this.taskAdapter;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// ============================================================================
|
|
185
|
+
// Factory Functions
|
|
186
|
+
// ============================================================================
|
|
187
|
+
/**
|
|
188
|
+
* Create a configured GitHub provider.
|
|
189
|
+
*
|
|
190
|
+
* The provider is ready to use for sync operations when a valid
|
|
191
|
+
* token is provided in the config. The task adapter is initialized
|
|
192
|
+
* immediately with the provided credentials.
|
|
193
|
+
*
|
|
194
|
+
* @param config - Provider configuration with token and optional apiBaseUrl
|
|
195
|
+
* @returns A fully configured GitHub ExternalProvider
|
|
196
|
+
*/
|
|
197
|
+
export function createGitHubProvider(config) {
|
|
198
|
+
return new GitHubProvider(config);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Create a placeholder GitHub provider.
|
|
202
|
+
*
|
|
203
|
+
* The provider is registered by default in the provider registry so that
|
|
204
|
+
* the system knows GitHub is an available provider. Connection testing
|
|
205
|
+
* always returns false and all adapter methods throw until configured.
|
|
206
|
+
*
|
|
207
|
+
* @returns A placeholder GitHub ExternalProvider
|
|
208
|
+
*/
|
|
209
|
+
export function createGitHubPlaceholderProvider() {
|
|
210
|
+
return new GitHubPlaceholderProvider();
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=github-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-provider.js","sourceRoot":"","sources":["../../../../src/external-sync/providers/github/github-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAYH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,+EAA+E;AAC/E,wCAAwC;AACxC,+EAA+E;AAE/E;;;;;;;;;;;;GAYG;AACH,MAAM,cAAc;IACT,IAAI,GAAG,QAAQ,CAAC;IAChB,WAAW,GAAG,QAAQ,CAAC;IACvB,iBAAiB,GAA+B,CAAC,MAAM,CAAC,CAAC;IAE1D,WAAW,GAA6B,IAAI,CAAC;IACpC,MAAM,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D;oBACE,UAAU,EAAE,UAAU;oBACtB,aAAa,EAAE,QAAQ;oBACvB,SAAS,EAAE,eAAe;oBAC1B,UAAU,EAAE,iBAAiB;oBAC7B,OAAO,EAAE,iBAAiB;iBAC3B;gBACD;oBACE,UAAU,EAAE,UAAU;oBACtB,aAAa,EAAE,WAAW;oBAC1B,SAAS,EAAE,eAAe;iBAC3B;aACF;SACF,CAAC;IACJ,CAAC;;AAGH;;;;;GAKG;AACH,MAAM,yBAAyB;IACpB,IAAI,GAAG,QAAQ,CAAC;IAChB,WAAW,GAAG,QAAQ,CAAC;IACvB,iBAAiB,GAA+B,CAAC,MAAM,CAAC,CAAC;IAEjD,WAAW,GAAG,IAAI,4BAA4B,EAAE,CAAC;IAElE,KAAK,CAAC,cAAc,CAAC,OAAuB;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAED,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAsB;IACzD,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,+BAA+B;IAC7C,OAAO,IAAI,yBAAyB,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Task Sync Adapter
|
|
3
|
+
*
|
|
4
|
+
* Implements TaskSyncAdapter for GitHub Issues.
|
|
5
|
+
* Uses GitHubApiClient internally for all API operations and maps between
|
|
6
|
+
* the normalized ExternalTask format and GitHub's issue representation.
|
|
7
|
+
*
|
|
8
|
+
* Project format: 'owner/repo' (e.g., 'stoneforge-ai/stoneforge')
|
|
9
|
+
* External ID format: issue number as string (e.g., '42')
|
|
10
|
+
*/
|
|
11
|
+
import type { TaskSyncAdapter, ExternalTask, ExternalTaskInput, TaskFieldMapConfig } from '@stoneforge/core';
|
|
12
|
+
import type { Timestamp } from '@stoneforge/core';
|
|
13
|
+
import type { GitHubApiClientOptions } from './github-api.js';
|
|
14
|
+
/**
|
|
15
|
+
* Returns the default color for a given sf:* label name.
|
|
16
|
+
* Falls back to a neutral gray if no specific color is defined.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getDefaultLabelColor(labelName: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* TaskSyncAdapter implementation for GitHub Issues.
|
|
21
|
+
*
|
|
22
|
+
* Maps between Stoneforge's normalized ExternalTask format and GitHub's
|
|
23
|
+
* issue API. Uses GitHubApiClient for all HTTP operations.
|
|
24
|
+
*
|
|
25
|
+
* Auto-creates sf:* labels on the target repository before assigning them
|
|
26
|
+
* to issues, preventing GitHub 422 "Validation Failed" errors.
|
|
27
|
+
*
|
|
28
|
+
* Usage:
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const adapter = new GitHubTaskAdapter({
|
|
31
|
+
* token: 'ghp_...',
|
|
32
|
+
* apiBaseUrl: 'https://api.github.com', // optional
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* const issue = await adapter.getIssue('owner/repo', '42');
|
|
36
|
+
* const issues = await adapter.listIssuesSince('owner/repo', Date.now());
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare class GitHubTaskAdapter implements TaskSyncAdapter {
|
|
40
|
+
private readonly client;
|
|
41
|
+
/**
|
|
42
|
+
* Per-repo cache of known label names.
|
|
43
|
+
* Key is 'owner/repo', value is a Set of label names that exist on the repo.
|
|
44
|
+
* Populated once per repo per session to avoid redundant API calls.
|
|
45
|
+
*/
|
|
46
|
+
private readonly labelCache;
|
|
47
|
+
constructor(options: GitHubApiClientOptions);
|
|
48
|
+
/**
|
|
49
|
+
* Fetch a single issue by its number.
|
|
50
|
+
*
|
|
51
|
+
* @param project - Repository in 'owner/repo' format
|
|
52
|
+
* @param externalId - GitHub issue number as a string
|
|
53
|
+
* @returns The normalized ExternalTask, or null if not found
|
|
54
|
+
*/
|
|
55
|
+
getIssue(project: string, externalId: string): Promise<ExternalTask | null>;
|
|
56
|
+
/**
|
|
57
|
+
* List all issues updated since the given timestamp.
|
|
58
|
+
*
|
|
59
|
+
* Fetches all issues (open and closed) that have been updated since
|
|
60
|
+
* the provided timestamp. Uses auto-pagination to retrieve all matching
|
|
61
|
+
* issues across multiple pages.
|
|
62
|
+
*
|
|
63
|
+
* @param project - Repository in 'owner/repo' format
|
|
64
|
+
* @param since - Timestamp (milliseconds since epoch) to filter by
|
|
65
|
+
* @returns Array of normalized ExternalTask objects
|
|
66
|
+
*/
|
|
67
|
+
listIssuesSince(project: string, since: Timestamp): Promise<ExternalTask[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Create a new issue in the specified repository.
|
|
70
|
+
*
|
|
71
|
+
* Maps ExternalTaskInput fields to GitHub's create issue payload:
|
|
72
|
+
* - title -> title
|
|
73
|
+
* - body -> body
|
|
74
|
+
* - labels -> labels (as label names)
|
|
75
|
+
*
|
|
76
|
+
* Note: Assignees are intentionally NOT set on created issues. Stoneforge
|
|
77
|
+
* assignees are ephemeral agents that don't correspond to GitHub users.
|
|
78
|
+
*
|
|
79
|
+
* Note: The 'state' field from ExternalTaskInput is ignored for creation
|
|
80
|
+
* since GitHub issues are always created in the 'open' state.
|
|
81
|
+
*
|
|
82
|
+
* @param project - Repository in 'owner/repo' format
|
|
83
|
+
* @param issue - The issue data to create
|
|
84
|
+
* @returns The created ExternalTask with its new external ID and URL
|
|
85
|
+
*/
|
|
86
|
+
createIssue(project: string, issue: ExternalTaskInput): Promise<ExternalTask>;
|
|
87
|
+
/**
|
|
88
|
+
* Update an existing issue in the specified repository.
|
|
89
|
+
*
|
|
90
|
+
* Maps partial ExternalTaskInput fields to GitHub's update issue payload.
|
|
91
|
+
* Only fields present in the updates object are sent to GitHub —
|
|
92
|
+
* undefined fields are left unchanged.
|
|
93
|
+
*
|
|
94
|
+
* @param project - Repository in 'owner/repo' format
|
|
95
|
+
* @param externalId - GitHub issue number as a string
|
|
96
|
+
* @param updates - Partial issue data to update
|
|
97
|
+
* @returns The updated ExternalTask
|
|
98
|
+
*/
|
|
99
|
+
updateIssue(project: string, externalId: string, updates: Partial<ExternalTaskInput>): Promise<ExternalTask>;
|
|
100
|
+
/**
|
|
101
|
+
* Ensures that all sf:* labels in the given list exist on the target repository.
|
|
102
|
+
*
|
|
103
|
+
* For each label with the sync prefix (sf:), checks the per-repo cache first.
|
|
104
|
+
* If the cache hasn't been populated yet, fetches all labels from the repo once.
|
|
105
|
+
* Any missing sf:* labels are created with sensible default colors.
|
|
106
|
+
*
|
|
107
|
+
* Non-sf:* labels (user-managed) are not checked or created — those are the
|
|
108
|
+
* user's responsibility.
|
|
109
|
+
*
|
|
110
|
+
* @param project - Repository in 'owner/repo' format
|
|
111
|
+
* @param labels - Array of label names that will be assigned to an issue
|
|
112
|
+
*/
|
|
113
|
+
ensureLabelsExist(project: string, labels: string[]): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Returns the GitHub-specific field mapping configuration.
|
|
116
|
+
*
|
|
117
|
+
* This configuration is used by the shared task sync adapter utilities
|
|
118
|
+
* to map between Stoneforge task fields and GitHub issue fields.
|
|
119
|
+
*
|
|
120
|
+
* The returned TaskFieldMapConfig describes individual field mappings
|
|
121
|
+
* with their directions and transform function names.
|
|
122
|
+
*
|
|
123
|
+
* @returns TaskFieldMapConfig for GitHub
|
|
124
|
+
*/
|
|
125
|
+
getFieldMapConfig(): TaskFieldMapConfig;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Returns the GitHub-specific TaskSyncFieldMapConfig for use with
|
|
129
|
+
* the shared task sync adapter utilities.
|
|
130
|
+
*
|
|
131
|
+
* This is a convenience export for code that needs the config directly
|
|
132
|
+
* without going through the adapter's getFieldMapConfig() method.
|
|
133
|
+
*/
|
|
134
|
+
export { GITHUB_FIELD_MAP_CONFIG } from './github-field-map.js';
|
|
135
|
+
//# sourceMappingURL=github-task-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-task-adapter.d.ts","sourceRoot":"","sources":["../../../../src/external-sync/providers/github/github-task-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EAAE,sBAAsB,EAAe,MAAM,iBAAiB,CAAC;AA6F3E;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9D;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IACvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IAEzC;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuC;gBAEtD,OAAO,EAAE,sBAAsB;IAI3C;;;;;;OAMG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAsBjF;;;;;;;;;;OAUG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAejF;;;;;;;;;;;;;;;;;OAiBG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IAkBnF;;;;;;;;;;;OAWG;IACG,WAAW,CACf,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAClC,OAAO,CAAC,YAAY,CAAC;IAqCxB;;;;;;;;;;;;OAYG;IAC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