Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+6
-6
@@ -76,15 +76,15 @@ describe("anonymize", () => {
|
||||
expect(row.fromUrl).toMatch(/^https:\/\/anonymized\.test\//u);
|
||||
});
|
||||
|
||||
it("rewrites Stripe customer/subscription ids with anon prefix", () => {
|
||||
it("rewrites billing customer/subscription ids with anon prefix", () => {
|
||||
const row = anonymizeRow(
|
||||
FULL_ANONYMIZED_PROFILE,
|
||||
"TenantSubscription",
|
||||
{ stripeCustomerId: "cus_real", stripeSubscriptionId: "sub_real" },
|
||||
{ billingProviderCustomerId: "cus_real", billingProviderSubscriptionId: "sub_real" },
|
||||
ctx,
|
||||
);
|
||||
expect(row.stripeCustomerId).toMatch(/^cus_anon[0-9a-f]{8}$/u);
|
||||
expect(row.stripeSubscriptionId).toMatch(/^sub_anon[0-9a-f]{8}$/u);
|
||||
expect(row.billingProviderCustomerId).toMatch(/^cus_anon[0-9a-f]{8}$/u);
|
||||
expect(row.billingProviderSubscriptionId).toMatch(/^sub_anon[0-9a-f]{8}$/u);
|
||||
});
|
||||
|
||||
it("redacts secrets to [REDACTED]", () => {
|
||||
@@ -102,7 +102,7 @@ describe("anonymize", () => {
|
||||
const row = anonymizeRow(
|
||||
FULL_ANONYMIZED_PROFILE,
|
||||
"TenantSubscription",
|
||||
{ stripeCustomerId: "cus_real", planTier: "pro", active: true },
|
||||
{ billingProviderCustomerId: "cus_real", planTier: "pro", active: true },
|
||||
ctx,
|
||||
);
|
||||
expect(row.planTier).toBe("pro");
|
||||
@@ -156,7 +156,7 @@ describe("anonymize", () => {
|
||||
|
||||
describe("none profile", () => {
|
||||
it("passes everything through unchanged", () => {
|
||||
const original = { email: "alice@example.com", stripeCustomerId: "cus_real" };
|
||||
const original = { email: "alice@example.com", billingProviderCustomerId: "cus_real" };
|
||||
const row = anonymizeRow(NONE_PROFILE, "TenantSubscription", original, {
|
||||
...ctx,
|
||||
profileName: "none",
|
||||
|
||||
+12
-12
@@ -30,10 +30,10 @@ export type FieldStrategy =
|
||||
| "address-country"
|
||||
| "zip-code"
|
||||
| "ip-address"
|
||||
| "stripe-customer-id"
|
||||
| "stripe-subscription-id"
|
||||
| "stripe-payment-method-id"
|
||||
| "stripe-id-generic"
|
||||
| "billing-customer-id"
|
||||
| "billing-subscription-id"
|
||||
| "payment-method-id"
|
||||
| "payment-id-generic"
|
||||
| "url-rewrite"
|
||||
| "avatar-url"
|
||||
| "redact"
|
||||
@@ -122,14 +122,14 @@ export const FULL_ANONYMIZED_PROFILE: AnonymizationProfile = {
|
||||
textBody: "redact",
|
||||
},
|
||||
TenantSubscription: {
|
||||
stripeCustomerId: "stripe-customer-id",
|
||||
stripeSubscriptionId: "stripe-subscription-id",
|
||||
billingProviderCustomerId: "billing-customer-id",
|
||||
billingProviderSubscriptionId: "billing-subscription-id",
|
||||
},
|
||||
TenantProductConfiguration: {
|
||||
stripeAccountId: "stripe-id-generic",
|
||||
paymentProviderAccountId: "payment-id-generic",
|
||||
},
|
||||
Credit: {
|
||||
stripeInvoiceId: "stripe-id-generic",
|
||||
providerInvoiceId: "payment-id-generic",
|
||||
},
|
||||
WorkflowCredential: {
|
||||
secret: "redact",
|
||||
@@ -345,13 +345,13 @@ export function applyStrategy(
|
||||
return anonZip(value, ctx);
|
||||
case "ip-address":
|
||||
return anonIp(value, ctx);
|
||||
case "stripe-customer-id":
|
||||
case "billing-customer-id":
|
||||
return `cus_anon${seededHex(value, ctx, 8)}`;
|
||||
case "stripe-subscription-id":
|
||||
case "billing-subscription-id":
|
||||
return `sub_anon${seededHex(value, ctx, 8)}`;
|
||||
case "stripe-payment-method-id":
|
||||
case "payment-method-id":
|
||||
return `pm_anon${seededHex(value, ctx, 8)}`;
|
||||
case "stripe-id-generic":
|
||||
case "payment-id-generic":
|
||||
return `anon_${seededHex(value, ctx, 12)}`;
|
||||
case "url-rewrite":
|
||||
return `https://anonymized.test/${seededHex(value, ctx, 10)}`;
|
||||
|
||||
+2
-2
@@ -35,10 +35,10 @@ describe("resolveTenantSnapshotConfig", () => {
|
||||
|
||||
it("threads STORAGE_BUCKET and optional prefix through", () => {
|
||||
const cfg = resolveTenantSnapshotConfig({
|
||||
STORAGE_BUCKET: "boilerplate-files",
|
||||
STORAGE_BUCKET: "hivegrid-files",
|
||||
TENANT_SNAPSHOT_STORAGE_PREFIX: "tenants/abc/",
|
||||
});
|
||||
expect(cfg.appStorageBucket).toBe("boilerplate-files");
|
||||
expect(cfg.appStorageBucket).toBe("hivegrid-files");
|
||||
expect(cfg.storagePrefix).toBe("tenants/abc/");
|
||||
});
|
||||
|
||||
|
||||
+4
-1
@@ -48,11 +48,14 @@ describe("collectAndWriteGlobals", () => {
|
||||
ctx: { salt: "deadbeef", profileName: "full-anonymized" },
|
||||
});
|
||||
|
||||
expect(result.entries).toHaveLength(1); // just User today
|
||||
expect(result.entries).toHaveLength(2); // User + McpOAuthClient today
|
||||
const userEntry = result.entries.find((e) => e.model === "User");
|
||||
expect(userEntry).toBeDefined();
|
||||
expect(userEntry?.rowCount).toBe(0);
|
||||
expect(userEntry?.path).toBe("globals/User.jsonl");
|
||||
const clientEntry = result.entries.find((e) => e.model === "McpOAuthClient");
|
||||
expect(clientEntry).toBeDefined();
|
||||
expect(clientEntry?.rowCount).toBe(0);
|
||||
expect(calls).toHaveLength(0);
|
||||
const userFile = await readFile(join(globalsDir, "User.jsonl"), "utf8");
|
||||
expect(userFile).toBe("");
|
||||
|
||||
+3
-3
@@ -65,13 +65,13 @@ describe("parseSchemaScalarTypes", () => {
|
||||
expect(collab?.fields.get("ydocState")).toBe("Bytes");
|
||||
});
|
||||
|
||||
it("captures RowValue.numberValue as Decimal (nullable + non-tenant-scoped)", () => {
|
||||
it("captures IpAddress.latitude as Decimal (nullable + non-tenant-scoped)", () => {
|
||||
// Use a Decimal field that actually exists in the schema. Decimal
|
||||
// columns are rare in tenant-scoped models today — the codec must
|
||||
// still parse them so non-tenant-scoped models referenced indirectly
|
||||
// (or future schema growth) decode correctly.
|
||||
const rowValue = map.get("RowValue");
|
||||
expect(rowValue?.fields.get("numberValue")).toBe("Decimal");
|
||||
const ipAddress = map.get("IpAddress");
|
||||
expect(ipAddress?.fields.get("latitude")).toBe("Decimal");
|
||||
});
|
||||
|
||||
it("captures TenantUser.createdAt as DateTime", () => {
|
||||
|
||||
+234
-24
@@ -43,18 +43,16 @@ export const TENANT_SCOPED_MODELS: readonly TenantScopedModel[] = [
|
||||
{ model: "MetricLog", tenantField: "tenantId", schema: "core.prisma" },
|
||||
{ model: "Widget", tenantField: "tenantId", schema: "core.prisma" },
|
||||
|
||||
// entityBuilder.prisma
|
||||
{ model: "Property", tenantField: "tenantId", schema: "entityBuilder.prisma" },
|
||||
{ model: "EntityTemplate", tenantField: "tenantId", schema: "entityBuilder.prisma" },
|
||||
{ model: "EntityView", tenantField: "tenantId", schema: "entityBuilder.prisma" },
|
||||
{ model: "EntityGroupConfiguration", tenantField: "tenantId", schema: "entityBuilder.prisma" },
|
||||
{ model: "Row", tenantField: "tenantId", schema: "entityBuilder.prisma" },
|
||||
{ model: "RowPermission", tenantField: "tenantId", schema: "entityBuilder.prisma" },
|
||||
{ model: "TenantSettingsRow", tenantField: "tenantId", schema: "entityBuilder.prisma" },
|
||||
{ model: "FormulaLog", tenantField: "tenantId", schema: "entityBuilder.prisma" },
|
||||
// publicApi.prisma (VR-P22b) — incoming endpoint before ingestion logs,
|
||||
// outgoing subscription before delivery logs (FK subscriptionId, Cascade).
|
||||
{ model: "PublicIncomingWebhookEndpoint", tenantField: "tenantId", schema: "publicApi.prisma" },
|
||||
{ model: "PublicWebhookIngestionLog", tenantField: "tenantId", schema: "publicApi.prisma" },
|
||||
{ model: "PublicWebhookSubscription", tenantField: "tenantId", schema: "publicApi.prisma" },
|
||||
{ model: "PublicWebhookDeliveryLog", tenantField: "tenantId", schema: "publicApi.prisma" },
|
||||
|
||||
// subscriptions.prisma
|
||||
{ model: "TenantSubscription", tenantField: "tenantId", schema: "subscriptions.prisma" },
|
||||
{ model: "TenantSubscriptionUsageRecord", tenantField: "tenantId", schema: "subscriptions.prisma" },
|
||||
{ model: "TenantFeatureOverride", tenantField: "tenantId", schema: "subscriptions.prisma" },
|
||||
{ model: "TenantProductConfiguration", tenantField: "tenantId", schema: "subscriptions.prisma" },
|
||||
{ model: "Credit", tenantField: "tenantId", schema: "subscriptions.prisma" },
|
||||
@@ -64,6 +62,20 @@ export const TENANT_SCOPED_MODELS: readonly TenantScopedModel[] = [
|
||||
{ model: "TenantInboundAddress", tenantField: "tenantId", schema: "email.prisma" },
|
||||
{ model: "Campaign", tenantField: "tenantId", schema: "email.prisma" },
|
||||
{ model: "OutboundEmail", tenantField: "tenantId", schema: "email.prisma" },
|
||||
// AK-P14a — email foundation (sending domain, suppression, templates).
|
||||
{ model: "TenantSendingDomain", tenantField: "tenantId", schema: "email.prisma" },
|
||||
{ model: "EmailSuppressionList", tenantField: "tenantId", schema: "email.prisma" },
|
||||
{ model: "EmailTemplate", tenantField: "tenantId", schema: "email.prisma" },
|
||||
// AK-P14b — email marketing (segments, A/B variants, consent, unsubscribe).
|
||||
// Ordering: RecipientSegment before SegmentSnapshotMember (FK segmentId,
|
||||
// Cascade); CampaignVariant references Campaign (listed above). kontaktId /
|
||||
// campaignId on Consent/Unsubscribe are BARE scalars (no @relation), so they
|
||||
// are NOT collected as globals.
|
||||
{ model: "RecipientSegment", tenantField: "tenantId", schema: "email.prisma" },
|
||||
{ model: "SegmentSnapshotMember", tenantField: "tenantId", schema: "email.prisma" },
|
||||
{ model: "CampaignVariant", tenantField: "tenantId", schema: "email.prisma" },
|
||||
{ model: "KontaktMarketingConsent", tenantField: "tenantId", schema: "email.prisma" },
|
||||
{ model: "Unsubscribe", tenantField: "tenantId", schema: "email.prisma" },
|
||||
|
||||
// workflows.prisma
|
||||
{ model: "Workflow", tenantField: "tenantId", schema: "workflows.prisma" },
|
||||
@@ -71,10 +83,23 @@ export const TENANT_SCOPED_MODELS: readonly TenantScopedModel[] = [
|
||||
{ model: "WorkflowVariable", tenantField: "tenantId", schema: "workflows.prisma" },
|
||||
{ model: "WorkflowCredential", tenantField: "tenantId", schema: "workflows.prisma" },
|
||||
|
||||
// appsEngine.prisma
|
||||
{ model: "App", tenantField: "tenantId", schema: "appsEngine.prisma" },
|
||||
{ model: "AppSyncRun", tenantField: "tenantId", schema: "appsEngine.prisma" },
|
||||
// automation.prisma (R-P12a: typed automation engine foundation)
|
||||
{ model: "AutomationRule", tenantField: "tenantId", schema: "automation.prisma" },
|
||||
{ model: "AutomationRuleStep", tenantField: "tenantId", schema: "automation.prisma" },
|
||||
{ model: "AutomationExecution", tenantField: "tenantId", schema: "automation.prisma" },
|
||||
{ model: "AutomationStepExecution", tenantField: "tenantId", schema: "automation.prisma" },
|
||||
{ model: "AutomationCredential", tenantField: "tenantId", schema: "automation.prisma" },
|
||||
{ model: "AutomationTemplate", tenantField: "tenantId", schema: "automation.prisma" },
|
||||
{ model: "AutomationTriggerMeter", tenantField: "tenantId", schema: "automation.prisma" },
|
||||
|
||||
// appsEngine.prisma (R-P5: App is GLOBAL/no-tenant; tenant-scoped rows below)
|
||||
{ model: "DataConnection", tenantField: "tenantId", schema: "appsEngine.prisma" },
|
||||
{ model: "AppSyncRun", tenantField: "tenantId", schema: "appsEngine.prisma" },
|
||||
{ model: "AppSyncRunLog", tenantField: "tenantId", schema: "appsEngine.prisma" },
|
||||
{ model: "AppSyncItem", tenantField: "tenantId", schema: "appsEngine.prisma" },
|
||||
|
||||
// crypto.prisma (R-P5 Phase 1)
|
||||
{ model: "TenantEncryptionKey", tenantField: "tenantId", schema: "crypto.prisma" },
|
||||
|
||||
// featureFlags.prisma
|
||||
{ model: "FeatureFlag", tenantField: "tenantId", schema: "featureFlags.prisma" },
|
||||
@@ -89,6 +114,12 @@ export const TENANT_SCOPED_MODELS: readonly TenantScopedModel[] = [
|
||||
// queue.prisma
|
||||
{ model: "ExportJob", tenantField: "tenantId", schema: "queue.prisma" },
|
||||
|
||||
// gdpr.prisma (AK-P21) — privacy exports, tenant deletion requests and AVV
|
||||
// acceptance history. Subprocessor is a global catalog, not tenant-scoped.
|
||||
{ model: "GdprExportJob", tenantField: "tenantId", schema: "gdpr.prisma" },
|
||||
{ model: "TenantDeletionRequest", tenantField: "tenantId", schema: "gdpr.prisma" },
|
||||
{ model: "AvvAcceptance", tenantField: "tenantId", schema: "gdpr.prisma" },
|
||||
|
||||
// knowledgeBase.prisma
|
||||
{ model: "KnowledgeBase", tenantField: "tenantId", schema: "knowledgeBase.prisma" },
|
||||
|
||||
@@ -98,6 +129,7 @@ export const TENANT_SCOPED_MODELS: readonly TenantScopedModel[] = [
|
||||
|
||||
// onboarding.prisma
|
||||
{ model: "OnboardingSession", tenantField: "tenantId", schema: "onboarding.prisma" },
|
||||
{ model: "OnboardingDemoProvisioning", tenantField: "tenantId", schema: "onboarding.prisma" },
|
||||
|
||||
// portals.prisma
|
||||
{ model: "Portal", tenantField: "tenantId", schema: "portals.prisma" },
|
||||
@@ -108,7 +140,11 @@ export const TENANT_SCOPED_MODELS: readonly TenantScopedModel[] = [
|
||||
|
||||
// formWidget.prisma (Phase 05 #58 — embeddable form widget)
|
||||
{ model: "Form", tenantField: "tenantId", schema: "formWidget.prisma" },
|
||||
{ model: "FormField", tenantField: "tenantId", schema: "formWidget.prisma" },
|
||||
{ model: "FormSubmission", tenantField: "tenantId", schema: "formWidget.prisma" },
|
||||
{ model: "FormFile", tenantField: "tenantId", schema: "formWidget.prisma" },
|
||||
{ model: "FormAction", tenantField: "tenantId", schema: "formWidget.prisma" },
|
||||
{ model: "FormActionLog", tenantField: "tenantId", schema: "formWidget.prisma" },
|
||||
|
||||
// outbox.prisma (tenantId is nullable — system-wide events use NULL)
|
||||
{ model: "OutboxEvent", tenantField: "tenantId", schema: "outbox.prisma" },
|
||||
@@ -134,6 +170,177 @@ export const TENANT_SCOPED_MODELS: readonly TenantScopedModel[] = [
|
||||
|
||||
// notifications.prisma — push tokens
|
||||
{ model: "DeviceToken", tenantField: "tenantId", schema: "notifications.prisma" },
|
||||
|
||||
// admin.prisma — operator note on a tenant (authorUserId → User global,
|
||||
// onDelete:SetNull; tenant Tenant relation = snapshot root).
|
||||
{ model: "AdminTenantNote", tenantField: "tenantId", schema: "admin.prisma" },
|
||||
|
||||
// files.prisma (P4 — AK-P4a). Direct `tenantId String` scalar. Ordering:
|
||||
// File before FileEntityLink (FK fileId, Cascade), FileUpload before
|
||||
// FileUploadChunk (FK uploadId, Cascade). createdByUserId/assignedToUserId
|
||||
// are intentionally BARE scalars (no DB-level FK), so they are NOT collected
|
||||
// as globals.
|
||||
{ model: "File", tenantField: "tenantId", schema: "files.prisma" },
|
||||
{ model: "FileEntityLink", tenantField: "tenantId", schema: "files.prisma" },
|
||||
{ model: "FileUpload", tenantField: "tenantId", schema: "files.prisma" },
|
||||
{ model: "FileUploadChunk", tenantField: "tenantId", schema: "files.prisma" },
|
||||
|
||||
// tasks.prisma (P4 — AK-P4b). Direct `tenantId String` scalar. Ordering:
|
||||
// Task before TaskWatcher (FK taskId, Cascade). createdByUserId/
|
||||
// assignedToUserId/assignedToGroupId are BARE scalars (no DB-level FK).
|
||||
{ model: "Task", tenantField: "tenantId", schema: "tasks.prisma" },
|
||||
{ model: "TaskWatcher", tenantField: "tenantId", schema: "tasks.prisma" },
|
||||
|
||||
// entityLinks.prisma (P4 — AK-P4b). Generic polymorphic link; all
|
||||
// references are bare scalars (no @relation), so no globals to collect.
|
||||
{ model: "EntityLink", tenantField: "tenantId", schema: "entityLinks.prisma" },
|
||||
|
||||
// hr.prisma (P17 — AK-P17a). Direct `tenantId String` scalar. AD-21: all
|
||||
// cross-model references (location_id, employee_user_id, manager_user_id,
|
||||
// file_id) are BARE scalars (no @relation), so they are NOT collected as
|
||||
// globals. Ordering: EmployeePasswordSafeVault before its Entry/Access (FK
|
||||
// vaultId, Cascade); the rest are independent.
|
||||
{ model: "HrEmployeeProfile", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrLocation", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrEmployeeDocument", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrResource", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrQuickLink", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "EmployeePasswordSafeVault", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "EmployeePasswordSafeEntry", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "EmployeePasswordSafeAccess", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
// P17 HR-Hub workflows (AK-P17b). Ordering: a parent before its Cascade
|
||||
// children (HrAnnouncement before Read/Reaction/Comment; EmployeeUploadReminder
|
||||
// before Dispatch; HrSurvey before Item/Submission; HrRequestTemplate before
|
||||
// HrRequest [SetNull]). The rest are independent.
|
||||
{ model: "EmployeeVacationRequest", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "EmployeeSickLeaveReport", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "EmployeePayslip", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrAnnouncement", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrAnnouncementRead", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrAnnouncementReaction", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrAnnouncementComment", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "EmployeeUploadReminder", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "EmployeeUploadReminderDispatch", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrRequestTemplate", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrRequest", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrSurvey", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrSurveyItem", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
{ model: "HrSurveySubmission", tenantField: "tenantId", schema: "hr.prisma" },
|
||||
|
||||
// crm.prisma (P6 — R-P6). Direct `tenantId String` scalar. AD-21: all
|
||||
// cross-model references (createdByUserId, zustaendigerUserId) are BARE scalars
|
||||
// (no @relation), so they are NOT collected as globals. Ordering: a referenced
|
||||
// model before its Cascade children — Adresse before Kontakt (FK adresseId),
|
||||
// Kontakt before KontaktEmail/Telefon/Relation (FK kontaktId/von-/zuKontaktId),
|
||||
// CustomFieldDefinition before CustomFieldValue (FK definitionId),
|
||||
// Tag before TagAssignment (FK tagId).
|
||||
{ model: "Adresse", tenantField: "tenantId", schema: "crm.prisma" },
|
||||
{ model: "Kontakt", tenantField: "tenantId", schema: "crm.prisma" },
|
||||
{ model: "KontaktEmail", tenantField: "tenantId", schema: "crm.prisma" },
|
||||
{ model: "KontaktTelefon", tenantField: "tenantId", schema: "crm.prisma" },
|
||||
{ model: "KontaktRelation", tenantField: "tenantId", schema: "crm.prisma" },
|
||||
{ model: "CustomFieldDefinition", tenantField: "tenantId", schema: "crm.prisma" },
|
||||
{ model: "CustomFieldValue", tenantField: "tenantId", schema: "crm.prisma" },
|
||||
{ model: "Tag", tenantField: "tenantId", schema: "crm.prisma" },
|
||||
{ model: "TagAssignment", tenantField: "tenantId", schema: "crm.prisma" },
|
||||
|
||||
// calendar.prisma (AK-P16a) — Connection before its Cascade children
|
||||
// (Event/Mapping/SyncCursor/WebhookEvent/Conflict via FK connectionId),
|
||||
// CalendarEvent before CalendarEventMapping (FK internalEventId).
|
||||
{ model: "CalendarConnection", tenantField: "tenantId", schema: "calendar.prisma" },
|
||||
{ model: "CalendarEvent", tenantField: "tenantId", schema: "calendar.prisma" },
|
||||
{ model: "CalendarEventMapping", tenantField: "tenantId", schema: "calendar.prisma" },
|
||||
{ model: "CalendarSyncCursor", tenantField: "tenantId", schema: "calendar.prisma" },
|
||||
{ model: "CalendarWebhookEvent", tenantField: "tenantId", schema: "calendar.prisma" },
|
||||
{ model: "CalendarConflict", tenantField: "tenantId", schema: "calendar.prisma" },
|
||||
|
||||
// email-inbox.prisma (VA-P23) — Mailbox before its Cascade children
|
||||
// (Message/SyncCursor/WebhookEvent via FK mailboxId).
|
||||
{ model: "EmailIntegrationMailbox", tenantField: "tenantId", schema: "email-inbox.prisma" },
|
||||
{ model: "EmailIntegrationMessage", tenantField: "tenantId", schema: "email-inbox.prisma" },
|
||||
{ model: "EmailIntegrationSyncCursor", tenantField: "tenantId", schema: "email-inbox.prisma" },
|
||||
{ model: "EmailIntegrationWebhookEvent", tenantField: "tenantId", schema: "email-inbox.prisma" },
|
||||
|
||||
// booking.prisma (AK-P16b) — BookingPage before its Cascade children
|
||||
// (BookingPageProvider/Appointment via FK bookingPageId). AvailabilityRule/
|
||||
// Exception are standalone (provider linked by bare scalar, no FK).
|
||||
{ model: "BookingPage", tenantField: "tenantId", schema: "booking.prisma" },
|
||||
{ model: "BookingPageProvider", tenantField: "tenantId", schema: "booking.prisma" },
|
||||
{ model: "AvailabilityRule", tenantField: "tenantId", schema: "booking.prisma" },
|
||||
{ model: "AvailabilityException", tenantField: "tenantId", schema: "booking.prisma" },
|
||||
{ model: "Appointment", tenantField: "tenantId", schema: "booking.prisma" },
|
||||
|
||||
// signature.prisma (AK-P16d) — provider connection before documents; document
|
||||
// before signers/events (Cascade by documentId). Cross-module references
|
||||
// (Projekt/DataConnection/File/Kontakt/User) are BARE scalars.
|
||||
{ model: "SignatureProviderConnection", tenantField: "tenantId", schema: "signature.prisma" },
|
||||
{ model: "ProjektSignatureDocument", tenantField: "tenantId", schema: "signature.prisma" },
|
||||
{ model: "ProjektSignatureSigner", tenantField: "tenantId", schema: "signature.prisma" },
|
||||
{ model: "SignatureEvent", tenantField: "tenantId", schema: "signature.prisma" },
|
||||
|
||||
// leads.prisma (P7 — R-P7). Direct `tenantId String` scalar. Cross-module
|
||||
// references (createdByUserId, zustaendigerUserId, konvertiertProjektId,
|
||||
// verknuepfterKontaktId) are BARE scalars. Ordering: LeadSource before InboxLead
|
||||
// (FK sourceId SetNull), config independent.
|
||||
{ model: "LeadSource", tenantField: "tenantId", schema: "leads.prisma" },
|
||||
{ model: "InboxLead", tenantField: "tenantId", schema: "leads.prisma" },
|
||||
{ model: "LeadAntiSpamConfig", tenantField: "tenantId", schema: "leads.prisma" },
|
||||
|
||||
// projekt.prisma (P8 — R-P8a). Direct `tenantId String` scalar. Ordering:
|
||||
// HiveNumberSeq independent; Pipeline before Cascade children; PipelineStage
|
||||
// and LostReason before Projekt; Projekt before history/contact children.
|
||||
// User/Kontakt/Lead/Adresse references are BARE scalars and not collected as globals.
|
||||
{ model: "HiveNumberSeq", tenantField: "tenantId", schema: "projekt.prisma" },
|
||||
{ model: "Pipeline", tenantField: "tenantId", schema: "projekt.prisma" },
|
||||
{ model: "PipelineStage", tenantField: "tenantId", schema: "projekt.prisma" },
|
||||
{ model: "PipelineAccess", tenantField: "tenantId", schema: "projekt.prisma" },
|
||||
{ model: "PipelineFieldConfig", tenantField: "tenantId", schema: "projekt.prisma" },
|
||||
{ model: "PipelineFieldVisibility", tenantField: "tenantId", schema: "projekt.prisma" },
|
||||
{ model: "LostReason", tenantField: "tenantId", schema: "projekt.prisma" },
|
||||
{ model: "Projekt", tenantField: "tenantId", schema: "projekt.prisma" },
|
||||
{ model: "ProjektStageChange", tenantField: "tenantId", schema: "projekt.prisma" },
|
||||
{ model: "PipelineAggregateSnapshot", tenantField: "tenantId", schema: "projekt.prisma" },
|
||||
{ model: "ProjektKontakt", tenantField: "tenantId", schema: "projekt.prisma" },
|
||||
|
||||
// auftrag.prisma (P9 — R-P9a/R-P9b). Order-specific sub-areas on the same
|
||||
// Projekt core. Projekt/User/Group/File/Form/Calendar references are BARE
|
||||
// scalars and not collected as globals; restore Projekt first via
|
||||
// projekt.prisma rows. Ordering keeps parents before Cascade/Restrict
|
||||
// children (ProjektChecklist before Item, ScheduleEntry before Conflict,
|
||||
// AbnahmeProtokoll before Signatur).
|
||||
{ model: "ProjektMitglied", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "ProjektTermin", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "Rechnung", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "ProjektChecklist", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "ProjektChecklistItem", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "AuftragPipelineStageConfig", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "AcceptanceFormTemplate", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "ProjectTemplate", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "ScheduleEntry", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "ScheduleConflict", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "AbnahmeProtokoll", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "AbnahmeSignatur", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
{ model: "OfflineSyncMutation", tenantField: "tenantId", schema: "auftrag.prisma" },
|
||||
|
||||
// search.prisma (P11 — R-P11a). Polymorphic entity references are bare
|
||||
// scalars; RecentSearch references User by bare userId for per-user recents.
|
||||
{ model: "SearchIndexEntry", tenantField: "tenantId", schema: "search.prisma" },
|
||||
{ model: "RecentSearch", tenantField: "tenantId", schema: "search.prisma" },
|
||||
|
||||
// dashboard.prisma (P11 — R-P11b). Dashboard before layout and widget
|
||||
// instances (Cascade by dashboardId); userId is a bare scalar.
|
||||
{ model: "Dashboard", tenantField: "tenantId", schema: "dashboard.prisma" },
|
||||
{ model: "DashboardLayout", tenantField: "tenantId", schema: "dashboard.prisma" },
|
||||
{ model: "WidgetInstance", tenantField: "tenantId", schema: "dashboard.prisma" },
|
||||
|
||||
// mcpOAuth.prisma (VR-MCP). OAuth grants carry bare tenantId/tenantSlug
|
||||
// scalars (userId is a bare scalar too); McpOAuthClient is a global
|
||||
// (dynamic client registration, no tenantId) and lives under
|
||||
// GLOBAL_REFERENCED_MODELS. RefreshToken before AccessToken
|
||||
// (AccessToken.refreshTokenId is a nullable SetNull FK).
|
||||
{ model: "McpOAuthAuthorizationCode", tenantField: "tenantId", schema: "mcpOAuth.prisma" },
|
||||
{ model: "McpOAuthRefreshToken", tenantField: "tenantId", schema: "mcpOAuth.prisma" },
|
||||
{ model: "McpOAuthAccessToken", tenantField: "tenantId", schema: "mcpOAuth.prisma" },
|
||||
];
|
||||
|
||||
/** Constant-time check that a model name is known to be tenant-scoped. */
|
||||
@@ -162,8 +369,7 @@ export function tenantScopedModelNames(): readonly string[] {
|
||||
* staging verification flagged as broken (`TenantUser`, `TenantIpAddress`,
|
||||
* `UserRole`, `Event`, `Log`, `SupportTicket`). All other globals reached
|
||||
* from tenant-scoped models in the current schema are platform-level
|
||||
* catalogs (`Entity`, `Formula`, `EntityGroup`, `Onboarding`,
|
||||
* `RowComment`, `WorkflowBlock`) — these are expected to
|
||||
* catalogs (`Onboarding`, `WorkflowBlock`) — these are expected to
|
||||
* already exist on the target deployment because they are seeded by
|
||||
* migrations/setup scripts, NOT by tenant onboarding. Their absence on
|
||||
* an "empty" target is therefore an operator-environment issue, not a
|
||||
@@ -193,16 +399,16 @@ export const GLOBAL_REFERENCED_MODELS: readonly GlobalReferencedModel[] = [
|
||||
schema: "accounts.prisma",
|
||||
referencedBy: [
|
||||
// (kept in alphabetical order by source model for review-friendliness)
|
||||
{ model: "AdminTenantNote", fkColumn: "authorUserId" },
|
||||
{ model: "ApiKey", fkColumn: "createdByUserId" },
|
||||
{ model: "App", fkColumn: "installedByUserId" },
|
||||
{ model: "AppSyncRun", fkColumn: "createdByUserId" },
|
||||
{ model: "DataConnection", fkColumn: "createdByUserId" },
|
||||
{ model: "ProjektSignatureDocument", fkColumn: "createdByUserId" },
|
||||
{ model: "SignatureEvent", fkColumn: "actorUserId" },
|
||||
{ model: "Credit", fkColumn: "userId" },
|
||||
{ model: "DeviceToken", fkColumn: "userId" },
|
||||
{ model: "EntityView", fkColumn: "createdByUserId" },
|
||||
{ model: "EntityView", fkColumn: "userId" },
|
||||
{ model: "Event", fkColumn: "userId" },
|
||||
{ model: "Feedback", fkColumn: "userId" },
|
||||
{ model: "FormulaLog", fkColumn: "userId" },
|
||||
{ model: "Group", fkColumn: "createdByUserId" },
|
||||
{ model: "ImpersonationAudit", fkColumn: "actorUserId" },
|
||||
{ model: "ImpersonationAudit", fkColumn: "targetUserId" },
|
||||
@@ -211,8 +417,6 @@ export const GLOBAL_REFERENCED_MODELS: readonly GlobalReferencedModel[] = [
|
||||
{ model: "NotificationDelivery", fkColumn: "userId" },
|
||||
{ model: "OnboardingSession", fkColumn: "userId" },
|
||||
{ model: "Portal", fkColumn: "createdByUserId" },
|
||||
{ model: "Row", fkColumn: "createdByUserId" },
|
||||
{ model: "RowPermission", fkColumn: "userId" },
|
||||
{ model: "Site", fkColumn: "createdByUserId" },
|
||||
{ model: "SupportTicket", fkColumn: "userId" },
|
||||
{ model: "TenantIpAddress", fkColumn: "userId" },
|
||||
@@ -229,6 +433,15 @@ export const GLOBAL_REFERENCED_MODELS: readonly GlobalReferencedModel[] = [
|
||||
{ model: "WorkflowVariable", fkColumn: "userId" },
|
||||
],
|
||||
},
|
||||
{
|
||||
model: "McpOAuthClient",
|
||||
schema: "mcpOAuth.prisma",
|
||||
referencedBy: [
|
||||
{ model: "McpOAuthAccessToken", fkColumn: "clientId" },
|
||||
{ model: "McpOAuthAuthorizationCode", fkColumn: "clientId" },
|
||||
{ model: "McpOAuthRefreshToken", fkColumn: "clientId" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -238,11 +451,8 @@ export const GLOBAL_REFERENCED_MODELS: readonly GlobalReferencedModel[] = [
|
||||
* test can prove every global reference is consciously categorized.
|
||||
*/
|
||||
export const PLATFORM_CATALOG_GLOBALS: readonly string[] = [
|
||||
"Entity",
|
||||
"EntityGroup",
|
||||
"Formula",
|
||||
"App", // R-P5: global integrations catalog (seeded at deployment), referenced by DataConnection.appId
|
||||
"Onboarding",
|
||||
"RowComment",
|
||||
"WorkflowBlock",
|
||||
];
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Bridge between the generic, dependency-injected `PrismaRunner` /
|
||||
* `PrismaRestoreRunner` interfaces and a real `@toolctrl/db` PrismaClient.
|
||||
* `PrismaRestoreRunner` interfaces and a real `@hivegrid/db` PrismaClient.
|
||||
*
|
||||
* Kept separate from `snapshot.ts` / `restore.ts` so those modules stay
|
||||
* Prisma-free (and trivially unit-testable with plain fakes). The CLI bin
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* The Prisma layer is dependency-injected via the `PrismaRestoreRunner`
|
||||
* interface so the CLI package stays free of `@prisma/client`. Production
|
||||
* callers wire up a real client in `bin/toolctrl-cli.mjs`; tests pass a fake.
|
||||
* callers wire up a real client in `bin/hivegrid-cli.mjs`; tests pass a fake.
|
||||
*
|
||||
* Foreign-key remapping: only the `tenantId` column is rewritten. Row primary
|
||||
* keys are preserved (the snapshot is intended to land in a separate
|
||||
@@ -435,7 +435,7 @@ export const tenantRestoreCommand = defineCommand({
|
||||
const { resolveTenantSnapshotConfig } = await import("./env.js");
|
||||
const cfg = resolveTenantSnapshotConfig(process.env as Record<string, string | undefined>);
|
||||
|
||||
const { getDbClient } = await import("@toolctrl/db/client.server");
|
||||
const { getDbClient } = await import("@hivegrid/db/client.server");
|
||||
const { createPrismaRestoreRunner } = await import("./prisma-runner.js");
|
||||
const { parseSchemaScalarTypes } = await import("./json-codec.js");
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import { mkdtemp } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { createDbClient } from "@toolctrl/db/client.server";
|
||||
import { createDbClient } from "@hivegrid/db/client.server";
|
||||
import { runTenantSnapshot } from "./snapshot.js";
|
||||
import { runTenantRestore } from "./restore.js";
|
||||
import { createPrismaSnapshotRunner, createPrismaRestoreRunner } from "./prisma-runner.js";
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* The Prisma layer is dependency-injected via the `PrismaRunner` interface so
|
||||
* the CLI package stays free of `@prisma/client`. The production entrypoint
|
||||
* (`bin/toolctrl-cli.mjs` of the consumer) wires up the real `PrismaClient`;
|
||||
* (`bin/hivegrid-cli.mjs` of the consumer) wires up the real `PrismaClient`;
|
||||
* tests pass a fake.
|
||||
*/
|
||||
import { defineCommand } from "citty";
|
||||
@@ -511,7 +511,7 @@ export const tenantSnapshotCommand = defineCommand({
|
||||
const { resolveTenantSnapshotConfig } = await import("./env.js");
|
||||
const cfg = resolveTenantSnapshotConfig(process.env as Record<string, string | undefined>);
|
||||
|
||||
const { getDbClient } = await import("@toolctrl/db/client.server");
|
||||
const { getDbClient } = await import("@hivegrid/db/client.server");
|
||||
const { createPrismaSnapshotRunner } = await import("./prisma-runner.js");
|
||||
const prisma = getDbClient();
|
||||
const runner = createPrismaSnapshotRunner(prisma as unknown as Record<string, unknown>);
|
||||
|
||||
Reference in new issue
Block a user