clhq-postgres-module 1.1.0-alpha.171 → 1.1.0-alpha.172

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const typeorm_1 = require("typeorm");
4
- const user_entity_1 = require("../entities/user.entity");
5
- const workspace_entity_1 = require("../entities/workspace.entity");
6
- const editor_project_entity_1 = require("../entities/editor-project.entity");
7
- const user_subscription_entity_1 = require("../entities/user-subscription.entity");
4
+ const path_1 = require("path");
8
5
  const connectionUrl = process.env.PG_SESSION_POOLER_URL || process.env.PG_POOLER_URL;
9
6
  let dataSource;
10
7
  if (connectionUrl) {
@@ -13,8 +10,8 @@ if (connectionUrl) {
13
10
  url: connectionUrl,
14
11
  synchronize: false,
15
12
  logging: process.env.NODE_ENV === 'development',
16
- entities: [user_entity_1.User, workspace_entity_1.Workspace, editor_project_entity_1.EditorProject, user_subscription_entity_1.UserSubscription],
17
- migrations: [],
13
+ entities: [(0, path_1.join)(__dirname, '/../entities/*.entity{.ts,.js}')],
14
+ migrations: [(0, path_1.join)(__dirname, '/../migrations/*{.ts,.js}')],
18
15
  ssl: { rejectUnauthorized: false },
19
16
  extra: {
20
17
  max: 20,
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class Baseline1713000000000 implements MigrationInterface {
3
+ name: string;
4
+ up(_queryRunner: QueryRunner): Promise<void>;
5
+ down(_queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Baseline1713000000000 = void 0;
4
+ class Baseline1713000000000 {
5
+ constructor() {
6
+ this.name = 'Baseline1713000000000';
7
+ }
8
+ async up(_queryRunner) {
9
+ }
10
+ async down(_queryRunner) {
11
+ }
12
+ }
13
+ exports.Baseline1713000000000 = Baseline1713000000000;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class CreateSocialConnectionTables1713000000001 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateSocialConnectionTables1713000000001 = void 0;
4
+ class CreateSocialConnectionTables1713000000001 {
5
+ constructor() {
6
+ this.name = 'CreateSocialConnectionTables1713000000001';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ CREATE TABLE IF NOT EXISTS social_accounts (
11
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
12
+ workspace_id UUID NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
13
+ connected_by_user_id UUID NOT NULL,
14
+ platform VARCHAR(50) NOT NULL,
15
+ auth_method VARCHAR(20) NOT NULL,
16
+ platform_account_id VARCHAR(255) NOT NULL,
17
+ platform_account_name VARCHAR(255),
18
+ platform_profile_url TEXT,
19
+ platform_avatar_url TEXT,
20
+ encrypted_access_token TEXT,
21
+ encrypted_refresh_token TEXT,
22
+ encrypted_api_key TEXT,
23
+ token_expires_at TIMESTAMP WITH TIME ZONE,
24
+ platform_metadata JSONB,
25
+ status VARCHAR(20) NOT NULL DEFAULT 'active',
26
+ last_error TEXT,
27
+ last_synced_at TIMESTAMP WITH TIME ZONE,
28
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
29
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
30
+ )
31
+ `);
32
+ await queryRunner.query(`
33
+ CREATE INDEX IF NOT EXISTS idx_social_accounts_workspace_id
34
+ ON social_accounts(workspace_id)
35
+ `);
36
+ await queryRunner.query(`
37
+ CREATE INDEX IF NOT EXISTS idx_social_accounts_workspace_platform
38
+ ON social_accounts(workspace_id, platform)
39
+ `);
40
+ await queryRunner.query(`
41
+ CREATE TABLE IF NOT EXISTS platform_configs (
42
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
43
+ workspace_id UUID NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
44
+ platform VARCHAR(50) NOT NULL,
45
+ encrypted_client_id TEXT,
46
+ encrypted_client_secret TEXT,
47
+ encrypted_api_key TEXT,
48
+ redirect_uri TEXT,
49
+ scopes JSONB,
50
+ is_active BOOLEAN NOT NULL DEFAULT TRUE,
51
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
52
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
53
+ CONSTRAINT uq_platform_configs_workspace_platform UNIQUE (workspace_id, platform)
54
+ )
55
+ `);
56
+ await queryRunner.query(`
57
+ CREATE INDEX IF NOT EXISTS idx_platform_configs_workspace_id
58
+ ON platform_configs(workspace_id)
59
+ `);
60
+ await queryRunner.query(`ALTER TABLE social_accounts ENABLE ROW LEVEL SECURITY`);
61
+ await queryRunner.query(`ALTER TABLE platform_configs ENABLE ROW LEVEL SECURITY`);
62
+ }
63
+ async down(queryRunner) {
64
+ await queryRunner.query(`DROP TABLE IF EXISTS platform_configs`);
65
+ await queryRunner.query(`DROP TABLE IF EXISTS social_accounts`);
66
+ }
67
+ }
68
+ exports.CreateSocialConnectionTables1713000000001 = CreateSocialConnectionTables1713000000001;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddIsActiveToWorkspaceMembers1713000000002 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddIsActiveToWorkspaceMembers1713000000002 = void 0;
4
+ class AddIsActiveToWorkspaceMembers1713000000002 {
5
+ constructor() {
6
+ this.name = 'AddIsActiveToWorkspaceMembers1713000000002';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ ALTER TABLE workspace_members
11
+ ADD COLUMN IF NOT EXISTS is_active BOOLEAN NOT NULL DEFAULT TRUE
12
+ `);
13
+ await queryRunner.query(`
14
+ UPDATE workspace_members
15
+ SET is_active = (status = 'active')
16
+ WHERE is_active IS DISTINCT FROM (status = 'active')
17
+ `);
18
+ await queryRunner.query(`
19
+ CREATE INDEX IF NOT EXISTS idx_workspace_members_is_active
20
+ ON workspace_members(is_active)
21
+ `);
22
+ await queryRunner.query(`
23
+ COMMENT ON COLUMN workspace_members.is_active
24
+ IS 'Whether this membership is active (derived from status for backwards compat)'
25
+ `);
26
+ }
27
+ async down(queryRunner) {
28
+ await queryRunner.query(`
29
+ DROP INDEX IF EXISTS idx_workspace_members_is_active
30
+ `);
31
+ await queryRunner.query(`
32
+ ALTER TABLE workspace_members DROP COLUMN IF EXISTS is_active
33
+ `);
34
+ }
35
+ }
36
+ exports.AddIsActiveToWorkspaceMembers1713000000002 = AddIsActiveToWorkspaceMembers1713000000002;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddDescriptionToBrandKits1713000000003 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddDescriptionToBrandKits1713000000003 = void 0;
4
+ class AddDescriptionToBrandKits1713000000003 {
5
+ constructor() {
6
+ this.name = 'AddDescriptionToBrandKits1713000000003';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ ALTER TABLE brand_kits
11
+ ADD COLUMN IF NOT EXISTS description TEXT
12
+ `);
13
+ }
14
+ async down(queryRunner) {
15
+ await queryRunner.query(`
16
+ ALTER TABLE brand_kits DROP COLUMN IF EXISTS description
17
+ `);
18
+ }
19
+ }
20
+ exports.AddDescriptionToBrandKits1713000000003 = AddDescriptionToBrandKits1713000000003;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clhq-postgres-module",
3
- "version": "1.1.0-alpha.171",
3
+ "version": "1.1.0-alpha.172",
4
4
  "description": "PostgreSQL module using TypeORM for Clippy",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,40 +22,18 @@
22
22
  "scripts": {
23
23
  "build": "tsc",
24
24
  "watch": "tsc --watch",
25
- "typeorm": "typeorm-ts-node-commonjs",
25
+ "typeorm": "env-cmd -f ../../.env.dev typeorm-ts-node-commonjs",
26
26
  "db:setup": "env-cmd -f ../../.env.dev npx ts-node scripts/setup-database.ts",
27
- "db:migrate": "npx ts-node scripts/run-migrations.ts --all",
28
- "db:migrate:002": "npx ts-node scripts/run-migrations.ts 002",
29
- "db:migrate:003": "npx ts-node scripts/run-migrations.ts 003",
30
- "db:migrate:004": "npx ts-node scripts/run-migrations.ts 004",
31
- "db:migrate:008": "npx ts-node scripts/run-migrations.ts 008",
32
- "db:migrate:009": "npx ts-node scripts/run-migrations.ts 009",
33
- "db:migrate:011": "npx ts-node scripts/run-migrations.ts 011",
34
- "db:migrate:012": "npx ts-node scripts/run-migrations.ts 012",
35
- "db:migrate:013": "npx ts-node scripts/run-migrations.ts 013",
36
- "db:migrate:014": "npx ts-node scripts/run-migrations.ts 014",
37
- "db:migrate:015": "npx ts-node scripts/run-migrations.ts 015",
38
- "db:migrate:016": "npx ts-node scripts/run-migrations.ts 016",
39
- "db:migrate:017": "npx ts-node scripts/run-migrations.ts 017",
40
- "db:migrate:018": "npx ts-node scripts/run-migrations.ts 018",
41
- "db:migrate:019": "npx ts-node scripts/run-migrations.ts 019",
42
- "db:migrate:020": "npx ts-node scripts/run-migrations.ts 020",
43
- "db:migrate:metadata": "npx ts-node scripts/run-migrations.ts 019 && npx ts-node scripts/run-migrations.ts 020",
44
- "db:migrate:031": "npx ts-node scripts/run-migrations.ts 031",
45
- "db:migrate:webp": "npx ts-node scripts/run-migrations.ts 031",
46
- "db:migrate:032": "npx ts-node scripts/run-migrations.ts 032",
47
- "db:migrate:scenes-format": "npx ts-node scripts/run-migrations.ts 032",
48
- "db:migrate:033": "npx ts-node scripts/run-migrations.ts 033",
49
- "db:migrate:fix-scenes-constraint": "npx ts-node scripts/run-migrations.ts 033",
50
- "db:migrate:035": "npx ts-node scripts/run-migrations.ts 035",
51
- "db:migrate:remotion-credits": "npx ts-node scripts/run-migrations.ts 035",
52
- "db:migrate:036": "npx ts-node scripts/run-migrations.ts 036",
53
- "db:migrate:037": "npx ts-node scripts/run-migrations.ts 037",
54
- "db:migrate:rls": "npx ts-node scripts/run-migrations.ts 037",
55
- "db:verify": "env-cmd -f ../../.env.dev npx ts-node scripts/verify-tables.ts",
56
- "db:test": "env-cmd -f ../../.env.dev npx ts-node scripts/test-connections.ts",
57
- "db:sync": "env-cmd -f ../../.env.dev npm run typeorm schema:sync -- -d src/config/data-source.ts",
58
- "db:drop": "env-cmd -f ../../.env.dev npm run typeorm schema:drop -- -d src/config/data-source.ts"
27
+ "db:migrate": "npm run typeorm migration:run -- -d src/config/data-source.ts",
28
+ "db:migrate:revert": "npm run typeorm migration:revert -- -d src/config/data-source.ts",
29
+ "db:migrate:generate": "npm run typeorm migration:generate -- -d src/config/data-source.ts",
30
+ "db:migrate:create": "npm run typeorm migration:create",
31
+ "db:migrate:show": "npm run typeorm migration:show -- -d src/config/data-source.ts",
32
+ "db:migrate:legacy": "npx ts-node scripts/run-migrations.ts --all",
33
+ "db:verify": "env-cmd -f ../../.env.dev npx ts-node scripts/verify-tables.ts",
34
+ "db:test": "env-cmd -f ../../.env.dev npx ts-node scripts/test-connections.ts",
35
+ "db:sync": "env-cmd -f ../../.env.dev npm run typeorm schema:sync -- -d src/config/data-source.ts",
36
+ "db:drop": "env-cmd -f ../../.env.dev npm run typeorm schema:drop -- -d src/config/data-source.ts"
59
37
  },
60
38
  "dependencies": {
61
39
  "@nestjs/common": "11.1.9",