@infuro/cms-core 1.0.31 → 1.0.34

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.
Files changed (41) hide show
  1. package/README.md +12 -8
  2. package/dist/admin.cjs +1907 -1144
  3. package/dist/admin.cjs.map +1 -1
  4. package/dist/admin.d.cts +7 -2
  5. package/dist/admin.d.ts +7 -2
  6. package/dist/admin.js +1955 -1191
  7. package/dist/admin.js.map +1 -1
  8. package/dist/api.cjs +2704 -914
  9. package/dist/api.cjs.map +1 -1
  10. package/dist/api.d.cts +1 -1
  11. package/dist/api.d.ts +1 -1
  12. package/dist/api.js +2664 -875
  13. package/dist/api.js.map +1 -1
  14. package/dist/auth.cjs +251 -23
  15. package/dist/auth.cjs.map +1 -1
  16. package/dist/auth.d.cts +53 -22
  17. package/dist/auth.d.ts +53 -22
  18. package/dist/auth.js +240 -23
  19. package/dist/auth.js.map +1 -1
  20. package/dist/cli.cjs +42 -2
  21. package/dist/cli.cjs.map +1 -1
  22. package/dist/cli.js +42 -2
  23. package/dist/cli.js.map +1 -1
  24. package/dist/{index-BcMRGNjS.d.cts → index-Bf5GO8fu.d.cts} +4 -3
  25. package/dist/{index-Bda8D1Rm.d.ts → index-DOiJuMQA.d.ts} +4 -3
  26. package/dist/index.cjs +3408 -1284
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +121 -35
  29. package/dist/index.d.ts +121 -35
  30. package/dist/index.js +3334 -1226
  31. package/dist/index.js.map +1 -1
  32. package/dist/migrations/1778660000003-AddQrTokenToOrders.ts +32 -0
  33. package/dist/migrations/1778660000004-CreateCustomerAndCustomerContacts.ts +99 -0
  34. package/dist/migrations/1778660000005-AddCustomerIdToVendorCustomers.ts +39 -0
  35. package/dist/migrations/1778660000006-UpdateVendorCustomersContactNullable.ts +36 -0
  36. package/dist/migrations/1778660000007-VendorOwnerCustomerContactsPermission.ts +39 -0
  37. package/dist/migrations/1779100000000-ChatConversationLeadEmailSent.ts +16 -0
  38. package/dist/migrations/1779200000000-LlmAgentScope.ts +72 -0
  39. package/dist/migrations/1779300000000-VendorOwnerContactsPermission.ts +39 -0
  40. package/dist/migrations/1779400000000-AddCustomerContactIdToOrders.ts +33 -0
  41. package/package.json +5 -3
package/dist/index.d.cts CHANGED
@@ -1,16 +1,17 @@
1
- import { e as CompanyDetails, T as TemplateContext, h as EmailTemplateResult, g as EmailTemplateName, O as OrderPlacedLineItem, o as StorageService, i as EntityMap$2 } from './index-BcMRGNjS.cjs';
2
- export { A as AnalyticsHandlerConfig, a as AuthHandlersConfig, B as BlogBySlugConfig, C as ChangePasswordConfig, b as ChatPublicConfig, c as CmsApiHandlerConfig, d as CmsGetter, f as CrudHandlerOptions, D as DashboardStatsConfig, E as EcommerceAnalyticsConfig, F as ForgotPasswordConfig, j as FormBySlugConfig, G as GetPublicSettingsGroupConfig, k as GetPublicSettingsGroupDataSource, I as InviteAcceptConfig, J as JobScheduleApiConfig, L as LlmAgentKnowledgeApiConfig, l as LlmAgentValidationRulesJson, P as ParsedLlmAgentValidation, S as SetPasswordConfig, m as SettingsApiConfig, n as SocialLinkItem, p as StorefrontApiConfig, q as StorefrontOtpFlags, U as UploadHandlerConfig, r as UserAuthApiConfig, s as UserAvatarConfig, t as UserProfileConfig, u as UsersApiConfig, V as VendorOnboardHandlersConfig, v as VendorOwnerActivation, w as createAnalyticsHandlers, x as createBlogBySlugHandler, y as createChangePasswordHandler, z as createCmsApiHandler, H as createCrudByIdHandler, K as createCrudHandler, M as createDashboardStatsHandler, N as createEcommerceAnalyticsHandler, Q as createForgotPasswordHandler, R as createFormBySlugHandler, W as createInviteAcceptHandler, X as createJobScheduleHandlers, Y as createLlmAgentKnowledgeHandlers, Z as createMediaZipExtractHandler, _ as createSetPasswordHandler, $ as createSettingsApiHandlers, a0 as createStorefrontApiHandler, a1 as createUploadHandler, a2 as createUserAuthApiRouter, a3 as createUserAvatarHandler, a4 as createUserProfileHandler, a5 as createUsersApiHandlers, a6 as createVendorOnboardHandlers, a7 as getCompanyDetailsFromSettings, a8 as getPublicSettingsGroup, a9 as mergeEmailLayoutCompanyDetails, aa as mergeGuardrailsIntoSystemPrompt, ab as parseLlmAgentValidationRules, ac as simpleDecrypt, ad as simpleEncrypt, ae as validateUserMessageAgainstAgentRules, af as validateUserMessageAgainstStructuredRules } from './index-BcMRGNjS.cjs';
1
+ import { e as CompanyDetails, T as TemplateContext, h as EmailTemplateResult, g as EmailTemplateName, O as OrderPlacedLineItem, o as StorageService, i as EntityMap$2 } from './index-Bf5GO8fu.cjs';
2
+ export { A as AnalyticsHandlerConfig, a as AuthHandlersConfig, B as BlogBySlugConfig, C as ChangePasswordConfig, b as ChatPublicConfig, c as CmsApiHandlerConfig, d as CmsGetter, f as CrudHandlerOptions, D as DashboardStatsConfig, E as EcommerceAnalyticsConfig, F as ForgotPasswordConfig, j as FormBySlugConfig, G as GetPublicSettingsGroupConfig, k as GetPublicSettingsGroupDataSource, I as InviteAcceptConfig, J as JobScheduleApiConfig, L as LlmAgentKnowledgeApiConfig, l as LlmAgentValidationRulesJson, P as ParsedLlmAgentValidation, S as SetPasswordConfig, m as SettingsApiConfig, n as SocialLinkItem, p as StorefrontApiConfig, q as StorefrontOtpFlags, U as UploadHandlerConfig, r as UserAuthApiConfig, s as UserAvatarConfig, t as UserProfileConfig, u as UsersApiConfig, V as VendorOnboardHandlersConfig, v as VendorOwnerActivation, w as createAnalyticsHandlers, x as createBlogBySlugHandler, y as createChangePasswordHandler, z as createCmsApiHandler, H as createCrudByIdHandler, K as createCrudHandler, M as createDashboardStatsHandler, N as createEcommerceAnalyticsHandler, Q as createForgotPasswordHandler, R as createFormBySlugHandler, W as createInviteAcceptHandler, X as createJobScheduleHandlers, Y as createLlmAgentKnowledgeHandlers, Z as createMediaZipExtractHandler, _ as createSetPasswordHandler, $ as createSettingsApiHandlers, a0 as createStorefrontApiHandler, a1 as createUploadHandler, a2 as createUserAuthApiRouter, a3 as createUserAvatarHandler, a4 as createUserProfileHandler, a5 as createUsersApiHandlers, a6 as createVendorOnboardHandlers, a7 as getCompanyDetailsFromSettings, a8 as getPublicSettingsGroup, a9 as mergeEmailLayoutCompanyDetails, aa as mergeGuardrailsIntoSystemPrompt, ab as parseLlmAgentValidationRules, ac as simpleDecrypt, ad as simpleEncrypt, ae as validateUserMessageAgainstAgentRules, af as validateUserMessageAgainstStructuredRules } from './index-Bf5GO8fu.cjs';
3
3
  import PgBoss from 'pg-boss';
4
4
  import * as typeorm from 'typeorm';
5
5
  import { DataSource, EntityTarget, ObjectLiteral, SelectQueryBuilder } from 'typeorm';
6
6
  import { ClassValue } from 'clsx';
7
7
  import { Metadata } from 'next';
8
8
  import { NextAuthUser } from './auth.cjs';
9
- export { AuthorizeOtpInput, CmsMiddlewareConfig, NextAuthOptionsConfig, createCmsMiddleware, defaultPublicApiMethods, explainSessionEntityAccess, getNextAuthOptions, isRbacDebugEnabled, logEntityAccessDecision, logRbac, seedAdministratorPermissions, summarizeEntityPerms } from './auth.cjs';
9
+ export { AuthorizeOtpInput, CmsMiddlewareConfig, CmsMiddlewareRequest, NextAuthOptionsConfig, SUPER_ADMIN_GROUP_ID, VENDOR_ADMIN_GROUP_ID, createCmsMiddleware, defaultPublicApiMethods, explainSessionEntityAccess, getNextAuthOptions, getStorefrontNextAuthOptions, isAuthDebugClientEnabled, isAuthDebugEnabled, isRbacDebugEnabled, isSuperAdmin, isVendorAdmin, logAuth, logAuthClient, logEntityAccessDecision, logRbac, nextAuthCookieDebugInfo, seedAdministratorPermissions, summarizeEntityPerms, summarizeSessionUserForLog } from './auth.cjs';
10
10
  import { E as EntityCrudAction, S as SessionUser, e as VendorScope } from './vendor-scope-DTYhJk_I.cjs';
11
11
  export { A as ADMIN_GROUP_NAME, a as AuthHelpers, b as EntityPermissionFlags, G as GetSession, O as OPEN_ENDPOINTS, P as PERMISSION_REQUIRED_ENDPOINTS, R as RBAC_ADMIN_ONLY_ENTITIES, V as VENDOR_OWNER_GROUP_NAME, c as VENDOR_SCOPED_STORE_ENTITIES, d as VENDOR_STORE_RBAC_ENTITIES, f as canManageRoles, g as canManageVendorRoles, h as canManageVendorTeam, i as canOnboardVendors, j as createAuthHelpers, k as createCmsAuthBundle, l as getPermissionableEntityKeys, m as getRequiredPermission, n as hasEntityPermission, o as isOpenEndpoint, p as isPlatformAdministrator, q as isPublicMethod, r as isSuperAdminGroupName, s as isVendorGroupName, t as isVendorOwner, u as isVendorPortalUser, v as isVendorStaff, w as permissionRowsToRecord, x as resolveVendorScopeFromSessionUser, y as sessionHasEntityAccess, z as vendorPortalFlagsFromUser } from './vendor-scope-DTYhJk_I.cjs';
12
12
  import { a as NavbarConfig, F as FooterConfig } from './types-DCVaXlPV.cjs';
13
13
  export { A as AdminNavItem, D as DEFAULT_ADMIN_NAV } from './config-DJ5CmQvS.cjs';
14
+ import 'next-auth/jwt';
14
15
  import 'next-auth';
15
16
 
16
17
  interface PluginContext {
@@ -219,6 +220,7 @@ interface EmailPluginConfig$1 {
219
220
  port?: number;
220
221
  secure?: boolean;
221
222
  region?: string;
223
+ /** IAM keys for SES API (SendEmail). Not the same as SES SMTP credentials in SMTP_USER/SMTP_PASSWORD. */
222
224
  accessKeyId?: string;
223
225
  secretAccessKey?: string;
224
226
  templateOptions?: RenderEmailOptions;
@@ -243,9 +245,13 @@ declare class EmailService implements EmailServiceInterface {
243
245
  private templateOptions?;
244
246
  private sesClient?;
245
247
  private transporter?;
248
+ /** AWS via SMTP (nodemailer) vs SES API SDK. */
249
+ private awsViaSmtp;
246
250
  constructor(config: EmailPluginConfig$1);
247
251
  send(emailData: EmailData): Promise<boolean>;
248
252
  renderTemplate(templateName: EmailTemplateName, ctx: TemplateContext<unknown>): RenderedEmail;
253
+ /** Default notification recipient from plugin config (SMTP_TO / plugin `to`). */
254
+ getDefaultTo(): string;
249
255
  }
250
256
  declare const emailTemplates: {
251
257
  formSubmission: (data: {
@@ -316,6 +322,21 @@ interface OrderPlacedEmailPayload {
316
322
  }
317
323
  /** Queues one `orderPlaced` email per recipient (customer + each unique sales address; skips sales if same as customer). */
318
324
  declare function queueOrderPlacedEmails(cms: CmsAppLike$2, payload: OrderPlacedEmailPayload): Promise<void>;
325
+ interface VendorOnboardEmailPayload {
326
+ vendorName: string;
327
+ vendorSlug?: string;
328
+ ownerName: string;
329
+ ownerEmail: string;
330
+ activation: 'invite' | 'password';
331
+ inviteLink?: string;
332
+ signInLink: string;
333
+ kind?: 'vendor_onboard' | 'team_invite';
334
+ notifyEmails: string[];
335
+ companyDetails: CompanyDetails;
336
+ sendToOwner?: boolean;
337
+ }
338
+ /** Queues `vendorOnboarded` email to owner and each unique notify address (sales team settings). */
339
+ declare function queueVendorOnboardEmails(cms: CmsAppLike$2, payload: VendorOnboardEmailPayload): Promise<void>;
319
340
 
320
341
  interface EmailPluginConfig {
321
342
  type: 'AWS' | 'SMTP' | 'GMAIL' | 'SENDGRID';
@@ -615,6 +636,38 @@ declare class LlmService implements LlmServiceInterface {
615
636
  streamChat(messages: LlmMessage[], options?: LlmChatOptions): AsyncIterable<string>;
616
637
  }
617
638
 
639
+ declare class LlmAgent {
640
+ id: number;
641
+ name: string;
642
+ /** Stable key for API / widgets (e.g. `support`, `sales`). */
643
+ slug: string;
644
+ /**
645
+ * Logical role for this agent (`chatbot`, `blog_creation`, `social_media_post`, `email_intent_chatbot`, …).
646
+ * At most one active row per scope; resolve agents by scope in application code.
647
+ */
648
+ scope: string | null;
649
+ /** Passed as `systemPrompt` to `LlmService.chatAgent`. */
650
+ systemInstruction: string;
651
+ model: string | null;
652
+ temperature: number | null;
653
+ maxTokens: number | null;
654
+ /**
655
+ * Rules string: plain prose → appended to system prompt as output guardrails; JSON → see `parseLlmAgentValidationRules` in cms-handlers
656
+ * (structural checks + optional `guardrails` / `outputRules` / `outputInstructions` for the model).
657
+ */
658
+ validationRules: string | null;
659
+ enabled: boolean;
660
+ createdAt: Date;
661
+ updatedAt: Date;
662
+ deletedAt: Date | null;
663
+ deleted: boolean;
664
+ createdBy: number | null;
665
+ updatedBy: number | null;
666
+ deletedBy: number | null;
667
+ }
668
+ /** Partial {@link LlmAgentOptions} for merging with `userPrompt` / `history` / `context`. */
669
+ declare function llmAgentToChatAgentOptions(agent: LlmAgent): Pick<LlmAgentOptions, 'systemPrompt' | 'model' | 'temperature' | 'max_tokens'>;
670
+
618
671
  interface LlmPluginConfig {
619
672
  baseURL?: string;
620
673
  apiKey?: string;
@@ -1176,19 +1229,47 @@ declare function rateLimitPublicApiIfNeeded(req: Request, method: string, segmen
1176
1229
  }): Promise<Response | null>;
1177
1230
  declare function rateLimitCheckoutPost(req: Request): Promise<Response | null>;
1178
1231
 
1179
- interface EntityMapLike {
1232
+ interface EntityMapLike$1 {
1180
1233
  configs: unknown;
1181
1234
  orders: unknown;
1182
1235
  order_items: unknown;
1183
1236
  }
1184
1237
  interface SendOrderPlacedEmailDeps {
1185
1238
  getDataSource: () => Promise<DataSource>;
1186
- entityMap: EntityMapLike;
1239
+ entityMap: EntityMapLike$1;
1187
1240
  getCms: () => Promise<CmsApp>;
1188
1241
  }
1189
1242
  /** After payment confirmation: email customer + each sales team address from plugin settings. */
1190
1243
  declare function sendOrderPlacedEmailsAfterConfirmation(orderId: number, deps: SendOrderPlacedEmailDeps): Promise<void>;
1191
1244
 
1245
+ type VendorOnboardedActivation = 'invite' | 'password';
1246
+ type VendorOnboardedKind = 'vendor_onboard' | 'team_invite';
1247
+
1248
+ interface EntityMapLike {
1249
+ configs: unknown;
1250
+ }
1251
+ interface SendVendorOnboardEmailInput {
1252
+ vendorName: string;
1253
+ vendorSlug?: string;
1254
+ ownerName: string;
1255
+ ownerEmail: string;
1256
+ activation: VendorOnboardedActivation;
1257
+ inviteLink?: string;
1258
+ signInLink: string;
1259
+ kind?: VendorOnboardedKind;
1260
+ /** When false, skips owner email but still notifies internal recipients. Default true. */
1261
+ sendToOwner?: boolean;
1262
+ }
1263
+ interface SendVendorOnboardEmailDeps {
1264
+ getDataSource: () => Promise<DataSource>;
1265
+ entityMap: EntityMapLike;
1266
+ getCms: () => Promise<CmsAppLike$2>;
1267
+ }
1268
+ /** After vendor onboard / team invite: email owner + platform team from plugin settings. */
1269
+ declare function sendVendorOnboardEmails(input: SendVendorOnboardEmailInput, deps: SendVendorOnboardEmailDeps): Promise<{
1270
+ ownerEmailSent: boolean;
1271
+ }>;
1272
+
1192
1273
  interface DataSourceManager {
1193
1274
  getDataSource: () => DataSource;
1194
1275
  getDataSourceInitialized: () => Promise<DataSource>;
@@ -1799,14 +1880,41 @@ declare class OrderAddresses {
1799
1880
  shippingOrders: Order[];
1800
1881
  }
1801
1882
 
1883
+ declare class Customer {
1884
+ id: number;
1885
+ userId: number;
1886
+ user: User | null;
1887
+ name: string;
1888
+ email: string;
1889
+ phone: string;
1890
+ createdAt: Date;
1891
+ updatedAt: Date;
1892
+ deletedAt: Date | null;
1893
+ deleted: boolean;
1894
+ createdBy: number | null;
1895
+ updatedBy: number | null;
1896
+ deletedBy: number | null;
1897
+ }
1898
+
1899
+ declare class Customer_Contacts {
1900
+ id: number;
1901
+ customerId: number;
1902
+ customer: Customer;
1903
+ contactId: number;
1904
+ contact: Contact;
1905
+ }
1906
+
1802
1907
  type OrderKind = 'sale' | 'return' | 'replacement';
1803
1908
  declare class Order {
1804
1909
  id: number;
1805
1910
  vendorId: number;
1806
1911
  orderNumber: string;
1912
+ qrToken: string | null;
1807
1913
  orderKind: OrderKind;
1808
1914
  parentOrderId: number | null;
1809
1915
  contactId: number;
1916
+ /** Junction row linking the account customer to the checkout contact (storefront checkout). */
1917
+ customerContactId: number | null;
1810
1918
  billingAddressId: number | null;
1811
1919
  shippingAddressId: number | null;
1812
1920
  status: 'pending' | 'confirmed' | 'processing' | 'completed' | 'cancelled';
@@ -1827,6 +1935,7 @@ declare class Order {
1827
1935
  parentOrder: Order | null;
1828
1936
  children: Order[];
1829
1937
  contact: Contact;
1938
+ customerContact: Customer_Contacts | null;
1830
1939
  billingAddress: OrderAddresses | null;
1831
1940
  shippingAddress: OrderAddresses | null;
1832
1941
  items: OrderItem[];
@@ -1847,6 +1956,8 @@ declare class ChatConversation {
1847
1956
  contactId: number;
1848
1957
  createdAt: Date;
1849
1958
  updatedAt: Date;
1959
+ /** Set when a chat lead email was sent for this conversation (intent tool). */
1960
+ leadEmailSentAt: Date | null;
1850
1961
  contact: Contact;
1851
1962
  messages: ChatMessage[];
1852
1963
  }
@@ -2015,33 +2126,6 @@ declare class Wishlist {
2015
2126
  items: WishlistItem[];
2016
2127
  }
2017
2128
 
2018
- declare class LlmAgent {
2019
- id: number;
2020
- name: string;
2021
- /** Stable key for API / widgets (e.g. `support`, `sales`). */
2022
- slug: string;
2023
- /** Passed as `systemPrompt` to `LlmService.chatAgent`. */
2024
- systemInstruction: string;
2025
- model: string | null;
2026
- temperature: number | null;
2027
- maxTokens: number | null;
2028
- /**
2029
- * Rules string: plain prose → appended to system prompt as output guardrails; JSON → see `parseLlmAgentValidationRules` in cms-handlers
2030
- * (structural checks + optional `guardrails` / `outputRules` / `outputInstructions` for the model).
2031
- */
2032
- validationRules: string | null;
2033
- enabled: boolean;
2034
- createdAt: Date;
2035
- updatedAt: Date;
2036
- deletedAt: Date | null;
2037
- deleted: boolean;
2038
- createdBy: number | null;
2039
- updatedBy: number | null;
2040
- deletedBy: number | null;
2041
- }
2042
- /** Partial {@link LlmAgentOptions} for merging with `userPrompt` / `history` / `context`. */
2043
- declare function llmAgentToChatAgentOptions(agent: LlmAgent): Pick<LlmAgentOptions, 'systemPrompt' | 'model' | 'temperature' | 'max_tokens'>;
2044
-
2045
2129
  declare class Currency {
2046
2130
  id: number;
2047
2131
  code: string;
@@ -2200,7 +2284,8 @@ declare class RssFeed {
2200
2284
  declare class VendorCustomer {
2201
2285
  id: number;
2202
2286
  vendorId: number;
2203
- contactId: number;
2287
+ contactId: number | null;
2288
+ customerId: number;
2204
2289
  /** Optional vendor-specific notes about this customer. */
2205
2290
  notes: string | null;
2206
2291
  /** Optional vendor-specific tags/labels. */
@@ -2208,10 +2293,11 @@ declare class VendorCustomer {
2208
2293
  createdAt: Date;
2209
2294
  updatedAt: Date;
2210
2295
  vendor: Vendor;
2211
- contact: Contact;
2296
+ contact: Contact | null;
2297
+ customer: Customer;
2212
2298
  }
2213
2299
 
2214
2300
  /** Map API resource segment (e.g. "blogs", "form_submissions") to entity. Used by CRUD handler. */
2215
2301
  declare const CMS_ENTITY_MAP: Record<string, EntityTarget<typeorm.ObjectLiteral>>;
2216
2302
 
2217
- export { Address, type AnalyticsPluginConfig, Attribute, BLOG_GENERATOR_AGENT_NAME, BLOG_GENERATOR_DEFAULT_SYSTEM_INSTRUCTION, BLOG_GENERATOR_DEFAULT_VALIDATION_RULES, BLOG_GENERATOR_LLM_AGENT_SLUG, BLOG_GENERATOR_MARKDOWN_ARTICLE_SEPARATOR, BLOG_METADATA_ENRICHER_AGENT_NAME, BLOG_METADATA_ENRICHER_DEFAULT_SYSTEM_INSTRUCTION, BLOG_METADATA_ENRICHER_DEFAULT_VALIDATION_RULES, BLOG_METADATA_ENRICHER_LLM_AGENT_SLUG, Blog, type BlogGeneratorBlogDraft, type BlogGeneratorDraftParseMode, type BlogGeneratorPluginConfig, type BlogGeneratorSeoDraft, BlogGeneratorService, 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, Currency, CurrencyExchange, type DataSourceManager, Discount, DiscountRules, type ERPPluginConfig, type ERPPluginInstance, ERPSubmissionService, type EmailData, type EmailJobPayload, type EmailPluginConfig, EmailService, type EmailServiceInterface, EmailTemplateName, EmailTemplateResult, EntityCrudAction, EntityMap$2 as EntityMap, type ErpContactSyncInput, type ErpCreateContactPayload, type ErpJobPayload, type ErpPaidOrderDataSource, type ErpPaidOrderEntityMap, type ExtraPublicWriteRule, type FacebookMeAccountsResponse, type FacebookPageAccount, Form, FormField, FormSubmission, JOB_RUNNER_QUEUE, type CmsAppLike as JobRunnerCmsAppLike, type JobRunnerDeps, type JobRunnerPayload, JobSchedule, JobScheduleRun, KnowledgeBaseChunk, KnowledgeBaseDocument, type LatestArticleFromFeed, LlmAgent, type LlmAgentOptions, type LlmChatOptions, type LlmEmbeddingProvider, type LlmMessage, type LlmPluginConfig, LlmService, type LlmServiceEmbedOptions, type LlmServiceInterface, type LocalStoragePluginConfig, type Logger, Media, MessageTemplate, type MetaGraphMutationResponse, NextAuthUser, Order, OrderAddresses, OrderDiscounts, OrderItem, type OrderPlacedEmailPayload, OrderPlacedLineItem, OtpChallenge, type OtpChannel, type OtpPurpose, Page, PasswordResetToken, Payment, type PaymentIntent, type PaymentPluginConfig, type PaymentServiceInterface, Permission, type PgBossPluginConfig, PgBossService, type PipelineNames, type PluginContext, Product, ProductAttribute, ProductCategory, ProductTax, type PublicThemeSettingsPayload, type QueuePluginConfig, type QueueService, type RenderEmailOptions, type RenderedEmail, RssArticle, RssFeed, type S3StoragePluginConfig, Seo, type SeoLike, type SeoMetadataOverrides, SessionUser, type SmsJobPayload, type SmsPluginConfig, type SmsProviderChoice, type SmsProviderId, type SmsServiceConfig, type SmsServiceInterface, type SocialMediaPluginConfig, StorageService, Tag, Tax, TemplateContext, User, UserGroup, Vendor, VendorCustomer, VendorUser, Wishlist, WishlistItem, ZIP_MIME_TYPES, allowRateLimit, analyticsPlugin, applyVendorCustomersContactFilter, assertCaptchaOk, assertContactAllowedForVendorOrder, blogGeneratorPlugin, buildBlogMetadataUserPrompt, buildCaptchaPublicConfig, buildCronFromSchedule, buildRssUserPromptFromFeeds, cachePlugin, captchaPlugin, cn, contactIsVendorCustomer, countRecentOtpSends, createCmsApp, createDataSourceManager, createOtpChallenge, createSocialMediaHandlers, emailPlugin, emailTemplates, enrichUserWithVendorContext, ensureScheduleQueueWorker, erpPlugin, fetchSeoBySlug, formatDate, formatDateOnly, formatDateTime, generateNumericOtp, generateSlug, getRssArticleSummaryFromItem, hashOtpCode, hydrateVendorSessionUser, isCustomerTypeContact, isZipMedia, joinRecipientsForSend, linkUnclaimedContactToUser, llmAgentToChatAgentOptions, llmPlugin, loadPublicThemeSettings, loadUserVendorContext, localStoragePlugin, mergeSeoBySlug, metaFetchUserManagedPages, metaPostPageFeed, metaPostPagePhoto, metaResolvePageAccessToken, normalizePhoneE164, parseBlogGeneratorAgentContent, parseBlogGeneratorModelOutput, parseBlogMetadataEnrichmentJson, parseEmailRecipientsFromConfig, parseHfInferenceEmbeddingBody, paymentPlugin, pgBossPlugin, pgBossScheduleNameForId, queueEmail, queueErp, queueErpCreateContactIfEnabled, queueErpPaidOrderForOrderId, queueJobScheduleNow, queueOrderPlacedEmails, queuePlugin, queueSms, rateLimitCheckoutPost, rateLimitKeyForApiRequest, rateLimitPublicApiIfNeeded, registerEmailQueueProcessor, registerErpQueueProcessor, registerJobRunnerWorker, registerSmsQueueProcessor, relativePathFromMediaParentId, renderEmail, renderLayout, resolveBlogCategoryIdByName, resolvePublicMetadata, resolveVendorIdForContactCheck, s3StoragePlugin, sanitizeMediaFolderPath, sanitizeStorageSegment, seedDefaultAdmin, sendOrderPlacedEmailsAfterConfirmation, serializeEmailRecipients, shouldRateLimitPublicWrite, smsPlugin, socialMediaPlugin, syncJobScheduleToPgBoss, truncateText, validateScheduleInput, validateSlug, verifyAndConsumeOtpChallenge, verifyOtpCodeHash, withAdminRlsContext, withVendorRlsContext };
2303
+ export { Address, type AnalyticsPluginConfig, Attribute, BLOG_GENERATOR_AGENT_NAME, BLOG_GENERATOR_DEFAULT_SYSTEM_INSTRUCTION, BLOG_GENERATOR_DEFAULT_VALIDATION_RULES, BLOG_GENERATOR_LLM_AGENT_SLUG, BLOG_GENERATOR_MARKDOWN_ARTICLE_SEPARATOR, BLOG_METADATA_ENRICHER_AGENT_NAME, BLOG_METADATA_ENRICHER_DEFAULT_SYSTEM_INSTRUCTION, BLOG_METADATA_ENRICHER_DEFAULT_VALIDATION_RULES, BLOG_METADATA_ENRICHER_LLM_AGENT_SLUG, Blog, type BlogGeneratorBlogDraft, type BlogGeneratorDraftParseMode, type BlogGeneratorPluginConfig, type BlogGeneratorSeoDraft, BlogGeneratorService, 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, Currency, CurrencyExchange, Customer, Customer_Contacts, type DataSourceManager, Discount, DiscountRules, type ERPPluginConfig, type ERPPluginInstance, ERPSubmissionService, type EmailData, type EmailJobPayload, type EmailPluginConfig, EmailService, type EmailServiceInterface, EmailTemplateName, EmailTemplateResult, EntityCrudAction, EntityMap$2 as EntityMap, type ErpContactSyncInput, type ErpCreateContactPayload, type ErpJobPayload, type ErpPaidOrderDataSource, type ErpPaidOrderEntityMap, type ExtraPublicWriteRule, type FacebookMeAccountsResponse, type FacebookPageAccount, Form, FormField, FormSubmission, JOB_RUNNER_QUEUE, type CmsAppLike as JobRunnerCmsAppLike, type JobRunnerDeps, type JobRunnerPayload, JobSchedule, JobScheduleRun, KnowledgeBaseChunk, KnowledgeBaseDocument, type LatestArticleFromFeed, LlmAgent, type LlmAgentOptions, type LlmChatOptions, type LlmEmbeddingProvider, type LlmMessage, type LlmPluginConfig, LlmService, type LlmServiceEmbedOptions, type LlmServiceInterface, type LocalStoragePluginConfig, type Logger, Media, MessageTemplate, type MetaGraphMutationResponse, NextAuthUser, Order, OrderAddresses, OrderDiscounts, OrderItem, type OrderPlacedEmailPayload, OrderPlacedLineItem, OtpChallenge, type OtpChannel, type OtpPurpose, Page, PasswordResetToken, Payment, type PaymentIntent, type PaymentPluginConfig, type PaymentServiceInterface, Permission, type PgBossPluginConfig, PgBossService, type PipelineNames, type PluginContext, Product, ProductAttribute, ProductCategory, ProductTax, type PublicThemeSettingsPayload, type QueuePluginConfig, type QueueService, type RenderEmailOptions, type RenderedEmail, RssArticle, RssFeed, type S3StoragePluginConfig, type SendVendorOnboardEmailInput, Seo, type SeoLike, type SeoMetadataOverrides, SessionUser, type SmsJobPayload, type SmsPluginConfig, type SmsProviderChoice, type SmsProviderId, type SmsServiceConfig, type SmsServiceInterface, type SocialMediaPluginConfig, StorageService, Tag, Tax, TemplateContext, User, UserGroup, Vendor, VendorCustomer, VendorUser, Wishlist, WishlistItem, ZIP_MIME_TYPES, allowRateLimit, analyticsPlugin, applyVendorCustomersContactFilter, assertCaptchaOk, assertContactAllowedForVendorOrder, blogGeneratorPlugin, buildBlogMetadataUserPrompt, buildCaptchaPublicConfig, buildCronFromSchedule, buildRssUserPromptFromFeeds, cachePlugin, captchaPlugin, cn, contactIsVendorCustomer, countRecentOtpSends, createCmsApp, createDataSourceManager, createOtpChallenge, createSocialMediaHandlers, emailPlugin, emailTemplates, enrichUserWithVendorContext, ensureScheduleQueueWorker, erpPlugin, fetchSeoBySlug, formatDate, formatDateOnly, formatDateTime, generateNumericOtp, generateSlug, getRssArticleSummaryFromItem, hashOtpCode, hydrateVendorSessionUser, isCustomerTypeContact, isZipMedia, joinRecipientsForSend, linkUnclaimedContactToUser, llmAgentToChatAgentOptions, llmPlugin, loadPublicThemeSettings, loadUserVendorContext, localStoragePlugin, mergeSeoBySlug, metaFetchUserManagedPages, metaPostPageFeed, metaPostPagePhoto, metaResolvePageAccessToken, normalizePhoneE164, parseBlogGeneratorAgentContent, parseBlogGeneratorModelOutput, parseBlogMetadataEnrichmentJson, parseEmailRecipientsFromConfig, parseHfInferenceEmbeddingBody, paymentPlugin, pgBossPlugin, pgBossScheduleNameForId, queueEmail, queueErp, queueErpCreateContactIfEnabled, queueErpPaidOrderForOrderId, queueJobScheduleNow, queueOrderPlacedEmails, queuePlugin, queueSms, queueVendorOnboardEmails, rateLimitCheckoutPost, rateLimitKeyForApiRequest, rateLimitPublicApiIfNeeded, registerEmailQueueProcessor, registerErpQueueProcessor, registerJobRunnerWorker, registerSmsQueueProcessor, relativePathFromMediaParentId, renderEmail, renderLayout, resolveBlogCategoryIdByName, resolvePublicMetadata, resolveVendorIdForContactCheck, s3StoragePlugin, sanitizeMediaFolderPath, sanitizeStorageSegment, seedDefaultAdmin, sendOrderPlacedEmailsAfterConfirmation, sendVendorOnboardEmails, serializeEmailRecipients, shouldRateLimitPublicWrite, smsPlugin, socialMediaPlugin, syncJobScheduleToPgBoss, truncateText, validateScheduleInput, validateSlug, verifyAndConsumeOtpChallenge, verifyOtpCodeHash, withAdminRlsContext, withVendorRlsContext };
package/dist/index.d.ts CHANGED
@@ -1,16 +1,17 @@
1
- import { e as CompanyDetails, T as TemplateContext, h as EmailTemplateResult, g as EmailTemplateName, O as OrderPlacedLineItem, o as StorageService, i as EntityMap$2 } from './index-Bda8D1Rm.js';
2
- export { A as AnalyticsHandlerConfig, a as AuthHandlersConfig, B as BlogBySlugConfig, C as ChangePasswordConfig, b as ChatPublicConfig, c as CmsApiHandlerConfig, d as CmsGetter, f as CrudHandlerOptions, D as DashboardStatsConfig, E as EcommerceAnalyticsConfig, F as ForgotPasswordConfig, j as FormBySlugConfig, G as GetPublicSettingsGroupConfig, k as GetPublicSettingsGroupDataSource, I as InviteAcceptConfig, J as JobScheduleApiConfig, L as LlmAgentKnowledgeApiConfig, l as LlmAgentValidationRulesJson, P as ParsedLlmAgentValidation, S as SetPasswordConfig, m as SettingsApiConfig, n as SocialLinkItem, p as StorefrontApiConfig, q as StorefrontOtpFlags, U as UploadHandlerConfig, r as UserAuthApiConfig, s as UserAvatarConfig, t as UserProfileConfig, u as UsersApiConfig, V as VendorOnboardHandlersConfig, v as VendorOwnerActivation, w as createAnalyticsHandlers, x as createBlogBySlugHandler, y as createChangePasswordHandler, z as createCmsApiHandler, H as createCrudByIdHandler, K as createCrudHandler, M as createDashboardStatsHandler, N as createEcommerceAnalyticsHandler, Q as createForgotPasswordHandler, R as createFormBySlugHandler, W as createInviteAcceptHandler, X as createJobScheduleHandlers, Y as createLlmAgentKnowledgeHandlers, Z as createMediaZipExtractHandler, _ as createSetPasswordHandler, $ as createSettingsApiHandlers, a0 as createStorefrontApiHandler, a1 as createUploadHandler, a2 as createUserAuthApiRouter, a3 as createUserAvatarHandler, a4 as createUserProfileHandler, a5 as createUsersApiHandlers, a6 as createVendorOnboardHandlers, a7 as getCompanyDetailsFromSettings, a8 as getPublicSettingsGroup, a9 as mergeEmailLayoutCompanyDetails, aa as mergeGuardrailsIntoSystemPrompt, ab as parseLlmAgentValidationRules, ac as simpleDecrypt, ad as simpleEncrypt, ae as validateUserMessageAgainstAgentRules, af as validateUserMessageAgainstStructuredRules } from './index-Bda8D1Rm.js';
1
+ import { e as CompanyDetails, T as TemplateContext, h as EmailTemplateResult, g as EmailTemplateName, O as OrderPlacedLineItem, o as StorageService, i as EntityMap$2 } from './index-DOiJuMQA.js';
2
+ export { A as AnalyticsHandlerConfig, a as AuthHandlersConfig, B as BlogBySlugConfig, C as ChangePasswordConfig, b as ChatPublicConfig, c as CmsApiHandlerConfig, d as CmsGetter, f as CrudHandlerOptions, D as DashboardStatsConfig, E as EcommerceAnalyticsConfig, F as ForgotPasswordConfig, j as FormBySlugConfig, G as GetPublicSettingsGroupConfig, k as GetPublicSettingsGroupDataSource, I as InviteAcceptConfig, J as JobScheduleApiConfig, L as LlmAgentKnowledgeApiConfig, l as LlmAgentValidationRulesJson, P as ParsedLlmAgentValidation, S as SetPasswordConfig, m as SettingsApiConfig, n as SocialLinkItem, p as StorefrontApiConfig, q as StorefrontOtpFlags, U as UploadHandlerConfig, r as UserAuthApiConfig, s as UserAvatarConfig, t as UserProfileConfig, u as UsersApiConfig, V as VendorOnboardHandlersConfig, v as VendorOwnerActivation, w as createAnalyticsHandlers, x as createBlogBySlugHandler, y as createChangePasswordHandler, z as createCmsApiHandler, H as createCrudByIdHandler, K as createCrudHandler, M as createDashboardStatsHandler, N as createEcommerceAnalyticsHandler, Q as createForgotPasswordHandler, R as createFormBySlugHandler, W as createInviteAcceptHandler, X as createJobScheduleHandlers, Y as createLlmAgentKnowledgeHandlers, Z as createMediaZipExtractHandler, _ as createSetPasswordHandler, $ as createSettingsApiHandlers, a0 as createStorefrontApiHandler, a1 as createUploadHandler, a2 as createUserAuthApiRouter, a3 as createUserAvatarHandler, a4 as createUserProfileHandler, a5 as createUsersApiHandlers, a6 as createVendorOnboardHandlers, a7 as getCompanyDetailsFromSettings, a8 as getPublicSettingsGroup, a9 as mergeEmailLayoutCompanyDetails, aa as mergeGuardrailsIntoSystemPrompt, ab as parseLlmAgentValidationRules, ac as simpleDecrypt, ad as simpleEncrypt, ae as validateUserMessageAgainstAgentRules, af as validateUserMessageAgainstStructuredRules } from './index-DOiJuMQA.js';
3
3
  import PgBoss from 'pg-boss';
4
4
  import * as typeorm from 'typeorm';
5
5
  import { DataSource, EntityTarget, ObjectLiteral, SelectQueryBuilder } from 'typeorm';
6
6
  import { ClassValue } from 'clsx';
7
7
  import { Metadata } from 'next';
8
8
  import { NextAuthUser } from './auth.js';
9
- export { AuthorizeOtpInput, CmsMiddlewareConfig, NextAuthOptionsConfig, createCmsMiddleware, defaultPublicApiMethods, explainSessionEntityAccess, getNextAuthOptions, isRbacDebugEnabled, logEntityAccessDecision, logRbac, seedAdministratorPermissions, summarizeEntityPerms } from './auth.js';
9
+ export { AuthorizeOtpInput, CmsMiddlewareConfig, CmsMiddlewareRequest, NextAuthOptionsConfig, SUPER_ADMIN_GROUP_ID, VENDOR_ADMIN_GROUP_ID, createCmsMiddleware, defaultPublicApiMethods, explainSessionEntityAccess, getNextAuthOptions, getStorefrontNextAuthOptions, isAuthDebugClientEnabled, isAuthDebugEnabled, isRbacDebugEnabled, isSuperAdmin, isVendorAdmin, logAuth, logAuthClient, logEntityAccessDecision, logRbac, nextAuthCookieDebugInfo, seedAdministratorPermissions, summarizeEntityPerms, summarizeSessionUserForLog } from './auth.js';
10
10
  import { E as EntityCrudAction, S as SessionUser, e as VendorScope } from './vendor-scope-DTYhJk_I.js';
11
11
  export { A as ADMIN_GROUP_NAME, a as AuthHelpers, b as EntityPermissionFlags, G as GetSession, O as OPEN_ENDPOINTS, P as PERMISSION_REQUIRED_ENDPOINTS, R as RBAC_ADMIN_ONLY_ENTITIES, V as VENDOR_OWNER_GROUP_NAME, c as VENDOR_SCOPED_STORE_ENTITIES, d as VENDOR_STORE_RBAC_ENTITIES, f as canManageRoles, g as canManageVendorRoles, h as canManageVendorTeam, i as canOnboardVendors, j as createAuthHelpers, k as createCmsAuthBundle, l as getPermissionableEntityKeys, m as getRequiredPermission, n as hasEntityPermission, o as isOpenEndpoint, p as isPlatformAdministrator, q as isPublicMethod, r as isSuperAdminGroupName, s as isVendorGroupName, t as isVendorOwner, u as isVendorPortalUser, v as isVendorStaff, w as permissionRowsToRecord, x as resolveVendorScopeFromSessionUser, y as sessionHasEntityAccess, z as vendorPortalFlagsFromUser } from './vendor-scope-DTYhJk_I.js';
12
12
  import { a as NavbarConfig, F as FooterConfig } from './types-DCVaXlPV.js';
13
13
  export { A as AdminNavItem, D as DEFAULT_ADMIN_NAV } from './config-DJ5CmQvS.js';
14
+ import 'next-auth/jwt';
14
15
  import 'next-auth';
15
16
 
16
17
  interface PluginContext {
@@ -219,6 +220,7 @@ interface EmailPluginConfig$1 {
219
220
  port?: number;
220
221
  secure?: boolean;
221
222
  region?: string;
223
+ /** IAM keys for SES API (SendEmail). Not the same as SES SMTP credentials in SMTP_USER/SMTP_PASSWORD. */
222
224
  accessKeyId?: string;
223
225
  secretAccessKey?: string;
224
226
  templateOptions?: RenderEmailOptions;
@@ -243,9 +245,13 @@ declare class EmailService implements EmailServiceInterface {
243
245
  private templateOptions?;
244
246
  private sesClient?;
245
247
  private transporter?;
248
+ /** AWS via SMTP (nodemailer) vs SES API SDK. */
249
+ private awsViaSmtp;
246
250
  constructor(config: EmailPluginConfig$1);
247
251
  send(emailData: EmailData): Promise<boolean>;
248
252
  renderTemplate(templateName: EmailTemplateName, ctx: TemplateContext<unknown>): RenderedEmail;
253
+ /** Default notification recipient from plugin config (SMTP_TO / plugin `to`). */
254
+ getDefaultTo(): string;
249
255
  }
250
256
  declare const emailTemplates: {
251
257
  formSubmission: (data: {
@@ -316,6 +322,21 @@ interface OrderPlacedEmailPayload {
316
322
  }
317
323
  /** Queues one `orderPlaced` email per recipient (customer + each unique sales address; skips sales if same as customer). */
318
324
  declare function queueOrderPlacedEmails(cms: CmsAppLike$2, payload: OrderPlacedEmailPayload): Promise<void>;
325
+ interface VendorOnboardEmailPayload {
326
+ vendorName: string;
327
+ vendorSlug?: string;
328
+ ownerName: string;
329
+ ownerEmail: string;
330
+ activation: 'invite' | 'password';
331
+ inviteLink?: string;
332
+ signInLink: string;
333
+ kind?: 'vendor_onboard' | 'team_invite';
334
+ notifyEmails: string[];
335
+ companyDetails: CompanyDetails;
336
+ sendToOwner?: boolean;
337
+ }
338
+ /** Queues `vendorOnboarded` email to owner and each unique notify address (sales team settings). */
339
+ declare function queueVendorOnboardEmails(cms: CmsAppLike$2, payload: VendorOnboardEmailPayload): Promise<void>;
319
340
 
320
341
  interface EmailPluginConfig {
321
342
  type: 'AWS' | 'SMTP' | 'GMAIL' | 'SENDGRID';
@@ -615,6 +636,38 @@ declare class LlmService implements LlmServiceInterface {
615
636
  streamChat(messages: LlmMessage[], options?: LlmChatOptions): AsyncIterable<string>;
616
637
  }
617
638
 
639
+ declare class LlmAgent {
640
+ id: number;
641
+ name: string;
642
+ /** Stable key for API / widgets (e.g. `support`, `sales`). */
643
+ slug: string;
644
+ /**
645
+ * Logical role for this agent (`chatbot`, `blog_creation`, `social_media_post`, `email_intent_chatbot`, …).
646
+ * At most one active row per scope; resolve agents by scope in application code.
647
+ */
648
+ scope: string | null;
649
+ /** Passed as `systemPrompt` to `LlmService.chatAgent`. */
650
+ systemInstruction: string;
651
+ model: string | null;
652
+ temperature: number | null;
653
+ maxTokens: number | null;
654
+ /**
655
+ * Rules string: plain prose → appended to system prompt as output guardrails; JSON → see `parseLlmAgentValidationRules` in cms-handlers
656
+ * (structural checks + optional `guardrails` / `outputRules` / `outputInstructions` for the model).
657
+ */
658
+ validationRules: string | null;
659
+ enabled: boolean;
660
+ createdAt: Date;
661
+ updatedAt: Date;
662
+ deletedAt: Date | null;
663
+ deleted: boolean;
664
+ createdBy: number | null;
665
+ updatedBy: number | null;
666
+ deletedBy: number | null;
667
+ }
668
+ /** Partial {@link LlmAgentOptions} for merging with `userPrompt` / `history` / `context`. */
669
+ declare function llmAgentToChatAgentOptions(agent: LlmAgent): Pick<LlmAgentOptions, 'systemPrompt' | 'model' | 'temperature' | 'max_tokens'>;
670
+
618
671
  interface LlmPluginConfig {
619
672
  baseURL?: string;
620
673
  apiKey?: string;
@@ -1176,19 +1229,47 @@ declare function rateLimitPublicApiIfNeeded(req: Request, method: string, segmen
1176
1229
  }): Promise<Response | null>;
1177
1230
  declare function rateLimitCheckoutPost(req: Request): Promise<Response | null>;
1178
1231
 
1179
- interface EntityMapLike {
1232
+ interface EntityMapLike$1 {
1180
1233
  configs: unknown;
1181
1234
  orders: unknown;
1182
1235
  order_items: unknown;
1183
1236
  }
1184
1237
  interface SendOrderPlacedEmailDeps {
1185
1238
  getDataSource: () => Promise<DataSource>;
1186
- entityMap: EntityMapLike;
1239
+ entityMap: EntityMapLike$1;
1187
1240
  getCms: () => Promise<CmsApp>;
1188
1241
  }
1189
1242
  /** After payment confirmation: email customer + each sales team address from plugin settings. */
1190
1243
  declare function sendOrderPlacedEmailsAfterConfirmation(orderId: number, deps: SendOrderPlacedEmailDeps): Promise<void>;
1191
1244
 
1245
+ type VendorOnboardedActivation = 'invite' | 'password';
1246
+ type VendorOnboardedKind = 'vendor_onboard' | 'team_invite';
1247
+
1248
+ interface EntityMapLike {
1249
+ configs: unknown;
1250
+ }
1251
+ interface SendVendorOnboardEmailInput {
1252
+ vendorName: string;
1253
+ vendorSlug?: string;
1254
+ ownerName: string;
1255
+ ownerEmail: string;
1256
+ activation: VendorOnboardedActivation;
1257
+ inviteLink?: string;
1258
+ signInLink: string;
1259
+ kind?: VendorOnboardedKind;
1260
+ /** When false, skips owner email but still notifies internal recipients. Default true. */
1261
+ sendToOwner?: boolean;
1262
+ }
1263
+ interface SendVendorOnboardEmailDeps {
1264
+ getDataSource: () => Promise<DataSource>;
1265
+ entityMap: EntityMapLike;
1266
+ getCms: () => Promise<CmsAppLike$2>;
1267
+ }
1268
+ /** After vendor onboard / team invite: email owner + platform team from plugin settings. */
1269
+ declare function sendVendorOnboardEmails(input: SendVendorOnboardEmailInput, deps: SendVendorOnboardEmailDeps): Promise<{
1270
+ ownerEmailSent: boolean;
1271
+ }>;
1272
+
1192
1273
  interface DataSourceManager {
1193
1274
  getDataSource: () => DataSource;
1194
1275
  getDataSourceInitialized: () => Promise<DataSource>;
@@ -1799,14 +1880,41 @@ declare class OrderAddresses {
1799
1880
  shippingOrders: Order[];
1800
1881
  }
1801
1882
 
1883
+ declare class Customer {
1884
+ id: number;
1885
+ userId: number;
1886
+ user: User | null;
1887
+ name: string;
1888
+ email: string;
1889
+ phone: string;
1890
+ createdAt: Date;
1891
+ updatedAt: Date;
1892
+ deletedAt: Date | null;
1893
+ deleted: boolean;
1894
+ createdBy: number | null;
1895
+ updatedBy: number | null;
1896
+ deletedBy: number | null;
1897
+ }
1898
+
1899
+ declare class Customer_Contacts {
1900
+ id: number;
1901
+ customerId: number;
1902
+ customer: Customer;
1903
+ contactId: number;
1904
+ contact: Contact;
1905
+ }
1906
+
1802
1907
  type OrderKind = 'sale' | 'return' | 'replacement';
1803
1908
  declare class Order {
1804
1909
  id: number;
1805
1910
  vendorId: number;
1806
1911
  orderNumber: string;
1912
+ qrToken: string | null;
1807
1913
  orderKind: OrderKind;
1808
1914
  parentOrderId: number | null;
1809
1915
  contactId: number;
1916
+ /** Junction row linking the account customer to the checkout contact (storefront checkout). */
1917
+ customerContactId: number | null;
1810
1918
  billingAddressId: number | null;
1811
1919
  shippingAddressId: number | null;
1812
1920
  status: 'pending' | 'confirmed' | 'processing' | 'completed' | 'cancelled';
@@ -1827,6 +1935,7 @@ declare class Order {
1827
1935
  parentOrder: Order | null;
1828
1936
  children: Order[];
1829
1937
  contact: Contact;
1938
+ customerContact: Customer_Contacts | null;
1830
1939
  billingAddress: OrderAddresses | null;
1831
1940
  shippingAddress: OrderAddresses | null;
1832
1941
  items: OrderItem[];
@@ -1847,6 +1956,8 @@ declare class ChatConversation {
1847
1956
  contactId: number;
1848
1957
  createdAt: Date;
1849
1958
  updatedAt: Date;
1959
+ /** Set when a chat lead email was sent for this conversation (intent tool). */
1960
+ leadEmailSentAt: Date | null;
1850
1961
  contact: Contact;
1851
1962
  messages: ChatMessage[];
1852
1963
  }
@@ -2015,33 +2126,6 @@ declare class Wishlist {
2015
2126
  items: WishlistItem[];
2016
2127
  }
2017
2128
 
2018
- declare class LlmAgent {
2019
- id: number;
2020
- name: string;
2021
- /** Stable key for API / widgets (e.g. `support`, `sales`). */
2022
- slug: string;
2023
- /** Passed as `systemPrompt` to `LlmService.chatAgent`. */
2024
- systemInstruction: string;
2025
- model: string | null;
2026
- temperature: number | null;
2027
- maxTokens: number | null;
2028
- /**
2029
- * Rules string: plain prose → appended to system prompt as output guardrails; JSON → see `parseLlmAgentValidationRules` in cms-handlers
2030
- * (structural checks + optional `guardrails` / `outputRules` / `outputInstructions` for the model).
2031
- */
2032
- validationRules: string | null;
2033
- enabled: boolean;
2034
- createdAt: Date;
2035
- updatedAt: Date;
2036
- deletedAt: Date | null;
2037
- deleted: boolean;
2038
- createdBy: number | null;
2039
- updatedBy: number | null;
2040
- deletedBy: number | null;
2041
- }
2042
- /** Partial {@link LlmAgentOptions} for merging with `userPrompt` / `history` / `context`. */
2043
- declare function llmAgentToChatAgentOptions(agent: LlmAgent): Pick<LlmAgentOptions, 'systemPrompt' | 'model' | 'temperature' | 'max_tokens'>;
2044
-
2045
2129
  declare class Currency {
2046
2130
  id: number;
2047
2131
  code: string;
@@ -2200,7 +2284,8 @@ declare class RssFeed {
2200
2284
  declare class VendorCustomer {
2201
2285
  id: number;
2202
2286
  vendorId: number;
2203
- contactId: number;
2287
+ contactId: number | null;
2288
+ customerId: number;
2204
2289
  /** Optional vendor-specific notes about this customer. */
2205
2290
  notes: string | null;
2206
2291
  /** Optional vendor-specific tags/labels. */
@@ -2208,10 +2293,11 @@ declare class VendorCustomer {
2208
2293
  createdAt: Date;
2209
2294
  updatedAt: Date;
2210
2295
  vendor: Vendor;
2211
- contact: Contact;
2296
+ contact: Contact | null;
2297
+ customer: Customer;
2212
2298
  }
2213
2299
 
2214
2300
  /** Map API resource segment (e.g. "blogs", "form_submissions") to entity. Used by CRUD handler. */
2215
2301
  declare const CMS_ENTITY_MAP: Record<string, EntityTarget<typeorm.ObjectLiteral>>;
2216
2302
 
2217
- export { Address, type AnalyticsPluginConfig, Attribute, BLOG_GENERATOR_AGENT_NAME, BLOG_GENERATOR_DEFAULT_SYSTEM_INSTRUCTION, BLOG_GENERATOR_DEFAULT_VALIDATION_RULES, BLOG_GENERATOR_LLM_AGENT_SLUG, BLOG_GENERATOR_MARKDOWN_ARTICLE_SEPARATOR, BLOG_METADATA_ENRICHER_AGENT_NAME, BLOG_METADATA_ENRICHER_DEFAULT_SYSTEM_INSTRUCTION, BLOG_METADATA_ENRICHER_DEFAULT_VALIDATION_RULES, BLOG_METADATA_ENRICHER_LLM_AGENT_SLUG, Blog, type BlogGeneratorBlogDraft, type BlogGeneratorDraftParseMode, type BlogGeneratorPluginConfig, type BlogGeneratorSeoDraft, BlogGeneratorService, 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, Currency, CurrencyExchange, type DataSourceManager, Discount, DiscountRules, type ERPPluginConfig, type ERPPluginInstance, ERPSubmissionService, type EmailData, type EmailJobPayload, type EmailPluginConfig, EmailService, type EmailServiceInterface, EmailTemplateName, EmailTemplateResult, EntityCrudAction, EntityMap$2 as EntityMap, type ErpContactSyncInput, type ErpCreateContactPayload, type ErpJobPayload, type ErpPaidOrderDataSource, type ErpPaidOrderEntityMap, type ExtraPublicWriteRule, type FacebookMeAccountsResponse, type FacebookPageAccount, Form, FormField, FormSubmission, JOB_RUNNER_QUEUE, type CmsAppLike as JobRunnerCmsAppLike, type JobRunnerDeps, type JobRunnerPayload, JobSchedule, JobScheduleRun, KnowledgeBaseChunk, KnowledgeBaseDocument, type LatestArticleFromFeed, LlmAgent, type LlmAgentOptions, type LlmChatOptions, type LlmEmbeddingProvider, type LlmMessage, type LlmPluginConfig, LlmService, type LlmServiceEmbedOptions, type LlmServiceInterface, type LocalStoragePluginConfig, type Logger, Media, MessageTemplate, type MetaGraphMutationResponse, NextAuthUser, Order, OrderAddresses, OrderDiscounts, OrderItem, type OrderPlacedEmailPayload, OrderPlacedLineItem, OtpChallenge, type OtpChannel, type OtpPurpose, Page, PasswordResetToken, Payment, type PaymentIntent, type PaymentPluginConfig, type PaymentServiceInterface, Permission, type PgBossPluginConfig, PgBossService, type PipelineNames, type PluginContext, Product, ProductAttribute, ProductCategory, ProductTax, type PublicThemeSettingsPayload, type QueuePluginConfig, type QueueService, type RenderEmailOptions, type RenderedEmail, RssArticle, RssFeed, type S3StoragePluginConfig, Seo, type SeoLike, type SeoMetadataOverrides, SessionUser, type SmsJobPayload, type SmsPluginConfig, type SmsProviderChoice, type SmsProviderId, type SmsServiceConfig, type SmsServiceInterface, type SocialMediaPluginConfig, StorageService, Tag, Tax, TemplateContext, User, UserGroup, Vendor, VendorCustomer, VendorUser, Wishlist, WishlistItem, ZIP_MIME_TYPES, allowRateLimit, analyticsPlugin, applyVendorCustomersContactFilter, assertCaptchaOk, assertContactAllowedForVendorOrder, blogGeneratorPlugin, buildBlogMetadataUserPrompt, buildCaptchaPublicConfig, buildCronFromSchedule, buildRssUserPromptFromFeeds, cachePlugin, captchaPlugin, cn, contactIsVendorCustomer, countRecentOtpSends, createCmsApp, createDataSourceManager, createOtpChallenge, createSocialMediaHandlers, emailPlugin, emailTemplates, enrichUserWithVendorContext, ensureScheduleQueueWorker, erpPlugin, fetchSeoBySlug, formatDate, formatDateOnly, formatDateTime, generateNumericOtp, generateSlug, getRssArticleSummaryFromItem, hashOtpCode, hydrateVendorSessionUser, isCustomerTypeContact, isZipMedia, joinRecipientsForSend, linkUnclaimedContactToUser, llmAgentToChatAgentOptions, llmPlugin, loadPublicThemeSettings, loadUserVendorContext, localStoragePlugin, mergeSeoBySlug, metaFetchUserManagedPages, metaPostPageFeed, metaPostPagePhoto, metaResolvePageAccessToken, normalizePhoneE164, parseBlogGeneratorAgentContent, parseBlogGeneratorModelOutput, parseBlogMetadataEnrichmentJson, parseEmailRecipientsFromConfig, parseHfInferenceEmbeddingBody, paymentPlugin, pgBossPlugin, pgBossScheduleNameForId, queueEmail, queueErp, queueErpCreateContactIfEnabled, queueErpPaidOrderForOrderId, queueJobScheduleNow, queueOrderPlacedEmails, queuePlugin, queueSms, rateLimitCheckoutPost, rateLimitKeyForApiRequest, rateLimitPublicApiIfNeeded, registerEmailQueueProcessor, registerErpQueueProcessor, registerJobRunnerWorker, registerSmsQueueProcessor, relativePathFromMediaParentId, renderEmail, renderLayout, resolveBlogCategoryIdByName, resolvePublicMetadata, resolveVendorIdForContactCheck, s3StoragePlugin, sanitizeMediaFolderPath, sanitizeStorageSegment, seedDefaultAdmin, sendOrderPlacedEmailsAfterConfirmation, serializeEmailRecipients, shouldRateLimitPublicWrite, smsPlugin, socialMediaPlugin, syncJobScheduleToPgBoss, truncateText, validateScheduleInput, validateSlug, verifyAndConsumeOtpChallenge, verifyOtpCodeHash, withAdminRlsContext, withVendorRlsContext };
2303
+ export { Address, type AnalyticsPluginConfig, Attribute, BLOG_GENERATOR_AGENT_NAME, BLOG_GENERATOR_DEFAULT_SYSTEM_INSTRUCTION, BLOG_GENERATOR_DEFAULT_VALIDATION_RULES, BLOG_GENERATOR_LLM_AGENT_SLUG, BLOG_GENERATOR_MARKDOWN_ARTICLE_SEPARATOR, BLOG_METADATA_ENRICHER_AGENT_NAME, BLOG_METADATA_ENRICHER_DEFAULT_SYSTEM_INSTRUCTION, BLOG_METADATA_ENRICHER_DEFAULT_VALIDATION_RULES, BLOG_METADATA_ENRICHER_LLM_AGENT_SLUG, Blog, type BlogGeneratorBlogDraft, type BlogGeneratorDraftParseMode, type BlogGeneratorPluginConfig, type BlogGeneratorSeoDraft, BlogGeneratorService, 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, Currency, CurrencyExchange, Customer, Customer_Contacts, type DataSourceManager, Discount, DiscountRules, type ERPPluginConfig, type ERPPluginInstance, ERPSubmissionService, type EmailData, type EmailJobPayload, type EmailPluginConfig, EmailService, type EmailServiceInterface, EmailTemplateName, EmailTemplateResult, EntityCrudAction, EntityMap$2 as EntityMap, type ErpContactSyncInput, type ErpCreateContactPayload, type ErpJobPayload, type ErpPaidOrderDataSource, type ErpPaidOrderEntityMap, type ExtraPublicWriteRule, type FacebookMeAccountsResponse, type FacebookPageAccount, Form, FormField, FormSubmission, JOB_RUNNER_QUEUE, type CmsAppLike as JobRunnerCmsAppLike, type JobRunnerDeps, type JobRunnerPayload, JobSchedule, JobScheduleRun, KnowledgeBaseChunk, KnowledgeBaseDocument, type LatestArticleFromFeed, LlmAgent, type LlmAgentOptions, type LlmChatOptions, type LlmEmbeddingProvider, type LlmMessage, type LlmPluginConfig, LlmService, type LlmServiceEmbedOptions, type LlmServiceInterface, type LocalStoragePluginConfig, type Logger, Media, MessageTemplate, type MetaGraphMutationResponse, NextAuthUser, Order, OrderAddresses, OrderDiscounts, OrderItem, type OrderPlacedEmailPayload, OrderPlacedLineItem, OtpChallenge, type OtpChannel, type OtpPurpose, Page, PasswordResetToken, Payment, type PaymentIntent, type PaymentPluginConfig, type PaymentServiceInterface, Permission, type PgBossPluginConfig, PgBossService, type PipelineNames, type PluginContext, Product, ProductAttribute, ProductCategory, ProductTax, type PublicThemeSettingsPayload, type QueuePluginConfig, type QueueService, type RenderEmailOptions, type RenderedEmail, RssArticle, RssFeed, type S3StoragePluginConfig, type SendVendorOnboardEmailInput, Seo, type SeoLike, type SeoMetadataOverrides, SessionUser, type SmsJobPayload, type SmsPluginConfig, type SmsProviderChoice, type SmsProviderId, type SmsServiceConfig, type SmsServiceInterface, type SocialMediaPluginConfig, StorageService, Tag, Tax, TemplateContext, User, UserGroup, Vendor, VendorCustomer, VendorUser, Wishlist, WishlistItem, ZIP_MIME_TYPES, allowRateLimit, analyticsPlugin, applyVendorCustomersContactFilter, assertCaptchaOk, assertContactAllowedForVendorOrder, blogGeneratorPlugin, buildBlogMetadataUserPrompt, buildCaptchaPublicConfig, buildCronFromSchedule, buildRssUserPromptFromFeeds, cachePlugin, captchaPlugin, cn, contactIsVendorCustomer, countRecentOtpSends, createCmsApp, createDataSourceManager, createOtpChallenge, createSocialMediaHandlers, emailPlugin, emailTemplates, enrichUserWithVendorContext, ensureScheduleQueueWorker, erpPlugin, fetchSeoBySlug, formatDate, formatDateOnly, formatDateTime, generateNumericOtp, generateSlug, getRssArticleSummaryFromItem, hashOtpCode, hydrateVendorSessionUser, isCustomerTypeContact, isZipMedia, joinRecipientsForSend, linkUnclaimedContactToUser, llmAgentToChatAgentOptions, llmPlugin, loadPublicThemeSettings, loadUserVendorContext, localStoragePlugin, mergeSeoBySlug, metaFetchUserManagedPages, metaPostPageFeed, metaPostPagePhoto, metaResolvePageAccessToken, normalizePhoneE164, parseBlogGeneratorAgentContent, parseBlogGeneratorModelOutput, parseBlogMetadataEnrichmentJson, parseEmailRecipientsFromConfig, parseHfInferenceEmbeddingBody, paymentPlugin, pgBossPlugin, pgBossScheduleNameForId, queueEmail, queueErp, queueErpCreateContactIfEnabled, queueErpPaidOrderForOrderId, queueJobScheduleNow, queueOrderPlacedEmails, queuePlugin, queueSms, queueVendorOnboardEmails, rateLimitCheckoutPost, rateLimitKeyForApiRequest, rateLimitPublicApiIfNeeded, registerEmailQueueProcessor, registerErpQueueProcessor, registerJobRunnerWorker, registerSmsQueueProcessor, relativePathFromMediaParentId, renderEmail, renderLayout, resolveBlogCategoryIdByName, resolvePublicMetadata, resolveVendorIdForContactCheck, s3StoragePlugin, sanitizeMediaFolderPath, sanitizeStorageSegment, seedDefaultAdmin, sendOrderPlacedEmailsAfterConfirmation, sendVendorOnboardEmails, serializeEmailRecipients, shouldRateLimitPublicWrite, smsPlugin, socialMediaPlugin, syncJobScheduleToPgBoss, truncateText, validateScheduleInput, validateSlug, verifyAndConsumeOtpChallenge, verifyOtpCodeHash, withAdminRlsContext, withVendorRlsContext };