@12-apps/prisma 6.0.0 → 6.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@12-apps/prisma",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "Prisma host: the multi-file schema folder, the plugin migration seam, and the shared PrismaClient singleton with its audit / append-only extensions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  }
13
13
  },
14
14
  "scripts": {
15
- "build": "node scripts/sync-lifecycle-schema.mjs && node scripts/sync-research-schema.mjs && node scripts/sync-shift-schema.mjs --check && node scripts/sync-jobs-schema.mjs --check && node scripts/sync-entitlements-schema.mjs --check && node scripts/sync-payments-schema.mjs --check && node scripts/sync-report-builder-schema.mjs --check && node scripts/sync-rbac-schema.mjs --check && node scripts/sync-notifications-schema.mjs --check && node scripts/sync-onboarding-schema.mjs --check && node scripts/sync-mcp-schema.mjs --check && node scripts/sync-realtime-schema.mjs --check && node scripts/sync-audit-schema.mjs --check && node scripts/sync-prisma-plugins.mjs --check && prisma generate && tsc",
15
+ "build": "node scripts/sync-lifecycle-schema.mjs && node scripts/sync-research-schema.mjs && node scripts/sync-shift-schema.mjs --check && node scripts/sync-jobs-schema.mjs --check && node scripts/sync-entitlements-schema.mjs --check && node scripts/sync-payments-schema.mjs --check && node scripts/sync-report-builder-schema.mjs --check && node scripts/sync-feature-flags-schema.mjs --check && node scripts/sync-rbac-schema.mjs --check && node scripts/sync-notifications-schema.mjs --check && node scripts/sync-onboarding-schema.mjs --check && node scripts/sync-mcp-schema.mjs --check && node scripts/sync-realtime-schema.mjs --check && node scripts/sync-audit-schema.mjs --check && node scripts/sync-prisma-plugins.mjs --check && prisma generate && tsc",
16
16
  "clean": "rm -rf dist node_modules coverage",
17
17
  "test": "node ../../scripts/vitest-with-teardown.mjs run",
18
18
  "test:watch": "vitest watch",
@@ -20,7 +20,7 @@
20
20
  "lint": "pnpm run lint:files .",
21
21
  "lint:fix": "bash -c 'eslint \"${@:-.}\" --max-warnings 0 --fix' _",
22
22
  "typecheck": "tsc --noEmit",
23
- "prisma:generate": "node scripts/sync-lifecycle-schema.mjs && node scripts/sync-research-schema.mjs && node scripts/sync-shift-schema.mjs --check && node scripts/sync-jobs-schema.mjs --check && node scripts/sync-entitlements-schema.mjs --check && node scripts/sync-payments-schema.mjs --check && node scripts/sync-auth-schema.mjs --check && node scripts/sync-report-builder-schema.mjs --check && node scripts/sync-rbac-schema.mjs --check && node scripts/sync-notifications-schema.mjs --check && node scripts/sync-onboarding-schema.mjs --check && node scripts/sync-mcp-schema.mjs --check && node scripts/sync-realtime-schema.mjs --check && node scripts/sync-audit-schema.mjs --check && node scripts/sync-prisma-plugins.mjs --check && prisma generate",
23
+ "prisma:generate": "node scripts/sync-lifecycle-schema.mjs && node scripts/sync-research-schema.mjs && node scripts/sync-shift-schema.mjs --check && node scripts/sync-jobs-schema.mjs --check && node scripts/sync-entitlements-schema.mjs --check && node scripts/sync-payments-schema.mjs --check && node scripts/sync-auth-schema.mjs --check && node scripts/sync-report-builder-schema.mjs --check && node scripts/sync-feature-flags-schema.mjs --check && node scripts/sync-rbac-schema.mjs --check && node scripts/sync-notifications-schema.mjs --check && node scripts/sync-onboarding-schema.mjs --check && node scripts/sync-mcp-schema.mjs --check && node scripts/sync-realtime-schema.mjs --check && node scripts/sync-audit-schema.mjs --check && node scripts/sync-prisma-plugins.mjs --check && prisma generate",
24
24
  "prisma:migrate": "prisma migrate dev",
25
25
  "prisma:push": "prisma db push",
26
26
  "prisma:studio": "prisma studio",
@@ -36,6 +36,8 @@
36
36
  "prisma:sync-payments:check": "node scripts/sync-payments-schema.mjs --check",
37
37
  "prisma:sync-report-builder": "node scripts/sync-report-builder-schema.mjs",
38
38
  "prisma:sync-report-builder:check": "node scripts/sync-report-builder-schema.mjs --check",
39
+ "prisma:sync-feature-flags": "node scripts/sync-feature-flags-schema.mjs",
40
+ "prisma:sync-feature-flags:check": "node scripts/sync-feature-flags-schema.mjs --check",
39
41
  "prisma:sync-plugins": "node scripts/sync-prisma-plugins.mjs",
40
42
  "prisma:sync-plugins:check": "node scripts/sync-prisma-plugins.mjs --check",
41
43
  "prisma:sync-rbac": "node scripts/sync-rbac-schema.mjs",
@@ -62,19 +64,20 @@
62
64
  },
63
65
  "devDependencies": {
64
66
  "@12-apps/audit": "^5.0.1",
65
- "@12-apps/auth": "^2.0.0",
67
+ "@12-apps/auth": "^2.1.0",
66
68
  "@12-apps/entitlements": "^3.1.0",
67
69
  "@12-apps/entity-lifecycle": "^4.2.0",
68
70
  "@12-apps/eslint-config": "^1.20.0",
71
+ "@12-apps/feature-flags": "^1.0.0",
69
72
  "@12-apps/jobs": "^4.2.0",
70
73
  "@12-apps/mcp": "^3.4.0",
71
74
  "@12-apps/notifications": "^4.1.1",
72
75
  "@12-apps/onboarding": "^2.0.1",
73
- "@12-apps/payments-backend": "^4.11.0",
76
+ "@12-apps/payments-backend": "^4.13.0",
74
77
  "@12-apps/product-research": "^2.0.0",
75
- "@12-apps/rbac": "^4.0.2",
78
+ "@12-apps/rbac": "^4.0.3",
76
79
  "@12-apps/realtime": "^2.0.0",
77
- "@12-apps/report-builder": "^5.0.2",
80
+ "@12-apps/report-builder": "^5.2.0",
78
81
  "@12-apps/shift": "^3.0.1",
79
82
  "@12-apps/typescript-config": "^1.20.0",
80
83
  "@types/node": "^22.10.6",
@@ -0,0 +1,19 @@
1
+ -- CreateTable
2
+ CREATE TABLE "user_feature_grants" (
3
+ "id" TEXT NOT NULL,
4
+ "user_id" TEXT NOT NULL,
5
+ "flag_key" TEXT NOT NULL,
6
+ "enabled" BOOLEAN NOT NULL DEFAULT true,
7
+ "granted_by" TEXT NOT NULL,
8
+ "note" TEXT,
9
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
10
+ "updated_at" TIMESTAMP(3) NOT NULL,
11
+
12
+ CONSTRAINT "user_feature_grants_pkey" PRIMARY KEY ("id")
13
+ );
14
+
15
+ -- CreateIndex
16
+ CREATE UNIQUE INDEX "user_feature_grants_user_id_flag_key_key" ON "user_feature_grants"("user_id", "flag_key");
17
+
18
+ -- CreateIndex
19
+ CREATE INDEX "user_feature_grants_flag_key_idx" ON "user_feature_grants"("flag_key");
@@ -32,6 +32,7 @@
32
32
  "20260813120000_add_entity_lifecycle_tables",
33
33
  "20260813140000_add_notification_tables",
34
34
  "20260813180000_add_realtime_outbox",
35
- "20260819230000_auth_email_password"
35
+ "20260819230000_auth_email_password",
36
+ "20260820120000_add_user_feature_grants"
36
37
  ]
37
38
  }
@@ -0,0 +1,37 @@
1
+ // ─────────────────────────────────────────────────────────────────────────────
2
+ // OWNED BY @12-apps/feature-flags — the host's multi-file schema folder holds
3
+ // only a COPY of this file (created/verified by `pnpm --filter
4
+ // @12-apps/feature-flags prisma:sync`): the user-level flag grants live here,
5
+ // in the package, never in the application.
6
+ //
7
+ // Deliberately self-contained (the payments-backend doctrine): `user_id` is a
8
+ // by-value String column — NO foreign key into any host table — so the model
9
+ // works in every repo without schema coupling. The host may add its own FK in
10
+ // a host migration if it wants the cascade.
11
+ // ─────────────────────────────────────────────────────────────────────────────
12
+
13
+ // One user-level flag grant (FUT-884). NO row means the flag's default (off —
14
+ // a beta fails CLOSED); a row with `enabled: false` is an EXPLICIT opt-out
15
+ // that survives a future default-on rollout. The flag CATALOG is host code on
16
+ // purpose — a flag with no code behind it does nothing, so a new flag ships
17
+ // with a deploy anyway, and a grant whose key left the catalog is an orphan
18
+ // the management surface reports. `granted_by` is the granting superadmin's
19
+ // email, kept as an opaque scalar (a platform admin may have no users row).
20
+ // USER-GLOBAL by design: the grant follows the person, and staying a VEIL
21
+ // (ANDed over the tenant axes — plan, lifecycle, tenant settings, RBAC) is
22
+ // exactly what makes that safe — in a store whose tenant axes deny the
23
+ // feature, the grant lights nothing.
24
+ model UserFeatureGrant {
25
+ id String @id @default(uuid())
26
+ userId String @map("user_id")
27
+ flagKey String @map("flag_key")
28
+ enabled Boolean @default(true)
29
+ grantedBy String @map("granted_by")
30
+ note String?
31
+ createdAt DateTime @default(now()) @map("created_at")
32
+ updatedAt DateTime @updatedAt @map("updated_at")
33
+
34
+ @@unique([userId, flagKey])
35
+ @@index([flagKey])
36
+ @@map("user_feature_grants")
37
+ }