@shipfox/api-integration-jira 4.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 (73) 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 +11 -0
  5. package/LICENSE +21 -0
  6. package/README.md +5 -0
  7. package/dist/config.d.ts +10 -0
  8. package/dist/config.d.ts.map +1 -0
  9. package/dist/config.js +28 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/core/errors.d.ts +10 -0
  12. package/dist/core/errors.d.ts.map +1 -0
  13. package/dist/core/errors.js +20 -0
  14. package/dist/core/errors.js.map +1 -0
  15. package/dist/core/tokens.d.ts +36 -0
  16. package/dist/core/tokens.d.ts.map +1 -0
  17. package/dist/core/tokens.js +40 -0
  18. package/dist/core/tokens.js.map +1 -0
  19. package/dist/db/db.d.ts +475 -0
  20. package/dist/db/db.d.ts.map +1 -0
  21. package/dist/db/db.js +18 -0
  22. package/dist/db/db.js.map +1 -0
  23. package/dist/db/installations.d.ts +41 -0
  24. package/dist/db/installations.d.ts.map +1 -0
  25. package/dist/db/installations.js +65 -0
  26. package/dist/db/installations.js.map +1 -0
  27. package/dist/db/migrations.d.ts +2 -0
  28. package/dist/db/migrations.d.ts.map +1 -0
  29. package/dist/db/migrations.js +5 -0
  30. package/dist/db/migrations.js.map +1 -0
  31. package/dist/db/schema/common.d.ts +2 -0
  32. package/dist/db/schema/common.d.ts.map +1 -0
  33. package/dist/db/schema/common.js +4 -0
  34. package/dist/db/schema/common.js.map +1 -0
  35. package/dist/db/schema/installations.d.ts +239 -0
  36. package/dist/db/schema/installations.d.ts.map +1 -0
  37. package/dist/db/schema/installations.js +48 -0
  38. package/dist/db/schema/installations.js.map +1 -0
  39. package/dist/index.d.ts +15 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +16 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/tsconfig.test.tsbuildinfo +1 -0
  44. package/drizzle/0000_whole_master_chief.sql +18 -0
  45. package/drizzle/meta/0000_snapshot.json +145 -0
  46. package/drizzle/meta/_journal.json +13 -0
  47. package/drizzle.config.ts +7 -0
  48. package/package.json +63 -0
  49. package/src/config.test.ts +37 -0
  50. package/src/config.ts +27 -0
  51. package/src/core/errors.ts +22 -0
  52. package/src/core/tokens.test.ts +106 -0
  53. package/src/core/tokens.ts +77 -0
  54. package/src/db/db.ts +16 -0
  55. package/src/db/installations.test.ts +93 -0
  56. package/src/db/installations.ts +125 -0
  57. package/src/db/migrations.ts +4 -0
  58. package/src/db/schema/common.ts +3 -0
  59. package/src/db/schema/installations.ts +48 -0
  60. package/src/index.test.ts +9 -0
  61. package/src/index.ts +36 -0
  62. package/test/api-secrets.d.ts +26 -0
  63. package/test/env.ts +15 -0
  64. package/test/factories/index.ts +1 -0
  65. package/test/factories/jira-installation.ts +35 -0
  66. package/test/globalSetup.ts +23 -0
  67. package/test/index.ts +1 -0
  68. package/test/setup.ts +17 -0
  69. package/tsconfig.build.json +9 -0
  70. package/tsconfig.build.tsbuildinfo +1 -0
  71. package/tsconfig.json +3 -0
  72. package/tsconfig.test.json +9 -0
  73. package/vitest.config.ts +12 -0
@@ -0,0 +1,475 @@
1
+ import { type NodePgDatabase } from '@shipfox/node-drizzle';
2
+ export declare const schema: {
3
+ jiraInstallations: import("drizzle-orm/pg-core").PgTableWithColumns<{
4
+ name: "installations";
5
+ schema: undefined;
6
+ columns: {
7
+ id: import("drizzle-orm/pg-core").PgColumn<{
8
+ name: "id";
9
+ tableName: "installations";
10
+ dataType: "string";
11
+ columnType: "PgUUID";
12
+ data: string;
13
+ driverParam: string;
14
+ notNull: true;
15
+ hasDefault: true;
16
+ isPrimaryKey: true;
17
+ isAutoincrement: false;
18
+ hasRuntimeDefault: false;
19
+ enumValues: undefined;
20
+ baseColumn: never;
21
+ identity: undefined;
22
+ generated: undefined;
23
+ }, {}, {}>;
24
+ connectionId: import("drizzle-orm/pg-core").PgColumn<{
25
+ name: "connection_id";
26
+ tableName: "installations";
27
+ dataType: "string";
28
+ columnType: "PgUUID";
29
+ data: string;
30
+ driverParam: string;
31
+ notNull: true;
32
+ hasDefault: false;
33
+ isPrimaryKey: false;
34
+ isAutoincrement: false;
35
+ hasRuntimeDefault: false;
36
+ enumValues: undefined;
37
+ baseColumn: never;
38
+ identity: undefined;
39
+ generated: undefined;
40
+ }, {}, {}>;
41
+ cloudId: import("drizzle-orm/pg-core").PgColumn<{
42
+ name: "cloud_id";
43
+ tableName: "installations";
44
+ dataType: "string";
45
+ columnType: "PgText";
46
+ data: string;
47
+ driverParam: string;
48
+ notNull: true;
49
+ hasDefault: false;
50
+ isPrimaryKey: false;
51
+ isAutoincrement: false;
52
+ hasRuntimeDefault: false;
53
+ enumValues: [string, ...string[]];
54
+ baseColumn: never;
55
+ identity: undefined;
56
+ generated: undefined;
57
+ }, {}, {}>;
58
+ siteUrl: import("drizzle-orm/pg-core").PgColumn<{
59
+ name: "site_url";
60
+ tableName: "installations";
61
+ dataType: "string";
62
+ columnType: "PgText";
63
+ data: string;
64
+ driverParam: string;
65
+ notNull: true;
66
+ hasDefault: false;
67
+ isPrimaryKey: false;
68
+ isAutoincrement: false;
69
+ hasRuntimeDefault: false;
70
+ enumValues: [string, ...string[]];
71
+ baseColumn: never;
72
+ identity: undefined;
73
+ generated: undefined;
74
+ }, {}, {}>;
75
+ siteName: import("drizzle-orm/pg-core").PgColumn<{
76
+ name: "site_name";
77
+ tableName: "installations";
78
+ dataType: "string";
79
+ columnType: "PgText";
80
+ data: string;
81
+ driverParam: string;
82
+ notNull: true;
83
+ hasDefault: false;
84
+ isPrimaryKey: false;
85
+ isAutoincrement: false;
86
+ hasRuntimeDefault: false;
87
+ enumValues: [string, ...string[]];
88
+ baseColumn: never;
89
+ identity: undefined;
90
+ generated: undefined;
91
+ }, {}, {}>;
92
+ authorizingAccountId: import("drizzle-orm/pg-core").PgColumn<{
93
+ name: "authorizing_account_id";
94
+ tableName: "installations";
95
+ dataType: "string";
96
+ columnType: "PgText";
97
+ data: string;
98
+ driverParam: string;
99
+ notNull: true;
100
+ hasDefault: false;
101
+ isPrimaryKey: false;
102
+ isAutoincrement: false;
103
+ hasRuntimeDefault: false;
104
+ enumValues: [string, ...string[]];
105
+ baseColumn: never;
106
+ identity: undefined;
107
+ generated: undefined;
108
+ }, {}, {}>;
109
+ scopes: import("drizzle-orm/pg-core").PgColumn<{
110
+ name: "scopes";
111
+ tableName: "installations";
112
+ dataType: "json";
113
+ columnType: "PgJsonb";
114
+ data: string[];
115
+ driverParam: unknown;
116
+ notNull: true;
117
+ hasDefault: false;
118
+ isPrimaryKey: false;
119
+ isAutoincrement: false;
120
+ hasRuntimeDefault: false;
121
+ enumValues: undefined;
122
+ baseColumn: never;
123
+ identity: undefined;
124
+ generated: undefined;
125
+ }, {}, {
126
+ $type: string[];
127
+ }>;
128
+ webhookIds: import("drizzle-orm/pg-core").PgColumn<{
129
+ name: "webhook_ids";
130
+ tableName: "installations";
131
+ dataType: "json";
132
+ columnType: "PgJsonb";
133
+ data: number[];
134
+ driverParam: unknown;
135
+ notNull: true;
136
+ hasDefault: true;
137
+ isPrimaryKey: false;
138
+ isAutoincrement: false;
139
+ hasRuntimeDefault: false;
140
+ enumValues: undefined;
141
+ baseColumn: never;
142
+ identity: undefined;
143
+ generated: undefined;
144
+ }, {}, {
145
+ $type: number[];
146
+ }>;
147
+ webhookExpiresAt: import("drizzle-orm/pg-core").PgColumn<{
148
+ name: "webhook_expires_at";
149
+ tableName: "installations";
150
+ dataType: "date";
151
+ columnType: "PgTimestamp";
152
+ data: Date;
153
+ driverParam: string;
154
+ notNull: false;
155
+ hasDefault: false;
156
+ isPrimaryKey: false;
157
+ isAutoincrement: false;
158
+ hasRuntimeDefault: false;
159
+ enumValues: undefined;
160
+ baseColumn: never;
161
+ identity: undefined;
162
+ generated: undefined;
163
+ }, {}, {}>;
164
+ status: import("drizzle-orm/pg-core").PgColumn<{
165
+ name: "status";
166
+ tableName: "installations";
167
+ dataType: "string";
168
+ columnType: "PgText";
169
+ data: import("./installations.js").JiraInstallationStatus;
170
+ driverParam: string;
171
+ notNull: true;
172
+ hasDefault: false;
173
+ isPrimaryKey: false;
174
+ isAutoincrement: false;
175
+ hasRuntimeDefault: false;
176
+ enumValues: [string, ...string[]];
177
+ baseColumn: never;
178
+ identity: undefined;
179
+ generated: undefined;
180
+ }, {}, {
181
+ $type: import("./installations.js").JiraInstallationStatus;
182
+ }>;
183
+ tokenExpiresAt: import("drizzle-orm/pg-core").PgColumn<{
184
+ name: "token_expires_at";
185
+ tableName: "installations";
186
+ dataType: "date";
187
+ columnType: "PgTimestamp";
188
+ data: Date;
189
+ driverParam: string;
190
+ notNull: false;
191
+ hasDefault: false;
192
+ isPrimaryKey: false;
193
+ isAutoincrement: false;
194
+ hasRuntimeDefault: false;
195
+ enumValues: undefined;
196
+ baseColumn: never;
197
+ identity: undefined;
198
+ generated: undefined;
199
+ }, {}, {}>;
200
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
201
+ name: "created_at";
202
+ tableName: "installations";
203
+ dataType: "date";
204
+ columnType: "PgTimestamp";
205
+ data: Date;
206
+ driverParam: string;
207
+ notNull: true;
208
+ hasDefault: true;
209
+ isPrimaryKey: false;
210
+ isAutoincrement: false;
211
+ hasRuntimeDefault: false;
212
+ enumValues: undefined;
213
+ baseColumn: never;
214
+ identity: undefined;
215
+ generated: undefined;
216
+ }, {}, {}>;
217
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
218
+ name: "updated_at";
219
+ tableName: "installations";
220
+ dataType: "date";
221
+ columnType: "PgTimestamp";
222
+ data: Date;
223
+ driverParam: string;
224
+ notNull: true;
225
+ hasDefault: true;
226
+ isPrimaryKey: false;
227
+ isAutoincrement: false;
228
+ hasRuntimeDefault: false;
229
+ enumValues: undefined;
230
+ baseColumn: never;
231
+ identity: undefined;
232
+ generated: undefined;
233
+ }, {}, {}>;
234
+ };
235
+ dialect: "pg";
236
+ }>;
237
+ };
238
+ export declare function db(): NodePgDatabase<{
239
+ jiraInstallations: import("drizzle-orm/pg-core").PgTableWithColumns<{
240
+ name: "installations";
241
+ schema: undefined;
242
+ columns: {
243
+ id: import("drizzle-orm/pg-core").PgColumn<{
244
+ name: "id";
245
+ tableName: "installations";
246
+ dataType: "string";
247
+ columnType: "PgUUID";
248
+ data: string;
249
+ driverParam: string;
250
+ notNull: true;
251
+ hasDefault: true;
252
+ isPrimaryKey: true;
253
+ isAutoincrement: false;
254
+ hasRuntimeDefault: false;
255
+ enumValues: undefined;
256
+ baseColumn: never;
257
+ identity: undefined;
258
+ generated: undefined;
259
+ }, {}, {}>;
260
+ connectionId: import("drizzle-orm/pg-core").PgColumn<{
261
+ name: "connection_id";
262
+ tableName: "installations";
263
+ dataType: "string";
264
+ columnType: "PgUUID";
265
+ data: string;
266
+ driverParam: string;
267
+ notNull: true;
268
+ hasDefault: false;
269
+ isPrimaryKey: false;
270
+ isAutoincrement: false;
271
+ hasRuntimeDefault: false;
272
+ enumValues: undefined;
273
+ baseColumn: never;
274
+ identity: undefined;
275
+ generated: undefined;
276
+ }, {}, {}>;
277
+ cloudId: import("drizzle-orm/pg-core").PgColumn<{
278
+ name: "cloud_id";
279
+ tableName: "installations";
280
+ dataType: "string";
281
+ columnType: "PgText";
282
+ data: string;
283
+ driverParam: string;
284
+ notNull: true;
285
+ hasDefault: false;
286
+ isPrimaryKey: false;
287
+ isAutoincrement: false;
288
+ hasRuntimeDefault: false;
289
+ enumValues: [string, ...string[]];
290
+ baseColumn: never;
291
+ identity: undefined;
292
+ generated: undefined;
293
+ }, {}, {}>;
294
+ siteUrl: import("drizzle-orm/pg-core").PgColumn<{
295
+ name: "site_url";
296
+ tableName: "installations";
297
+ dataType: "string";
298
+ columnType: "PgText";
299
+ data: string;
300
+ driverParam: string;
301
+ notNull: true;
302
+ hasDefault: false;
303
+ isPrimaryKey: false;
304
+ isAutoincrement: false;
305
+ hasRuntimeDefault: false;
306
+ enumValues: [string, ...string[]];
307
+ baseColumn: never;
308
+ identity: undefined;
309
+ generated: undefined;
310
+ }, {}, {}>;
311
+ siteName: import("drizzle-orm/pg-core").PgColumn<{
312
+ name: "site_name";
313
+ tableName: "installations";
314
+ dataType: "string";
315
+ columnType: "PgText";
316
+ data: string;
317
+ driverParam: string;
318
+ notNull: true;
319
+ hasDefault: false;
320
+ isPrimaryKey: false;
321
+ isAutoincrement: false;
322
+ hasRuntimeDefault: false;
323
+ enumValues: [string, ...string[]];
324
+ baseColumn: never;
325
+ identity: undefined;
326
+ generated: undefined;
327
+ }, {}, {}>;
328
+ authorizingAccountId: import("drizzle-orm/pg-core").PgColumn<{
329
+ name: "authorizing_account_id";
330
+ tableName: "installations";
331
+ dataType: "string";
332
+ columnType: "PgText";
333
+ data: string;
334
+ driverParam: string;
335
+ notNull: true;
336
+ hasDefault: false;
337
+ isPrimaryKey: false;
338
+ isAutoincrement: false;
339
+ hasRuntimeDefault: false;
340
+ enumValues: [string, ...string[]];
341
+ baseColumn: never;
342
+ identity: undefined;
343
+ generated: undefined;
344
+ }, {}, {}>;
345
+ scopes: import("drizzle-orm/pg-core").PgColumn<{
346
+ name: "scopes";
347
+ tableName: "installations";
348
+ dataType: "json";
349
+ columnType: "PgJsonb";
350
+ data: string[];
351
+ driverParam: unknown;
352
+ notNull: true;
353
+ hasDefault: false;
354
+ isPrimaryKey: false;
355
+ isAutoincrement: false;
356
+ hasRuntimeDefault: false;
357
+ enumValues: undefined;
358
+ baseColumn: never;
359
+ identity: undefined;
360
+ generated: undefined;
361
+ }, {}, {
362
+ $type: string[];
363
+ }>;
364
+ webhookIds: import("drizzle-orm/pg-core").PgColumn<{
365
+ name: "webhook_ids";
366
+ tableName: "installations";
367
+ dataType: "json";
368
+ columnType: "PgJsonb";
369
+ data: number[];
370
+ driverParam: unknown;
371
+ notNull: true;
372
+ hasDefault: true;
373
+ isPrimaryKey: false;
374
+ isAutoincrement: false;
375
+ hasRuntimeDefault: false;
376
+ enumValues: undefined;
377
+ baseColumn: never;
378
+ identity: undefined;
379
+ generated: undefined;
380
+ }, {}, {
381
+ $type: number[];
382
+ }>;
383
+ webhookExpiresAt: import("drizzle-orm/pg-core").PgColumn<{
384
+ name: "webhook_expires_at";
385
+ tableName: "installations";
386
+ dataType: "date";
387
+ columnType: "PgTimestamp";
388
+ data: Date;
389
+ driverParam: string;
390
+ notNull: false;
391
+ hasDefault: false;
392
+ isPrimaryKey: false;
393
+ isAutoincrement: false;
394
+ hasRuntimeDefault: false;
395
+ enumValues: undefined;
396
+ baseColumn: never;
397
+ identity: undefined;
398
+ generated: undefined;
399
+ }, {}, {}>;
400
+ status: import("drizzle-orm/pg-core").PgColumn<{
401
+ name: "status";
402
+ tableName: "installations";
403
+ dataType: "string";
404
+ columnType: "PgText";
405
+ data: import("./installations.js").JiraInstallationStatus;
406
+ driverParam: string;
407
+ notNull: true;
408
+ hasDefault: false;
409
+ isPrimaryKey: false;
410
+ isAutoincrement: false;
411
+ hasRuntimeDefault: false;
412
+ enumValues: [string, ...string[]];
413
+ baseColumn: never;
414
+ identity: undefined;
415
+ generated: undefined;
416
+ }, {}, {
417
+ $type: import("./installations.js").JiraInstallationStatus;
418
+ }>;
419
+ tokenExpiresAt: import("drizzle-orm/pg-core").PgColumn<{
420
+ name: "token_expires_at";
421
+ tableName: "installations";
422
+ dataType: "date";
423
+ columnType: "PgTimestamp";
424
+ data: Date;
425
+ driverParam: string;
426
+ notNull: false;
427
+ hasDefault: false;
428
+ isPrimaryKey: false;
429
+ isAutoincrement: false;
430
+ hasRuntimeDefault: false;
431
+ enumValues: undefined;
432
+ baseColumn: never;
433
+ identity: undefined;
434
+ generated: undefined;
435
+ }, {}, {}>;
436
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
437
+ name: "created_at";
438
+ tableName: "installations";
439
+ dataType: "date";
440
+ columnType: "PgTimestamp";
441
+ data: Date;
442
+ driverParam: string;
443
+ notNull: true;
444
+ hasDefault: true;
445
+ isPrimaryKey: false;
446
+ isAutoincrement: false;
447
+ hasRuntimeDefault: false;
448
+ enumValues: undefined;
449
+ baseColumn: never;
450
+ identity: undefined;
451
+ generated: undefined;
452
+ }, {}, {}>;
453
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
454
+ name: "updated_at";
455
+ tableName: "installations";
456
+ dataType: "date";
457
+ columnType: "PgTimestamp";
458
+ data: Date;
459
+ driverParam: string;
460
+ notNull: true;
461
+ hasDefault: true;
462
+ isPrimaryKey: false;
463
+ isAutoincrement: false;
464
+ hasRuntimeDefault: false;
465
+ enumValues: undefined;
466
+ baseColumn: never;
467
+ identity: undefined;
468
+ generated: undefined;
469
+ }, {}, {}>;
470
+ };
471
+ dialect: "pg";
472
+ }>;
473
+ }>;
474
+ export declare function closeDb(): void;
475
+ //# sourceMappingURL=db.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/db/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAInE,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAsB,CAAC;AAI1C,wBAAgB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGjB;AAED,wBAAgB,OAAO,IAAI,IAAI,CAE9B"}
package/dist/db/db.js ADDED
@@ -0,0 +1,18 @@
1
+ import { drizzle } from '@shipfox/node-drizzle';
2
+ import { pgClient } from '@shipfox/node-postgres';
3
+ import { jiraInstallations } from './schema/installations.js';
4
+ export const schema = {
5
+ jiraInstallations
6
+ };
7
+ let database;
8
+ export function db() {
9
+ if (!database) database = drizzle(pgClient(), {
10
+ schema
11
+ });
12
+ return database;
13
+ }
14
+ export function closeDb() {
15
+ database = undefined;
16
+ }
17
+
18
+ //# sourceMappingURL=db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/db/db.ts"],"sourcesContent":["import {drizzle, type NodePgDatabase} from '@shipfox/node-drizzle';\nimport {pgClient} from '@shipfox/node-postgres';\nimport {jiraInstallations} from './schema/installations.js';\n\nexport const schema = {jiraInstallations};\n\nlet database: NodePgDatabase<typeof schema> | undefined;\n\nexport function db() {\n if (!database) database = drizzle(pgClient(), {schema});\n return database;\n}\n\nexport function closeDb(): void {\n database = undefined;\n}\n"],"names":["drizzle","pgClient","jiraInstallations","schema","database","db","closeDb","undefined"],"mappings":"AAAA,SAAQA,OAAO,QAA4B,wBAAwB;AACnE,SAAQC,QAAQ,QAAO,yBAAyB;AAChD,SAAQC,iBAAiB,QAAO,4BAA4B;AAE5D,OAAO,MAAMC,SAAS;IAACD;AAAiB,EAAE;AAE1C,IAAIE;AAEJ,OAAO,SAASC;IACd,IAAI,CAACD,UAAUA,WAAWJ,QAAQC,YAAY;QAACE;IAAM;IACrD,OAAOC;AACT;AAEA,OAAO,SAASE;IACdF,WAAWG;AACb"}
@@ -0,0 +1,41 @@
1
+ export type JiraInstallationStatus = 'installed' | 'revoked';
2
+ export interface JiraInstallation {
3
+ id: string;
4
+ connectionId: string;
5
+ cloudId: string;
6
+ siteUrl: string;
7
+ siteName: string;
8
+ authorizingAccountId: string;
9
+ scopes: string[];
10
+ webhookIds: number[];
11
+ webhookExpiresAt: Date | null;
12
+ status: JiraInstallationStatus;
13
+ tokenExpiresAt: Date | null;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ }
17
+ export interface UpsertJiraInstallationParams {
18
+ connectionId: string;
19
+ cloudId: string;
20
+ siteUrl: string;
21
+ siteName: string;
22
+ authorizingAccountId: string;
23
+ scopes: string[];
24
+ webhookIds?: number[] | undefined;
25
+ webhookExpiresAt?: Date | null | undefined;
26
+ status: JiraInstallationStatus;
27
+ tokenExpiresAt?: Date | null | undefined;
28
+ }
29
+ export declare function upsertJiraInstallation(params: UpsertJiraInstallationParams, options?: {
30
+ tx?: unknown;
31
+ }): Promise<JiraInstallation>;
32
+ export declare function getJiraInstallationByConnectionId(connectionId: string, options?: {
33
+ tx?: unknown;
34
+ }): Promise<JiraInstallation | undefined>;
35
+ export declare function getJiraInstallationByWebhookId(webhookId: number, options?: {
36
+ tx?: unknown;
37
+ }): Promise<JiraInstallation | undefined>;
38
+ export declare function markJiraInstallationRevoked(connectionId: string, options?: {
39
+ tx?: unknown;
40
+ }): Promise<JiraInstallation | undefined>;
41
+ //# sourceMappingURL=installations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installations.d.ts","sourceRoot":"","sources":["../../src/db/installations.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,sBAAsB,GAAG,WAAW,GAAG,SAAS,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,gBAAgB,EAAE,IAAI,GAA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0,0 +1,65 @@
1
+ import { eq, sql } from 'drizzle-orm';
2
+ import { JiraInstallationSiteMismatchError } from '#core/errors.js';
3
+ import { db } from './db.js';
4
+ import { jiraInstallations, toJiraInstallation } from './schema/installations.js';
5
+ export async function upsertJiraInstallation(params, options = {}) {
6
+ const executor = options.tx ?? db();
7
+ const now = new Date();
8
+ const webhookIds = params.webhookIds ?? [];
9
+ const [row] = await executor.insert(jiraInstallations).values({
10
+ connectionId: params.connectionId,
11
+ cloudId: params.cloudId,
12
+ siteUrl: params.siteUrl,
13
+ siteName: params.siteName,
14
+ authorizingAccountId: params.authorizingAccountId,
15
+ scopes: params.scopes,
16
+ webhookIds,
17
+ webhookExpiresAt: params.webhookExpiresAt ?? null,
18
+ status: params.status,
19
+ tokenExpiresAt: params.tokenExpiresAt ?? null
20
+ }).onConflictDoUpdate({
21
+ target: jiraInstallations.connectionId,
22
+ setWhere: eq(jiraInstallations.cloudId, params.cloudId),
23
+ set: {
24
+ cloudId: params.cloudId,
25
+ siteUrl: params.siteUrl,
26
+ siteName: params.siteName,
27
+ authorizingAccountId: params.authorizingAccountId,
28
+ scopes: params.scopes,
29
+ webhookIds,
30
+ webhookExpiresAt: params.webhookExpiresAt ?? null,
31
+ status: params.status,
32
+ tokenExpiresAt: params.tokenExpiresAt ?? null,
33
+ updatedAt: now
34
+ }
35
+ }).returning();
36
+ if (!row) throw new JiraInstallationSiteMismatchError(params.connectionId, params.cloudId);
37
+ return toJiraInstallation(row);
38
+ }
39
+ export async function getJiraInstallationByConnectionId(connectionId, options = {}) {
40
+ const executor = options.tx ?? db();
41
+ const rows = await executor.select().from(jiraInstallations).where(eq(jiraInstallations.connectionId, connectionId)).limit(1);
42
+ const row = rows[0];
43
+ if (!row) return undefined;
44
+ return toJiraInstallation(row);
45
+ }
46
+ export async function getJiraInstallationByWebhookId(webhookId, options = {}) {
47
+ const executor = options.tx ?? db();
48
+ const rows = await executor.select().from(jiraInstallations).where(sql`${jiraInstallations.webhookIds} @> ${JSON.stringify([
49
+ webhookId
50
+ ])}::jsonb`).limit(1);
51
+ const row = rows[0];
52
+ if (!row) return undefined;
53
+ return toJiraInstallation(row);
54
+ }
55
+ export async function markJiraInstallationRevoked(connectionId, options = {}) {
56
+ const executor = options.tx ?? db();
57
+ const [row] = await executor.update(jiraInstallations).set({
58
+ status: 'revoked',
59
+ updatedAt: new Date()
60
+ }).where(eq(jiraInstallations.connectionId, connectionId)).returning();
61
+ if (!row) return undefined;
62
+ return toJiraInstallation(row);
63
+ }
64
+
65
+ //# sourceMappingURL=installations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/db/installations.ts"],"sourcesContent":["import {eq, sql} from 'drizzle-orm';\nimport {JiraInstallationSiteMismatchError} from '#core/errors.js';\nimport {db} from './db.js';\nimport {jiraInstallations, toJiraInstallation} from './schema/installations.js';\n\nexport type JiraInstallationStatus = 'installed' | 'revoked';\n\nexport interface JiraInstallation {\n id: string;\n connectionId: string;\n cloudId: string;\n siteUrl: string;\n siteName: string;\n authorizingAccountId: string;\n scopes: string[];\n webhookIds: number[];\n webhookExpiresAt: Date | null;\n status: JiraInstallationStatus;\n tokenExpiresAt: Date | null;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface UpsertJiraInstallationParams {\n connectionId: string;\n cloudId: string;\n siteUrl: string;\n siteName: string;\n authorizingAccountId: string;\n scopes: string[];\n webhookIds?: number[] | undefined;\n webhookExpiresAt?: Date | null | undefined;\n status: JiraInstallationStatus;\n tokenExpiresAt?: Date | null | undefined;\n}\n\ntype JiraDb = ReturnType<typeof db>;\ntype JiraTx = Parameters<Parameters<JiraDb['transaction']>[0]>[0];\n\nexport async function upsertJiraInstallation(\n params: UpsertJiraInstallationParams,\n options: {tx?: unknown} = {},\n): Promise<JiraInstallation> {\n const executor = (options.tx ?? db()) as JiraDb | JiraTx;\n const now = new Date();\n const webhookIds = params.webhookIds ?? [];\n const [row] = await executor\n .insert(jiraInstallations)\n .values({\n connectionId: params.connectionId,\n cloudId: params.cloudId,\n siteUrl: params.siteUrl,\n siteName: params.siteName,\n authorizingAccountId: params.authorizingAccountId,\n scopes: params.scopes,\n webhookIds,\n webhookExpiresAt: params.webhookExpiresAt ?? null,\n status: params.status,\n tokenExpiresAt: params.tokenExpiresAt ?? null,\n })\n .onConflictDoUpdate({\n target: jiraInstallations.connectionId,\n setWhere: eq(jiraInstallations.cloudId, params.cloudId),\n set: {\n cloudId: params.cloudId,\n siteUrl: params.siteUrl,\n siteName: params.siteName,\n authorizingAccountId: params.authorizingAccountId,\n scopes: params.scopes,\n webhookIds,\n webhookExpiresAt: params.webhookExpiresAt ?? null,\n status: params.status,\n tokenExpiresAt: params.tokenExpiresAt ?? null,\n updatedAt: now,\n },\n })\n .returning();\n\n if (!row) throw new JiraInstallationSiteMismatchError(params.connectionId, params.cloudId);\n return toJiraInstallation(row);\n}\n\nexport async function getJiraInstallationByConnectionId(\n connectionId: string,\n options: {tx?: unknown} = {},\n): Promise<JiraInstallation | undefined> {\n const executor = (options.tx ?? db()) as JiraDb | JiraTx;\n const rows = await executor\n .select()\n .from(jiraInstallations)\n .where(eq(jiraInstallations.connectionId, connectionId))\n .limit(1);\n const row = rows[0];\n if (!row) return undefined;\n return toJiraInstallation(row);\n}\n\nexport async function getJiraInstallationByWebhookId(\n webhookId: number,\n options: {tx?: unknown} = {},\n): Promise<JiraInstallation | undefined> {\n const executor = (options.tx ?? db()) as JiraDb | JiraTx;\n const rows = await executor\n .select()\n .from(jiraInstallations)\n .where(sql`${jiraInstallations.webhookIds} @> ${JSON.stringify([webhookId])}::jsonb`)\n .limit(1);\n const row = rows[0];\n if (!row) return undefined;\n return toJiraInstallation(row);\n}\n\nexport async function markJiraInstallationRevoked(\n connectionId: string,\n options: {tx?: unknown} = {},\n): Promise<JiraInstallation | undefined> {\n const executor = (options.tx ?? db()) as JiraDb | JiraTx;\n const [row] = await executor\n .update(jiraInstallations)\n .set({status: 'revoked', updatedAt: new Date()})\n .where(eq(jiraInstallations.connectionId, connectionId))\n .returning();\n if (!row) return undefined;\n return toJiraInstallation(row);\n}\n"],"names":["eq","sql","JiraInstallationSiteMismatchError","db","jiraInstallations","toJiraInstallation","upsertJiraInstallation","params","options","executor","tx","now","Date","webhookIds","row","insert","values","connectionId","cloudId","siteUrl","siteName","authorizingAccountId","scopes","webhookExpiresAt","status","tokenExpiresAt","onConflictDoUpdate","target","setWhere","set","updatedAt","returning","getJiraInstallationByConnectionId","rows","select","from","where","limit","undefined","getJiraInstallationByWebhookId","webhookId","JSON","stringify","markJiraInstallationRevoked","update"],"mappings":"AAAA,SAAQA,EAAE,EAAEC,GAAG,QAAO,cAAc;AACpC,SAAQC,iCAAiC,QAAO,kBAAkB;AAClE,SAAQC,EAAE,QAAO,UAAU;AAC3B,SAAQC,iBAAiB,EAAEC,kBAAkB,QAAO,4BAA4B;AAoChF,OAAO,eAAeC,uBACpBC,MAAoC,EACpCC,UAA0B,CAAC,CAAC;IAE5B,MAAMC,WAAYD,QAAQE,EAAE,IAAIP;IAChC,MAAMQ,MAAM,IAAIC;IAChB,MAAMC,aAAaN,OAAOM,UAAU,IAAI,EAAE;IAC1C,MAAM,CAACC,IAAI,GAAG,MAAML,SACjBM,MAAM,CAACX,mBACPY,MAAM,CAAC;QACNC,cAAcV,OAAOU,YAAY;QACjCC,SAASX,OAAOW,OAAO;QACvBC,SAASZ,OAAOY,OAAO;QACvBC,UAAUb,OAAOa,QAAQ;QACzBC,sBAAsBd,OAAOc,oBAAoB;QACjDC,QAAQf,OAAOe,MAAM;QACrBT;QACAU,kBAAkBhB,OAAOgB,gBAAgB,IAAI;QAC7CC,QAAQjB,OAAOiB,MAAM;QACrBC,gBAAgBlB,OAAOkB,cAAc,IAAI;IAC3C,GACCC,kBAAkB,CAAC;QAClBC,QAAQvB,kBAAkBa,YAAY;QACtCW,UAAU5B,GAAGI,kBAAkBc,OAAO,EAAEX,OAAOW,OAAO;QACtDW,KAAK;YACHX,SAASX,OAAOW,OAAO;YACvBC,SAASZ,O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AAIP;IAChC,MAAM,CAACW,IAAI,GAAG,MAAML,SACjBmC,MAAM,CAACxC,mBACPyB,GAAG,CAAC;QAACL,QAAQ;QAAWM,WAAW,IAAIlB;IAAM,GAC7CwB,KAAK,CAACpC,GAAGI,kBAAkBa,YAAY,EAAEA,eACzCc,SAAS;IACZ,IAAI,CAACjB,KAAK,OAAOwB;IACjB,OAAOjC,mBAAmBS;AAC5B"}
@@ -0,0 +1,2 @@
1
+ export declare const migrationsPath: string;
2
+ //# sourceMappingURL=migrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,QAAoE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { dirname, resolve } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ export const migrationsPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../drizzle');
4
+
5
+ //# sourceMappingURL=migrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/db/migrations.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\n\nexport const migrationsPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../drizzle');\n"],"names":["dirname","resolve","fileURLToPath","migrationsPath","url"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AAEvC,OAAO,MAAMC,iBAAiBF,QAAQD,QAAQE,cAAc,YAAYE,GAAG,IAAI,iBAAiB"}
@@ -0,0 +1,2 @@
1
+ export declare const pgTable: import("drizzle-orm/pg-core").PgTableFn<undefined>;
2
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/db/schema/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,oDAAwD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { pgTableCreator } from 'drizzle-orm/pg-core';
2
+ export const pgTable = pgTableCreator((name)=>`integrations_jira_${name}`);
3
+
4
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/db/schema/common.ts"],"sourcesContent":["import {pgTableCreator} from 'drizzle-orm/pg-core';\n\nexport const pgTable = pgTableCreator((name) => `integrations_jira_${name}`);\n"],"names":["pgTableCreator","pgTable","name"],"mappings":"AAAA,SAAQA,cAAc,QAAO,sBAAsB;AAEnD,OAAO,MAAMC,UAAUD,eAAe,CAACE,OAAS,CAAC,kBAAkB,EAAEA,MAAM,EAAE"}