@infuro/cms-core 1.0.30 → 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 +12886 -8223
  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 +12668 -8004
  7. package/dist/admin.js.map +1 -1
  8. package/dist/api.cjs +4873 -1096
  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 +4621 -838
  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 +16 -13
  21. package/dist/cli.cjs.map +1 -1
  22. package/dist/cli.js +16 -13
  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 +4622 -765
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +300 -36
  29. package/dist/index.d.ts +300 -36
  30. package/dist/index.js +4549 -723
  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 +2 -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.cts 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-BPQSXgXF.cjs';
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-BPQSXgXF.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-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';
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.cjs';
9
- import { E as EntityCrudAction } from './helpers-dlrF_49e.cjs';
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.cjs';
11
- export { AuthorizeOtpInput, CmsMiddlewareConfig, NextAuthOptionsConfig, NextAuthUser, createCmsMiddleware, defaultPublicApiMethods, getNextAuthOptions, seedAdministratorPermissions } from './auth.cjs';
8
+ import { NextAuthUser } from './auth.cjs';
9
+ export { AuthorizeOtpInput, CmsMiddlewareConfig, NextAuthOptionsConfig, createCmsMiddleware, defaultPublicApiMethods, explainSessionEntityAccess, getNextAuthOptions, isRbacDebugEnabled, logEntityAccessDecision, logRbac, seedAdministratorPermissions, summarizeEntityPerms } from './auth.cjs';
10
+ import { E as EntityCrudAction, S as SessionUser, e as VendorScope } from './vendor-scope-DTYhJk_I.cjs';
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
+ import { a as NavbarConfig, F as FooterConfig } from './types-DCVaXlPV.cjs';
12
13
  export { A as AdminNavItem, D as DEFAULT_ADMIN_NAV } from './config-DJ5CmQvS.cjs';
13
14
  import 'next-auth';
14
15
 
@@ -1209,33 +1210,29 @@ declare function seedDefaultAdmin(ds: DataSource, entityMap: SeedEntityMap, opts
1209
1210
  password?: string;
1210
1211
  }): Promise<void>;
1211
1212
 
1212
- interface PublicThemeSettingsPayload {
1213
- activeThemeId: string;
1214
- primaryColor: string;
1215
- secondaryColor: string;
1216
- navbarConfig: NavbarConfig;
1217
- 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[];
1218
1235
  }
1219
- declare function loadPublicThemeSettings(config: {
1220
- dataSource: DataSource;
1221
- entityMap: EntityMap$2;
1222
- encryptionKey?: string;
1223
- defaultActiveThemeId?: string;
1224
- defaultPrimaryColor?: string;
1225
- defaultSecondaryColor?: string;
1226
- }): Promise<PublicThemeSettingsPayload>;
1227
-
1228
- /** Normalize a logical media folder path: no leading/trailing slashes, no ".." segments, max length. */
1229
- declare function sanitizeMediaFolderPath(input: unknown): string;
1230
- /** Single path segment for storage (folder name or legacy path segment). */
1231
- declare function sanitizeStorageSegment(name: string): string;
1232
-
1233
- type EntityMap = Record<string, EntityTarget<ObjectLiteral>>;
1234
- /** Build `a/b/c` path under `uploads/` from the chain of folder rows up to root. */
1235
- declare function relativePathFromMediaParentId(dataSource: DataSource, entityMap: EntityMap, parentId: number | null): Promise<string>;
1236
-
1237
- declare const ZIP_MIME_TYPES: Set<string>;
1238
- declare function isZipMedia(mime: string | null | undefined, filename: string): boolean;
1239
1236
 
1240
1237
  declare class Permission {
1241
1238
  id: number;
@@ -1291,6 +1288,94 @@ declare class User {
1291
1288
  group: UserGroup | null;
1292
1289
  }
1293
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
+
1294
1379
  declare class OtpChallenge {
1295
1380
  id: number;
1296
1381
  purpose: string;
@@ -1468,6 +1553,7 @@ declare class Address {
1468
1553
 
1469
1554
  declare class ProductCategory {
1470
1555
  id: number;
1556
+ vendorId: number;
1471
1557
  name: string;
1472
1558
  slug: string;
1473
1559
  parentId: number | null;
@@ -1483,6 +1569,7 @@ declare class ProductCategory {
1483
1569
  createdBy: number | null;
1484
1570
  updatedBy: number | null;
1485
1571
  deletedBy: number | null;
1572
+ vendor: Vendor;
1486
1573
  parent: ProductCategory | null;
1487
1574
  children: ProductCategory[];
1488
1575
  products: Product[];
@@ -1491,6 +1578,7 @@ declare class ProductCategory {
1491
1578
 
1492
1579
  declare class Brand {
1493
1580
  id: number;
1581
+ vendorId: number;
1494
1582
  name: string;
1495
1583
  slug: string;
1496
1584
  logo: string | null;
@@ -1506,6 +1594,7 @@ declare class Brand {
1506
1594
  updatedBy: number | null;
1507
1595
  deletedBy: number | null;
1508
1596
  seoId: number | null;
1597
+ vendor: Vendor;
1509
1598
  seo: Seo | null;
1510
1599
  products: Product[];
1511
1600
  collections: Collection[];
@@ -1513,6 +1602,7 @@ declare class Brand {
1513
1602
 
1514
1603
  declare class Collection {
1515
1604
  id: number;
1605
+ vendorId: number;
1516
1606
  categoryId: number | null;
1517
1607
  brandId: number | null;
1518
1608
  name: string;
@@ -1532,6 +1622,7 @@ declare class Collection {
1532
1622
  updatedBy: number | null;
1533
1623
  deletedBy: number | null;
1534
1624
  seoId: number | null;
1625
+ vendor: Vendor;
1535
1626
  seo: Seo | null;
1536
1627
  category: ProductCategory | null;
1537
1628
  brand: Brand | null;
@@ -1540,6 +1631,7 @@ declare class Collection {
1540
1631
 
1541
1632
  declare class Attribute {
1542
1633
  id: number;
1634
+ vendorId: number;
1543
1635
  name: string;
1544
1636
  slug: string;
1545
1637
  type: 'text' | 'number' | 'select' | 'boolean';
@@ -1554,6 +1646,7 @@ declare class Attribute {
1554
1646
  createdBy: number | null;
1555
1647
  updatedBy: number | null;
1556
1648
  deletedBy: number | null;
1649
+ vendor: Vendor;
1557
1650
  }
1558
1651
 
1559
1652
  declare class ProductAttribute {
@@ -1570,6 +1663,7 @@ declare class ProductAttribute {
1570
1663
 
1571
1664
  declare class Tax {
1572
1665
  id: number;
1666
+ vendorId: number;
1573
1667
  name: string;
1574
1668
  slug: string;
1575
1669
  rate: number;
@@ -1584,6 +1678,7 @@ declare class Tax {
1584
1678
  createdBy: number | null;
1585
1679
  updatedBy: number | null;
1586
1680
  deletedBy: number | null;
1681
+ vendor: Vendor;
1587
1682
  }
1588
1683
 
1589
1684
  declare class ProductTax {
@@ -1599,6 +1694,7 @@ declare class ProductTax {
1599
1694
 
1600
1695
  declare class Product {
1601
1696
  id: number;
1697
+ vendorId: number;
1602
1698
  collectionId: number | null;
1603
1699
  brandId: number | null;
1604
1700
  categoryId: number | null;
@@ -1623,6 +1719,7 @@ declare class Product {
1623
1719
  updatedBy: number | null;
1624
1720
  deletedBy: number | null;
1625
1721
  seoId: number | null;
1722
+ vendor: Vendor;
1626
1723
  seo: Seo | null;
1627
1724
  collection: Collection | null;
1628
1725
  brand: Brand | null;
@@ -1635,8 +1732,12 @@ declare class OrderItem {
1635
1732
  id: number;
1636
1733
  orderId: number;
1637
1734
  productId: number;
1735
+ discountIds: number[];
1638
1736
  quantity: number;
1639
1737
  unitPrice: number;
1738
+ subTotal: number;
1739
+ discount: number;
1740
+ discountedAmount: number;
1640
1741
  tax: number;
1641
1742
  total: number;
1642
1743
  /** Snapshot at order time */
@@ -1655,6 +1756,7 @@ declare class OrderItem {
1655
1756
 
1656
1757
  declare class Payment {
1657
1758
  id: number;
1759
+ vendorId: number;
1658
1760
  orderId: number;
1659
1761
  contactId: number | null;
1660
1762
  amount: number;
@@ -1671,13 +1773,36 @@ declare class Payment {
1671
1773
  createdBy: number | null;
1672
1774
  updatedBy: number | null;
1673
1775
  deletedBy: number | null;
1776
+ vendor: Vendor;
1674
1777
  order: Order;
1675
1778
  contact: Contact | null;
1676
1779
  }
1677
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
+
1678
1802
  type OrderKind = 'sale' | 'return' | 'replacement';
1679
1803
  declare class Order {
1680
1804
  id: number;
1805
+ vendorId: number;
1681
1806
  orderNumber: string;
1682
1807
  orderKind: OrderKind;
1683
1808
  parentOrderId: number | null;
@@ -1698,11 +1823,12 @@ declare class Order {
1698
1823
  createdBy: number | null;
1699
1824
  updatedBy: number | null;
1700
1825
  deletedBy: number | null;
1826
+ vendor: Vendor;
1701
1827
  parentOrder: Order | null;
1702
1828
  children: Order[];
1703
1829
  contact: Contact;
1704
- billingAddress: Address | null;
1705
- shippingAddress: Address | null;
1830
+ billingAddress: OrderAddresses | null;
1831
+ shippingAddress: OrderAddresses | null;
1706
1832
  items: OrderItem[];
1707
1833
  payments: Payment[];
1708
1834
  }
@@ -1748,6 +1874,7 @@ declare class Contact {
1748
1874
  orders: Order[];
1749
1875
  payments: Payment[];
1750
1876
  chatConversations: ChatConversation[];
1877
+ orderAddresses: OrderAddresses[];
1751
1878
  }
1752
1879
 
1753
1880
  declare class Config {
@@ -1915,6 +2042,128 @@ declare class LlmAgent {
1915
2042
  /** Partial {@link LlmAgentOptions} for merging with `userPrompt` / `history` / `context`. */
1916
2043
  declare function llmAgentToChatAgentOptions(agent: LlmAgent): Pick<LlmAgentOptions, 'systemPrompt' | 'model' | 'temperature' | 'max_tokens'>;
1917
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
+
1918
2167
  declare class RssArticle {
1919
2168
  id: string;
1920
2169
  rssFeedId: string;
@@ -1947,7 +2196,22 @@ declare class RssFeed {
1947
2196
  updatedAt: Date;
1948
2197
  }
1949
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
+
1950
2214
  /** Map API resource segment (e.g. "blogs", "form_submissions") to entity. Used by CRUD handler. */
1951
2215
  declare const CMS_ENTITY_MAP: Record<string, EntityTarget<typeorm.ObjectLiteral>>;
1952
2216
 
1953
- 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 };