@kosha-ai/integration-github 0.2.0 → 0.4.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.
@@ -1 +1 @@
1
- {"version":3,"file":"integration-github.d.ts","sourceRoot":"","sources":["../../src/lib/integration-github.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAQlE,MAAM,WAAW,wBAAwB;IACvC,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAiBD,wBAAgB,MAAM,CACpB,OAAO,GAAE,wBAA6B,GACrC,gBAAgB,CA4DlB;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"integration-github.d.ts","sourceRoot":"","sources":["../../src/lib/integration-github.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAIlE,MAAM,WAAW,wBAAwB;IACvC,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAiBD,wBAAgB,MAAM,CACpB,OAAO,GAAE,wBAA6B,GACrC,gBAAgB,CA6DlB;AAED,eAAe,MAAM,CAAC"}
@@ -1,8 +1,5 @@
1
- import { defineIntegration, oauth2 } from '@kosha-ai/integration-sdk';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- const currentDir = path.dirname(fileURLToPath(import.meta.url));
5
- const docsDirectory = path.join(currentDir, '../../docs');
1
+ import { defineIntegration, oauth2, packageDirs, } from '@kosha-ai/integration-sdk';
2
+ const { docsPath, migrationsPath } = packageDirs(import.meta.url);
6
3
  /**
7
4
  * The hosts a `git clone` talks to. github.com redirects pack fetches to
8
5
  * codeload.github.com, which needs the same credential; a GitHub Enterprise
@@ -19,7 +16,8 @@ export function github(options = {}) {
19
16
  key: 'github',
20
17
  name: 'GitHub',
21
18
  docsUrl: 'https://docs.github.com/rest',
22
- docsPath: docsDirectory,
19
+ docsPath,
20
+ migrationsPath,
23
21
  auth: oauth2({
24
22
  authorizationUrl: `${webBaseUrl}/login/oauth/authorize`,
25
23
  tokenUrl: `${webBaseUrl}/login/oauth/access_token`,
package/docs/setup.md CHANGED
@@ -13,7 +13,7 @@ To connect to GitHub, you need to create a GitHub OAuth App. This allows Kosha t
13
13
  4. Fill in the application details:
14
14
  - **Application name**: The name of your application.
15
15
  - **Homepage URL**: Your website URL.
16
- - **Authorization callback URL**: Your Kosha redirect URI (e.g. `https://your-app.com/api/connect/github/callback`).
16
+ - **Authorization callback URL**: Your Kosha redirect URI (e.g. `{KOSHA_PUBLIC_URL}/api/connect/callback/github`).
17
17
 
18
18
  ![GitHub Application Registration Form](./images/github-register-app.png)
19
19
 
@@ -0,0 +1,48 @@
1
+ CREATE TABLE "github_configuration" (
2
+ "id" TEXT NOT NULL,
3
+ "environmentId" TEXT NOT NULL,
4
+ "name" TEXT NOT NULL,
5
+ "slug" TEXT NOT NULL,
6
+ -- Encrypted, so TEXT rather than JSONB.
7
+ "credentials" TEXT,
8
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
9
+ "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
10
+
11
+ CONSTRAINT "github_configuration_pkey" PRIMARY KEY ("id")
12
+ );
13
+
14
+ CREATE TABLE "github_connection" (
15
+ "accountId" TEXT NOT NULL,
16
+ -- Copied from `account` so the unique index below can use it.
17
+ "userId" TEXT NOT NULL,
18
+ "environmentId" TEXT NOT NULL,
19
+ "configurationId" TEXT NOT NULL,
20
+ "metadata" JSONB,
21
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
22
+ "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
23
+
24
+ CONSTRAINT "github_connection_pkey" PRIMARY KEY ("accountId")
25
+ );
26
+
27
+ CREATE UNIQUE INDEX "github_configuration_environmentId_slug_key" ON "github_configuration"("environmentId", "slug");
28
+
29
+ CREATE INDEX "github_configuration_environmentId_idx" ON "github_configuration"("environmentId");
30
+
31
+ CREATE UNIQUE INDEX "github_connection_environmentId_configurationId_userId_key" ON "github_connection"("environmentId", "configurationId", "userId");
32
+
33
+ CREATE INDEX "github_connection_environmentId_idx" ON "github_connection"("environmentId");
34
+
35
+ CREATE INDEX "github_connection_configurationId_idx" ON "github_connection"("configurationId");
36
+
37
+ CREATE INDEX "github_connection_userId_idx" ON "github_connection"("userId");
38
+
39
+ ALTER TABLE "github_configuration" ADD CONSTRAINT "github_configuration_environmentId_fkey" FOREIGN KEY ("environmentId") REFERENCES "environment"("id") ON DELETE CASCADE ON UPDATE CASCADE;
40
+
41
+ ALTER TABLE "github_connection" ADD CONSTRAINT "github_connection_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "account"("id") ON DELETE CASCADE ON UPDATE CASCADE;
42
+
43
+ ALTER TABLE "github_connection" ADD CONSTRAINT "github_connection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
44
+
45
+ ALTER TABLE "github_connection" ADD CONSTRAINT "github_connection_environmentId_fkey" FOREIGN KEY ("environmentId") REFERENCES "environment"("id") ON DELETE CASCADE ON UPDATE CASCADE;
46
+
47
+ -- RESTRICT: a configuration that still has connections cannot be deleted.
48
+ ALTER TABLE "github_connection" ADD CONSTRAINT "github_connection_configurationId_fkey" FOREIGN KEY ("configurationId") REFERENCES "github_configuration"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosha-ai/integration-github",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "GitHub integration for Kosha",
5
5
  "keywords": [
6
6
  "kosha",
@@ -37,6 +37,7 @@
37
37
  "files": [
38
38
  "dist",
39
39
  "docs",
40
+ "migrations",
40
41
  "!**/*.tsbuildinfo"
41
42
  ],
42
43
  "dependencies": {
@@ -47,9 +48,9 @@
47
48
  "key": "github"
48
49
  },
49
50
  "peerDependencies": {
50
- "@kosha-ai/integration-sdk": "0.2.0"
51
+ "@kosha-ai/integration-sdk": "0.4.0"
51
52
  },
52
53
  "devDependencies": {
53
- "@kosha-ai/integration-sdk": "0.2.0"
54
+ "@kosha-ai/integration-sdk": "0.4.0"
54
55
  }
55
56
  }