strapi-plugin-comments 3.0.0-beta.1 → 3.0.0

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.
Files changed (90) hide show
  1. package/README.md +81 -122
  2. package/dist/_chunks/{index-CY_AVWS-.js → index-B-ygLKrb.js} +417 -242
  3. package/dist/_chunks/{index-D3iNqWZT.mjs → index-BgN4aUMA.mjs} +5 -5
  4. package/dist/_chunks/{index-BBcsmSTs.mjs → index-Bx2boY6h.mjs} +420 -245
  5. package/dist/_chunks/{index-DJ32APz-.mjs → index-CIqMAf50.mjs} +1277 -1152
  6. package/dist/_chunks/{index-BXEk5PWx.js → index-CWfr5ejx.js} +20 -26
  7. package/dist/_chunks/{index-BFPteXuP.js → index-D8uskGzQ.js} +5 -5
  8. package/dist/_chunks/{index-Bcck91A8.js → index-DFAPx7Bl.js} +1290 -1144
  9. package/dist/_chunks/{index-D9MOkoQ2.mjs → index-Db2zwbpe.mjs} +20 -26
  10. package/dist/admin/index.js +1 -1
  11. package/dist/admin/index.mjs +1 -1
  12. package/dist/admin/src/api/client.d.ts +30 -50
  13. package/dist/admin/src/api/schemas.d.ts +432 -756
  14. package/dist/admin/src/components/UserAvatar/index.d.ts +1 -1
  15. package/dist/admin/src/hooks/useAPI.d.ts +30 -50
  16. package/dist/admin/src/hooks/useCommentsAll.d.ts +6 -10
  17. package/dist/admin/src/hooks/useReports.d.ts +6 -10
  18. package/dist/server/index.js +198 -144
  19. package/dist/server/index.mjs +198 -144
  20. package/dist/server/src/{@types-v5 → @types}/utils.d.ts +4 -0
  21. package/dist/server/src/bootstrap.d.ts +1 -1
  22. package/dist/server/src/config/index.d.ts +30 -0
  23. package/dist/server/src/content-types/index.d.ts +1 -1
  24. package/dist/server/src/controllers/admin.controller.d.ts +108 -29
  25. package/dist/server/src/controllers/client.controller.d.ts +117 -23
  26. package/dist/server/src/controllers/index.d.ts +297 -88
  27. package/dist/server/src/controllers/settings.controller.d.ts +33 -1
  28. package/dist/server/src/graphql/index.d.ts +1 -1
  29. package/dist/server/src/graphql/mutations/getCreateAbuseReport.d.ts +10 -4
  30. package/dist/server/src/graphql/mutations/getCreateComment.d.ts +10 -4
  31. package/dist/server/src/graphql/mutations/getRemoveComment.d.ts +10 -4
  32. package/dist/server/src/graphql/mutations/getUpdateComment.d.ts +10 -4
  33. package/dist/server/src/graphql/mutations/index.d.ts +2 -2
  34. package/dist/server/src/graphql/queries/findAllFlat.d.ts +18 -6
  35. package/dist/server/src/graphql/queries/findAllInHierarchy.d.ts +10 -4
  36. package/dist/server/src/graphql/queries/findAllPerAuthor.d.ts +18 -6
  37. package/dist/server/src/graphql/queries/index.d.ts +2 -2
  38. package/dist/server/src/graphql/types/getComment.d.ts +1 -1
  39. package/dist/server/src/graphql/types/getCommentAuthor.d.ts +1 -1
  40. package/dist/server/src/graphql/types/getCommentAuthorType.d.ts +1 -1
  41. package/dist/server/src/graphql/types/getCommentNested.d.ts +1 -1
  42. package/dist/server/src/graphql/types/getCreateComment.d.ts +1 -1
  43. package/dist/server/src/graphql/types/getCreateCommentAuthor.d.ts +1 -1
  44. package/dist/server/src/graphql/types/getCreateReport.d.ts +1 -1
  45. package/dist/server/src/graphql/types/getId.d.ts +1 -1
  46. package/dist/server/src/graphql/types/getIdentityAuthor.d.ts +1 -1
  47. package/dist/server/src/graphql/types/getRemoveComment.d.ts +1 -1
  48. package/dist/server/src/graphql/types/getReport.d.ts +1 -1
  49. package/dist/server/src/graphql/types/getReportReason.d.ts +1 -1
  50. package/dist/server/src/graphql/types/getResponseFindAll.d.ts +1 -1
  51. package/dist/server/src/graphql/types/getResponseFindAllPerAuthor.d.ts +1 -1
  52. package/dist/server/src/graphql/types/getResponseMeta.d.ts +1 -1
  53. package/dist/server/src/graphql/types/getResponsePagination.d.ts +1 -1
  54. package/dist/server/src/graphql/types/getUpdateComment.d.ts +1 -1
  55. package/dist/server/src/graphql/types/index.d.ts +1 -1
  56. package/dist/server/src/index.d.ts +921 -314
  57. package/dist/server/src/register/custom-fields/index.d.ts +1 -1
  58. package/dist/server/src/register/index.d.ts +1 -1
  59. package/dist/server/src/repositories/comment.repository.d.ts +10 -1
  60. package/dist/server/src/repositories/index.d.ts +0 -2
  61. package/dist/server/src/repositories/report.comment.repository.d.ts +38 -1
  62. package/dist/server/src/repositories/store.repository.d.ts +159 -3
  63. package/dist/server/src/repositories/utils.d.ts +1 -3
  64. package/dist/server/src/routes/admin.routes.d.ts +1 -1
  65. package/dist/server/src/routes/client.routes.d.ts +1 -1
  66. package/dist/server/src/routes/index.d.ts +2 -2
  67. package/dist/server/src/services/admin/admin.service.d.ts +232 -78
  68. package/dist/server/src/services/admin/utils.d.ts +1 -1
  69. package/dist/server/src/services/client.service.d.ts +177 -66
  70. package/dist/server/src/services/common.service.d.ts +60 -19
  71. package/dist/server/src/services/gql.service.d.ts +1 -1
  72. package/dist/server/src/services/index.d.ts +608 -222
  73. package/dist/server/src/services/settings.service.d.ts +25 -1
  74. package/dist/server/src/services/utils/functions.d.ts +1 -3
  75. package/dist/server/src/test/utils.d.ts +1 -0
  76. package/dist/server/src/utils/constants.d.ts +1 -1
  77. package/dist/server/src/utils/getConfig.d.ts +2 -2
  78. package/dist/server/src/utils/getPluginService.d.ts +2 -2
  79. package/dist/server/src/utils/throwError.d.ts +1 -1
  80. package/dist/server/src/validators/api/controllers/client.controller.validator.d.ts +10 -9
  81. package/dist/server/src/validators/api/controllers/settings.controller.validator.d.ts +4 -0
  82. package/dist/server/src/validators/repositories/comment.schema.d.ts +18 -3
  83. package/dist/server/src/validators/repositories/comment.validator.d.ts +384 -72
  84. package/dist/server/src/validators/repositories/reports.validator.d.ts +60 -18
  85. package/dist/server/src/validators/utils.d.ts +1 -1
  86. package/package.json +18 -12
  87. /package/dist/server/src/{@types-v5 → @types}/controllers.d.ts +0 -0
  88. /package/dist/server/src/{@types-v5 → @types}/index.d.ts +0 -0
  89. /package/dist/server/src/{@types-v5 → @types}/repositories.d.ts +0 -0
  90. /package/dist/server/src/{@types-v5 → @types}/routes.d.ts +0 -0
@@ -206,7 +206,7 @@ const getModelUid = (strapi2, name) => {
206
206
  const getDefaultAuthorPopulate = (strapi2) => {
207
207
  const strapiUserTypeUid = "plugin::users-permissions.user";
208
208
  const allowedTypes = ["media", "relation"];
209
- const { attributes } = strapi2.contentTypes[strapiUserTypeUid] || {};
209
+ const { attributes } = strapi2.contentType(strapiUserTypeUid) ?? { attributes: {} };
210
210
  const relationTypes = Object.keys(attributes)?.filter(
211
211
  (key) => allowedTypes.includes(attributes[key]?.type)
212
212
  );
@@ -1039,7 +1039,7 @@ lodash.exports;
1039
1039
  }
1040
1040
  var runInContext = function runInContext2(context) {
1041
1041
  context = context == null ? root : _2.defaults(root.Object(), context, _2.pick(root, contextProps));
1042
- var Array2 = context.Array, Date2 = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String2 = context.String, TypeError2 = context.TypeError;
1042
+ var Array2 = context.Array, Date = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String2 = context.String, TypeError2 = context.TypeError;
1043
1043
  var arrayProto = Array2.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
1044
1044
  var coreJsData = context["__core-js_shared__"];
1045
1045
  var funcToString = funcProto.toString;
@@ -1064,8 +1064,8 @@ lodash.exports;
1064
1064
  } catch (e) {
1065
1065
  }
1066
1066
  }();
1067
- var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1068
- var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
1067
+ var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date && Date.now !== root.Date.now && Date.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1068
+ var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
1069
1069
  var DataView = getNative(context, "DataView"), Map2 = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set2 = getNative(context, "Set"), WeakMap = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
1070
1070
  var metaMap = WeakMap && new WeakMap();
1071
1071
  var realNames = {};
@@ -2237,7 +2237,7 @@ lodash.exports;
2237
2237
  return symbolToString ? symbolToString.call(value) : "";
2238
2238
  }
2239
2239
  var result2 = value + "";
2240
- return result2 == "0" && 1 / value == -INFINITY ? "-0" : result2;
2240
+ return result2 == "0" && 1 / value == -Infinity ? "-0" : result2;
2241
2241
  }
2242
2242
  function baseUniq(array, iteratee2, comparator) {
2243
2243
  var index2 = -1, includes2 = arrayIncludes, length = array.length, isCommon = true, result2 = [], seen = result2;
@@ -2789,7 +2789,7 @@ lodash.exports;
2789
2789
  bitmask |= isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG;
2790
2790
  bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
2791
2791
  if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
2792
- bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
2792
+ bitmask &= -4;
2793
2793
  }
2794
2794
  var newData = [
2795
2795
  func,
@@ -2845,7 +2845,7 @@ lodash.exports;
2845
2845
  }
2846
2846
  var length = partials ? partials.length : 0;
2847
2847
  if (!length) {
2848
- bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
2848
+ bitmask &= -97;
2849
2849
  partials = holders = undefined$1;
2850
2850
  }
2851
2851
  ary2 = ary2 === undefined$1 ? ary2 : nativeMax(toInteger(ary2), 0);
@@ -2878,7 +2878,7 @@ lodash.exports;
2878
2878
  holders = newData[4];
2879
2879
  arity = newData[9] = newData[9] === undefined$1 ? isBindKey ? 0 : func.length : nativeMax(newData[9] - length, 0);
2880
2880
  if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
2881
- bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
2881
+ bitmask &= -25;
2882
2882
  }
2883
2883
  if (!bitmask || bitmask == WRAP_BIND_FLAG) {
2884
2884
  var result2 = createBind(func, bitmask, thisArg);
@@ -3444,7 +3444,7 @@ lodash.exports;
3444
3444
  return value;
3445
3445
  }
3446
3446
  var result2 = value + "";
3447
- return result2 == "0" && 1 / value == -INFINITY ? "-0" : result2;
3447
+ return result2 == "0" && 1 / value == -Infinity ? "-0" : result2;
3448
3448
  }
3449
3449
  function toSource(func) {
3450
3450
  if (func != null) {
@@ -4508,7 +4508,7 @@ lodash.exports;
4508
4508
  }
4509
4509
  var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
4510
4510
  function isSafeInteger(value) {
4511
- return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
4511
+ return isInteger(value) && value >= -9007199254740991 && value <= MAX_SAFE_INTEGER;
4512
4512
  }
4513
4513
  var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
4514
4514
  function isString(value) {
@@ -4549,7 +4549,7 @@ lodash.exports;
4549
4549
  return value === 0 ? value : 0;
4550
4550
  }
4551
4551
  value = toNumber(value);
4552
- if (value === INFINITY || value === -INFINITY) {
4552
+ if (value === INFINITY || value === -Infinity) {
4553
4553
  var sign = value < 0 ? -1 : 1;
4554
4554
  return sign * MAX_INTEGER;
4555
4555
  }
@@ -4584,7 +4584,7 @@ lodash.exports;
4584
4584
  return copyObject(value, keysIn(value));
4585
4585
  }
4586
4586
  function toSafeInteger(value) {
4587
- return value ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) : value === 0 ? value : 0;
4587
+ return value ? baseClamp(toInteger(value), -9007199254740991, MAX_SAFE_INTEGER) : value === 0 ? value : 0;
4588
4588
  }
4589
4589
  function toString(value) {
4590
4590
  return value == null ? "" : baseToString(value);
@@ -5822,29 +5822,6 @@ lodash.exports;
5822
5822
  }).call(commonjsGlobal);
5823
5823
  })(lodash, lodash.exports);
5824
5824
  var lodashExports = lodash.exports;
5825
- let PluginError$1 = class PluginError extends Error {
5826
- constructor(status, message, payload = void 0) {
5827
- super();
5828
- this.name = "Strapi:Plugin:Comments";
5829
- this.status = status || 500;
5830
- this.message = message || "Internal error";
5831
- this.payload = payload;
5832
- Object.setPrototypeOf(this, PluginError.prototype);
5833
- }
5834
- toString(e = this) {
5835
- return `${e.name} - ${e.message}`;
5836
- }
5837
- toJSON() {
5838
- if (this.payload) {
5839
- return {
5840
- ...this.payload,
5841
- name: this.name,
5842
- message: this.message
5843
- };
5844
- }
5845
- return this;
5846
- }
5847
- };
5848
5825
  const flatInput = (payload) => {
5849
5826
  const {
5850
5827
  sort,
@@ -5884,7 +5861,6 @@ const flatInput = (payload) => {
5884
5861
  }
5885
5862
  };
5886
5863
  }
5887
- ({ ...filters });
5888
5864
  return {
5889
5865
  ...payload,
5890
5866
  filters: {
@@ -6025,6 +6001,7 @@ const getComment = (nexus) => {
6025
6001
  name: "CommentSingle",
6026
6002
  definition(t) {
6027
6003
  t.id("id");
6004
+ t.string("documentId");
6028
6005
  t.nonNull.string("content");
6029
6006
  t.boolean("blocked");
6030
6007
  t.boolean("blockedThread");
@@ -6060,6 +6037,7 @@ const getCommentNested = (nexus) => {
6060
6037
  name: "CommentNested",
6061
6038
  definition(t) {
6062
6039
  t.id("id");
6040
+ t.string("documentId");
6063
6041
  t.nonNull.string("content");
6064
6042
  t.boolean("blocked");
6065
6043
  t.boolean("blockedThread");
@@ -8111,8 +8089,19 @@ const typesFactories = [
8111
8089
  getReport
8112
8090
  ];
8113
8091
  const getTypes = (config2, nexus) => typesFactories.map((factory) => factory(nexus, config2));
8092
+ const getExtensionService = (strapi2) => strapi2.plugin("graphql").service("extension");
8093
+ const disableDefaultGQL = (strapi2) => {
8094
+ const extensionService = getExtensionService(strapi2);
8095
+ extensionService.shadowCRUD(getModelUid(strapi2, "comment")).disable();
8096
+ extensionService.shadowCRUD(getModelUid(strapi2, "comment")).disableQueries();
8097
+ extensionService.shadowCRUD(getModelUid(strapi2, "comment")).disableMutations();
8098
+ extensionService.shadowCRUD(getModelUid(strapi2, "comment-report")).disable();
8099
+ extensionService.shadowCRUD(getModelUid(strapi2, "comment-report")).disableQueries();
8100
+ extensionService.shadowCRUD(getModelUid(strapi2, "comment-report")).disableMutations();
8101
+ };
8114
8102
  const setupGQL = async ({ strapi: strapi2 }) => {
8115
8103
  if (strapi2.plugin("graphql")) {
8104
+ disableDefaultGQL(strapi2);
8116
8105
  const enableCollections = await getPluginService(strapi2, "common").getConfig(CONFIG_PARAMS$1.ENABLED_COLLECTIONS, []);
8117
8106
  if (enableCollections.length) {
8118
8107
  await handleConfig(strapi2);
@@ -8120,13 +8109,7 @@ const setupGQL = async ({ strapi: strapi2 }) => {
8120
8109
  }
8121
8110
  };
8122
8111
  const handleConfig = async (strapi2) => {
8123
- const extensionService = strapi2.plugin("graphql").service("extension");
8124
- extensionService.shadowCRUD(getModelUid(strapi2, "comment")).disable();
8125
- extensionService.shadowCRUD(getModelUid(strapi2, "comment")).disableQueries();
8126
- extensionService.shadowCRUD(getModelUid(strapi2, "comment")).disableMutations();
8127
- extensionService.shadowCRUD(getModelUid(strapi2, "comment-report")).disable();
8128
- extensionService.shadowCRUD(getModelUid(strapi2, "comment-report")).disableQueries();
8129
- extensionService.shadowCRUD(getModelUid(strapi2, "comment-report")).disableMutations();
8112
+ const extensionService = getExtensionService(strapi2);
8130
8113
  const config2 = await getPluginService(strapi2, "common").getConfig();
8131
8114
  extensionService.use(({ strapi: strapi22, nexus }) => {
8132
8115
  const types = getTypes(config2, nexus);
@@ -8235,7 +8218,11 @@ const schemaConfig = zod.z.object({
8235
8218
  [CONFIG_PARAMS.AUTHOR_BLOCKED_PROPS]: zod.z.array(zod.z.string()),
8236
8219
  gql: zod.z.object({
8237
8220
  auth: zod.z.boolean().optional()
8238
- }).optional()
8221
+ }).optional(),
8222
+ client: zod.z.object({
8223
+ url: zod.z.string().nullable(),
8224
+ contactEmail: zod.z.string().nullable()
8225
+ }).default({ url: null, contactEmail: null })
8239
8226
  });
8240
8227
  const config = {
8241
8228
  default: schemaConfig.parse(defaultPluginConfig),
@@ -8272,14 +8259,14 @@ const isRight = (e) => {
8272
8259
  };
8273
8260
  const makeLeft = (value) => ({ left: value });
8274
8261
  const makeRight = (value) => ({ right: value });
8275
- class PluginError2 extends Error {
8262
+ let PluginError$1 = class PluginError extends Error {
8276
8263
  constructor(status, message, payload = void 0) {
8277
8264
  super();
8278
8265
  this.name = "Strapi:Plugin:Comments";
8279
8266
  this.status = status || 500;
8280
8267
  this.message = message || "Internal error";
8281
8268
  this.payload = payload;
8282
- Object.setPrototypeOf(this, PluginError2.prototype);
8269
+ Object.setPrototypeOf(this, PluginError.prototype);
8283
8270
  }
8284
8271
  toString(e = this) {
8285
8272
  return `${e.name} - ${e.message}`;
@@ -8294,9 +8281,9 @@ class PluginError2 extends Error {
8294
8281
  }
8295
8282
  return this;
8296
8283
  }
8297
- }
8284
+ };
8298
8285
  const throwError = (ctx, e) => {
8299
- if (e instanceof PluginError2) {
8286
+ if (e instanceof PluginError$1) {
8300
8287
  return ctx.throw(e.status, JSON.stringify(e));
8301
8288
  }
8302
8289
  return e;
@@ -8383,7 +8370,7 @@ const queryPaginationSchema = zod.z.object({ pageSize: stringToNumberValidator.d
8383
8370
  const validate = (result) => {
8384
8371
  if (!result.success) {
8385
8372
  const message = result.error.issues.map((i) => `Path: ${i.path.join(".")} Code: ${i.code} Message: ${i.message}`).join("\n");
8386
- return makeLeft(new PluginError2(400, message));
8373
+ return makeLeft(new PluginError$1(400, message));
8387
8374
  }
8388
8375
  return makeRight(result.data);
8389
8376
  };
@@ -8451,7 +8438,7 @@ const getCommentSchema = (enabledCollections) => {
8451
8438
  relation: getRelationValidator(enabledCollections),
8452
8439
  content: zod.z.string().min(1),
8453
8440
  author: externalAuthorSchema.optional(),
8454
- threadOf: zod.z.number().optional(),
8441
+ threadOf: zod.z.string().optional(),
8455
8442
  approvalStatus: zod.z.nativeEnum(APPROVAL_STATUS).optional(),
8456
8443
  locale: zod.z.string().optional()
8457
8444
  });
@@ -8538,16 +8525,16 @@ const findAllPerAuthorValidator = (params, payload) => {
8538
8525
  ...params
8539
8526
  }));
8540
8527
  };
8541
- const getReportAbuseSchema = (enabledCollections) => {
8528
+ const getReportAbuseSchema = (config2) => {
8542
8529
  return zod.z.object({
8543
- relation: getRelationValidator(enabledCollections),
8544
- commentId: zod.z.number(),
8530
+ relation: getRelationValidator(config2[CONFIG_PARAMS.ENABLED_COLLECTIONS]),
8531
+ commentId: stringToNumberValidator,
8545
8532
  content: zod.z.string().min(1),
8546
- reason: zod.z.string().min(1)
8533
+ reason: zod.z.nativeEnum(config2.reportReasons)
8547
8534
  });
8548
8535
  };
8549
- const reportAbuseValidator = (enabledCollections, payload) => {
8550
- return validate(getReportAbuseSchema(enabledCollections).safeParse(payload));
8536
+ const reportAbuseValidator = (config2, payload) => {
8537
+ return validate(getReportAbuseSchema(config2).safeParse(payload));
8551
8538
  };
8552
8539
  const getRemoveCommentSchema = (enabledCollections) => {
8553
8540
  return zod.z.object({
@@ -8714,7 +8701,7 @@ const dbBaseCommentSchema = zod.z.object({
8714
8701
  authorName: zod.z.string().nullable(),
8715
8702
  authorEmail: zod.z.string().email().nullable(),
8716
8703
  authorAvatar: zod.z.string().nullable(),
8717
- authorUser: zod.z.string().optional().nullable(),
8704
+ authorUser: zod.z.union([zod.z.string(), zod.z.object({ id: zod.z.number(), email: zod.z.string().email() })]).optional().nullable(),
8718
8705
  locale: zod.z.string().nullable()
8719
8706
  });
8720
8707
  const paginationSchema = zod.z.object({
@@ -8804,7 +8791,7 @@ const reportSchema = zod.z.object({
8804
8791
  updatedAt: zod.z.string(),
8805
8792
  publishedAt: zod.z.string().nullable(),
8806
8793
  locale: zod.z.string().nullable(),
8807
- related: relatedSchema.nullable()
8794
+ related: relatedSchema.nullable().optional()
8808
8795
  });
8809
8796
  const findPageSchema = zod.z.object({
8810
8797
  results: zod.z.array(reportSchema),
@@ -8839,7 +8826,7 @@ const reportResultValidator = {
8839
8826
  update: updateResultSchema,
8840
8827
  create: reportSchema
8841
8828
  };
8842
- const getReportCommentRepository = lodashExports.once((strapi2) => {
8829
+ const getReportCommentRepositorySource = (strapi2) => {
8843
8830
  const modelUid = getModelUid(strapi2, "comment-report");
8844
8831
  const repository = strapi2.query(modelUid);
8845
8832
  return {
@@ -8863,8 +8850,9 @@ const getReportCommentRepository = lodashExports.once((strapi2) => {
8863
8850
  return repository.create(params).then(shouldValidateObject(isValidationEnabled, reportResultValidator.create));
8864
8851
  }
8865
8852
  };
8866
- });
8867
- const getCommentRepository = lodashExports.once((strapi2) => {
8853
+ };
8854
+ const getReportCommentRepository = lodashExports.once(getReportCommentRepositorySource);
8855
+ const getCommentRepositorySource = (strapi2) => {
8868
8856
  const modelUid = getModelUid(strapi2, "comment");
8869
8857
  return {
8870
8858
  async findMany(params) {
@@ -8895,8 +8883,9 @@ const getCommentRepository = lodashExports.once((strapi2) => {
8895
8883
  return strapi2.query(modelUid).create(params).then(shouldValidateObject(isValidationEnabled, commentResultValidator.create));
8896
8884
  }
8897
8885
  };
8898
- });
8899
- const getStoreRepository = lodashExports.once((strapi2) => {
8886
+ };
8887
+ const getCommentRepository = lodashExports.once(getCommentRepositorySource);
8888
+ const getStoreRepositorySource = (strapi2) => {
8900
8889
  return {
8901
8890
  getLocalConfig(prop, defaultValue) {
8902
8891
  return strapi2.config.get([PLUGIN_SELECTOR, prop].filter(Boolean).join("."), defaultValue);
@@ -8973,7 +8962,8 @@ const getStoreRepository = lodashExports.once((strapi2) => {
8973
8962
  return this.get();
8974
8963
  }
8975
8964
  };
8976
- });
8965
+ };
8966
+ const getStoreRepository = lodashExports.once(getStoreRepositorySource);
8977
8967
  const controllers$1 = ({ strapi: strapi2 }) => ({
8978
8968
  getService(name) {
8979
8969
  return getPluginService(strapi2, name);
@@ -8985,7 +8975,6 @@ const controllers$1 = ({ strapi: strapi2 }) => ({
8985
8975
  const configResult = await this.getStoreRepository().get(true);
8986
8976
  if (isRight(configResult)) {
8987
8977
  const config2 = unwrapEither(configResult);
8988
- console.log("config.enabledCollections", config2.enabledCollections);
8989
8978
  const result = newCommentValidator(config2.enabledCollections, ctx.params.relation, ctx.request.body);
8990
8979
  if (isRight(result)) {
8991
8980
  return this.getService("client").create(result.right, ctx.state.user);
@@ -9057,7 +9046,7 @@ const controllers$1 = ({ strapi: strapi2 }) => ({
9057
9046
  const configResult = await this.getStoreRepository().get(true);
9058
9047
  if (isRight(configResult)) {
9059
9048
  const config2 = unwrapEither(configResult);
9060
- const result = reportAbuseValidator(config2.enabledCollections, {
9049
+ const result = reportAbuseValidator(config2, {
9061
9050
  ...ctx.request.body,
9062
9051
  ...ctx.params
9063
9052
  });
@@ -9328,7 +9317,6 @@ const routes$1 = [
9328
9317
  path: "/:relation",
9329
9318
  handler: "client.findAllInHierarchy",
9330
9319
  config: {
9331
- auth: false,
9332
9320
  policies: [],
9333
9321
  description: "Find all comments related to configured Collection / Single Type and return them in a nested structure",
9334
9322
  tag: {
@@ -9343,7 +9331,6 @@ const routes$1 = [
9343
9331
  path: "/:relation",
9344
9332
  handler: "client.post",
9345
9333
  config: {
9346
- auth: false,
9347
9334
  policies: [],
9348
9335
  description: "Post a comment against configured Collection / Single Type",
9349
9336
  tag: {
@@ -9358,7 +9345,6 @@ const routes$1 = [
9358
9345
  path: "/:relation/flat",
9359
9346
  handler: "client.findAllFlat",
9360
9347
  config: {
9361
- auth: false,
9362
9348
  policies: [],
9363
9349
  description: "Find all comments related to configured Collection / Single Type and return them in a flat structure for further processing",
9364
9350
  tag: {
@@ -9373,7 +9359,6 @@ const routes$1 = [
9373
9359
  path: "/:relation/comment/:commentId",
9374
9360
  handler: "client.put",
9375
9361
  config: {
9376
- auth: false,
9377
9362
  policies: [],
9378
9363
  description: "Update comment related to configured Collection / Single Type if user is the author",
9379
9364
  tag: {
@@ -9388,7 +9373,6 @@ const routes$1 = [
9388
9373
  path: "/:relation/comment/:commentId/report-abuse",
9389
9374
  handler: "client.reportAbuse",
9390
9375
  config: {
9391
- auth: false,
9392
9376
  policies: [],
9393
9377
  description: "Report an abuse against comment for configured Collection / Single Type",
9394
9378
  tag: {
@@ -9403,7 +9387,6 @@ const routes$1 = [
9403
9387
  path: "/:relation/comment/:commentId",
9404
9388
  handler: "client.removeComment",
9405
9389
  config: {
9406
- auth: false,
9407
9390
  policies: [],
9408
9391
  description: "Remove comment related to configured Collection / Single Type if user is the author",
9409
9392
  tag: {
@@ -9418,7 +9401,6 @@ const routes$1 = [
9418
9401
  path: "/author/:authorId",
9419
9402
  handler: "client.findAllPerAuthor",
9420
9403
  config: {
9421
- auth: false,
9422
9404
  policies: [],
9423
9405
  description: "Find all comments created by Strapi user",
9424
9406
  tag: {
@@ -9433,7 +9415,6 @@ const routes$1 = [
9433
9415
  path: "/author/:authorId/:type",
9434
9416
  handler: "client.findAllPerAuthor",
9435
9417
  config: {
9436
- auth: false,
9437
9418
  policies: [],
9438
9419
  description: "Find all comments created by specified type of user",
9439
9420
  tag: {
@@ -9454,6 +9435,29 @@ const routes = {
9454
9435
  routes: adminRoutes$1
9455
9436
  }
9456
9437
  };
9438
+ class PluginError2 extends Error {
9439
+ constructor(status, message, payload = void 0) {
9440
+ super();
9441
+ this.name = "Strapi:Plugin:Comments";
9442
+ this.status = status || 500;
9443
+ this.message = message || "Internal error";
9444
+ this.payload = payload;
9445
+ Object.setPrototypeOf(this, PluginError2.prototype);
9446
+ }
9447
+ toString(e = this) {
9448
+ return `${e.name} - ${e.message}`;
9449
+ }
9450
+ toJSON() {
9451
+ if (this.payload) {
9452
+ return {
9453
+ ...this.payload,
9454
+ name: this.name,
9455
+ message: this.message
9456
+ };
9457
+ }
9458
+ return this;
9459
+ }
9460
+ }
9457
9461
  const buildNestedStructure = (entities, id = null, field = "threadOf", dropBlockedThreads = false, blockNestedThreads = false) => entities.filter((entity) => {
9458
9462
  const entityField = lodashExports.get(entity, field);
9459
9463
  if (entityField === null && id === null) {
@@ -9519,14 +9523,14 @@ const buildAuthorModel = (item, blockedAuthorProps, fieldsToPopulate = []) => {
9519
9523
  );
9520
9524
  return {
9521
9525
  ...rest,
9522
- author
9526
+ author: lodashExports.isEmpty(author) ? item.author || {} : author
9523
9527
  };
9524
9528
  };
9525
9529
  const resolveUserContextError = (user) => {
9526
9530
  if (user) {
9527
- throw new PluginError$1(401, "Not authenticated");
9531
+ throw new PluginError2(401, "Not authenticated");
9528
9532
  } else {
9529
- throw new PluginError$1(403, "Not authorized");
9533
+ throw new PluginError2(403, "Not authorized");
9530
9534
  }
9531
9535
  };
9532
9536
  const getAuthorName = (author) => {
@@ -9717,16 +9721,16 @@ const adminServices = ({ strapi: strapi2 }) => {
9717
9721
  where: { id }
9718
9722
  });
9719
9723
  if (!entity) {
9720
- throw new PluginError2(404, "Not found");
9724
+ throw new PluginError$1(404, "Not found");
9721
9725
  }
9722
9726
  const { relatedId, uid } = this.getCommonService().parseRelationString(entity.related);
9723
- const relatedEntity = await strapi2.entityService.findOne(uid, relatedId).then((_2) => {
9727
+ const relatedEntity = await strapi2.documents(uid).findOne({ documentId: relatedId }).then((_2) => {
9724
9728
  if (!_2) {
9725
- throw new PluginError2(404, "Relation not found");
9729
+ throw new PluginError$1(404, "Relation not found");
9726
9730
  }
9727
9731
  return { ..._2, uid };
9728
9732
  });
9729
- const levelThreadId = entity.threadOf && typeof entity.threadOf === "object" ? entity.threadOf.id : null;
9733
+ const levelThreadId = entity.threadOf && typeof entity.threadOf === "object" ? entity.threadOf.documentId : null;
9730
9734
  const entitiesOnSameLevel = await this.getCommonService().findAllInHierarchy(
9731
9735
  {
9732
9736
  query: {
@@ -9783,7 +9787,7 @@ const adminServices = ({ strapi: strapi2 }) => {
9783
9787
  data: { approvalStatus: APPROVAL_STATUS.APPROVED }
9784
9788
  });
9785
9789
  if (!entity) {
9786
- throw new PluginError2(404, "Not found");
9790
+ throw new PluginError$1(404, "Not found");
9787
9791
  }
9788
9792
  return this.getCommonService().sanitizeCommentEntity(entity, []);
9789
9793
  },
@@ -9793,7 +9797,7 @@ const adminServices = ({ strapi: strapi2 }) => {
9793
9797
  data: { approvalStatus: APPROVAL_STATUS.REJECTED }
9794
9798
  });
9795
9799
  if (!entity) {
9796
- throw new PluginError2(404, "Not found");
9800
+ throw new PluginError$1(404, "Not found");
9797
9801
  }
9798
9802
  return this.getCommonService().sanitizeCommentEntity(entity, []);
9799
9803
  },
@@ -9839,14 +9843,14 @@ const adminServices = ({ strapi: strapi2 }) => {
9839
9843
  }
9840
9844
  });
9841
9845
  }
9842
- throw new PluginError2(
9846
+ throw new PluginError$1(
9843
9847
  400,
9844
9848
  "At least one of selected reports got invalid comment entity relation. Try again."
9845
9849
  );
9846
9850
  },
9847
9851
  async resolveAllAbuseReportsForComment(id) {
9848
9852
  if (!id) {
9849
- throw new PluginError2(
9853
+ throw new PluginError$1(
9850
9854
  400,
9851
9855
  "There is something wrong with comment Id. Try again."
9852
9856
  );
@@ -9863,7 +9867,7 @@ const adminServices = ({ strapi: strapi2 }) => {
9863
9867
  },
9864
9868
  async resolveAllAbuseReportsForThread(commentId) {
9865
9869
  if (!commentId) {
9866
- throw new PluginError2(
9870
+ throw new PluginError$1(
9867
9871
  400,
9868
9872
  "There is something wrong with comment Id. Try again."
9869
9873
  );
@@ -9901,7 +9905,7 @@ const adminServices = ({ strapi: strapi2 }) => {
9901
9905
  where: { id }
9902
9906
  });
9903
9907
  if (!entity) {
9904
- throw new PluginError2(404, "Not found");
9908
+ throw new PluginError$1(404, "Not found");
9905
9909
  }
9906
9910
  return getCommentRepository(strapi2).create({
9907
9911
  data: {
@@ -9921,7 +9925,7 @@ const adminServices = ({ strapi: strapi2 }) => {
9921
9925
  data: { content }
9922
9926
  });
9923
9927
  if (!entity) {
9924
- throw new PluginError2(404, "Not found");
9928
+ throw new PluginError$1(404, "Not found");
9925
9929
  }
9926
9930
  return this.getCommonService().sanitizeCommentEntity(entity, []);
9927
9931
  }
@@ -9935,8 +9939,8 @@ const tryCatch = async (callback, throwError2) => {
9935
9939
  }
9936
9940
  };
9937
9941
  const clientService = ({ strapi: strapi2 }) => {
9938
- const createAuthor = (isValidContent, author, user) => {
9939
- if (isValidContent && user) {
9942
+ const createAuthor = (author, user) => {
9943
+ if (user) {
9940
9944
  return {
9941
9945
  authorUser: user.id
9942
9946
  };
@@ -9958,7 +9962,7 @@ const clientService = ({ strapi: strapi2 }) => {
9958
9962
  const { uid, relatedId } = this.getCommonService().parseRelationString(relation);
9959
9963
  const relatedEntity = await strapi2.documents(uid).findOne({ documentId: relatedId, locale });
9960
9964
  if (!relatedEntity) {
9961
- throw new PluginError$1(
9965
+ throw new PluginError2(
9962
9966
  400,
9963
9967
  `Relation for field "related" does not exist. Check your payload please.`
9964
9968
  );
@@ -9973,21 +9977,24 @@ const clientService = ({ strapi: strapi2 }) => {
9973
9977
  async () => {
9974
9978
  return threadOf ? await this.getCommonService().findOne({ id: threadOf, related: relation, locale }) : null;
9975
9979
  },
9976
- new PluginError$1(400, "Thread does not exist")
9980
+ new PluginError2(400, "Thread does not exist")
9977
9981
  );
9978
9982
  if (isLeft(threadData)) {
9979
9983
  throw unwrapEither(threadData);
9980
9984
  }
9981
9985
  const linkToThread = unwrapEither(threadData);
9982
- this.getCommonService().isValidUserContext(user);
9986
+ const isValidContext = this.getCommonService().isValidUserContext(user);
9987
+ if (!isValidContext) {
9988
+ throw resolveUserContextError(user);
9989
+ }
9983
9990
  const clearContent = await this.getCommonService().checkBadWords(content);
9984
- const authorData = createAuthor(isApprovalFlowEnabled, author, user);
9991
+ const authorData = createAuthor(author, user);
9985
9992
  const authorNotProperlyProvided = !lodashExports.isEmpty(authorData) && !(authorData.authorId || authorData.authorUser);
9986
9993
  if (lodashExports.isEmpty(authorData) || authorNotProperlyProvided) {
9987
- throw new PluginError$1(400, `Not able to recognise author of a comment. Make sure you've provided "author" property in a payload or authenticated your request properly.`);
9994
+ throw new PluginError2(400, `Not able to recognise author of a comment. Make sure you've provided "author" property in a payload or authenticated your request properly.`);
9988
9995
  }
9989
9996
  if (isApprovalFlowEnabled && approvalStatus && approvalStatus !== APPROVAL_STATUS.PENDING) {
9990
- throw new PluginError$1(400, "Invalid approval status");
9997
+ throw new PluginError2(400, "Invalid approval status");
9991
9998
  }
9992
9999
  const comment2 = await getCommentRepository(strapi2).create({
9993
10000
  data: {
@@ -10040,7 +10047,7 @@ const clientService = ({ strapi: strapi2 }) => {
10040
10047
  related: relation
10041
10048
  });
10042
10049
  if (reportAgainstEntity.isAdminComment) {
10043
- throw new PluginError$1(
10050
+ throw new PluginError2(
10044
10051
  403,
10045
10052
  `You're not allowed to take an action on that entity. This in a admin comment.`
10046
10053
  );
@@ -10065,10 +10072,10 @@ const clientService = ({ strapi: strapi2 }) => {
10065
10072
  return response;
10066
10073
  }
10067
10074
  } else {
10068
- throw new PluginError$1(500, "Report cannot be created");
10075
+ throw new PluginError2(500, "Report cannot be created");
10069
10076
  }
10070
10077
  }
10071
- throw new PluginError$1(
10078
+ throw new PluginError2(
10072
10079
  403,
10073
10080
  `You're not allowed to take an action on that entity. Make sure that comment exist or you've authenticated your request properly.`
10074
10081
  );
@@ -10082,7 +10089,7 @@ const clientService = ({ strapi: strapi2 }) => {
10082
10089
  }
10083
10090
  const author = user?.id || authorId;
10084
10091
  if (!author) {
10085
- throw new PluginError$1(
10092
+ throw new PluginError2(
10086
10093
  403,
10087
10094
  `You're not allowed to take an action on that entity. Make sure that you've provided proper "authorId" or authenticated your request properly.`
10088
10095
  );
@@ -10111,23 +10118,88 @@ const clientService = ({ strapi: strapi2 }) => {
10111
10118
  const doNotPopulateAuthor = await this.getCommonService().getConfig(CONFIG_PARAMS$1.AUTHOR_BLOCKED_PROPS, []);
10112
10119
  return this.getCommonService().sanitizeCommentEntity(removedEntity, doNotPopulateAuthor);
10113
10120
  } else {
10114
- throw new PluginError$1(
10121
+ throw new PluginError2(
10115
10122
  404,
10116
10123
  `Entity does not exist or you're not allowed to take an action on it`
10117
10124
  );
10118
10125
  }
10119
10126
  } catch (e) {
10120
- throw new PluginError$1(
10127
+ throw new PluginError2(
10121
10128
  404,
10122
10129
  `Entity does not exist or you're not allowed to take an action on it`
10123
10130
  );
10124
10131
  }
10125
10132
  },
10126
10133
  async sendAbuseReportEmail(reason, content) {
10134
+ const SUPER_ADMIN_ROLE = "strapi-super-admin";
10135
+ const rolesToNotify = await this.getCommonService().getConfig(CONFIG_PARAMS$1.MODERATOR_ROLES, [SUPER_ADMIN_ROLE]);
10136
+ if (rolesToNotify.length > 0) {
10137
+ const emails = await strapi2.query("admin::user").findMany({ where: { roles: { code: rolesToNotify } } }).then((users) => users.map((user) => user.email));
10138
+ if (emails.length > 0) {
10139
+ const from = await strapi2.query("admin::user").findOne({ where: { roles: { code: SUPER_ADMIN_ROLE } } });
10140
+ if (strapi2.plugin("email")) {
10141
+ await strapi2.plugin("email").service("email").send({
10142
+ to: emails,
10143
+ from: from.email,
10144
+ subject: "New abuse report on comment",
10145
+ text: `
10146
+ There was a new abuse report on your app.
10147
+ Reason: ${reason}
10148
+ Message: ${content}
10149
+ `
10150
+ });
10151
+ }
10152
+ }
10153
+ }
10127
10154
  },
10128
10155
  async markAsRemovedNested(commentId, status) {
10156
+ return this.getCommonService().modifiedNestedNestedComments(
10157
+ commentId,
10158
+ "removed",
10159
+ status
10160
+ );
10129
10161
  },
10130
- async sendResponseNotification(_entry) {
10162
+ async sendResponseNotification(entity) {
10163
+ if (entity.threadOf) {
10164
+ const thread = typeof entity.threadOf === "object" ? entity.threadOf : await this.getCommonService().findOne({ id: entity.threadOf });
10165
+ let emailRecipient = thread?.author?.email;
10166
+ if (thread.authorUser && !emailRecipient) {
10167
+ const strapiUser = typeof thread.authorUser === "object" ? thread.authorUser : await strapi2.query("plugin::users-permissions.user").findOne({
10168
+ where: { id: thread.authorUser }
10169
+ });
10170
+ emailRecipient = strapiUser?.email;
10171
+ }
10172
+ if (emailRecipient) {
10173
+ const superAdmin = await strapi2.query("admin::user").findOne({
10174
+ where: {
10175
+ roles: { code: "strapi-super-admin" }
10176
+ }
10177
+ });
10178
+ const emailSender = await this.getCommonService().getConfig("client.contactEmail", superAdmin.email);
10179
+ const clientAppUrl = await this.getCommonService().getConfig("client.url", "our site");
10180
+ try {
10181
+ await strapi2.plugin("email").service("email").send({
10182
+ to: [emailRecipient],
10183
+ from: emailSender,
10184
+ subject: "You've got a new response to your comment",
10185
+ text: `Hello ${thread?.author?.name || emailRecipient}!
10186
+ You've got a new response to your comment by ${entity?.author?.name || entity?.author?.email}.
10187
+
10188
+ ------
10189
+
10190
+ "${entity.content}"
10191
+
10192
+ ------
10193
+
10194
+ Visit ${clientAppUrl} and continue the discussion.
10195
+ `
10196
+ });
10197
+ } catch (err) {
10198
+ strapi2.log.error(err);
10199
+ throw err;
10200
+ }
10201
+ }
10202
+ }
10131
10203
  }
10132
10204
  };
10133
10205
  };
@@ -10137,7 +10209,7 @@ const commonService = ({ strapi: strapi2 }) => ({
10137
10209
  async getConfig(prop, defaultValue, useLocal = false) {
10138
10210
  const storeRepository = getStoreRepository(strapi2);
10139
10211
  const config2 = await storeRepository.getConfig();
10140
- if (prop && config2 && !useLocal) {
10212
+ if (prop && !useLocal) {
10141
10213
  return lodashExports.get(config2, prop, defaultValue);
10142
10214
  }
10143
10215
  if (useLocal) {
@@ -10188,7 +10260,7 @@ const commonService = ({ strapi: strapi2 }) => ({
10188
10260
  const [operator, direction] = getOrderBy(sort);
10189
10261
  const fieldsQuery = {
10190
10262
  sort: { [operator]: direction },
10191
- select: Array.isArray(fields) ? lodashExports.uniq([...fields, defaultSelect]) : fields
10263
+ select: Array.isArray(fields) ? lodashExports.uniq([...fields, defaultSelect].flat()) : fields
10192
10264
  };
10193
10265
  const entries = await getCommentRepository(strapi2).findMany({
10194
10266
  where: {
@@ -10275,10 +10347,12 @@ const commonService = ({ strapi: strapi2 }) => ({
10275
10347
  authorUser: true
10276
10348
  }
10277
10349
  });
10350
+ console.log("findOne::entity", entity);
10278
10351
  if (!entity) {
10279
- throw new PluginError2(400, "Comment does not exist. Check your payload please.");
10352
+ throw new PluginError$1(400, "Comment does not exist. Check your payload please.");
10280
10353
  }
10281
10354
  const doNotPopulateAuthor = await this.getConfig(CONFIG_PARAMS.AUTHOR_BLOCKED_PROPS, []);
10355
+ console.log("doNotPopulateAuthor", doNotPopulateAuthor);
10282
10356
  const item = this.sanitizeCommentEntity(entity, doNotPopulateAuthor);
10283
10357
  return filterOurResolvedReports(item);
10284
10358
  },
@@ -10380,7 +10454,11 @@ const commonService = ({ strapi: strapi2 }) => ({
10380
10454
  )
10381
10455
  };
10382
10456
  },
10383
- async modifiedNestedNestedComments(id, fieldName, value) {
10457
+ // TODO: we need to add deepLimit to the function to prevent infinite loops
10458
+ async modifiedNestedNestedComments(id, fieldName, value, deepLimit = 10) {
10459
+ if (deepLimit === 0) {
10460
+ return true;
10461
+ }
10384
10462
  try {
10385
10463
  const entities = await this.findMany({ where: { threadOf: id } });
10386
10464
  const changedEntries = await getCommentRepository(strapi2).updateMany({
@@ -10389,7 +10467,7 @@ const commonService = ({ strapi: strapi2 }) => ({
10389
10467
  });
10390
10468
  if (entities.length === changedEntries.count && changedEntries.count > 0) {
10391
10469
  const nestedTransactions = await Promise.all(
10392
- entities.map((item) => this.modifiedNestedNestedComments(item.id, fieldName, value))
10470
+ entities.map((item) => this.modifiedNestedNestedComments(item.id, fieldName, value, deepLimit - 1))
10393
10471
  );
10394
10472
  return nestedTransactions.length === changedEntries.count;
10395
10473
  }
@@ -10402,7 +10480,7 @@ const commonService = ({ strapi: strapi2 }) => ({
10402
10480
  const config2 = await this.getConfig(CONFIG_PARAMS.BAD_WORDS, true);
10403
10481
  if (config2) {
10404
10482
  if (content && noProfanity.isProfane({ testString: content })) {
10405
- throw new PluginError2(
10483
+ throw new PluginError$1(
10406
10484
  400,
10407
10485
  "Bad language used! Please polite your comment...",
10408
10486
  {
@@ -11502,7 +11580,7 @@ lodash_min.exports;
11502
11580
  if (bh(n2)) return c(n2, vu) + "";
11503
11581
  if (bc(n2)) return vs ? vs.call(n2) : "";
11504
11582
  var t2 = n2 + "";
11505
- return "0" == t2 && 1 / n2 == -Sn ? "-0" : t2;
11583
+ return "0" == t2 && 1 / n2 == -Infinity ? "-0" : t2;
11506
11584
  }
11507
11585
  function gu(n2, t2, r2) {
11508
11586
  var e2 = -1, u2 = o, i2 = n2.length, c2 = true, a2 = [], l2 = a2;
@@ -11821,7 +11899,7 @@ lodash_min.exports;
11821
11899
  }
11822
11900
  function oi(n2, t2, r2, e2, u2, i2, o2, f2, c2, a2) {
11823
11901
  var l2 = t2 & yn, s2 = l2 ? o2 : X, h2 = l2 ? X : o2, p3 = l2 ? i2 : X, _3 = l2 ? X : i2;
11824
- t2 |= l2 ? bn : wn, t2 &= ~(l2 ? wn : bn), t2 & gn || (t2 &= ~(_n | vn));
11902
+ t2 |= l2 ? bn : wn, t2 &= ~(l2 ? wn : bn), t2 & gn || (t2 &= -4);
11825
11903
  var v2 = [n2, t2, u2, p3, s2, _3, h2, f2, c2, a2], g2 = r2.apply(X, v2);
11826
11904
  return $i(n2) && Ss(g2, v2), g2.placeholder = e2, Yi(g2, n2, t2);
11827
11905
  }
@@ -11845,12 +11923,12 @@ lodash_min.exports;
11845
11923
  var c2 = t2 & vn;
11846
11924
  if (!c2 && "function" != typeof n2) throw new pl(en);
11847
11925
  var a2 = e2 ? e2.length : 0;
11848
- if (a2 || (t2 &= ~(bn | wn), e2 = u2 = X), o2 = o2 === X ? o2 : Gl(kc(o2), 0), f2 = f2 === X ? f2 : kc(f2), a2 -= u2 ? u2.length : 0, t2 & wn) {
11926
+ if (a2 || (t2 &= -97, e2 = u2 = X), o2 = o2 === X ? o2 : Gl(kc(o2), 0), f2 = f2 === X ? f2 : kc(f2), a2 -= u2 ? u2.length : 0, t2 & wn) {
11849
11927
  var l2 = e2, s2 = u2;
11850
11928
  e2 = u2 = X;
11851
11929
  }
11852
11930
  var h2 = c2 ? X : Os(n2), p3 = [n2, t2, r2, e2, u2, l2, s2, i2, o2, f2];
11853
- if (h2 && qi(p3, h2), n2 = p3[0], t2 = p3[1], r2 = p3[2], e2 = p3[3], u2 = p3[4], f2 = p3[9] = p3[9] === X ? c2 ? 0 : n2.length : Gl(p3[9] - a2, 0), !f2 && t2 & (yn | dn) && (t2 &= ~(yn | dn)), t2 && t2 != _n) _3 = t2 == yn || t2 == dn ? Hu(n2, t2, f2) : t2 != bn && t2 != (_n | bn) || u2.length ? Qu.apply(X, p3) : ei(n2, t2, r2, e2);
11931
+ if (h2 && qi(p3, h2), n2 = p3[0], t2 = p3[1], r2 = p3[2], e2 = p3[3], u2 = p3[4], f2 = p3[9] = p3[9] === X ? c2 ? 0 : n2.length : Gl(p3[9] - a2, 0), !f2 && t2 & (yn | dn) && (t2 &= -25), t2 && t2 != _n) _3 = t2 == yn || t2 == dn ? Hu(n2, t2, f2) : t2 != bn && t2 != (_n | bn) || u2.length ? Qu.apply(X, p3) : ei(n2, t2, r2, e2);
11854
11932
  else var _3 = Zu(n2, t2, r2);
11855
11933
  return Yi((h2 ? ms : Ss)(_3, p3), n2, t2);
11856
11934
  }
@@ -12189,7 +12267,7 @@ lodash_min.exports;
12189
12267
  function no(n2) {
12190
12268
  if ("string" == typeof n2 || bc(n2)) return n2;
12191
12269
  var t2 = n2 + "";
12192
- return "0" == t2 && 1 / n2 == -Sn ? "-0" : t2;
12270
+ return "0" == t2 && 1 / n2 == -Infinity ? "-0" : t2;
12193
12271
  }
12194
12272
  function to(n2) {
12195
12273
  if (null != n2) {
@@ -12753,7 +12831,7 @@ lodash_min.exports;
12753
12831
  return "function" == typeof r2 && r2 instanceof r2 && dl.call(r2) == jl;
12754
12832
  }
12755
12833
  function yc(n2) {
12756
- return ic(n2) && n2 >= -Wn && n2 <= Wn;
12834
+ return ic(n2) && n2 >= -9007199254740991 && n2 <= Wn;
12757
12835
  }
12758
12836
  function dc(n2) {
12759
12837
  return "string" == typeof n2 || !bh(n2) && cc(n2) && we(n2) == rt;
@@ -12779,7 +12857,7 @@ lodash_min.exports;
12779
12857
  }
12780
12858
  function Ac(n2) {
12781
12859
  if (!n2) return 0 === n2 ? n2 : 0;
12782
- if (n2 = Ic(n2), n2 === Sn || n2 === -Sn) {
12860
+ if (n2 = Ic(n2), n2 === Sn || n2 === -Infinity) {
12783
12861
  return (n2 < 0 ? -1 : 1) * Ln;
12784
12862
  }
12785
12863
  return n2 === n2 ? n2 : 0;
@@ -12807,7 +12885,7 @@ lodash_min.exports;
12807
12885
  return $u(n2, qc(n2));
12808
12886
  }
12809
12887
  function zc(n2) {
12810
- return n2 ? Mr2(kc(n2), -Wn, Wn) : 0 === n2 ? n2 : 0;
12888
+ return n2 ? Mr2(kc(n2), -9007199254740991, Wn) : 0 === n2 ? n2 : 0;
12811
12889
  }
12812
12890
  function Ec(n2) {
12813
12891
  return null == n2 ? "" : vu(n2);
@@ -14720,7 +14798,6 @@ class DynamicOutputPropertyDef {
14720
14798
  }
14721
14799
  withNexusSymbol(DynamicOutputPropertyDef, NexusTypes.DynamicOutputProperty);
14722
14800
  const virtualScalarAttributes = ["id"];
14723
- const customFields = ["filterBy", "filterByValue"];
14724
14801
  const addScalarAttribute = (builder, attributeName, attribute) => {
14725
14802
  const { naming, mappers } = strapi.plugin("graphql").service("utils");
14726
14803
  const gqlType = mappers.strapiScalarToGraphQLScalar(attribute.type);
@@ -14769,19 +14846,16 @@ const gqlService = ({ strapi: strapi2 }) => {
14769
14846
  }
14770
14847
  if (Array.isArray(queryFilters)) {
14771
14848
  return queryFilters.reduce((acc, filtersItem) => {
14772
- if (!customFields.includes(filtersItem)) {
14773
- acc.push(graphQLFiltersToStrapiQuery(filtersItem, contentType));
14774
- }
14849
+ acc.push(graphQLFiltersToStrapiQuery(filtersItem, contentType));
14775
14850
  return acc;
14776
- });
14851
+ }, []);
14777
14852
  }
14778
14853
  const resultMap = {};
14779
- const { filterBy, filterByValue, ...filters } = queryFilters;
14780
14854
  const { attributes } = contentType;
14781
14855
  const isAttribute = (attributeName) => {
14782
14856
  return virtualScalarAttributes.includes(attributeName) || fp.has(attributeName, attributes);
14783
14857
  };
14784
- for (const [key, value] of Object.entries(filters)) {
14858
+ for (const [key, value] of Object.entries(queryFilters)) {
14785
14859
  if (isAttribute(key)) {
14786
14860
  const attribute = attributes[key];
14787
14861
  if (virtualScalarAttributes.includes(key) || isStrapiScalar(attribute)) {
@@ -14803,23 +14877,6 @@ const gqlService = ({ strapi: strapi2 }) => {
14803
14877
  }
14804
14878
  }
14805
14879
  }
14806
- if (filterBy === "DATE_CREATED") {
14807
- const date = new Date(filterByValue);
14808
- if (!filterByValue || Number.isNaN(+date)) {
14809
- throw new Error('Invalid date specified in "filterByValue"');
14810
- }
14811
- const start = date.setHours(0, 0, 0, 0);
14812
- const end = date.setHours(23, 59, 59, 999);
14813
- resultMap.createdAt = {
14814
- $between: [start, end]
14815
- };
14816
- }
14817
- if (filterBy === "APPROVAL_STATUS") {
14818
- if (!filterByValue) {
14819
- throw new Error('Empty "filterByValue" parameter');
14820
- }
14821
- resultMap.approvalStatus = filterByValue;
14822
- }
14823
14880
  return resultMap;
14824
14881
  };
14825
14882
  return {
@@ -14851,9 +14908,6 @@ const gqlService = ({ strapi: strapi2 }) => {
14851
14908
  for (const operator of rootLevelOperators()) {
14852
14909
  operator.add(t, filtersTypeName);
14853
14910
  }
14854
- customFields.forEach((field) => {
14855
- t.field(field, { type: "String" });
14856
- });
14857
14911
  }
14858
14912
  });
14859
14913
  }