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
@@ -4,17 +4,17 @@ import {
|
||||
findLegacyTenantById,
|
||||
findLegacyTenantByIdOrSlug,
|
||||
type LegacyTenantWithDetails,
|
||||
} from "@toolctrl/db/accounts.server";
|
||||
} from "@hivegrid/db/accounts.server";
|
||||
import {
|
||||
createLegacyApiKeyLog,
|
||||
findLegacyApiKeyByKey,
|
||||
setLegacyApiKeyLogStatus,
|
||||
} from "@toolctrl/db/api-keys.server";
|
||||
} from "@hivegrid/db/api-keys.server";
|
||||
import {
|
||||
listWorkspaceAuthProviders,
|
||||
revalidateWorkspaceContext,
|
||||
type WorkspaceAuthProviderDto,
|
||||
} from "@toolctrl/db/auth-providers.server";
|
||||
} from "@hivegrid/db/auth-providers.server";
|
||||
import {
|
||||
createAnalyticsEvent,
|
||||
createAnalyticsPageView,
|
||||
@@ -29,54 +29,38 @@ import {
|
||||
type AnalyticsInfo,
|
||||
type AnalyticsPeriod,
|
||||
type AnalyticsUniqueVisitor,
|
||||
} from "@toolctrl/db/analytics.server";
|
||||
} from "@hivegrid/db/analytics.server";
|
||||
import {
|
||||
findLegacyAuthUserById,
|
||||
findLegacyLoginUserByEmail,
|
||||
recordLegacyLogin,
|
||||
type LegacyAuthUser,
|
||||
type LegacyLoginUser,
|
||||
} from "@toolctrl/db/users.server";
|
||||
import { findLegacyEntityByName, type LegacyEntity, type LegacyEntityWithDetails } from "@toolctrl/db/entities.server";
|
||||
import {
|
||||
createLegacyEntityRow,
|
||||
deleteLegacyEntityRow,
|
||||
findLegacyRelationshipRowById,
|
||||
getAllLegacyEntityRows,
|
||||
getLegacyEntityRow,
|
||||
updateLegacyEntityRow,
|
||||
type LegacyEntityRow,
|
||||
type LegacyEntityRowPage,
|
||||
type LegacyRelationshipRow,
|
||||
} from "@toolctrl/db/rows.server";
|
||||
import {
|
||||
createLegacyRowRelationship,
|
||||
deleteLegacyRowRelationshipById,
|
||||
findLegacyEntityRelationship,
|
||||
findLegacyRowRelationshipById,
|
||||
type LegacyEntityRelationshipDetails,
|
||||
type LegacyRowRelationshipDetails,
|
||||
} from "@toolctrl/db/relationships.server";
|
||||
} from "@hivegrid/db/users.server";
|
||||
import {
|
||||
findLegacyEventWebhookAttemptById,
|
||||
updateLegacyEventWebhookAttempt,
|
||||
type LegacyEventWebhookAttempt,
|
||||
type LegacyEventWebhookAttemptUpdate,
|
||||
} from "@toolctrl/db/event-webhook-attempts.server";
|
||||
import { createLegacyEvent } from "@toolctrl/db/events.server";
|
||||
import { markEmailSequenceDeliveryBounced, type MarkEmailSequenceDeliveryBouncedInput, type EmailSequenceProviderWebhookResult } from "@toolctrl/db/email-sequences.server";
|
||||
import { findExportJobForDownload, type ExportJobDownloadRecord } from "@toolctrl/db/export-jobs.server";
|
||||
} from "@hivegrid/db/event-webhook-attempts.server";
|
||||
import { createLegacyEvent } from "@hivegrid/db/events.server";
|
||||
import { markEmailSequenceDeliveryBounced, type MarkEmailSequenceDeliveryBouncedInput, type EmailSequenceProviderWebhookResult } from "@hivegrid/db/email-sequences.server";
|
||||
import { recordEmailSuppression } from "@hivegrid/db/email-suppression.server";
|
||||
import { findExportJobForDownload, type ExportJobDownloadRecord } from "@hivegrid/db/export-jobs.server";
|
||||
import { readExportProgressFromSharedStore } from "./export-progress.js";
|
||||
import {
|
||||
findTenantSubscriptionProductByStripeSubscriptionId,
|
||||
getTenantSubscription,
|
||||
updateTenantSubscriptionProductFromStripe,
|
||||
type StripeTenantSubscriptionProduct,
|
||||
type TenantSubscriptionWithDetails,
|
||||
} from "@toolctrl/db/subscriptions.server";
|
||||
import { getTenantApiUsage } from "@toolctrl/db/usage.server";
|
||||
import { publishOutboxEvent } from "@toolctrl/db/outbox";
|
||||
import { createInboundSupportTicketFromEmail, type InboundSupportTicketInput, type InboundSupportTicketResult } from "@toolctrl/db/support-tickets.server";
|
||||
} from "@hivegrid/db/subscriptions.server";
|
||||
import { applyLagoSubscriptionSync, applyMolliePaymentSync } from "@hivegrid/db/billing-sync.server";
|
||||
import { getTenantApiUsage } from "@hivegrid/db/usage.server";
|
||||
import {
|
||||
createPublicWebhookIngestionLog,
|
||||
findPublicIncomingWebhookEndpoint,
|
||||
ingestPublicLeadWebhook,
|
||||
type IngestPublicLeadWebhookResult,
|
||||
} from "@hivegrid/db/public-api.server";
|
||||
import { createInboundSupportTicketFromEmail, type InboundSupportTicketInput, type InboundSupportTicketResult } from "@hivegrid/db/support-tickets.server";
|
||||
import {
|
||||
acceptWorkspaceInvite,
|
||||
createWorkspaceInvite,
|
||||
@@ -84,11 +68,10 @@ import {
|
||||
revokeWorkspaceInvite,
|
||||
type WorkspaceInviteCreateResult,
|
||||
type WorkspaceInviteDto,
|
||||
} from "@toolctrl/db/workspace-invites.server";
|
||||
import { getDbClient } from "@toolctrl/db/client.server";
|
||||
import { getNotificationStreamSnapshot, type NotificationStreamCursor, type NotificationStreamSnapshot } from "@toolctrl/db/notifications.server";
|
||||
} from "@hivegrid/db/workspace-invites.server";
|
||||
import { getDbClient } from "@hivegrid/db/client.server";
|
||||
import { getNotificationStreamSnapshot, type NotificationStreamCursor, type NotificationStreamSnapshot } from "@hivegrid/db/notifications.server";
|
||||
import bcrypt from "bcryptjs";
|
||||
import Stripe from "stripe";
|
||||
import {
|
||||
checkLoginRateLimit,
|
||||
recordFailedLoginAttempt,
|
||||
@@ -97,7 +80,6 @@ import {
|
||||
type LoginRateLimitRequest,
|
||||
} from "./auth/login-rate-limit.js";
|
||||
import { apiSessionStore } from "./auth/session/session-store.js";
|
||||
import { getApiRuntimeConfig } from "./config.js";
|
||||
import {
|
||||
createMemoryIdempotencyStorageClient,
|
||||
type IdempotencyStorageClient,
|
||||
@@ -115,6 +97,9 @@ import {
|
||||
type QueueExportArtifactRetentionInput,
|
||||
type QueueExportArtifactRetentionResult,
|
||||
} from "./exportRetentionQueue.js";
|
||||
import { listPublicApiResource } from "./public-api/read-service.js";
|
||||
import type { PublicApiListInput, PublicApiListResult } from "./public-api/resources.js";
|
||||
import { createDefaultLagoInvoicePaymentStatusUpdater, createDefaultMollieWebhookResolver } from "./billing/mollie-webhook-route.js";
|
||||
|
||||
export { defaultAnalyticsPeriod, isAnalyticsPeriod };
|
||||
export type {
|
||||
@@ -123,19 +108,11 @@ export type {
|
||||
AnalyticsPeriod,
|
||||
AnalyticsUniqueVisitor,
|
||||
ExportJobDownloadRecord,
|
||||
LegacyEntity,
|
||||
LegacyEntityRelationshipDetails,
|
||||
LegacyEntityRow,
|
||||
LegacyEntityRowPage,
|
||||
LegacyEntityWithDetails,
|
||||
LegacyEventWebhookAttempt,
|
||||
LegacyRelationshipRow,
|
||||
LegacyRowRelationshipDetails,
|
||||
LegacyTenantWithDetails,
|
||||
LoginRateLimitRequest,
|
||||
NotificationStreamCursor,
|
||||
NotificationStreamSnapshot,
|
||||
StripeTenantSubscriptionProduct,
|
||||
TenantSubscriptionWithDetails,
|
||||
WorkspaceAuthProviderDto,
|
||||
WorkspaceInviteCreateResult,
|
||||
@@ -173,41 +150,25 @@ export type ApiAppDependencies = {
|
||||
findFeatureFlagByName(name: string): Promise<{ id: string } | null>;
|
||||
getAnalyticsOverview(args: { period: AnalyticsPeriod; portalId: string | null | undefined }): Promise<AnalyticsOverview>;
|
||||
findLegacyAuthUserById(userId: string): Promise<LegacyAuthUser | null>;
|
||||
findLegacyEntityByName(args: { tenantId: string | null | undefined; name: string; active?: boolean }): Promise<LegacyEntity>;
|
||||
getAllLegacyEntityRows(args: { entityId: string; tenantId: string | null; page: number; pageSize: number }): Promise<LegacyEntityRowPage>;
|
||||
getLegacyEntityRow(args: { entityId: string; tenantId: string | null; rowId: string }): Promise<LegacyEntityRow | null>;
|
||||
findLegacyRelationshipRowById(args: { id: string; tenantId?: string | null }): Promise<LegacyRelationshipRow | null>;
|
||||
findLegacyEntityRelationship(args: { parentId: string; childId: string }): Promise<LegacyEntityRelationshipDetails | null>;
|
||||
findLegacyRowRelationshipById(id: string, tenantId?: string | null): Promise<LegacyRowRelationshipDetails | null>;
|
||||
createLegacyRowRelationship(args: { relationshipId: string; parentId: string; childId: string; tenantId?: string | null; metadata?: string | null }): Promise<LegacyRowRelationshipDetails>;
|
||||
deleteLegacyRowRelationshipById(args: { id: string; relationshipId: string; parentId: string; childId: string; tenantId: string | null }): Promise<unknown>;
|
||||
createLegacyEntityRow(args: { entity: LegacyEntityWithDetails; tenantId: string | null; createdByUserId?: string | null; createdByApiKeyId?: string | null; data: Record<string, unknown> }): Promise<LegacyEntityRow>;
|
||||
updateLegacyEntityRow(args: { entity: LegacyEntityWithDetails; tenantId: string | null; rowId: string; data: Record<string, unknown> }): Promise<LegacyEntityRow>;
|
||||
deleteLegacyEntityRow(args: { entityId: string; tenantId: string | null; rowId: string }): Promise<string>;
|
||||
findLegacyEventWebhookAttemptById(id: string): Promise<LegacyEventWebhookAttempt | null>;
|
||||
findTenantSubscriptionProductByStripeSubscriptionId(stripeSubscriptionId: string): Promise<StripeTenantSubscriptionProduct | null>;
|
||||
updateTenantSubscriptionProductFromStripe: typeof updateTenantSubscriptionProductFromStripe;
|
||||
createLegacyEvent: typeof createLegacyEvent;
|
||||
/**
|
||||
* Phase 03 #42 — transaction runner used by the Stripe webhook so the
|
||||
* subscription update + outbox publishes commit atomically. The
|
||||
* callback receives a transaction client that doubles as both a
|
||||
* Prisma-style subscription writer and an OutboxPublisherTransaction.
|
||||
*/
|
||||
runStripeWebhookTransaction: import("./billing/stripe-webhook-route.js").StripeWebhookTransactionRunner;
|
||||
/**
|
||||
* Phase 03 #42 — outbox publisher bound to the surrounding
|
||||
* transaction. Defaults to `publishOutboxEvent` from `@toolctrl/db/outbox`.
|
||||
*/
|
||||
publishOutboxEvent: typeof import("@toolctrl/db/outbox").publishOutboxEvent;
|
||||
applyLagoSubscriptionSync: typeof import("@hivegrid/db/billing-sync.server").applyLagoSubscriptionSync;
|
||||
applyMolliePaymentSync: typeof import("@hivegrid/db/billing-sync.server").applyMolliePaymentSync;
|
||||
resolveMollieWebhookPayment: ReturnType<typeof createDefaultMollieWebhookResolver>;
|
||||
updateLagoInvoicePaymentStatus: ReturnType<typeof createDefaultLagoInvoicePaymentStatusUpdater>;
|
||||
findLegacyLoginUserByEmail(email: string): Promise<LegacyLoginUser | null>;
|
||||
adminGetAllLegacyTenants(): Promise<LegacyTenantWithDetails[]>;
|
||||
findLegacyTenantById(id: string): Promise<LegacyTenantWithDetails | null>;
|
||||
findLegacyTenantByIdOrSlug(idOrSlug: string): Promise<{ id: string } | null>;
|
||||
getTenantSubscription: typeof getTenantSubscription;
|
||||
getTenantApiUsage: typeof getTenantApiUsage;
|
||||
listPublicApiResource(input: PublicApiListInput): Promise<PublicApiListResult>;
|
||||
findPublicIncomingWebhookEndpoint: typeof findPublicIncomingWebhookEndpoint;
|
||||
createPublicWebhookIngestionLog: typeof createPublicWebhookIngestionLog;
|
||||
ingestPublicLeadWebhook(input: Parameters<typeof ingestPublicLeadWebhook>[0]): Promise<IngestPublicLeadWebhookResult>;
|
||||
createInboundSupportTicketFromEmail(input: InboundSupportTicketInput): Promise<InboundSupportTicketResult>;
|
||||
markEmailSequenceDeliveryBounced(input: MarkEmailSequenceDeliveryBouncedInput): Promise<EmailSequenceProviderWebhookResult>;
|
||||
recordSuppression: typeof recordEmailSuppression;
|
||||
findExportJobForDownload(args: { id: string; tenantId: string }): Promise<ExportJobDownloadRecord | null>;
|
||||
readExportProgress(args: { exportJobId: string; tenantId: string }): Promise<{ processedRows: number; totalEstimate: number | null; updatedAt: string | null } | null>;
|
||||
getAnalyticsSettings(): Promise<{ public: boolean; ignorePages: string } | null>;
|
||||
@@ -225,8 +186,6 @@ export type ApiAppDependencies = {
|
||||
revalidateWorkspaceContext(input: Parameters<typeof revalidateWorkspaceContext>[0]): ReturnType<typeof revalidateWorkspaceContext>;
|
||||
uploadFile(bucketId: string, path: string, file: UploadBody, contentType?: string): Promise<{ id: string; publicUrl: string | null }>;
|
||||
createSignedDownloadUrl(bucketId: string, input: CreateStorageSignedDownloadUrlInput): Promise<StorageSignedDownloadUrlResult>;
|
||||
constructStripeWebhookEvent(payload: string, signature: string): Stripe.Event;
|
||||
retrieveStripeSubscription(id: string): Promise<Stripe.Subscription | null>;
|
||||
recordLegacyLogin(userId: string): Promise<void>;
|
||||
comparePassword(password: string, passwordHash: string): Promise<boolean>;
|
||||
checkLoginRateLimit(request: LoginRateLimitRequest): ReturnType<typeof checkLoginRateLimit>;
|
||||
@@ -244,22 +203,6 @@ export type ApiAppDependencies = {
|
||||
|
||||
type UploadBody = Parameters<typeof createStorageFile>[2];
|
||||
|
||||
const STRIPE_API_VERSION = "2025-10-29.clover";
|
||||
let apiStripeClient: Stripe | null = null;
|
||||
let apiStripeClientSecretKey: string | undefined;
|
||||
|
||||
function getApiStripeClient() {
|
||||
const secretKey = getApiRuntimeConfig().stripe.secretKey;
|
||||
if (!secretKey) {
|
||||
throw new Error("STRIPE_SK is required before using Stripe API services.");
|
||||
}
|
||||
if (!apiStripeClient || apiStripeClientSecretKey !== secretKey) {
|
||||
apiStripeClient = new Stripe(secretKey, { apiVersion: STRIPE_API_VERSION });
|
||||
apiStripeClientSecretKey = secretKey;
|
||||
}
|
||||
return apiStripeClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Idempotency-storage backend selection (Phase 03 #38).
|
||||
*
|
||||
@@ -291,41 +234,25 @@ const defaultApiAppDependencies: ApiAppDependencies = {
|
||||
findFeatureFlagByName,
|
||||
getAnalyticsOverview,
|
||||
findLegacyAuthUserById,
|
||||
findLegacyEntityByName,
|
||||
getAllLegacyEntityRows,
|
||||
getLegacyEntityRow,
|
||||
findLegacyRelationshipRowById,
|
||||
findLegacyEntityRelationship,
|
||||
findLegacyRowRelationshipById,
|
||||
createLegacyRowRelationship,
|
||||
deleteLegacyRowRelationshipById,
|
||||
createLegacyEntityRow,
|
||||
updateLegacyEntityRow,
|
||||
deleteLegacyEntityRow,
|
||||
findLegacyEventWebhookAttemptById,
|
||||
findTenantSubscriptionProductByStripeSubscriptionId,
|
||||
updateTenantSubscriptionProductFromStripe,
|
||||
createLegacyEvent,
|
||||
// Phase 03 #42 — Stripe-webhook outbox migration. The default runs
|
||||
// the callback inside `prisma.$transaction(...)`; the resulting tx
|
||||
// client doubles as both StripeTenantSubscriptionProductClient and
|
||||
// OutboxPublisherTransaction (Prisma transaction clients implement
|
||||
// both surfaces structurally).
|
||||
runStripeWebhookTransaction: (async <T,>(fn: (tx: import("./billing/stripe-webhook-route.js").StripeWebhookTransactionClient) => Promise<T>) => {
|
||||
const prisma = getDbClient() as unknown as {
|
||||
$transaction: <U>(runner: (tx: import("./billing/stripe-webhook-route.js").StripeWebhookTransactionClient) => Promise<U>) => Promise<U>;
|
||||
};
|
||||
return prisma.$transaction(fn);
|
||||
}) as import("./billing/stripe-webhook-route.js").StripeWebhookTransactionRunner,
|
||||
publishOutboxEvent,
|
||||
applyLagoSubscriptionSync,
|
||||
applyMolliePaymentSync,
|
||||
resolveMollieWebhookPayment: createDefaultMollieWebhookResolver(),
|
||||
updateLagoInvoicePaymentStatus: createDefaultLagoInvoicePaymentStatusUpdater(),
|
||||
findLegacyLoginUserByEmail,
|
||||
adminGetAllLegacyTenants,
|
||||
findLegacyTenantById,
|
||||
findLegacyTenantByIdOrSlug,
|
||||
getTenantSubscription,
|
||||
getTenantApiUsage,
|
||||
listPublicApiResource,
|
||||
findPublicIncomingWebhookEndpoint,
|
||||
createPublicWebhookIngestionLog,
|
||||
ingestPublicLeadWebhook,
|
||||
createInboundSupportTicketFromEmail,
|
||||
markEmailSequenceDeliveryBounced,
|
||||
recordSuppression: recordEmailSuppression,
|
||||
findExportJobForDownload,
|
||||
readExportProgress: readExportProgressFromSharedStore,
|
||||
getAnalyticsSettings,
|
||||
@@ -343,20 +270,6 @@ const defaultApiAppDependencies: ApiAppDependencies = {
|
||||
revalidateWorkspaceContext,
|
||||
uploadFile: createStorageFile,
|
||||
createSignedDownloadUrl: createStorageSignedDownloadUrl,
|
||||
constructStripeWebhookEvent(payload, signature) {
|
||||
const config = getApiRuntimeConfig();
|
||||
if (!config.stripe.webhookSigningSecret) {
|
||||
throw new Error("STRIPE_WEBHOOK_SIGNING_SECRET is required before verifying Stripe webhooks.");
|
||||
}
|
||||
return getApiStripeClient().webhooks.constructEvent(payload, signature, config.stripe.webhookSigningSecret);
|
||||
},
|
||||
async retrieveStripeSubscription(id) {
|
||||
try {
|
||||
return await getApiStripeClient().subscriptions.retrieve(id);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
recordLegacyLogin,
|
||||
comparePassword: bcrypt.compare,
|
||||
checkLoginRateLimit,
|
||||
|
||||
Reference in new issue
Block a user