@infuro/cms-core 1.0.29 → 1.0.31

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 (58) hide show
  1. package/README.md +17 -13
  2. package/dist/admin.cjs +8522 -3281
  3. package/dist/admin.cjs.map +1 -1
  4. package/dist/admin.d.cts +13 -2
  5. package/dist/admin.d.ts +13 -2
  6. package/dist/admin.js +8210 -2957
  7. package/dist/admin.js.map +1 -1
  8. package/dist/api.cjs +5099 -1167
  9. package/dist/api.cjs.map +1 -1
  10. package/dist/api.d.cts +2 -2
  11. package/dist/api.d.ts +2 -2
  12. package/dist/api.js +4847 -909
  13. package/dist/api.js.map +1 -1
  14. package/dist/auth.cjs +461 -62
  15. package/dist/auth.cjs.map +1 -1
  16. package/dist/auth.d.cts +73 -47
  17. package/dist/auth.d.ts +73 -47
  18. package/dist/auth.js +425 -38
  19. package/dist/auth.js.map +1 -1
  20. package/dist/cli.cjs +21 -14
  21. package/dist/cli.cjs.map +1 -1
  22. package/dist/cli.js +21 -14
  23. package/dist/cli.js.map +1 -1
  24. package/dist/{index-D9SdaDJ0.d.ts → index-BcMRGNjS.d.cts} +36 -3
  25. package/dist/{index-BPQSXgXF.d.cts → index-Bda8D1Rm.d.ts} +36 -3
  26. package/dist/index.cjs +4753 -740
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +301 -36
  29. package/dist/index.d.ts +301 -36
  30. package/dist/index.js +4750 -768
  31. package/dist/index.js.map +1 -1
  32. package/dist/migrations/1775400000001-AddDiscountAndOrderAddresses.ts +274 -0
  33. package/dist/migrations/1775800000000-VendorsAndVendorUsers.ts +74 -0
  34. package/dist/migrations/1775900000000-StoreVendorIdColumns.ts +124 -0
  35. package/dist/migrations/1775910000000-VendorOwnerRbacSeed.ts +54 -0
  36. package/dist/migrations/1775920000000-VendorOwnerSettingsPermission.ts +25 -0
  37. package/dist/migrations/1775930000000-VendorGroupStorePermissions.ts +54 -0
  38. package/dist/migrations/1775940000000-VendorRls.ts +71 -0
  39. package/dist/migrations/1775950000000-VendorCustomers.ts +87 -0
  40. package/dist/migrations/1775950000001-VendorCustomersPermissions.ts +67 -0
  41. package/dist/migrations/1778652250860-CreateCurrencyTables.ts +16 -0
  42. package/dist/migrations/1778652250861-OrderAddressTables.ts +88 -0
  43. package/dist/migrations/1778652250862-UpdateDiscountandRules.ts +100 -0
  44. package/dist/migrations/1778652250863-MakeCouponCodeNullable.ts +19 -0
  45. package/dist/migrations/1778652250864-RemoveUniqueConstraintFromDiscountCouponCode.ts +22 -0
  46. package/dist/migrations/1778652250865-FixOrdersAddressForeignKeys.ts +71 -0
  47. package/dist/migrations/1778660000000-DiscountVendorId.ts +90 -0
  48. package/dist/migrations/1778660000001-FixOrdersAddressFkToOrderAddresses.ts +79 -0
  49. package/dist/migrations/1778660000002-VendorUserIdInviteStatus.ts +61 -0
  50. package/dist/theme.d.cts +2 -2
  51. package/dist/theme.d.ts +2 -2
  52. package/dist/{types-D34wmivy.d.cts → types-DCVaXlPV.d.cts} +1 -1
  53. package/dist/{types-D34wmivy.d.ts → types-DCVaXlPV.d.ts} +1 -1
  54. package/dist/vendor-scope-DTYhJk_I.d.cts +129 -0
  55. package/dist/vendor-scope-DTYhJk_I.d.ts +129 -0
  56. package/package.json +9 -2
  57. package/dist/helpers-dlrF_49e.d.cts +0 -60
  58. package/dist/helpers-dlrF_49e.d.ts +0 -60
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
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-D9SdaDJ0.js';
2
- export { A as AnalyticsHandlerConfig, c as AuthHandlersConfig, B as BlogBySlugConfig, d as ChangePasswordConfig, e as ChatPublicConfig, f as CmsApiHandlerConfig, g as CmsGetter, h as CrudHandlerOptions, D as DashboardStatsConfig, i 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, m as SetPasswordConfig, n as SettingsApiConfig, o 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 createAnalyticsHandlers, w as createBlogBySlugHandler, x as createChangePasswordHandler, y as createCmsApiHandler, z as createCrudByIdHandler, H as createCrudHandler, K as createDashboardStatsHandler, M as createEcommerceAnalyticsHandler, N as createForgotPasswordHandler, Q as createFormBySlugHandler, R as createInviteAcceptHandler, V as createJobScheduleHandlers, W as createLlmAgentKnowledgeHandlers, X as createMediaZipExtractHandler, Y as createSetPasswordHandler, Z as createSettingsApiHandlers, _ as createStorefrontApiHandler, $ as createUploadHandler, a0 as createUserAuthApiRouter, a1 as createUserAvatarHandler, a2 as createUserProfileHandler, a3 as createUsersApiHandlers, a4 as getCompanyDetailsFromSettings, a5 as getPublicSettingsGroup, a6 as mergeEmailLayoutCompanyDetails, a7 as mergeGuardrailsIntoSystemPrompt, a8 as parseLlmAgentValidationRules, a9 as simpleDecrypt, aa as simpleEncrypt, ab as validateUserMessageAgainstAgentRules, ac as validateUserMessageAgainstStructuredRules } from './index-D9SdaDJ0.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-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';
3
3
  import PgBoss from 'pg-boss';
4
4
  import * as typeorm from 'typeorm';
5
- import { DataSource, EntityTarget, ObjectLiteral } from 'typeorm';
5
+ import { DataSource, EntityTarget, ObjectLiteral, SelectQueryBuilder } from 'typeorm';
6
6
  import { ClassValue } from 'clsx';
7
7
  import { Metadata } from 'next';
8
- import { N as NavbarConfig, F as FooterConfig } from './types-D34wmivy.js';
9
- import { E as EntityCrudAction } from './helpers-dlrF_49e.js';
10
- 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, 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';
11
- export { AuthorizeOtpInput, CmsMiddlewareConfig, NextAuthOptionsConfig, NextAuthUser, createCmsMiddleware, defaultPublicApiMethods, getNextAuthOptions, seedAdministratorPermissions } from './auth.js';
8
+ import { NextAuthUser } from './auth.js';
9
+ export { AuthorizeOtpInput, CmsMiddlewareConfig, NextAuthOptionsConfig, createCmsMiddleware, defaultPublicApiMethods, explainSessionEntityAccess, getNextAuthOptions, isRbacDebugEnabled, logEntityAccessDecision, logRbac, seedAdministratorPermissions, summarizeEntityPerms } from './auth.js';
10
+ import { E as EntityCrudAction, S as SessionUser, e as VendorScope } from './vendor-scope-DTYhJk_I.js';
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
+ import { a as NavbarConfig, F as FooterConfig } from './types-DCVaXlPV.js';
12
13
  export { A as AdminNavItem, D as DEFAULT_ADMIN_NAV } from './config-DJ5CmQvS.js';
13
14
  import 'next-auth';
14
15
 
@@ -990,6 +991,7 @@ interface SocialMediaApiConfig {
990
991
  }
991
992
  declare function createSocialMediaHandlers(config: SocialMediaApiConfig): {
992
993
  getLinkedInStatus(req: Request): Promise<Response>;
994
+ fetchLinkedInOrganizations(req: Request): Promise<Response>;
993
995
  syncLinkedInProfile(req: Request): Promise<Response>;
994
996
  publishBlogToLinkedIn(req: Request, blogId: number): Promise<Response>;
995
997
  getFacebookStatus(req: Request): Promise<Response>;
@@ -1208,33 +1210,29 @@ declare function seedDefaultAdmin(ds: DataSource, entityMap: SeedEntityMap, opts
1208
1210
  password?: string;
1209
1211
  }): Promise<void>;
1210
1212
 
1211
- interface PublicThemeSettingsPayload {
1212
- activeThemeId: string;
1213
- primaryColor: string;
1214
- secondaryColor: string;
1215
- navbarConfig: NavbarConfig;
1216
- footerOverrides: Partial<FooterConfig>;
1213
+ type VendorInviteStatus = 'none' | 'pending' | 'expired' | 'accepted';
1214
+ declare class Vendor {
1215
+ id: number;
1216
+ name: string;
1217
+ slug: string;
1218
+ email: string | null;
1219
+ phone: string | null;
1220
+ logo: string | null;
1221
+ description: string | null;
1222
+ metadata: Record<string, unknown> | null;
1223
+ active: boolean;
1224
+ /** Primary owner user for this vendor (set on onboard). */
1225
+ userId: number | null;
1226
+ inviteStatus: VendorInviteStatus;
1227
+ createdAt: Date;
1228
+ updatedAt: Date;
1229
+ deletedAt: Date | null;
1230
+ deleted: boolean;
1231
+ createdBy: number | null;
1232
+ updatedBy: number | null;
1233
+ deletedBy: number | null;
1234
+ vendorUsers: VendorUser[];
1217
1235
  }
1218
- declare function loadPublicThemeSettings(config: {
1219
- dataSource: DataSource;
1220
- entityMap: EntityMap$2;
1221
- encryptionKey?: string;
1222
- defaultActiveThemeId?: string;
1223
- defaultPrimaryColor?: string;
1224
- defaultSecondaryColor?: string;
1225
- }): Promise<PublicThemeSettingsPayload>;
1226
-
1227
- /** Normalize a logical media folder path: no leading/trailing slashes, no ".." segments, max length. */
1228
- declare function sanitizeMediaFolderPath(input: unknown): string;
1229
- /** Single path segment for storage (folder name or legacy path segment). */
1230
- declare function sanitizeStorageSegment(name: string): string;
1231
-
1232
- type EntityMap = Record<string, EntityTarget<ObjectLiteral>>;
1233
- /** Build `a/b/c` path under `uploads/` from the chain of folder rows up to root. */
1234
- declare function relativePathFromMediaParentId(dataSource: DataSource, entityMap: EntityMap, parentId: number | null): Promise<string>;
1235
-
1236
- declare const ZIP_MIME_TYPES: Set<string>;
1237
- declare function isZipMedia(mime: string | null | undefined, filename: string): boolean;
1238
1236
 
1239
1237
  declare class Permission {
1240
1238
  id: number;
@@ -1290,6 +1288,94 @@ declare class User {
1290
1288
  group: UserGroup | null;
1291
1289
  }
1292
1290
 
1291
+ /** Links a staff user to a vendor store. */
1292
+ type VendorUserRole = 'owner' | 'staff';
1293
+ declare class VendorUser {
1294
+ id: number;
1295
+ vendorId: number;
1296
+ userId: number;
1297
+ role: VendorUserRole;
1298
+ createdAt: Date;
1299
+ updatedAt: Date;
1300
+ vendor: Vendor;
1301
+ user: User;
1302
+ }
1303
+
1304
+ /** Load vendor membership for session (call from app `getUserByEmail`).
1305
+ *
1306
+ * Uses a raw SQL query so it works even when the consuming app's DataSource
1307
+ * does not explicitly register the VendorUser entity.
1308
+ */
1309
+ declare function loadUserVendorContext(dataSource: DataSource, userId: number, preferredVendorId?: number | null): Promise<{
1310
+ vendorIds: number[];
1311
+ activeVendorId: number | null;
1312
+ vendorRole: VendorUserRole | null;
1313
+ }>;
1314
+
1315
+ /** Attach vendorIds / activeVendorId / vendorRole for NextAuth (use in app getUserByEmail). */
1316
+ declare function enrichUserWithVendorContext(dataSource: DataSource, user: NextAuthUser | null): Promise<NextAuthUser | null>;
1317
+
1318
+ /** Merge DB group + vendor_users into session (JWT often missing these). Server/API only. */
1319
+ declare function hydrateVendorSessionUser(dataSource: DataSource, user: SessionUser | null | undefined): Promise<SessionUser | null | undefined>;
1320
+
1321
+ interface PublicThemeSettingsPayload {
1322
+ activeThemeId: string;
1323
+ primaryColor: string;
1324
+ secondaryColor: string;
1325
+ navbarConfig: NavbarConfig;
1326
+ footerOverrides: Partial<FooterConfig>;
1327
+ }
1328
+ declare function loadPublicThemeSettings(config: {
1329
+ dataSource: DataSource;
1330
+ entityMap: EntityMap$2;
1331
+ encryptionKey?: string;
1332
+ defaultActiveThemeId?: string;
1333
+ defaultPrimaryColor?: string;
1334
+ defaultSecondaryColor?: string;
1335
+ }): Promise<PublicThemeSettingsPayload>;
1336
+
1337
+ /** Normalize a logical media folder path: no leading/trailing slashes, no ".." segments, max length. */
1338
+ declare function sanitizeMediaFolderPath(input: unknown): string;
1339
+ /** Single path segment for storage (folder name or legacy path segment). */
1340
+ declare function sanitizeStorageSegment(name: string): string;
1341
+
1342
+ type EntityMap = Record<string, EntityTarget<ObjectLiteral>>;
1343
+ /** Build `a/b/c` path under `uploads/` from the chain of folder rows up to root. */
1344
+ declare function relativePathFromMediaParentId(dataSource: DataSource, entityMap: EntityMap, parentId: number | null): Promise<string>;
1345
+
1346
+ declare const ZIP_MIME_TYPES: Set<string>;
1347
+ declare function isZipMedia(mime: string | null | undefined, filename: string): boolean;
1348
+
1349
+ /**
1350
+ * Executes `fn` inside a transaction where the PostgreSQL GUC
1351
+ * `app.vendor_id` is set for the duration of that transaction.
1352
+ *
1353
+ * This activates the `vendor_isolation` RLS policy added by the
1354
+ * `VendorRls1775940000000` migration.
1355
+ *
1356
+ * vendorId = 0 → admin / all-access (policy allows everything)
1357
+ * vendorId > 0 → only rows whose `vendorId` column matches
1358
+ *
1359
+ * Example:
1360
+ * const orders = await withVendorRlsContext(dataSource, 4, (ds) =>
1361
+ * ds.getRepository(Order).find({ where: { deleted: false } })
1362
+ * );
1363
+ */
1364
+ declare function withVendorRlsContext<T>(dataSource: DataSource, vendorId: number, fn: (dataSource: DataSource) => Promise<T>): Promise<T>;
1365
+ /**
1366
+ * Convenience wrapper: sets admin mode (vendor_id = '0') so all rows are
1367
+ * visible regardless of their vendorId. Use for platform-admin queries.
1368
+ */
1369
+ declare function withAdminRlsContext<T>(dataSource: DataSource, fn: (dataSource: DataSource) => Promise<T>): Promise<T>;
1370
+
1371
+ declare function isCustomerTypeContact(type: unknown): boolean;
1372
+ /** Restrict contact list to rows linked in `vendor_customers` with type customer. */
1373
+ declare function applyVendorCustomersContactFilter(qb: SelectQueryBuilder<typeorm.ObjectLiteral>, contactAlias: string, scope: VendorScope, vendorIdFilter: number | null): void;
1374
+ declare function contactIsVendorCustomer(dataSource: DataSource, entityMap: EntityMap$2, vendorId: number, contactId: number): Promise<boolean>;
1375
+ /** Returns an error message when the contact is not a vendor-linked customer; otherwise null. */
1376
+ declare function assertContactAllowedForVendorOrder(dataSource: DataSource, entityMap: EntityMap$2, vendorId: number, contactId: number): Promise<string | null>;
1377
+ declare function resolveVendorIdForContactCheck(scope: VendorScope, bodyOrRow: Record<string, unknown>): number | null;
1378
+
1293
1379
  declare class OtpChallenge {
1294
1380
  id: number;
1295
1381
  purpose: string;
@@ -1467,6 +1553,7 @@ declare class Address {
1467
1553
 
1468
1554
  declare class ProductCategory {
1469
1555
  id: number;
1556
+ vendorId: number;
1470
1557
  name: string;
1471
1558
  slug: string;
1472
1559
  parentId: number | null;
@@ -1482,6 +1569,7 @@ declare class ProductCategory {
1482
1569
  createdBy: number | null;
1483
1570
  updatedBy: number | null;
1484
1571
  deletedBy: number | null;
1572
+ vendor: Vendor;
1485
1573
  parent: ProductCategory | null;
1486
1574
  children: ProductCategory[];
1487
1575
  products: Product[];
@@ -1490,6 +1578,7 @@ declare class ProductCategory {
1490
1578
 
1491
1579
  declare class Brand {
1492
1580
  id: number;
1581
+ vendorId: number;
1493
1582
  name: string;
1494
1583
  slug: string;
1495
1584
  logo: string | null;
@@ -1505,6 +1594,7 @@ declare class Brand {
1505
1594
  updatedBy: number | null;
1506
1595
  deletedBy: number | null;
1507
1596
  seoId: number | null;
1597
+ vendor: Vendor;
1508
1598
  seo: Seo | null;
1509
1599
  products: Product[];
1510
1600
  collections: Collection[];
@@ -1512,6 +1602,7 @@ declare class Brand {
1512
1602
 
1513
1603
  declare class Collection {
1514
1604
  id: number;
1605
+ vendorId: number;
1515
1606
  categoryId: number | null;
1516
1607
  brandId: number | null;
1517
1608
  name: string;
@@ -1531,6 +1622,7 @@ declare class Collection {
1531
1622
  updatedBy: number | null;
1532
1623
  deletedBy: number | null;
1533
1624
  seoId: number | null;
1625
+ vendor: Vendor;
1534
1626
  seo: Seo | null;
1535
1627
  category: ProductCategory | null;
1536
1628
  brand: Brand | null;
@@ -1539,6 +1631,7 @@ declare class Collection {
1539
1631
 
1540
1632
  declare class Attribute {
1541
1633
  id: number;
1634
+ vendorId: number;
1542
1635
  name: string;
1543
1636
  slug: string;
1544
1637
  type: 'text' | 'number' | 'select' | 'boolean';
@@ -1553,6 +1646,7 @@ declare class Attribute {
1553
1646
  createdBy: number | null;
1554
1647
  updatedBy: number | null;
1555
1648
  deletedBy: number | null;
1649
+ vendor: Vendor;
1556
1650
  }
1557
1651
 
1558
1652
  declare class ProductAttribute {
@@ -1569,6 +1663,7 @@ declare class ProductAttribute {
1569
1663
 
1570
1664
  declare class Tax {
1571
1665
  id: number;
1666
+ vendorId: number;
1572
1667
  name: string;
1573
1668
  slug: string;
1574
1669
  rate: number;
@@ -1583,6 +1678,7 @@ declare class Tax {
1583
1678
  createdBy: number | null;
1584
1679
  updatedBy: number | null;
1585
1680
  deletedBy: number | null;
1681
+ vendor: Vendor;
1586
1682
  }
1587
1683
 
1588
1684
  declare class ProductTax {
@@ -1598,6 +1694,7 @@ declare class ProductTax {
1598
1694
 
1599
1695
  declare class Product {
1600
1696
  id: number;
1697
+ vendorId: number;
1601
1698
  collectionId: number | null;
1602
1699
  brandId: number | null;
1603
1700
  categoryId: number | null;
@@ -1622,6 +1719,7 @@ declare class Product {
1622
1719
  updatedBy: number | null;
1623
1720
  deletedBy: number | null;
1624
1721
  seoId: number | null;
1722
+ vendor: Vendor;
1625
1723
  seo: Seo | null;
1626
1724
  collection: Collection | null;
1627
1725
  brand: Brand | null;
@@ -1634,8 +1732,12 @@ declare class OrderItem {
1634
1732
  id: number;
1635
1733
  orderId: number;
1636
1734
  productId: number;
1735
+ discountIds: number[];
1637
1736
  quantity: number;
1638
1737
  unitPrice: number;
1738
+ subTotal: number;
1739
+ discount: number;
1740
+ discountedAmount: number;
1639
1741
  tax: number;
1640
1742
  total: number;
1641
1743
  /** Snapshot at order time */
@@ -1654,6 +1756,7 @@ declare class OrderItem {
1654
1756
 
1655
1757
  declare class Payment {
1656
1758
  id: number;
1759
+ vendorId: number;
1657
1760
  orderId: number;
1658
1761
  contactId: number | null;
1659
1762
  amount: number;
@@ -1670,13 +1773,36 @@ declare class Payment {
1670
1773
  createdBy: number | null;
1671
1774
  updatedBy: number | null;
1672
1775
  deletedBy: number | null;
1776
+ vendor: Vendor;
1673
1777
  order: Order;
1674
1778
  contact: Contact | null;
1675
1779
  }
1676
1780
 
1781
+ declare enum AddressType {
1782
+ SHIPPING_ADDRESS = "shipping_address",
1783
+ BILLING_ADDRESS = "billing_address"
1784
+ }
1785
+ declare class OrderAddresses {
1786
+ id: number;
1787
+ contactId: number;
1788
+ addressType: AddressType;
1789
+ line1: string;
1790
+ line2: string | null;
1791
+ city: string;
1792
+ state: string;
1793
+ postalCode: string;
1794
+ country: string;
1795
+ createdAt: Date;
1796
+ updatedAt: Date;
1797
+ contact: Contact;
1798
+ billingOrders: Order[];
1799
+ shippingOrders: Order[];
1800
+ }
1801
+
1677
1802
  type OrderKind = 'sale' | 'return' | 'replacement';
1678
1803
  declare class Order {
1679
1804
  id: number;
1805
+ vendorId: number;
1680
1806
  orderNumber: string;
1681
1807
  orderKind: OrderKind;
1682
1808
  parentOrderId: number | null;
@@ -1697,11 +1823,12 @@ declare class Order {
1697
1823
  createdBy: number | null;
1698
1824
  updatedBy: number | null;
1699
1825
  deletedBy: number | null;
1826
+ vendor: Vendor;
1700
1827
  parentOrder: Order | null;
1701
1828
  children: Order[];
1702
1829
  contact: Contact;
1703
- billingAddress: Address | null;
1704
- shippingAddress: Address | null;
1830
+ billingAddress: OrderAddresses | null;
1831
+ shippingAddress: OrderAddresses | null;
1705
1832
  items: OrderItem[];
1706
1833
  payments: Payment[];
1707
1834
  }
@@ -1747,6 +1874,7 @@ declare class Contact {
1747
1874
  orders: Order[];
1748
1875
  payments: Payment[];
1749
1876
  chatConversations: ChatConversation[];
1877
+ orderAddresses: OrderAddresses[];
1750
1878
  }
1751
1879
 
1752
1880
  declare class Config {
@@ -1914,6 +2042,128 @@ declare class LlmAgent {
1914
2042
  /** Partial {@link LlmAgentOptions} for merging with `userPrompt` / `history` / `context`. */
1915
2043
  declare function llmAgentToChatAgentOptions(agent: LlmAgent): Pick<LlmAgentOptions, 'systemPrompt' | 'model' | 'temperature' | 'max_tokens'>;
1916
2044
 
2045
+ declare class Currency {
2046
+ id: number;
2047
+ code: string;
2048
+ name: string;
2049
+ symbol: string;
2050
+ isActive: boolean;
2051
+ isBaseCurrency: boolean;
2052
+ }
2053
+
2054
+ declare class CurrencyExchange {
2055
+ id: number;
2056
+ fromCurrency: string;
2057
+ toCurrency: string;
2058
+ rate: number;
2059
+ }
2060
+
2061
+ declare enum Type {
2062
+ MIN_AMOUNT = "minAmount",
2063
+ USER = "user",
2064
+ PRODUCT = "product",
2065
+ CATEGORY = "category",
2066
+ CART = "cart",
2067
+ PAYMENT_METHOD = "paymentMethod",
2068
+ ORDER = "order",
2069
+ QUANTITY = "quantity",
2070
+ TIME = "time",
2071
+ SHIPPING = "shipping",
2072
+ REFERRAL = "referral",
2073
+ REWARD = "reward"
2074
+ }
2075
+ declare enum SubType {
2076
+ USER_TYPE = "userType",
2077
+ USER_ID = "userId",
2078
+ PRODUCT_ID = "productId",
2079
+ CATEGORY_ID = "categoryId",
2080
+ CART_ID = "cartId",
2081
+ ORDER_ID = "orderId",
2082
+ FIRST_ORDER = "firstOrder",
2083
+ NTH_ORDER = "nthOrder",
2084
+ DATE_RANGE = "dateRange",
2085
+ DAY_OF_WEEK = "dayOfWeek",
2086
+ TIME_RANGE = "timeRange"
2087
+ }
2088
+ declare enum ConditionType {
2089
+ GROUP = "group",
2090
+ RULE = "rule"
2091
+ }
2092
+ declare enum ConditionOperator {
2093
+ AND = "and",
2094
+ OR = "or"
2095
+ }
2096
+ declare enum ComparisonOperator {
2097
+ EQ = "eq",
2098
+ NEQ = "neq",
2099
+ GT = "gt",
2100
+ GTE = "gte",
2101
+ LT = "lt",
2102
+ LTE = "lte",
2103
+ IN = "in",
2104
+ NOT_IN = "notIn",
2105
+ BETWEEN = "between"
2106
+ }
2107
+ declare class DiscountRules {
2108
+ id: number;
2109
+ discount: Discount;
2110
+ discountId: number;
2111
+ parent?: DiscountRules;
2112
+ children: DiscountRules[];
2113
+ parentId?: number;
2114
+ conditionType: ConditionType;
2115
+ conditionOperator?: ConditionOperator;
2116
+ type?: Type;
2117
+ subType?: SubType;
2118
+ comparisonOperator?: ComparisonOperator;
2119
+ value: Record<string, any>;
2120
+ }
2121
+
2122
+ declare enum DiscountType {
2123
+ PERCENTAGE = "PERCENTAGE",
2124
+ FLAT = "FLAT"
2125
+ }
2126
+ declare enum DiscountStatus {
2127
+ ACTIVE = "ACTIVE",
2128
+ INACTIVE = "INACTIVE",
2129
+ EXPIRED = "EXPIRED"
2130
+ }
2131
+ declare class Discount {
2132
+ id: number;
2133
+ vendorId: number;
2134
+ vendor: Vendor;
2135
+ name: string;
2136
+ couponCode: string;
2137
+ description?: string;
2138
+ discountType: DiscountType;
2139
+ value: number;
2140
+ maxDiscountAmount?: number;
2141
+ maxTotalUsage?: number;
2142
+ maxUsagePerUser?: number;
2143
+ usedCount: number;
2144
+ validFrom: Date;
2145
+ validUntil: Date;
2146
+ status: DiscountStatus;
2147
+ canCombineWithOtherDiscounts: boolean;
2148
+ isAutomatic: boolean;
2149
+ currency: string;
2150
+ rules: DiscountRules[];
2151
+ }
2152
+
2153
+ declare class OrderDiscounts {
2154
+ id: number;
2155
+ order: Order;
2156
+ orderId: number;
2157
+ orderItem: OrderItem;
2158
+ orderItemId: number;
2159
+ userId: number;
2160
+ discount?: Discount;
2161
+ discountId: number;
2162
+ discountCode: string;
2163
+ discountAmount: number;
2164
+ metaData?: Record<string, any>;
2165
+ }
2166
+
1917
2167
  declare class RssArticle {
1918
2168
  id: string;
1919
2169
  rssFeedId: string;
@@ -1946,7 +2196,22 @@ declare class RssFeed {
1946
2196
  updatedAt: Date;
1947
2197
  }
1948
2198
 
2199
+ /** Links a contact (customer) to a vendor store. One contact can belong to multiple vendors. */
2200
+ declare class VendorCustomer {
2201
+ id: number;
2202
+ vendorId: number;
2203
+ contactId: number;
2204
+ /** Optional vendor-specific notes about this customer. */
2205
+ notes: string | null;
2206
+ /** Optional vendor-specific tags/labels. */
2207
+ tags: string[] | null;
2208
+ createdAt: Date;
2209
+ updatedAt: Date;
2210
+ vendor: Vendor;
2211
+ contact: Contact;
2212
+ }
2213
+
1949
2214
  /** Map API resource segment (e.g. "blogs", "form_submissions") to entity. Used by CRUD handler. */
1950
2215
  declare const CMS_ENTITY_MAP: Record<string, EntityTarget<typeorm.ObjectLiteral>>;
1951
2216
 
1952
- 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, type DataSourceManager, 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, Order, 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, type SmsJobPayload, type SmsPluginConfig, type SmsProviderChoice, type SmsProviderId, type SmsServiceConfig, type SmsServiceInterface, type SocialMediaPluginConfig, StorageService, Tag, Tax, TemplateContext, User, UserGroup, Wishlist, WishlistItem, ZIP_MIME_TYPES, allowRateLimit, analyticsPlugin, assertCaptchaOk, blogGeneratorPlugin, buildBlogMetadataUserPrompt, buildCaptchaPublicConfig, buildCronFromSchedule, buildRssUserPromptFromFeeds, cachePlugin, captchaPlugin, cn, countRecentOtpSends, createCmsApp, createDataSourceManager, createOtpChallenge, createSocialMediaHandlers, emailPlugin, emailTemplates, ensureScheduleQueueWorker, erpPlugin, fetchSeoBySlug, formatDate, formatDateOnly, formatDateTime, generateNumericOtp, generateSlug, getRssArticleSummaryFromItem, hashOtpCode, isZipMedia, joinRecipientsForSend, linkUnclaimedContactToUser, llmAgentToChatAgentOptions, llmPlugin, loadPublicThemeSettings, 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, s3StoragePlugin, sanitizeMediaFolderPath, sanitizeStorageSegment, seedDefaultAdmin, sendOrderPlacedEmailsAfterConfirmation, serializeEmailRecipients, shouldRateLimitPublicWrite, smsPlugin, socialMediaPlugin, syncJobScheduleToPgBoss, truncateText, validateScheduleInput, validateSlug, verifyAndConsumeOtpChallenge, verifyOtpCodeHash };
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 };