@timardex/cluemart-server-shared 1.0.179 → 1.0.201

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,11 +1,10 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
- import { AdType, CreateBulkNotificationInput, NotificationType, EnumUserRole, ChatMessageType, ParticipantType, ChatType, ReportChatUser, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, GoogleImportedMarket, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, AppSettingsType, GameType, GameDocType, SchoolType, EnumUserLicence, DateTimeWithPriceType } from '@timardex/cluemart-shared';
2
+ import { AdType, CreateBulkNotificationInput, NotificationType, EnumUserRole, ChatMessageType, ParticipantType, ChatType, ReportChatUser, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, AppSettingsType, GameType, GameDocType, SchoolType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
3
3
  import mongoose from 'mongoose';
4
4
  export { default as mongoose } from 'mongoose';
5
5
  import { NotificationCount, DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
6
6
  import express from 'express';
7
7
  export { default as express } from 'express';
8
- import { EnumOSPlatform } from '@timardex/cluemart-shared/enums';
9
8
 
10
9
  declare const AdModel: mongoose.Model<AdType, {}, {}, {}, mongoose.Document<unknown, {}, AdType, {}, {}> & AdType & Required<{
11
10
  _id: string;
@@ -62,13 +61,11 @@ interface GraphQLContext {
62
61
  type SchemaChatMessageReplyPreviewType = Omit<NonNullable<ChatMessageType["replyPreview"]>, "senderId"> & {
63
62
  senderId: ObjectId;
64
63
  };
65
- type SchemaChatMessageReactionType = Omit<NonNullable<ChatMessageType["likedBy"]>[number], "userId" | "createdAt"> & {
64
+ type SchemaChatMessageReactionType = Omit<NonNullable<ChatMessageType["likedBy"]>[number], "userId"> & {
66
65
  userId: ObjectId;
67
- createdAt: Date;
68
66
  };
69
- type SchemaChatMessageSeenType = Omit<NonNullable<ChatMessageType["seenBy"]>[number], "userId" | "seenAt"> & {
67
+ type SchemaChatMessageSeenType = Omit<NonNullable<ChatMessageType["seenBy"]>[number], "userId"> & {
70
68
  userId: ObjectId;
71
- seenAt: Date;
72
69
  };
73
70
  type SchemaChatMessageType = Omit<ChatMessageType, "senderId" | "replyToMessageId" | "replyPreview" | "likedBy" | "seenBy"> & {
74
71
  senderId: ObjectId;
@@ -411,14 +408,6 @@ declare const GoogleImportedMarketModel: mongoose.Model<SchemaGoogleImportedMark
411
408
  __v: number;
412
409
  }, any>;
413
410
 
414
- type PushTokenType = {
415
- _id: string;
416
- createdAt: Date;
417
- platform: EnumOSPlatform;
418
- token: string;
419
- updatedAt: Date;
420
- userId: string;
421
- };
422
411
  type SchemaPushTokenType = Omit<PushTokenType, "userId"> & {
423
412
  userId: ObjectId;
424
413
  };
@@ -722,10 +711,7 @@ declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceType: E
722
711
  */
723
712
  declare function convertObjectIdsToStrings(obj: any): any;
724
713
 
725
- type EventOrMarket = {
726
- _id: ObjectId | string;
727
- name: string;
728
- } | null;
714
+ type EventOrMarket = Pick<EventListItemType, "_id" | "name"> | null;
729
715
  /**
730
716
  * This function attempts to find an Event or a Google Imported Market by the given resource ID.
731
717
  * It first normalizes the resource ID to a string format, then performs parallel queries to both collections.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
- import { AdType, CreateBulkNotificationInput, NotificationType, EnumUserRole, ChatMessageType, ParticipantType, ChatType, ReportChatUser, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, GoogleImportedMarket, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, AppSettingsType, GameType, GameDocType, SchoolType, EnumUserLicence, DateTimeWithPriceType } from '@timardex/cluemart-shared';
2
+ import { AdType, CreateBulkNotificationInput, NotificationType, EnumUserRole, ChatMessageType, ParticipantType, ChatType, ReportChatUser, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, AppSettingsType, GameType, GameDocType, SchoolType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
3
3
  import mongoose from 'mongoose';
4
4
  export { default as mongoose } from 'mongoose';
5
5
  import { NotificationCount, DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
6
6
  import express from 'express';
7
7
  export { default as express } from 'express';
8
- import { EnumOSPlatform } from '@timardex/cluemart-shared/enums';
9
8
 
10
9
  declare const AdModel: mongoose.Model<AdType, {}, {}, {}, mongoose.Document<unknown, {}, AdType, {}, {}> & AdType & Required<{
11
10
  _id: string;
@@ -62,13 +61,11 @@ interface GraphQLContext {
62
61
  type SchemaChatMessageReplyPreviewType = Omit<NonNullable<ChatMessageType["replyPreview"]>, "senderId"> & {
63
62
  senderId: ObjectId;
64
63
  };
65
- type SchemaChatMessageReactionType = Omit<NonNullable<ChatMessageType["likedBy"]>[number], "userId" | "createdAt"> & {
64
+ type SchemaChatMessageReactionType = Omit<NonNullable<ChatMessageType["likedBy"]>[number], "userId"> & {
66
65
  userId: ObjectId;
67
- createdAt: Date;
68
66
  };
69
- type SchemaChatMessageSeenType = Omit<NonNullable<ChatMessageType["seenBy"]>[number], "userId" | "seenAt"> & {
67
+ type SchemaChatMessageSeenType = Omit<NonNullable<ChatMessageType["seenBy"]>[number], "userId"> & {
70
68
  userId: ObjectId;
71
- seenAt: Date;
72
69
  };
73
70
  type SchemaChatMessageType = Omit<ChatMessageType, "senderId" | "replyToMessageId" | "replyPreview" | "likedBy" | "seenBy"> & {
74
71
  senderId: ObjectId;
@@ -411,14 +408,6 @@ declare const GoogleImportedMarketModel: mongoose.Model<SchemaGoogleImportedMark
411
408
  __v: number;
412
409
  }, any>;
413
410
 
414
- type PushTokenType = {
415
- _id: string;
416
- createdAt: Date;
417
- platform: EnumOSPlatform;
418
- token: string;
419
- updatedAt: Date;
420
- userId: string;
421
- };
422
411
  type SchemaPushTokenType = Omit<PushTokenType, "userId"> & {
423
412
  userId: ObjectId;
424
413
  };
@@ -722,10 +711,7 @@ declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceType: E
722
711
  */
723
712
  declare function convertObjectIdsToStrings(obj: any): any;
724
713
 
725
- type EventOrMarket = {
726
- _id: ObjectId | string;
727
- name: string;
728
- } | null;
714
+ type EventOrMarket = Pick<EventListItemType, "_id" | "name"> | null;
729
715
  /**
730
716
  * This function attempts to find an Event or a Google Imported Market by the given resource ID.
731
717
  * It first normalizes the resource ID to a string format, then performs parallel queries to both collections.
package/dist/index.mjs CHANGED
@@ -7281,7 +7281,12 @@ var gameScreenIdentifierList = [
7281
7281
  match: "/events/events-near-me"
7282
7282
  },
7283
7283
  {
7284
- clue: "A collection of things worth attending.",
7284
+ clue: "Where events appear as pins on a map.",
7285
+ id: "events-map",
7286
+ match: "/events/events-map"
7287
+ },
7288
+ {
7289
+ clue: "A collection of events worth attending.",
7285
7290
  id: "events",
7286
7291
  match: "/events"
7287
7292
  },
@@ -7374,6 +7379,7 @@ function normalizeUrl(url) {
7374
7379
  }
7375
7380
  return url;
7376
7381
  }
7382
+ var CLUEMART_MAIN_DOMAIN_URL = "https://cluemart.co.nz";
7377
7383
  var SCHOOL_MIN_STUDENT_COUNT = 300;
7378
7384
  var packagingTypes = [
7379
7385
  "Biodegradable",
@@ -8779,7 +8785,6 @@ var USER_FIELDS_FRAGMENT = gql`
8779
8785
  platform
8780
8786
  preferredRegion
8781
8787
  promoCodes
8782
- refreshToken
8783
8788
  role
8784
8789
  school
8785
8790
  termsAgreement {
@@ -9029,7 +9034,10 @@ var GET_EVENT_BY_PLACE_ID = gql`
9029
9034
  ${EVENT_LIST_ITEM}
9030
9035
  `;
9031
9036
  var GET_EVENTS_BY_REGION = gql`
9032
- query getEventsByRegion($region: String!, $options: EventsByRegionOptions) {
9037
+ query getEventsByRegion(
9038
+ $region: String!
9039
+ $options: ResourcesByRegionOptions
9040
+ ) {
9033
9041
  eventsByRegion(region: $region, options: $options) {
9034
9042
  ...EventListItemFields
9035
9043
  }
@@ -9037,7 +9045,7 @@ var GET_EVENTS_BY_REGION = gql`
9037
9045
  ${EVENT_LIST_ITEM}
9038
9046
  `;
9039
9047
  var SEARCH_EVENTS = gql`
9040
- query searchEvents($region: String, $search: String,$tags: [String]) {
9048
+ query searchEvents($region: String, $search: String, $tags: [String]) {
9041
9049
  eventsSearch(region: $region, search: $search, tags: $tags) {
9042
9050
  ...EventListItemFields
9043
9051
  }
@@ -9261,8 +9269,11 @@ var GET_VENDOR = gql`
9261
9269
  ${VENDOR}
9262
9270
  `;
9263
9271
  var GET_VENDORS_BY_REGION = gql`
9264
- query getVendorsByRegion($region: String!) {
9265
- vendorsByRegion(region: $region) {
9272
+ query getVendorsByRegion(
9273
+ $region: String!
9274
+ $options: ResourcesByRegionOptions
9275
+ ) {
9276
+ vendorsByRegion(region: $region, options: $options) {
9266
9277
  ...VendorFields
9267
9278
  }
9268
9279
  }
@@ -9658,8 +9669,11 @@ var GET_PARTNER = gql`
9658
9669
  ${PARTNER}
9659
9670
  `;
9660
9671
  var GET_PARTNERS_BY_REGION = gql`
9661
- query getPartnersByRegion($region: String!) {
9662
- partnersByRegion(region: $region) {
9672
+ query getPartnersByRegion(
9673
+ $region: String!
9674
+ $options: ResourcesByRegionOptions
9675
+ ) {
9676
+ partnersByRegion(region: $region, options: $options) {
9663
9677
  ...PartnerFields
9664
9678
  }
9665
9679
  }
@@ -9862,7 +9876,6 @@ var RELATION_FIELDS_FRAGMENT = gql`
9862
9876
  fragment RelationFields on RelationType {
9863
9877
  _id
9864
9878
  active
9865
- apiMessage
9866
9879
  chatId
9867
9880
  createdAt
9868
9881
  lastUpdateBy
@@ -10878,7 +10891,7 @@ var emailOptionalSchema = create$6().nullable().notRequired().transform(
10878
10891
  (value) => !value || create$6().email().isValidSync(value)
10879
10892
  ).label("Email");
10880
10893
  var mobileRegex = /^02\d{7,9}$/;
10881
- var landlineRegex = /^(0(3|4|6|7|9)[0-9]{7})$/;
10894
+ var landlineRegex = /^0[34679]\d{7}$/;
10882
10895
  var mobilePhoneSchema = create$6().label("Mobile Phone").nullable().notRequired().test(
10883
10896
  "mobile-phone",
10884
10897
  "Mobile must start with 02 and be 9\u201311 digits",
@@ -11263,12 +11276,12 @@ var validateVerificationTokenSchema = create$3().shape({
11263
11276
  email: emailRequiredSchema,
11264
11277
  verificationToken: create$6().required("Verification code is required").matches(/^\d{6}$/, "Verification code must be exactly 6 digits")
11265
11278
  });
11266
- var EnumAdShowOn = /* @__PURE__ */ ((EnumAdShowOn3) => {
11267
- EnumAdShowOn3["EVENTS_PAGE"] = "Events_page";
11268
- EnumAdShowOn3["FRONT_PAGE"] = "Front_page";
11269
- EnumAdShowOn3["PARTNERS_PAGE"] = "Partners_page";
11270
- EnumAdShowOn3["VENDORS_PAGE"] = "Vendors_page";
11271
- return EnumAdShowOn3;
11279
+ var EnumAdShowOn = /* @__PURE__ */ ((EnumAdShowOn2) => {
11280
+ EnumAdShowOn2["EVENTS_PAGE"] = "Events_page";
11281
+ EnumAdShowOn2["FRONT_PAGE"] = "Front_page";
11282
+ EnumAdShowOn2["PARTNERS_PAGE"] = "Partners_page";
11283
+ EnumAdShowOn2["VENDORS_PAGE"] = "Vendors_page";
11284
+ return EnumAdShowOn2;
11272
11285
  })(EnumAdShowOn || {});
11273
11286
  var EnumAdStatus = /* @__PURE__ */ ((EnumAdStatus2) => {
11274
11287
  EnumAdStatus2["ACTIVE"] = "Active";
@@ -11287,15 +11300,15 @@ var EnumAdStyle = /* @__PURE__ */ ((EnumAdStyle2) => {
11287
11300
  return EnumAdStyle2;
11288
11301
  })(EnumAdStyle || {});
11289
11302
  var adResourceSchema = create$3({
11290
- adDescription: create$6().nullable().trim().required("Ad description is required").max(150, "Ad description must be at most 150 characters"),
11291
- adImage: create$6().nullable().required("Ad image is required"),
11292
- adStyle: create$8().nullable().oneOf(Object.values(EnumAdStyle), "Please select a valid ad style").required("Ad style is required"),
11293
- adTitle: create$6().nullable().trim().required("Ad title is required").max(30, "Ad title must be at most 30 characters"),
11294
- adType: create$8().nullable().oneOf(Object.values(EnumAdType), "Please select a valid ad type").required("Ad type is required"),
11295
- resourceId: create$6().nullable().required("Resource ID is required"),
11296
- resourceName: create$6().nullable().required("Resource name is required"),
11297
- resourceRegion: create$6().nullable().required("Resource region is required"),
11298
- resourceType: create$8().nullable().oneOf(Object.values(EnumResourceType), "Please select Event or Vendor").required("Resource type is required")
11303
+ adDescription: create$6().trim().required("Ad description is required").max(150, "Ad description must be at most 150 characters"),
11304
+ adImage: create$6().required("Ad image is required"),
11305
+ adStyle: create$8().oneOf(Object.values(EnumAdStyle), "Please select a valid ad style").required("Ad style is required"),
11306
+ adTitle: create$6().trim().required("Ad title is required").max(30, "Ad title must be at most 30 characters"),
11307
+ adType: create$8().oneOf(Object.values(EnumAdType), "Please select a valid ad type").required("Ad type is required"),
11308
+ resourceId: create$6().required("Resource ID is required"),
11309
+ resourceName: create$6().required("Resource name is required"),
11310
+ resourceRegion: create$6().required("Resource region is required"),
11311
+ resourceType: create$8().oneOf(Object.values(EnumResourceType), "Please select Event or Vendor").required("Resource type is required")
11299
11312
  });
11300
11313
  var adSchema = create$3().shape({
11301
11314
  active: create$7().required("Active status is required"),
@@ -11325,7 +11338,8 @@ var adSchema = create$3().shape({
11325
11338
  if (!value) return false;
11326
11339
  return value > /* @__PURE__ */ new Date();
11327
11340
  }),
11328
- otherwise: () => create$4().nullable().notRequired()
11341
+ // Keep `start` optional (not null) when ACTIVE to match TS type `start?: Date`.
11342
+ otherwise: () => create$4().notRequired()
11329
11343
  }),
11330
11344
  targetRegion: create$2().of(create$6().required()).min(1, "At least one target region is required").required("Target region is required")
11331
11345
  });
@@ -11453,6 +11467,31 @@ var contactUsSchema = create$3().shape({
11453
11467
  lastName: create$6().label("Last Name").required("Last name is required"),
11454
11468
  message: create$6().label("Message").required("Message is required")
11455
11469
  });
11470
+ var defaultValues8 = {
11471
+ active: true,
11472
+ // Use a future default so yup "future date" rules pass on first submit.
11473
+ end: new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3),
11474
+ resource: {
11475
+ adDescription: "",
11476
+ adImage: "",
11477
+ adStyle: "Bloom",
11478
+ adTitle: "",
11479
+ adType: "Sponsored",
11480
+ resourceId: "",
11481
+ resourceName: "",
11482
+ resourceRegion: "",
11483
+ resourceType: "event"
11484
+ /* EVENT */
11485
+ },
11486
+ showOn: [
11487
+ "Front_page"
11488
+ /* FRONT_PAGE */
11489
+ ],
11490
+ // `start` is only required (and must be future) when status !== ACTIVE.
11491
+ start: void 0,
11492
+ status: "Active",
11493
+ targetRegion: []
11494
+ };
11456
11495
  var schoolSchema = create$3().shape({
11457
11496
  active: create$7().required("Active is required"),
11458
11497
  contactDetails: contactDetailsSchema,
@@ -11514,8 +11553,9 @@ var badgeFiles = Object.fromEntries(
11514
11553
  var logoIds = [
11515
11554
  "googleMaps-logo-dark",
11516
11555
  "googleMaps-logo-light",
11517
- "logo",
11518
- "logo-atr"
11556
+ "logo-atr",
11557
+ "logo-dark",
11558
+ "logo"
11519
11559
  ];
11520
11560
  var logoFiles = Object.fromEntries(
11521
11561
  logoIds.map((id) => [id, `${id}${IMAGE_EXTENSION}`])
@@ -11523,6 +11563,7 @@ var logoFiles = Object.fromEntries(
11523
11563
  var otherImagesIds = [
11524
11564
  "banner-horizontal",
11525
11565
  "banner-vertical",
11566
+ "gazebo-top",
11526
11567
  "qr-code",
11527
11568
  "store-android",
11528
11569
  "store-ios"
@@ -11550,7 +11591,7 @@ var otherImages = Object.fromEntries(
11550
11591
  );
11551
11592
  var RELATION_SHARE_INVITATION = "invitation";
11552
11593
  var RELATION_SHARE_APPLICATION = "application";
11553
- var SHARE_SITE_URL = "https://cluemart.co.nz";
11594
+ var SHARE_SITE_URL = CLUEMART_MAIN_DOMAIN_URL;
11554
11595
  var SHARE_CALENDAR_ICON = "\u{1F4C5}";
11555
11596
  var SHARE_MARKET_DATES_SECTION_HEADING = `${SHARE_CALENDAR_ICON} Market dates:`;
11556
11597
  var SHARE_CHECKMARK_ICON = "\u2705";
@@ -11890,6 +11931,7 @@ var refundPolicySchema = new MongooseSchema4(
11890
11931
  );
11891
11932
  var schema2 = new MongooseSchema4(
11892
11933
  {
11934
+ active: { default: true, type: Boolean },
11893
11935
  applicationDeadlineHours: { required: true, type: Number },
11894
11936
  dateTime: { required: true, type: [dateTimeSchema2] },
11895
11937
  eventId: {
@@ -12331,7 +12373,11 @@ var schema5 = new MongooseSchema9(
12331
12373
  type: String
12332
12374
  },
12333
12375
  token: { required: true, type: String },
12334
- userId: { required: true, type: mongoose9.Schema.Types.ObjectId }
12376
+ userId: {
12377
+ ref: "User",
12378
+ required: true,
12379
+ type: mongoose9.Schema.Types.ObjectId
12380
+ }
12335
12381
  },
12336
12382
  { timestamps: true }
12337
12383
  );
@@ -12674,6 +12720,7 @@ var AttributesSchema = new MongooseSchema14(
12674
12720
  );
12675
12721
  var schema10 = new MongooseSchema14(
12676
12722
  {
12723
+ active: { default: true, type: Boolean },
12677
12724
  compliance: {
12678
12725
  foodBeverageLicense: { default: false, required: false, type: Boolean },
12679
12726
  liabilityInsurance: { default: false, required: false, type: Boolean }
@@ -13405,12 +13452,12 @@ async function removeAssociateFromResource({
13405
13452
  // src/service/vendor.ts
13406
13453
  async function updateVendorBasedOnUserLicense(userId, licenceType) {
13407
13454
  try {
13408
- const user = await UserModel.findById(userId).select("vendor").lean();
13455
+ const user = await UserModel.findById(userId).select("vendor").lean().exec();
13409
13456
  if (!user?.vendor) {
13410
13457
  console.warn(`[updateVendor] No vendor found for userId=${userId}`);
13411
13458
  return;
13412
13459
  }
13413
- const vendor = await VendorModel.findById(user.vendor).lean();
13460
+ const vendor = await VendorModel.findById(user.vendor).lean().exec();
13414
13461
  if (!vendor) {
13415
13462
  console.warn(`[updateVendor] Vendor not found for id=${user.vendor}`);
13416
13463
  return;