@stoneforge/quarry 1.12.0 → 1.14.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.
Files changed (199) hide show
  1. package/README.md +2 -0
  2. package/dist/api/quarry-api.d.ts +9 -1
  3. package/dist/api/quarry-api.d.ts.map +1 -1
  4. package/dist/api/quarry-api.js +21 -2
  5. package/dist/api/quarry-api.js.map +1 -1
  6. package/dist/api/types.d.ts +8 -1
  7. package/dist/api/types.d.ts.map +1 -1
  8. package/dist/api/types.js.map +1 -1
  9. package/dist/cli/commands/auto-link-helper.d.ts +33 -0
  10. package/dist/cli/commands/auto-link-helper.d.ts.map +1 -0
  11. package/dist/cli/commands/auto-link-helper.js +74 -0
  12. package/dist/cli/commands/auto-link-helper.js.map +1 -0
  13. package/dist/cli/commands/crud.d.ts +3 -0
  14. package/dist/cli/commands/crud.d.ts.map +1 -1
  15. package/dist/cli/commands/crud.js +144 -15
  16. package/dist/cli/commands/crud.js.map +1 -1
  17. package/dist/cli/commands/docs.js +2 -2
  18. package/dist/cli/commands/docs.js.map +1 -1
  19. package/dist/cli/commands/document.js +1 -1
  20. package/dist/cli/commands/document.js.map +1 -1
  21. package/dist/cli/commands/entity.js +1 -1
  22. package/dist/cli/commands/entity.js.map +1 -1
  23. package/dist/cli/commands/external-sync.d.ts +18 -0
  24. package/dist/cli/commands/external-sync.d.ts.map +1 -0
  25. package/dist/cli/commands/external-sync.js +2499 -0
  26. package/dist/cli/commands/external-sync.js.map +1 -0
  27. package/dist/cli/commands/library.js +1 -1
  28. package/dist/cli/commands/library.js.map +1 -1
  29. package/dist/cli/commands/message.js +2 -2
  30. package/dist/cli/commands/message.js.map +1 -1
  31. package/dist/cli/commands/serve.d.ts.map +1 -1
  32. package/dist/cli/commands/serve.js +2 -0
  33. package/dist/cli/commands/serve.js.map +1 -1
  34. package/dist/cli/commands/task.d.ts.map +1 -1
  35. package/dist/cli/commands/task.js +7 -4
  36. package/dist/cli/commands/task.js.map +1 -1
  37. package/dist/cli/commands/team.js +1 -1
  38. package/dist/cli/commands/team.js.map +1 -1
  39. package/dist/cli/commands/workflow.js +1 -1
  40. package/dist/cli/commands/workflow.js.map +1 -1
  41. package/dist/cli/runner.d.ts.map +1 -1
  42. package/dist/cli/runner.js +3 -0
  43. package/dist/cli/runner.js.map +1 -1
  44. package/dist/cli/utils/progress.d.ts +30 -0
  45. package/dist/cli/utils/progress.d.ts.map +1 -0
  46. package/dist/cli/utils/progress.js +47 -0
  47. package/dist/cli/utils/progress.js.map +1 -0
  48. package/dist/config/config.d.ts.map +1 -1
  49. package/dist/config/config.js +34 -0
  50. package/dist/config/config.js.map +1 -1
  51. package/dist/config/defaults.d.ts +13 -1
  52. package/dist/config/defaults.d.ts.map +1 -1
  53. package/dist/config/defaults.js +22 -0
  54. package/dist/config/defaults.js.map +1 -1
  55. package/dist/config/file.d.ts.map +1 -1
  56. package/dist/config/file.js +71 -0
  57. package/dist/config/file.js.map +1 -1
  58. package/dist/config/index.d.ts +3 -3
  59. package/dist/config/index.d.ts.map +1 -1
  60. package/dist/config/index.js +2 -2
  61. package/dist/config/index.js.map +1 -1
  62. package/dist/config/merge.d.ts.map +1 -1
  63. package/dist/config/merge.js +52 -1
  64. package/dist/config/merge.js.map +1 -1
  65. package/dist/config/types.d.ts +68 -1
  66. package/dist/config/types.d.ts.map +1 -1
  67. package/dist/config/types.js +33 -0
  68. package/dist/config/types.js.map +1 -1
  69. package/dist/config/validation.d.ts.map +1 -1
  70. package/dist/config/validation.js +64 -1
  71. package/dist/config/validation.js.map +1 -1
  72. package/dist/external-sync/adapters/document-sync-adapter.d.ts +150 -0
  73. package/dist/external-sync/adapters/document-sync-adapter.d.ts.map +1 -0
  74. package/dist/external-sync/adapters/document-sync-adapter.js +325 -0
  75. package/dist/external-sync/adapters/document-sync-adapter.js.map +1 -0
  76. package/dist/external-sync/adapters/task-sync-adapter.d.ts +177 -0
  77. package/dist/external-sync/adapters/task-sync-adapter.d.ts.map +1 -0
  78. package/dist/external-sync/adapters/task-sync-adapter.js +353 -0
  79. package/dist/external-sync/adapters/task-sync-adapter.js.map +1 -0
  80. package/dist/external-sync/auto-link.d.ts +66 -0
  81. package/dist/external-sync/auto-link.d.ts.map +1 -0
  82. package/dist/external-sync/auto-link.js +98 -0
  83. package/dist/external-sync/auto-link.js.map +1 -0
  84. package/dist/external-sync/conflict-resolver.d.ts +170 -0
  85. package/dist/external-sync/conflict-resolver.d.ts.map +1 -0
  86. package/dist/external-sync/conflict-resolver.js +580 -0
  87. package/dist/external-sync/conflict-resolver.js.map +1 -0
  88. package/dist/external-sync/index.d.ts +23 -0
  89. package/dist/external-sync/index.d.ts.map +1 -0
  90. package/dist/external-sync/index.js +24 -0
  91. package/dist/external-sync/index.js.map +1 -0
  92. package/dist/external-sync/provider-registry.d.ts +113 -0
  93. package/dist/external-sync/provider-registry.d.ts.map +1 -0
  94. package/dist/external-sync/provider-registry.js +205 -0
  95. package/dist/external-sync/provider-registry.js.map +1 -0
  96. package/dist/external-sync/providers/folder/folder-document-adapter.d.ts +97 -0
  97. package/dist/external-sync/providers/folder/folder-document-adapter.d.ts.map +1 -0
  98. package/dist/external-sync/providers/folder/folder-document-adapter.js +261 -0
  99. package/dist/external-sync/providers/folder/folder-document-adapter.js.map +1 -0
  100. package/dist/external-sync/providers/folder/folder-fs.d.ts +146 -0
  101. package/dist/external-sync/providers/folder/folder-fs.d.ts.map +1 -0
  102. package/dist/external-sync/providers/folder/folder-fs.js +300 -0
  103. package/dist/external-sync/providers/folder/folder-fs.js.map +1 -0
  104. package/dist/external-sync/providers/folder/folder-provider.d.ts +28 -0
  105. package/dist/external-sync/providers/folder/folder-provider.d.ts.map +1 -0
  106. package/dist/external-sync/providers/folder/folder-provider.js +87 -0
  107. package/dist/external-sync/providers/folder/folder-provider.js.map +1 -0
  108. package/dist/external-sync/providers/folder/index.d.ts +11 -0
  109. package/dist/external-sync/providers/folder/index.d.ts.map +1 -0
  110. package/dist/external-sync/providers/folder/index.js +13 -0
  111. package/dist/external-sync/providers/folder/index.js.map +1 -0
  112. package/dist/external-sync/providers/github/github-api.d.ts +271 -0
  113. package/dist/external-sync/providers/github/github-api.d.ts.map +1 -0
  114. package/dist/external-sync/providers/github/github-api.js +366 -0
  115. package/dist/external-sync/providers/github/github-api.js.map +1 -0
  116. package/dist/external-sync/providers/github/github-field-map.d.ts +76 -0
  117. package/dist/external-sync/providers/github/github-field-map.d.ts.map +1 -0
  118. package/dist/external-sync/providers/github/github-field-map.js +157 -0
  119. package/dist/external-sync/providers/github/github-field-map.js.map +1 -0
  120. package/dist/external-sync/providers/github/github-provider.d.ts +36 -0
  121. package/dist/external-sync/providers/github/github-provider.d.ts.map +1 -0
  122. package/dist/external-sync/providers/github/github-provider.js +212 -0
  123. package/dist/external-sync/providers/github/github-provider.js.map +1 -0
  124. package/dist/external-sync/providers/github/github-task-adapter.d.ts +135 -0
  125. package/dist/external-sync/providers/github/github-task-adapter.d.ts.map +1 -0
  126. package/dist/external-sync/providers/github/github-task-adapter.js +374 -0
  127. package/dist/external-sync/providers/github/github-task-adapter.js.map +1 -0
  128. package/dist/external-sync/providers/github/index.d.ts +12 -0
  129. package/dist/external-sync/providers/github/index.d.ts.map +1 -0
  130. package/dist/external-sync/providers/github/index.js +15 -0
  131. package/dist/external-sync/providers/github/index.js.map +1 -0
  132. package/dist/external-sync/providers/index.d.ts +13 -0
  133. package/dist/external-sync/providers/index.d.ts.map +1 -0
  134. package/dist/external-sync/providers/index.js +15 -0
  135. package/dist/external-sync/providers/index.js.map +1 -0
  136. package/dist/external-sync/providers/linear/index.d.ts +19 -0
  137. package/dist/external-sync/providers/linear/index.d.ts.map +1 -0
  138. package/dist/external-sync/providers/linear/index.js +19 -0
  139. package/dist/external-sync/providers/linear/index.js.map +1 -0
  140. package/dist/external-sync/providers/linear/linear-api.d.ts +252 -0
  141. package/dist/external-sync/providers/linear/linear-api.d.ts.map +1 -0
  142. package/dist/external-sync/providers/linear/linear-api.js +522 -0
  143. package/dist/external-sync/providers/linear/linear-api.js.map +1 -0
  144. package/dist/external-sync/providers/linear/linear-field-map.d.ts +135 -0
  145. package/dist/external-sync/providers/linear/linear-field-map.d.ts.map +1 -0
  146. package/dist/external-sync/providers/linear/linear-field-map.js +338 -0
  147. package/dist/external-sync/providers/linear/linear-field-map.js.map +1 -0
  148. package/dist/external-sync/providers/linear/linear-provider.d.ts +52 -0
  149. package/dist/external-sync/providers/linear/linear-provider.d.ts.map +1 -0
  150. package/dist/external-sync/providers/linear/linear-provider.js +169 -0
  151. package/dist/external-sync/providers/linear/linear-provider.js.map +1 -0
  152. package/dist/external-sync/providers/linear/linear-task-adapter.d.ts +190 -0
  153. package/dist/external-sync/providers/linear/linear-task-adapter.d.ts.map +1 -0
  154. package/dist/external-sync/providers/linear/linear-task-adapter.js +521 -0
  155. package/dist/external-sync/providers/linear/linear-task-adapter.js.map +1 -0
  156. package/dist/external-sync/providers/linear/linear-types.d.ts +114 -0
  157. package/dist/external-sync/providers/linear/linear-types.d.ts.map +1 -0
  158. package/dist/external-sync/providers/linear/linear-types.js +10 -0
  159. package/dist/external-sync/providers/linear/linear-types.js.map +1 -0
  160. package/dist/external-sync/providers/notion/index.d.ts +19 -0
  161. package/dist/external-sync/providers/notion/index.d.ts.map +1 -0
  162. package/dist/external-sync/providers/notion/index.js +20 -0
  163. package/dist/external-sync/providers/notion/index.js.map +1 -0
  164. package/dist/external-sync/providers/notion/notion-api.d.ts +253 -0
  165. package/dist/external-sync/providers/notion/notion-api.d.ts.map +1 -0
  166. package/dist/external-sync/providers/notion/notion-api.js +492 -0
  167. package/dist/external-sync/providers/notion/notion-api.js.map +1 -0
  168. package/dist/external-sync/providers/notion/notion-blocks.d.ts +93 -0
  169. package/dist/external-sync/providers/notion/notion-blocks.d.ts.map +1 -0
  170. package/dist/external-sync/providers/notion/notion-blocks.js +773 -0
  171. package/dist/external-sync/providers/notion/notion-blocks.js.map +1 -0
  172. package/dist/external-sync/providers/notion/notion-document-adapter.d.ts +176 -0
  173. package/dist/external-sync/providers/notion/notion-document-adapter.d.ts.map +1 -0
  174. package/dist/external-sync/providers/notion/notion-document-adapter.js +413 -0
  175. package/dist/external-sync/providers/notion/notion-document-adapter.js.map +1 -0
  176. package/dist/external-sync/providers/notion/notion-provider.d.ts +57 -0
  177. package/dist/external-sync/providers/notion/notion-provider.d.ts.map +1 -0
  178. package/dist/external-sync/providers/notion/notion-provider.js +159 -0
  179. package/dist/external-sync/providers/notion/notion-provider.js.map +1 -0
  180. package/dist/external-sync/providers/notion/notion-types.d.ts +388 -0
  181. package/dist/external-sync/providers/notion/notion-types.d.ts.map +1 -0
  182. package/dist/external-sync/providers/notion/notion-types.js +47 -0
  183. package/dist/external-sync/providers/notion/notion-types.js.map +1 -0
  184. package/dist/external-sync/sync-engine.d.ts +364 -0
  185. package/dist/external-sync/sync-engine.d.ts.map +1 -0
  186. package/dist/external-sync/sync-engine.js +1154 -0
  187. package/dist/external-sync/sync-engine.js.map +1 -0
  188. package/dist/index.d.ts +1 -0
  189. package/dist/index.d.ts.map +1 -1
  190. package/dist/index.js +2 -0
  191. package/dist/index.js.map +1 -1
  192. package/dist/server/index.js +8 -8
  193. package/dist/server/index.js.map +1 -1
  194. package/dist/services/inbox.js +1 -1
  195. package/dist/sync/hash.d.ts +5 -0
  196. package/dist/sync/hash.d.ts.map +1 -1
  197. package/dist/sync/hash.js +21 -2
  198. package/dist/sync/hash.js.map +1 -1
  199. package/package.json +10 -12
@@ -0,0 +1,76 @@
1
+ /**
2
+ * GitHub Field Map Configuration
3
+ *
4
+ * Defines how Stoneforge task fields map to GitHub issue fields.
5
+ * Used by the GitHubTaskAdapter and the shared task sync adapter utilities.
6
+ *
7
+ * Key mappings:
8
+ * - Priority (1-5) -> labels with 'priority:' prefix
9
+ * - TaskType (bug/feature/task/chore) -> labels with 'type:' prefix
10
+ * - Status -> GitHub issue state ('open' or 'closed')
11
+ * - Tags -> labels (user-managed, no prefix)
12
+ * - Sync-managed labels use the 'sf:' prefix
13
+ */
14
+ import type { TaskStatus, Priority, TaskTypeValue } from '@stoneforge/core';
15
+ import type { TaskSyncFieldMapConfig } from '../../adapters/task-sync-adapter.js';
16
+ /**
17
+ * Maps Stoneforge priority values (1-5) to GitHub label names.
18
+ * These labels are prefixed with 'sf:' when pushed to GitHub to
19
+ * distinguish sync-managed labels from user-created labels.
20
+ */
21
+ export declare const GITHUB_PRIORITY_LABELS: Record<Priority, string>;
22
+ /**
23
+ * Maps Stoneforge task type values to GitHub label names.
24
+ * These labels are prefixed with 'sf:' when pushed to GitHub.
25
+ */
26
+ export declare const GITHUB_TASK_TYPE_LABELS: Record<TaskTypeValue, string>;
27
+ /**
28
+ * Prefix for Stoneforge-managed labels on GitHub issues.
29
+ * Labels with this prefix are created and managed by the sync system.
30
+ * User labels without this prefix are preserved during sync.
31
+ */
32
+ export declare const GITHUB_SYNC_LABEL_PREFIX = "sf:";
33
+ /**
34
+ * Maps Stoneforge TaskStatus values to GitHub label names.
35
+ * These labels are prefixed with 'sf:' when pushed to GitHub to
36
+ * provide granular status visibility beyond GitHub's binary open/closed state.
37
+ */
38
+ export declare const GITHUB_STATUS_LABELS: Record<TaskStatus, string>;
39
+ /**
40
+ * Maps Stoneforge TaskStatus to GitHub issue state.
41
+ *
42
+ * GitHub only supports two issue states: 'open' and 'closed'.
43
+ * Most Stoneforge statuses map to 'open' since GitHub can't
44
+ * distinguish between open, in_progress, review, blocked, etc.
45
+ *
46
+ * Mapping:
47
+ * - open, in_progress, review, blocked, deferred, backlog -> 'open'
48
+ * - closed, tombstone -> 'closed'
49
+ */
50
+ export declare function statusToGitHubState(status: TaskStatus): 'open' | 'closed';
51
+ /**
52
+ * Maps GitHub issue state + labels back to Stoneforge TaskStatus.
53
+ *
54
+ * Uses sf:status:* labels for granular status inference when available.
55
+ * If a status label is found, it takes precedence over the basic
56
+ * open/closed state mapping. Falls back to the simple state mapping
57
+ * when no status label is present.
58
+ *
59
+ * Mapping with labels:
60
+ * - 'sf:status:in-progress' → 'in_progress'
61
+ * - 'sf:status:blocked' → 'blocked'
62
+ * - etc.
63
+ *
64
+ * Fallback mapping (no status label):
65
+ * - 'open' → 'open'
66
+ * - 'closed' → 'closed'
67
+ */
68
+ export declare function gitHubStateToStatus(state: 'open' | 'closed', labels: string[]): TaskStatus;
69
+ /**
70
+ * Complete GitHub-specific field mapping configuration.
71
+ *
72
+ * Used by the shared task sync adapter utilities to convert between
73
+ * Stoneforge tasks and GitHub issues (in both push and pull directions).
74
+ */
75
+ export declare const GITHUB_FIELD_MAP_CONFIG: TaskSyncFieldMapConfig;
76
+ //# sourceMappingURL=github-field-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-field-map.d.ts","sourceRoot":"","sources":["../../../../src/external-sync/providers/github/github-field-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAMlF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAM/B,CAAC;AAM9B;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAKhC,CAAC;AAMnC;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAM9C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAS3D,CAAC;AAMF;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,CAczE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,GAAG,QAAQ,EACxB,MAAM,EAAE,MAAM,EAAE,GACf,UAAU,CA0BZ;AAMD;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,sBAOrC,CAAC"}
@@ -0,0 +1,157 @@
1
+ /**
2
+ * GitHub Field Map Configuration
3
+ *
4
+ * Defines how Stoneforge task fields map to GitHub issue fields.
5
+ * Used by the GitHubTaskAdapter and the shared task sync adapter utilities.
6
+ *
7
+ * Key mappings:
8
+ * - Priority (1-5) -> labels with 'priority:' prefix
9
+ * - TaskType (bug/feature/task/chore) -> labels with 'type:' prefix
10
+ * - Status -> GitHub issue state ('open' or 'closed')
11
+ * - Tags -> labels (user-managed, no prefix)
12
+ * - Sync-managed labels use the 'sf:' prefix
13
+ */
14
+ // ============================================================================
15
+ // Priority Label Mapping
16
+ // ============================================================================
17
+ /**
18
+ * Maps Stoneforge priority values (1-5) to GitHub label names.
19
+ * These labels are prefixed with 'sf:' when pushed to GitHub to
20
+ * distinguish sync-managed labels from user-created labels.
21
+ */
22
+ export const GITHUB_PRIORITY_LABELS = {
23
+ 1: 'priority:critical',
24
+ 2: 'priority:high',
25
+ 3: 'priority:medium',
26
+ 4: 'priority:low',
27
+ 5: 'priority:minimal',
28
+ };
29
+ // ============================================================================
30
+ // Task Type Label Mapping
31
+ // ============================================================================
32
+ /**
33
+ * Maps Stoneforge task type values to GitHub label names.
34
+ * These labels are prefixed with 'sf:' when pushed to GitHub.
35
+ */
36
+ export const GITHUB_TASK_TYPE_LABELS = {
37
+ bug: 'type:bug',
38
+ feature: 'type:feature',
39
+ task: 'type:task',
40
+ chore: 'type:chore',
41
+ };
42
+ // ============================================================================
43
+ // Sync Label Prefix
44
+ // ============================================================================
45
+ /**
46
+ * Prefix for Stoneforge-managed labels on GitHub issues.
47
+ * Labels with this prefix are created and managed by the sync system.
48
+ * User labels without this prefix are preserved during sync.
49
+ */
50
+ export const GITHUB_SYNC_LABEL_PREFIX = 'sf:';
51
+ // ============================================================================
52
+ // Status Label Mapping
53
+ // ============================================================================
54
+ /**
55
+ * Maps Stoneforge TaskStatus values to GitHub label names.
56
+ * These labels are prefixed with 'sf:' when pushed to GitHub to
57
+ * provide granular status visibility beyond GitHub's binary open/closed state.
58
+ */
59
+ export const GITHUB_STATUS_LABELS = {
60
+ open: 'status:open',
61
+ in_progress: 'status:in-progress',
62
+ blocked: 'status:blocked',
63
+ deferred: 'status:deferred',
64
+ backlog: 'status:backlog',
65
+ review: 'status:review',
66
+ closed: 'status:closed',
67
+ tombstone: 'status:tombstone',
68
+ };
69
+ // ============================================================================
70
+ // Status <-> State Mapping
71
+ // ============================================================================
72
+ /**
73
+ * Maps Stoneforge TaskStatus to GitHub issue state.
74
+ *
75
+ * GitHub only supports two issue states: 'open' and 'closed'.
76
+ * Most Stoneforge statuses map to 'open' since GitHub can't
77
+ * distinguish between open, in_progress, review, blocked, etc.
78
+ *
79
+ * Mapping:
80
+ * - open, in_progress, review, blocked, deferred, backlog -> 'open'
81
+ * - closed, tombstone -> 'closed'
82
+ */
83
+ export function statusToGitHubState(status) {
84
+ switch (status) {
85
+ case 'closed':
86
+ case 'tombstone':
87
+ return 'closed';
88
+ case 'open':
89
+ case 'in_progress':
90
+ case 'review':
91
+ case 'blocked':
92
+ case 'deferred':
93
+ case 'backlog':
94
+ default:
95
+ return 'open';
96
+ }
97
+ }
98
+ /**
99
+ * Maps GitHub issue state + labels back to Stoneforge TaskStatus.
100
+ *
101
+ * Uses sf:status:* labels for granular status inference when available.
102
+ * If a status label is found, it takes precedence over the basic
103
+ * open/closed state mapping. Falls back to the simple state mapping
104
+ * when no status label is present.
105
+ *
106
+ * Mapping with labels:
107
+ * - 'sf:status:in-progress' → 'in_progress'
108
+ * - 'sf:status:blocked' → 'blocked'
109
+ * - etc.
110
+ *
111
+ * Fallback mapping (no status label):
112
+ * - 'open' → 'open'
113
+ * - 'closed' → 'closed'
114
+ */
115
+ export function gitHubStateToStatus(state, labels) {
116
+ // Build a reverse lookup from status labels: 'status:open' → 'open', etc.
117
+ const statusByLabel = new Map();
118
+ for (const [status, label] of Object.entries(GITHUB_STATUS_LABELS)) {
119
+ statusByLabel.set(label, status);
120
+ }
121
+ // Check labels for a status label (strip the sync prefix first)
122
+ for (const label of labels) {
123
+ if (label.startsWith(GITHUB_SYNC_LABEL_PREFIX)) {
124
+ const value = label.slice(GITHUB_SYNC_LABEL_PREFIX.length);
125
+ const matchedStatus = statusByLabel.get(value);
126
+ if (matchedStatus !== undefined) {
127
+ return matchedStatus;
128
+ }
129
+ }
130
+ }
131
+ // Fallback: basic open/closed mapping
132
+ switch (state) {
133
+ case 'closed':
134
+ return 'closed';
135
+ case 'open':
136
+ default:
137
+ return 'open';
138
+ }
139
+ }
140
+ // ============================================================================
141
+ // Combined Field Map Config
142
+ // ============================================================================
143
+ /**
144
+ * Complete GitHub-specific field mapping configuration.
145
+ *
146
+ * Used by the shared task sync adapter utilities to convert between
147
+ * Stoneforge tasks and GitHub issues (in both push and pull directions).
148
+ */
149
+ export const GITHUB_FIELD_MAP_CONFIG = {
150
+ priorityLabels: GITHUB_PRIORITY_LABELS,
151
+ taskTypeLabels: GITHUB_TASK_TYPE_LABELS,
152
+ statusLabels: GITHUB_STATUS_LABELS,
153
+ syncLabelPrefix: GITHUB_SYNC_LABEL_PREFIX,
154
+ statusToState: statusToGitHubState,
155
+ stateToStatus: gitHubStateToStatus,
156
+ };
157
+ //# sourceMappingURL=github-field-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-field-map.js","sourceRoot":"","sources":["../../../../src/external-sync/providers/github/github-field-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAA6B;IAC9D,CAAC,EAAE,mBAAmB;IACtB,CAAC,EAAE,eAAe;IAClB,CAAC,EAAE,iBAAiB;IACpB,CAAC,EAAE,cAAc;IACjB,CAAC,EAAE,kBAAkB;CACM,CAAC;AAE9B,+EAA+E;AAC/E,0BAA0B;AAC1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AAoB,CAAC,EAAE,CAAC;QACnE,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,MAAoB,CAAC,CAAC;IACjD,CAAC;IAED,gEAAgE;IAChE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,UAAU,CAAC,wBAAwB,CAAC,EAAE,CAAC;YAC/C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC;YAC3D,MAAM,aAAa,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,OAAO,aAAa,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC;IAED,sCAAsC;IACtC,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,MAAM,CAAC;QACZ;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC7D,cAAc,EAAE,sBAAsB;IACtC,cAAc,EAAE,uBAAuB;IACvC,YAAY,EAAE,oBAAoB;IAClC,eAAe,EAAE,wBAAwB;IACzC,aAAa,EAAE,mBAAmB;IAClC,aAAa,EAAE,mBAAmB;CACnC,CAAC"}
@@ -0,0 +1,36 @@
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 type { ExternalProvider, ProviderConfig } from '@stoneforge/core';
15
+ /**
16
+ * Create a configured GitHub provider.
17
+ *
18
+ * The provider is ready to use for sync operations when a valid
19
+ * token is provided in the config. The task adapter is initialized
20
+ * immediately with the provided credentials.
21
+ *
22
+ * @param config - Provider configuration with token and optional apiBaseUrl
23
+ * @returns A fully configured GitHub ExternalProvider
24
+ */
25
+ export declare function createGitHubProvider(config: ProviderConfig): ExternalProvider;
26
+ /**
27
+ * Create a placeholder GitHub provider.
28
+ *
29
+ * The provider is registered by default in the provider registry so that
30
+ * the system knows GitHub is an available provider. Connection testing
31
+ * always returns false and all adapter methods throw until configured.
32
+ *
33
+ * @returns A placeholder GitHub ExternalProvider
34
+ */
35
+ export declare function createGitHubPlaceholderProvider(): ExternalProvider;
36
+ //# sourceMappingURL=github-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-provider.d.ts","sourceRoot":"","sources":["../../../../src/external-sync/providers/github/github-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EAMf,MAAM,kBAAkB,CAAC;AA4M1B;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAE7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,IAAI,gBAAgB,CAElE"}
@@ -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,CA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B;gBACD;oBACE,UAAU,EAAE,MAAM;oBAClB,aAAa,EAAE,QAAQ;oBACvB,SAAS,EAAE,eAAe;iBAC3B;gBACD;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,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,O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