@timardex/cluemart-server-shared 4.1.0 → 4.2.1

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.
@@ -43,6 +43,7 @@ __export(mongoose_exports, {
43
43
  AiImportRunModel: () => AiImportRunModel,
44
44
  AiImportedMarketModel: () => AiImportedMarketModel,
45
45
  AppSettingModel: () => AppSettingModel,
46
+ AssociateTypeSchema: () => AssociateTypeSchema,
46
47
  AuthHandoffTokenModel: () => AuthHandoffTokenModel,
47
48
  BILLING_CATALOG_COLLECTION_NAME: () => BILLING_CATALOG_COLLECTION_NAME,
48
49
  BillingCatalogModel: () => BillingCatalogModel,
@@ -776,6 +777,25 @@ var OwnerTypeSchema = new MongooseSchema5(
776
777
  { _id: false }
777
778
  // Prevents Mongoose from creating an additional _id field for subdocuments
778
779
  );
780
+ var AssociateTypeSchema = new MongooseSchema5(
781
+ {
782
+ addedAt: { default: Date.now, required: false, type: Date },
783
+ email: { lowercase: true, required: true, trim: true, type: String },
784
+ respondedAt: { default: null, required: false, type: Date },
785
+ status: {
786
+ default: import_cluemart_shared8.EnumAssociateStatus.PENDING,
787
+ enum: Object.values(import_cluemart_shared8.EnumAssociateStatus),
788
+ required: true,
789
+ type: String
790
+ },
791
+ userId: {
792
+ ref: "User",
793
+ required: true,
794
+ type: import_mongoose9.default.Schema.Types.ObjectId
795
+ }
796
+ },
797
+ { _id: false }
798
+ );
779
799
  var SocialMediaTypeSchema = new MongooseSchema5(
780
800
  {
781
801
  link: { required: true, type: String },
@@ -941,6 +961,7 @@ var baseResourceFields = {
941
961
  type: [import_mongoose9.default.Schema.Types.ObjectId]
942
962
  },
943
963
  approvedAt: { default: null, required: false, type: Date },
964
+ associates: { default: [], required: false, type: [AssociateTypeSchema] },
944
965
  contactDetails: { required: false, type: ContactDetailsSchema },
945
966
  cover: {
946
967
  required: true,
@@ -1822,6 +1843,29 @@ var userOverallPointsSchema = new MongooseSchema16(
1822
1843
  },
1823
1844
  { _id: false }
1824
1845
  );
1846
+ var userAssociatedResourcesSchema = new MongooseSchema16(
1847
+ {
1848
+ events: {
1849
+ default: [],
1850
+ ref: "Event",
1851
+ required: false,
1852
+ type: [import_mongoose20.default.Schema.Types.ObjectId]
1853
+ },
1854
+ partners: {
1855
+ default: [],
1856
+ ref: "Partner",
1857
+ required: false,
1858
+ type: [import_mongoose20.default.Schema.Types.ObjectId]
1859
+ },
1860
+ vendors: {
1861
+ default: [],
1862
+ ref: "Vendor",
1863
+ required: false,
1864
+ type: [import_mongoose20.default.Schema.Types.ObjectId]
1865
+ }
1866
+ },
1867
+ { _id: false }
1868
+ );
1825
1869
  var schema15 = new MongooseSchema16(
1826
1870
  {
1827
1871
  active: { default: false, required: true, type: Boolean },
@@ -1830,6 +1874,11 @@ var schema15 = new MongooseSchema16(
1830
1874
  required: false,
1831
1875
  type: import_mongoose20.default.Schema.Types.ObjectId
1832
1876
  },
1877
+ associatedResources: {
1878
+ default: () => ({ events: [], partners: [], vendors: [] }),
1879
+ required: false,
1880
+ type: userAssociatedResourcesSchema
1881
+ },
1833
1882
  avatar: {
1834
1883
  required: false,
1835
1884
  type: ResourceImageTypeSchema
@@ -1840,7 +1889,10 @@ var schema15 = new MongooseSchema16(
1840
1889
  type: import_mongoose20.default.Schema.Types.ObjectId
1841
1890
  },
1842
1891
  deletedAt: { default: null, required: false, type: Date },
1843
- email: { required: true, type: String },
1892
+ // `normalizeEmail` (`cluemart-shared`) is trim + lower-case; keeping the same
1893
+ // rule here means every write path — resolvers, seeds, scripts — stores the
1894
+ // comparable form, not only the clients that validate through `emailRequiredSchema`.
1895
+ email: { lowercase: true, required: true, trim: true, type: String },
1844
1896
  emailSentFor: {
1845
1897
  enum: Object.values(import_cluemart_shared16.EnumNotificationResourceType),
1846
1898
  required: false,
@@ -1955,6 +2007,10 @@ schema15.index({ "licences.expiryDate": 1 });
1955
2007
  schema15.index({ "licences.licenceType": 1 });
1956
2008
  schema15.index({ promoCodes: 1, active: 1, deletedAt: 1 });
1957
2009
  schema15.index({ email: "text", firstName: "text", lastName: "text" });
2010
+ schema15.index({ email: 1 }, { name: "email_unique", unique: true });
2011
+ schema15.index({ "associatedResources.events": 1 });
2012
+ schema15.index({ "associatedResources.partners": 1 });
2013
+ schema15.index({ "associatedResources.vendors": 1 });
1958
2014
  var UserModel = import_mongoose20.default.models.User || import_mongoose20.default.model("User", schema15);
1959
2015
 
1960
2016
  // src/mongoose/VerificationToken.ts
@@ -2088,6 +2144,7 @@ schema17.index({
2088
2144
  name: "text"
2089
2145
  });
2090
2146
  schema17.index({ deletedAt: 1, "owner.userId": 1 });
2147
+ schema17.index({ "associates.userId": 1, deletedAt: 1 });
2091
2148
  schema17.plugin(searchNamePlugin);
2092
2149
  var VendorModel = import_mongoose22.default.models.Vendor || import_mongoose22.default.model("Vendor", schema17);
2093
2150
 
@@ -2239,6 +2296,7 @@ schema20.index({ "dateTime.dateStatus": 1 });
2239
2296
  schema20.index({ slug: 1 });
2240
2297
  schema20.index({ description: "text", name: "text", tags: "text" });
2241
2298
  schema20.index({ deletedAt: 1, "owner.userId": 1 });
2299
+ schema20.index({ "associates.userId": 1, deletedAt: 1 });
2242
2300
  schema20.plugin(searchNamePlugin);
2243
2301
  var EventModel = import_mongoose25.default.models.Event || import_mongoose25.default.model("Event", schema20);
2244
2302
 
@@ -2285,6 +2343,7 @@ schema22.index({ "location.geo": "2dsphere" });
2285
2343
  schema22.index({ slug: 1 });
2286
2344
  schema22.index({ name: "text", description: "text" });
2287
2345
  schema22.index({ "owner.userId": 1, deletedAt: 1 });
2346
+ schema22.index({ "associates.userId": 1, deletedAt: 1 });
2288
2347
  schema22.plugin(searchNamePlugin);
2289
2348
  var PartnerModel = import_mongoose27.default.models.Partner || import_mongoose27.default.model("Partner", schema22);
2290
2349
 
@@ -2937,6 +2996,7 @@ var ImpersonationAuditModel = import_mongoose38.default.models.ImpersonationAudi
2937
2996
  AiImportRunModel,
2938
2997
  AiImportedMarketModel,
2939
2998
  AppSettingModel,
2999
+ AssociateTypeSchema,
2940
3000
  AuthHandoffTokenModel,
2941
3001
  BILLING_CATALOG_COLLECTION_NAME,
2942
3002
  BillingCatalogModel,