@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.mjs CHANGED
@@ -1691,9 +1691,9 @@ function __extends(d, b) {
1691
1691
  }
1692
1692
  var __assign = function() {
1693
1693
  __assign = Object.assign || function __assign2(t) {
1694
- for (var s2, i = 1, n = arguments.length; i < n; i++) {
1695
- s2 = arguments[i];
1696
- for (var p in s2) if (Object.prototype.hasOwnProperty.call(s2, p)) t[p] = s2[p];
1694
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1695
+ s = arguments[i];
1696
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1697
1697
  }
1698
1698
  return t;
1699
1699
  };
@@ -4785,20 +4785,19 @@ function createValidation(config) {
4785
4785
  abortEarly = schema14.spec.abortEarly,
4786
4786
  disableStackTrace = schema14.spec.disableStackTrace
4787
4787
  } = options;
4788
- const resolveOptions = {
4789
- value,
4790
- parent,
4791
- context
4792
- };
4788
+ function resolve(item) {
4789
+ return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
4790
+ }
4793
4791
  function createError(overrides = {}) {
4794
- const nextParams = resolveParams(Object.assign({
4792
+ const nextParams = Object.assign({
4795
4793
  value,
4796
4794
  originalValue,
4797
4795
  label: schema14.spec.label,
4798
4796
  path: overrides.path || path,
4799
4797
  spec: schema14.spec,
4800
4798
  disableStackTrace: overrides.disableStackTrace || disableStackTrace
4801
- }, params, overrides.params), resolveOptions);
4799
+ }, params, overrides.params);
4800
+ for (const key of Object.keys(nextParams)) nextParams[key] = resolve(nextParams[key]);
4802
4801
  const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name, nextParams.disableStackTrace);
4803
4802
  error.params = nextParams;
4804
4803
  return error;
@@ -4810,9 +4809,7 @@ function createValidation(config) {
4810
4809
  type: name,
4811
4810
  from: options.from,
4812
4811
  createError,
4813
- resolve(item) {
4814
- return resolveMaybeRef(item, resolveOptions);
4815
- },
4812
+ resolve,
4816
4813
  options,
4817
4814
  originalValue,
4818
4815
  schema: schema14
@@ -4849,16 +4846,6 @@ function createValidation(config) {
4849
4846
  validate.OPTIONS = config;
4850
4847
  return validate;
4851
4848
  }
4852
- function resolveParams(params, options) {
4853
- if (!params) return params;
4854
- for (const key of Object.keys(params)) {
4855
- params[key] = resolveMaybeRef(params[key], options);
4856
- }
4857
- return params;
4858
- }
4859
- function resolveMaybeRef(item, options) {
4860
- return Reference.isRef(item) ? item.getValue(options.value, options.parent, options.context) : item;
4861
- }
4862
4849
  function getIn(schema14, path, value, context = value) {
4863
4850
  let parent, lastPart, lastPartDebug;
4864
4851
  if (!path) return {
@@ -4955,69 +4942,6 @@ function clone(src, seen = /* @__PURE__ */ new Map()) {
4955
4942
  }
4956
4943
  return copy;
4957
4944
  }
4958
- function createStandardPath(path) {
4959
- if (!(path != null && path.length)) {
4960
- return void 0;
4961
- }
4962
- const segments = [];
4963
- let currentSegment = "";
4964
- let inBrackets = false;
4965
- let inQuotes = false;
4966
- for (let i = 0; i < path.length; i++) {
4967
- const char = path[i];
4968
- if (char === "[" && !inQuotes) {
4969
- if (currentSegment) {
4970
- segments.push(...currentSegment.split(".").filter(Boolean));
4971
- currentSegment = "";
4972
- }
4973
- inBrackets = true;
4974
- continue;
4975
- }
4976
- if (char === "]" && !inQuotes) {
4977
- if (currentSegment) {
4978
- if (/^\d+$/.test(currentSegment)) {
4979
- segments.push(currentSegment);
4980
- } else {
4981
- segments.push(currentSegment.replace(/^"|"$/g, ""));
4982
- }
4983
- currentSegment = "";
4984
- }
4985
- inBrackets = false;
4986
- continue;
4987
- }
4988
- if (char === '"') {
4989
- inQuotes = !inQuotes;
4990
- continue;
4991
- }
4992
- if (char === "." && !inBrackets && !inQuotes) {
4993
- if (currentSegment) {
4994
- segments.push(currentSegment);
4995
- currentSegment = "";
4996
- }
4997
- continue;
4998
- }
4999
- currentSegment += char;
5000
- }
5001
- if (currentSegment) {
5002
- segments.push(...currentSegment.split(".").filter(Boolean));
5003
- }
5004
- return segments;
5005
- }
5006
- function createStandardIssues(error, parentPath) {
5007
- const path = parentPath ? `${parentPath}.${error.path}` : error.path;
5008
- return error.errors.map((err) => ({
5009
- message: err,
5010
- path: createStandardPath(path)
5011
- }));
5012
- }
5013
- function issuesFromValidationError(error, parentPath) {
5014
- var _error$inner;
5015
- if (!((_error$inner = error.inner) != null && _error$inner.length) && error.errors.length) {
5016
- return createStandardIssues(error, parentPath);
5017
- }
5018
- const path = parentPath ? `${parentPath}.${error.path}` : error.path;
5019
- return error.inner.flatMap((err) => issuesFromValidationError(err, path));
5020
- }
5021
4945
  var Schema = class {
5022
4946
  constructor(options) {
5023
4947
  this.type = void 0;
@@ -5049,8 +4973,8 @@ var Schema = class {
5049
4973
  optional: true,
5050
4974
  coerce: true
5051
4975
  }, options == null ? void 0 : options.spec);
5052
- this.withMutation((s2) => {
5053
- s2.nonNullable();
4976
+ this.withMutation((s) => {
4977
+ s.nonNullable();
5054
4978
  });
5055
4979
  }
5056
4980
  // TODO: remove
@@ -5147,11 +5071,9 @@ var Schema = class {
5147
5071
  * Run the configured transform pipeline over an input value.
5148
5072
  */
5149
5073
  cast(value, options = {}) {
5150
- let resolvedSchema = this.resolve(Object.assign({}, options, {
5074
+ let resolvedSchema = this.resolve(Object.assign({
5151
5075
  value
5152
- // parent: options.parent,
5153
- // context: options.context,
5154
- }));
5076
+ }, options));
5155
5077
  let allowOptionality = options.assert === "ignore-optionality";
5156
5078
  let result = resolvedSchema._cast(value, options);
5157
5079
  if (options.assert !== false && !resolvedSchema.isType(result)) {
@@ -5168,7 +5090,7 @@ attempted value: ${formattedValue}
5168
5090
  return result;
5169
5091
  }
5170
5092
  _cast(rawValue, options) {
5171
- let value = rawValue === void 0 ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this, options), rawValue);
5093
+ let value = rawValue === void 0 ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this), rawValue);
5172
5094
  if (value === void 0) {
5173
5095
  value = this.getDefault(options);
5174
5096
  }
@@ -5563,41 +5485,13 @@ attempted value: ${formattedValue}
5563
5485
  type: next.type,
5564
5486
  oneOf: next._whitelist.describe(),
5565
5487
  notOneOf: next._blacklist.describe(),
5566
- tests: next.tests.filter((n, idx, list) => list.findIndex((c) => c.OPTIONS.name === n.OPTIONS.name) === idx).map((fn) => {
5567
- const params = fn.OPTIONS.params && options ? resolveParams(Object.assign({}, fn.OPTIONS.params), options) : fn.OPTIONS.params;
5568
- return {
5569
- name: fn.OPTIONS.name,
5570
- params
5571
- };
5572
- })
5488
+ tests: next.tests.map((fn) => ({
5489
+ name: fn.OPTIONS.name,
5490
+ params: fn.OPTIONS.params
5491
+ })).filter((n, idx, list) => list.findIndex((c) => c.name === n.name) === idx)
5573
5492
  };
5574
5493
  return description;
5575
5494
  }
5576
- get ["~standard"]() {
5577
- const schema14 = this;
5578
- const standard = {
5579
- version: 1,
5580
- vendor: "yup",
5581
- async validate(value) {
5582
- try {
5583
- const result = await schema14.validate(value, {
5584
- abortEarly: false
5585
- });
5586
- return {
5587
- value: result
5588
- };
5589
- } catch (err) {
5590
- if (err instanceof ValidationError) {
5591
- return {
5592
- issues: issuesFromValidationError(err)
5593
- };
5594
- }
5595
- throw err;
5596
- }
5597
- }
5598
- };
5599
- return standard;
5600
- }
5601
5495
  };
5602
5496
  Schema.prototype.__isYupSchema__ = true;
5603
5497
  for (const method of ["validate", "validateSync"]) Schema.prototype[`${method}At`] = function(path, value, options = {}) {
@@ -5642,8 +5536,8 @@ var BooleanSchema = class extends Schema {
5642
5536
  }
5643
5537
  });
5644
5538
  this.withMutation(() => {
5645
- this.transform((value, _raw) => {
5646
- if (this.spec.coerce && !this.isType(value)) {
5539
+ this.transform((value, _raw, ctx) => {
5540
+ if (ctx.spec.coerce && !ctx.isType(value)) {
5647
5541
  if (/^(true|1)$/i.test(String(value))) return true;
5648
5542
  if (/^(false|0)$/i.test(String(value))) return false;
5649
5543
  }
@@ -5770,8 +5664,8 @@ var StringSchema = class extends Schema {
5770
5664
  }
5771
5665
  });
5772
5666
  this.withMutation(() => {
5773
- this.transform((value, _raw) => {
5774
- if (!this.spec.coerce || this.isType(value)) return value;
5667
+ this.transform((value, _raw, ctx) => {
5668
+ if (!ctx.spec.coerce || ctx.isType(value)) return value;
5775
5669
  if (Array.isArray(value)) return value;
5776
5670
  const strValue = value != null && value.toString ? value.toString() : value;
5777
5671
  if (strValue === objStringTag) return value;
@@ -5973,15 +5867,15 @@ var NumberSchema = class extends Schema {
5973
5867
  }
5974
5868
  });
5975
5869
  this.withMutation(() => {
5976
- this.transform((value, _raw) => {
5977
- if (!this.spec.coerce) return value;
5870
+ this.transform((value, _raw, ctx) => {
5871
+ if (!ctx.spec.coerce) return value;
5978
5872
  let parsed = value;
5979
5873
  if (typeof parsed === "string") {
5980
5874
  parsed = parsed.replace(/\s/g, "");
5981
5875
  if (parsed === "") return NaN;
5982
5876
  parsed = +parsed;
5983
5877
  }
5984
- if (this.isType(parsed) || parsed === null) return parsed;
5878
+ if (ctx.isType(parsed) || parsed === null) return parsed;
5985
5879
  return parseFloat(parsed);
5986
5880
  });
5987
5881
  });
@@ -6083,8 +5977,8 @@ var DateSchema = class _DateSchema extends Schema {
6083
5977
  }
6084
5978
  });
6085
5979
  this.withMutation(() => {
6086
- this.transform((value, _raw) => {
6087
- if (!this.spec.coerce || this.isType(value) || value === null) return value;
5980
+ this.transform((value, _raw, ctx) => {
5981
+ if (!ctx.spec.coerce || ctx.isType(value) || value === null) return value;
6088
5982
  value = parseIsoDate(value);
6089
5983
  return !isNaN(value) ? new Date(value) : _DateSchema.INVALID_DATE;
6090
5984
  });
@@ -6168,7 +6062,7 @@ function sortByKeyOrder(keys) {
6168
6062
  return findIndex(keys, a) - findIndex(keys, b);
6169
6063
  };
6170
6064
  }
6171
- var parseJson = (value, _, schema14) => {
6065
+ var parseJson = (value, _, ctx) => {
6172
6066
  if (typeof value !== "string") {
6173
6067
  return value;
6174
6068
  }
@@ -6177,7 +6071,7 @@ var parseJson = (value, _, schema14) => {
6177
6071
  parsed = JSON.parse(value);
6178
6072
  } catch (err) {
6179
6073
  }
6180
- return schema14.isType(parsed) ? parsed : value;
6074
+ return ctx.isType(parsed) ? parsed : value;
6181
6075
  };
6182
6076
  function deepPartial(schema14) {
6183
6077
  if ("fields" in schema14) {
@@ -6253,9 +6147,9 @@ var ObjectSchema = class extends Schema {
6253
6147
  for (const prop of props) {
6254
6148
  let field = fields[prop];
6255
6149
  let exists = prop in value;
6256
- let inputValue = value[prop];
6257
6150
  if (field) {
6258
6151
  let fieldValue;
6152
+ let inputValue = value[prop];
6259
6153
  innerOptions.path = (options.path ? `${options.path}.` : "") + prop;
6260
6154
  field = field.resolve({
6261
6155
  value: inputValue,
@@ -6268,14 +6162,17 @@ var ObjectSchema = class extends Schema {
6268
6162
  isChanged = isChanged || prop in value;
6269
6163
  continue;
6270
6164
  }
6271
- fieldValue = !options.__validating || !strict ? field.cast(inputValue, innerOptions) : inputValue;
6165
+ fieldValue = !options.__validating || !strict ? (
6166
+ // TODO: use _cast, this is double resolving
6167
+ field.cast(value[prop], innerOptions)
6168
+ ) : value[prop];
6272
6169
  if (fieldValue !== void 0) {
6273
6170
  intermediateValue[prop] = fieldValue;
6274
6171
  }
6275
6172
  } else if (exists && !strip) {
6276
- intermediateValue[prop] = inputValue;
6173
+ intermediateValue[prop] = value[prop];
6277
6174
  }
6278
- if (exists !== prop in intermediateValue || intermediateValue[prop] !== inputValue) {
6175
+ if (exists !== prop in intermediateValue || intermediateValue[prop] !== value[prop]) {
6279
6176
  isChanged = true;
6280
6177
  }
6281
6178
  }
@@ -6338,9 +6235,9 @@ var ObjectSchema = class extends Schema {
6338
6235
  const target = nextFields[field];
6339
6236
  nextFields[field] = target === void 0 ? schemaOrRef : target;
6340
6237
  }
6341
- return next.withMutation((s2) => (
6238
+ return next.withMutation((s) => (
6342
6239
  // XXX: excludes here is wrong
6343
- s2.setFields(nextFields, [...this._excludedEdges, ...schema14._excludedEdges])
6240
+ s.setFields(nextFields, [...this._excludedEdges, ...schema14._excludedEdges])
6344
6241
  ));
6345
6242
  }
6346
6243
  _getDefault(options) {
@@ -6536,11 +6433,7 @@ var ArraySchema = class extends Schema {
6536
6433
  let isChanged = false;
6537
6434
  const castArray = value.map((v, idx) => {
6538
6435
  const castElement = this.innerType.cast(v, Object.assign({}, _opts, {
6539
- path: `${_opts.path || ""}[${idx}]`,
6540
- parent: value,
6541
- originalValue: v,
6542
- value: v,
6543
- index: idx
6436
+ path: `${_opts.path || ""}[${idx}]`
6544
6437
  }));
6545
6438
  if (castElement !== v) {
6546
6439
  isChanged = true;
@@ -6710,11 +6603,7 @@ var TupleSchema = class extends Schema {
6710
6603
  let isChanged = false;
6711
6604
  const castArray = types.map((type, idx) => {
6712
6605
  const castElement = type.cast(value[idx], Object.assign({}, options, {
6713
- path: `${options.path || ""}[${idx}]`,
6714
- parent: value,
6715
- originalValue: value[idx],
6716
- value: value[idx],
6717
- index: idx
6606
+ path: `${options.path || ""}[${idx}]`
6718
6607
  }));
6719
6608
  if (castElement !== value[idx]) isChanged = true;
6720
6609
  return castElement;
@@ -9155,22 +9044,28 @@ var GET_CHATS_BY_REGION = gql`
9155
9044
  }
9156
9045
  ${CHAT_FIELDS_FRAGMENT}
9157
9046
  `;
9047
+ var CHAT_REPORT_FIELDS_FRAGMENT = gql`
9048
+ fragment ChatReportFields on ReportChatUserType {
9049
+ _id
9050
+ chatId
9051
+ createdAt
9052
+ reason {
9053
+ reasonType
9054
+ details
9055
+ }
9056
+ reportedUserId
9057
+ reporterUserId
9058
+ resolved
9059
+ updatedAt
9060
+ }
9061
+ `;
9158
9062
  var GET_REPORTED_CHAT_USERS = gql`
9159
9063
  query getReportedChatUsers {
9160
9064
  reportedChatUsers {
9161
- _id
9162
- chatId
9163
- createdAt
9164
- reason {
9165
- reasonType
9166
- details
9167
- }
9168
- reportedUserId
9169
- reporterUserId
9170
- resolved
9171
- updatedAt
9065
+ ...ChatReportFields
9172
9066
  }
9173
9067
  }
9068
+ ${CHAT_REPORT_FIELDS_FRAGMENT}
9174
9069
  `;
9175
9070
  var SEND_CHAT_MESSAGE_MUTATION = gql`
9176
9071
  mutation sendChatMessage($_id: ID!, $input: ChatMessageInputType!) {
@@ -9220,9 +9115,10 @@ var MARK_CHAT_MESSAGES_SEEN_MUTATION = gql`
9220
9115
  var REPORT_CHAT_USER_MUTATION = gql`
9221
9116
  mutation reportChatUser($input: ReportChatUserInputType!) {
9222
9117
  reportChatUser(input: $input) {
9223
- success
9118
+ ...ChatReportFields
9224
9119
  }
9225
9120
  }
9121
+ ${CHAT_REPORT_FIELDS_FRAGMENT}
9226
9122
  `;
9227
9123
  var GET_CHAT_MESSAGE = gql`
9228
9124
  subscription {
@@ -10087,6 +9983,10 @@ var POST_FIELDS_FRAGMENT = gql`
10087
9983
  createdAt
10088
9984
  deletedAt
10089
9985
  postType
9986
+ resource {
9987
+ resourceId
9988
+ resourceType
9989
+ }
10090
9990
  tags
10091
9991
  title
10092
9992
  updatedAt
@@ -10790,6 +10690,10 @@ var postSchema = create$3().shape({
10790
10690
  caption: create$6().required(),
10791
10691
  content: create$2().of(postContentSchema).required(),
10792
10692
  postType: create$8().oneOf(Object.values(EnumPostType)).required(),
10693
+ resource: create$3({
10694
+ resourceId: create$6().required(),
10695
+ resourceType: create$8().oneOf(Object.values(EnumResourceType)).required()
10696
+ }).nullable().optional(),
10793
10697
  tags: create$2().of(create$6().required()).nullable().optional(),
10794
10698
  title: create$6().required()
10795
10699
  });
@@ -12203,6 +12107,17 @@ var schema13 = new MongooseSchema18(
12203
12107
  required: true,
12204
12108
  type: String
12205
12109
  },
12110
+ resource: {
12111
+ required: false,
12112
+ type: {
12113
+ resourceId: { required: true, type: String },
12114
+ resourceType: {
12115
+ enum: Object.values(EnumResourceType),
12116
+ required: true,
12117
+ type: String
12118
+ }
12119
+ }
12120
+ },
12206
12121
  tags: { default: [], required: false, type: [String] },
12207
12122
  title: { required: true, type: String }
12208
12123
  },