@futdevpro/nts-dynamo 1.14.43 → 1.14.45

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 (40) hide show
  1. package/build/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.d.ts.map +1 -1
  2. package/build/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.js +6 -0
  3. package/build/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.js.map +1 -1
  4. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.d.ts.map +1 -1
  5. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.js +2 -0
  6. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.js.map +1 -1
  7. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.d.ts.map +1 -1
  8. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.js +2 -0
  9. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.js.map +1 -1
  10. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.d.ts.map +1 -1
  11. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.js +2 -0
  12. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.js.map +1 -1
  13. package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-chunk-data.service.js +4 -4
  14. package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-chunk-data.service.js.map +1 -1
  15. package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.d.ts.map +1 -1
  16. package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.js +7 -2
  17. package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.js.map +1 -1
  18. package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.d.ts +2 -1
  19. package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.d.ts.map +1 -1
  20. package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.js +18 -1
  21. package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.js.map +1 -1
  22. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js +3 -3
  23. package/build/_modules/discord-bot/_collections/dibo-operations.util.d.ts +1 -0
  24. package/build/_modules/discord-bot/_collections/dibo-operations.util.d.ts.map +1 -1
  25. package/build/_modules/discord-bot/_collections/dibo-operations.util.js +18 -1
  26. package/build/_modules/discord-bot/_collections/dibo-operations.util.js.map +1 -1
  27. package/build/_services/base/data.service.d.ts.map +1 -1
  28. package/build/_services/base/data.service.js +25 -1
  29. package/build/_services/base/data.service.js.map +1 -1
  30. package/package.json +4 -4
  31. package/src/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.ts +6 -0
  32. package/src/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.ts +3 -1
  33. package/src/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.ts +2 -0
  34. package/src/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.ts +2 -0
  35. package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-chunk-data.service.ts +4 -4
  36. package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.ts +6 -1
  37. package/src/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.ts +24 -1
  38. package/src/_modules/discord-assistant/_services/dias-chunk.data-service.ts +3 -3
  39. package/src/_modules/discord-bot/_collections/dibo-operations.util.ts +24 -1
  40. package/src/_services/base/data.service.ts +30 -1
@@ -88,7 +88,7 @@ export class DyNTS_DiBo_Operations_Util {
88
88
  ): Promise<Collection<string, GuildMember>> {
89
89
  const channel = this.findChannelByName(guild.channels, channelName)
90
90
 
91
- const members = await guild?.members.fetch()
91
+ const members = await this.fetchMembersInGuild(guild)
92
92
 
93
93
  const allowedMembers = members?.filter((member) =>
94
94
  channel.permissionsFor(member)?.has('ViewChannel')
@@ -97,6 +97,29 @@ export class DyNTS_DiBo_Operations_Util {
97
97
  return allowedMembers
98
98
  }
99
99
 
100
+ static async fetchMembersInGuild(guild: Guild): Promise<Collection<string, GuildMember>> {
101
+ // First try to use the cache, because the fetch() can timeout for large guilds
102
+ let members: Collection<string, GuildMember> = guild?.members.cache
103
+
104
+ // If the cache is empty or does not contain all the necessary members, try to fetch them
105
+ if (!members || members.size === 0) {
106
+ try {
107
+ // Try to fetch with a limit to avoid timeout
108
+ members = await guild?.members.fetch({ limit: 1000 })
109
+ } catch (fetchError: any) {
110
+ // If the fetch times out, use the cache (even if it is empty)
111
+ DyFM_Log.warn(
112
+ 'Failed to fetch members, using cache instead',
113
+ fetchError?.message || fetchError
114
+ )
115
+
116
+ members = guild?.members.cache || new Collection<string, GuildMember>()
117
+ }
118
+ }
119
+
120
+ return members;
121
+ }
122
+
100
123
  static async readMemberNamesInChannel(guild: Guild, channelName: string): Promise<string[]> {
101
124
  const members = await this.readMembersInChannel(guild, channelName)
102
125
 
@@ -1242,11 +1242,35 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
1242
1242
  });
1243
1243
  }
1244
1244
 
1245
+ const errors: DyFM_Error[] = [];
1246
+
1245
1247
  Object.values(properties).forEach(
1246
1248
  (propertyParams: DyFM_DataProperty_Params<any, T>) => {
1247
- this.validateProperty(data, data[propertyParams.key], propertyParams, isSubObjectOf);
1249
+ try {
1250
+ this.validateProperty(data, data[propertyParams.key], propertyParams, isSubObjectOf);
1251
+ } catch (error) {
1252
+ errors.push(error);
1253
+ }
1248
1254
  }
1249
1255
  );
1256
+
1257
+ if (errors.length > 0) {
1258
+ if (errors.length === 1) {
1259
+ throw errors[0];
1260
+ } else {
1261
+ throw new DyFM_Error({
1262
+ ...this._getDefaultErrorSettings(
1263
+ 'validateByPropertyParams',
1264
+ new Error(
1265
+ 'Validation failed! (multiple validation errors)' +
1266
+ errors.map((error: DyFM_Error) => `\n ${DyFM_Error.getAnyMessage(error)}`).join('')
1267
+ )
1268
+ ),
1269
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-DS0-VDP3`,
1270
+ errors: errors,
1271
+ });
1272
+ }
1273
+ }
1250
1274
  } catch (error) {
1251
1275
  if (error?.errorCode?.includes?.('DyNTS-DS0-VDP')) {
1252
1276
  throw error;
@@ -1390,6 +1414,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
1390
1414
  'validateProperty',
1391
1415
  new Error(
1392
1416
  `validateProperty failed, "${this.getPropertyKey(propertyParams, isSubObjectOf)}" is not a valid string! ` +
1417
+ `(type: ${typeof propertyValue}, value: "${propertyValue}") ` +
1393
1418
  `(${this.dataParams.dataName})` +
1394
1419
  ((data as any)?.name ? `\n The failed data's name: ${(data as any).name}` : '')
1395
1420
  )
@@ -1413,6 +1438,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
1413
1438
  'validateProperty',
1414
1439
  new Error(
1415
1440
  `validateProperty failed, "${this.getPropertyKey(propertyParams, isSubObjectOf)}" is not a valid boolean! ` +
1441
+ `(type: ${typeof propertyValue}, value: "${propertyValue}") ` +
1416
1442
  `(${this.dataParams.dataName})` +
1417
1443
  ((data as any)?.name ? `\n The failed data's name: ${(data as any).name}` : '')
1418
1444
  )
@@ -1433,6 +1459,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
1433
1459
  'validateProperty',
1434
1460
  new Error(
1435
1461
  `validateProperty failed, "${this.getPropertyKey(propertyParams, isSubObjectOf)}" is not a valid object! ` +
1462
+ `(type: ${typeof propertyValue}, value: "${propertyValue}") ` +
1436
1463
  `(${this.dataParams.dataName})` +
1437
1464
  (data as any)?.name ? `\n That failed data's name: ${(data as any).name}` : ''
1438
1465
  )
@@ -1457,6 +1484,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
1457
1484
  'validateProperty',
1458
1485
  new Error(
1459
1486
  `validateProperty failed, "${this.getPropertyKey(propertyParams, isSubObjectOf)}" is not a valid array! ` +
1487
+ `(type: ${typeof propertyValue}, value: "${propertyValue}") ` +
1460
1488
  `(${this.dataParams.dataName})` +
1461
1489
  ((data as any)?.name ? `\n The failed data's name: ${(data as any).name}` : '')
1462
1490
  )
@@ -1507,6 +1535,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
1507
1535
  new Error(
1508
1536
  `validateProperty failed, "${this.getPropertyKey(propertyParams, isSubObjectOf)}" is not a valid property type! ` +
1509
1537
  `(type: ${propertyParams.type}, nonBasicType: ${propertyParams.nonBasicType}) ` +
1538
+ `(value type: ${typeof propertyValue}, value: "${propertyValue}") ` +
1510
1539
  `(${this.dataParams.dataName})` +
1511
1540
  ((data as any)?.name ? `\n The failed data's name: ${(data as any).name}` : '')
1512
1541
  )