mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 21:29:20 +00:00
feat(infisical-pg): updated pg migrator to new table name changes
This commit is contained in:
@@ -35,6 +35,8 @@ const getZodPrimitiveType = (type: string) => {
|
|||||||
return "z.date()";
|
return "z.date()";
|
||||||
case "integer":
|
case "integer":
|
||||||
return "z.number()";
|
return "z.number()";
|
||||||
|
case "bigint":
|
||||||
|
return "z.number()";
|
||||||
case "text":
|
case "text":
|
||||||
return "z.string()";
|
return "z.string()";
|
||||||
default:
|
default:
|
||||||
@@ -70,6 +72,10 @@ const getZodDefaultValue = (type: unknown, value: string | number | boolean | Ob
|
|||||||
if ((value as string).includes("nextval")) return;
|
if ((value as string).includes("nextval")) return;
|
||||||
return `.default(${value})`;
|
return `.default(${value})`;
|
||||||
}
|
}
|
||||||
|
case "bigint": {
|
||||||
|
if ((value as string).includes("nextval")) return;
|
||||||
|
return `.default(${parseInt((value as string).split("::")[0].slice(1, -1), 10)})`;
|
||||||
|
}
|
||||||
case "text":
|
case "text":
|
||||||
if (typeof value === "string" && value.includes("::")) {
|
if (typeof value === "string" && value.includes("::")) {
|
||||||
return `.default(${value.split("::")[0]})`;
|
return `.default(${value.split("::")[0]})`;
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
t.text("clientPublicKey");
|
t.text("clientPublicKey");
|
||||||
t.text("serverPrivateKey");
|
t.text("serverPrivateKey");
|
||||||
t.integer("encryptionVersion").defaultTo(2);
|
t.integer("encryptionVersion").defaultTo(2);
|
||||||
t.text("protectedKey").notNullable();
|
t.text("protectedKey");
|
||||||
t.text("protectedKeyIV").notNullable();
|
t.text("protectedKeyIV");
|
||||||
t.text("protectedKeyTag").notNullable();
|
t.text("protectedKeyTag");
|
||||||
t.text("publicKey").notNullable();
|
t.text("publicKey").notNullable();
|
||||||
t.text("encryptedPrivateKey").notNullable();
|
t.text("encryptedPrivateKey").notNullable();
|
||||||
t.text("iv").notNullable();
|
t.text("iv").notNullable();
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
await knex.schema.createTable(TableName.IdentityUniversalAuth, (t) => {
|
await knex.schema.createTable(TableName.IdentityUniversalAuth, (t) => {
|
||||||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
||||||
t.string("clientId").notNullable();
|
t.string("clientId").notNullable();
|
||||||
t.integer("accessTokenTTL").defaultTo(7200).notNullable();
|
t.bigInteger("accessTokenTTL").defaultTo(7200).notNullable();
|
||||||
t.integer("accessTokenMaxTTL").defaultTo(7200).notNullable();
|
t.bigInteger("accessTokenMaxTTL").defaultTo(7200).notNullable();
|
||||||
t.integer("accessTokenNumUsesLimit").defaultTo(0).notNullable();
|
t.bigInteger("accessTokenNumUsesLimit").defaultTo(0).notNullable();
|
||||||
t.jsonb("clientSecretTrustedIps").notNullable();
|
t.jsonb("clientSecretTrustedIps").notNullable();
|
||||||
t.jsonb("accessTokenTrustedIps").notNullable();
|
t.jsonb("accessTokenTrustedIps").notNullable();
|
||||||
t.timestamps(true, true, true);
|
t.timestamps(true, true, true);
|
||||||
@@ -25,9 +25,9 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
t.string("clientSecretPrefix").notNullable();
|
t.string("clientSecretPrefix").notNullable();
|
||||||
t.string("clientSecretHash").notNullable();
|
t.string("clientSecretHash").notNullable();
|
||||||
t.datetime("clientSecretLastUsedAt");
|
t.datetime("clientSecretLastUsedAt");
|
||||||
t.integer("clientSecretNumUses").defaultTo(0).notNullable();
|
t.bigInteger("clientSecretNumUses").defaultTo(0).notNullable();
|
||||||
t.integer("clientSecretNumUsesLimit").defaultTo(0).notNullable();
|
t.bigInteger("clientSecretNumUsesLimit").defaultTo(0).notNullable();
|
||||||
t.integer("clientSecretTTL").defaultTo(0).notNullable();
|
t.bigInteger("clientSecretTTL").defaultTo(0).notNullable();
|
||||||
t.boolean("isClientSecretRevoked").defaultTo(false).notNullable();
|
t.boolean("isClientSecretRevoked").defaultTo(false).notNullable();
|
||||||
t.timestamps(true, true, true);
|
t.timestamps(true, true, true);
|
||||||
t.uuid("identityUAId").notNullable();
|
t.uuid("identityUAId").notNullable();
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
await knex.schema.createTable(TableName.IdentityAccessToken, (t) => {
|
await knex.schema.createTable(TableName.IdentityAccessToken, (t) => {
|
||||||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
||||||
t.string("authType").notNullable();
|
t.string("authType").notNullable();
|
||||||
t.integer("accessTokenTTL").defaultTo(2592000).notNullable(); // 30 days second
|
t.bigInteger("accessTokenTTL").defaultTo(2592000).notNullable(); // 30 days second
|
||||||
t.integer("accessTokenMaxTTL").defaultTo(2592000).notNullable();
|
t.bigInteger("accessTokenMaxTTL").defaultTo(2592000).notNullable();
|
||||||
t.integer("accessTokenNumUses").defaultTo(0).notNullable();
|
t.bigInteger("accessTokenNumUses").defaultTo(0).notNullable();
|
||||||
t.integer("accessTokenNumUsesLimit").defaultTo(0).notNullable();
|
t.bigInteger("accessTokenNumUsesLimit").defaultTo(0).notNullable();
|
||||||
t.datetime("accessTokenLastUsedAt");
|
t.datetime("accessTokenLastUsedAt");
|
||||||
t.datetime("accessTokenLastRenewedAt");
|
t.datetime("accessTokenLastRenewedAt");
|
||||||
t.boolean("isAccessTokenRevoked").defaultTo(false).notNullable();
|
t.boolean("isAccessTokenRevoked").defaultTo(false).notNullable();
|
||||||
|
|||||||
@@ -19,9 +19,11 @@ export const IdentityUaClientSecretsSchema = z.object({
|
|||||||
isClientSecretRevoked: z.boolean().default(false),
|
isClientSecretRevoked: z.boolean().default(false),
|
||||||
createdAt: z.date(),
|
createdAt: z.date(),
|
||||||
updatedAt: z.date(),
|
updatedAt: z.date(),
|
||||||
identityUAId: z.string().uuid(),
|
identityUAId: z.string().uuid()
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TIdentityUaClientSecrets = z.infer<typeof IdentityUaClientSecretsSchema>;
|
export type TIdentityUaClientSecrets = z.infer<typeof IdentityUaClientSecretsSchema>;
|
||||||
export type TIdentityUaClientSecretsInsert = Omit<TIdentityUaClientSecrets, TImmutableDBKeys>;
|
export type TIdentityUaClientSecretsInsert = Omit<TIdentityUaClientSecrets, TImmutableDBKeys>;
|
||||||
export type TIdentityUaClientSecretsUpdate = Partial<Omit<TIdentityUaClientSecrets, TImmutableDBKeys>>;
|
export type TIdentityUaClientSecretsUpdate = Partial<
|
||||||
|
Omit<TIdentityUaClientSecrets, TImmutableDBKeys>
|
||||||
|
>;
|
||||||
|
|||||||
Generated
+59
@@ -10,10 +10,12 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@casl/ability": "^6.5.0",
|
"@casl/ability": "^6.5.0",
|
||||||
|
"@sindresorhus/slugify": "^2.2.1",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"knex": "^3.1.0",
|
"knex": "^3.1.0",
|
||||||
"level": "^8.0.0",
|
"level": "^8.0.0",
|
||||||
"mongoose": "^8.0.4",
|
"mongoose": "^8.0.4",
|
||||||
|
"nanoid": "^5.0.4",
|
||||||
"pg": "^8.11.3",
|
"pg": "^8.11.3",
|
||||||
"prompt-sync": "^4.2.0",
|
"prompt-sync": "^4.2.0",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^9.0.1",
|
||||||
@@ -414,6 +416,35 @@
|
|||||||
"sparse-bitfield": "^3.0.3"
|
"sparse-bitfield": "^3.0.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@sindresorhus/slugify": {
|
||||||
|
"version": "2.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@sindresorhus/slugify/-/slugify-2.2.1.tgz",
|
||||||
|
"integrity": "sha512-MkngSCRZ8JdSOCHRaYd+D01XhvU3Hjy6MGl06zhOk614hp9EOAp5gIkBeQg7wtmxpitU6eAL4kdiRMcJa2dlrw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@sindresorhus/transliterate": "^1.0.0",
|
||||||
|
"escape-string-regexp": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@sindresorhus/transliterate": {
|
||||||
|
"version": "1.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@sindresorhus/transliterate/-/transliterate-1.6.0.tgz",
|
||||||
|
"integrity": "sha512-doH1gimEu3A46VX6aVxpHTeHrytJAG6HgdxntYnCFiIFHEM/ZGpG8KiZGBChchjQmG0XFIBL552kBTjVcMZXwQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"escape-string-regexp": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "20.11.0",
|
"version": "20.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.0.tgz",
|
||||||
@@ -683,6 +714,17 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/escape-string-regexp": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/esm": {
|
"node_modules/esm": {
|
||||||
"version": "3.2.25",
|
"version": "3.2.25",
|
||||||
"resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz",
|
"resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz",
|
||||||
@@ -1025,6 +1067,23 @@
|
|||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||||
},
|
},
|
||||||
|
"node_modules/nanoid": {
|
||||||
|
"version": "5.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.4.tgz",
|
||||||
|
"integrity": "sha512-vAjmBf13gsmhXSgBrtIclinISzFFy22WwCYoyilZlsrRXNIHSwgFQ1bEdjRwMT3aoadeIF6HMuDRlOxzfXV8ig==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/ai"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bin": {
|
||||||
|
"nanoid": "bin/nanoid.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18 || >=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/napi-macros": {
|
"node_modules/napi-macros": {
|
||||||
"version": "2.2.2",
|
"version": "2.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.2.2.tgz",
|
||||||
|
|||||||
@@ -18,10 +18,12 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@casl/ability": "^6.5.0",
|
"@casl/ability": "^6.5.0",
|
||||||
|
"@sindresorhus/slugify": "^2.2.1",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"knex": "^3.1.0",
|
"knex": "^3.1.0",
|
||||||
"level": "^8.0.0",
|
"level": "^8.0.0",
|
||||||
"mongoose": "^8.0.4",
|
"mongoose": "^8.0.4",
|
||||||
|
"nanoid": "^5.0.4",
|
||||||
"pg": "^8.11.3",
|
"pg": "^8.11.3",
|
||||||
"prompt-sync": "^4.2.0",
|
"prompt-sync": "^4.2.0",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^9.0.1",
|
||||||
|
|||||||
Vendored
+37
-29
@@ -12,6 +12,7 @@ import {
|
|||||||
TAuthTokenSessions,
|
TAuthTokenSessions,
|
||||||
TAuthTokenSessionsInsert,
|
TAuthTokenSessionsInsert,
|
||||||
TAuthTokenSessionsUpdate,
|
TAuthTokenSessionsUpdate,
|
||||||
|
TAuthTokensInsert,
|
||||||
TAuthTokensUpdate,
|
TAuthTokensUpdate,
|
||||||
TBackupPrivateKey,
|
TBackupPrivateKey,
|
||||||
TBackupPrivateKeyInsert,
|
TBackupPrivateKeyInsert,
|
||||||
@@ -82,23 +83,23 @@ import {
|
|||||||
TSamlConfigs,
|
TSamlConfigs,
|
||||||
TSamlConfigsInsert,
|
TSamlConfigsInsert,
|
||||||
TSamlConfigsUpdate,
|
TSamlConfigsUpdate,
|
||||||
TSapApprovers,
|
|
||||||
TSapApproversInsert,
|
|
||||||
TSapApproversUpdate,
|
|
||||||
TSaRequestSecrets,
|
|
||||||
TSaRequestSecretsInsert,
|
|
||||||
TSaRequestSecretsUpdate,
|
|
||||||
TSaRequestSecretTags,
|
|
||||||
TSaRequestSecretTagsInsert,
|
|
||||||
TSaRequestSecretTagsUpdate,
|
|
||||||
TSarReviewers,
|
|
||||||
TSarReviewersInsert,
|
|
||||||
TSarReviewersUpdate,
|
|
||||||
TSecretApprovalPolicies,
|
TSecretApprovalPolicies,
|
||||||
|
TSecretApprovalPoliciesApprovers,
|
||||||
|
TSecretApprovalPoliciesApproversInsert,
|
||||||
|
TSecretApprovalPoliciesApproversUpdate,
|
||||||
TSecretApprovalPoliciesInsert,
|
TSecretApprovalPoliciesInsert,
|
||||||
TSecretApprovalPoliciesUpdate,
|
TSecretApprovalPoliciesUpdate,
|
||||||
TSecretApprovalRequests,
|
TSecretApprovalRequests,
|
||||||
|
TSecretApprovalRequestSecretTags,
|
||||||
|
TSecretApprovalRequestSecretTagsInsert,
|
||||||
|
TSecretApprovalRequestSecretTagsUpdate,
|
||||||
TSecretApprovalRequestsInsert,
|
TSecretApprovalRequestsInsert,
|
||||||
|
TSecretApprovalRequestsReviewers,
|
||||||
|
TSecretApprovalRequestsReviewersInsert,
|
||||||
|
TSecretApprovalRequestsReviewersUpdate,
|
||||||
|
TSecretApprovalRequestsSecrets,
|
||||||
|
TSecretApprovalRequestsSecretsInsert,
|
||||||
|
TSecretApprovalRequestsSecretsUpdate,
|
||||||
TSecretApprovalRequestsUpdate,
|
TSecretApprovalRequestsUpdate,
|
||||||
TSecretBlindIndexes,
|
TSecretBlindIndexes,
|
||||||
TSecretBlindIndexesInsert,
|
TSecretBlindIndexesInsert,
|
||||||
@@ -142,6 +143,9 @@ import {
|
|||||||
TSecretVersions,
|
TSecretVersions,
|
||||||
TSecretVersionsInsert,
|
TSecretVersionsInsert,
|
||||||
TSecretVersionsUpdate,
|
TSecretVersionsUpdate,
|
||||||
|
TSecretVersionTagJunction,
|
||||||
|
TSecretVersionTagJunctionInsert,
|
||||||
|
TSecretVersionTagJunctionUpdate,
|
||||||
TServiceTokens,
|
TServiceTokens,
|
||||||
TServiceTokensInsert,
|
TServiceTokensInsert,
|
||||||
TServiceTokensUpdate,
|
TServiceTokensUpdate,
|
||||||
@@ -163,7 +167,6 @@ import {
|
|||||||
TWebhooks,
|
TWebhooks,
|
||||||
TWebhooksInsert,
|
TWebhooksInsert,
|
||||||
TWebhooksUpdate,
|
TWebhooksUpdate,
|
||||||
TAuthTokensInsert,
|
|
||||||
} from "../schemas";
|
} from "../schemas";
|
||||||
|
|
||||||
declare module "knex/types/tables" {
|
declare module "knex/types/tables" {
|
||||||
@@ -348,30 +351,30 @@ declare module "knex/types/tables" {
|
|||||||
TSecretApprovalPoliciesInsert,
|
TSecretApprovalPoliciesInsert,
|
||||||
TSecretApprovalPoliciesUpdate
|
TSecretApprovalPoliciesUpdate
|
||||||
>;
|
>;
|
||||||
[TableName.SapApprover]: Knex.CompositeTableType<
|
[TableName.SecretApprovalPolicyApprover]: Knex.CompositeTableType<
|
||||||
TSapApprovers,
|
TSecretApprovalPoliciesApprovers,
|
||||||
TSapApproversInsert,
|
TSecretApprovalPoliciesApproversInsert,
|
||||||
TSapApproversUpdate
|
TSecretApprovalPoliciesApproversUpdate
|
||||||
>;
|
>;
|
||||||
[TableName.SecretApprovalRequest]: Knex.CompositeTableType<
|
[TableName.SecretApprovalRequest]: Knex.CompositeTableType<
|
||||||
TSecretApprovalRequests,
|
TSecretApprovalRequests,
|
||||||
TSecretApprovalRequestsInsert,
|
TSecretApprovalRequestsInsert,
|
||||||
TSecretApprovalRequestsUpdate
|
TSecretApprovalRequestsUpdate
|
||||||
>;
|
>;
|
||||||
[TableName.SarReviewer]: Knex.CompositeTableType<
|
[TableName.SecretApprovalRequestReviewer]: Knex.CompositeTableType<
|
||||||
TSarReviewers,
|
TSecretApprovalRequestsReviewers,
|
||||||
TSarReviewersInsert,
|
TSecretApprovalRequestsReviewersInsert,
|
||||||
TSarReviewersUpdate
|
TSecretApprovalRequestsReviewersUpdate
|
||||||
>;
|
>;
|
||||||
[TableName.SarSecret]: Knex.CompositeTableType<
|
[TableName.SecretApprovalRequestSecret]: Knex.CompositeTableType<
|
||||||
TSaRequestSecrets,
|
TSecretApprovalRequestsSecrets,
|
||||||
TSaRequestSecretsInsert,
|
TSecretApprovalRequestsSecretsInsert,
|
||||||
TSaRequestSecretsUpdate
|
TSecretApprovalRequestsSecretsUpdate
|
||||||
>;
|
>;
|
||||||
[TableName.SarSecretTag]: Knex.CompositeTableType<
|
[TableName.SecretApprovalRequestSecretTag]: Knex.CompositeTableType<
|
||||||
TSaRequestSecretTags,
|
TSecretApprovalRequestSecretTags,
|
||||||
TSaRequestSecretTagsInsert,
|
TSecretApprovalRequestSecretTagsInsert,
|
||||||
TSaRequestSecretTagsUpdate
|
TSecretApprovalRequestSecretTagsUpdate
|
||||||
>;
|
>;
|
||||||
[TableName.SecretRotation]: Knex.CompositeTableType<
|
[TableName.SecretRotation]: Knex.CompositeTableType<
|
||||||
TSecretRotations,
|
TSecretRotations,
|
||||||
@@ -439,5 +442,10 @@ declare module "knex/types/tables" {
|
|||||||
TSecretTagJunctionInsert,
|
TSecretTagJunctionInsert,
|
||||||
TSecretTagJunctionUpdate
|
TSecretTagJunctionUpdate
|
||||||
>;
|
>;
|
||||||
|
[TableName.SecretVersionTag]: Knex.CompositeTableType<
|
||||||
|
TSecretVersionTagJunction,
|
||||||
|
TSecretVersionTagJunctionInsert,
|
||||||
|
TSecretVersionTagJunctionUpdate
|
||||||
|
>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+483
-210
File diff suppressed because it is too large
Load Diff
@@ -9,13 +9,17 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
await knex.schema.createTable(TableName.Organization, (t) => {
|
await knex.schema.createTable(TableName.Organization, (t) => {
|
||||||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
||||||
t.string("name").notNullable();
|
t.string("name").notNullable();
|
||||||
|
t.string("slug").notNullable();
|
||||||
t.string("customerId");
|
t.string("customerId");
|
||||||
// does not need update trigger we will do it manually
|
// does not need update trigger we will do it manually
|
||||||
t.timestamps(true, true, true);
|
t.timestamps(true, true, true);
|
||||||
});
|
});
|
||||||
await knex.schema.alterTable(TableName.AuthTokens, (t) => {
|
await knex.schema.alterTable(TableName.AuthTokens, (t) => {
|
||||||
t.uuid("orgId");
|
t.uuid("orgId");
|
||||||
t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");
|
t.foreign("orgId")
|
||||||
|
.references("id")
|
||||||
|
.inTable(TableName.Organization)
|
||||||
|
.onDelete("CASCADE");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// this is a one time function
|
// this is a one time function
|
||||||
|
|||||||
@@ -8,9 +8,13 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
await knex.schema.createTable(TableName.Project, (t) => {
|
await knex.schema.createTable(TableName.Project, (t) => {
|
||||||
t.string("id", 36).primary().defaultTo(knex.fn.uuid());
|
t.string("id", 36).primary().defaultTo(knex.fn.uuid());
|
||||||
t.string("name", 60).notNullable();
|
t.string("name", 60).notNullable();
|
||||||
|
t.string("slug").notNullable();
|
||||||
t.boolean("autoCapitalization").defaultTo(true);
|
t.boolean("autoCapitalization").defaultTo(true);
|
||||||
t.uuid("orgId").notNullable();
|
t.uuid("orgId").notNullable();
|
||||||
t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");
|
t.foreign("orgId")
|
||||||
|
.references("id")
|
||||||
|
.inTable(TableName.Organization)
|
||||||
|
.onDelete("CASCADE");
|
||||||
t.timestamps(true, true, true);
|
t.timestamps(true, true, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -23,11 +27,14 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
t.string("slug").notNullable();
|
t.string("slug").notNullable();
|
||||||
t.integer("position").notNullable();
|
t.integer("position").notNullable();
|
||||||
t.string("projectId").notNullable();
|
t.string("projectId").notNullable();
|
||||||
t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE");
|
t.foreign("projectId")
|
||||||
|
.references("id")
|
||||||
|
.inTable(TableName.Project)
|
||||||
|
.onDelete("CASCADE");
|
||||||
// this will ensure ever env has its position
|
// this will ensure ever env has its position
|
||||||
t.unique(["projectId", "position"], {
|
t.unique(["projectId", "position"], {
|
||||||
indexName: "env_pos_composite_uniqe",
|
indexName: "env_pos_composite_uniqe",
|
||||||
deferrable: "deferred"
|
deferrable: "deferred",
|
||||||
});
|
});
|
||||||
t.timestamps(true, true, true);
|
t.timestamps(true, true, true);
|
||||||
});
|
});
|
||||||
@@ -39,12 +46,21 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
t.text("encryptedKey").notNullable();
|
t.text("encryptedKey").notNullable();
|
||||||
t.text("nonce").notNullable();
|
t.text("nonce").notNullable();
|
||||||
t.uuid("receiverId").notNullable();
|
t.uuid("receiverId").notNullable();
|
||||||
t.foreign("receiverId").references("id").inTable(TableName.Users).onDelete("CASCADE");
|
t.foreign("receiverId")
|
||||||
|
.references("id")
|
||||||
|
.inTable(TableName.Users)
|
||||||
|
.onDelete("CASCADE");
|
||||||
t.uuid("senderId");
|
t.uuid("senderId");
|
||||||
// if sender is deleted just don't do anything to this record
|
// if sender is deleted just don't do anything to this record
|
||||||
t.foreign("senderId").references("id").inTable(TableName.Users).onDelete("SET NULL");
|
t.foreign("senderId")
|
||||||
|
.references("id")
|
||||||
|
.inTable(TableName.Users)
|
||||||
|
.onDelete("SET NULL");
|
||||||
t.string("projectId").notNullable();
|
t.string("projectId").notNullable();
|
||||||
t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE");
|
t.foreign("projectId")
|
||||||
|
.references("id")
|
||||||
|
.inTable(TableName.Project)
|
||||||
|
.onDelete("CASCADE");
|
||||||
t.timestamps(true, true, true);
|
t.timestamps(true, true, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ export * from "./project-keys";
|
|||||||
export * from "./project-memberships";
|
export * from "./project-memberships";
|
||||||
export * from "./project-roles";
|
export * from "./project-roles";
|
||||||
export * from "./projects";
|
export * from "./projects";
|
||||||
export * from "./sa-request-secret-tags";
|
export * from "./secret-approval-request-secret-tags";
|
||||||
export * from "./sa-request-secrets";
|
export * from "./secret-approval-requests-secrets";
|
||||||
export * from "./saml-configs";
|
export * from "./saml-configs";
|
||||||
export * from "./sap-approvers";
|
export * from "./secret-approval-policies-approvers";
|
||||||
export * from "./sar-reviewers";
|
export * from "./secret-approval-requests-reviewers";
|
||||||
export * from "./secret-approval-policies";
|
export * from "./secret-approval-policies";
|
||||||
export * from "./secret-approval-requests";
|
export * from "./secret-approval-requests";
|
||||||
export * from "./secret-blind-indexes";
|
export * from "./secret-blind-indexes";
|
||||||
@@ -53,3 +53,4 @@ export * from "./user-actions";
|
|||||||
export * from "./user-encryption-keys";
|
export * from "./user-encryption-keys";
|
||||||
export * from "./users";
|
export * from "./users";
|
||||||
export * from "./webhooks";
|
export * from "./webhooks";
|
||||||
|
export * from "./secret-version-tag-junction";
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ export enum TableName {
|
|||||||
IdentityOrgMembership = "identity_org_memberships",
|
IdentityOrgMembership = "identity_org_memberships",
|
||||||
IdentityProjectMembership = "identity_project_memberships",
|
IdentityProjectMembership = "identity_project_memberships",
|
||||||
SecretApprovalPolicy = "secret_approval_policies",
|
SecretApprovalPolicy = "secret_approval_policies",
|
||||||
SapApprover = "sap_approvers", // sap: secret approval policy
|
SecretApprovalPolicyApprover = "secret_approval_policies_approvers",
|
||||||
SecretApprovalRequest = "secret_approval_requests",
|
SecretApprovalRequest = "secret_approval_requests",
|
||||||
SarReviewer = "sar_reviewers",
|
SecretApprovalRequestReviewer = "secret_approval_requests_reviewers",
|
||||||
SarSecret = "sa_request_secrets",
|
SecretApprovalRequestSecret = "secret_approval_requests_secrets",
|
||||||
SarSecretTag = "sa_request_secret_tags",
|
SecretApprovalRequestSecretTag = "secret_approval_request_secret_tags",
|
||||||
SecretRotation = "secret_rotations",
|
SecretRotation = "secret_rotations",
|
||||||
SecretRotationOutput = "secret_rotation_outputs",
|
SecretRotationOutput = "secret_rotation_outputs",
|
||||||
SamlConfig = "saml_configs",
|
SamlConfig = "saml_configs",
|
||||||
@@ -54,9 +54,9 @@ export enum TableName {
|
|||||||
GitAppOrg = "git_app_org",
|
GitAppOrg = "git_app_org",
|
||||||
SecretScanningGitRisk = "secret_scanning_git_risks",
|
SecretScanningGitRisk = "secret_scanning_git_risks",
|
||||||
TrustedIps = "trusted_ips",
|
TrustedIps = "trusted_ips",
|
||||||
// junction tables
|
// junction tables with tags
|
||||||
JnSecretTag = "secret_tag_junction",
|
JnSecretTag = "secret_tag_junction",
|
||||||
JnSecretVersionTag = "secret_version_tag_junction"
|
SecretVersionTag = "secret_version_tag_junction",
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TImmutableDBKeys = "id" | "createdAt" | "updatedAt";
|
export type TImmutableDBKeys = "id" | "createdAt" | "updatedAt";
|
||||||
@@ -64,7 +64,7 @@ export type TImmutableDBKeys = "id" | "createdAt" | "updatedAt";
|
|||||||
export const UserDeviceSchema = z
|
export const UserDeviceSchema = z
|
||||||
.object({
|
.object({
|
||||||
ip: z.string(),
|
ip: z.string(),
|
||||||
userAgent: z.string()
|
userAgent: z.string(),
|
||||||
})
|
})
|
||||||
.array()
|
.array()
|
||||||
.default([]);
|
.default([]);
|
||||||
@@ -72,7 +72,7 @@ export const UserDeviceSchema = z
|
|||||||
export const ServiceTokenScopes = z
|
export const ServiceTokenScopes = z
|
||||||
.object({
|
.object({
|
||||||
environment: z.string(),
|
environment: z.string(),
|
||||||
secretPath: z.string().default("/")
|
secretPath: z.string().default("/"),
|
||||||
})
|
})
|
||||||
.array();
|
.array();
|
||||||
|
|
||||||
@@ -80,12 +80,12 @@ export enum OrgMembershipRole {
|
|||||||
Admin = "admin",
|
Admin = "admin",
|
||||||
Member = "member",
|
Member = "member",
|
||||||
NoAccess = "no-access",
|
NoAccess = "no-access",
|
||||||
Custom = "custom"
|
Custom = "custom",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum OrgMembershipStatus {
|
export enum OrgMembershipStatus {
|
||||||
Invited = "invited",
|
Invited = "invited",
|
||||||
Accepted = "accepted"
|
Accepted = "accepted",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ProjectMembershipRole {
|
export enum ProjectMembershipRole {
|
||||||
@@ -93,24 +93,24 @@ export enum ProjectMembershipRole {
|
|||||||
Member = "member",
|
Member = "member",
|
||||||
Custom = "custom",
|
Custom = "custom",
|
||||||
Viewer = "viewer",
|
Viewer = "viewer",
|
||||||
NoAccess = "no-access"
|
NoAccess = "no-access",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SecretEncryptionAlgo {
|
export enum SecretEncryptionAlgo {
|
||||||
AES_256_GCM = "aes-256-gcm"
|
AES_256_GCM = "aes-256-gcm",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SecretKeyEncoding {
|
export enum SecretKeyEncoding {
|
||||||
UTF8 = "utf8",
|
UTF8 = "utf8",
|
||||||
BASE64 = "base64",
|
BASE64 = "base64",
|
||||||
HEX = "hex"
|
HEX = "hex",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SecretType {
|
export enum SecretType {
|
||||||
Shared = "shared",
|
Shared = "shared",
|
||||||
Personal = "personal"
|
Personal = "personal",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum IdentityAuthMethod {
|
export enum IdentityAuthMethod {
|
||||||
Univeral = "universal"
|
Univeral = "universal",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { TImmutableDBKeys } from "./models";
|
|||||||
export const OrganizationsSchema = z.object({
|
export const OrganizationsSchema = z.object({
|
||||||
id: z.string().uuid(),
|
id: z.string().uuid(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
|
slug: z.string(),
|
||||||
customerId: z.string().nullable().optional(),
|
customerId: z.string().nullable().optional(),
|
||||||
createdAt: z.date(),
|
createdAt: z.date(),
|
||||||
updatedAt: z.date(),
|
updatedAt: z.date(),
|
||||||
@@ -17,4 +18,6 @@ export const OrganizationsSchema = z.object({
|
|||||||
|
|
||||||
export type TOrganizations = z.infer<typeof OrganizationsSchema>;
|
export type TOrganizations = z.infer<typeof OrganizationsSchema>;
|
||||||
export type TOrganizationsInsert = Omit<TOrganizations, TImmutableDBKeys>;
|
export type TOrganizationsInsert = Omit<TOrganizations, TImmutableDBKeys>;
|
||||||
export type TOrganizationsUpdate = Partial<Omit<TOrganizations, TImmutableDBKeys>>;
|
export type TOrganizationsUpdate = Partial<
|
||||||
|
Omit<TOrganizations, TImmutableDBKeys>
|
||||||
|
>;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { TImmutableDBKeys } from "./models";
|
|||||||
export const ProjectsSchema = z.object({
|
export const ProjectsSchema = z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
|
slug: z.string(),
|
||||||
autoCapitalization: z.boolean().default(true).nullable().optional(),
|
autoCapitalization: z.boolean().default(true).nullable().optional(),
|
||||||
orgId: z.string().uuid(),
|
orgId: z.string().uuid(),
|
||||||
createdAt: z.date(),
|
createdAt: z.date(),
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
// Code generated by automation script, DO NOT EDIT.
|
|
||||||
// Automated by pulling database and generating zod schema
|
|
||||||
// To update. Just run npm run generate:schema
|
|
||||||
// Written by akhilmhdh.
|
|
||||||
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import { TImmutableDBKeys } from "./models";
|
|
||||||
|
|
||||||
export const SaRequestSecretTagsSchema = z.object({
|
|
||||||
id: z.string().uuid(),
|
|
||||||
secretId: z.string().uuid(),
|
|
||||||
tagId: z.string().uuid(),
|
|
||||||
createdAt: z.date(),
|
|
||||||
updatedAt: z.date(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type TSaRequestSecretTags = z.infer<typeof SaRequestSecretTagsSchema>;
|
|
||||||
export type TSaRequestSecretTagsInsert = Omit<TSaRequestSecretTags, TImmutableDBKeys>;
|
|
||||||
export type TSaRequestSecretTagsUpdate = Partial<Omit<TSaRequestSecretTags, TImmutableDBKeys>>;
|
|
||||||
+4
-4
@@ -7,7 +7,7 @@ import { z } from "zod";
|
|||||||
|
|
||||||
import { TImmutableDBKeys } from "./models";
|
import { TImmutableDBKeys } from "./models";
|
||||||
|
|
||||||
export const SapApproversSchema = z.object({
|
export const SecretApprovalPoliciesApproversSchema = z.object({
|
||||||
id: z.string().uuid(),
|
id: z.string().uuid(),
|
||||||
approverId: z.string().uuid(),
|
approverId: z.string().uuid(),
|
||||||
policyId: z.string().uuid(),
|
policyId: z.string().uuid(),
|
||||||
@@ -15,6 +15,6 @@ export const SapApproversSchema = z.object({
|
|||||||
updatedAt: z.date(),
|
updatedAt: z.date(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TSapApprovers = z.infer<typeof SapApproversSchema>;
|
export type TSecretApprovalPoliciesApprovers = z.infer<typeof SecretApprovalPoliciesApproversSchema>;
|
||||||
export type TSapApproversInsert = Omit<TSapApprovers, TImmutableDBKeys>;
|
export type TSecretApprovalPoliciesApproversInsert = Omit<TSecretApprovalPoliciesApprovers, TImmutableDBKeys>;
|
||||||
export type TSapApproversUpdate = Partial<Omit<TSapApprovers, TImmutableDBKeys>>;
|
export type TSecretApprovalPoliciesApproversUpdate = Partial<Omit<TSecretApprovalPoliciesApprovers, TImmutableDBKeys>>;
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Code generated by automation script, DO NOT EDIT.
|
||||||
|
// Automated by pulling database and generating zod schema
|
||||||
|
// To update. Just run npm run generate:schema
|
||||||
|
// Written by akhilmhdh.
|
||||||
|
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { TImmutableDBKeys } from "./models";
|
||||||
|
|
||||||
|
export const SecretApprovalRequestSecretTagsSchema = z.object({
|
||||||
|
id: z.string().uuid(),
|
||||||
|
secretId: z.string().uuid(),
|
||||||
|
tagId: z.string().uuid(),
|
||||||
|
createdAt: z.date(),
|
||||||
|
updatedAt: z.date(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type TSecretApprovalRequestSecretTags = z.infer<typeof SecretApprovalRequestSecretTagsSchema>;
|
||||||
|
export type TSecretApprovalRequestSecretTagsInsert = Omit<TSecretApprovalRequestSecretTags, TImmutableDBKeys>;
|
||||||
|
export type TSecretApprovalRequestSecretTagsUpdate = Partial<Omit<TSecretApprovalRequestSecretTags, TImmutableDBKeys>>;
|
||||||
+4
-4
@@ -7,7 +7,7 @@ import { z } from "zod";
|
|||||||
|
|
||||||
import { TImmutableDBKeys } from "./models";
|
import { TImmutableDBKeys } from "./models";
|
||||||
|
|
||||||
export const SarReviewersSchema = z.object({
|
export const SecretApprovalRequestsReviewersSchema = z.object({
|
||||||
id: z.string().uuid(),
|
id: z.string().uuid(),
|
||||||
member: z.string().uuid(),
|
member: z.string().uuid(),
|
||||||
status: z.string(),
|
status: z.string(),
|
||||||
@@ -16,6 +16,6 @@ export const SarReviewersSchema = z.object({
|
|||||||
updatedAt: z.date(),
|
updatedAt: z.date(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TSarReviewers = z.infer<typeof SarReviewersSchema>;
|
export type TSecretApprovalRequestsReviewers = z.infer<typeof SecretApprovalRequestsReviewersSchema>;
|
||||||
export type TSarReviewersInsert = Omit<TSarReviewers, TImmutableDBKeys>;
|
export type TSecretApprovalRequestsReviewersInsert = Omit<TSecretApprovalRequestsReviewers, TImmutableDBKeys>;
|
||||||
export type TSarReviewersUpdate = Partial<Omit<TSarReviewers, TImmutableDBKeys>>;
|
export type TSecretApprovalRequestsReviewersUpdate = Partial<Omit<TSecretApprovalRequestsReviewers, TImmutableDBKeys>>;
|
||||||
+4
-4
@@ -7,7 +7,7 @@ import { z } from "zod";
|
|||||||
|
|
||||||
import { TImmutableDBKeys } from "./models";
|
import { TImmutableDBKeys } from "./models";
|
||||||
|
|
||||||
export const SaRequestSecretsSchema = z.object({
|
export const SecretApprovalRequestsSecretsSchema = z.object({
|
||||||
id: z.string().uuid(),
|
id: z.string().uuid(),
|
||||||
version: z.number().default(1).nullable().optional(),
|
version: z.number().default(1).nullable().optional(),
|
||||||
secretBlindIndex: z.string(),
|
secretBlindIndex: z.string(),
|
||||||
@@ -34,6 +34,6 @@ export const SaRequestSecretsSchema = z.object({
|
|||||||
secretVersion: z.string().uuid().nullable().optional(),
|
secretVersion: z.string().uuid().nullable().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TSaRequestSecrets = z.infer<typeof SaRequestSecretsSchema>;
|
export type TSecretApprovalRequestsSecrets = z.infer<typeof SecretApprovalRequestsSecretsSchema>;
|
||||||
export type TSaRequestSecretsInsert = Omit<TSaRequestSecrets, TImmutableDBKeys>;
|
export type TSecretApprovalRequestsSecretsInsert = Omit<TSecretApprovalRequestsSecrets, TImmutableDBKeys>;
|
||||||
export type TSaRequestSecretsUpdate = Partial<Omit<TSaRequestSecrets, TImmutableDBKeys>>;
|
export type TSecretApprovalRequestsSecretsUpdate = Partial<Omit<TSecretApprovalRequestsSecrets, TImmutableDBKeys>>;
|
||||||
Reference in New Issue
Block a user