@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.
@@ -33,7 +33,7 @@ import {
33
33
  resourceRelationsSchema,
34
34
  termsAgreementSchema,
35
35
  userLicenseSchema
36
- } from "../chunk-FVFOQT5F.mjs";
36
+ } from "../chunk-H4HID6QS.mjs";
37
37
  import "../chunk-3QS3WKRC.mjs";
38
38
  export {
39
39
  APP_SETTINGS_ID,
@@ -1732,9 +1732,9 @@ function __extends(d, b) {
1732
1732
  }
1733
1733
  var __assign = function() {
1734
1734
  __assign = Object.assign || function __assign2(t) {
1735
- for (var s2, i = 1, n = arguments.length; i < n; i++) {
1736
- s2 = arguments[i];
1737
- for (var p in s2) if (Object.prototype.hasOwnProperty.call(s2, p)) t[p] = s2[p];
1735
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1736
+ s = arguments[i];
1737
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1738
1738
  }
1739
1739
  return t;
1740
1740
  };
@@ -4826,20 +4826,19 @@ function createValidation(config) {
4826
4826
  abortEarly = schema14.spec.abortEarly,
4827
4827
  disableStackTrace = schema14.spec.disableStackTrace
4828
4828
  } = options;
4829
- const resolveOptions = {
4830
- value,
4831
- parent,
4832
- context
4833
- };
4829
+ function resolve(item) {
4830
+ return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
4831
+ }
4834
4832
  function createError(overrides = {}) {
4835
- const nextParams = resolveParams(Object.assign({
4833
+ const nextParams = Object.assign({
4836
4834
  value,
4837
4835
  originalValue,
4838
4836
  label: schema14.spec.label,
4839
4837
  path: overrides.path || path,
4840
4838
  spec: schema14.spec,
4841
4839
  disableStackTrace: overrides.disableStackTrace || disableStackTrace
4842
- }, params, overrides.params), resolveOptions);
4840
+ }, params, overrides.params);
4841
+ for (const key of Object.keys(nextParams)) nextParams[key] = resolve(nextParams[key]);
4843
4842
  const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name, nextParams.disableStackTrace);
4844
4843
  error.params = nextParams;
4845
4844
  return error;
@@ -4851,9 +4850,7 @@ function createValidation(config) {
4851
4850
  type: name,
4852
4851
  from: options.from,
4853
4852
  createError,
4854
- resolve(item) {
4855
- return resolveMaybeRef(item, resolveOptions);
4856
- },
4853
+ resolve,
4857
4854
  options,
4858
4855
  originalValue,
4859
4856
  schema: schema14
@@ -4890,16 +4887,6 @@ function createValidation(config) {
4890
4887
  validate.OPTIONS = config;
4891
4888
  return validate;
4892
4889
  }
4893
- function resolveParams(params, options) {
4894
- if (!params) return params;
4895
- for (const key of Object.keys(params)) {
4896
- params[key] = resolveMaybeRef(params[key], options);
4897
- }
4898
- return params;
4899
- }
4900
- function resolveMaybeRef(item, options) {
4901
- return Reference.isRef(item) ? item.getValue(options.value, options.parent, options.context) : item;
4902
- }
4903
4890
  function getIn(schema14, path, value, context = value) {
4904
4891
  let parent, lastPart, lastPartDebug;
4905
4892
  if (!path) return {
@@ -4996,69 +4983,6 @@ function clone(src, seen = /* @__PURE__ */ new Map()) {
4996
4983
  }
4997
4984
  return copy;
4998
4985
  }
4999
- function createStandardPath(path) {
5000
- if (!(path != null && path.length)) {
5001
- return void 0;
5002
- }
5003
- const segments = [];
5004
- let currentSegment = "";
5005
- let inBrackets = false;
5006
- let inQuotes = false;
5007
- for (let i = 0; i < path.length; i++) {
5008
- const char = path[i];
5009
- if (char === "[" && !inQuotes) {
5010
- if (currentSegment) {
5011
- segments.push(...currentSegment.split(".").filter(Boolean));
5012
- currentSegment = "";
5013
- }
5014
- inBrackets = true;
5015
- continue;
5016
- }
5017
- if (char === "]" && !inQuotes) {
5018
- if (currentSegment) {
5019
- if (/^\d+$/.test(currentSegment)) {
5020
- segments.push(currentSegment);
5021
- } else {
5022
- segments.push(currentSegment.replace(/^"|"$/g, ""));
5023
- }
5024
- currentSegment = "";
5025
- }
5026
- inBrackets = false;
5027
- continue;
5028
- }
5029
- if (char === '"') {
5030
- inQuotes = !inQuotes;
5031
- continue;
5032
- }
5033
- if (char === "." && !inBrackets && !inQuotes) {
5034
- if (currentSegment) {
5035
- segments.push(currentSegment);
5036
- currentSegment = "";
5037
- }
5038
- continue;
5039
- }
5040
- currentSegment += char;
5041
- }
5042
- if (currentSegment) {
5043
- segments.push(...currentSegment.split(".").filter(Boolean));
5044
- }
5045
- return segments;
5046
- }
5047
- function createStandardIssues(error, parentPath) {
5048
- const path = parentPath ? `${parentPath}.${error.path}` : error.path;
5049
- return error.errors.map((err) => ({
5050
- message: err,
5051
- path: createStandardPath(path)
5052
- }));
5053
- }
5054
- function issuesFromValidationError(error, parentPath) {
5055
- var _error$inner;
5056
- if (!((_error$inner = error.inner) != null && _error$inner.length) && error.errors.length) {
5057
- return createStandardIssues(error, parentPath);
5058
- }
5059
- const path = parentPath ? `${parentPath}.${error.path}` : error.path;
5060
- return error.inner.flatMap((err) => issuesFromValidationError(err, path));
5061
- }
5062
4986
  var Schema = class {
5063
4987
  constructor(options) {
5064
4988
  this.type = void 0;
@@ -5090,8 +5014,8 @@ var Schema = class {
5090
5014
  optional: true,
5091
5015
  coerce: true
5092
5016
  }, options == null ? void 0 : options.spec);
5093
- this.withMutation((s2) => {
5094
- s2.nonNullable();
5017
+ this.withMutation((s) => {
5018
+ s.nonNullable();
5095
5019
  });
5096
5020
  }
5097
5021
  // TODO: remove
@@ -5188,11 +5112,9 @@ var Schema = class {
5188
5112
  * Run the configured transform pipeline over an input value.
5189
5113
  */
5190
5114
  cast(value, options = {}) {
5191
- let resolvedSchema = this.resolve(Object.assign({}, options, {
5115
+ let resolvedSchema = this.resolve(Object.assign({
5192
5116
  value
5193
- // parent: options.parent,
5194
- // context: options.context,
5195
- }));
5117
+ }, options));
5196
5118
  let allowOptionality = options.assert === "ignore-optionality";
5197
5119
  let result = resolvedSchema._cast(value, options);
5198
5120
  if (options.assert !== false && !resolvedSchema.isType(result)) {
@@ -5209,7 +5131,7 @@ attempted value: ${formattedValue}
5209
5131
  return result;
5210
5132
  }
5211
5133
  _cast(rawValue, options) {
5212
- let value = rawValue === void 0 ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this, options), rawValue);
5134
+ let value = rawValue === void 0 ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this), rawValue);
5213
5135
  if (value === void 0) {
5214
5136
  value = this.getDefault(options);
5215
5137
  }
@@ -5604,41 +5526,13 @@ attempted value: ${formattedValue}
5604
5526
  type: next.type,
5605
5527
  oneOf: next._whitelist.describe(),
5606
5528
  notOneOf: next._blacklist.describe(),
5607
- tests: next.tests.filter((n, idx, list) => list.findIndex((c) => c.OPTIONS.name === n.OPTIONS.name) === idx).map((fn) => {
5608
- const params = fn.OPTIONS.params && options ? resolveParams(Object.assign({}, fn.OPTIONS.params), options) : fn.OPTIONS.params;
5609
- return {
5610
- name: fn.OPTIONS.name,
5611
- params
5612
- };
5613
- })
5529
+ tests: next.tests.map((fn) => ({
5530
+ name: fn.OPTIONS.name,
5531
+ params: fn.OPTIONS.params
5532
+ })).filter((n, idx, list) => list.findIndex((c) => c.name === n.name) === idx)
5614
5533
  };
5615
5534
  return description;
5616
5535
  }
5617
- get ["~standard"]() {
5618
- const schema14 = this;
5619
- const standard = {
5620
- version: 1,
5621
- vendor: "yup",
5622
- async validate(value) {
5623
- try {
5624
- const result = await schema14.validate(value, {
5625
- abortEarly: false
5626
- });
5627
- return {
5628
- value: result
5629
- };
5630
- } catch (err) {
5631
- if (err instanceof ValidationError) {
5632
- return {
5633
- issues: issuesFromValidationError(err)
5634
- };
5635
- }
5636
- throw err;
5637
- }
5638
- }
5639
- };
5640
- return standard;
5641
- }
5642
5536
  };
5643
5537
  Schema.prototype.__isYupSchema__ = true;
5644
5538
  for (const method of ["validate", "validateSync"]) Schema.prototype[`${method}At`] = function(path, value, options = {}) {
@@ -5683,8 +5577,8 @@ var BooleanSchema = class extends Schema {
5683
5577
  }
5684
5578
  });
5685
5579
  this.withMutation(() => {
5686
- this.transform((value, _raw) => {
5687
- if (this.spec.coerce && !this.isType(value)) {
5580
+ this.transform((value, _raw, ctx) => {
5581
+ if (ctx.spec.coerce && !ctx.isType(value)) {
5688
5582
  if (/^(true|1)$/i.test(String(value))) return true;
5689
5583
  if (/^(false|0)$/i.test(String(value))) return false;
5690
5584
  }
@@ -5811,8 +5705,8 @@ var StringSchema = class extends Schema {
5811
5705
  }
5812
5706
  });
5813
5707
  this.withMutation(() => {
5814
- this.transform((value, _raw) => {
5815
- if (!this.spec.coerce || this.isType(value)) return value;
5708
+ this.transform((value, _raw, ctx) => {
5709
+ if (!ctx.spec.coerce || ctx.isType(value)) return value;
5816
5710
  if (Array.isArray(value)) return value;
5817
5711
  const strValue = value != null && value.toString ? value.toString() : value;
5818
5712
  if (strValue === objStringTag) return value;
@@ -6014,15 +5908,15 @@ var NumberSchema = class extends Schema {
6014
5908
  }
6015
5909
  });
6016
5910
  this.withMutation(() => {
6017
- this.transform((value, _raw) => {
6018
- if (!this.spec.coerce) return value;
5911
+ this.transform((value, _raw, ctx) => {
5912
+ if (!ctx.spec.coerce) return value;
6019
5913
  let parsed = value;
6020
5914
  if (typeof parsed === "string") {
6021
5915
  parsed = parsed.replace(/\s/g, "");
6022
5916
  if (parsed === "") return NaN;
6023
5917
  parsed = +parsed;
6024
5918
  }
6025
- if (this.isType(parsed) || parsed === null) return parsed;
5919
+ if (ctx.isType(parsed) || parsed === null) return parsed;
6026
5920
  return parseFloat(parsed);
6027
5921
  });
6028
5922
  });
@@ -6124,8 +6018,8 @@ var DateSchema = class _DateSchema extends Schema {
6124
6018
  }
6125
6019
  });
6126
6020
  this.withMutation(() => {
6127
- this.transform((value, _raw) => {
6128
- if (!this.spec.coerce || this.isType(value) || value === null) return value;
6021
+ this.transform((value, _raw, ctx) => {
6022
+ if (!ctx.spec.coerce || ctx.isType(value) || value === null) return value;
6129
6023
  value = parseIsoDate(value);
6130
6024
  return !isNaN(value) ? new Date(value) : _DateSchema.INVALID_DATE;
6131
6025
  });
@@ -6209,7 +6103,7 @@ function sortByKeyOrder(keys) {
6209
6103
  return findIndex(keys, a) - findIndex(keys, b);
6210
6104
  };
6211
6105
  }
6212
- var parseJson = (value, _, schema14) => {
6106
+ var parseJson = (value, _, ctx) => {
6213
6107
  if (typeof value !== "string") {
6214
6108
  return value;
6215
6109
  }
@@ -6218,7 +6112,7 @@ var parseJson = (value, _, schema14) => {
6218
6112
  parsed = JSON.parse(value);
6219
6113
  } catch (err) {
6220
6114
  }
6221
- return schema14.isType(parsed) ? parsed : value;
6115
+ return ctx.isType(parsed) ? parsed : value;
6222
6116
  };
6223
6117
  function deepPartial(schema14) {
6224
6118
  if ("fields" in schema14) {
@@ -6294,9 +6188,9 @@ var ObjectSchema = class extends Schema {
6294
6188
  for (const prop of props) {
6295
6189
  let field = fields[prop];
6296
6190
  let exists = prop in value;
6297
- let inputValue = value[prop];
6298
6191
  if (field) {
6299
6192
  let fieldValue;
6193
+ let inputValue = value[prop];
6300
6194
  innerOptions.path = (options.path ? `${options.path}.` : "") + prop;
6301
6195
  field = field.resolve({
6302
6196
  value: inputValue,
@@ -6309,14 +6203,17 @@ var ObjectSchema = class extends Schema {
6309
6203
  isChanged = isChanged || prop in value;
6310
6204
  continue;
6311
6205
  }
6312
- fieldValue = !options.__validating || !strict ? field.cast(inputValue, innerOptions) : inputValue;
6206
+ fieldValue = !options.__validating || !strict ? (
6207
+ // TODO: use _cast, this is double resolving
6208
+ field.cast(value[prop], innerOptions)
6209
+ ) : value[prop];
6313
6210
  if (fieldValue !== void 0) {
6314
6211
  intermediateValue[prop] = fieldValue;
6315
6212
  }
6316
6213
  } else if (exists && !strip) {
6317
- intermediateValue[prop] = inputValue;
6214
+ intermediateValue[prop] = value[prop];
6318
6215
  }
6319
- if (exists !== prop in intermediateValue || intermediateValue[prop] !== inputValue) {
6216
+ if (exists !== prop in intermediateValue || intermediateValue[prop] !== value[prop]) {
6320
6217
  isChanged = true;
6321
6218
  }
6322
6219
  }
@@ -6379,9 +6276,9 @@ var ObjectSchema = class extends Schema {
6379
6276
  const target = nextFields[field];
6380
6277
  nextFields[field] = target === void 0 ? schemaOrRef : target;
6381
6278
  }
6382
- return next.withMutation((s2) => (
6279
+ return next.withMutation((s) => (
6383
6280
  // XXX: excludes here is wrong
6384
- s2.setFields(nextFields, [...this._excludedEdges, ...schema14._excludedEdges])
6281
+ s.setFields(nextFields, [...this._excludedEdges, ...schema14._excludedEdges])
6385
6282
  ));
6386
6283
  }
6387
6284
  _getDefault(options) {
@@ -6577,11 +6474,7 @@ var ArraySchema = class extends Schema {
6577
6474
  let isChanged = false;
6578
6475
  const castArray = value.map((v, idx) => {
6579
6476
  const castElement = this.innerType.cast(v, Object.assign({}, _opts, {
6580
- path: `${_opts.path || ""}[${idx}]`,
6581
- parent: value,
6582
- originalValue: v,
6583
- value: v,
6584
- index: idx
6477
+ path: `${_opts.path || ""}[${idx}]`
6585
6478
  }));
6586
6479
  if (castElement !== v) {
6587
6480
  isChanged = true;
@@ -6751,11 +6644,7 @@ var TupleSchema = class extends Schema {
6751
6644
  let isChanged = false;
6752
6645
  const castArray = types.map((type, idx) => {
6753
6646
  const castElement = type.cast(value[idx], Object.assign({}, options, {
6754
- path: `${options.path || ""}[${idx}]`,
6755
- parent: value,
6756
- originalValue: value[idx],
6757
- value: value[idx],
6758
- index: idx
6647
+ path: `${options.path || ""}[${idx}]`
6759
6648
  }));
6760
6649
  if (castElement !== value[idx]) isChanged = true;
6761
6650
  return castElement;
@@ -9196,22 +9085,28 @@ var GET_CHATS_BY_REGION = gql`
9196
9085
  }
9197
9086
  ${CHAT_FIELDS_FRAGMENT}
9198
9087
  `;
9088
+ var CHAT_REPORT_FIELDS_FRAGMENT = gql`
9089
+ fragment ChatReportFields on ReportChatUserType {
9090
+ _id
9091
+ chatId
9092
+ createdAt
9093
+ reason {
9094
+ reasonType
9095
+ details
9096
+ }
9097
+ reportedUserId
9098
+ reporterUserId
9099
+ resolved
9100
+ updatedAt
9101
+ }
9102
+ `;
9199
9103
  var GET_REPORTED_CHAT_USERS = gql`
9200
9104
  query getReportedChatUsers {
9201
9105
  reportedChatUsers {
9202
- _id
9203
- chatId
9204
- createdAt
9205
- reason {
9206
- reasonType
9207
- details
9208
- }
9209
- reportedUserId
9210
- reporterUserId
9211
- resolved
9212
- updatedAt
9106
+ ...ChatReportFields
9213
9107
  }
9214
9108
  }
9109
+ ${CHAT_REPORT_FIELDS_FRAGMENT}
9215
9110
  `;
9216
9111
  var SEND_CHAT_MESSAGE_MUTATION = gql`
9217
9112
  mutation sendChatMessage($_id: ID!, $input: ChatMessageInputType!) {
@@ -9261,9 +9156,10 @@ var MARK_CHAT_MESSAGES_SEEN_MUTATION = gql`
9261
9156
  var REPORT_CHAT_USER_MUTATION = gql`
9262
9157
  mutation reportChatUser($input: ReportChatUserInputType!) {
9263
9158
  reportChatUser(input: $input) {
9264
- success
9159
+ ...ChatReportFields
9265
9160
  }
9266
9161
  }
9162
+ ${CHAT_REPORT_FIELDS_FRAGMENT}
9267
9163
  `;
9268
9164
  var GET_CHAT_MESSAGE = gql`
9269
9165
  subscription {
@@ -10128,6 +10024,10 @@ var POST_FIELDS_FRAGMENT = gql`
10128
10024
  createdAt
10129
10025
  deletedAt
10130
10026
  postType
10027
+ resource {
10028
+ resourceId
10029
+ resourceType
10030
+ }
10131
10031
  tags
10132
10032
  title
10133
10033
  updatedAt
@@ -10831,6 +10731,10 @@ var postSchema = create$3().shape({
10831
10731
  caption: create$6().required(),
10832
10732
  content: create$2().of(postContentSchema).required(),
10833
10733
  postType: create$8().oneOf(Object.values(EnumPostType)).required(),
10734
+ resource: create$3({
10735
+ resourceId: create$6().required(),
10736
+ resourceType: create$8().oneOf(Object.values(EnumResourceType)).required()
10737
+ }).nullable().optional(),
10834
10738
  tags: create$2().of(create$6().required()).nullable().optional(),
10835
10739
  title: create$6().required()
10836
10740
  });
@@ -12378,6 +12282,17 @@ var schema13 = new MongooseSchema18(
12378
12282
  required: true,
12379
12283
  type: String
12380
12284
  },
12285
+ resource: {
12286
+ required: false,
12287
+ type: {
12288
+ resourceId: { required: true, type: String },
12289
+ resourceType: {
12290
+ enum: Object.values(EnumResourceType),
12291
+ required: true,
12292
+ type: String
12293
+ }
12294
+ }
12295
+ },
12381
12296
  tags: { default: [], required: false, type: [String] },
12382
12297
  title: { required: true, type: String }
12383
12298
  },