@hawk.so/types 0.5.8 → 0.6.0-rc.1

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.
@@ -17,7 +17,16 @@ jobs:
17
17
  - run: yarn
18
18
  - run: yarn lint
19
19
  - run: yarn build
20
- - run: yarn publish --access=public
20
+ - name: Determine npm dist-tag
21
+ id: dist-tag
22
+ run: |
23
+ VERSION=$(node -p "require('./package.json').version")
24
+ if echo "$VERSION" | grep -q "\-rc\."; then
25
+ echo "tag=rc" >> "$GITHUB_OUTPUT"
26
+ else
27
+ echo "tag=latest" >> "$GITHUB_OUTPUT"
28
+ fi
29
+ - run: yarn publish --access=public --tag ${{ steps.dist-tag.outputs.tag }}
21
30
  env:
22
31
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23
32
  notify:
package/build/index.d.ts CHANGED
@@ -10,6 +10,8 @@ export * from './src/base/event/taskManagerItem';
10
10
  export * from './src/base/event/addons';
11
11
  export * from './src/base/integrations/integrationToken';
12
12
  export * from './src/base/project/ProjectTaskManager';
13
+ export * from './src/base/workspace/GitHubIntegration';
14
+ export * from './src/base/user/GitHubAuthorization';
13
15
  export * from './src/dbScheme/businessOperation';
14
16
  export * from './src/dbScheme/groupedEvent';
15
17
  export * from './src/dbScheme/notificationsChannels';
package/build/index.js CHANGED
@@ -26,6 +26,8 @@ __exportStar(require("./src/base/event/taskManagerItem"), exports);
26
26
  __exportStar(require("./src/base/event/addons"), exports);
27
27
  __exportStar(require("./src/base/integrations/integrationToken"), exports);
28
28
  __exportStar(require("./src/base/project/ProjectTaskManager"), exports);
29
+ __exportStar(require("./src/base/workspace/GitHubIntegration"), exports);
30
+ __exportStar(require("./src/base/user/GitHubAuthorization"), exports);
29
31
  __exportStar(require("./src/dbScheme/businessOperation"), exports);
30
32
  __exportStar(require("./src/dbScheme/groupedEvent"), exports);
31
33
  __exportStar(require("./src/dbScheme/notificationsChannels"), exports);
@@ -48,7 +48,11 @@ export interface ProjectTaskManagerConfig {
48
48
  */
49
49
  config: {
50
50
  /**
51
- * GitHub App installation ID
51
+ * GitHub App installation ID.
52
+ *
53
+ * This is a **copy** from workspace.integrations.github.installations[].
54
+ * Stored here for worker optimization — allows the worker to operate
55
+ * per-project without additional joins/lookups to the workspaces collection.
52
56
  */
53
57
  installationId: string;
54
58
  /**
@@ -60,57 +64,8 @@ export interface ProjectTaskManagerConfig {
60
64
  */
61
65
  repoFullName: string;
62
66
  /**
63
- * Delegated user OAuth token for user-to-server authentication
64
- * Used for creating issues and assigning Copilot on behalf of the user
67
+ * Primary programming language of the repository (as reported by GitHub)
65
68
  */
66
- delegatedUser?: {
67
- /**
68
- * Hawk user ID who authorized the GitHub App
69
- */
70
- hawkUserId: string;
71
- /**
72
- * GitHub user ID
73
- */
74
- githubUserId: number;
75
- /**
76
- * GitHub username/login
77
- */
78
- githubLogin: string;
79
- /**
80
- * OAuth access token (user-to-server token)
81
- */
82
- accessToken: string;
83
- /**
84
- * Date when access token expires
85
- * null if token expiration is disabled
86
- */
87
- accessTokenExpiresAt: Date | null;
88
- /**
89
- * OAuth refresh token
90
- * Used to obtain new access tokens when they expire
91
- */
92
- refreshToken: string;
93
- /**
94
- * Date when refresh token expires
95
- * null if refresh token expiration is disabled
96
- */
97
- refreshTokenExpiresAt: Date | null;
98
- /**
99
- * Date when token was created/saved
100
- */
101
- tokenCreatedAt: Date;
102
- /**
103
- * Date when token was last successfully validated
104
- * null if never validated
105
- */
106
- tokenLastValidatedAt: Date | null;
107
- /**
108
- * Token status
109
- * - active: token is valid (GET /user returns 200)
110
- * - revoked: token was revoked (GET /user returns 401/403) or user removed authorization
111
- * - missing: token is not present in project
112
- */
113
- status: 'active' | 'revoked' | 'missing';
114
- };
69
+ repoLanguage?: string;
115
70
  };
116
71
  }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * GitHub OAuth authorization stored at user level.
3
+ *
4
+ * accessToken is NOT stored persistently — it is obtained via refreshToken
5
+ * each time an action is needed on behalf of the user (e.g. Copilot assignment).
6
+ *
7
+ * GitHub may return a new refreshToken during refresh (token rotation),
8
+ * so it must be updated in the user document.
9
+ */
10
+ export interface GitHubAuthorization {
11
+ /**
12
+ * GitHub user ID
13
+ */
14
+ githubUserId: number;
15
+ /**
16
+ * GitHub username/login
17
+ */
18
+ githubLogin: string;
19
+ /**
20
+ * OAuth refresh token.
21
+ * Used to obtain ephemeral access tokens on demand.
22
+ */
23
+ refreshToken: string;
24
+ /**
25
+ * Date when refresh token expires.
26
+ * null if refresh token expiration is disabled by GitHub.
27
+ */
28
+ refreshTokenExpiresAt: Date | null;
29
+ /**
30
+ * Date when this authorization (refreshToken) was originally created/saved
31
+ */
32
+ tokenCreatedAt: Date;
33
+ /**
34
+ * Date when refreshToken was last successfully used to obtain an accessToken.
35
+ * null if never validated after initial creation.
36
+ */
37
+ tokenLastValidatedAt: Date | null;
38
+ /**
39
+ * Token status:
40
+ * - 'active': token is valid
41
+ * - 'revoked': token was revoked or user removed authorization
42
+ */
43
+ status: 'active' | 'revoked';
44
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,93 @@
1
+ /**
2
+ * GitHub App installation account info
3
+ */
4
+ export interface GitHubInstallationAccount {
5
+ /**
6
+ * GitHub account ID
7
+ */
8
+ id: number;
9
+ /**
10
+ * GitHub account login (username or org name)
11
+ */
12
+ login: string;
13
+ /**
14
+ * Account type
15
+ */
16
+ type: 'User' | 'Organization';
17
+ }
18
+ /**
19
+ * Delegate user for agent operations (e.g. Copilot assignment).
20
+ * Points to a Hawk user who has an active GitHub authorization.
21
+ */
22
+ export interface GitHubInstallationDelegatedUser {
23
+ /**
24
+ * Hawk user ID of the delegate
25
+ */
26
+ hawkUserId: string;
27
+ /**
28
+ * GitHub user ID of the delegate
29
+ */
30
+ githubUserId: number;
31
+ /**
32
+ * GitHub login of the delegate
33
+ */
34
+ githubLogin: string;
35
+ /**
36
+ * Delegate status:
37
+ * - 'active': delegate has a valid GitHub authorization
38
+ * - 'missing': no workspace member has a GitHub authorization
39
+ * - 'revoked': delegate's GitHub authorization was revoked
40
+ */
41
+ status: 'active' | 'missing' | 'revoked';
42
+ }
43
+ /**
44
+ * GitHub App installation record stored at workspace level.
45
+ *
46
+ * GitHub issues installationId per organization/account, not per repository.
47
+ * One workspace can have multiple installations
48
+ * (e.g. client's GitHub org + personal account).
49
+ */
50
+ export interface GitHubInstallation {
51
+ /**
52
+ * GitHub App installation ID
53
+ */
54
+ installationId: number;
55
+ /**
56
+ * GitHub account where the App is installed
57
+ */
58
+ account: GitHubInstallationAccount;
59
+ /**
60
+ * Hawk user ID of who connected this installation (for audit)
61
+ */
62
+ connectedByHawkUserId: string;
63
+ /**
64
+ * Date when installation was connected
65
+ */
66
+ connectedAt: Date;
67
+ /**
68
+ * Date when installation record was last updated
69
+ */
70
+ updatedAt: Date;
71
+ /**
72
+ * Delegate user for agent actions in Worker
73
+ */
74
+ delegatedUser: GitHubInstallationDelegatedUser;
75
+ }
76
+ /**
77
+ * GitHub integration data stored at workspace level
78
+ */
79
+ export interface WorkspaceGitHubIntegration {
80
+ /**
81
+ * List of GitHub App installations for this workspace
82
+ */
83
+ installations: GitHubInstallation[];
84
+ }
85
+ /**
86
+ * All integrations stored at workspace level
87
+ */
88
+ export interface WorkspaceIntegrations {
89
+ /**
90
+ * GitHub integration (installations, etc.)
91
+ */
92
+ github?: WorkspaceGitHubIntegration;
93
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -27,4 +27,8 @@ export interface NotificationsChannelsDBScheme {
27
27
  * Alerts through the Loop
28
28
  */
29
29
  loop?: NotificationsChannelSettingsDBScheme;
30
+ /**
31
+ * Alerts through a custom Webhook URL
32
+ */
33
+ webhook?: NotificationsChannelSettingsDBScheme;
30
34
  }
@@ -3,6 +3,7 @@ import type { UserNotificationsDBScheme } from '../../index.ts';
3
3
  import type { BankCard } from './bankCard.ts';
4
4
  import type { MembershipDBScheme } from './membership.ts';
5
5
  import type { UserProjectsLastVisitDBScheme } from './userProjectsLastVisit.ts';
6
+ import type { GitHubAuthorization } from '../base/user/GitHubAuthorization.ts';
6
7
  /**
7
8
  * Interface representing how user is stored in DB
8
9
  */
@@ -78,6 +79,11 @@ export interface UserDBScheme {
78
79
  */
79
80
  term?: string;
80
81
  };
82
+ /**
83
+ * GitHub OAuth authorizations.
84
+ * Used for user-to-server operations (e.g. Copilot assignment).
85
+ */
86
+ githubAuthorizations?: GitHubAuthorization[];
81
87
  /**
82
88
  * External identities for SSO (keyed by workspaceId)
83
89
  */
@@ -1,5 +1,6 @@
1
1
  import type { ObjectId } from 'bson';
2
2
  import type { WorkspaceSsoConfig } from './sso.ts';
3
+ import type { WorkspaceIntegrations } from '../base/workspace/GitHubIntegration.ts';
3
4
  /**
4
5
  * Workspace representation in DataBase
5
6
  */
@@ -73,4 +74,8 @@ export interface WorkspaceDBScheme {
73
74
  * SSO configuration (optional, only for workspaces with SSO enabled)
74
75
  */
75
76
  sso?: WorkspaceSsoConfig;
77
+ /**
78
+ * External integrations (GitHub, etc.)
79
+ */
80
+ integrations?: WorkspaceIntegrations;
76
81
  }
package/index.ts CHANGED
@@ -14,6 +14,8 @@ export * from './src/base/event/addons';
14
14
 
15
15
  export * from './src/base/integrations/integrationToken';
16
16
  export * from './src/base/project/ProjectTaskManager';
17
+ export * from './src/base/workspace/GitHubIntegration';
18
+ export * from './src/base/user/GitHubAuthorization';
17
19
 
18
20
  export * from './src/dbScheme/businessOperation';
19
21
  export * from './src/dbScheme/groupedEvent';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hawk.so/types",
3
- "version": "0.5.8",
3
+ "version": "0.6.0-rc.1",
4
4
  "description": "TypeScript definitions for Hawk",
5
5
  "types": "build/index.d.ts",
6
6
  "main": "build/index.js",
@@ -57,7 +57,11 @@ export interface ProjectTaskManagerConfig {
57
57
  */
58
58
  config: {
59
59
  /**
60
- * GitHub App installation ID
60
+ * GitHub App installation ID.
61
+ *
62
+ * This is a **copy** from workspace.integrations.github.installations[].
63
+ * Stored here for worker optimization — allows the worker to operate
64
+ * per-project without additional joins/lookups to the workspaces collection.
61
65
  */
62
66
  installationId: string;
63
67
 
@@ -72,66 +76,8 @@ export interface ProjectTaskManagerConfig {
72
76
  repoFullName: string;
73
77
 
74
78
  /**
75
- * Delegated user OAuth token for user-to-server authentication
76
- * Used for creating issues and assigning Copilot on behalf of the user
79
+ * Primary programming language of the repository (as reported by GitHub)
77
80
  */
78
- delegatedUser?: {
79
- /**
80
- * Hawk user ID who authorized the GitHub App
81
- */
82
- hawkUserId: string;
83
-
84
- /**
85
- * GitHub user ID
86
- */
87
- githubUserId: number;
88
-
89
- /**
90
- * GitHub username/login
91
- */
92
- githubLogin: string;
93
-
94
- /**
95
- * OAuth access token (user-to-server token)
96
- */
97
- accessToken: string;
98
-
99
- /**
100
- * Date when access token expires
101
- * null if token expiration is disabled
102
- */
103
- accessTokenExpiresAt: Date | null;
104
-
105
- /**
106
- * OAuth refresh token
107
- * Used to obtain new access tokens when they expire
108
- */
109
- refreshToken: string;
110
-
111
- /**
112
- * Date when refresh token expires
113
- * null if refresh token expiration is disabled
114
- */
115
- refreshTokenExpiresAt: Date | null;
116
-
117
- /**
118
- * Date when token was created/saved
119
- */
120
- tokenCreatedAt: Date;
121
-
122
- /**
123
- * Date when token was last successfully validated
124
- * null if never validated
125
- */
126
- tokenLastValidatedAt: Date | null;
127
-
128
- /**
129
- * Token status
130
- * - active: token is valid (GET /user returns 200)
131
- * - revoked: token was revoked (GET /user returns 401/403) or user removed authorization
132
- * - missing: token is not present in project
133
- */
134
- status: 'active' | 'revoked' | 'missing';
135
- };
81
+ repoLanguage?: string;
136
82
  };
137
83
  }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * GitHub OAuth authorization stored at user level.
3
+ *
4
+ * accessToken is NOT stored persistently — it is obtained via refreshToken
5
+ * each time an action is needed on behalf of the user (e.g. Copilot assignment).
6
+ *
7
+ * GitHub may return a new refreshToken during refresh (token rotation),
8
+ * so it must be updated in the user document.
9
+ */
10
+ export interface GitHubAuthorization {
11
+ /**
12
+ * GitHub user ID
13
+ */
14
+ githubUserId: number;
15
+
16
+ /**
17
+ * GitHub username/login
18
+ */
19
+ githubLogin: string;
20
+
21
+ /**
22
+ * OAuth refresh token.
23
+ * Used to obtain ephemeral access tokens on demand.
24
+ */
25
+ refreshToken: string;
26
+
27
+ /**
28
+ * Date when refresh token expires.
29
+ * null if refresh token expiration is disabled by GitHub.
30
+ */
31
+ refreshTokenExpiresAt: Date | null;
32
+
33
+ /**
34
+ * Date when this authorization (refreshToken) was originally created/saved
35
+ */
36
+ tokenCreatedAt: Date;
37
+
38
+ /**
39
+ * Date when refreshToken was last successfully used to obtain an accessToken.
40
+ * null if never validated after initial creation.
41
+ */
42
+ tokenLastValidatedAt: Date | null;
43
+
44
+ /**
45
+ * Token status:
46
+ * - 'active': token is valid
47
+ * - 'revoked': token was revoked or user removed authorization
48
+ */
49
+ status: 'active' | 'revoked';
50
+ }
@@ -0,0 +1,107 @@
1
+ /**
2
+ * GitHub App installation account info
3
+ */
4
+ export interface GitHubInstallationAccount {
5
+ /**
6
+ * GitHub account ID
7
+ */
8
+ id: number;
9
+
10
+ /**
11
+ * GitHub account login (username or org name)
12
+ */
13
+ login: string;
14
+
15
+ /**
16
+ * Account type
17
+ */
18
+ type: 'User' | 'Organization';
19
+ }
20
+
21
+ /**
22
+ * Delegate user for agent operations (e.g. Copilot assignment).
23
+ * Points to a Hawk user who has an active GitHub authorization.
24
+ */
25
+ export interface GitHubInstallationDelegatedUser {
26
+ /**
27
+ * Hawk user ID of the delegate
28
+ */
29
+ hawkUserId: string;
30
+
31
+ /**
32
+ * GitHub user ID of the delegate
33
+ */
34
+ githubUserId: number;
35
+
36
+ /**
37
+ * GitHub login of the delegate
38
+ */
39
+ githubLogin: string;
40
+
41
+ /**
42
+ * Delegate status:
43
+ * - 'active': delegate has a valid GitHub authorization
44
+ * - 'missing': no workspace member has a GitHub authorization
45
+ * - 'revoked': delegate's GitHub authorization was revoked
46
+ */
47
+ status: 'active' | 'missing' | 'revoked';
48
+ }
49
+
50
+ /**
51
+ * GitHub App installation record stored at workspace level.
52
+ *
53
+ * GitHub issues installationId per organization/account, not per repository.
54
+ * One workspace can have multiple installations
55
+ * (e.g. client's GitHub org + personal account).
56
+ */
57
+ export interface GitHubInstallation {
58
+ /**
59
+ * GitHub App installation ID
60
+ */
61
+ installationId: number;
62
+
63
+ /**
64
+ * GitHub account where the App is installed
65
+ */
66
+ account: GitHubInstallationAccount;
67
+
68
+ /**
69
+ * Hawk user ID of who connected this installation (for audit)
70
+ */
71
+ connectedByHawkUserId: string;
72
+
73
+ /**
74
+ * Date when installation was connected
75
+ */
76
+ connectedAt: Date;
77
+
78
+ /**
79
+ * Date when installation record was last updated
80
+ */
81
+ updatedAt: Date;
82
+
83
+ /**
84
+ * Delegate user for agent actions in Worker
85
+ */
86
+ delegatedUser: GitHubInstallationDelegatedUser;
87
+ }
88
+
89
+ /**
90
+ * GitHub integration data stored at workspace level
91
+ */
92
+ export interface WorkspaceGitHubIntegration {
93
+ /**
94
+ * List of GitHub App installations for this workspace
95
+ */
96
+ installations: GitHubInstallation[];
97
+ }
98
+
99
+ /**
100
+ * All integrations stored at workspace level
101
+ */
102
+ export interface WorkspaceIntegrations {
103
+ /**
104
+ * GitHub integration (installations, etc.)
105
+ */
106
+ github?: WorkspaceGitHubIntegration;
107
+ }
@@ -33,4 +33,9 @@ export interface NotificationsChannelsDBScheme {
33
33
  * Alerts through the Loop
34
34
  */
35
35
  loop?: NotificationsChannelSettingsDBScheme;
36
+
37
+ /**
38
+ * Alerts through a custom Webhook URL
39
+ */
40
+ webhook?: NotificationsChannelSettingsDBScheme;
36
41
  }
@@ -3,6 +3,7 @@ import type { UserNotificationsDBScheme } from '../../index.ts';
3
3
  import type { BankCard } from './bankCard.ts';
4
4
  import type { MembershipDBScheme } from './membership.ts';
5
5
  import type { UserProjectsLastVisitDBScheme } from './userProjectsLastVisit.ts';
6
+ import type { GitHubAuthorization } from '../base/user/GitHubAuthorization.ts';
6
7
 
7
8
  /**
8
9
  * Interface representing how user is stored in DB
@@ -95,6 +96,12 @@ export interface UserDBScheme {
95
96
  term?: string;
96
97
  };
97
98
 
99
+ /**
100
+ * GitHub OAuth authorizations.
101
+ * Used for user-to-server operations (e.g. Copilot assignment).
102
+ */
103
+ githubAuthorizations?: GitHubAuthorization[];
104
+
98
105
  /**
99
106
  * External identities for SSO (keyed by workspaceId)
100
107
  */
@@ -1,5 +1,6 @@
1
1
  import type { ObjectId } from 'bson';
2
2
  import type { WorkspaceSsoConfig } from './sso.ts';
3
+ import type { WorkspaceIntegrations } from '../base/workspace/GitHubIntegration.ts';
3
4
 
4
5
  /**
5
6
  * Workspace representation in DataBase
@@ -87,4 +88,9 @@ export interface WorkspaceDBScheme {
87
88
  * SSO configuration (optional, only for workspaces with SSO enabled)
88
89
  */
89
90
  sso?: WorkspaceSsoConfig;
91
+
92
+ /**
93
+ * External integrations (GitHub, etc.)
94
+ */
95
+ integrations?: WorkspaceIntegrations;
90
96
  }