@shipfox/api-integration-github 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/.turbo/turbo-build.log +2 -0
  2. package/.turbo/turbo-type$colon$emit.log +1 -0
  3. package/.turbo/turbo-type.log +1 -0
  4. package/CHANGELOG.md +138 -0
  5. package/LICENSE +21 -0
  6. package/dist/api/client.d.ts +90 -0
  7. package/dist/api/client.d.ts.map +1 -0
  8. package/dist/api/client.js +306 -0
  9. package/dist/api/client.js.map +1 -0
  10. package/dist/api/installation-token-envelope.d.ts +36 -0
  11. package/dist/api/installation-token-envelope.d.ts.map +1 -0
  12. package/dist/api/installation-token-envelope.js +123 -0
  13. package/dist/api/installation-token-envelope.js.map +1 -0
  14. package/dist/api/installation-token-provider.d.ts +23 -0
  15. package/dist/api/installation-token-provider.d.ts.map +1 -0
  16. package/dist/api/installation-token-provider.js +130 -0
  17. package/dist/api/installation-token-provider.js.map +1 -0
  18. package/dist/api/shared-installation-token-cache.d.ts +43 -0
  19. package/dist/api/shared-installation-token-cache.d.ts.map +1 -0
  20. package/dist/api/shared-installation-token-cache.js +224 -0
  21. package/dist/api/shared-installation-token-cache.js.map +1 -0
  22. package/dist/config.d.ts +15 -0
  23. package/dist/config.d.ts.map +1 -0
  24. package/dist/config.js +44 -0
  25. package/dist/config.js.map +1 -0
  26. package/dist/core/actions-logs.d.ts +47 -0
  27. package/dist/core/actions-logs.d.ts.map +1 -0
  28. package/dist/core/actions-logs.js +134 -0
  29. package/dist/core/actions-logs.js.map +1 -0
  30. package/dist/core/agent-tool-selection.d.ts +4 -0
  31. package/dist/core/agent-tool-selection.d.ts.map +1 -0
  32. package/dist/core/agent-tool-selection.js +38 -0
  33. package/dist/core/agent-tool-selection.js.map +1 -0
  34. package/dist/core/agent-tools.d.ts +50 -0
  35. package/dist/core/agent-tools.d.ts.map +1 -0
  36. package/dist/core/agent-tools.js +1122 -0
  37. package/dist/core/agent-tools.js.map +1 -0
  38. package/dist/core/errors.d.ts +15 -0
  39. package/dist/core/errors.d.ts.map +1 -0
  40. package/dist/core/errors.js +22 -0
  41. package/dist/core/errors.js.map +1 -0
  42. package/dist/core/install.d.ts +38 -0
  43. package/dist/core/install.d.ts.map +1 -0
  44. package/dist/core/install.js +64 -0
  45. package/dist/core/install.js.map +1 -0
  46. package/dist/core/source-control.d.ts +15 -0
  47. package/dist/core/source-control.d.ts.map +1 -0
  48. package/dist/core/source-control.js +175 -0
  49. package/dist/core/source-control.js.map +1 -0
  50. package/dist/core/state.d.ts +12 -0
  51. package/dist/core/state.d.ts.map +1 -0
  52. package/dist/core/state.js +54 -0
  53. package/dist/core/state.js.map +1 -0
  54. package/dist/core/webhook.d.ts +20 -0
  55. package/dist/core/webhook.d.ts.map +1 -0
  56. package/dist/core/webhook.js +216 -0
  57. package/dist/core/webhook.js.map +1 -0
  58. package/dist/db/db.d.ts +433 -0
  59. package/dist/db/db.d.ts.map +1 -0
  60. package/dist/db/db.js +18 -0
  61. package/dist/db/db.js.map +1 -0
  62. package/dist/db/installation-token-lock.d.ts +8 -0
  63. package/dist/db/installation-token-lock.d.ts.map +1 -0
  64. package/dist/db/installation-token-lock.js +37 -0
  65. package/dist/db/installation-token-lock.js.map +1 -0
  66. package/dist/db/installations.d.ts +33 -0
  67. package/dist/db/installations.d.ts.map +1 -0
  68. package/dist/db/installations.js +56 -0
  69. package/dist/db/installations.js.map +1 -0
  70. package/dist/db/migrations.d.ts +2 -0
  71. package/dist/db/migrations.d.ts.map +1 -0
  72. package/dist/db/migrations.js +5 -0
  73. package/dist/db/migrations.js.map +1 -0
  74. package/dist/db/schema/common.d.ts +2 -0
  75. package/dist/db/schema/common.d.ts.map +1 -0
  76. package/dist/db/schema/common.js +4 -0
  77. package/dist/db/schema/common.js.map +1 -0
  78. package/dist/db/schema/installations.d.ts +218 -0
  79. package/dist/db/schema/installations.d.ts.map +1 -0
  80. package/dist/db/schema/installations.js +46 -0
  81. package/dist/db/schema/installations.js.map +1 -0
  82. package/dist/index.d.ts +53 -0
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/index.js +66 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/metrics/index.d.ts +2 -0
  87. package/dist/metrics/index.d.ts.map +1 -0
  88. package/dist/metrics/index.js +3 -0
  89. package/dist/metrics/index.js.map +1 -0
  90. package/dist/metrics/instance.d.ts +14 -0
  91. package/dist/metrics/instance.d.ts.map +1 -0
  92. package/dist/metrics/instance.js +75 -0
  93. package/dist/metrics/instance.js.map +1 -0
  94. package/dist/presentation/dto/integrations.d.ts +15 -0
  95. package/dist/presentation/dto/integrations.d.ts.map +1 -0
  96. package/dist/presentation/dto/integrations.js +10 -0
  97. package/dist/presentation/dto/integrations.js.map +1 -0
  98. package/dist/presentation/e2eRoutes/create-connection.d.ts +11 -0
  99. package/dist/presentation/e2eRoutes/create-connection.d.ts.map +1 -0
  100. package/dist/presentation/e2eRoutes/create-connection.js +57 -0
  101. package/dist/presentation/e2eRoutes/create-connection.js.map +1 -0
  102. package/dist/presentation/e2eRoutes/index.d.ts +5 -0
  103. package/dist/presentation/e2eRoutes/index.d.ts.map +1 -0
  104. package/dist/presentation/e2eRoutes/index.js +11 -0
  105. package/dist/presentation/e2eRoutes/index.js.map +1 -0
  106. package/dist/presentation/routes/errors.d.ts +2 -0
  107. package/dist/presentation/routes/errors.d.ts.map +1 -0
  108. package/dist/presentation/routes/errors.js +46 -0
  109. package/dist/presentation/routes/errors.js.map +1 -0
  110. package/dist/presentation/routes/install.d.ts +13 -0
  111. package/dist/presentation/routes/install.d.ts.map +1 -0
  112. package/dist/presentation/routes/install.js +77 -0
  113. package/dist/presentation/routes/install.js.map +1 -0
  114. package/dist/presentation/routes/webhooks.d.ts +16 -0
  115. package/dist/presentation/routes/webhooks.d.ts.map +1 -0
  116. package/dist/presentation/routes/webhooks.js +110 -0
  117. package/dist/presentation/routes/webhooks.js.map +1 -0
  118. package/dist/tsconfig.test.tsbuildinfo +1 -0
  119. package/drizzle/0000_initial.sql +17 -0
  120. package/drizzle/meta/_journal.json +13 -0
  121. package/drizzle.config.ts +7 -0
  122. package/package.json +71 -0
  123. package/src/api/client.test.ts +94 -0
  124. package/src/api/client.ts +525 -0
  125. package/src/api/installation-token-envelope.ts +171 -0
  126. package/src/api/installation-token-provider.test.ts +241 -0
  127. package/src/api/installation-token-provider.ts +224 -0
  128. package/src/api/shared-installation-token-cache.test.ts +294 -0
  129. package/src/api/shared-installation-token-cache.ts +346 -0
  130. package/src/config.test.ts +14 -0
  131. package/src/config.ts +47 -0
  132. package/src/connection-external-url.test.ts +78 -0
  133. package/src/core/actions-logs.test.ts +156 -0
  134. package/src/core/actions-logs.ts +186 -0
  135. package/src/core/agent-tool-selection.test.ts +41 -0
  136. package/src/core/agent-tool-selection.ts +42 -0
  137. package/src/core/agent-tools.test.ts +539 -0
  138. package/src/core/agent-tools.ts +1269 -0
  139. package/src/core/errors.ts +23 -0
  140. package/src/core/install.test.ts +238 -0
  141. package/src/core/install.ts +119 -0
  142. package/src/core/source-control.test.ts +327 -0
  143. package/src/core/source-control.ts +223 -0
  144. package/src/core/state.test.ts +43 -0
  145. package/src/core/state.ts +85 -0
  146. package/src/core/webhook.test.ts +522 -0
  147. package/src/core/webhook.ts +296 -0
  148. package/src/db/db.ts +18 -0
  149. package/src/db/installation-token-lock.test.ts +68 -0
  150. package/src/db/installation-token-lock.ts +39 -0
  151. package/src/db/installations.test.ts +67 -0
  152. package/src/db/installations.ts +108 -0
  153. package/src/db/migrations.ts +4 -0
  154. package/src/db/schema/common.ts +3 -0
  155. package/src/db/schema/installations.ts +46 -0
  156. package/src/index.ts +124 -0
  157. package/src/metrics/index.ts +1 -0
  158. package/src/metrics/instance.ts +82 -0
  159. package/src/presentation/dto/integrations.ts +8 -0
  160. package/src/presentation/e2eRoutes/create-connection.ts +70 -0
  161. package/src/presentation/e2eRoutes/index.test.ts +126 -0
  162. package/src/presentation/e2eRoutes/index.ts +14 -0
  163. package/src/presentation/routes/errors.ts +43 -0
  164. package/src/presentation/routes/install.test.ts +279 -0
  165. package/src/presentation/routes/install.ts +93 -0
  166. package/src/presentation/routes/webhooks.test.ts +560 -0
  167. package/src/presentation/routes/webhooks.ts +115 -0
  168. package/test/env.ts +16 -0
  169. package/test/factories/github-installation.ts +35 -0
  170. package/test/factories/index.ts +1 -0
  171. package/test/fixtures/github-webhook.ts +20 -0
  172. package/test/globalSetup.ts +14 -0
  173. package/test/index.ts +2 -0
  174. package/test/setup.ts +17 -0
  175. package/tsconfig.build.json +9 -0
  176. package/tsconfig.build.tsbuildinfo +1 -0
  177. package/tsconfig.json +3 -0
  178. package/tsconfig.test.json +9 -0
  179. package/vitest.config.ts +12 -0
@@ -0,0 +1,218 @@
1
+ import type { GithubInstallation } from '#db/installations.js';
2
+ export declare const githubInstallations: import("drizzle-orm/pg-core").PgTableWithColumns<{
3
+ name: "installations";
4
+ schema: undefined;
5
+ columns: {
6
+ id: import("drizzle-orm/pg-core").PgColumn<{
7
+ name: "id";
8
+ tableName: "installations";
9
+ dataType: "string";
10
+ columnType: "PgUUID";
11
+ data: string;
12
+ driverParam: string;
13
+ notNull: true;
14
+ hasDefault: true;
15
+ isPrimaryKey: true;
16
+ isAutoincrement: false;
17
+ hasRuntimeDefault: false;
18
+ enumValues: undefined;
19
+ baseColumn: never;
20
+ identity: undefined;
21
+ generated: undefined;
22
+ }, {}, {}>;
23
+ connectionId: import("drizzle-orm/pg-core").PgColumn<{
24
+ name: "connection_id";
25
+ tableName: "installations";
26
+ dataType: "string";
27
+ columnType: "PgUUID";
28
+ data: string;
29
+ driverParam: string;
30
+ notNull: true;
31
+ hasDefault: false;
32
+ isPrimaryKey: false;
33
+ isAutoincrement: false;
34
+ hasRuntimeDefault: false;
35
+ enumValues: undefined;
36
+ baseColumn: never;
37
+ identity: undefined;
38
+ generated: undefined;
39
+ }, {}, {}>;
40
+ installationId: import("drizzle-orm/pg-core").PgColumn<{
41
+ name: "installation_id";
42
+ tableName: "installations";
43
+ dataType: "string";
44
+ columnType: "PgText";
45
+ data: string;
46
+ driverParam: string;
47
+ notNull: true;
48
+ hasDefault: false;
49
+ isPrimaryKey: false;
50
+ isAutoincrement: false;
51
+ hasRuntimeDefault: false;
52
+ enumValues: [string, ...string[]];
53
+ baseColumn: never;
54
+ identity: undefined;
55
+ generated: undefined;
56
+ }, {}, {}>;
57
+ accountLogin: import("drizzle-orm/pg-core").PgColumn<{
58
+ name: "account_login";
59
+ tableName: "installations";
60
+ dataType: "string";
61
+ columnType: "PgText";
62
+ data: string;
63
+ driverParam: string;
64
+ notNull: true;
65
+ hasDefault: false;
66
+ isPrimaryKey: false;
67
+ isAutoincrement: false;
68
+ hasRuntimeDefault: false;
69
+ enumValues: [string, ...string[]];
70
+ baseColumn: never;
71
+ identity: undefined;
72
+ generated: undefined;
73
+ }, {}, {}>;
74
+ accountType: import("drizzle-orm/pg-core").PgColumn<{
75
+ name: "account_type";
76
+ tableName: "installations";
77
+ dataType: "string";
78
+ columnType: "PgText";
79
+ data: string;
80
+ driverParam: string;
81
+ notNull: true;
82
+ hasDefault: false;
83
+ isPrimaryKey: false;
84
+ isAutoincrement: false;
85
+ hasRuntimeDefault: false;
86
+ enumValues: [string, ...string[]];
87
+ baseColumn: never;
88
+ identity: undefined;
89
+ generated: undefined;
90
+ }, {}, {}>;
91
+ repositorySelection: import("drizzle-orm/pg-core").PgColumn<{
92
+ name: "repository_selection";
93
+ tableName: "installations";
94
+ dataType: "string";
95
+ columnType: "PgText";
96
+ data: string;
97
+ driverParam: string;
98
+ notNull: true;
99
+ hasDefault: false;
100
+ isPrimaryKey: false;
101
+ isAutoincrement: false;
102
+ hasRuntimeDefault: false;
103
+ enumValues: [string, ...string[]];
104
+ baseColumn: never;
105
+ identity: undefined;
106
+ generated: undefined;
107
+ }, {}, {}>;
108
+ suspendedAt: import("drizzle-orm/pg-core").PgColumn<{
109
+ name: "suspended_at";
110
+ tableName: "installations";
111
+ dataType: "date";
112
+ columnType: "PgTimestamp";
113
+ data: Date;
114
+ driverParam: string;
115
+ notNull: false;
116
+ hasDefault: false;
117
+ isPrimaryKey: false;
118
+ isAutoincrement: false;
119
+ hasRuntimeDefault: false;
120
+ enumValues: undefined;
121
+ baseColumn: never;
122
+ identity: undefined;
123
+ generated: undefined;
124
+ }, {}, {}>;
125
+ deletedAt: import("drizzle-orm/pg-core").PgColumn<{
126
+ name: "deleted_at";
127
+ tableName: "installations";
128
+ dataType: "date";
129
+ columnType: "PgTimestamp";
130
+ data: Date;
131
+ driverParam: string;
132
+ notNull: false;
133
+ hasDefault: false;
134
+ isPrimaryKey: false;
135
+ isAutoincrement: false;
136
+ hasRuntimeDefault: false;
137
+ enumValues: undefined;
138
+ baseColumn: never;
139
+ identity: undefined;
140
+ generated: undefined;
141
+ }, {}, {}>;
142
+ latestEvent: import("drizzle-orm/pg-core").PgColumn<{
143
+ name: "latest_event";
144
+ tableName: "installations";
145
+ dataType: "json";
146
+ columnType: "PgJsonb";
147
+ data: Record<string, unknown>;
148
+ driverParam: unknown;
149
+ notNull: true;
150
+ hasDefault: false;
151
+ isPrimaryKey: false;
152
+ isAutoincrement: false;
153
+ hasRuntimeDefault: false;
154
+ enumValues: undefined;
155
+ baseColumn: never;
156
+ identity: undefined;
157
+ generated: undefined;
158
+ }, {}, {
159
+ $type: Record<string, unknown>;
160
+ }>;
161
+ installerUserId: import("drizzle-orm/pg-core").PgColumn<{
162
+ name: "installer_user_id";
163
+ tableName: "installations";
164
+ dataType: "string";
165
+ columnType: "PgUUID";
166
+ data: string;
167
+ driverParam: string;
168
+ notNull: false;
169
+ hasDefault: false;
170
+ isPrimaryKey: false;
171
+ isAutoincrement: false;
172
+ hasRuntimeDefault: false;
173
+ enumValues: undefined;
174
+ baseColumn: never;
175
+ identity: undefined;
176
+ generated: undefined;
177
+ }, {}, {}>;
178
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
179
+ name: "created_at";
180
+ tableName: "installations";
181
+ dataType: "date";
182
+ columnType: "PgTimestamp";
183
+ data: Date;
184
+ driverParam: string;
185
+ notNull: true;
186
+ hasDefault: true;
187
+ isPrimaryKey: false;
188
+ isAutoincrement: false;
189
+ hasRuntimeDefault: false;
190
+ enumValues: undefined;
191
+ baseColumn: never;
192
+ identity: undefined;
193
+ generated: undefined;
194
+ }, {}, {}>;
195
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
196
+ name: "updated_at";
197
+ tableName: "installations";
198
+ dataType: "date";
199
+ columnType: "PgTimestamp";
200
+ data: Date;
201
+ driverParam: string;
202
+ notNull: true;
203
+ hasDefault: true;
204
+ isPrimaryKey: false;
205
+ isAutoincrement: false;
206
+ hasRuntimeDefault: false;
207
+ enumValues: undefined;
208
+ baseColumn: never;
209
+ identity: undefined;
210
+ generated: undefined;
211
+ }, {}, {}>;
212
+ };
213
+ dialect: "pg";
214
+ }>;
215
+ export type GithubInstallationDb = typeof githubInstallations.$inferSelect;
216
+ export type GithubInstallationCreateDb = typeof githubInstallations.$inferInsert;
217
+ export declare function toGithubInstallation(row: GithubInstallationDb): GithubInstallation;
218
+ //# sourceMappingURL=installations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installations.d.ts","sourceRoot":"","sources":["../../../src/db/schema/installations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAG7D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoB/B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,OAAO,mBAAmB,CAAC,YAAY,CAAC;AAC3E,MAAM,MAAM,0BAA0B,GAAG,OAAO,mBAAmB,CAAC,YAAY,CAAC;AAEjF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,oBAAoB,GAAG,kBAAkB,CAelF"}
@@ -0,0 +1,46 @@
1
+ import { uuidv7PrimaryKey } from '@shipfox/node-drizzle';
2
+ import { jsonb, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
3
+ import { pgTable } from './common.js';
4
+ export const githubInstallations = pgTable('installations', {
5
+ id: uuidv7PrimaryKey(),
6
+ connectionId: uuid('connection_id').notNull(),
7
+ installationId: text('installation_id').notNull(),
8
+ accountLogin: text('account_login').notNull(),
9
+ accountType: text('account_type').notNull(),
10
+ repositorySelection: text('repository_selection').notNull(),
11
+ suspendedAt: timestamp('suspended_at', {
12
+ withTimezone: true
13
+ }),
14
+ deletedAt: timestamp('deleted_at', {
15
+ withTimezone: true
16
+ }),
17
+ latestEvent: jsonb('latest_event').notNull().$type(),
18
+ installerUserId: uuid('installer_user_id'),
19
+ createdAt: timestamp('created_at', {
20
+ withTimezone: true
21
+ }).notNull().defaultNow(),
22
+ updatedAt: timestamp('updated_at', {
23
+ withTimezone: true
24
+ }).notNull().defaultNow()
25
+ }, (table)=>[
26
+ uniqueIndex('integrations_github_installations_connection_unique').on(table.connectionId),
27
+ uniqueIndex('integrations_github_installations_installation_unique').on(table.installationId)
28
+ ]);
29
+ export function toGithubInstallation(row) {
30
+ return {
31
+ id: row.id,
32
+ connectionId: row.connectionId,
33
+ installationId: row.installationId,
34
+ accountLogin: row.accountLogin,
35
+ accountType: row.accountType,
36
+ repositorySelection: row.repositorySelection,
37
+ suspendedAt: row.suspendedAt,
38
+ deletedAt: row.deletedAt,
39
+ latestEvent: row.latestEvent,
40
+ installerUserId: row.installerUserId,
41
+ createdAt: row.createdAt,
42
+ updatedAt: row.updatedAt
43
+ };
44
+ }
45
+
46
+ //# sourceMappingURL=installations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/db/schema/installations.ts"],"sourcesContent":["import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {jsonb, text, timestamp, uniqueIndex, uuid} from 'drizzle-orm/pg-core';\nimport type {GithubInstallation} from '#db/installations.js';\nimport {pgTable} from './common.js';\n\nexport const githubInstallations = pgTable(\n 'installations',\n {\n id: uuidv7PrimaryKey(),\n connectionId: uuid('connection_id').notNull(),\n installationId: text('installation_id').notNull(),\n accountLogin: text('account_login').notNull(),\n accountType: text('account_type').notNull(),\n repositorySelection: text('repository_selection').notNull(),\n suspendedAt: timestamp('suspended_at', {withTimezone: true}),\n deletedAt: timestamp('deleted_at', {withTimezone: true}),\n latestEvent: jsonb('latest_event').notNull().$type<Record<string, unknown>>(),\n installerUserId: uuid('installer_user_id'),\n createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),\n },\n (table) => [\n uniqueIndex('integrations_github_installations_connection_unique').on(table.connectionId),\n uniqueIndex('integrations_github_installations_installation_unique').on(table.installationId),\n ],\n);\n\nexport type GithubInstallationDb = typeof githubInstallations.$inferSelect;\nexport type GithubInstallationCreateDb = typeof githubInstallations.$inferInsert;\n\nexport function toGithubInstallation(row: GithubInstallationDb): GithubInstallation {\n return {\n id: row.id,\n connectionId: row.connectionId,\n installationId: row.installationId,\n accountLogin: row.accountLogin,\n accountType: row.accountType,\n repositorySelection: row.repositorySelection,\n suspendedAt: row.suspendedAt,\n deletedAt: row.deletedAt,\n latestEvent: row.latestEvent,\n installerUserId: row.installerUserId,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n"],"names":["uuidv7PrimaryKey","jsonb","text","timestamp","uniqueIndex","uuid","pgTable","githubInstallations","id","connectionId","notNull","installationId","accountLogin","accountType","repositorySelection","suspendedAt","withTimezone","deletedAt","latestEvent","$type","installerUserId","createdAt","defaultNow","updatedAt","table","on","toGithubInstallation","row"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wBA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}
@@ -0,0 +1,53 @@
1
+ import type { GetIntegrationConnectionByIdFn, PublishIntegrationEventReceivedFn, PublishSourcePushFn, RecordDeliveryOnlyFn } from '@shipfox/api-integration-core-dto';
2
+ import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
3
+ import { type GithubApiClient } from '#api/client.js';
4
+ import type { GithubInstallationTokenProvider } from '#api/installation-token-provider.js';
5
+ import { GithubAgentToolsProvider } from '#core/agent-tools.js';
6
+ import { GithubSourceControlProvider } from '#core/source-control.js';
7
+ import { closeDb, db } from '#db/db.js';
8
+ import { getGithubInstallationByConnectionId } from '#db/installations.js';
9
+ import { migrationsPath } from '#db/migrations.js';
10
+ import { type CreateGithubE2eRoutesOptions, createGithubE2eRoutes } from '#presentation/e2eRoutes/index.js';
11
+ import { type CreateGithubIntegrationRoutesOptions } from '#presentation/routes/install.js';
12
+ export type { GithubApiClient } from '#api/client.js';
13
+ export { encodeInstallationTokenEnvelope, githubInstallationTokenNamespace, } from '#api/installation-token-envelope.js';
14
+ export { createGithubInstallationTokenProvider, type GithubInstallationTokenProvider, } from '#api/installation-token-provider.js';
15
+ export { type GithubAgentToolCatalogEntry, type GithubAgentToolCategory, type GithubAgentToolId, type GithubAgentToolPermission, type GithubAgentToolPermissionAccess, type GithubAgentToolRequiredPermission, type GithubAgentToolRequiredScope, GithubAgentToolsProvider, githubAgentToolCatalog, } from '#core/agent-tools.js';
16
+ export { GithubIntegrationProviderError } from '#core/errors.js';
17
+ export type { ConnectGithubInstallationInput } from '#core/install.js';
18
+ export { handleGithubCallback } from '#core/install.js';
19
+ export { signGithubInstallState, verifyGithubInstallState } from '#core/state.js';
20
+ export type { HandleGithubEventOutcome } from '#core/webhook.js';
21
+ export { handleGithubEvent } from '#core/webhook.js';
22
+ export type { GithubInstallation, UpsertGithubInstallationParams } from '#db/installations.js';
23
+ export { getGithubInstallationByConnectionId, getGithubInstallationByInstallationId, upsertGithubInstallation, } from '#db/installations.js';
24
+ export { type CreateGithubE2eRoutesOptions, closeDb, createGithubE2eRoutes, db, migrationsPath };
25
+ export interface CreateGithubIntegrationProviderOptions extends Omit<CreateGithubIntegrationRoutesOptions, 'github'> {
26
+ github?: GithubApiClient | undefined;
27
+ coreDb: () => NodePgDatabase<Record<string, unknown>>;
28
+ publishIntegrationEventReceived: PublishIntegrationEventReceivedFn;
29
+ publishSourcePush: PublishSourcePushFn;
30
+ recordDeliveryOnly: RecordDeliveryOnlyFn;
31
+ getIntegrationConnectionById: GetIntegrationConnectionByIdFn;
32
+ getGithubInstallationByConnectionId?: typeof getGithubInstallationByConnectionId | undefined;
33
+ deleteSecrets?: ((params: {
34
+ workspaceId: string;
35
+ namespace: string;
36
+ }) => Promise<number>) | undefined;
37
+ agentTools?: {
38
+ tokenProvider: GithubInstallationTokenProvider;
39
+ } | undefined;
40
+ }
41
+ export declare function createGithubIntegrationProvider(options: CreateGithubIntegrationProviderOptions): {
42
+ provider: "github";
43
+ displayName: string;
44
+ adapters: {
45
+ source_control: GithubSourceControlProvider;
46
+ agent_tools: GithubAgentToolsProvider;
47
+ };
48
+ connectionExternalUrl(connection: {
49
+ id: string;
50
+ }): Promise<string | undefined>;
51
+ routes: import("@shipfox/node-fastify").RouteGroup[];
52
+ };
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,EAC9B,iCAAiC,EACjC,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAwB,KAAK,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAC3E,OAAO,KAAK,EAAC,+BAA+B,EAAC,MAAM,qCAAqC,CAAC;AAEzF,OAAO,EAAC,wBAAwB,EAAC,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAC,2BAA2B,EA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AK,4BAA4B,EAAE,OAAO,EAAE,qBAAqB,EAAE,EAAE,EAAE,cAAc,EAAC,CAAC;AAE/F,MAAM,WAAW,sCACf,SAAQ,IAAI,CAAC,oCAAoC,EAAE,QAAQ,CAAC;IAC5D,MAAM,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;IACrC,MAAM,EAAE,MAAM,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD,+BAA+B,EAAE,iCAAiC,CAAC;IACnE,iBAAiB,EAAE,mBAAmB,CAAC;IACvC,kBAAkB,EAAE,oBAAoB,CAAC;IACzC,4BAA4B,EAAE,8BAA8B,CAAC;IAC7D,mCAAmC,CAAC,EAAE,OAAO,mCAAmC,GAAG,SAAS,CAAC;IAC7F,aAAa,CAAC,EACV,CAAC,CAAC,MAAM,EAAE;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GACvE,SAAS,CAAC;IACd,UAAU,CAAC,EAAE;QAAC,aAAa,EAAE,+BAA+B,CAAA;KAAC,GAAG,SAAS,CAAC;CAC3E;AAED,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,sCAAsC;;;;;;;sCAgBnD;QAAC,EAAE,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;;EAiCrF"}
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ import { createGithubApiClient } from '#api/client.js';
2
+ import { deleteGithubInstallationTokenSecret } from '#api/installation-token-provider.js';
3
+ import { GithubAgentToolsProvider } from '#core/agent-tools.js';
4
+ import { GithubSourceControlProvider } from '#core/source-control.js';
5
+ import { closeDb, db } from '#db/db.js';
6
+ import { getGithubInstallationByConnectionId } from '#db/installations.js';
7
+ import { migrationsPath } from '#db/migrations.js';
8
+ import { createGithubE2eRoutes } from '#presentation/e2eRoutes/index.js';
9
+ import { createGithubIntegrationRoutes } from '#presentation/routes/install.js';
10
+ import { createGithubWebhookRoutes } from '#presentation/routes/webhooks.js';
11
+ export { encodeInstallationTokenEnvelope, githubInstallationTokenNamespace } from '#api/installation-token-envelope.js';
12
+ export { createGithubInstallationTokenProvider } from '#api/installation-token-provider.js';
13
+ export { GithubAgentToolsProvider, githubAgentToolCatalog } from '#core/agent-tools.js';
14
+ export { GithubIntegrationProviderError } from '#core/errors.js';
15
+ export { handleGithubCallback } from '#core/install.js';
16
+ export { signGithubInstallState, verifyGithubInstallState } from '#core/state.js';
17
+ export { handleGithubEvent } from '#core/webhook.js';
18
+ export { getGithubInstallationByConnectionId, getGithubInstallationByInstallationId, upsertGithubInstallation } from '#db/installations.js';
19
+ export { closeDb, createGithubE2eRoutes, db, migrationsPath };
20
+ export function createGithubIntegrationProvider(options) {
21
+ const github = options.github ?? createGithubApiClient();
22
+ const getInstallationByConnectionId = options.getGithubInstallationByConnectionId ?? getGithubInstallationByConnectionId;
23
+ const deleteSecrets = options.deleteSecrets;
24
+ return {
25
+ provider: 'github',
26
+ displayName: 'GitHub',
27
+ adapters: {
28
+ source_control: new GithubSourceControlProvider(github),
29
+ agent_tools: new GithubAgentToolsProvider({
30
+ getInstallationByConnectionId: getInstallationByConnectionId,
31
+ tokenProvider: options.agentTools?.tokenProvider
32
+ })
33
+ },
34
+ async connectionExternalUrl (connection) {
35
+ const installation = await getInstallationByConnectionId(connection.id);
36
+ if (!installation) return undefined;
37
+ const installationId = encodeURIComponent(installation.installationId);
38
+ if (installation.accountType === 'Organization') {
39
+ const login = encodeURIComponent(installation.accountLogin);
40
+ return `https://github.com/organizations/${login}/settings/installations/${installationId}`;
41
+ }
42
+ return `https://github.com/settings/installations/${installationId}`;
43
+ },
44
+ routes: [
45
+ createGithubIntegrationRoutes({
46
+ github,
47
+ getExistingGithubConnection: options.getExistingGithubConnection,
48
+ connectGithubInstallation: options.connectGithubInstallation
49
+ }),
50
+ createGithubWebhookRoutes({
51
+ coreDb: options.coreDb,
52
+ publishIntegrationEventReceived: options.publishIntegrationEventReceived,
53
+ publishSourcePush: options.publishSourcePush,
54
+ recordDeliveryOnly: options.recordDeliveryOnly,
55
+ getIntegrationConnectionById: options.getIntegrationConnectionById,
56
+ deleteInstallationTokenSecret: deleteSecrets ? (params)=>deleteGithubInstallationTokenSecret({
57
+ workspaceId: params.workspaceId,
58
+ installationId: params.installationId,
59
+ deleteSecrets
60
+ }) : undefined
61
+ })
62
+ ]
63
+ };
64
+ }
65
+
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type {\n GetIntegrationConnectionByIdFn,\n PublishIntegrationEventReceivedFn,\n PublishSourcePushFn,\n RecordDeliveryOnlyFn,\n} from '@shipfox/api-integration-core-dto';\nimport type {NodePgDatabase} from 'drizzle-orm/node-postgres';\nimport {createGithubApiClient, type GithubApiClient} from '#api/client.js';\nimport type {GithubInstallationTokenProvider} from '#api/installation-token-provider.js';\nimport {deleteGithubInstallationTokenSecret} from '#api/installation-token-provider.js';\nimport {GithubAgentToolsProvider} from '#core/agent-tools.js';\nimport {GithubSourceControlProvider} from '#core/source-control.js';\nimport {closeDb, db} from '#db/db.js';\nimport {getGithubInstallationByConnectionId} from '#db/installations.js';\nimport {migrationsPath} from '#db/migrations.js';\nimport {\n type CreateGithubE2eRoutesOptions,\n createGithubE2eRoutes,\n} from '#presentation/e2eRoutes/index.js';\nimport {\n type CreateGithubIntegrationRoutesOptions,\n createGithubIntegrationRoutes,\n} from '#presentation/routes/install.js';\nimport {createGithubWebhookRoutes} from '#presentation/routes/webhooks.js';\n\nexport type {GithubApiClient} from '#api/client.js';\nexport {\n encodeInstallationTokenEnvelope,\n githubInstallationTokenNamespace,\n} from '#api/installation-token-envelope.js';\nexport {\n createGithubInstallationTokenProvider,\n type GithubInstallationTokenProvider,\n} from '#api/installation-token-provider.js';\nexport {\n type GithubAgentToolCatalogEntry,\n type GithubAgentToolCategory,\n type GithubAgentToolId,\n type GithubAgentToolPermission,\n type GithubAgentToolPermissionAccess,\n type GithubAgentToolRequiredPermission,\n type GithubAgentToolRequiredScope,\n GithubAgentToolsProvider,\n githubAgentToolCatalog,\n} from '#core/agent-tools.js';\nexport {GithubIntegrationProviderError} from '#core/errors.js';\nexport type {ConnectGithubInstallationInput} from '#core/install.js';\nexport {handleGithubCallback} from '#core/install.js';\nexport {signGithubInstallState, verifyGithubInstallState} from '#core/state.js';\nexport type {HandleGithubEventOutcome} from '#core/webhook.js';\nexport {handleGithubEvent} from '#core/webhook.js';\nexport type {GithubInstallation, UpsertGithubInstallationParams} from '#db/installations.js';\nexport {\n getGithubInstallationByConnectionId,\n getGithubInstallationByInstallationId,\n upsertGithubInstallation,\n} from '#db/installations.js';\nexport {type CreateGithubE2eRoutesOptions, closeDb, createGithubE2eRoutes, db, migrationsPath};\n\nexport interface CreateGithubIntegrationProviderOptions\n extends Omit<CreateGithubIntegrationRoutesOptions, 'github'> {\n github?: GithubApiClient | undefined;\n coreDb: () => NodePgDatabase<Record<string, unknown>>;\n publishIntegrationEventReceived: PublishIntegrationEventReceivedFn;\n publishSourcePush: PublishSourcePushFn;\n recordDeliveryOnly: RecordDeliveryOnlyFn;\n getIntegrationConnectionById: GetIntegrationConnectionByIdFn;\n getGithubInstallationByConnectionId?: typeof getGithubInstallationByConnectionId | undefined;\n deleteSecrets?:\n | ((params: {workspaceId: string; namespace: string}) => Promise<number>)\n | undefined;\n agentTools?: {tokenProvider: GithubInstallationTokenProvider} | undefined;\n}\n\nexport function createGithubIntegrationProvider(options: CreateGithubIntegrationProviderOptions) {\n const github = options.github ?? createGithubApiClient();\n const getInstallationByConnectionId =\n options.getGithubInstallationByConnectionId ?? getGithubInstallationByConnectionId;\n const deleteSecrets = options.deleteSecrets;\n\n return {\n provider: 'github' as const,\n displayName: 'GitHub',\n adapters: {\n source_control: new GithubSourceControlProvider(github),\n agent_tools: new GithubAgentToolsProvider({\n getInstallationByConnectionId: getInstallationByConnectionId,\n tokenProvider: options.agentTools?.tokenProvider,\n }),\n },\n async connectionExternalUrl(connection: {id: string}): Promise<string | undefined> {\n const installation = await getInstallationByConnectionId(connection.id);\n if (!installation) return undefined;\n const installationId = encodeURIComponent(installation.installationId);\n if (installation.accountType === 'Organization') {\n const login = encodeURIComponent(installation.accountLogin);\n return `https://github.com/organizations/${login}/settings/installations/${installationId}`;\n }\n return `https://github.com/settings/installations/${installationId}`;\n },\n routes: [\n createGithubIntegrationRoutes({\n github,\n getExistingGithubConnection: options.getExistingGithubConnection,\n connectGithubInstallation: options.connectGithubInstallation,\n }),\n createGithubWebhookRoutes({\n coreDb: options.coreDb,\n publishIntegrationEventReceived: options.publishIntegrationEventReceived,\n publishSourcePush: options.publishSourcePush,\n recordDeliveryOnly: options.recordDeliveryOnly,\n getIntegrationConnectionById: options.getIntegrationConnectionById,\n deleteInstallationTokenSecret: deleteSecrets\n ? (params) =>\n deleteGithubInstallationTokenSecret({\n workspaceId: params.workspaceId,\n installationId: params.installationId,\n deleteSecrets,\n })\n : undefined,\n }),\n ],\n };\n}\n"],"names":["createGithubApiClient","deleteGithubInstallationTokenSecret","GithubAgentToolsProvider","GithubSourceControlProvider","closeDb","db","getGithubInstallationByConnectionId","migrationsPath","createGithubE2eRoutes","createGithubIntegrationRoutes","createGithubWebhookRoutes","encodeInstallationTokenEnvelope","githubInstallationTokenNamespace","createGithubInstallationTokenProvider","githubAgentToolCatalog","GithubIntegrationProviderError","handleGithubCallback","signGithubInstallState","verifyGithubInstallState","handleGithubEvent","getGithubInstallationByInstallationId","upsertGithubInstallation","createGithubIntegrationProvider","options","github","getInstallationByConnectionId","deleteSecrets","provider","displayName","adapters","source_control","agent_tools","tokenProvider","agentTools","connectionExternalUrl","connection","installation","id","undefined","installationId","encodeURIComponent","accountType","login","accountLogin","routes","getExistingGithubConnection","connectGithubInstallation","coreDb","publishIntegrationEventReceived","publishSourcePush","recordDeliveryOnly","getIntegrationConnectionById","deleteInstallationTokenSecret","params","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AA8BU,WAAWE,EAAE;YACtE,IAAI,CAACD,cAAc,OAAOE;YAC1B,MAAMC,iBAAiBC,mBAAmBJ,aAAaG,cAAc;YACrE,IAAIH,aAAaK,WAAW,KAAK,gBAAgB;gBAC/C,MAAMC,QAAQF,mBAAmBJ,aAAaO,YAAY;gBAC1D,OAAO,CAAC,iCAAiC,EAAED,MAAM,wBAAwB,EAAEH,gBAAgB;YAC7F;YACA,OAAO,CAAC,0CAA0C,EAAEA,gBAAgB;QACtE;QACAK,QAAQ;YACNnC,8BAA8B;gBAC5Be;gBACAqB,6BAA6BtB,QAAQsB,2BAA2B;gBAChEC,2BAA2BvB,QAAQuB,yBAAyB;YAC9D;YACApC,0BAA0B;gBACxBqC,QAAQxB,QAAQwB,MAAM;gBACtBC,iCAAiCzB,QAAQyB,+BAA+B;gBACxEC,mBAAmB1B,QAAQ0B,iBAAiB;gBAC5CC,oBAAoB3B,QAAQ2B,kBAAkB;gBAC9CC,8BAA8B5B,QAAQ4B,4BAA4B;gBAClEC,+BAA+B1B,gBAC3B,CAAC2B,SACCpD,oCAAoC;wBAClCqD,aAAaD,OAAOC,WAAW;wBAC/Bf,gBAAgBc,OAAOd,cAAc;wBACrCb;oBACF,KACFY;YACN;SACD;IACH;AACF"}
@@ -0,0 +1,2 @@
1
+ export * from './instance.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './instance.js';
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/metrics/index.ts"],"sourcesContent":["export * from './instance.js';\n"],"names":[],"mappings":"AAAA,cAAc,gBAAgB"}
@@ -0,0 +1,14 @@
1
+ import type { IntegrationProviderErrorReason } from '@shipfox/api-integration-core-dto';
2
+ import type { MintErrorClass } from '#api/installation-token-envelope.js';
3
+ export type GithubInstallationTokenLookupOutcome = 'ram-hit' | 'db-hit' | 'minted' | 'served-stale' | 'backoff' | 'contended-poll';
4
+ export declare function recordInstallationTokenLookup(outcome: GithubInstallationTokenLookupOutcome): void;
5
+ export declare function recordInstallationTokenMint(params: {
6
+ outcome: 'success' | 'failure';
7
+ durationMs: number;
8
+ }): void;
9
+ export declare function recordInstallationTokenLockWait(durationMs: number): void;
10
+ export declare function recordInstallationTokenBackoff(params: {
11
+ reason: IntegrationProviderErrorReason;
12
+ class: MintErrorClass;
13
+ }): void;
14
+ //# sourceMappingURL=instance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/metrics/instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,mCAAmC,CAAC;AAEtF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qCAAqC,CAAC;AAIxE,MAAM,MAAM,oCAAoC,GAC5C,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,cAAc,GACd,SAAS,GACT,gBAAgB,CAAC;AA8CrB,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,oCAAoC,GAAG,IAAI,CAEjG;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAClD,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,IAAI,CAKP;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAExE;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE;IACrD,MAAM,EAAE,8BAA8B,CAAC;IACvC,KAAK,EAAE,cAAc,CAAC;CACvB,GAAG,IAAI,CAEP"}
@@ -0,0 +1,75 @@
1
+ import { instanceMetrics } from '@shipfox/node-opentelemetry';
2
+ const meter = instanceMetrics.getMeter('github');
3
+ const installationTokenLookupCount = meter.createCounter('github_installation_token_lookup', {
4
+ description: 'GitHub installation token cache lookups by serving outcome'
5
+ });
6
+ const installationTokenMintCount = meter.createCounter('github_installation_token_mint', {
7
+ description: 'GitHub installation token mint attempts by outcome'
8
+ });
9
+ const installationTokenMintDuration = meter.createHistogram('github_installation_token_mint_duration', {
10
+ description: 'GitHub installation token mint duration',
11
+ unit: 'ms',
12
+ advice: {
13
+ explicitBucketBoundaries: [
14
+ 10,
15
+ 50,
16
+ 100,
17
+ 250,
18
+ 500,
19
+ 1000,
20
+ 2500,
21
+ 5000,
22
+ 10000
23
+ ]
24
+ }
25
+ });
26
+ const installationTokenLockWaitDuration = meter.createHistogram('github_installation_token_lock_wait_duration', {
27
+ description: 'GitHub installation token advisory lock acquire and hold duration',
28
+ unit: 'ms',
29
+ advice: {
30
+ explicitBucketBoundaries: [
31
+ 0,
32
+ 1,
33
+ 5,
34
+ 10,
35
+ 25,
36
+ 50,
37
+ 100,
38
+ 250,
39
+ 500,
40
+ 1000,
41
+ 5000
42
+ ]
43
+ }
44
+ });
45
+ const installationTokenBackoffCount = meter.createCounter('github_installation_token_backoff', {
46
+ description: 'GitHub installation token mint backoff activations by reason and class'
47
+ });
48
+ function recordMetric(record) {
49
+ try {
50
+ record();
51
+ } catch {
52
+ // Metrics must not affect GitHub provider outcomes.
53
+ }
54
+ }
55
+ export function recordInstallationTokenLookup(outcome) {
56
+ recordMetric(()=>installationTokenLookupCount.add(1, {
57
+ outcome
58
+ }));
59
+ }
60
+ export function recordInstallationTokenMint(params) {
61
+ recordMetric(()=>{
62
+ installationTokenMintCount.add(1, {
63
+ outcome: params.outcome
64
+ });
65
+ installationTokenMintDuration.record(params.durationMs);
66
+ });
67
+ }
68
+ export function recordInstallationTokenLockWait(durationMs) {
69
+ recordMetric(()=>installationTokenLockWaitDuration.record(durationMs));
70
+ }
71
+ export function recordInstallationTokenBackoff(params) {
72
+ recordMetric(()=>installationTokenBackoffCount.add(1, params));
73
+ }
74
+
75
+ //# sourceMappingURL=instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/metrics/instance.ts"],"sourcesContent":["import type {IntegrationProviderErrorReason} from '@shipfox/api-integration-core-dto';\nimport {instanceMetrics} from '@shipfox/node-opentelemetry';\nimport type {MintErrorClass} from '#api/installation-token-envelope.js';\n\nconst meter = instanceMetrics.getMeter('github');\n\nexport type GithubInstallationTokenLookupOutcome =\n | 'ram-hit'\n | 'db-hit'\n | 'minted'\n | 'served-stale'\n | 'backoff'\n | 'contended-poll';\n\nconst installationTokenLookupCount = meter.createCounter<{\n outcome: GithubInstallationTokenLookupOutcome;\n}>('github_installation_token_lookup', {\n description: 'GitHub installation token cache lookups by serving outcome',\n});\n\nconst installationTokenMintCount = meter.createCounter<{outcome: 'success' | 'failure'}>(\n 'github_installation_token_mint',\n {description: 'GitHub installation token mint attempts by outcome'},\n);\n\nconst installationTokenMintDuration = meter.createHistogram<Record<string, never>>(\n 'github_installation_token_mint_duration',\n {\n description: 'GitHub installation token mint duration',\n unit: 'ms',\n advice: {explicitBucketBoundaries: [10, 50, 100, 250, 500, 1000, 2500, 5000, 10000]},\n },\n);\n\nconst installationTokenLockWaitDuration = meter.createHistogram<Record<string, never>>(\n 'github_installation_token_lock_wait_duration',\n {\n description: 'GitHub installation token advisory lock acquire and hold duration',\n unit: 'ms',\n advice: {explicitBucketBoundaries: [0, 1, 5, 10, 25, 50, 100, 250, 500, 1000, 5000]},\n },\n);\n\nconst installationTokenBackoffCount = meter.createCounter<{\n reason: IntegrationProviderErrorReason;\n class: MintErrorClass;\n}>('github_installation_token_backoff', {\n description: 'GitHub installation token mint backoff activations by reason and class',\n});\n\nfunction recordMetric(record: () => void): void {\n try {\n record();\n } catch {\n // Metrics must not affect GitHub provider outcomes.\n }\n}\n\nexport function recordInstallationTokenLookup(outcome: GithubInstallationTokenLookupOutcome): void {\n recordMetric(() => installationTokenLookupCount.add(1, {outcome}));\n}\n\nexport function recordInstallationTokenMint(params: {\n outcome: 'success' | 'failure';\n durationMs: number;\n}): void {\n recordMetric(() => {\n installationTokenMintCount.add(1, {outcome: params.outcome});\n installationTokenMintDuration.record(params.durationMs);\n });\n}\n\nexport function recordInstallationTokenLockWait(durationMs: number): void {\n recordMetric(() => installationTokenLockWaitDuration.record(durationMs));\n}\n\nexport function recordInstallationTokenBackoff(params: {\n reason: IntegrationProviderErrorReason;\n class: MintErrorClass;\n}): void {\n recordMetric(() => installationTokenBackoffCount.add(1, params));\n}\n"],"names":["instanceMetrics","meter","getMeter","installationTokenLookupCount","createCounter","description","installationTokenMintCount","installationTokenMintDuration","createHistogram","unit","advice","explicitBucketBoundaries","installationTokenLockWaitDuration","installationTokenBackoffCount","recordMetric","record","recordInstallationTokenLookup","outcome","add","recordInstallationTokenMint","params","durationMs","recordInstallationTokenLockWait","recordInstallationTokenBackoff"],"mappings":"AACA,SAAQA,eAAe,QAAO,8BAA8B;AAG5D,MAAMC,QAAQD,gBAAgBE,QAAQ,CAAC;AAUvC,MAAMC,+BAA+BF,MAAMG,aAAa,CAErD,oCAAoC;IACrCC,aAAa;AACf;AAEA,MAAMC,6BAA6BL,MAAMG,aAAa,CACpD,kCACA;IAACC,aAAa;AAAoD;AAGpE,MAAME,gCAAgCN,MAAMO,eAAe,CACzD,2CACA;IACEH,aAAa;IACbI,MAAM;IACNC,QAAQ;QAACC,0BAA0B;YAAC;YAAI;YAAI;YAAK;YAAK;YAAK;YAAM;YAAM;YAAM;SAAM;IAAA;AACrF;AAGF,MAAMC,oCAAoCX,MAAMO,eAAe,CAC7D,gDACA;IACEH,aAAa;IACbI,MAAM;IACNC,QAAQ;QAACC,0BAA0B;YAAC;YAAG;YAAG;YAAG;YAAI;YAAI;YAAI;YAAK;YAAK;YAAK;YAAM;SAAK;IAAA;AACrF;AAGF,MAAME,gCAAgCZ,MAAMG,aAAa,CAGtD,qCAAqC;IACtCC,aAAa;AACf;AAEA,SAASS,aAAaC,MAAkB;IACtC,IAAI;QACFA;IACF,EAAE,OAAM;IACN,oDAAoD;IACtD;AACF;AAEA,OAAO,SAASC,8BAA8BC,OAA6C;IACzFH,aAAa,IAAMX,6BAA6Be,GAAG,CAAC,GAAG;YAACD;QAAO;AACjE;AAEA,OAAO,SAASE,4BAA4BC,MAG3C;IACCN,aAAa;QACXR,2BAA2BY,GAAG,CAAC,GAAG;YAACD,SAASG,OAAOH,OAAO;QAAA;QAC1DV,8BAA8BQ,MAAM,CAACK,OAAOC,UAAU;IACxD;AACF;AAEA,OAAO,SAASC,gCAAgCD,UAAkB;IAChEP,aAAa,IAAMF,kCAAkCG,MAAM,CAACM;AAC9D;AAEA,OAAO,SAASE,+BAA+BH,MAG9C;IACCN,aAAa,IAAMD,8BAA8BK,GAAG,CAAC,GAAGE;AAC1D"}
@@ -0,0 +1,15 @@
1
+ import { type IntegrationConnection } from '@shipfox/api-integration-core-dto';
2
+ export declare function toIntegrationConnectionDto(connection: IntegrationConnection<'github'>): {
3
+ created_at: string;
4
+ updated_at: string;
5
+ external_url?: string;
6
+ id: string;
7
+ workspace_id: string;
8
+ provider: string;
9
+ external_account_id: string;
10
+ slug: string;
11
+ display_name: string;
12
+ lifecycle_status: import("@shipfox/api-integration-core-dto").IntegrationConnectionLifecycleStatus;
13
+ capabilities: import("@shipfox/api-integration-core-dto").IntegrationCapability[];
14
+ };
15
+ //# sourceMappingURL=integrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,mCAAmC,CAAC;AAE3C,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,qBAAqB,CAAC,QAAQ,CAAC;;;;;;;;;;;;EAErF"}
@@ -0,0 +1,10 @@
1
+ import { toIntegrationConnectionDto as toCoreIntegrationConnectionDto } from '@shipfox/api-integration-core-dto';
2
+ export function toIntegrationConnectionDto(connection) {
3
+ return toCoreIntegrationConnectionDto(connection, {
4
+ capabilities: [
5
+ 'source_control'
6
+ ]
7
+ });
8
+ }
9
+
10
+ //# sourceMappingURL=integrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/presentation/dto/integrations.ts"],"sourcesContent":["import {\n type IntegrationConnection,\n toIntegrationConnectionDto as toCoreIntegrationConnectionDto,\n} from '@shipfox/api-integration-core-dto';\n\nexport function toIntegrationConnectionDto(connection: IntegrationConnection<'github'>) {\n return toCoreIntegrationConnectionDto(connection, {capabilities: ['source_control']});\n}\n"],"names":["toIntegrationConnectionDto","toCoreIntegrationConnectionDto","connection","capabilities"],"mappings":"AAAA,SAEEA,8BAA8BC,8BAA8B,QACvD,oCAAoC;AAE3C,OAAO,SAASD,2BAA2BE,UAA2C;IACpF,OAAOD,+BAA+BC,YAAY;QAACC,cAAc;YAAC;SAAiB;IAAA;AACrF"}
@@ -0,0 +1,11 @@
1
+ import type { IntegrationCapability, IntegrationConnection } from '@shipfox/api-integration-core-dto';
2
+ import type { ConnectGithubInstallationInput } from '#core/install.js';
3
+ export interface CreateE2eGithubConnectionRouteOptions {
4
+ getExistingGithubConnection: (input: {
5
+ installationId: string;
6
+ }) => Promise<IntegrationConnection<'github'> | undefined>;
7
+ connectGithubInstallation: (input: ConnectGithubInstallationInput) => Promise<IntegrationConnection<'github'>>;
8
+ connectionCapabilities: IntegrationCapability[];
9
+ }
10
+ export declare function createE2eGithubConnectionRoute(options: CreateE2eGithubConnectionRouteOptions): import("@shipfox/node-fastify").RouteDefinition;
11
+ //# sourceMappingURL=create-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-connection.d.ts","sourceRoot":"","sources":["../../../src/presentation/e2eRoutes/create-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,qBAAqB,EAAE,qBAAqB,EAAC,MAAM,mCAAmC,CAAC;AAOpG,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,kBAAkB,CAAC;AAErE,MAAM,WAAW,qCAAqC;IACpD,2BAA2B,EAAE,CAAC,KAAK,EAAE;QACnC,cAAc,EAAE,MAAM,CAAC;KACxB,KAAK,OAAO,CAAC,qBAAqB,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,CAAC;IAC3D,yBAAyB,EAAE,CACzB,KAAK,EAAE,8BAA8B,KAClC,OAAO,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,sBAAsB,EAAE,qBAAqB,EAAE,CAAC;CACjD;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,qCAAqC,mDAkD5F"}