@timardex/cluemart-server-shared 1.0.86 → 1.0.88

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.cjs CHANGED
@@ -1744,9 +1744,9 @@ function __extends(d, b) {
1744
1744
  }
1745
1745
  var __assign = function() {
1746
1746
  __assign = Object.assign || function __assign2(t) {
1747
- for (var s2, i = 1, n = arguments.length; i < n; i++) {
1748
- s2 = arguments[i];
1749
- for (var p in s2) if (Object.prototype.hasOwnProperty.call(s2, p)) t[p] = s2[p];
1747
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1748
+ s = arguments[i];
1749
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1750
1750
  }
1751
1751
  return t;
1752
1752
  };
@@ -4838,20 +4838,19 @@ function createValidation(config) {
4838
4838
  abortEarly = schema14.spec.abortEarly,
4839
4839
  disableStackTrace = schema14.spec.disableStackTrace
4840
4840
  } = options;
4841
- const resolveOptions = {
4842
- value,
4843
- parent,
4844
- context
4845
- };
4841
+ function resolve(item) {
4842
+ return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
4843
+ }
4846
4844
  function createError(overrides = {}) {
4847
- const nextParams = resolveParams(Object.assign({
4845
+ const nextParams = Object.assign({
4848
4846
  value,
4849
4847
  originalValue,
4850
4848
  label: schema14.spec.label,
4851
4849
  path: overrides.path || path,
4852
4850
  spec: schema14.spec,
4853
4851
  disableStackTrace: overrides.disableStackTrace || disableStackTrace
4854
- }, params, overrides.params), resolveOptions);
4852
+ }, params, overrides.params);
4853
+ for (const key of Object.keys(nextParams)) nextParams[key] = resolve(nextParams[key]);
4855
4854
  const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name, nextParams.disableStackTrace);
4856
4855
  error.params = nextParams;
4857
4856
  return error;
@@ -4863,9 +4862,7 @@ function createValidation(config) {
4863
4862
  type: name,
4864
4863
  from: options.from,
4865
4864
  createError,
4866
- resolve(item) {
4867
- return resolveMaybeRef(item, resolveOptions);
4868
- },
4865
+ resolve,
4869
4866
  options,
4870
4867
  originalValue,
4871
4868
  schema: schema14
@@ -4902,16 +4899,6 @@ function createValidation(config) {
4902
4899
  validate.OPTIONS = config;
4903
4900
  return validate;
4904
4901
  }
4905
- function resolveParams(params, options) {
4906
- if (!params) return params;
4907
- for (const key of Object.keys(params)) {
4908
- params[key] = resolveMaybeRef(params[key], options);
4909
- }
4910
- return params;
4911
- }
4912
- function resolveMaybeRef(item, options) {
4913
- return Reference.isRef(item) ? item.getValue(options.value, options.parent, options.context) : item;
4914
- }
4915
4902
  function getIn(schema14, path, value, context = value) {
4916
4903
  let parent, lastPart, lastPartDebug;
4917
4904
  if (!path) return {
@@ -5008,69 +4995,6 @@ function clone(src, seen = /* @__PURE__ */ new Map()) {
5008
4995
  }
5009
4996
  return copy;
5010
4997
  }
5011
- function createStandardPath(path) {
5012
- if (!(path != null && path.length)) {
5013
- return void 0;
5014
- }
5015
- const segments = [];
5016
- let currentSegment = "";
5017
- let inBrackets = false;
5018
- let inQuotes = false;
5019
- for (let i = 0; i < path.length; i++) {
5020
- const char = path[i];
5021
- if (char === "[" && !inQuotes) {
5022
- if (currentSegment) {
5023
- segments.push(...currentSegment.split(".").filter(Boolean));
5024
- currentSegment = "";
5025
- }
5026
- inBrackets = true;
5027
- continue;
5028
- }
5029
- if (char === "]" && !inQuotes) {
5030
- if (currentSegment) {
5031
- if (/^\d+$/.test(currentSegment)) {
5032
- segments.push(currentSegment);
5033
- } else {
5034
- segments.push(currentSegment.replace(/^"|"$/g, ""));
5035
- }
5036
- currentSegment = "";
5037
- }
5038
- inBrackets = false;
5039
- continue;
5040
- }
5041
- if (char === '"') {
5042
- inQuotes = !inQuotes;
5043
- continue;
5044
- }
5045
- if (char === "." && !inBrackets && !inQuotes) {
5046
- if (currentSegment) {
5047
- segments.push(currentSegment);
5048
- currentSegment = "";
5049
- }
5050
- continue;
5051
- }
5052
- currentSegment += char;
5053
- }
5054
- if (currentSegment) {
5055
- segments.push(...currentSegment.split(".").filter(Boolean));
5056
- }
5057
- return segments;
5058
- }
5059
- function createStandardIssues(error, parentPath) {
5060
- const path = parentPath ? `${parentPath}.${error.path}` : error.path;
5061
- return error.errors.map((err) => ({
5062
- message: err,
5063
- path: createStandardPath(path)
5064
- }));
5065
- }
5066
- function issuesFromValidationError(error, parentPath) {
5067
- var _error$inner;
5068
- if (!((_error$inner = error.inner) != null && _error$inner.length) && error.errors.length) {
5069
- return createStandardIssues(error, parentPath);
5070
- }
5071
- const path = parentPath ? `${parentPath}.${error.path}` : error.path;
5072
- return error.inner.flatMap((err) => issuesFromValidationError(err, path));
5073
- }
5074
4998
  var Schema = class {
5075
4999
  constructor(options) {
5076
5000
  this.type = void 0;
@@ -5102,8 +5026,8 @@ var Schema = class {
5102
5026
  optional: true,
5103
5027
  coerce: true
5104
5028
  }, options == null ? void 0 : options.spec);
5105
- this.withMutation((s2) => {
5106
- s2.nonNullable();
5029
+ this.withMutation((s) => {
5030
+ s.nonNullable();
5107
5031
  });
5108
5032
  }
5109
5033
  // TODO: remove
@@ -5200,11 +5124,9 @@ var Schema = class {
5200
5124
  * Run the configured transform pipeline over an input value.
5201
5125
  */
5202
5126
  cast(value, options = {}) {
5203
- let resolvedSchema = this.resolve(Object.assign({}, options, {
5127
+ let resolvedSchema = this.resolve(Object.assign({
5204
5128
  value
5205
- // parent: options.parent,
5206
- // context: options.context,
5207
- }));
5129
+ }, options));
5208
5130
  let allowOptionality = options.assert === "ignore-optionality";
5209
5131
  let result = resolvedSchema._cast(value, options);
5210
5132
  if (options.assert !== false && !resolvedSchema.isType(result)) {
@@ -5221,7 +5143,7 @@ attempted value: ${formattedValue}
5221
5143
  return result;
5222
5144
  }
5223
5145
  _cast(rawValue, options) {
5224
- let value = rawValue === void 0 ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this, options), rawValue);
5146
+ let value = rawValue === void 0 ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this), rawValue);
5225
5147
  if (value === void 0) {
5226
5148
  value = this.getDefault(options);
5227
5149
  }
@@ -5616,41 +5538,13 @@ attempted value: ${formattedValue}
5616
5538
  type: next.type,
5617
5539
  oneOf: next._whitelist.describe(),
5618
5540
  notOneOf: next._blacklist.describe(),
5619
- tests: next.tests.filter((n, idx, list) => list.findIndex((c) => c.OPTIONS.name === n.OPTIONS.name) === idx).map((fn) => {
5620
- const params = fn.OPTIONS.params && options ? resolveParams(Object.assign({}, fn.OPTIONS.params), options) : fn.OPTIONS.params;
5621
- return {
5622
- name: fn.OPTIONS.name,
5623
- params
5624
- };
5625
- })
5541
+ tests: next.tests.map((fn) => ({
5542
+ name: fn.OPTIONS.name,
5543
+ params: fn.OPTIONS.params
5544
+ })).filter((n, idx, list) => list.findIndex((c) => c.name === n.name) === idx)
5626
5545
  };
5627
5546
  return description;
5628
5547
  }
5629
- get ["~standard"]() {
5630
- const schema14 = this;
5631
- const standard = {
5632
- version: 1,
5633
- vendor: "yup",
5634
- async validate(value) {
5635
- try {
5636
- const result = await schema14.validate(value, {
5637
- abortEarly: false
5638
- });
5639
- return {
5640
- value: result
5641
- };
5642
- } catch (err) {
5643
- if (err instanceof ValidationError) {
5644
- return {
5645
- issues: issuesFromValidationError(err)
5646
- };
5647
- }
5648
- throw err;
5649
- }
5650
- }
5651
- };
5652
- return standard;
5653
- }
5654
5548
  };
5655
5549
  Schema.prototype.__isYupSchema__ = true;
5656
5550
  for (const method of ["validate", "validateSync"]) Schema.prototype[`${method}At`] = function(path, value, options = {}) {
@@ -5695,8 +5589,8 @@ var BooleanSchema = class extends Schema {
5695
5589
  }
5696
5590
  });
5697
5591
  this.withMutation(() => {
5698
- this.transform((value, _raw) => {
5699
- if (this.spec.coerce && !this.isType(value)) {
5592
+ this.transform((value, _raw, ctx) => {
5593
+ if (ctx.spec.coerce && !ctx.isType(value)) {
5700
5594
  if (/^(true|1)$/i.test(String(value))) return true;
5701
5595
  if (/^(false|0)$/i.test(String(value))) return false;
5702
5596
  }
@@ -5823,8 +5717,8 @@ var StringSchema = class extends Schema {
5823
5717
  }
5824
5718
  });
5825
5719
  this.withMutation(() => {
5826
- this.transform((value, _raw) => {
5827
- if (!this.spec.coerce || this.isType(value)) return value;
5720
+ this.transform((value, _raw, ctx) => {
5721
+ if (!ctx.spec.coerce || ctx.isType(value)) return value;
5828
5722
  if (Array.isArray(value)) return value;
5829
5723
  const strValue = value != null && value.toString ? value.toString() : value;
5830
5724
  if (strValue === objStringTag) return value;
@@ -6026,15 +5920,15 @@ var NumberSchema = class extends Schema {
6026
5920
  }
6027
5921
  });
6028
5922
  this.withMutation(() => {
6029
- this.transform((value, _raw) => {
6030
- if (!this.spec.coerce) return value;
5923
+ this.transform((value, _raw, ctx) => {
5924
+ if (!ctx.spec.coerce) return value;
6031
5925
  let parsed = value;
6032
5926
  if (typeof parsed === "string") {
6033
5927
  parsed = parsed.replace(/\s/g, "");
6034
5928
  if (parsed === "") return NaN;
6035
5929
  parsed = +parsed;
6036
5930
  }
6037
- if (this.isType(parsed) || parsed === null) return parsed;
5931
+ if (ctx.isType(parsed) || parsed === null) return parsed;
6038
5932
  return parseFloat(parsed);
6039
5933
  });
6040
5934
  });
@@ -6136,8 +6030,8 @@ var DateSchema = class _DateSchema extends Schema {
6136
6030
  }
6137
6031
  });
6138
6032
  this.withMutation(() => {
6139
- this.transform((value, _raw) => {
6140
- if (!this.spec.coerce || this.isType(value) || value === null) return value;
6033
+ this.transform((value, _raw, ctx) => {
6034
+ if (!ctx.spec.coerce || ctx.isType(value) || value === null) return value;
6141
6035
  value = parseIsoDate(value);
6142
6036
  return !isNaN(value) ? new Date(value) : _DateSchema.INVALID_DATE;
6143
6037
  });
@@ -6221,7 +6115,7 @@ function sortByKeyOrder(keys) {
6221
6115
  return findIndex(keys, a) - findIndex(keys, b);
6222
6116
  };
6223
6117
  }
6224
- var parseJson = (value, _, schema14) => {
6118
+ var parseJson = (value, _, ctx) => {
6225
6119
  if (typeof value !== "string") {
6226
6120
  return value;
6227
6121
  }
@@ -6230,7 +6124,7 @@ var parseJson = (value, _, schema14) => {
6230
6124
  parsed = JSON.parse(value);
6231
6125
  } catch (err) {
6232
6126
  }
6233
- return schema14.isType(parsed) ? parsed : value;
6127
+ return ctx.isType(parsed) ? parsed : value;
6234
6128
  };
6235
6129
  function deepPartial(schema14) {
6236
6130
  if ("fields" in schema14) {
@@ -6306,9 +6200,9 @@ var ObjectSchema = class extends Schema {
6306
6200
  for (const prop of props) {
6307
6201
  let field = fields[prop];
6308
6202
  let exists = prop in value;
6309
- let inputValue = value[prop];
6310
6203
  if (field) {
6311
6204
  let fieldValue;
6205
+ let inputValue = value[prop];
6312
6206
  innerOptions.path = (options.path ? `${options.path}.` : "") + prop;
6313
6207
  field = field.resolve({
6314
6208
  value: inputValue,
@@ -6321,14 +6215,17 @@ var ObjectSchema = class extends Schema {
6321
6215
  isChanged = isChanged || prop in value;
6322
6216
  continue;
6323
6217
  }
6324
- fieldValue = !options.__validating || !strict ? field.cast(inputValue, innerOptions) : inputValue;
6218
+ fieldValue = !options.__validating || !strict ? (
6219
+ // TODO: use _cast, this is double resolving
6220
+ field.cast(value[prop], innerOptions)
6221
+ ) : value[prop];
6325
6222
  if (fieldValue !== void 0) {
6326
6223
  intermediateValue[prop] = fieldValue;
6327
6224
  }
6328
6225
  } else if (exists && !strip) {
6329
- intermediateValue[prop] = inputValue;
6226
+ intermediateValue[prop] = value[prop];
6330
6227
  }
6331
- if (exists !== prop in intermediateValue || intermediateValue[prop] !== inputValue) {
6228
+ if (exists !== prop in intermediateValue || intermediateValue[prop] !== value[prop]) {
6332
6229
  isChanged = true;
6333
6230
  }
6334
6231
  }
@@ -6391,9 +6288,9 @@ var ObjectSchema = class extends Schema {
6391
6288
  const target = nextFields[field];
6392
6289
  nextFields[field] = target === void 0 ? schemaOrRef : target;
6393
6290
  }
6394
- return next.withMutation((s2) => (
6291
+ return next.withMutation((s) => (
6395
6292
  // XXX: excludes here is wrong
6396
- s2.setFields(nextFields, [...this._excludedEdges, ...schema14._excludedEdges])
6293
+ s.setFields(nextFields, [...this._excludedEdges, ...schema14._excludedEdges])
6397
6294
  ));
6398
6295
  }
6399
6296
  _getDefault(options) {
@@ -6589,11 +6486,7 @@ var ArraySchema = class extends Schema {
6589
6486
  let isChanged = false;
6590
6487
  const castArray = value.map((v, idx) => {
6591
6488
  const castElement = this.innerType.cast(v, Object.assign({}, _opts, {
6592
- path: `${_opts.path || ""}[${idx}]`,
6593
- parent: value,
6594
- originalValue: v,
6595
- value: v,
6596
- index: idx
6489
+ path: `${_opts.path || ""}[${idx}]`
6597
6490
  }));
6598
6491
  if (castElement !== v) {
6599
6492
  isChanged = true;
@@ -6763,11 +6656,7 @@ var TupleSchema = class extends Schema {
6763
6656
  let isChanged = false;
6764
6657
  const castArray = types.map((type, idx) => {
6765
6658
  const castElement = type.cast(value[idx], Object.assign({}, options, {
6766
- path: `${options.path || ""}[${idx}]`,
6767
- parent: value,
6768
- originalValue: value[idx],
6769
- value: value[idx],
6770
- index: idx
6659
+ path: `${options.path || ""}[${idx}]`
6771
6660
  }));
6772
6661
  if (castElement !== value[idx]) isChanged = true;
6773
6662
  return castElement;
@@ -9208,22 +9097,28 @@ var GET_CHATS_BY_REGION = gql`
9208
9097
  }
9209
9098
  ${CHAT_FIELDS_FRAGMENT}
9210
9099
  `;
9100
+ var CHAT_REPORT_FIELDS_FRAGMENT = gql`
9101
+ fragment ChatReportFields on ReportChatUserType {
9102
+ _id
9103
+ chatId
9104
+ createdAt
9105
+ reason {
9106
+ reasonType
9107
+ details
9108
+ }
9109
+ reportedUserId
9110
+ reporterUserId
9111
+ resolved
9112
+ updatedAt
9113
+ }
9114
+ `;
9211
9115
  var GET_REPORTED_CHAT_USERS = gql`
9212
9116
  query getReportedChatUsers {
9213
9117
  reportedChatUsers {
9214
- _id
9215
- chatId
9216
- createdAt
9217
- reason {
9218
- reasonType
9219
- details
9220
- }
9221
- reportedUserId
9222
- reporterUserId
9223
- resolved
9224
- updatedAt
9118
+ ...ChatReportFields
9225
9119
  }
9226
9120
  }
9121
+ ${CHAT_REPORT_FIELDS_FRAGMENT}
9227
9122
  `;
9228
9123
  var SEND_CHAT_MESSAGE_MUTATION = gql`
9229
9124
  mutation sendChatMessage($_id: ID!, $input: ChatMessageInputType!) {
@@ -9273,9 +9168,10 @@ var MARK_CHAT_MESSAGES_SEEN_MUTATION = gql`
9273
9168
  var REPORT_CHAT_USER_MUTATION = gql`
9274
9169
  mutation reportChatUser($input: ReportChatUserInputType!) {
9275
9170
  reportChatUser(input: $input) {
9276
- success
9171
+ ...ChatReportFields
9277
9172
  }
9278
9173
  }
9174
+ ${CHAT_REPORT_FIELDS_FRAGMENT}
9279
9175
  `;
9280
9176
  var GET_CHAT_MESSAGE = gql`
9281
9177
  subscription {
@@ -10140,6 +10036,10 @@ var POST_FIELDS_FRAGMENT = gql`
10140
10036
  createdAt
10141
10037
  deletedAt
10142
10038
  postType
10039
+ resource {
10040
+ resourceId
10041
+ resourceType
10042
+ }
10143
10043
  tags
10144
10044
  title
10145
10045
  updatedAt
@@ -10843,6 +10743,10 @@ var postSchema = create$3().shape({
10843
10743
  caption: create$6().required(),
10844
10744
  content: create$2().of(postContentSchema).required(),
10845
10745
  postType: create$8().oneOf(Object.values(EnumPostType)).required(),
10746
+ resource: create$3({
10747
+ resourceId: create$6().required(),
10748
+ resourceType: create$8().oneOf(Object.values(EnumResourceType)).required()
10749
+ }).nullable().optional(),
10846
10750
  tags: create$2().of(create$6().required()).nullable().optional(),
10847
10751
  title: create$6().required()
10848
10752
  });
@@ -12256,6 +12160,17 @@ var schema13 = new MongooseSchema18(
12256
12160
  required: true,
12257
12161
  type: String
12258
12162
  },
12163
+ resource: {
12164
+ required: false,
12165
+ type: {
12166
+ resourceId: { required: true, type: String },
12167
+ resourceType: {
12168
+ enum: Object.values(EnumResourceType),
12169
+ required: true,
12170
+ type: String
12171
+ }
12172
+ }
12173
+ },
12259
12174
  tags: { default: [], required: false, type: [String] },
12260
12175
  title: { required: true, type: String }
12261
12176
  },