@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/browser.d.mts +89 -1
- package/dist/browser.d.ts +89 -1
- package/dist/browser.js +111 -0
- package/dist/browser.mjs +110 -0
- package/dist/node.d.mts +89 -1
- package/dist/node.d.ts +89 -1
- package/dist/node.js +111 -0
- package/dist/node.mjs +110 -0
- package/dist/universal.d.mts +89 -1
- package/dist/universal.d.ts +89 -1
- package/dist/universal.js +111 -0
- package/dist/universal.mjs +110 -0
- package/package.json +1 -1
package/dist/browser.d.mts
CHANGED
|
@@ -151,6 +151,51 @@ declare const _recursExtractBlocks: ({ data, cb, sectionStack, blockPathPrefix }
|
|
|
151
151
|
blockPathPrefix?: string;
|
|
152
152
|
}) => void;
|
|
153
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Calculates all possible rollup relationships for a tag type
|
|
156
|
+
*
|
|
157
|
+
* Rollups allow indirect filtering (e.g., filter stories by topic type where stories are tagged with topics)
|
|
158
|
+
*
|
|
159
|
+
* Returns two types of possibilities:
|
|
160
|
+
* 1. **valuePathType**: Direct field rollups within the tag (e.g., topics.main.category)
|
|
161
|
+
* 2. **tagType**: Nested tag chain rollups (e.g., topics → themes → categories)
|
|
162
|
+
*
|
|
163
|
+
* Performance optimizations:
|
|
164
|
+
* - Caches template blocks to avoid repeated extractAllBlocksFromTpl calls
|
|
165
|
+
* - Limits recursion depth to MAX_DEPTH_ROLLUP_POSSIBILITIES (10 levels)
|
|
166
|
+
*
|
|
167
|
+
* @param {Object} params - Parameters object
|
|
168
|
+
* @param {string} params.tagType - The tag type to find rollup possibilities for (e.g., 'topics', 'districts')
|
|
169
|
+
* @param {Array} params.allTpls - All templates in the system
|
|
170
|
+
*
|
|
171
|
+
* @returns {Array} Array of rollup possibilities
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* // Input:
|
|
175
|
+
* getRollupPossibilities({ tagType: 'topics', allTpls: [...] })
|
|
176
|
+
*
|
|
177
|
+
* // Output:
|
|
178
|
+
* [
|
|
179
|
+
* {
|
|
180
|
+
* rollupType: 'valuePathType',
|
|
181
|
+
* tagTypeCollectionToRollup: 'topics',
|
|
182
|
+
* valuePathInRolledUpCollection: 'main.category.value',
|
|
183
|
+
* filterSourceValuePath: 'main.category',
|
|
184
|
+
* blockValuePath: 'main.category',
|
|
185
|
+
* filterDisplay: 'Topic Category'
|
|
186
|
+
* },
|
|
187
|
+
* {
|
|
188
|
+
* rollupType: 'tagType',
|
|
189
|
+
* tagTypeCollectionToRollup: 'topics',
|
|
190
|
+
* rollupPath: ['topics', 'themes']
|
|
191
|
+
* }
|
|
192
|
+
* ]
|
|
193
|
+
*/
|
|
194
|
+
declare function getRollupPossibilities({ tagType, allTpls }: {
|
|
195
|
+
tagType: string;
|
|
196
|
+
allTpls: any[];
|
|
197
|
+
}): any[];
|
|
198
|
+
|
|
154
199
|
declare namespace BASE_BULLMQ_CONFIG {
|
|
155
200
|
namespace PLUGIN__MAD_USERS_SYNC_QUEUE {
|
|
156
201
|
let id: string;
|
|
@@ -479,6 +524,49 @@ declare namespace BASE_BULLMQ_CONFIG {
|
|
|
479
524
|
}
|
|
480
525
|
export { workerConfig_7 as workerConfig };
|
|
481
526
|
}
|
|
527
|
+
namespace CONTENT_ELASTIC_SYNC_QUEUE {
|
|
528
|
+
let id_8: string;
|
|
529
|
+
export { id_8 as id };
|
|
530
|
+
export namespace queueConfig_8 {
|
|
531
|
+
export namespace defaultJobOptions_8 {
|
|
532
|
+
let attempts_8: number;
|
|
533
|
+
export { attempts_8 as attempts };
|
|
534
|
+
export namespace backoff_8 {
|
|
535
|
+
let type_8: string;
|
|
536
|
+
export { type_8 as type };
|
|
537
|
+
let delay_8: number;
|
|
538
|
+
export { delay_8 as delay };
|
|
539
|
+
}
|
|
540
|
+
export { backoff_8 as backoff };
|
|
541
|
+
let removeOnComplete_8: number;
|
|
542
|
+
export { removeOnComplete_8 as removeOnComplete };
|
|
543
|
+
let removeOnFail_8: number;
|
|
544
|
+
export { removeOnFail_8 as removeOnFail };
|
|
545
|
+
}
|
|
546
|
+
export { defaultJobOptions_8 as defaultJobOptions };
|
|
547
|
+
export namespace streams_8 {
|
|
548
|
+
export namespace events_8 {
|
|
549
|
+
let maxLen_8: number;
|
|
550
|
+
export { maxLen_8 as maxLen };
|
|
551
|
+
}
|
|
552
|
+
export { events_8 as events };
|
|
553
|
+
}
|
|
554
|
+
export { streams_8 as streams };
|
|
555
|
+
}
|
|
556
|
+
export { queueConfig_8 as queueConfig };
|
|
557
|
+
export namespace workerConfig_8 {
|
|
558
|
+
let concurrency_8: number;
|
|
559
|
+
export { concurrency_8 as concurrency };
|
|
560
|
+
export namespace limiter_8 {
|
|
561
|
+
let max_8: number;
|
|
562
|
+
export { max_8 as max };
|
|
563
|
+
let duration_8: number;
|
|
564
|
+
export { duration_8 as duration };
|
|
565
|
+
}
|
|
566
|
+
export { limiter_8 as limiter };
|
|
567
|
+
}
|
|
568
|
+
export { workerConfig_8 as workerConfig };
|
|
569
|
+
}
|
|
482
570
|
}
|
|
483
571
|
|
|
484
572
|
interface PlatformContextContentItem {
|
|
@@ -498,4 +586,4 @@ interface GetPlatformContextContentParams {
|
|
|
498
586
|
}
|
|
499
587
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
500
588
|
|
|
501
|
-
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getVal, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray };
|
|
589
|
+
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray };
|
package/dist/browser.d.ts
CHANGED
|
@@ -151,6 +151,51 @@ declare const _recursExtractBlocks: ({ data, cb, sectionStack, blockPathPrefix }
|
|
|
151
151
|
blockPathPrefix?: string;
|
|
152
152
|
}) => void;
|
|
153
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Calculates all possible rollup relationships for a tag type
|
|
156
|
+
*
|
|
157
|
+
* Rollups allow indirect filtering (e.g., filter stories by topic type where stories are tagged with topics)
|
|
158
|
+
*
|
|
159
|
+
* Returns two types of possibilities:
|
|
160
|
+
* 1. **valuePathType**: Direct field rollups within the tag (e.g., topics.main.category)
|
|
161
|
+
* 2. **tagType**: Nested tag chain rollups (e.g., topics → themes → categories)
|
|
162
|
+
*
|
|
163
|
+
* Performance optimizations:
|
|
164
|
+
* - Caches template blocks to avoid repeated extractAllBlocksFromTpl calls
|
|
165
|
+
* - Limits recursion depth to MAX_DEPTH_ROLLUP_POSSIBILITIES (10 levels)
|
|
166
|
+
*
|
|
167
|
+
* @param {Object} params - Parameters object
|
|
168
|
+
* @param {string} params.tagType - The tag type to find rollup possibilities for (e.g., 'topics', 'districts')
|
|
169
|
+
* @param {Array} params.allTpls - All templates in the system
|
|
170
|
+
*
|
|
171
|
+
* @returns {Array} Array of rollup possibilities
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* // Input:
|
|
175
|
+
* getRollupPossibilities({ tagType: 'topics', allTpls: [...] })
|
|
176
|
+
*
|
|
177
|
+
* // Output:
|
|
178
|
+
* [
|
|
179
|
+
* {
|
|
180
|
+
* rollupType: 'valuePathType',
|
|
181
|
+
* tagTypeCollectionToRollup: 'topics',
|
|
182
|
+
* valuePathInRolledUpCollection: 'main.category.value',
|
|
183
|
+
* filterSourceValuePath: 'main.category',
|
|
184
|
+
* blockValuePath: 'main.category',
|
|
185
|
+
* filterDisplay: 'Topic Category'
|
|
186
|
+
* },
|
|
187
|
+
* {
|
|
188
|
+
* rollupType: 'tagType',
|
|
189
|
+
* tagTypeCollectionToRollup: 'topics',
|
|
190
|
+
* rollupPath: ['topics', 'themes']
|
|
191
|
+
* }
|
|
192
|
+
* ]
|
|
193
|
+
*/
|
|
194
|
+
declare function getRollupPossibilities({ tagType, allTpls }: {
|
|
195
|
+
tagType: string;
|
|
196
|
+
allTpls: any[];
|
|
197
|
+
}): any[];
|
|
198
|
+
|
|
154
199
|
declare namespace BASE_BULLMQ_CONFIG {
|
|
155
200
|
namespace PLUGIN__MAD_USERS_SYNC_QUEUE {
|
|
156
201
|
let id: string;
|
|
@@ -479,6 +524,49 @@ declare namespace BASE_BULLMQ_CONFIG {
|
|
|
479
524
|
}
|
|
480
525
|
export { workerConfig_7 as workerConfig };
|
|
481
526
|
}
|
|
527
|
+
namespace CONTENT_ELASTIC_SYNC_QUEUE {
|
|
528
|
+
let id_8: string;
|
|
529
|
+
export { id_8 as id };
|
|
530
|
+
export namespace queueConfig_8 {
|
|
531
|
+
export namespace defaultJobOptions_8 {
|
|
532
|
+
let attempts_8: number;
|
|
533
|
+
export { attempts_8 as attempts };
|
|
534
|
+
export namespace backoff_8 {
|
|
535
|
+
let type_8: string;
|
|
536
|
+
export { type_8 as type };
|
|
537
|
+
let delay_8: number;
|
|
538
|
+
export { delay_8 as delay };
|
|
539
|
+
}
|
|
540
|
+
export { backoff_8 as backoff };
|
|
541
|
+
let removeOnComplete_8: number;
|
|
542
|
+
export { removeOnComplete_8 as removeOnComplete };
|
|
543
|
+
let removeOnFail_8: number;
|
|
544
|
+
export { removeOnFail_8 as removeOnFail };
|
|
545
|
+
}
|
|
546
|
+
export { defaultJobOptions_8 as defaultJobOptions };
|
|
547
|
+
export namespace streams_8 {
|
|
548
|
+
export namespace events_8 {
|
|
549
|
+
let maxLen_8: number;
|
|
550
|
+
export { maxLen_8 as maxLen };
|
|
551
|
+
}
|
|
552
|
+
export { events_8 as events };
|
|
553
|
+
}
|
|
554
|
+
export { streams_8 as streams };
|
|
555
|
+
}
|
|
556
|
+
export { queueConfig_8 as queueConfig };
|
|
557
|
+
export namespace workerConfig_8 {
|
|
558
|
+
let concurrency_8: number;
|
|
559
|
+
export { concurrency_8 as concurrency };
|
|
560
|
+
export namespace limiter_8 {
|
|
561
|
+
let max_8: number;
|
|
562
|
+
export { max_8 as max };
|
|
563
|
+
let duration_8: number;
|
|
564
|
+
export { duration_8 as duration };
|
|
565
|
+
}
|
|
566
|
+
export { limiter_8 as limiter };
|
|
567
|
+
}
|
|
568
|
+
export { workerConfig_8 as workerConfig };
|
|
569
|
+
}
|
|
482
570
|
}
|
|
483
571
|
|
|
484
572
|
interface PlatformContextContentItem {
|
|
@@ -498,4 +586,4 @@ interface GetPlatformContextContentParams {
|
|
|
498
586
|
}
|
|
499
587
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
500
588
|
|
|
501
|
-
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getVal, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray };
|
|
589
|
+
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray };
|
package/dist/browser.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(browser_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,
|
package/dist/browser.mjs
CHANGED
|
@@ -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/dist/node.d.mts
CHANGED
|
@@ -158,6 +158,51 @@ declare const _recursExtractBlocks: ({ data, cb, sectionStack, blockPathPrefix }
|
|
|
158
158
|
blockPathPrefix?: string;
|
|
159
159
|
}) => void;
|
|
160
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Calculates all possible rollup relationships for a tag type
|
|
163
|
+
*
|
|
164
|
+
* Rollups allow indirect filtering (e.g., filter stories by topic type where stories are tagged with topics)
|
|
165
|
+
*
|
|
166
|
+
* Returns two types of possibilities:
|
|
167
|
+
* 1. **valuePathType**: Direct field rollups within the tag (e.g., topics.main.category)
|
|
168
|
+
* 2. **tagType**: Nested tag chain rollups (e.g., topics → themes → categories)
|
|
169
|
+
*
|
|
170
|
+
* Performance optimizations:
|
|
171
|
+
* - Caches template blocks to avoid repeated extractAllBlocksFromTpl calls
|
|
172
|
+
* - Limits recursion depth to MAX_DEPTH_ROLLUP_POSSIBILITIES (10 levels)
|
|
173
|
+
*
|
|
174
|
+
* @param {Object} params - Parameters object
|
|
175
|
+
* @param {string} params.tagType - The tag type to find rollup possibilities for (e.g., 'topics', 'districts')
|
|
176
|
+
* @param {Array} params.allTpls - All templates in the system
|
|
177
|
+
*
|
|
178
|
+
* @returns {Array} Array of rollup possibilities
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* // Input:
|
|
182
|
+
* getRollupPossibilities({ tagType: 'topics', allTpls: [...] })
|
|
183
|
+
*
|
|
184
|
+
* // Output:
|
|
185
|
+
* [
|
|
186
|
+
* {
|
|
187
|
+
* rollupType: 'valuePathType',
|
|
188
|
+
* tagTypeCollectionToRollup: 'topics',
|
|
189
|
+
* valuePathInRolledUpCollection: 'main.category.value',
|
|
190
|
+
* filterSourceValuePath: 'main.category',
|
|
191
|
+
* blockValuePath: 'main.category',
|
|
192
|
+
* filterDisplay: 'Topic Category'
|
|
193
|
+
* },
|
|
194
|
+
* {
|
|
195
|
+
* rollupType: 'tagType',
|
|
196
|
+
* tagTypeCollectionToRollup: 'topics',
|
|
197
|
+
* rollupPath: ['topics', 'themes']
|
|
198
|
+
* }
|
|
199
|
+
* ]
|
|
200
|
+
*/
|
|
201
|
+
declare function getRollupPossibilities({ tagType, allTpls }: {
|
|
202
|
+
tagType: string;
|
|
203
|
+
allTpls: any[];
|
|
204
|
+
}): any[];
|
|
205
|
+
|
|
161
206
|
declare namespace BASE_BULLMQ_CONFIG {
|
|
162
207
|
namespace PLUGIN__MAD_USERS_SYNC_QUEUE {
|
|
163
208
|
let id: string;
|
|
@@ -486,6 +531,49 @@ declare namespace BASE_BULLMQ_CONFIG {
|
|
|
486
531
|
}
|
|
487
532
|
export { workerConfig_7 as workerConfig };
|
|
488
533
|
}
|
|
534
|
+
namespace CONTENT_ELASTIC_SYNC_QUEUE {
|
|
535
|
+
let id_8: string;
|
|
536
|
+
export { id_8 as id };
|
|
537
|
+
export namespace queueConfig_8 {
|
|
538
|
+
export namespace defaultJobOptions_8 {
|
|
539
|
+
let attempts_8: number;
|
|
540
|
+
export { attempts_8 as attempts };
|
|
541
|
+
export namespace backoff_8 {
|
|
542
|
+
let type_8: string;
|
|
543
|
+
export { type_8 as type };
|
|
544
|
+
let delay_8: number;
|
|
545
|
+
export { delay_8 as delay };
|
|
546
|
+
}
|
|
547
|
+
export { backoff_8 as backoff };
|
|
548
|
+
let removeOnComplete_8: number;
|
|
549
|
+
export { removeOnComplete_8 as removeOnComplete };
|
|
550
|
+
let removeOnFail_8: number;
|
|
551
|
+
export { removeOnFail_8 as removeOnFail };
|
|
552
|
+
}
|
|
553
|
+
export { defaultJobOptions_8 as defaultJobOptions };
|
|
554
|
+
export namespace streams_8 {
|
|
555
|
+
export namespace events_8 {
|
|
556
|
+
let maxLen_8: number;
|
|
557
|
+
export { maxLen_8 as maxLen };
|
|
558
|
+
}
|
|
559
|
+
export { events_8 as events };
|
|
560
|
+
}
|
|
561
|
+
export { streams_8 as streams };
|
|
562
|
+
}
|
|
563
|
+
export { queueConfig_8 as queueConfig };
|
|
564
|
+
export namespace workerConfig_8 {
|
|
565
|
+
let concurrency_8: number;
|
|
566
|
+
export { concurrency_8 as concurrency };
|
|
567
|
+
export namespace limiter_8 {
|
|
568
|
+
let max_8: number;
|
|
569
|
+
export { max_8 as max };
|
|
570
|
+
let duration_8: number;
|
|
571
|
+
export { duration_8 as duration };
|
|
572
|
+
}
|
|
573
|
+
export { limiter_8 as limiter };
|
|
574
|
+
}
|
|
575
|
+
export { workerConfig_8 as workerConfig };
|
|
576
|
+
}
|
|
489
577
|
}
|
|
490
578
|
|
|
491
579
|
interface PlatformContextContentItem {
|
|
@@ -1030,4 +1118,4 @@ declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
|
|
|
1030
1118
|
};
|
|
1031
1119
|
}): Object;
|
|
1032
1120
|
|
|
1033
|
-
export { AIChatSchema, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, ElasticSearchConnector, GET_GLOBAL_BULLMQ_CONFIG, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, TplSchema, WorkerManager, deleteVal, extractAllBlocksFromTpl, genTagId, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getTplModelByTenant, getVal, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray };
|
|
1121
|
+
export { AIChatSchema, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, ElasticSearchConnector, GET_GLOBAL_BULLMQ_CONFIG, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, TplSchema, WorkerManager, deleteVal, extractAllBlocksFromTpl, genTagId, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getTplModelByTenant, getVal, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray };
|