@okf/ootils 1.6.13 → 1.7.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.
package/dist/universal.js CHANGED
@@ -25,6 +25,7 @@ __export(universal_exports, {
25
25
  extractAllBlocksFromTpl: () => extractAllBlocksFromTpl,
26
26
  genTagId: () => genTagId,
27
27
  getPlatformContextContent: () => getPlatformContextContent,
28
+ getRollupPossibilities: () => getRollupPossibilities,
28
29
  getVal: () => getVal,
29
30
  recursivelyExtractBlocks: () => _recursExtractBlocks,
30
31
  setVal: () => setVal,
@@ -307,6 +308,85 @@ var _extractBlocksFromSomeBuilders = ({
307
308
  }
308
309
  };
309
310
 
311
+ // src/utils/getRollupPossibilities.ts
312
+ var MAX_DEPTH_ROLLUP_POSSIBILITIES = 10;
313
+ function getRollupPossibilities({
314
+ tagType,
315
+ allTpls
316
+ }) {
317
+ const thisTagTpl = allTpls.find((d) => d.kp_content_type === tagType);
318
+ if (!thisTagTpl) return [];
319
+ const allBlocks = extractAllBlocksFromTpl({ tpl: thisTagTpl });
320
+ const templateBlocksCache = /* @__PURE__ */ new Map();
321
+ const getCachedTemplateBlocks = (templateTagType) => {
322
+ if (!templateBlocksCache.has(templateTagType)) {
323
+ const template = allTpls.find((d) => d.kp_content_type === templateTagType);
324
+ if (template) {
325
+ templateBlocksCache.set(templateTagType, extractAllBlocksFromTpl({ tpl: template }));
326
+ } else {
327
+ templateBlocksCache.set(templateTagType, []);
328
+ }
329
+ }
330
+ return templateBlocksCache.get(templateTagType);
331
+ };
332
+ const findTagChains = (startTagType, visited = [], maxDepth = 10) => {
333
+ if (visited.includes(startTagType) || visited.length >= maxDepth) {
334
+ return [];
335
+ }
336
+ const tagBlocks = getCachedTemplateBlocks(startTagType).filter(
337
+ (block) => block.valuePath?.startsWith("tags.")
338
+ );
339
+ const chains = [];
340
+ for (const block of tagBlocks) {
341
+ const nextTagType = block.props?.tagType;
342
+ if (nextTagType) {
343
+ chains.push({
344
+ rollupType: "tagType",
345
+ tagTypeCollectionToRollup: tagType,
346
+ rollupPath: [...visited, startTagType, nextTagType]
347
+ });
348
+ if (visited.length < maxDepth - 1) {
349
+ const nextChains = findTagChains(
350
+ nextTagType,
351
+ [...visited, startTagType],
352
+ maxDepth
353
+ );
354
+ chains.push(...nextChains);
355
+ }
356
+ }
357
+ }
358
+ return chains;
359
+ };
360
+ const singleLevelValuePathRollups = allBlocks.map((block) => {
361
+ if (block.props?.options?.length > 0) {
362
+ return {
363
+ rollupType: "valuePathType",
364
+ tagTypeCollectionToRollup: tagType,
365
+ // Handle both string values and object values (with .value accessor)
366
+ valuePathInRolledUpCollection: block.props?.saveValueAsString ? block.valuePath : `${block.valuePath}.value`,
367
+ filterSourceValuePath: block.valuePath,
368
+ blockValuePath: block.valuePath,
369
+ filterDisplay: block.props?.shortLabel || block.props?.label || block.valuePath
370
+ };
371
+ }
372
+ return void 0;
373
+ }).filter(Boolean);
374
+ const nestedTagRollups = allBlocks.filter((block) => block.valuePath?.startsWith("tags.")).flatMap((block) => {
375
+ const directChain = {
376
+ rollupType: "tagType",
377
+ tagTypeCollectionToRollup: tagType,
378
+ rollupPath: [tagType, block.props.tagType]
379
+ };
380
+ const deeperChains = findTagChains(
381
+ block.props?.tagType,
382
+ [tagType],
383
+ MAX_DEPTH_ROLLUP_POSSIBILITIES
384
+ );
385
+ return [directChain, ...deeperChains];
386
+ });
387
+ return [...singleLevelValuePathRollups, ...nestedTagRollups];
388
+ }
389
+
310
390
  // src/bullmq/GLOBAL_BULLMQ_CONFIG.js
311
391
  var BASE_BULLMQ_CONFIG = {
312
392
  PLUGIN__MAD_USERS_SYNC_QUEUE: {
@@ -450,6 +530,7 @@ var BASE_BULLMQ_CONFIG = {
450
530
  },
451
531
  workerConfig: {
452
532
  concurrency: 1,
533
+ // Cannot mess with this else duplicate options in tpl, maybe even duplicate tags
453
534
  limiter: {
454
535
  max: 20,
455
536
  // Max 5 jobs per...
@@ -544,6 +625,35 @@ var BASE_BULLMQ_CONFIG = {
544
625
  // ...60 seconds (higher throughput for chunking)
545
626
  }
546
627
  }
628
+ },
629
+ CONTENT_ELASTIC_SYNC_QUEUE: {
630
+ id: "content-elastic-sync-queue",
631
+ queueConfig: {
632
+ defaultJobOptions: {
633
+ attempts: 3,
634
+ backoff: {
635
+ type: "exponential",
636
+ delay: 2e3
637
+ },
638
+ removeOnComplete: 30,
639
+ removeOnFail: 100
640
+ },
641
+ streams: {
642
+ events: {
643
+ maxLen: 10
644
+ // Keep very low, cuz we dont really use historical stream events as of now
645
+ }
646
+ }
647
+ },
648
+ workerConfig: {
649
+ concurrency: 5,
650
+ limiter: {
651
+ max: 200,
652
+ // (lets always keep this same as content enhance & embed since it comes immediately after)
653
+ duration: 6e4
654
+ // ...60 seconds (higher throughput for chunking)
655
+ }
656
+ }
547
657
  }
548
658
  };
549
659
 
@@ -577,6 +687,7 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
577
687
  extractAllBlocksFromTpl,
578
688
  genTagId,
579
689
  getPlatformContextContent,
690
+ getRollupPossibilities,
580
691
  getVal,
581
692
  recursivelyExtractBlocks,
582
693
  setVal,
@@ -273,6 +273,85 @@ var _extractBlocksFromSomeBuilders = ({
273
273
  }
274
274
  };
275
275
 
276
+ // src/utils/getRollupPossibilities.ts
277
+ var MAX_DEPTH_ROLLUP_POSSIBILITIES = 10;
278
+ function getRollupPossibilities({
279
+ tagType,
280
+ allTpls
281
+ }) {
282
+ const thisTagTpl = allTpls.find((d) => d.kp_content_type === tagType);
283
+ if (!thisTagTpl) return [];
284
+ const allBlocks = extractAllBlocksFromTpl({ tpl: thisTagTpl });
285
+ const templateBlocksCache = /* @__PURE__ */ new Map();
286
+ const getCachedTemplateBlocks = (templateTagType) => {
287
+ if (!templateBlocksCache.has(templateTagType)) {
288
+ const template = allTpls.find((d) => d.kp_content_type === templateTagType);
289
+ if (template) {
290
+ templateBlocksCache.set(templateTagType, extractAllBlocksFromTpl({ tpl: template }));
291
+ } else {
292
+ templateBlocksCache.set(templateTagType, []);
293
+ }
294
+ }
295
+ return templateBlocksCache.get(templateTagType);
296
+ };
297
+ const findTagChains = (startTagType, visited = [], maxDepth = 10) => {
298
+ if (visited.includes(startTagType) || visited.length >= maxDepth) {
299
+ return [];
300
+ }
301
+ const tagBlocks = getCachedTemplateBlocks(startTagType).filter(
302
+ (block) => block.valuePath?.startsWith("tags.")
303
+ );
304
+ const chains = [];
305
+ for (const block of tagBlocks) {
306
+ const nextTagType = block.props?.tagType;
307
+ if (nextTagType) {
308
+ chains.push({
309
+ rollupType: "tagType",
310
+ tagTypeCollectionToRollup: tagType,
311
+ rollupPath: [...visited, startTagType, nextTagType]
312
+ });
313
+ if (visited.length < maxDepth - 1) {
314
+ const nextChains = findTagChains(
315
+ nextTagType,
316
+ [...visited, startTagType],
317
+ maxDepth
318
+ );
319
+ chains.push(...nextChains);
320
+ }
321
+ }
322
+ }
323
+ return chains;
324
+ };
325
+ const singleLevelValuePathRollups = allBlocks.map((block) => {
326
+ if (block.props?.options?.length > 0) {
327
+ return {
328
+ rollupType: "valuePathType",
329
+ tagTypeCollectionToRollup: tagType,
330
+ // Handle both string values and object values (with .value accessor)
331
+ valuePathInRolledUpCollection: block.props?.saveValueAsString ? block.valuePath : `${block.valuePath}.value`,
332
+ filterSourceValuePath: block.valuePath,
333
+ blockValuePath: block.valuePath,
334
+ filterDisplay: block.props?.shortLabel || block.props?.label || block.valuePath
335
+ };
336
+ }
337
+ return void 0;
338
+ }).filter(Boolean);
339
+ const nestedTagRollups = allBlocks.filter((block) => block.valuePath?.startsWith("tags.")).flatMap((block) => {
340
+ const directChain = {
341
+ rollupType: "tagType",
342
+ tagTypeCollectionToRollup: tagType,
343
+ rollupPath: [tagType, block.props.tagType]
344
+ };
345
+ const deeperChains = findTagChains(
346
+ block.props?.tagType,
347
+ [tagType],
348
+ MAX_DEPTH_ROLLUP_POSSIBILITIES
349
+ );
350
+ return [directChain, ...deeperChains];
351
+ });
352
+ return [...singleLevelValuePathRollups, ...nestedTagRollups];
353
+ }
354
+
276
355
  // src/bullmq/GLOBAL_BULLMQ_CONFIG.js
277
356
  var BASE_BULLMQ_CONFIG = {
278
357
  PLUGIN__MAD_USERS_SYNC_QUEUE: {
@@ -416,6 +495,7 @@ var BASE_BULLMQ_CONFIG = {
416
495
  },
417
496
  workerConfig: {
418
497
  concurrency: 1,
498
+ // Cannot mess with this else duplicate options in tpl, maybe even duplicate tags
419
499
  limiter: {
420
500
  max: 20,
421
501
  // Max 5 jobs per...
@@ -510,6 +590,35 @@ var BASE_BULLMQ_CONFIG = {
510
590
  // ...60 seconds (higher throughput for chunking)
511
591
  }
512
592
  }
593
+ },
594
+ CONTENT_ELASTIC_SYNC_QUEUE: {
595
+ id: "content-elastic-sync-queue",
596
+ queueConfig: {
597
+ defaultJobOptions: {
598
+ attempts: 3,
599
+ backoff: {
600
+ type: "exponential",
601
+ delay: 2e3
602
+ },
603
+ removeOnComplete: 30,
604
+ removeOnFail: 100
605
+ },
606
+ streams: {
607
+ events: {
608
+ maxLen: 10
609
+ // Keep very low, cuz we dont really use historical stream events as of now
610
+ }
611
+ }
612
+ },
613
+ workerConfig: {
614
+ concurrency: 5,
615
+ limiter: {
616
+ max: 200,
617
+ // (lets always keep this same as content enhance & embed since it comes immediately after)
618
+ duration: 6e4
619
+ // ...60 seconds (higher throughput for chunking)
620
+ }
621
+ }
513
622
  }
514
623
  };
515
624
 
@@ -542,6 +651,7 @@ export {
542
651
  extractAllBlocksFromTpl,
543
652
  genTagId,
544
653
  getPlatformContextContent,
654
+ getRollupPossibilities,
545
655
  getVal,
546
656
  _recursExtractBlocks as recursivelyExtractBlocks,
547
657
  setVal,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.6.13",
6
+ "version": "1.7.0",
7
7
  "description": "Utility functions for both browser and Node.js",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.mjs",