@intx/db 0.1.2 → 0.3.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/LICENSE +176 -0
- package/README.md +23 -4
- package/dist/approval-store.d.ts +52 -0
- package/dist/approval-store.js +79 -0
- package/dist/asset-resolution.d.ts +52 -0
- package/dist/asset-resolution.js +66 -0
- package/dist/catalog-resolution.d.ts +76 -0
- package/dist/catalog-resolution.js +151 -0
- package/dist/client.d.ts +19 -0
- package/dist/client.js +18 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.js +16 -0
- package/dist/connection.d.ts +3 -0
- package/dist/connection.js +26 -0
- package/dist/credential-resolution.d.ts +222 -0
- package/dist/credential-resolution.js +255 -0
- package/dist/grant-store.d.ts +3 -0
- package/dist/grant-store.js +59 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +20 -0
- package/dist/migrate.d.ts +36 -0
- package/dist/migrate.js +135 -0
- package/dist/model-source-resolution.d.ts +115 -0
- package/dist/model-source-resolution.js +291 -0
- package/dist/parse-row.d.ts +373 -0
- package/dist/parse-row.js +232 -0
- package/dist/pg-error.d.ts +3 -0
- package/dist/pg-error.js +19 -0
- package/dist/pricing.d.ts +15 -0
- package/dist/pricing.js +24 -0
- package/dist/rekey-credential-secrets.d.ts +13 -0
- package/dist/rekey-credential-secrets.js +61 -0
- package/dist/schema/approvals.d.ts +245 -0
- package/dist/schema/approvals.js +52 -0
- package/dist/schema/assets.d.ts +143 -0
- package/{src/schema/assets.ts → dist/schema/assets.js} +7 -16
- package/dist/schema/auth.d.ts +606 -0
- package/dist/schema/auth.js +47 -0
- package/dist/schema/catalog.d.ts +811 -0
- package/dist/schema/catalog.js +108 -0
- package/dist/schema/column-types.d.ts +26 -0
- package/dist/schema/column-types.js +15 -0
- package/dist/schema/credentials.d.ts +305 -0
- package/{src/schema/credentials.ts → dist/schema/credentials.js} +16 -22
- package/dist/schema/git-tokens.d.ts +256 -0
- package/{src/schema/git-tokens.ts → dist/schema/git-tokens.js} +16 -39
- package/dist/schema/grants.d.ts +211 -0
- package/dist/schema/grants.js +30 -0
- package/dist/schema/index.d.ts +25 -0
- package/dist/schema/index.js +25 -0
- package/dist/schema/messages.d.ts +414 -0
- package/dist/schema/messages.js +82 -0
- package/dist/schema/oauth-clients.d.ts +246 -0
- package/{src/schema/oauth-clients.ts → dist/schema/oauth-clients.js} +8 -14
- package/dist/schema/offerings.d.ts +160 -0
- package/dist/schema/offerings.js +24 -0
- package/dist/schema/principals.d.ts +128 -0
- package/dist/schema/principals.js +23 -0
- package/dist/schema/providers.d.ts +237 -0
- package/dist/schema/providers.js +22 -0
- package/dist/schema/roles.d.ts +242 -0
- package/dist/schema/roles.js +37 -0
- package/dist/schema/session-assets.d.ts +92 -0
- package/dist/schema/session-assets.js +45 -0
- package/dist/schema/sessions.d.ts +143 -0
- package/dist/schema/sessions.js +29 -0
- package/dist/schema/sidecar-allocation.d.ts +406 -0
- package/dist/schema/sidecar-allocation.js +57 -0
- package/dist/schema/sidecar.d.ts +145 -0
- package/dist/schema/sidecar.js +28 -0
- package/dist/schema/signal-correlations.d.ts +177 -0
- package/dist/schema/signal-correlations.js +31 -0
- package/dist/schema/tenants.d.ts +235 -0
- package/{src/schema/tenants.ts → dist/schema/tenants.js} +10 -27
- package/dist/schema/wallets.d.ts +354 -0
- package/dist/schema/wallets.js +43 -0
- package/dist/schema/workflow-definitions.d.ts +371 -0
- package/dist/schema/workflow-definitions.js +97 -0
- package/dist/schema/workflow-run-dispatch.d.ts +328 -0
- package/dist/schema/workflow-run-dispatch.js +56 -0
- package/dist/schema/workflow-run-execution.d.ts +126 -0
- package/dist/schema/workflow-run-execution.js +48 -0
- package/dist/schema/workflow-run-launch-spec.d.ts +200 -0
- package/dist/schema/workflow-run-launch-spec.js +26 -0
- package/dist/schema/workflow-run.d.ts +230 -0
- package/dist/schema/workflow-run.js +102 -0
- package/dist/sidecar-allocation-store.d.ts +171 -0
- package/dist/sidecar-allocation-store.js +512 -0
- package/dist/signal-correlation-store.d.ts +36 -0
- package/dist/signal-correlation-store.js +63 -0
- package/dist/tenant-hierarchy.d.ts +23 -0
- package/dist/tenant-hierarchy.js +60 -0
- package/dist/workflow-definition-store.d.ts +55 -0
- package/dist/workflow-definition-store.js +93 -0
- package/dist/workflow-run-dispatch-store.d.ts +80 -0
- package/dist/workflow-run-dispatch-store.js +298 -0
- package/dist/workflow-run-launch-spec-store.d.ts +13 -0
- package/dist/workflow-run-launch-spec-store.js +30 -0
- package/dist/workflow-run-store.d.ts +54 -0
- package/dist/workflow-run-store.js +85 -0
- package/migrations/0029_loose_warlock.sql +1 -0
- package/migrations/0030_session_asset_audit_split.sql +5 -0
- package/migrations/0031_gigantic_nicolaos.sql +68 -0
- package/migrations/0032_lethal_misty_knight.sql +1 -0
- package/migrations/0033_old_payback.sql +1 -0
- package/migrations/0034_sleepy_songbird.sql +11 -0
- package/migrations/0035_violet_giant_man.sql +3 -0
- package/migrations/0036_sharp_the_executioner.sql +2 -0
- package/migrations/0037_credential_use_backfill.sql +39 -0
- package/migrations/0038_chilly_blacklash.sql +37 -0
- package/migrations/0039_quick_carnage.sql +2 -0
- package/migrations/0040_reshape_approval_origin.sql +24 -0
- package/migrations/0041_make_approval_timeout_at_nullable.sql +1 -0
- package/migrations/0042_youthful_mantis.sql +2 -0
- package/migrations/0043_signal_correlation_deployment_fk.sql +1 -0
- package/migrations/0044_model_offering_quirks.sql +1 -0
- package/migrations/0045_create_workflow_run.sql +13 -0
- package/migrations/0046_approval_signal_correlation_run_fk.sql +2 -0
- package/migrations/0047_create_workflow_definition.sql +30 -0
- package/migrations/0048_workflow_definition_origin_agent_id.sql +2 -0
- package/migrations/0049_curly_omega_flight.sql +2 -0
- package/migrations/0050_late_crystal.sql +10 -0
- package/migrations/0051_funny_madelyne_pryor.sql +1 -0
- package/migrations/0052_drop_inference_turn_instance_fk.sql +1 -0
- package/migrations/0053_session_mail_session_id_index.sql +1 -0
- package/migrations/0054_rekey_instance_grants_to_workflow_run.sql +10 -0
- package/migrations/0055_backfill_anchor_workflow_runs.sql +69 -0
- package/migrations/0056_repoint_deployment_fks_to_anchor_run.sql +32 -0
- package/migrations/0057_drop_workflow_deployment_projection.sql +22 -0
- package/migrations/0058_repoint_offering_fk_to_definition.sql +41 -0
- package/migrations/0059_repoint_transaction_fk_to_run.sql +10 -0
- package/migrations/0060_drop_session_mail_instance_fk.sql +6 -0
- package/migrations/0061_drop_session_asset_instance_fk.sql +7 -0
- package/migrations/0062_drop_agent_asset_table.sql +11 -0
- package/migrations/0063_repoint_agent_role_fk_to_definition.sql +39 -0
- package/migrations/0064_repoint_agent_session_fk_to_definition.sql +47 -0
- package/migrations/0065_add_workflow_definition_model_requirements.sql +37 -0
- package/migrations/0066_rekey_agent_definition_principals_to_workflow.sql +27 -0
- package/migrations/0067_add_workflow_definition_kind.sql +10 -0
- package/migrations/0068_drop_agent_tables_and_origin_agent_id.sql +31 -0
- package/migrations/0069_drop_workflow_definition_kind.sql +10 -0
- package/migrations/0070_flashy_proteus.sql +13 -0
- package/migrations/0072_add_workflow_definition_credential_bindings.sql +1 -0
- package/migrations/0073_grant_target_exactly_one_check.sql +13 -0
- package/migrations/0074_add_provider_api_base_url.sql +1 -0
- package/migrations/0075_workflow_run_launch_spec.sql +17 -0
- package/migrations/0076_sidecar_allocation.sql +40 -0
- package/migrations/0077_workflow_run_dispatch.sql +29 -0
- package/migrations/0078_workflow_run_dispatch_kind.sql +2 -0
- package/migrations/0079_rename_workflow_run_deployment_id_to_anchor_run_id.sql +4 -0
- package/migrations/0080_rename_correlation_approval_deployment_id_to_anchor_run_id.sql +9 -0
- package/migrations/0081_workflow_definition_content_hash_and_approved_wire_hash.sql +4 -0
- package/migrations/0082_blue_black_queen.sql +1 -0
- package/migrations/0083_replace_launch_spec_snapshot_with_frozen_bundle.sql +3 -0
- package/migrations/0084_delete_orphaned_credential_grants.sql +22 -0
- package/migrations/meta/0029_snapshot.json +2664 -0
- package/migrations/meta/0030_snapshot.json +2670 -0
- package/migrations/meta/0031_snapshot.json +3100 -0
- package/migrations/meta/0032_snapshot.json +3106 -0
- package/migrations/meta/0033_snapshot.json +3112 -0
- package/migrations/meta/0034_snapshot.json +3198 -0
- package/migrations/meta/0035_snapshot.json +3225 -0
- package/migrations/meta/0036_snapshot.json +3237 -0
- package/migrations/meta/0037_snapshot.json +3237 -0
- package/migrations/meta/0038_snapshot.json +3470 -0
- package/migrations/meta/0039_snapshot.json +3470 -0
- package/migrations/meta/0040_snapshot.json +3489 -0
- package/migrations/meta/0041_snapshot.json +3489 -0
- package/migrations/meta/0042_snapshot.json +3489 -0
- package/migrations/meta/0043_snapshot.json +3498 -0
- package/migrations/meta/0044_snapshot.json +3504 -0
- package/migrations/meta/0045_snapshot.json +3589 -0
- package/migrations/meta/0046_snapshot.json +3607 -0
- package/migrations/meta/0047_snapshot.json +3832 -0
- package/migrations/meta/0048_snapshot.json +3853 -0
- package/migrations/meta/0049_snapshot.json +3854 -0
- package/migrations/meta/0050_snapshot.json +3924 -0
- package/migrations/meta/0051_snapshot.json +3940 -0
- package/migrations/meta/0052_snapshot.json +3931 -0
- package/migrations/meta/0053_snapshot.json +3952 -0
- package/migrations/meta/0054_snapshot.json +3952 -0
- package/migrations/meta/0055_snapshot.json +3952 -0
- package/migrations/meta/0056_snapshot.json +3952 -0
- package/migrations/meta/0057_snapshot.json +3839 -0
- package/migrations/meta/0058_snapshot.json +3839 -0
- package/migrations/meta/0059_snapshot.json +3839 -0
- package/migrations/meta/0060_snapshot.json +3830 -0
- package/migrations/meta/0061_snapshot.json +3821 -0
- package/migrations/meta/0062_snapshot.json +3723 -0
- package/migrations/meta/0063_snapshot.json +3723 -0
- package/migrations/meta/0064_snapshot.json +3723 -0
- package/migrations/meta/0065_snapshot.json +3729 -0
- package/migrations/meta/0066_snapshot.json +3729 -0
- package/migrations/meta/0067_snapshot.json +3736 -0
- package/migrations/meta/0068_snapshot.json +3347 -0
- package/migrations/meta/0069_snapshot.json +3340 -0
- package/migrations/meta/0070_snapshot.json +3444 -0
- package/migrations/meta/0072_snapshot.json +3450 -0
- package/migrations/meta/0073_snapshot.json +3455 -0
- package/migrations/meta/0074_snapshot.json +3461 -0
- package/migrations/meta/0075_snapshot.json +3567 -0
- package/migrations/meta/0076_snapshot.json +3851 -0
- package/migrations/meta/0077_snapshot.json +4067 -0
- package/migrations/meta/0078_snapshot.json +4078 -0
- package/migrations/meta/0079_snapshot.json +4078 -0
- package/migrations/meta/0080_snapshot.json +4078 -0
- package/migrations/meta/0081_snapshot.json +4096 -0
- package/migrations/meta/0082_snapshot.json +4102 -0
- package/migrations/meta/0083_snapshot.json +4096 -0
- package/migrations/meta/0084_snapshot.json +4096 -0
- package/migrations/meta/_journal.json +385 -0
- package/package.json +25 -11
- package/drizzle.config.ts +0 -23
- package/src/client.ts +0 -24
- package/src/config.ts +0 -19
- package/src/connection.ts +0 -27
- package/src/credential-resolution.ts +0 -378
- package/src/grant-store.ts +0 -51
- package/src/index.ts +0 -32
- package/src/migrate.test.ts +0 -35
- package/src/migrate.ts +0 -168
- package/src/parse-row.test.ts +0 -113
- package/src/parse-row.ts +0 -185
- package/src/schema/agent-assets.ts +0 -21
- package/src/schema/agents.ts +0 -49
- package/src/schema/auth.ts +0 -51
- package/src/schema/grants.ts +0 -26
- package/src/schema/index.ts +0 -19
- package/src/schema/instances.ts +0 -36
- package/src/schema/messages.ts +0 -108
- package/src/schema/offerings.ts +0 -20
- package/src/schema/principals.ts +0 -28
- package/src/schema/providers.ts +0 -23
- package/src/schema/roles.ts +0 -51
- package/src/schema/session-assets.ts +0 -49
- package/src/schema/sessions.ts +0 -26
- package/src/schema/sidecar.ts +0 -14
- package/src/schema/wallets.ts +0 -44
- package/src/tenant-hierarchy.ts +0 -34
- package/tsconfig.json +0 -4
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
import { boolean, check, integer, jsonb, pgTable, text, timestamp, unique, } from "drizzle-orm/pg-core";
|
|
3
|
+
import { credential } from "./credentials.js";
|
|
4
|
+
import { tenant } from "./tenants.js";
|
|
5
|
+
import { wallet } from "./wallets.js";
|
|
6
|
+
export const model = pgTable("model", {
|
|
7
|
+
id: text("id").primaryKey(),
|
|
8
|
+
tenantId: text("tenant_id")
|
|
9
|
+
.notNull()
|
|
10
|
+
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
11
|
+
canonicalName: text("canonical_name").notNull(),
|
|
12
|
+
displayName: text("display_name"),
|
|
13
|
+
description: text("description"),
|
|
14
|
+
// Own-row disable. Suppressing an inherited row (a child tenant hiding a
|
|
15
|
+
// parent's model) is a separate resolution-time mechanism, not this flag.
|
|
16
|
+
disabled: boolean("disabled").notNull().default(false),
|
|
17
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
18
|
+
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
19
|
+
}, (t) => [
|
|
20
|
+
unique("model_tenant_canonical_name").on(t.tenantId, t.canonicalName),
|
|
21
|
+
]);
|
|
22
|
+
export const modelProvider = pgTable("model_provider", {
|
|
23
|
+
id: text("id").primaryKey(),
|
|
24
|
+
tenantId: text("tenant_id")
|
|
25
|
+
.notNull()
|
|
26
|
+
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
27
|
+
name: text("name").notNull(),
|
|
28
|
+
plugin: text("plugin", {
|
|
29
|
+
enum: ["anthropic", "openai", "openai-compatible", "google-genai"],
|
|
30
|
+
}).notNull(),
|
|
31
|
+
baseURL: text("base_url").notNull(),
|
|
32
|
+
// A provider authenticates via exactly one of credential or wallet (the
|
|
33
|
+
// check constraint below enforces the XOR). onDelete is "restrict" so a
|
|
34
|
+
// credential or wallet cannot be deleted out from under a provider that
|
|
35
|
+
// depends on it — the provider must be repointed or removed first.
|
|
36
|
+
credentialId: text("credential_id").references(() => credential.id, {
|
|
37
|
+
onDelete: "restrict",
|
|
38
|
+
}),
|
|
39
|
+
walletId: text("wallet_id").references(() => wallet.id, {
|
|
40
|
+
onDelete: "restrict",
|
|
41
|
+
}),
|
|
42
|
+
// Own-row disable. Inherited-row suppression is resolved separately.
|
|
43
|
+
disabled: boolean("disabled").notNull().default(false),
|
|
44
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
45
|
+
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
46
|
+
}, (t) => [
|
|
47
|
+
unique("model_provider_tenant_name").on(t.tenantId, t.name),
|
|
48
|
+
check("model_provider_auth_xor", sql `(${t.credentialId} is not null) <> (${t.walletId} is not null)`),
|
|
49
|
+
]);
|
|
50
|
+
export const modelOffering = pgTable("model_offering", {
|
|
51
|
+
id: text("id").primaryKey(),
|
|
52
|
+
tenantId: text("tenant_id")
|
|
53
|
+
.notNull()
|
|
54
|
+
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
55
|
+
modelId: text("model_id")
|
|
56
|
+
.notNull()
|
|
57
|
+
.references(() => model.id, { onDelete: "cascade" }),
|
|
58
|
+
providerId: text("provider_id")
|
|
59
|
+
.notNull()
|
|
60
|
+
.references(() => modelProvider.id, { onDelete: "cascade" }),
|
|
61
|
+
priority: integer("priority").notNull(),
|
|
62
|
+
deploymentTags: text("deployment_tags").array().notNull().default([]),
|
|
63
|
+
// Curated-capability tags. This issue creates the column; the values are
|
|
64
|
+
// populated by the discovery-support-matrix seeding work.
|
|
65
|
+
capabilities: text("capabilities").array().notNull().default([]),
|
|
66
|
+
// Opaque per-deployment bag of provider-specific adapter accommodations
|
|
67
|
+
// (e.g. OpenAI's forceAssistantReasoningContent). Interpreted and
|
|
68
|
+
// validated only at the adapter factory, which alone knows the provider
|
|
69
|
+
// shape. NULL means the factory receives no bag and applies its default
|
|
70
|
+
// behavior.
|
|
71
|
+
quirks: jsonb("quirks"),
|
|
72
|
+
// Own-row disable. Inherited-row suppression is resolved separately.
|
|
73
|
+
disabled: boolean("disabled").notNull().default(false),
|
|
74
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
75
|
+
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
76
|
+
}, (t) => [
|
|
77
|
+
unique("model_offering_tenant_model_provider").on(t.tenantId, t.modelId, t.providerId),
|
|
78
|
+
]);
|
|
79
|
+
export const modelPricing = pgTable("model_pricing", {
|
|
80
|
+
id: text("id").primaryKey(),
|
|
81
|
+
tenantId: text("tenant_id")
|
|
82
|
+
.notNull()
|
|
83
|
+
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
84
|
+
offeringId: text("offering_id")
|
|
85
|
+
.notNull()
|
|
86
|
+
.references(() => modelOffering.id, { onDelete: "cascade" }),
|
|
87
|
+
currency: text("currency").notNull(),
|
|
88
|
+
inputTokenPrice: text("input_token_price"),
|
|
89
|
+
outputTokenPrice: text("output_token_price"),
|
|
90
|
+
cacheReadTokenPrice: text("cache_read_token_price"),
|
|
91
|
+
cacheWriteTokenPrice: text("cache_write_token_price"),
|
|
92
|
+
thinkingTokenPrice: text("thinking_token_price"),
|
|
93
|
+
perRequestFee: text("per_request_fee"),
|
|
94
|
+
perImageFee: text("per_image_fee"),
|
|
95
|
+
perAudioFee: text("per_audio_fee"),
|
|
96
|
+
// Append-only. A price change inserts a new row with a later
|
|
97
|
+
// effective_from; rows are never edited in place, so cost attribution at
|
|
98
|
+
// a past timestamp stays accurate. withTimezone anchors the as-of
|
|
99
|
+
// comparison across writers.
|
|
100
|
+
effectiveFrom: timestamp("effective_from", {
|
|
101
|
+
withTimezone: true,
|
|
102
|
+
}).notNull(),
|
|
103
|
+
createdAt: timestamp("created_at", { withTimezone: true })
|
|
104
|
+
.notNull()
|
|
105
|
+
.defaultNow(),
|
|
106
|
+
}, (t) => [
|
|
107
|
+
unique("model_pricing_offering_currency_effective_from").on(t.offeringId, t.currency, t.effectiveFrom),
|
|
108
|
+
]);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const bytea: {
|
|
2
|
+
(): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
|
|
3
|
+
name: "";
|
|
4
|
+
dataType: "custom";
|
|
5
|
+
columnType: "PgCustomColumn";
|
|
6
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
7
|
+
driverParam: Uint8Array<ArrayBufferLike>;
|
|
8
|
+
enumValues: undefined;
|
|
9
|
+
}>;
|
|
10
|
+
<TConfig extends Record<string, any>>(fieldConfig?: TConfig | undefined): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
|
|
11
|
+
name: "";
|
|
12
|
+
dataType: "custom";
|
|
13
|
+
columnType: "PgCustomColumn";
|
|
14
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
15
|
+
driverParam: Uint8Array<ArrayBufferLike>;
|
|
16
|
+
enumValues: undefined;
|
|
17
|
+
}>;
|
|
18
|
+
<TName extends string>(dbName: TName, fieldConfig?: unknown): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
|
|
19
|
+
name: TName;
|
|
20
|
+
dataType: "custom";
|
|
21
|
+
columnType: "PgCustomColumn";
|
|
22
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
23
|
+
driverParam: Uint8Array<ArrayBufferLike>;
|
|
24
|
+
enumValues: undefined;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { customType } from "drizzle-orm/pg-core";
|
|
2
|
+
// Postgres `bytea` mapped to `Uint8Array` on both the app and driver
|
|
3
|
+
// sides, so binary columns (hash digests, raw message frames) round-trip
|
|
4
|
+
// as raw bytes with no encoding layer to keep in sync.
|
|
5
|
+
export const bytea = customType({
|
|
6
|
+
dataType() {
|
|
7
|
+
return "bytea";
|
|
8
|
+
},
|
|
9
|
+
toDriver(value) {
|
|
10
|
+
return value;
|
|
11
|
+
},
|
|
12
|
+
fromDriver(value) {
|
|
13
|
+
return new Uint8Array(value);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
export declare const credential: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "credential";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "id";
|
|
7
|
+
tableName: "credential";
|
|
8
|
+
dataType: "string";
|
|
9
|
+
columnType: "PgText";
|
|
10
|
+
data: string;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: false;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: [string, ...string[]];
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
tenantId: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "tenant_id";
|
|
24
|
+
tableName: "credential";
|
|
25
|
+
dataType: "string";
|
|
26
|
+
columnType: "PgText";
|
|
27
|
+
data: string;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: false;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: [string, ...string[]];
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
principalId: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "principal_id";
|
|
41
|
+
tableName: "credential";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "PgText";
|
|
44
|
+
data: string;
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: false;
|
|
47
|
+
hasDefault: false;
|
|
48
|
+
isPrimaryKey: false;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: [string, ...string[]];
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
providerId: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "provider_id";
|
|
58
|
+
tableName: "credential";
|
|
59
|
+
dataType: "string";
|
|
60
|
+
columnType: "PgText";
|
|
61
|
+
data: string;
|
|
62
|
+
driverParam: string;
|
|
63
|
+
notNull: true;
|
|
64
|
+
hasDefault: false;
|
|
65
|
+
isPrimaryKey: false;
|
|
66
|
+
isAutoincrement: false;
|
|
67
|
+
hasRuntimeDefault: false;
|
|
68
|
+
enumValues: [string, ...string[]];
|
|
69
|
+
baseColumn: never;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}, {}, {}>;
|
|
73
|
+
oauthClientId: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "oauth_client_id";
|
|
75
|
+
tableName: "credential";
|
|
76
|
+
dataType: "string";
|
|
77
|
+
columnType: "PgText";
|
|
78
|
+
data: string;
|
|
79
|
+
driverParam: string;
|
|
80
|
+
notNull: false;
|
|
81
|
+
hasDefault: false;
|
|
82
|
+
isPrimaryKey: false;
|
|
83
|
+
isAutoincrement: false;
|
|
84
|
+
hasRuntimeDefault: false;
|
|
85
|
+
enumValues: [string, ...string[]];
|
|
86
|
+
baseColumn: never;
|
|
87
|
+
identity: undefined;
|
|
88
|
+
generated: undefined;
|
|
89
|
+
}, {}, {}>;
|
|
90
|
+
name: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
|
+
name: "name";
|
|
92
|
+
tableName: "credential";
|
|
93
|
+
dataType: "string";
|
|
94
|
+
columnType: "PgText";
|
|
95
|
+
data: string;
|
|
96
|
+
driverParam: string;
|
|
97
|
+
notNull: true;
|
|
98
|
+
hasDefault: false;
|
|
99
|
+
isPrimaryKey: false;
|
|
100
|
+
isAutoincrement: false;
|
|
101
|
+
hasRuntimeDefault: false;
|
|
102
|
+
enumValues: [string, ...string[]];
|
|
103
|
+
baseColumn: never;
|
|
104
|
+
identity: undefined;
|
|
105
|
+
generated: undefined;
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
type: import("drizzle-orm/pg-core").PgColumn<{
|
|
108
|
+
name: "type";
|
|
109
|
+
tableName: "credential";
|
|
110
|
+
dataType: "string";
|
|
111
|
+
columnType: "PgText";
|
|
112
|
+
data: "api_key" | "oauth_token" | "certificate" | "other";
|
|
113
|
+
driverParam: string;
|
|
114
|
+
notNull: true;
|
|
115
|
+
hasDefault: false;
|
|
116
|
+
isPrimaryKey: false;
|
|
117
|
+
isAutoincrement: false;
|
|
118
|
+
hasRuntimeDefault: false;
|
|
119
|
+
enumValues: ["api_key", "oauth_token", "certificate", "other"];
|
|
120
|
+
baseColumn: never;
|
|
121
|
+
identity: undefined;
|
|
122
|
+
generated: undefined;
|
|
123
|
+
}, {}, {}>;
|
|
124
|
+
description: import("drizzle-orm/pg-core").PgColumn<{
|
|
125
|
+
name: "description";
|
|
126
|
+
tableName: "credential";
|
|
127
|
+
dataType: "string";
|
|
128
|
+
columnType: "PgText";
|
|
129
|
+
data: string;
|
|
130
|
+
driverParam: string;
|
|
131
|
+
notNull: false;
|
|
132
|
+
hasDefault: false;
|
|
133
|
+
isPrimaryKey: false;
|
|
134
|
+
isAutoincrement: false;
|
|
135
|
+
hasRuntimeDefault: false;
|
|
136
|
+
enumValues: [string, ...string[]];
|
|
137
|
+
baseColumn: never;
|
|
138
|
+
identity: undefined;
|
|
139
|
+
generated: undefined;
|
|
140
|
+
}, {}, {}>;
|
|
141
|
+
secret: import("drizzle-orm/pg-core").PgColumn<{
|
|
142
|
+
name: "secret";
|
|
143
|
+
tableName: "credential";
|
|
144
|
+
dataType: "string";
|
|
145
|
+
columnType: "PgText";
|
|
146
|
+
data: string;
|
|
147
|
+
driverParam: string;
|
|
148
|
+
notNull: true;
|
|
149
|
+
hasDefault: false;
|
|
150
|
+
isPrimaryKey: false;
|
|
151
|
+
isAutoincrement: false;
|
|
152
|
+
hasRuntimeDefault: false;
|
|
153
|
+
enumValues: [string, ...string[]];
|
|
154
|
+
baseColumn: never;
|
|
155
|
+
identity: undefined;
|
|
156
|
+
generated: undefined;
|
|
157
|
+
}, {}, {}>;
|
|
158
|
+
refreshSecret: import("drizzle-orm/pg-core").PgColumn<{
|
|
159
|
+
name: "refresh_secret";
|
|
160
|
+
tableName: "credential";
|
|
161
|
+
dataType: "string";
|
|
162
|
+
columnType: "PgText";
|
|
163
|
+
data: string;
|
|
164
|
+
driverParam: string;
|
|
165
|
+
notNull: false;
|
|
166
|
+
hasDefault: false;
|
|
167
|
+
isPrimaryKey: false;
|
|
168
|
+
isAutoincrement: false;
|
|
169
|
+
hasRuntimeDefault: false;
|
|
170
|
+
enumValues: [string, ...string[]];
|
|
171
|
+
baseColumn: never;
|
|
172
|
+
identity: undefined;
|
|
173
|
+
generated: undefined;
|
|
174
|
+
}, {}, {}>;
|
|
175
|
+
scopes: import("drizzle-orm/pg-core").PgColumn<{
|
|
176
|
+
name: "scopes";
|
|
177
|
+
tableName: "credential";
|
|
178
|
+
dataType: "array";
|
|
179
|
+
columnType: "PgArray";
|
|
180
|
+
data: string[];
|
|
181
|
+
driverParam: string | string[];
|
|
182
|
+
notNull: false;
|
|
183
|
+
hasDefault: false;
|
|
184
|
+
isPrimaryKey: false;
|
|
185
|
+
isAutoincrement: false;
|
|
186
|
+
hasRuntimeDefault: false;
|
|
187
|
+
enumValues: [string, ...string[]];
|
|
188
|
+
baseColumn: import("drizzle-orm").Column<{
|
|
189
|
+
name: "scopes";
|
|
190
|
+
tableName: "credential";
|
|
191
|
+
dataType: "string";
|
|
192
|
+
columnType: "PgText";
|
|
193
|
+
data: string;
|
|
194
|
+
driverParam: string;
|
|
195
|
+
notNull: false;
|
|
196
|
+
hasDefault: false;
|
|
197
|
+
isPrimaryKey: false;
|
|
198
|
+
isAutoincrement: false;
|
|
199
|
+
hasRuntimeDefault: false;
|
|
200
|
+
enumValues: [string, ...string[]];
|
|
201
|
+
baseColumn: never;
|
|
202
|
+
identity: undefined;
|
|
203
|
+
generated: undefined;
|
|
204
|
+
}, {}, {}>;
|
|
205
|
+
identity: undefined;
|
|
206
|
+
generated: undefined;
|
|
207
|
+
}, {}, {
|
|
208
|
+
baseBuilder: import("drizzle-orm/pg-core").PgColumnBuilder<{
|
|
209
|
+
name: "scopes";
|
|
210
|
+
dataType: "string";
|
|
211
|
+
columnType: "PgText";
|
|
212
|
+
data: string;
|
|
213
|
+
enumValues: [string, ...string[]];
|
|
214
|
+
driverParam: string;
|
|
215
|
+
}, {}, {}, import("drizzle-orm").ColumnBuilderExtraConfig>;
|
|
216
|
+
size: undefined;
|
|
217
|
+
}>;
|
|
218
|
+
expiresAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
219
|
+
name: "expires_at";
|
|
220
|
+
tableName: "credential";
|
|
221
|
+
dataType: "date";
|
|
222
|
+
columnType: "PgTimestamp";
|
|
223
|
+
data: Date;
|
|
224
|
+
driverParam: string;
|
|
225
|
+
notNull: false;
|
|
226
|
+
hasDefault: false;
|
|
227
|
+
isPrimaryKey: false;
|
|
228
|
+
isAutoincrement: false;
|
|
229
|
+
hasRuntimeDefault: false;
|
|
230
|
+
enumValues: undefined;
|
|
231
|
+
baseColumn: never;
|
|
232
|
+
identity: undefined;
|
|
233
|
+
generated: undefined;
|
|
234
|
+
}, {}, {}>;
|
|
235
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
236
|
+
name: "status";
|
|
237
|
+
tableName: "credential";
|
|
238
|
+
dataType: "string";
|
|
239
|
+
columnType: "PgText";
|
|
240
|
+
data: "active" | "error" | "expired" | "revoked";
|
|
241
|
+
driverParam: string;
|
|
242
|
+
notNull: true;
|
|
243
|
+
hasDefault: true;
|
|
244
|
+
isPrimaryKey: false;
|
|
245
|
+
isAutoincrement: false;
|
|
246
|
+
hasRuntimeDefault: false;
|
|
247
|
+
enumValues: ["active", "expired", "revoked", "error"];
|
|
248
|
+
baseColumn: never;
|
|
249
|
+
identity: undefined;
|
|
250
|
+
generated: undefined;
|
|
251
|
+
}, {}, {}>;
|
|
252
|
+
metadata: import("drizzle-orm/pg-core").PgColumn<{
|
|
253
|
+
name: "metadata";
|
|
254
|
+
tableName: "credential";
|
|
255
|
+
dataType: "json";
|
|
256
|
+
columnType: "PgJsonb";
|
|
257
|
+
data: unknown;
|
|
258
|
+
driverParam: unknown;
|
|
259
|
+
notNull: false;
|
|
260
|
+
hasDefault: false;
|
|
261
|
+
isPrimaryKey: false;
|
|
262
|
+
isAutoincrement: false;
|
|
263
|
+
hasRuntimeDefault: false;
|
|
264
|
+
enumValues: undefined;
|
|
265
|
+
baseColumn: never;
|
|
266
|
+
identity: undefined;
|
|
267
|
+
generated: undefined;
|
|
268
|
+
}, {}, {}>;
|
|
269
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
270
|
+
name: "created_at";
|
|
271
|
+
tableName: "credential";
|
|
272
|
+
dataType: "date";
|
|
273
|
+
columnType: "PgTimestamp";
|
|
274
|
+
data: Date;
|
|
275
|
+
driverParam: string;
|
|
276
|
+
notNull: true;
|
|
277
|
+
hasDefault: true;
|
|
278
|
+
isPrimaryKey: false;
|
|
279
|
+
isAutoincrement: false;
|
|
280
|
+
hasRuntimeDefault: false;
|
|
281
|
+
enumValues: undefined;
|
|
282
|
+
baseColumn: never;
|
|
283
|
+
identity: undefined;
|
|
284
|
+
generated: undefined;
|
|
285
|
+
}, {}, {}>;
|
|
286
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
287
|
+
name: "updated_at";
|
|
288
|
+
tableName: "credential";
|
|
289
|
+
dataType: "date";
|
|
290
|
+
columnType: "PgTimestamp";
|
|
291
|
+
data: Date;
|
|
292
|
+
driverParam: string;
|
|
293
|
+
notNull: true;
|
|
294
|
+
hasDefault: true;
|
|
295
|
+
isPrimaryKey: false;
|
|
296
|
+
isAutoincrement: false;
|
|
297
|
+
hasRuntimeDefault: false;
|
|
298
|
+
enumValues: undefined;
|
|
299
|
+
baseColumn: never;
|
|
300
|
+
identity: undefined;
|
|
301
|
+
generated: undefined;
|
|
302
|
+
}, {}, {}>;
|
|
303
|
+
};
|
|
304
|
+
dialect: "pg";
|
|
305
|
+
}>;
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
import { jsonb, pgTable, text, timestamp, unique } from "drizzle-orm/pg-core";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const credential = pgTable(
|
|
9
|
-
"credential",
|
|
10
|
-
{
|
|
2
|
+
import { oauthClient } from "./oauth-clients.js";
|
|
3
|
+
import { principal } from "./principals.js";
|
|
4
|
+
import { provider } from "./providers.js";
|
|
5
|
+
import { tenant } from "./tenants.js";
|
|
6
|
+
export const credential = pgTable("credential", {
|
|
11
7
|
id: text("id").primaryKey(),
|
|
12
8
|
tenantId: text("tenant_id")
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
.notNull()
|
|
10
|
+
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
15
11
|
principalId: text("principal_id").references(() => principal.id, {
|
|
16
|
-
|
|
12
|
+
onDelete: "set null",
|
|
17
13
|
}),
|
|
18
14
|
providerId: text("provider_id")
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
.notNull()
|
|
16
|
+
.references(() => provider.id, { onDelete: "cascade" }),
|
|
21
17
|
oauthClientId: text("oauth_client_id").references(() => oauthClient.id, {
|
|
22
|
-
|
|
18
|
+
onDelete: "set null",
|
|
23
19
|
}),
|
|
24
20
|
name: text("name").notNull(),
|
|
25
21
|
type: text("type", {
|
|
26
|
-
|
|
22
|
+
enum: ["api_key", "oauth_token", "certificate", "other"],
|
|
27
23
|
}).notNull(),
|
|
28
24
|
description: text("description"),
|
|
29
25
|
secret: text("secret").notNull(),
|
|
@@ -31,13 +27,11 @@ export const credential = pgTable(
|
|
|
31
27
|
scopes: text("scopes").array(),
|
|
32
28
|
expiresAt: timestamp("expires_at"),
|
|
33
29
|
status: text("status", {
|
|
34
|
-
|
|
30
|
+
enum: ["active", "expired", "revoked", "error"],
|
|
35
31
|
})
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
.notNull()
|
|
33
|
+
.default("active"),
|
|
38
34
|
metadata: jsonb("metadata"),
|
|
39
35
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
40
36
|
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
41
|
-
|
|
42
|
-
(t) => [unique("credential_tenant_name").on(t.tenantId, t.name)],
|
|
43
|
-
);
|
|
37
|
+
}, (t) => [unique("credential_tenant_name").on(t.tenantId, t.name)]);
|