@infuro/cms-core 1.0.15 → 1.0.16

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/dist/index.d.cts CHANGED
@@ -1,9 +1,10 @@
1
- import { C as CompanyDetails, T as TemplateContext, E as EmailTemplateResult, a as EmailTemplateName, O as OrderPlacedLineItem, S as StorageService, b as EntityMap$1 } from './index-BQnqJ7EO.cjs';
2
- export { A as AnalyticsHandlerConfig, c as AuthHandlersConfig, B as BlogBySlugConfig, d as ChangePasswordConfig, e as CmsApiHandlerConfig, f as CmsGetter, g as CrudHandlerOptions, D as DashboardStatsConfig, F as ForgotPasswordConfig, h as FormBySlugConfig, G as GetPublicSettingsGroupConfig, i as GetPublicSettingsGroupDataSource, I as InviteAcceptConfig, j as SetPasswordConfig, k as SettingsApiConfig, l as SocialLinkItem, m as StorefrontApiConfig, n as StorefrontOtpFlags, U as UploadHandlerConfig, o as UserAuthApiConfig, p as UserAvatarConfig, q as UserProfileConfig, r as UsersApiConfig, s as createAnalyticsHandlers, t as createBlogBySlugHandler, u as createChangePasswordHandler, v as createCmsApiHandler, w as createCrudByIdHandler, x as createCrudHandler, y as createDashboardStatsHandler, z as createForgotPasswordHandler, H as createFormBySlugHandler, J as createInviteAcceptHandler, K as createSetPasswordHandler, L as createSettingsApiHandlers, M as createStorefrontApiHandler, N as createUploadHandler, P as createUserAuthApiRouter, Q as createUserAvatarHandler, R as createUserProfileHandler, V as createUsersApiHandlers, W as getCompanyDetailsFromSettings, X as getPublicSettingsGroup, Y as mergeEmailLayoutCompanyDetails } from './index-BQnqJ7EO.cjs';
1
+ import { C as CompanyDetails, T as TemplateContext, E as EmailTemplateResult, a as EmailTemplateName, O as OrderPlacedLineItem, S as StorageService, b as EntityMap$2 } from './index-h42MoUNq.cjs';
2
+ export { A as AnalyticsHandlerConfig, c as AuthHandlersConfig, B as BlogBySlugConfig, d as ChangePasswordConfig, e as CmsApiHandlerConfig, f as CmsGetter, g as CrudHandlerOptions, D as DashboardStatsConfig, h as EcommerceAnalyticsConfig, F as ForgotPasswordConfig, i as FormBySlugConfig, G as GetPublicSettingsGroupConfig, j as GetPublicSettingsGroupDataSource, I as InviteAcceptConfig, k as SetPasswordConfig, l as SettingsApiConfig, m as SocialLinkItem, n as StorefrontApiConfig, o as StorefrontOtpFlags, U as UploadHandlerConfig, p as UserAuthApiConfig, q as UserAvatarConfig, r as UserProfileConfig, s as UsersApiConfig, t as createAnalyticsHandlers, u as createBlogBySlugHandler, v as createChangePasswordHandler, w as createCmsApiHandler, x as createCrudByIdHandler, y as createCrudHandler, z as createDashboardStatsHandler, H as createEcommerceAnalyticsHandler, J as createForgotPasswordHandler, K as createFormBySlugHandler, L as createInviteAcceptHandler, M as createMediaZipExtractHandler, N as createSetPasswordHandler, P as createSettingsApiHandlers, Q as createStorefrontApiHandler, R as createUploadHandler, V as createUserAuthApiRouter, W as createUserAvatarHandler, X as createUserProfileHandler, Y as createUsersApiHandlers, Z as getCompanyDetailsFromSettings, _ as getPublicSettingsGroup, $ as mergeEmailLayoutCompanyDetails } from './index-h42MoUNq.cjs';
3
3
  import { ClassValue } from 'clsx';
4
4
  import * as typeorm from 'typeorm';
5
5
  import { DataSource, EntityTarget, ObjectLiteral } from 'typeorm';
6
6
  import { Metadata } from 'next';
7
+ import { N as NavbarConfig, F as FooterConfig } from './types-D34wmivy.cjs';
7
8
  export { A as ADMIN_GROUP_NAME, a as AuthHelpers, E as EntityCrudAction, b as EntityPermissionFlags, G as GetSession, O as OPEN_ENDPOINTS, P as PERMISSION_REQUIRED_ENDPOINTS, R as RBAC_ADMIN_ONLY_ENTITIES, S as SessionUser, c as canManageRoles, d as createAuthHelpers, g as getPermissionableEntityKeys, e as getRequiredPermission, h as hasEntityPermission, i as isOpenEndpoint, f as isPublicMethod, j as isSuperAdminGroupName, p as permissionRowsToRecord, s as sessionHasEntityAccess } from './helpers-dlrF_49e.cjs';
8
9
  export { AuthorizeOtpInput, CmsMiddlewareConfig, NextAuthOptionsConfig, NextAuthUser, createCmsMiddleware, defaultPublicApiMethods, getNextAuthOptions, seedAdministratorPermissions } from './auth.cjs';
9
10
  export { A as AdminNavItem, D as DEFAULT_ADMIN_NAV } from './config-DJ5CmQvS.cjs';
@@ -630,7 +631,7 @@ type SeoMetadataOverrides = {
630
631
  };
631
632
  /** Per-field: join row wins over slug row. */
632
633
  declare function mergeSeoBySlug(join: SeoLike | null | undefined, bySlug: SeoLike | null): SeoLike | null;
633
- declare function fetchSeoBySlug(dataSource: DataSource, entityMap: EntityMap$1, slug: string): Promise<SeoLike | null>;
634
+ declare function fetchSeoBySlug(dataSource: DataSource, entityMap: EntityMap$2, slug: string): Promise<SeoLike | null>;
634
635
  /**
635
636
  * Build Next.js Metadata from merged SEO + optional layers.
636
637
  * `overrides` win over SEO; `fallbacks` apply when SEO (and overrides) omit a field.
@@ -638,7 +639,7 @@ declare function fetchSeoBySlug(dataSource: DataSource, entityMap: EntityMap$1,
638
639
  */
639
640
  declare function resolvePublicMetadata(args: {
640
641
  dataSource: DataSource;
641
- entityMap: EntityMap$1;
642
+ entityMap: EntityMap$2;
642
643
  slug: string;
643
644
  seoFromJoin?: SeoLike | null;
644
645
  overrides?: SeoMetadataOverrides;
@@ -664,9 +665,9 @@ declare function verifyOtpCodeHash(code: string, storedHash: string, purpose: st
664
665
  declare function generateNumericOtp(length?: number): string;
665
666
  /** Normalize to E.164-like +digits */
666
667
  declare function normalizePhoneE164(raw: string, defaultCountryCode?: string): string | null;
667
- type EntityMap = Record<string, EntityTarget<ObjectLiteral>>;
668
- declare function countRecentOtpSends(dataSource: DataSource, entityMap: EntityMap, purpose: OtpPurpose, identifier: string, since: Date): Promise<number>;
669
- declare function createOtpChallenge(dataSource: DataSource, entityMap: EntityMap, input: {
668
+ type EntityMap$1 = Record<string, EntityTarget<ObjectLiteral>>;
669
+ declare function countRecentOtpSends(dataSource: DataSource, entityMap: EntityMap$1, purpose: OtpPurpose, identifier: string, since: Date): Promise<number>;
670
+ declare function createOtpChallenge(dataSource: DataSource, entityMap: EntityMap$1, input: {
670
671
  purpose: OtpPurpose;
671
672
  channel: OtpChannel;
672
673
  identifier: string;
@@ -679,7 +680,7 @@ declare function createOtpChallenge(dataSource: DataSource, entityMap: EntityMap
679
680
  error: string;
680
681
  status: number;
681
682
  }>;
682
- declare function verifyAndConsumeOtpChallenge(dataSource: DataSource, entityMap: EntityMap, input: {
683
+ declare function verifyAndConsumeOtpChallenge(dataSource: DataSource, entityMap: EntityMap$1, input: {
683
684
  purpose: OtpPurpose;
684
685
  identifier: string;
685
686
  code: string;
@@ -692,6 +693,79 @@ declare function verifyAndConsumeOtpChallenge(dataSource: DataSource, entityMap:
692
693
  status: number;
693
694
  }>;
694
695
 
696
+ /** Returns true if request is allowed; false if rate limited. */
697
+ declare function allowRateLimit(key: string): Promise<boolean>;
698
+ type ExtraPublicWriteRule = (method: string, segments: string[]) => boolean;
699
+ /** Segments are path parts after `/api/` (e.g. `['form-submissions']`). */
700
+ declare function shouldRateLimitPublicWrite(method: string, segments: string[], extraRule?: ExtraPublicWriteRule): boolean;
701
+ declare function rateLimitKeyForApiRequest(req: Request, segments: string[]): string;
702
+ declare function rateLimitPublicApiIfNeeded(req: Request, method: string, segments: string[], options?: {
703
+ extraRule?: ExtraPublicWriteRule;
704
+ }): Promise<Response | null>;
705
+ declare function rateLimitCheckoutPost(req: Request): Promise<Response | null>;
706
+
707
+ interface EntityMapLike {
708
+ configs: unknown;
709
+ orders: unknown;
710
+ order_items: unknown;
711
+ }
712
+ interface SendOrderPlacedEmailDeps {
713
+ getDataSource: () => Promise<DataSource>;
714
+ entityMap: EntityMapLike;
715
+ getCms: () => Promise<CmsApp>;
716
+ }
717
+ /** After payment confirmation: email customer + each sales team address from plugin settings. */
718
+ declare function sendOrderPlacedEmailsAfterConfirmation(orderId: number, deps: SendOrderPlacedEmailDeps): Promise<void>;
719
+
720
+ interface DataSourceManager {
721
+ getDataSource: () => DataSource;
722
+ getDataSourceInitialized: () => Promise<DataSource>;
723
+ resetDataSource: () => void;
724
+ registerOnReset: (cb: () => void) => void;
725
+ isConnectionError: (e: unknown) => boolean;
726
+ }
727
+ declare function createDataSourceManager(entityMap: Record<string, unknown>, options?: {
728
+ databaseUrl?: string;
729
+ idleTimeoutMillis?: number;
730
+ }): DataSourceManager;
731
+
732
+ interface SeedEntityMap {
733
+ users: unknown;
734
+ user_groups: unknown;
735
+ }
736
+ declare function seedDefaultAdmin(ds: DataSource, entityMap: SeedEntityMap, opts?: {
737
+ email?: string;
738
+ password?: string;
739
+ }): Promise<void>;
740
+
741
+ interface PublicThemeSettingsPayload {
742
+ activeThemeId: string;
743
+ primaryColor: string;
744
+ secondaryColor: string;
745
+ navbarConfig: NavbarConfig;
746
+ footerOverrides: Partial<FooterConfig>;
747
+ }
748
+ declare function loadPublicThemeSettings(config: {
749
+ dataSource: DataSource;
750
+ entityMap: EntityMap$2;
751
+ encryptionKey?: string;
752
+ defaultActiveThemeId?: string;
753
+ defaultPrimaryColor?: string;
754
+ defaultSecondaryColor?: string;
755
+ }): Promise<PublicThemeSettingsPayload>;
756
+
757
+ /** Normalize a logical media folder path: no leading/trailing slashes, no ".." segments, max length. */
758
+ declare function sanitizeMediaFolderPath(input: unknown): string;
759
+ /** Single path segment for storage (folder name or legacy path segment). */
760
+ declare function sanitizeStorageSegment(name: string): string;
761
+
762
+ type EntityMap = Record<string, EntityTarget<ObjectLiteral>>;
763
+ /** Build `a/b/c` path under `uploads/` from the chain of folder rows up to root. */
764
+ declare function relativePathFromMediaParentId(dataSource: DataSource, entityMap: EntityMap, parentId: number | null): Promise<string>;
765
+
766
+ declare const ZIP_MIME_TYPES: Set<string>;
767
+ declare function isZipMedia(mime: string | null | undefined, filename: string): boolean;
768
+
695
769
  declare class Permission {
696
770
  id: number;
697
771
  groupId: number;
@@ -1239,9 +1313,13 @@ declare class MessageTemplate {
1239
1313
 
1240
1314
  declare class Media {
1241
1315
  id: number;
1316
+ kind: 'file' | 'folder';
1317
+ parentId: number | null;
1318
+ parent: Media | null;
1319
+ children: Media[];
1242
1320
  filename: string;
1243
- url: string;
1244
- mimeType: string;
1321
+ url: string | null;
1322
+ mimeType: string | null;
1245
1323
  size: number;
1246
1324
  alt: string | null;
1247
1325
  isPublic: boolean;
@@ -1339,4 +1417,4 @@ declare class Wishlist {
1339
1417
  /** Map API resource segment (e.g. "blogs", "form_submissions") to entity. Used by CRUD handler. */
1340
1418
  declare const CMS_ENTITY_MAP: Record<string, EntityTarget<typeorm.ObjectLiteral>>;
1341
1419
 
1342
- export { type AnalyticsPluginConfig, Attribute, Blog, Brand, CMS_ENTITY_MAP, type CachePluginConfig, type CacheService, type CaptchaProviderId, type CaptchaPublicConfig, CaptchaService, type CaptchaVerifyResult, Cart, CartItem, Category, ChatConversation, ChatMessage, type CmsApp, type CmsPlugin, Collection, Comment, CompanyDetails, Config, Contact, type CreateCmsAppOptions, type ERPPluginConfig, type ERPPluginInstance, ERPSubmissionService, type EmailData, type EmailJobPayload, type EmailPluginConfig, EmailService, type EmailServiceInterface, EmailTemplateName, EmailTemplateResult, EntityMap$1 as EntityMap, type ErpContactSyncInput, type ErpCreateContactPayload, type ErpJobPayload, type ErpPaidOrderDataSource, type ErpPaidOrderEntityMap, Form, FormField, FormSubmission, KnowledgeBaseChunk, KnowledgeBaseDocument, type LlmChatOptions, type LlmMessage, type LlmPluginConfig, LlmService, type LlmServiceInterface, type LocalStoragePluginConfig, type Logger, Media, MessageTemplate, Order, OrderItem, type OrderPlacedEmailPayload, OrderPlacedLineItem, OtpChallenge, type OtpChannel, type OtpPurpose, Page, PasswordResetToken, Payment, type PaymentIntent, type PaymentPluginConfig, type PaymentServiceInterface, Permission, type PipelineNames, type PluginContext, Product, ProductAttribute, ProductCategory, ProductTax, type QueuePluginConfig, type QueueService, type RenderEmailOptions, type RenderedEmail, type S3StoragePluginConfig, Seo, type SeoLike, type SeoMetadataOverrides, type SmsJobPayload, type SmsPluginConfig, type SmsProviderChoice, type SmsProviderId, type SmsServiceConfig, type SmsServiceInterface, StorageService, Tag, Tax, TemplateContext, User, UserGroup, Wishlist, WishlistItem, analyticsPlugin, assertCaptchaOk, buildCaptchaPublicConfig, cachePlugin, captchaPlugin, cn, countRecentOtpSends, createCmsApp, createOtpChallenge, emailPlugin, emailTemplates, erpPlugin, fetchSeoBySlug, formatDate, formatDateOnly, formatDateTime, generateNumericOtp, generateSlug, hashOtpCode, joinRecipientsForSend, linkUnclaimedContactToUser, llmPlugin, localStoragePlugin, mergeSeoBySlug, normalizePhoneE164, parseEmailRecipientsFromConfig, paymentPlugin, queueEmail, queueErp, queueErpCreateContactIfEnabled, queueErpPaidOrderForOrderId, queueOrderPlacedEmails, queuePlugin, queueSms, registerEmailQueueProcessor, registerErpQueueProcessor, registerSmsQueueProcessor, renderEmail, renderLayout, resolvePublicMetadata, s3StoragePlugin, serializeEmailRecipients, smsPlugin, truncateText, validateSlug, verifyAndConsumeOtpChallenge, verifyOtpCodeHash };
1420
+ export { Address, type AnalyticsPluginConfig, Attribute, Blog, Brand, CMS_ENTITY_MAP, type CachePluginConfig, type CacheService, type CaptchaProviderId, type CaptchaPublicConfig, CaptchaService, type CaptchaVerifyResult, Cart, CartItem, Category, ChatConversation, ChatMessage, type CmsApp, type CmsPlugin, Collection, Comment, CompanyDetails, Config, Contact, type CreateCmsAppOptions, type DataSourceManager, type ERPPluginConfig, type ERPPluginInstance, ERPSubmissionService, type EmailData, type EmailJobPayload, type EmailPluginConfig, EmailService, type EmailServiceInterface, EmailTemplateName, EmailTemplateResult, EntityMap$2 as EntityMap, type ErpContactSyncInput, type ErpCreateContactPayload, type ErpJobPayload, type ErpPaidOrderDataSource, type ErpPaidOrderEntityMap, type ExtraPublicWriteRule, Form, FormField, FormSubmission, KnowledgeBaseChunk, KnowledgeBaseDocument, type LlmChatOptions, type LlmMessage, type LlmPluginConfig, LlmService, type LlmServiceInterface, type LocalStoragePluginConfig, type Logger, Media, MessageTemplate, Order, OrderItem, type OrderPlacedEmailPayload, OrderPlacedLineItem, OtpChallenge, type OtpChannel, type OtpPurpose, Page, PasswordResetToken, Payment, type PaymentIntent, type PaymentPluginConfig, type PaymentServiceInterface, Permission, type PipelineNames, type PluginContext, Product, ProductAttribute, ProductCategory, ProductTax, type PublicThemeSettingsPayload, type QueuePluginConfig, type QueueService, type RenderEmailOptions, type RenderedEmail, type S3StoragePluginConfig, Seo, type SeoLike, type SeoMetadataOverrides, type SmsJobPayload, type SmsPluginConfig, type SmsProviderChoice, type SmsProviderId, type SmsServiceConfig, type SmsServiceInterface, StorageService, Tag, Tax, TemplateContext, User, UserGroup, Wishlist, WishlistItem, ZIP_MIME_TYPES, allowRateLimit, analyticsPlugin, assertCaptchaOk, buildCaptchaPublicConfig, cachePlugin, captchaPlugin, cn, countRecentOtpSends, createCmsApp, createDataSourceManager, createOtpChallenge, emailPlugin, emailTemplates, erpPlugin, fetchSeoBySlug, formatDate, formatDateOnly, formatDateTime, generateNumericOtp, generateSlug, hashOtpCode, isZipMedia, joinRecipientsForSend, linkUnclaimedContactToUser, llmPlugin, loadPublicThemeSettings, localStoragePlugin, mergeSeoBySlug, normalizePhoneE164, parseEmailRecipientsFromConfig, paymentPlugin, queueEmail, queueErp, queueErpCreateContactIfEnabled, queueErpPaidOrderForOrderId, queueOrderPlacedEmails, queuePlugin, queueSms, rateLimitCheckoutPost, rateLimitKeyForApiRequest, rateLimitPublicApiIfNeeded, registerEmailQueueProcessor, registerErpQueueProcessor, registerSmsQueueProcessor, relativePathFromMediaParentId, renderEmail, renderLayout, resolvePublicMetadata, s3StoragePlugin, sanitizeMediaFolderPath, sanitizeStorageSegment, seedDefaultAdmin, sendOrderPlacedEmailsAfterConfirmation, serializeEmailRecipients, shouldRateLimitPublicWrite, smsPlugin, truncateText, validateSlug, verifyAndConsumeOtpChallenge, verifyOtpCodeHash };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { C as CompanyDetails, T as TemplateContext, E as EmailTemplateResult, a as EmailTemplateName, O as OrderPlacedLineItem, S as StorageService, b as EntityMap$1 } from './index-BiagwMjV.js';
2
- export { A as AnalyticsHandlerConfig, c as AuthHandlersConfig, B as BlogBySlugConfig, d as ChangePasswordConfig, e as CmsApiHandlerConfig, f as CmsGetter, g as CrudHandlerOptions, D as DashboardStatsConfig, F as ForgotPasswordConfig, h as FormBySlugConfig, G as GetPublicSettingsGroupConfig, i as GetPublicSettingsGroupDataSource, I as InviteAcceptConfig, j as SetPasswordConfig, k as SettingsApiConfig, l as SocialLinkItem, m as StorefrontApiConfig, n as StorefrontOtpFlags, U as UploadHandlerConfig, o as UserAuthApiConfig, p as UserAvatarConfig, q as UserProfileConfig, r as UsersApiConfig, s as createAnalyticsHandlers, t as createBlogBySlugHandler, u as createChangePasswordHandler, v as createCmsApiHandler, w as createCrudByIdHandler, x as createCrudHandler, y as createDashboardStatsHandler, z as createForgotPasswordHandler, H as createFormBySlugHandler, J as createInviteAcceptHandler, K as createSetPasswordHandler, L as createSettingsApiHandlers, M as createStorefrontApiHandler, N as createUploadHandler, P as createUserAuthApiRouter, Q as createUserAvatarHandler, R as createUserProfileHandler, V as createUsersApiHandlers, W as getCompanyDetailsFromSettings, X as getPublicSettingsGroup, Y as mergeEmailLayoutCompanyDetails } from './index-BiagwMjV.js';
1
+ import { C as CompanyDetails, T as TemplateContext, E as EmailTemplateResult, a as EmailTemplateName, O as OrderPlacedLineItem, S as StorageService, b as EntityMap$2 } from './index-C85X7cc7.js';
2
+ export { A as AnalyticsHandlerConfig, c as AuthHandlersConfig, B as BlogBySlugConfig, d as ChangePasswordConfig, e as CmsApiHandlerConfig, f as CmsGetter, g as CrudHandlerOptions, D as DashboardStatsConfig, h as EcommerceAnalyticsConfig, F as ForgotPasswordConfig, i as FormBySlugConfig, G as GetPublicSettingsGroupConfig, j as GetPublicSettingsGroupDataSource, I as InviteAcceptConfig, k as SetPasswordConfig, l as SettingsApiConfig, m as SocialLinkItem, n as StorefrontApiConfig, o as StorefrontOtpFlags, U as UploadHandlerConfig, p as UserAuthApiConfig, q as UserAvatarConfig, r as UserProfileConfig, s as UsersApiConfig, t as createAnalyticsHandlers, u as createBlogBySlugHandler, v as createChangePasswordHandler, w as createCmsApiHandler, x as createCrudByIdHandler, y as createCrudHandler, z as createDashboardStatsHandler, H as createEcommerceAnalyticsHandler, J as createForgotPasswordHandler, K as createFormBySlugHandler, L as createInviteAcceptHandler, M as createMediaZipExtractHandler, N as createSetPasswordHandler, P as createSettingsApiHandlers, Q as createStorefrontApiHandler, R as createUploadHandler, V as createUserAuthApiRouter, W as createUserAvatarHandler, X as createUserProfileHandler, Y as createUsersApiHandlers, Z as getCompanyDetailsFromSettings, _ as getPublicSettingsGroup, $ as mergeEmailLayoutCompanyDetails } from './index-C85X7cc7.js';
3
3
  import { ClassValue } from 'clsx';
4
4
  import * as typeorm from 'typeorm';
5
5
  import { DataSource, EntityTarget, ObjectLiteral } from 'typeorm';
6
6
  import { Metadata } from 'next';
7
+ import { N as NavbarConfig, F as FooterConfig } from './types-D34wmivy.js';
7
8
  export { A as ADMIN_GROUP_NAME, a as AuthHelpers, E as EntityCrudAction, b as EntityPermissionFlags, G as GetSession, O as OPEN_ENDPOINTS, P as PERMISSION_REQUIRED_ENDPOINTS, R as RBAC_ADMIN_ONLY_ENTITIES, S as SessionUser, c as canManageRoles, d as createAuthHelpers, g as getPermissionableEntityKeys, e as getRequiredPermission, h as hasEntityPermission, i as isOpenEndpoint, f as isPublicMethod, j as isSuperAdminGroupName, p as permissionRowsToRecord, s as sessionHasEntityAccess } from './helpers-dlrF_49e.js';
8
9
  export { AuthorizeOtpInput, CmsMiddlewareConfig, NextAuthOptionsConfig, NextAuthUser, createCmsMiddleware, defaultPublicApiMethods, getNextAuthOptions, seedAdministratorPermissions } from './auth.js';
9
10
  export { A as AdminNavItem, D as DEFAULT_ADMIN_NAV } from './config-DJ5CmQvS.js';
@@ -630,7 +631,7 @@ type SeoMetadataOverrides = {
630
631
  };
631
632
  /** Per-field: join row wins over slug row. */
632
633
  declare function mergeSeoBySlug(join: SeoLike | null | undefined, bySlug: SeoLike | null): SeoLike | null;
633
- declare function fetchSeoBySlug(dataSource: DataSource, entityMap: EntityMap$1, slug: string): Promise<SeoLike | null>;
634
+ declare function fetchSeoBySlug(dataSource: DataSource, entityMap: EntityMap$2, slug: string): Promise<SeoLike | null>;
634
635
  /**
635
636
  * Build Next.js Metadata from merged SEO + optional layers.
636
637
  * `overrides` win over SEO; `fallbacks` apply when SEO (and overrides) omit a field.
@@ -638,7 +639,7 @@ declare function fetchSeoBySlug(dataSource: DataSource, entityMap: EntityMap$1,
638
639
  */
639
640
  declare function resolvePublicMetadata(args: {
640
641
  dataSource: DataSource;
641
- entityMap: EntityMap$1;
642
+ entityMap: EntityMap$2;
642
643
  slug: string;
643
644
  seoFromJoin?: SeoLike | null;
644
645
  overrides?: SeoMetadataOverrides;
@@ -664,9 +665,9 @@ declare function verifyOtpCodeHash(code: string, storedHash: string, purpose: st
664
665
  declare function generateNumericOtp(length?: number): string;
665
666
  /** Normalize to E.164-like +digits */
666
667
  declare function normalizePhoneE164(raw: string, defaultCountryCode?: string): string | null;
667
- type EntityMap = Record<string, EntityTarget<ObjectLiteral>>;
668
- declare function countRecentOtpSends(dataSource: DataSource, entityMap: EntityMap, purpose: OtpPurpose, identifier: string, since: Date): Promise<number>;
669
- declare function createOtpChallenge(dataSource: DataSource, entityMap: EntityMap, input: {
668
+ type EntityMap$1 = Record<string, EntityTarget<ObjectLiteral>>;
669
+ declare function countRecentOtpSends(dataSource: DataSource, entityMap: EntityMap$1, purpose: OtpPurpose, identifier: string, since: Date): Promise<number>;
670
+ declare function createOtpChallenge(dataSource: DataSource, entityMap: EntityMap$1, input: {
670
671
  purpose: OtpPurpose;
671
672
  channel: OtpChannel;
672
673
  identifier: string;
@@ -679,7 +680,7 @@ declare function createOtpChallenge(dataSource: DataSource, entityMap: EntityMap
679
680
  error: string;
680
681
  status: number;
681
682
  }>;
682
- declare function verifyAndConsumeOtpChallenge(dataSource: DataSource, entityMap: EntityMap, input: {
683
+ declare function verifyAndConsumeOtpChallenge(dataSource: DataSource, entityMap: EntityMap$1, input: {
683
684
  purpose: OtpPurpose;
684
685
  identifier: string;
685
686
  code: string;
@@ -692,6 +693,79 @@ declare function verifyAndConsumeOtpChallenge(dataSource: DataSource, entityMap:
692
693
  status: number;
693
694
  }>;
694
695
 
696
+ /** Returns true if request is allowed; false if rate limited. */
697
+ declare function allowRateLimit(key: string): Promise<boolean>;
698
+ type ExtraPublicWriteRule = (method: string, segments: string[]) => boolean;
699
+ /** Segments are path parts after `/api/` (e.g. `['form-submissions']`). */
700
+ declare function shouldRateLimitPublicWrite(method: string, segments: string[], extraRule?: ExtraPublicWriteRule): boolean;
701
+ declare function rateLimitKeyForApiRequest(req: Request, segments: string[]): string;
702
+ declare function rateLimitPublicApiIfNeeded(req: Request, method: string, segments: string[], options?: {
703
+ extraRule?: ExtraPublicWriteRule;
704
+ }): Promise<Response | null>;
705
+ declare function rateLimitCheckoutPost(req: Request): Promise<Response | null>;
706
+
707
+ interface EntityMapLike {
708
+ configs: unknown;
709
+ orders: unknown;
710
+ order_items: unknown;
711
+ }
712
+ interface SendOrderPlacedEmailDeps {
713
+ getDataSource: () => Promise<DataSource>;
714
+ entityMap: EntityMapLike;
715
+ getCms: () => Promise<CmsApp>;
716
+ }
717
+ /** After payment confirmation: email customer + each sales team address from plugin settings. */
718
+ declare function sendOrderPlacedEmailsAfterConfirmation(orderId: number, deps: SendOrderPlacedEmailDeps): Promise<void>;
719
+
720
+ interface DataSourceManager {
721
+ getDataSource: () => DataSource;
722
+ getDataSourceInitialized: () => Promise<DataSource>;
723
+ resetDataSource: () => void;
724
+ registerOnReset: (cb: () => void) => void;
725
+ isConnectionError: (e: unknown) => boolean;
726
+ }
727
+ declare function createDataSourceManager(entityMap: Record<string, unknown>, options?: {
728
+ databaseUrl?: string;
729
+ idleTimeoutMillis?: number;
730
+ }): DataSourceManager;
731
+
732
+ interface SeedEntityMap {
733
+ users: unknown;
734
+ user_groups: unknown;
735
+ }
736
+ declare function seedDefaultAdmin(ds: DataSource, entityMap: SeedEntityMap, opts?: {
737
+ email?: string;
738
+ password?: string;
739
+ }): Promise<void>;
740
+
741
+ interface PublicThemeSettingsPayload {
742
+ activeThemeId: string;
743
+ primaryColor: string;
744
+ secondaryColor: string;
745
+ navbarConfig: NavbarConfig;
746
+ footerOverrides: Partial<FooterConfig>;
747
+ }
748
+ declare function loadPublicThemeSettings(config: {
749
+ dataSource: DataSource;
750
+ entityMap: EntityMap$2;
751
+ encryptionKey?: string;
752
+ defaultActiveThemeId?: string;
753
+ defaultPrimaryColor?: string;
754
+ defaultSecondaryColor?: string;
755
+ }): Promise<PublicThemeSettingsPayload>;
756
+
757
+ /** Normalize a logical media folder path: no leading/trailing slashes, no ".." segments, max length. */
758
+ declare function sanitizeMediaFolderPath(input: unknown): string;
759
+ /** Single path segment for storage (folder name or legacy path segment). */
760
+ declare function sanitizeStorageSegment(name: string): string;
761
+
762
+ type EntityMap = Record<string, EntityTarget<ObjectLiteral>>;
763
+ /** Build `a/b/c` path under `uploads/` from the chain of folder rows up to root. */
764
+ declare function relativePathFromMediaParentId(dataSource: DataSource, entityMap: EntityMap, parentId: number | null): Promise<string>;
765
+
766
+ declare const ZIP_MIME_TYPES: Set<string>;
767
+ declare function isZipMedia(mime: string | null | undefined, filename: string): boolean;
768
+
695
769
  declare class Permission {
696
770
  id: number;
697
771
  groupId: number;
@@ -1239,9 +1313,13 @@ declare class MessageTemplate {
1239
1313
 
1240
1314
  declare class Media {
1241
1315
  id: number;
1316
+ kind: 'file' | 'folder';
1317
+ parentId: number | null;
1318
+ parent: Media | null;
1319
+ children: Media[];
1242
1320
  filename: string;
1243
- url: string;
1244
- mimeType: string;
1321
+ url: string | null;
1322
+ mimeType: string | null;
1245
1323
  size: number;
1246
1324
  alt: string | null;
1247
1325
  isPublic: boolean;
@@ -1339,4 +1417,4 @@ declare class Wishlist {
1339
1417
  /** Map API resource segment (e.g. "blogs", "form_submissions") to entity. Used by CRUD handler. */
1340
1418
  declare const CMS_ENTITY_MAP: Record<string, EntityTarget<typeorm.ObjectLiteral>>;
1341
1419
 
1342
- export { type AnalyticsPluginConfig, Attribute, Blog, Brand, CMS_ENTITY_MAP, type CachePluginConfig, type CacheService, type CaptchaProviderId, type CaptchaPublicConfig, CaptchaService, type CaptchaVerifyResult, Cart, CartItem, Category, ChatConversation, ChatMessage, type CmsApp, type CmsPlugin, Collection, Comment, CompanyDetails, Config, Contact, type CreateCmsAppOptions, type ERPPluginConfig, type ERPPluginInstance, ERPSubmissionService, type EmailData, type EmailJobPayload, type EmailPluginConfig, EmailService, type EmailServiceInterface, EmailTemplateName, EmailTemplateResult, EntityMap$1 as EntityMap, type ErpContactSyncInput, type ErpCreateContactPayload, type ErpJobPayload, type ErpPaidOrderDataSource, type ErpPaidOrderEntityMap, Form, FormField, FormSubmission, KnowledgeBaseChunk, KnowledgeBaseDocument, type LlmChatOptions, type LlmMessage, type LlmPluginConfig, LlmService, type LlmServiceInterface, type LocalStoragePluginConfig, type Logger, Media, MessageTemplate, Order, OrderItem, type OrderPlacedEmailPayload, OrderPlacedLineItem, OtpChallenge, type OtpChannel, type OtpPurpose, Page, PasswordResetToken, Payment, type PaymentIntent, type PaymentPluginConfig, type PaymentServiceInterface, Permission, type PipelineNames, type PluginContext, Product, ProductAttribute, ProductCategory, ProductTax, type QueuePluginConfig, type QueueService, type RenderEmailOptions, type RenderedEmail, type S3StoragePluginConfig, Seo, type SeoLike, type SeoMetadataOverrides, type SmsJobPayload, type SmsPluginConfig, type SmsProviderChoice, type SmsProviderId, type SmsServiceConfig, type SmsServiceInterface, StorageService, Tag, Tax, TemplateContext, User, UserGroup, Wishlist, WishlistItem, analyticsPlugin, assertCaptchaOk, buildCaptchaPublicConfig, cachePlugin, captchaPlugin, cn, countRecentOtpSends, createCmsApp, createOtpChallenge, emailPlugin, emailTemplates, erpPlugin, fetchSeoBySlug, formatDate, formatDateOnly, formatDateTime, generateNumericOtp, generateSlug, hashOtpCode, joinRecipientsForSend, linkUnclaimedContactToUser, llmPlugin, localStoragePlugin, mergeSeoBySlug, normalizePhoneE164, parseEmailRecipientsFromConfig, paymentPlugin, queueEmail, queueErp, queueErpCreateContactIfEnabled, queueErpPaidOrderForOrderId, queueOrderPlacedEmails, queuePlugin, queueSms, registerEmailQueueProcessor, registerErpQueueProcessor, registerSmsQueueProcessor, renderEmail, renderLayout, resolvePublicMetadata, s3StoragePlugin, serializeEmailRecipients, smsPlugin, truncateText, validateSlug, verifyAndConsumeOtpChallenge, verifyOtpCodeHash };
1420
+ export { Address, type AnalyticsPluginConfig, Attribute, Blog, Brand, CMS_ENTITY_MAP, type CachePluginConfig, type CacheService, type CaptchaProviderId, type CaptchaPublicConfig, CaptchaService, type CaptchaVerifyResult, Cart, CartItem, Category, ChatConversation, ChatMessage, type CmsApp, type CmsPlugin, Collection, Comment, CompanyDetails, Config, Contact, type CreateCmsAppOptions, type DataSourceManager, type ERPPluginConfig, type ERPPluginInstance, ERPSubmissionService, type EmailData, type EmailJobPayload, type EmailPluginConfig, EmailService, type EmailServiceInterface, EmailTemplateName, EmailTemplateResult, EntityMap$2 as EntityMap, type ErpContactSyncInput, type ErpCreateContactPayload, type ErpJobPayload, type ErpPaidOrderDataSource, type ErpPaidOrderEntityMap, type ExtraPublicWriteRule, Form, FormField, FormSubmission, KnowledgeBaseChunk, KnowledgeBaseDocument, type LlmChatOptions, type LlmMessage, type LlmPluginConfig, LlmService, type LlmServiceInterface, type LocalStoragePluginConfig, type Logger, Media, MessageTemplate, Order, OrderItem, type OrderPlacedEmailPayload, OrderPlacedLineItem, OtpChallenge, type OtpChannel, type OtpPurpose, Page, PasswordResetToken, Payment, type PaymentIntent, type PaymentPluginConfig, type PaymentServiceInterface, Permission, type PipelineNames, type PluginContext, Product, ProductAttribute, ProductCategory, ProductTax, type PublicThemeSettingsPayload, type QueuePluginConfig, type QueueService, type RenderEmailOptions, type RenderedEmail, type S3StoragePluginConfig, Seo, type SeoLike, type SeoMetadataOverrides, type SmsJobPayload, type SmsPluginConfig, type SmsProviderChoice, type SmsProviderId, type SmsServiceConfig, type SmsServiceInterface, StorageService, Tag, Tax, TemplateContext, User, UserGroup, Wishlist, WishlistItem, ZIP_MIME_TYPES, allowRateLimit, analyticsPlugin, assertCaptchaOk, buildCaptchaPublicConfig, cachePlugin, captchaPlugin, cn, countRecentOtpSends, createCmsApp, createDataSourceManager, createOtpChallenge, emailPlugin, emailTemplates, erpPlugin, fetchSeoBySlug, formatDate, formatDateOnly, formatDateTime, generateNumericOtp, generateSlug, hashOtpCode, isZipMedia, joinRecipientsForSend, linkUnclaimedContactToUser, llmPlugin, loadPublicThemeSettings, localStoragePlugin, mergeSeoBySlug, normalizePhoneE164, parseEmailRecipientsFromConfig, paymentPlugin, queueEmail, queueErp, queueErpCreateContactIfEnabled, queueErpPaidOrderForOrderId, queueOrderPlacedEmails, queuePlugin, queueSms, rateLimitCheckoutPost, rateLimitKeyForApiRequest, rateLimitPublicApiIfNeeded, registerEmailQueueProcessor, registerErpQueueProcessor, registerSmsQueueProcessor, relativePathFromMediaParentId, renderEmail, renderLayout, resolvePublicMetadata, s3StoragePlugin, sanitizeMediaFolderPath, sanitizeStorageSegment, seedDefaultAdmin, sendOrderPlacedEmailsAfterConfirmation, serializeEmailRecipients, shouldRateLimitPublicWrite, smsPlugin, truncateText, validateSlug, verifyAndConsumeOtpChallenge, verifyOtpCodeHash };