@okf/ootils 1.8.3 → 1.8.5
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 +22 -1
- package/dist/browser.d.ts +22 -1
- package/dist/browser.js +36 -0
- package/dist/browser.mjs +35 -0
- package/dist/node.d.mts +28 -3
- package/dist/node.d.ts +28 -3
- package/dist/node.js +52 -7
- package/dist/node.mjs +51 -7
- package/dist/universal.d.mts +22 -1
- package/dist/universal.d.ts +22 -1
- package/dist/universal.js +36 -0
- package/dist/universal.mjs +35 -0
- package/package.json +1 -1
package/dist/browser.d.mts
CHANGED
|
@@ -58,6 +58,27 @@ declare const genTagId: (tagName: TagNameInput) => string;
|
|
|
58
58
|
*/
|
|
59
59
|
declare const toArray: <T>(property: T | T[] | null | undefined | false | 0) => T[];
|
|
60
60
|
|
|
61
|
+
interface SegrigateDocsOptions {
|
|
62
|
+
skipUndefined?: boolean;
|
|
63
|
+
idPath?: string;
|
|
64
|
+
titlePath?: string;
|
|
65
|
+
aryKey?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Groups an array of documents by a specified property path
|
|
69
|
+
*
|
|
70
|
+
* @param docs - Array of documents to group
|
|
71
|
+
* @param sortByPath - Dot-separated path to group by (e.g., "user.id")
|
|
72
|
+
* @param options - Optional configuration
|
|
73
|
+
* @returns Object with grouped documents
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Basic usage
|
|
77
|
+
* segrigateDocs(users, "department")
|
|
78
|
+
* // Returns: { "Engineering": [...], "Marketing": [...] }
|
|
79
|
+
*/
|
|
80
|
+
declare const segrigateDocs: (docs: any[], sortByPath: string, options?: SegrigateDocsOptions) => Record<string, any>;
|
|
81
|
+
|
|
61
82
|
interface Block {
|
|
62
83
|
[key: string]: any;
|
|
63
84
|
comp?: string;
|
|
@@ -629,4 +650,4 @@ interface GetPlatformContextContentParams {
|
|
|
629
650
|
}
|
|
630
651
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
631
652
|
|
|
632
|
-
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray };
|
|
653
|
+
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/browser.d.ts
CHANGED
|
@@ -58,6 +58,27 @@ declare const genTagId: (tagName: TagNameInput) => string;
|
|
|
58
58
|
*/
|
|
59
59
|
declare const toArray: <T>(property: T | T[] | null | undefined | false | 0) => T[];
|
|
60
60
|
|
|
61
|
+
interface SegrigateDocsOptions {
|
|
62
|
+
skipUndefined?: boolean;
|
|
63
|
+
idPath?: string;
|
|
64
|
+
titlePath?: string;
|
|
65
|
+
aryKey?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Groups an array of documents by a specified property path
|
|
69
|
+
*
|
|
70
|
+
* @param docs - Array of documents to group
|
|
71
|
+
* @param sortByPath - Dot-separated path to group by (e.g., "user.id")
|
|
72
|
+
* @param options - Optional configuration
|
|
73
|
+
* @returns Object with grouped documents
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Basic usage
|
|
77
|
+
* segrigateDocs(users, "department")
|
|
78
|
+
* // Returns: { "Engineering": [...], "Marketing": [...] }
|
|
79
|
+
*/
|
|
80
|
+
declare const segrigateDocs: (docs: any[], sortByPath: string, options?: SegrigateDocsOptions) => Record<string, any>;
|
|
81
|
+
|
|
61
82
|
interface Block {
|
|
62
83
|
[key: string]: any;
|
|
63
84
|
comp?: string;
|
|
@@ -629,4 +650,4 @@ interface GetPlatformContextContentParams {
|
|
|
629
650
|
}
|
|
630
651
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
631
652
|
|
|
632
|
-
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray };
|
|
653
|
+
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/browser.js
CHANGED
|
@@ -28,6 +28,7 @@ __export(browser_exports, {
|
|
|
28
28
|
getRollupPossibilities: () => getRollupPossibilities,
|
|
29
29
|
getVal: () => getVal,
|
|
30
30
|
recursivelyExtractBlocks: () => _recursExtractBlocks,
|
|
31
|
+
segrigateDocs: () => segrigateDocs,
|
|
31
32
|
setVal: () => setVal,
|
|
32
33
|
toArray: () => toArray
|
|
33
34
|
});
|
|
@@ -196,6 +197,40 @@ var toArray = (property) => {
|
|
|
196
197
|
return [property];
|
|
197
198
|
};
|
|
198
199
|
|
|
200
|
+
// src/utils/segrigateDocs.ts
|
|
201
|
+
var segrigateDocs = (docs, sortByPath, options = {}) => {
|
|
202
|
+
let newSegrigatedObj = {};
|
|
203
|
+
docs.map((d, i) => {
|
|
204
|
+
let sortByValue = getVal(d, sortByPath);
|
|
205
|
+
if (sortByValue || !options.skipUndefined) {
|
|
206
|
+
if (Array.isArray(sortByValue)) {
|
|
207
|
+
sortByValue.map((v) => {
|
|
208
|
+
if (!newSegrigatedObj[v]) {
|
|
209
|
+
newSegrigatedObj[v] = [];
|
|
210
|
+
}
|
|
211
|
+
newSegrigatedObj[v].push(d);
|
|
212
|
+
});
|
|
213
|
+
} else {
|
|
214
|
+
if (!newSegrigatedObj[sortByValue]) {
|
|
215
|
+
newSegrigatedObj[sortByValue] = [];
|
|
216
|
+
}
|
|
217
|
+
newSegrigatedObj[sortByValue].push(d);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
if (options.idPath || options.titlePath) {
|
|
222
|
+
Object.values(newSegrigatedObj).map((v, i) => {
|
|
223
|
+
let key = Object.keys(newSegrigatedObj)[i];
|
|
224
|
+
newSegrigatedObj[key] = {
|
|
225
|
+
id: options.idPath ? getVal(v[0], options.idPath) : void 0,
|
|
226
|
+
title: options.titlePath ? getVal(v[0], options.titlePath) : void 0,
|
|
227
|
+
[options.aryKey ? options.aryKey : "ary"]: v
|
|
228
|
+
};
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return newSegrigatedObj;
|
|
232
|
+
};
|
|
233
|
+
|
|
199
234
|
// src/utils/extractAllBlocksFromTpl.ts
|
|
200
235
|
var extractAllBlocksFromTpl = ({
|
|
201
236
|
tpl,
|
|
@@ -717,6 +752,7 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
717
752
|
getRollupPossibilities,
|
|
718
753
|
getVal,
|
|
719
754
|
recursivelyExtractBlocks,
|
|
755
|
+
segrigateDocs,
|
|
720
756
|
setVal,
|
|
721
757
|
toArray
|
|
722
758
|
});
|
package/dist/browser.mjs
CHANGED
|
@@ -161,6 +161,40 @@ var toArray = (property) => {
|
|
|
161
161
|
return [property];
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
+
// src/utils/segrigateDocs.ts
|
|
165
|
+
var segrigateDocs = (docs, sortByPath, options = {}) => {
|
|
166
|
+
let newSegrigatedObj = {};
|
|
167
|
+
docs.map((d, i) => {
|
|
168
|
+
let sortByValue = getVal(d, sortByPath);
|
|
169
|
+
if (sortByValue || !options.skipUndefined) {
|
|
170
|
+
if (Array.isArray(sortByValue)) {
|
|
171
|
+
sortByValue.map((v) => {
|
|
172
|
+
if (!newSegrigatedObj[v]) {
|
|
173
|
+
newSegrigatedObj[v] = [];
|
|
174
|
+
}
|
|
175
|
+
newSegrigatedObj[v].push(d);
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
if (!newSegrigatedObj[sortByValue]) {
|
|
179
|
+
newSegrigatedObj[sortByValue] = [];
|
|
180
|
+
}
|
|
181
|
+
newSegrigatedObj[sortByValue].push(d);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
if (options.idPath || options.titlePath) {
|
|
186
|
+
Object.values(newSegrigatedObj).map((v, i) => {
|
|
187
|
+
let key = Object.keys(newSegrigatedObj)[i];
|
|
188
|
+
newSegrigatedObj[key] = {
|
|
189
|
+
id: options.idPath ? getVal(v[0], options.idPath) : void 0,
|
|
190
|
+
title: options.titlePath ? getVal(v[0], options.titlePath) : void 0,
|
|
191
|
+
[options.aryKey ? options.aryKey : "ary"]: v
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return newSegrigatedObj;
|
|
196
|
+
};
|
|
197
|
+
|
|
164
198
|
// src/utils/extractAllBlocksFromTpl.ts
|
|
165
199
|
var extractAllBlocksFromTpl = ({
|
|
166
200
|
tpl,
|
|
@@ -681,6 +715,7 @@ export {
|
|
|
681
715
|
getRollupPossibilities,
|
|
682
716
|
getVal,
|
|
683
717
|
_recursExtractBlocks as recursivelyExtractBlocks,
|
|
718
|
+
segrigateDocs,
|
|
684
719
|
setVal,
|
|
685
720
|
toArray
|
|
686
721
|
};
|
package/dist/node.d.mts
CHANGED
|
@@ -65,6 +65,27 @@ declare const genTagId: (tagName: TagNameInput) => string;
|
|
|
65
65
|
*/
|
|
66
66
|
declare const toArray: <T>(property: T | T[] | null | undefined | false | 0) => T[];
|
|
67
67
|
|
|
68
|
+
interface SegrigateDocsOptions {
|
|
69
|
+
skipUndefined?: boolean;
|
|
70
|
+
idPath?: string;
|
|
71
|
+
titlePath?: string;
|
|
72
|
+
aryKey?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Groups an array of documents by a specified property path
|
|
76
|
+
*
|
|
77
|
+
* @param docs - Array of documents to group
|
|
78
|
+
* @param sortByPath - Dot-separated path to group by (e.g., "user.id")
|
|
79
|
+
* @param options - Optional configuration
|
|
80
|
+
* @returns Object with grouped documents
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* // Basic usage
|
|
84
|
+
* segrigateDocs(users, "department")
|
|
85
|
+
* // Returns: { "Engineering": [...], "Marketing": [...] }
|
|
86
|
+
*/
|
|
87
|
+
declare const segrigateDocs: (docs: any[], sortByPath: string, options?: SegrigateDocsOptions) => Record<string, any>;
|
|
88
|
+
|
|
68
89
|
interface Block {
|
|
69
90
|
[key: string]: any;
|
|
70
91
|
comp?: string;
|
|
@@ -696,13 +717,15 @@ declare class RedisCacheConnector {
|
|
|
696
717
|
* @param {string} params.tenant - The tenant identifier
|
|
697
718
|
* @param {'platformConfigs'|'tpl'} params.modelName - The collection to search in
|
|
698
719
|
* @param {string} [params.type] - When modelName='platformConfigs': one of platformConfigTypes array values; when modelName='tpl': content type string. If omitted, returns all documents for the collection.
|
|
720
|
+
* @param {string} [params.env] - Environment (defaults to current env)
|
|
699
721
|
* @returns {Promise<Array>} Array of matching documents
|
|
700
722
|
* @see {platformConfigTypes} for valid platformConfigs type values
|
|
701
723
|
*/
|
|
702
|
-
static findConfigsInCache({ tenant, modelName, type }: {
|
|
724
|
+
static findConfigsInCache({ tenant, modelName, type, env }: {
|
|
703
725
|
tenant: string;
|
|
704
726
|
modelName: "platformConfigs" | "tpl";
|
|
705
727
|
type?: string | undefined;
|
|
728
|
+
env?: string | undefined;
|
|
706
729
|
}): Promise<any[]>;
|
|
707
730
|
/**
|
|
708
731
|
* Find a single document in Redis cache (returns first match)
|
|
@@ -710,13 +733,15 @@ declare class RedisCacheConnector {
|
|
|
710
733
|
* @param {string} params.tenant - The tenant identifier
|
|
711
734
|
* @param {'platformConfigs'|'tpl'} params.modelName - The collection to search in
|
|
712
735
|
* @param {string} [params.type] - When modelName='platformConfigs': one of platformConfigTypes array values; when modelName='tpl': content type string. If omitted, returns first document of any type.
|
|
736
|
+
* @param {string} [params.env] - Environment (defaults to current env)
|
|
713
737
|
* @returns {Promise<Object|undefined>} First matching document or undefined if none found
|
|
714
738
|
* @see {platformConfigTypes} for valid platformConfigs type values
|
|
715
739
|
*/
|
|
716
|
-
static findOneConfigInCache({ tenant, modelName, type }: {
|
|
740
|
+
static findOneConfigInCache({ tenant, modelName, type, env }: {
|
|
717
741
|
tenant: string;
|
|
718
742
|
modelName: "platformConfigs" | "tpl";
|
|
719
743
|
type?: string | undefined;
|
|
744
|
+
env?: string | undefined;
|
|
720
745
|
}): Promise<Object | undefined>;
|
|
721
746
|
/**
|
|
722
747
|
* Generate Redis key for config caching
|
|
@@ -1163,4 +1188,4 @@ declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
|
|
|
1163
1188
|
};
|
|
1164
1189
|
}): Object;
|
|
1165
1190
|
|
|
1166
|
-
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 };
|
|
1191
|
+
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, segrigateDocs, setVal, toArray };
|
package/dist/node.d.ts
CHANGED
|
@@ -65,6 +65,27 @@ declare const genTagId: (tagName: TagNameInput) => string;
|
|
|
65
65
|
*/
|
|
66
66
|
declare const toArray: <T>(property: T | T[] | null | undefined | false | 0) => T[];
|
|
67
67
|
|
|
68
|
+
interface SegrigateDocsOptions {
|
|
69
|
+
skipUndefined?: boolean;
|
|
70
|
+
idPath?: string;
|
|
71
|
+
titlePath?: string;
|
|
72
|
+
aryKey?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Groups an array of documents by a specified property path
|
|
76
|
+
*
|
|
77
|
+
* @param docs - Array of documents to group
|
|
78
|
+
* @param sortByPath - Dot-separated path to group by (e.g., "user.id")
|
|
79
|
+
* @param options - Optional configuration
|
|
80
|
+
* @returns Object with grouped documents
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* // Basic usage
|
|
84
|
+
* segrigateDocs(users, "department")
|
|
85
|
+
* // Returns: { "Engineering": [...], "Marketing": [...] }
|
|
86
|
+
*/
|
|
87
|
+
declare const segrigateDocs: (docs: any[], sortByPath: string, options?: SegrigateDocsOptions) => Record<string, any>;
|
|
88
|
+
|
|
68
89
|
interface Block {
|
|
69
90
|
[key: string]: any;
|
|
70
91
|
comp?: string;
|
|
@@ -696,13 +717,15 @@ declare class RedisCacheConnector {
|
|
|
696
717
|
* @param {string} params.tenant - The tenant identifier
|
|
697
718
|
* @param {'platformConfigs'|'tpl'} params.modelName - The collection to search in
|
|
698
719
|
* @param {string} [params.type] - When modelName='platformConfigs': one of platformConfigTypes array values; when modelName='tpl': content type string. If omitted, returns all documents for the collection.
|
|
720
|
+
* @param {string} [params.env] - Environment (defaults to current env)
|
|
699
721
|
* @returns {Promise<Array>} Array of matching documents
|
|
700
722
|
* @see {platformConfigTypes} for valid platformConfigs type values
|
|
701
723
|
*/
|
|
702
|
-
static findConfigsInCache({ tenant, modelName, type }: {
|
|
724
|
+
static findConfigsInCache({ tenant, modelName, type, env }: {
|
|
703
725
|
tenant: string;
|
|
704
726
|
modelName: "platformConfigs" | "tpl";
|
|
705
727
|
type?: string | undefined;
|
|
728
|
+
env?: string | undefined;
|
|
706
729
|
}): Promise<any[]>;
|
|
707
730
|
/**
|
|
708
731
|
* Find a single document in Redis cache (returns first match)
|
|
@@ -710,13 +733,15 @@ declare class RedisCacheConnector {
|
|
|
710
733
|
* @param {string} params.tenant - The tenant identifier
|
|
711
734
|
* @param {'platformConfigs'|'tpl'} params.modelName - The collection to search in
|
|
712
735
|
* @param {string} [params.type] - When modelName='platformConfigs': one of platformConfigTypes array values; when modelName='tpl': content type string. If omitted, returns first document of any type.
|
|
736
|
+
* @param {string} [params.env] - Environment (defaults to current env)
|
|
713
737
|
* @returns {Promise<Object|undefined>} First matching document or undefined if none found
|
|
714
738
|
* @see {platformConfigTypes} for valid platformConfigs type values
|
|
715
739
|
*/
|
|
716
|
-
static findOneConfigInCache({ tenant, modelName, type }: {
|
|
740
|
+
static findOneConfigInCache({ tenant, modelName, type, env }: {
|
|
717
741
|
tenant: string;
|
|
718
742
|
modelName: "platformConfigs" | "tpl";
|
|
719
743
|
type?: string | undefined;
|
|
744
|
+
env?: string | undefined;
|
|
720
745
|
}): Promise<Object | undefined>;
|
|
721
746
|
/**
|
|
722
747
|
* Generate Redis key for config caching
|
|
@@ -1163,4 +1188,4 @@ declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
|
|
|
1163
1188
|
};
|
|
1164
1189
|
}): Object;
|
|
1165
1190
|
|
|
1166
|
-
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 };
|
|
1191
|
+
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, segrigateDocs, setVal, toArray };
|
package/dist/node.js
CHANGED
|
@@ -1455,6 +1455,7 @@ __export(node_exports, {
|
|
|
1455
1455
|
getTplModelByTenant: () => import_getModelByTenant2.getTplModelByTenant,
|
|
1456
1456
|
getVal: () => getVal,
|
|
1457
1457
|
recursivelyExtractBlocks: () => _recursExtractBlocks,
|
|
1458
|
+
segrigateDocs: () => segrigateDocs,
|
|
1458
1459
|
setVal: () => setVal,
|
|
1459
1460
|
toArray: () => toArray
|
|
1460
1461
|
});
|
|
@@ -1623,6 +1624,40 @@ var toArray = (property) => {
|
|
|
1623
1624
|
return [property];
|
|
1624
1625
|
};
|
|
1625
1626
|
|
|
1627
|
+
// src/utils/segrigateDocs.ts
|
|
1628
|
+
var segrigateDocs = (docs, sortByPath, options = {}) => {
|
|
1629
|
+
let newSegrigatedObj = {};
|
|
1630
|
+
docs.map((d, i) => {
|
|
1631
|
+
let sortByValue = getVal(d, sortByPath);
|
|
1632
|
+
if (sortByValue || !options.skipUndefined) {
|
|
1633
|
+
if (Array.isArray(sortByValue)) {
|
|
1634
|
+
sortByValue.map((v) => {
|
|
1635
|
+
if (!newSegrigatedObj[v]) {
|
|
1636
|
+
newSegrigatedObj[v] = [];
|
|
1637
|
+
}
|
|
1638
|
+
newSegrigatedObj[v].push(d);
|
|
1639
|
+
});
|
|
1640
|
+
} else {
|
|
1641
|
+
if (!newSegrigatedObj[sortByValue]) {
|
|
1642
|
+
newSegrigatedObj[sortByValue] = [];
|
|
1643
|
+
}
|
|
1644
|
+
newSegrigatedObj[sortByValue].push(d);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
});
|
|
1648
|
+
if (options.idPath || options.titlePath) {
|
|
1649
|
+
Object.values(newSegrigatedObj).map((v, i) => {
|
|
1650
|
+
let key = Object.keys(newSegrigatedObj)[i];
|
|
1651
|
+
newSegrigatedObj[key] = {
|
|
1652
|
+
id: options.idPath ? getVal(v[0], options.idPath) : void 0,
|
|
1653
|
+
title: options.titlePath ? getVal(v[0], options.titlePath) : void 0,
|
|
1654
|
+
[options.aryKey ? options.aryKey : "ary"]: v
|
|
1655
|
+
};
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
return newSegrigatedObj;
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1626
1661
|
// src/utils/extractAllBlocksFromTpl.ts
|
|
1627
1662
|
var extractAllBlocksFromTpl = ({
|
|
1628
1663
|
tpl,
|
|
@@ -1952,13 +1987,14 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
1952
1987
|
* @param {string} params.tenant - The tenant identifier
|
|
1953
1988
|
* @param {'platformConfigs'|'tpl'} params.modelName - The collection to search in
|
|
1954
1989
|
* @param {string} [params.type] - When modelName='platformConfigs': one of platformConfigTypes array values; when modelName='tpl': content type string. If omitted, returns all documents for the collection.
|
|
1990
|
+
* @param {string} [params.env] - Environment (defaults to current env)
|
|
1955
1991
|
* @returns {Promise<Array>} Array of matching documents
|
|
1956
1992
|
* @see {platformConfigTypes} for valid platformConfigs type values
|
|
1957
1993
|
*/
|
|
1958
|
-
static async findConfigsInCache({ tenant, modelName, type }) {
|
|
1994
|
+
static async findConfigsInCache({ tenant, modelName, type, env }) {
|
|
1959
1995
|
try {
|
|
1960
1996
|
const client = this.getClient();
|
|
1961
|
-
const environment = this.getEnv();
|
|
1997
|
+
const environment = env || this.getEnv();
|
|
1962
1998
|
const keyPrefix = `${environment}:${tenant}:${modelName}:`;
|
|
1963
1999
|
const keys = await client.keys(`${keyPrefix}${type || "*"}`);
|
|
1964
2000
|
if (keys.length === 0) {
|
|
@@ -1982,7 +2018,8 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
1982
2018
|
tenant,
|
|
1983
2019
|
modelName,
|
|
1984
2020
|
type: doc[typeKey],
|
|
1985
|
-
val: doc
|
|
2021
|
+
val: doc,
|
|
2022
|
+
env: environment
|
|
1986
2023
|
})
|
|
1987
2024
|
)
|
|
1988
2025
|
);
|
|
@@ -2006,14 +2043,16 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
2006
2043
|
* @param {string} params.tenant - The tenant identifier
|
|
2007
2044
|
* @param {'platformConfigs'|'tpl'} params.modelName - The collection to search in
|
|
2008
2045
|
* @param {string} [params.type] - When modelName='platformConfigs': one of platformConfigTypes array values; when modelName='tpl': content type string. If omitted, returns first document of any type.
|
|
2046
|
+
* @param {string} [params.env] - Environment (defaults to current env)
|
|
2009
2047
|
* @returns {Promise<Object|undefined>} First matching document or undefined if none found
|
|
2010
2048
|
* @see {platformConfigTypes} for valid platformConfigs type values
|
|
2011
2049
|
*/
|
|
2012
|
-
static async findOneConfigInCache({ tenant, modelName, type }) {
|
|
2050
|
+
static async findOneConfigInCache({ tenant, modelName, type, env }) {
|
|
2013
2051
|
const cacheData = await this.findConfigsInCache({
|
|
2014
2052
|
tenant,
|
|
2015
2053
|
modelName,
|
|
2016
|
-
type
|
|
2054
|
+
type,
|
|
2055
|
+
env
|
|
2017
2056
|
});
|
|
2018
2057
|
return cacheData?.[0];
|
|
2019
2058
|
}
|
|
@@ -2081,14 +2120,19 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
2081
2120
|
type,
|
|
2082
2121
|
env
|
|
2083
2122
|
});
|
|
2084
|
-
await client.del(cacheKey);
|
|
2123
|
+
const delResult = await client.del(cacheKey);
|
|
2124
|
+
let setResult;
|
|
2085
2125
|
if (newVal) {
|
|
2086
2126
|
try {
|
|
2087
|
-
await client.set(cacheKey, JSON.stringify(newVal));
|
|
2127
|
+
setResult = await client.set(cacheKey, JSON.stringify(newVal));
|
|
2088
2128
|
} catch (err) {
|
|
2089
2129
|
console.log("invalidateCache - Cache set failed: ", err);
|
|
2090
2130
|
}
|
|
2091
2131
|
}
|
|
2132
|
+
return {
|
|
2133
|
+
delResult,
|
|
2134
|
+
setResult
|
|
2135
|
+
};
|
|
2092
2136
|
}
|
|
2093
2137
|
/**
|
|
2094
2138
|
* Load all collections and templates into Redis cache for all tenants
|
|
@@ -2193,6 +2237,7 @@ var import_GET_GLOBAL_BULLMQ_CONFIG = __toESM(require_GET_GLOBAL_BULLMQ_CONFIG()
|
|
|
2193
2237
|
getTplModelByTenant,
|
|
2194
2238
|
getVal,
|
|
2195
2239
|
recursivelyExtractBlocks,
|
|
2240
|
+
segrigateDocs,
|
|
2196
2241
|
setVal,
|
|
2197
2242
|
toArray
|
|
2198
2243
|
});
|
package/dist/node.mjs
CHANGED
|
@@ -1594,6 +1594,40 @@ var toArray = (property) => {
|
|
|
1594
1594
|
return [property];
|
|
1595
1595
|
};
|
|
1596
1596
|
|
|
1597
|
+
// src/utils/segrigateDocs.ts
|
|
1598
|
+
var segrigateDocs = (docs, sortByPath, options = {}) => {
|
|
1599
|
+
let newSegrigatedObj = {};
|
|
1600
|
+
docs.map((d, i) => {
|
|
1601
|
+
let sortByValue = getVal(d, sortByPath);
|
|
1602
|
+
if (sortByValue || !options.skipUndefined) {
|
|
1603
|
+
if (Array.isArray(sortByValue)) {
|
|
1604
|
+
sortByValue.map((v) => {
|
|
1605
|
+
if (!newSegrigatedObj[v]) {
|
|
1606
|
+
newSegrigatedObj[v] = [];
|
|
1607
|
+
}
|
|
1608
|
+
newSegrigatedObj[v].push(d);
|
|
1609
|
+
});
|
|
1610
|
+
} else {
|
|
1611
|
+
if (!newSegrigatedObj[sortByValue]) {
|
|
1612
|
+
newSegrigatedObj[sortByValue] = [];
|
|
1613
|
+
}
|
|
1614
|
+
newSegrigatedObj[sortByValue].push(d);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
if (options.idPath || options.titlePath) {
|
|
1619
|
+
Object.values(newSegrigatedObj).map((v, i) => {
|
|
1620
|
+
let key = Object.keys(newSegrigatedObj)[i];
|
|
1621
|
+
newSegrigatedObj[key] = {
|
|
1622
|
+
id: options.idPath ? getVal(v[0], options.idPath) : void 0,
|
|
1623
|
+
title: options.titlePath ? getVal(v[0], options.titlePath) : void 0,
|
|
1624
|
+
[options.aryKey ? options.aryKey : "ary"]: v
|
|
1625
|
+
};
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
return newSegrigatedObj;
|
|
1629
|
+
};
|
|
1630
|
+
|
|
1597
1631
|
// src/utils/extractAllBlocksFromTpl.ts
|
|
1598
1632
|
var extractAllBlocksFromTpl = ({
|
|
1599
1633
|
tpl,
|
|
@@ -1923,13 +1957,14 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
1923
1957
|
* @param {string} params.tenant - The tenant identifier
|
|
1924
1958
|
* @param {'platformConfigs'|'tpl'} params.modelName - The collection to search in
|
|
1925
1959
|
* @param {string} [params.type] - When modelName='platformConfigs': one of platformConfigTypes array values; when modelName='tpl': content type string. If omitted, returns all documents for the collection.
|
|
1960
|
+
* @param {string} [params.env] - Environment (defaults to current env)
|
|
1926
1961
|
* @returns {Promise<Array>} Array of matching documents
|
|
1927
1962
|
* @see {platformConfigTypes} for valid platformConfigs type values
|
|
1928
1963
|
*/
|
|
1929
|
-
static async findConfigsInCache({ tenant, modelName, type }) {
|
|
1964
|
+
static async findConfigsInCache({ tenant, modelName, type, env }) {
|
|
1930
1965
|
try {
|
|
1931
1966
|
const client = this.getClient();
|
|
1932
|
-
const environment = this.getEnv();
|
|
1967
|
+
const environment = env || this.getEnv();
|
|
1933
1968
|
const keyPrefix = `${environment}:${tenant}:${modelName}:`;
|
|
1934
1969
|
const keys = await client.keys(`${keyPrefix}${type || "*"}`);
|
|
1935
1970
|
if (keys.length === 0) {
|
|
@@ -1953,7 +1988,8 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
1953
1988
|
tenant,
|
|
1954
1989
|
modelName,
|
|
1955
1990
|
type: doc[typeKey],
|
|
1956
|
-
val: doc
|
|
1991
|
+
val: doc,
|
|
1992
|
+
env: environment
|
|
1957
1993
|
})
|
|
1958
1994
|
)
|
|
1959
1995
|
);
|
|
@@ -1977,14 +2013,16 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
1977
2013
|
* @param {string} params.tenant - The tenant identifier
|
|
1978
2014
|
* @param {'platformConfigs'|'tpl'} params.modelName - The collection to search in
|
|
1979
2015
|
* @param {string} [params.type] - When modelName='platformConfigs': one of platformConfigTypes array values; when modelName='tpl': content type string. If omitted, returns first document of any type.
|
|
2016
|
+
* @param {string} [params.env] - Environment (defaults to current env)
|
|
1980
2017
|
* @returns {Promise<Object|undefined>} First matching document or undefined if none found
|
|
1981
2018
|
* @see {platformConfigTypes} for valid platformConfigs type values
|
|
1982
2019
|
*/
|
|
1983
|
-
static async findOneConfigInCache({ tenant, modelName, type }) {
|
|
2020
|
+
static async findOneConfigInCache({ tenant, modelName, type, env }) {
|
|
1984
2021
|
const cacheData = await this.findConfigsInCache({
|
|
1985
2022
|
tenant,
|
|
1986
2023
|
modelName,
|
|
1987
|
-
type
|
|
2024
|
+
type,
|
|
2025
|
+
env
|
|
1988
2026
|
});
|
|
1989
2027
|
return cacheData?.[0];
|
|
1990
2028
|
}
|
|
@@ -2052,14 +2090,19 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
2052
2090
|
type,
|
|
2053
2091
|
env
|
|
2054
2092
|
});
|
|
2055
|
-
await client.del(cacheKey);
|
|
2093
|
+
const delResult = await client.del(cacheKey);
|
|
2094
|
+
let setResult;
|
|
2056
2095
|
if (newVal) {
|
|
2057
2096
|
try {
|
|
2058
|
-
await client.set(cacheKey, JSON.stringify(newVal));
|
|
2097
|
+
setResult = await client.set(cacheKey, JSON.stringify(newVal));
|
|
2059
2098
|
} catch (err) {
|
|
2060
2099
|
console.log("invalidateCache - Cache set failed: ", err);
|
|
2061
2100
|
}
|
|
2062
2101
|
}
|
|
2102
|
+
return {
|
|
2103
|
+
delResult,
|
|
2104
|
+
setResult
|
|
2105
|
+
};
|
|
2063
2106
|
}
|
|
2064
2107
|
/**
|
|
2065
2108
|
* Load all collections and templates into Redis cache for all tenants
|
|
@@ -2175,6 +2218,7 @@ export {
|
|
|
2175
2218
|
export_getTplModelByTenant as getTplModelByTenant,
|
|
2176
2219
|
getVal,
|
|
2177
2220
|
_recursExtractBlocks as recursivelyExtractBlocks,
|
|
2221
|
+
segrigateDocs,
|
|
2178
2222
|
setVal,
|
|
2179
2223
|
toArray
|
|
2180
2224
|
};
|
package/dist/universal.d.mts
CHANGED
|
@@ -58,6 +58,27 @@ declare const genTagId: (tagName: TagNameInput) => string;
|
|
|
58
58
|
*/
|
|
59
59
|
declare const toArray: <T>(property: T | T[] | null | undefined | false | 0) => T[];
|
|
60
60
|
|
|
61
|
+
interface SegrigateDocsOptions {
|
|
62
|
+
skipUndefined?: boolean;
|
|
63
|
+
idPath?: string;
|
|
64
|
+
titlePath?: string;
|
|
65
|
+
aryKey?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Groups an array of documents by a specified property path
|
|
69
|
+
*
|
|
70
|
+
* @param docs - Array of documents to group
|
|
71
|
+
* @param sortByPath - Dot-separated path to group by (e.g., "user.id")
|
|
72
|
+
* @param options - Optional configuration
|
|
73
|
+
* @returns Object with grouped documents
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Basic usage
|
|
77
|
+
* segrigateDocs(users, "department")
|
|
78
|
+
* // Returns: { "Engineering": [...], "Marketing": [...] }
|
|
79
|
+
*/
|
|
80
|
+
declare const segrigateDocs: (docs: any[], sortByPath: string, options?: SegrigateDocsOptions) => Record<string, any>;
|
|
81
|
+
|
|
61
82
|
interface Block {
|
|
62
83
|
[key: string]: any;
|
|
63
84
|
comp?: string;
|
|
@@ -629,4 +650,4 @@ interface GetPlatformContextContentParams {
|
|
|
629
650
|
}
|
|
630
651
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
631
652
|
|
|
632
|
-
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray };
|
|
653
|
+
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/universal.d.ts
CHANGED
|
@@ -58,6 +58,27 @@ declare const genTagId: (tagName: TagNameInput) => string;
|
|
|
58
58
|
*/
|
|
59
59
|
declare const toArray: <T>(property: T | T[] | null | undefined | false | 0) => T[];
|
|
60
60
|
|
|
61
|
+
interface SegrigateDocsOptions {
|
|
62
|
+
skipUndefined?: boolean;
|
|
63
|
+
idPath?: string;
|
|
64
|
+
titlePath?: string;
|
|
65
|
+
aryKey?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Groups an array of documents by a specified property path
|
|
69
|
+
*
|
|
70
|
+
* @param docs - Array of documents to group
|
|
71
|
+
* @param sortByPath - Dot-separated path to group by (e.g., "user.id")
|
|
72
|
+
* @param options - Optional configuration
|
|
73
|
+
* @returns Object with grouped documents
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Basic usage
|
|
77
|
+
* segrigateDocs(users, "department")
|
|
78
|
+
* // Returns: { "Engineering": [...], "Marketing": [...] }
|
|
79
|
+
*/
|
|
80
|
+
declare const segrigateDocs: (docs: any[], sortByPath: string, options?: SegrigateDocsOptions) => Record<string, any>;
|
|
81
|
+
|
|
61
82
|
interface Block {
|
|
62
83
|
[key: string]: any;
|
|
63
84
|
comp?: string;
|
|
@@ -629,4 +650,4 @@ interface GetPlatformContextContentParams {
|
|
|
629
650
|
}
|
|
630
651
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
631
652
|
|
|
632
|
-
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray };
|
|
653
|
+
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/universal.js
CHANGED
|
@@ -28,6 +28,7 @@ __export(universal_exports, {
|
|
|
28
28
|
getRollupPossibilities: () => getRollupPossibilities,
|
|
29
29
|
getVal: () => getVal,
|
|
30
30
|
recursivelyExtractBlocks: () => _recursExtractBlocks,
|
|
31
|
+
segrigateDocs: () => segrigateDocs,
|
|
31
32
|
setVal: () => setVal,
|
|
32
33
|
toArray: () => toArray
|
|
33
34
|
});
|
|
@@ -196,6 +197,40 @@ var toArray = (property) => {
|
|
|
196
197
|
return [property];
|
|
197
198
|
};
|
|
198
199
|
|
|
200
|
+
// src/utils/segrigateDocs.ts
|
|
201
|
+
var segrigateDocs = (docs, sortByPath, options = {}) => {
|
|
202
|
+
let newSegrigatedObj = {};
|
|
203
|
+
docs.map((d, i) => {
|
|
204
|
+
let sortByValue = getVal(d, sortByPath);
|
|
205
|
+
if (sortByValue || !options.skipUndefined) {
|
|
206
|
+
if (Array.isArray(sortByValue)) {
|
|
207
|
+
sortByValue.map((v) => {
|
|
208
|
+
if (!newSegrigatedObj[v]) {
|
|
209
|
+
newSegrigatedObj[v] = [];
|
|
210
|
+
}
|
|
211
|
+
newSegrigatedObj[v].push(d);
|
|
212
|
+
});
|
|
213
|
+
} else {
|
|
214
|
+
if (!newSegrigatedObj[sortByValue]) {
|
|
215
|
+
newSegrigatedObj[sortByValue] = [];
|
|
216
|
+
}
|
|
217
|
+
newSegrigatedObj[sortByValue].push(d);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
if (options.idPath || options.titlePath) {
|
|
222
|
+
Object.values(newSegrigatedObj).map((v, i) => {
|
|
223
|
+
let key = Object.keys(newSegrigatedObj)[i];
|
|
224
|
+
newSegrigatedObj[key] = {
|
|
225
|
+
id: options.idPath ? getVal(v[0], options.idPath) : void 0,
|
|
226
|
+
title: options.titlePath ? getVal(v[0], options.titlePath) : void 0,
|
|
227
|
+
[options.aryKey ? options.aryKey : "ary"]: v
|
|
228
|
+
};
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return newSegrigatedObj;
|
|
232
|
+
};
|
|
233
|
+
|
|
199
234
|
// src/utils/extractAllBlocksFromTpl.ts
|
|
200
235
|
var extractAllBlocksFromTpl = ({
|
|
201
236
|
tpl,
|
|
@@ -717,6 +752,7 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
717
752
|
getRollupPossibilities,
|
|
718
753
|
getVal,
|
|
719
754
|
recursivelyExtractBlocks,
|
|
755
|
+
segrigateDocs,
|
|
720
756
|
setVal,
|
|
721
757
|
toArray
|
|
722
758
|
});
|
package/dist/universal.mjs
CHANGED
|
@@ -161,6 +161,40 @@ var toArray = (property) => {
|
|
|
161
161
|
return [property];
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
+
// src/utils/segrigateDocs.ts
|
|
165
|
+
var segrigateDocs = (docs, sortByPath, options = {}) => {
|
|
166
|
+
let newSegrigatedObj = {};
|
|
167
|
+
docs.map((d, i) => {
|
|
168
|
+
let sortByValue = getVal(d, sortByPath);
|
|
169
|
+
if (sortByValue || !options.skipUndefined) {
|
|
170
|
+
if (Array.isArray(sortByValue)) {
|
|
171
|
+
sortByValue.map((v) => {
|
|
172
|
+
if (!newSegrigatedObj[v]) {
|
|
173
|
+
newSegrigatedObj[v] = [];
|
|
174
|
+
}
|
|
175
|
+
newSegrigatedObj[v].push(d);
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
if (!newSegrigatedObj[sortByValue]) {
|
|
179
|
+
newSegrigatedObj[sortByValue] = [];
|
|
180
|
+
}
|
|
181
|
+
newSegrigatedObj[sortByValue].push(d);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
if (options.idPath || options.titlePath) {
|
|
186
|
+
Object.values(newSegrigatedObj).map((v, i) => {
|
|
187
|
+
let key = Object.keys(newSegrigatedObj)[i];
|
|
188
|
+
newSegrigatedObj[key] = {
|
|
189
|
+
id: options.idPath ? getVal(v[0], options.idPath) : void 0,
|
|
190
|
+
title: options.titlePath ? getVal(v[0], options.titlePath) : void 0,
|
|
191
|
+
[options.aryKey ? options.aryKey : "ary"]: v
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return newSegrigatedObj;
|
|
196
|
+
};
|
|
197
|
+
|
|
164
198
|
// src/utils/extractAllBlocksFromTpl.ts
|
|
165
199
|
var extractAllBlocksFromTpl = ({
|
|
166
200
|
tpl,
|
|
@@ -681,6 +715,7 @@ export {
|
|
|
681
715
|
getRollupPossibilities,
|
|
682
716
|
getVal,
|
|
683
717
|
_recursExtractBlocks as recursivelyExtractBlocks,
|
|
718
|
+
segrigateDocs,
|
|
684
719
|
setVal,
|
|
685
720
|
toArray
|
|
686
721
|
};
|