@structured-world/gitlab-mcp-db 10.0.1 → 11.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.
- package/README.md +6 -6
- package/dist/generated/prisma/client.d.ts +2 -0
- package/dist/generated/prisma/commonInputTypes.d.ts +178 -9
- package/dist/generated/prisma/internal/class.d.ts +6 -0
- package/dist/generated/prisma/internal/class.js +4 -4
- package/dist/generated/prisma/internal/class.js.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespace.d.ts +207 -1
- package/dist/generated/prisma/internal/prismaNamespace.js +52 -3
- package/dist/generated/prisma/internal/prismaNamespace.js.map +1 -1
- package/dist/generated/prisma/models/AccountSettings.d.ts +400 -0
- package/dist/generated/prisma/models/AccountSettings.js +3 -0
- package/dist/generated/prisma/models/AccountSettings.js.map +1 -0
- package/dist/generated/prisma/models/AuthCodeFlowState.d.ts +152 -2
- package/dist/generated/prisma/models/DeviceFlowState.d.ts +214 -2
- package/dist/generated/prisma/models/OAuthClient.d.ts +577 -0
- package/dist/generated/prisma/models/OAuthClient.js +3 -0
- package/dist/generated/prisma/models/OAuthClient.js.map +1 -0
- package/dist/generated/prisma/models/OAuthSession.d.ts +116 -1
- package/dist/generated/prisma/models.d.ts +2 -0
- package/dist/src/migrate.d.ts +16 -0
- package/dist/src/migrate.js +115 -0
- package/dist/src/migrate.js.map +1 -0
- package/dist/src/postgresql.d.ts +17 -1
- package/dist/src/postgresql.js +309 -83
- package/dist/src/postgresql.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -5
- package/prisma/migrations/0_init/migration.sql +115 -0
- package/prisma/migrations/20261008000000_released_schema_columns/migration.sql +15 -0
- package/prisma/migrations/20261009000000_oauth_account_linking/migration.sql +47 -0
- package/prisma/migrations/20261010000000_account_settings/migration.sql +12 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +59 -0
- package/prisma.config.ts +19 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
-- OAuth account linking: resource/scope/instance binding of flows and sessions, the
|
|
2
|
+
-- device flow's client state, poll cadence and issued GitLab tokens, the GitLab refresh
|
|
3
|
+
-- lease, and durable
|
|
4
|
+
-- client registrations.
|
|
5
|
+
-- Additive only: new nullable columns and a new table; existing rows stay valid.
|
|
6
|
+
|
|
7
|
+
-- AlterTable
|
|
8
|
+
ALTER TABLE "oauth_sessions" ADD COLUMN "gitlab_refresh_lease_until" BIGINT,
|
|
9
|
+
ADD COLUMN "resource" TEXT;
|
|
10
|
+
|
|
11
|
+
-- AlterTable
|
|
12
|
+
ALTER TABLE "oauth_device_flows" ADD COLUMN "client_state" TEXT,
|
|
13
|
+
ADD COLUMN "gitlab_tokens" JSONB,
|
|
14
|
+
ADD COLUMN "mcp_scopes" JSONB,
|
|
15
|
+
ADD COLUMN "next_poll_at" BIGINT,
|
|
16
|
+
ADD COLUMN "resource" TEXT,
|
|
17
|
+
ADD COLUMN "selected_instance" TEXT,
|
|
18
|
+
ADD COLUMN "selected_instance_label" TEXT;
|
|
19
|
+
|
|
20
|
+
-- AlterTable
|
|
21
|
+
ALTER TABLE "oauth_auth_code_flows" ADD COLUMN "gitlab_tokens" JSONB,
|
|
22
|
+
ADD COLUMN "mcp_scopes" JSONB,
|
|
23
|
+
ADD COLUMN "resource" TEXT,
|
|
24
|
+
ADD COLUMN "selected_instance" TEXT,
|
|
25
|
+
ADD COLUMN "selected_instance_label" TEXT;
|
|
26
|
+
|
|
27
|
+
-- CreateTable
|
|
28
|
+
CREATE TABLE "oauth_clients" (
|
|
29
|
+
"client_id" TEXT NOT NULL,
|
|
30
|
+
"client_secret" TEXT,
|
|
31
|
+
"redirect_uris" TEXT[],
|
|
32
|
+
"client_name" TEXT,
|
|
33
|
+
"token_endpoint_auth_method" TEXT NOT NULL,
|
|
34
|
+
"grant_types" TEXT[],
|
|
35
|
+
"response_types" TEXT[],
|
|
36
|
+
"created_at" BIGINT NOT NULL,
|
|
37
|
+
"registered_from" TEXT,
|
|
38
|
+
"expires_at" BIGINT,
|
|
39
|
+
|
|
40
|
+
CONSTRAINT "oauth_clients_pkey" PRIMARY KEY ("client_id")
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
-- CreateIndex
|
|
44
|
+
CREATE INDEX "idx_oauth_clients_registered_from" ON "oauth_clients"("registered_from");
|
|
45
|
+
|
|
46
|
+
-- CreateIndex
|
|
47
|
+
CREATE INDEX "idx_oauth_clients_expires_at" ON "oauth_clients"("expires_at");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- Account settings: what an account chose in the settings page or through manage_context,
|
|
2
|
+
-- shared by every replica. Additive only: a new table.
|
|
3
|
+
|
|
4
|
+
-- CreateTable
|
|
5
|
+
CREATE TABLE "oauth_account_settings" (
|
|
6
|
+
"account_key" TEXT NOT NULL,
|
|
7
|
+
"settings" JSONB NOT NULL,
|
|
8
|
+
"version" INTEGER NOT NULL,
|
|
9
|
+
"updated_at" BIGINT NOT NULL,
|
|
10
|
+
|
|
11
|
+
CONSTRAINT "oauth_account_settings_pkey" PRIMARY KEY ("account_key")
|
|
12
|
+
);
|
package/prisma/schema.prisma
CHANGED
|
@@ -23,6 +23,10 @@ model OAuthSession {
|
|
|
23
23
|
gitlabAccessToken String @map("gitlab_access_token")
|
|
24
24
|
gitlabRefreshToken String @map("gitlab_refresh_token")
|
|
25
25
|
gitlabTokenExpiry BigInt @map("gitlab_token_expiry")
|
|
26
|
+
// Null means the upstream grant was not reported; [] means no grants.
|
|
27
|
+
gitlabScopes Json? @map("gitlab_scopes")
|
|
28
|
+
// End of the lease of the replica refreshing the single-use GitLab refresh token.
|
|
29
|
+
gitlabRefreshLeaseUntil BigInt? @map("gitlab_refresh_lease_until")
|
|
26
30
|
|
|
27
31
|
// User info from GitLab
|
|
28
32
|
gitlabUserId Int @map("gitlab_user_id")
|
|
@@ -35,6 +39,8 @@ model OAuthSession {
|
|
|
35
39
|
// Session metadata
|
|
36
40
|
clientId String @map("client_id")
|
|
37
41
|
scopes String[] @default([])
|
|
42
|
+
// RFC 8707 resource the session's tokens are issued for; null for older sessions.
|
|
43
|
+
resource String?
|
|
38
44
|
createdAt BigInt @map("created_at")
|
|
39
45
|
updatedAt BigInt @map("updated_at")
|
|
40
46
|
|
|
@@ -61,6 +67,19 @@ model DeviceFlowState {
|
|
|
61
67
|
codeChallenge String @map("code_challenge")
|
|
62
68
|
codeChallengeMethod String @map("code_challenge_method")
|
|
63
69
|
redirectUri String? @map("redirect_uri")
|
|
70
|
+
// The original GitLab grant request, retained across polling on another replica.
|
|
71
|
+
requestedGitlabScopes Json? @map("requested_gitlab_scopes")
|
|
72
|
+
// The client's own state value; `state` above is the storage key.
|
|
73
|
+
clientState String? @map("client_state")
|
|
74
|
+
// Earliest next GitLab poll (RFC 8628 3.5), shared by all replicas.
|
|
75
|
+
nextPollAt BigInt? @map("next_poll_at")
|
|
76
|
+
selectedInstance String? @map("selected_instance")
|
|
77
|
+
selectedInstanceLabel String? @map("selected_instance_label")
|
|
78
|
+
// MCP scopes granted at /authorize; null means the full default set.
|
|
79
|
+
mcpScopes Json? @map("mcp_scopes")
|
|
80
|
+
resource String?
|
|
81
|
+
// Tokens GitLab issued on approval, kept until the account is set up.
|
|
82
|
+
gitlabTokens Json? @map("gitlab_tokens")
|
|
64
83
|
|
|
65
84
|
@@map("oauth_device_flows")
|
|
66
85
|
@@index([deviceCode], map: "idx_oauth_device_flows_device_code")
|
|
@@ -77,6 +96,15 @@ model AuthCodeFlowState {
|
|
|
77
96
|
clientRedirectUri String @map("client_redirect_uri")
|
|
78
97
|
callbackUri String @map("callback_uri")
|
|
79
98
|
expiresAt BigInt @map("expires_at")
|
|
99
|
+
// OAuth §5.1 lets the token response omit scope when this grant is unchanged.
|
|
100
|
+
requestedGitlabScopes Json? @map("requested_gitlab_scopes")
|
|
101
|
+
selectedInstance String? @map("selected_instance")
|
|
102
|
+
selectedInstanceLabel String? @map("selected_instance_label")
|
|
103
|
+
// MCP scopes granted at /authorize; null means the full default set.
|
|
104
|
+
mcpScopes Json? @map("mcp_scopes")
|
|
105
|
+
resource String?
|
|
106
|
+
// Tokens GitLab issued for the callback's code, kept until the account is set up.
|
|
107
|
+
gitlabTokens Json? @map("gitlab_tokens")
|
|
80
108
|
|
|
81
109
|
@@map("oauth_auth_code_flows")
|
|
82
110
|
@@index([expiresAt], map: "idx_oauth_auth_code_flows_expires_at")
|
|
@@ -100,6 +128,37 @@ model AuthorizationCode {
|
|
|
100
128
|
@@index([expiresAt], map: "idx_oauth_authorization_codes_expires_at")
|
|
101
129
|
}
|
|
102
130
|
|
|
131
|
+
// OAuth client registered through Dynamic Client Registration (RFC 7591)
|
|
132
|
+
model OAuthClient {
|
|
133
|
+
clientId String @id @map("client_id")
|
|
134
|
+
clientSecret String? @map("client_secret")
|
|
135
|
+
redirectUris String[] @map("redirect_uris")
|
|
136
|
+
clientName String? @map("client_name")
|
|
137
|
+
tokenEndpointAuthMethod String @map("token_endpoint_auth_method")
|
|
138
|
+
grantTypes String[] @map("grant_types")
|
|
139
|
+
responseTypes String[] @map("response_types")
|
|
140
|
+
createdAt BigInt @map("created_at")
|
|
141
|
+
// Keyed hash of the registering address; never-used registrations are capped per source
|
|
142
|
+
registeredFrom String? @map("registered_from")
|
|
143
|
+
// Removal time of a registration that never completed an authorization
|
|
144
|
+
expiresAt BigInt? @map("expires_at")
|
|
145
|
+
|
|
146
|
+
@@map("oauth_clients")
|
|
147
|
+
@@index([registeredFrom], map: "idx_oauth_clients_registered_from")
|
|
148
|
+
@@index([expiresAt], map: "idx_oauth_clients_expires_at")
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Settings an account keeps across its sessions and restarts
|
|
152
|
+
model AccountSettings {
|
|
153
|
+
accountKey String @id @map("account_key")
|
|
154
|
+
settings Json
|
|
155
|
+
// Grows with every write; writes are compare-and-set on it.
|
|
156
|
+
version Int
|
|
157
|
+
updatedAt BigInt @map("updated_at")
|
|
158
|
+
|
|
159
|
+
@@map("oauth_account_settings")
|
|
160
|
+
}
|
|
161
|
+
|
|
103
162
|
// MCP session to OAuth session mapping
|
|
104
163
|
model McpSessionMapping {
|
|
105
164
|
mcpSessionId String @id @map("mcp_session_id")
|
package/prisma.config.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prisma Configuration for gitlab-mcp OAuth Storage
|
|
3
|
+
*
|
|
4
|
+
* Uses OAUTH_STORAGE_POSTGRESQL_URL environment variable.
|
|
5
|
+
* If not set, Prisma client will not be initialized.
|
|
6
|
+
*/
|
|
7
|
+
import "dotenv/config";
|
|
8
|
+
import { defineConfig } from "prisma/config";
|
|
9
|
+
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
schema: "prisma/schema.prisma",
|
|
12
|
+
migrations: {
|
|
13
|
+
path: "prisma/migrations",
|
|
14
|
+
},
|
|
15
|
+
datasource: {
|
|
16
|
+
// Use our consistent env variable naming
|
|
17
|
+
url: process.env["OAUTH_STORAGE_POSTGRESQL_URL"] ?? process.env["DATABASE_URL"],
|
|
18
|
+
},
|
|
19
|
+
});
|