@encodeagent/platform-helper-util 1.2508.1241505

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 (122) hide show
  1. package/README.md +121 -0
  2. package/dist/__tests__/core.test.d.ts +5 -0
  3. package/dist/__tests__/core.test.d.ts.map +1 -0
  4. package/dist/__tests__/core.test.js +128 -0
  5. package/dist/__tests__/core.test.js.map +1 -0
  6. package/dist/__tests__/shortid.test.d.ts +5 -0
  7. package/dist/__tests__/shortid.test.d.ts.map +1 -0
  8. package/dist/__tests__/shortid.test.js +72 -0
  9. package/dist/__tests__/shortid.test.js.map +1 -0
  10. package/dist/__tests__/slug.test.d.ts +5 -0
  11. package/dist/__tests__/slug.test.d.ts.map +1 -0
  12. package/dist/__tests__/slug.test.js +31 -0
  13. package/dist/__tests__/slug.test.js.map +1 -0
  14. package/dist/__tests__/token.test.d.ts +5 -0
  15. package/dist/__tests__/token.test.d.ts.map +1 -0
  16. package/dist/__tests__/token.test.js +49 -0
  17. package/dist/__tests__/token.test.js.map +1 -0
  18. package/dist/__tests__/uuid.test.d.ts +5 -0
  19. package/dist/__tests__/uuid.test.d.ts.map +1 -0
  20. package/dist/__tests__/uuid.test.js +42 -0
  21. package/dist/__tests__/uuid.test.js.map +1 -0
  22. package/dist/__tests__/value-of-object.test.d.ts +5 -0
  23. package/dist/__tests__/value-of-object.test.d.ts.map +1 -0
  24. package/dist/__tests__/value-of-object.test.js +49 -0
  25. package/dist/__tests__/value-of-object.test.js.map +1 -0
  26. package/dist/ai/llm.d.ts +90 -0
  27. package/dist/ai/llm.d.ts.map +1 -0
  28. package/dist/ai/llm.js +524 -0
  29. package/dist/ai/llm.js.map +1 -0
  30. package/dist/ai/model.d.ts +14 -0
  31. package/dist/ai/model.d.ts.map +1 -0
  32. package/dist/ai/model.js +120 -0
  33. package/dist/ai/model.js.map +1 -0
  34. package/dist/ai/types.d.ts +85 -0
  35. package/dist/ai/types.d.ts.map +1 -0
  36. package/dist/ai/types.js +15 -0
  37. package/dist/ai/types.js.map +1 -0
  38. package/dist/ai/util.d.ts +28 -0
  39. package/dist/ai/util.d.ts.map +1 -0
  40. package/dist/ai/util.js +43 -0
  41. package/dist/ai/util.js.map +1 -0
  42. package/dist/auth.d.ts +34 -0
  43. package/dist/auth.d.ts.map +1 -0
  44. package/dist/auth.js +568 -0
  45. package/dist/auth.js.map +1 -0
  46. package/dist/colors.d.ts +79 -0
  47. package/dist/colors.d.ts.map +1 -0
  48. package/dist/colors.js +492 -0
  49. package/dist/colors.js.map +1 -0
  50. package/dist/constants.d.ts +86 -0
  51. package/dist/constants.d.ts.map +1 -0
  52. package/dist/constants.js +2578 -0
  53. package/dist/constants.js.map +1 -0
  54. package/dist/core.d.ts +337 -0
  55. package/dist/core.d.ts.map +1 -0
  56. package/dist/core.js +1165 -0
  57. package/dist/core.js.map +1 -0
  58. package/dist/cost.d.ts +35 -0
  59. package/dist/cost.d.ts.map +1 -0
  60. package/dist/cost.js +143 -0
  61. package/dist/cost.js.map +1 -0
  62. package/dist/file.d.ts +55 -0
  63. package/dist/file.d.ts.map +1 -0
  64. package/dist/file.js +273 -0
  65. package/dist/file.js.map +1 -0
  66. package/dist/html.d.ts +44 -0
  67. package/dist/html.d.ts.map +1 -0
  68. package/dist/html.js +420 -0
  69. package/dist/html.js.map +1 -0
  70. package/dist/index.d.ts +53 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +313 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/markdown.d.ts +20 -0
  75. package/dist/markdown.d.ts.map +1 -0
  76. package/dist/markdown.js +38 -0
  77. package/dist/markdown.js.map +1 -0
  78. package/dist/metadata.d.ts +39 -0
  79. package/dist/metadata.d.ts.map +1 -0
  80. package/dist/metadata.js +110 -0
  81. package/dist/metadata.js.map +1 -0
  82. package/dist/record.d.ts +67 -0
  83. package/dist/record.d.ts.map +1 -0
  84. package/dist/record.js +404 -0
  85. package/dist/record.js.map +1 -0
  86. package/dist/shortid.d.ts +42 -0
  87. package/dist/shortid.d.ts.map +1 -0
  88. package/dist/shortid.js +42 -0
  89. package/dist/shortid.js.map +1 -0
  90. package/dist/slug.d.ts +24 -0
  91. package/dist/slug.d.ts.map +1 -0
  92. package/dist/slug.js +43 -0
  93. package/dist/slug.js.map +1 -0
  94. package/dist/token.d.ts +34 -0
  95. package/dist/token.d.ts.map +1 -0
  96. package/dist/token.js +20 -0
  97. package/dist/token.js.map +1 -0
  98. package/dist/tree.d.ts +27 -0
  99. package/dist/tree.d.ts.map +1 -0
  100. package/dist/tree.js +193 -0
  101. package/dist/tree.js.map +1 -0
  102. package/dist/types.d.ts +270 -0
  103. package/dist/types.d.ts.map +1 -0
  104. package/dist/types.js +29 -0
  105. package/dist/types.js.map +1 -0
  106. package/dist/uuid.d.ts +25 -0
  107. package/dist/uuid.d.ts.map +1 -0
  108. package/dist/uuid.js +32 -0
  109. package/dist/uuid.js.map +1 -0
  110. package/dist/value-of-object.d.ts +25 -0
  111. package/dist/value-of-object.d.ts.map +1 -0
  112. package/dist/value-of-object.js +123 -0
  113. package/dist/value-of-object.js.map +1 -0
  114. package/dist/web-content.d.ts +54 -0
  115. package/dist/web-content.d.ts.map +1 -0
  116. package/dist/web-content.js +268 -0
  117. package/dist/web-content.js.map +1 -0
  118. package/dist/web.d.ts +36 -0
  119. package/dist/web.d.ts.map +1 -0
  120. package/dist/web.js +162 -0
  121. package/dist/web.js.map +1 -0
  122. package/package.json +68 -0
package/dist/slug.js ADDED
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview URL-friendly slug generation utilities for creating clean, SEO-optimized identifiers from text strings
4
+ * @copyright PrimeObjects Software Inc. (C) 2024 All Rights Reserved
5
+ * @author EncodeAgent Team.
6
+ * @copyright © 2024 PrimeObjects Software Inc. All rights reserved.
7
+ * @license Proprietary - Subject to PrimeObjects License Agreements
8
+ * @contact encode.agent@primeobjects.com
9
+ * @website https://www.encodeagent.com/
10
+ *
11
+ * This software contains proprietary and confidential information of
12
+ * PrimeObjects Software Inc. Any reproduction or distribution of this
13
+ * software, in whole or in part, without written permission of
14
+ * PrimeObjects Software Inc. is strictly prohibited.
15
+ *
16
+ * Unauthorized copying of this file, via any medium, is strictly prohibited.
17
+ * This file is proprietary and confidential.
18
+ */
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.slug = void 0;
24
+ const slugify_1 = __importDefault(require("slugify"));
25
+ const lodash_1 = require("lodash");
26
+ const slug = (text, settings = {}) => {
27
+ return !(0, lodash_1.isString)(text)
28
+ ? undefined
29
+ : (0, slugify_1.default)(text
30
+ .replace(/[^a-zA-Z0-9 _[.]-]/g, "")
31
+ .replace(/_/g, settings?.keepUnderscore ? "_" : "-")
32
+ .replace(/\./g, settings?.keepPeriod ? "." : "-")
33
+ .replace(/\ /g, settings?.keepSpace ? " " : "-")
34
+ .replace(/\|/g, settings?.keepPipe ? "|" : "-")
35
+ .replace(new RegExp(`( ){2,}`, "g"), "-"), {
36
+ lower: true,
37
+ remove: /[=:?#@!$&'()*+,;"<>%{}|\\^`]/g
38
+ })
39
+ .replace(/\//g, "-")
40
+ .toLowerCase();
41
+ };
42
+ exports.slug = slug;
43
+ //# sourceMappingURL=slug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slug.js","sourceRoot":"","sources":["../src/slug.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;AAEH,sDAA8B;AAC9B,mCAAkC;AAE3B,MAAM,IAAI,GAAG,CAChB,IAAY,EACZ,WAKI,EAAE,EACY,EAAE;IACpB,OAAO,CAAC,IAAA,iBAAQ,EAAC,IAAI,CAAC;QAClB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,IAAA,iBAAO,EACH,IAAI;aACC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC;aAClC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;aACnD,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;aAChD,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;aAC/C,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;aAC9C,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAC7C;YACI,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,+BAA+B;SAC1C,CACJ;aACI,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,WAAW,EAAE,CAAC;AAC7B,CAAC,CAAC;AA1BW,QAAA,IAAI,QA0Bf"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview Token type definitions and parsing utilities for authentication and authorization tokens
3
+ * @copyright PrimeObjects Software Inc. (C) 2024 All Rights Reserved
4
+ * @author EncodeAgent Team.
5
+ * @copyright © 2024 PrimeObjects Software Inc. All rights reserved.
6
+ * @license Proprietary - Subject to PrimeObjects License Agreements
7
+ * @contact encode.agent@primeobjects.com
8
+ * @website https://www.encodeagent.com/
9
+ *
10
+ * This software contains proprietary and confidential information of
11
+ * PrimeObjects Software Inc. Any reproduction or distribution of this
12
+ * software, in whole or in part, without written permission of
13
+ * PrimeObjects Software Inc. is strictly prohibited.
14
+ *
15
+ * Unauthorized copying of this file, via any medium, is strictly prohibited.
16
+ * This file is proprietary and confidential.
17
+ */
18
+ import { IError } from "./types";
19
+ export type TTokenType = "user" | "access" | "api" | "webhook" | "verification" | "value";
20
+ export type TToken = {
21
+ token: string;
22
+ key: string;
23
+ type: TTokenType;
24
+ userId: string;
25
+ organizationId: string;
26
+ solutionId: string;
27
+ createdOn: number;
28
+ data?: string | Record<string, any>;
29
+ };
30
+ export type TParseTokenResult = {
31
+ token?: TToken;
32
+ error?: IError;
33
+ };
34
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,MAAM,UAAU,GAChB,MAAM,GACN,QAAQ,GACR,KAAK,GACL,SAAS,GACT,cAAc,GACd,OAAO,CAAC;AAEd,MAAM,MAAM,MAAM,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
package/dist/token.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Token type definitions and parsing utilities for authentication and authorization tokens
4
+ * @copyright PrimeObjects Software Inc. (C) 2024 All Rights Reserved
5
+ * @author EncodeAgent Team.
6
+ * @copyright © 2024 PrimeObjects Software Inc. All rights reserved.
7
+ * @license Proprietary - Subject to PrimeObjects License Agreements
8
+ * @contact encode.agent@primeobjects.com
9
+ * @website https://www.encodeagent.com/
10
+ *
11
+ * This software contains proprietary and confidential information of
12
+ * PrimeObjects Software Inc. Any reproduction or distribution of this
13
+ * software, in whole or in part, without written permission of
14
+ * PrimeObjects Software Inc. is strictly prohibited.
15
+ *
16
+ * Unauthorized copying of this file, via any medium, is strictly prohibited.
17
+ * This file is proprietary and confidential.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ //# sourceMappingURL=token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.js","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG"}
package/dist/tree.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @fileoverview Tree data structure utilities for hierarchical data manipulation and traversal operations
3
+ * @copyright PrimeObjects Software Inc. (C) 2024 All Rights Reserved
4
+ * @author EncodeAgent Team.
5
+ * @copyright © 2024 PrimeObjects Software Inc. All rights reserved.
6
+ * @license Proprietary - Subject to PrimeObjects License Agreements
7
+ * @contact encode.agent@primeobjects.com
8
+ * @website https://www.encodeagent.com/
9
+ *
10
+ * This software contains proprietary and confidential information of
11
+ * PrimeObjects Software Inc. Any reproduction or distribution of this
12
+ * software, in whole or in part, without written permission of
13
+ * PrimeObjects Software Inc. is strictly prohibited.
14
+ *
15
+ * Unauthorized copying of this file, via any medium, is strictly prohibited.
16
+ * This file is proprietary and confidential.
17
+ */
18
+ export declare const getTreeItem: (items: Array<Record<string, any>>, func: (item?: Record<string, any>, items?: Array<Record<string, any>>, childrenNodeName?: string) => boolean, childrenNodeName?: string) => Record<string, any> | undefined;
19
+ export declare const updateAllTreeItems: (items: Array<Record<string, any>>, childrenNodeName?: string, func?: (item?: Record<string, any>, items?: Array<Record<string, any>>, childrenNodeName?: string) => Record<string, any> | undefined | null) => Array<Record<string, any>>;
20
+ export declare const updateTreeItem: (items: Array<Record<string, any>>, id: string, matchFunc?: (item?: Record<string, any>, items?: Array<Record<string, any>>, childrenNodeName?: string) => Record<string, any> | undefined | null, notMatchFunc?: (item?: Record<string, any>, items?: Array<Record<string, any>>, childrenNodeName?: string) => Record<string, any> | undefined | null, childrenNodeName?: string) => Array<Record<string, any>>;
21
+ export declare const insertTreeItem: (items: Array<Record<string, any>>, id: string, newItem: Record<string, any>, pos: "above" | "below" | "children", childrenNodeName?: string) => Array<Record<string, any>>;
22
+ export declare const replaceTreeItem: (items: Array<Record<string, any>>, id: string, newItem: Record<string, any>, childrenNodeName?: string) => Array<Record<string, any>>;
23
+ export declare const removeTreeItem: (items: Array<Record<string, any>>, id: string, childrenNodeName?: string) => Array<Record<string, any>>;
24
+ export declare const getTreeItemPath: (items: Array<Record<string, any>>, func: (item?: Record<string, any>, items?: Array<Record<string, any>>, childrenNodeName?: string) => boolean, childrenNodeName?: string, result?: Record<string, any>) => Record<string, any>;
25
+ export declare const getTreeItemHavingPropValue: (items: Array<Record<string, any>>, prop: string, func: (item?: Record<string, any>, items?: Array<Record<string, any>>, childrenNodeName?: string) => boolean, childrenNodeName?: string) => Record<string, any> | undefined;
26
+ export declare const getTreeItemAndChildrenIds: (item: Record<string, any>, ids: Array<string>, childrenNodeName?: string) => Array<string>;
27
+ //# sourceMappingURL=tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAgBH,eAAO,MAAM,WAAW,GACpB,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EACjC,MAAM,CACF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAClC,gBAAgB,CAAC,EAAE,MAAM,KACxB,OAAO,EACZ,mBAAmB,MAAM,KAC1B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAmBxB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC3B,OAAO,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EAAE,GAAG,CAAC,CAAC,EAClC,gBAAgB,CAAC,EAAE,MAAM,KACxB,OAAO,EACZ,mBAAmB,MAAM,KAC1B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAaxB,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAClC,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,KAAK,KAAK,CAAC,MAAM,CAAC,EAClB,mBAAmB,MAAM,KAC1B,KAAK,CAAC,MAAM,CAOd,CAAC"}
package/dist/tree.js ADDED
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Tree data structure utilities for hierarchical data manipulation and traversal operations
4
+ * @copyright PrimeObjects Software Inc. (C) 2024 All Rights Reserved
5
+ * @author EncodeAgent Team.
6
+ * @copyright © 2024 PrimeObjects Software Inc. All rights reserved.
7
+ * @license Proprietary - Subject to PrimeObjects License Agreements
8
+ * @contact encode.agent@primeobjects.com
9
+ * @website https://www.encodeagent.com/
10
+ *
11
+ * This software contains proprietary and confidential information of
12
+ * PrimeObjects Software Inc. Any reproduction or distribution of this
13
+ * software, in whole or in part, without written permission of
14
+ * PrimeObjects Software Inc. is strictly prohibited.
15
+ *
16
+ * Unauthorized copying of this file, via any medium, is strictly prohibited.
17
+ * This file is proprietary and confidential.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.getTreeItemAndChildrenIds = exports.getTreeItemHavingPropValue = exports.getTreeItemPath = exports.removeTreeItem = exports.replaceTreeItem = exports.insertTreeItem = exports.updateTreeItem = exports.updateAllTreeItems = exports.getTreeItem = void 0;
21
+ const core_1 = require("./core");
22
+ const lodash_1 = require("lodash");
23
+ const getTreeItem = (items, func, childrenNodeName) => {
24
+ if (!childrenNodeName)
25
+ childrenNodeName = "items";
26
+ let v = undefined;
27
+ if ((0, lodash_1.isArray)(items) && items.length > 0) {
28
+ for (let i = 0; i < items.length && !v; i++) {
29
+ const item = items[i];
30
+ if (func(item)) {
31
+ v = item;
32
+ }
33
+ else {
34
+ if (!v)
35
+ v = (0, exports.getTreeItem)(item[childrenNodeName], func, childrenNodeName);
36
+ }
37
+ }
38
+ }
39
+ return v;
40
+ };
41
+ exports.getTreeItem = getTreeItem;
42
+ const updateAllTreeItems = (items, childrenNodeName, func) => {
43
+ if (!(0, lodash_1.isArray)(items))
44
+ return items;
45
+ if (!(0, lodash_1.isFunction)(func))
46
+ return items;
47
+ if (!childrenNodeName)
48
+ childrenNodeName = "items";
49
+ return (0, lodash_1.without)((0, lodash_1.map)(items, (item) => {
50
+ const newItem = func(item, items, childrenNodeName);
51
+ if ((0, core_1.isObject)(newItem) && !(0, lodash_1.isEmpty)(newItem) && childrenNodeName)
52
+ newItem[childrenNodeName] = (0, exports.updateAllTreeItems)(newItem[childrenNodeName], childrenNodeName, func);
53
+ return (0, core_1.isObject)(newItem) ? newItem : null;
54
+ }), null);
55
+ };
56
+ exports.updateAllTreeItems = updateAllTreeItems;
57
+ const updateTreeItem = (items, id, matchFunc, notMatchFunc, childrenNodeName) => {
58
+ if (!(0, lodash_1.isArray)(items))
59
+ return items;
60
+ if (!(0, lodash_1.isFunction)(matchFunc) && !(0, lodash_1.isFunction)(notMatchFunc))
61
+ return items;
62
+ if (!childrenNodeName)
63
+ childrenNodeName = "items";
64
+ return (0, lodash_1.without)((0, lodash_1.map)(items, (item) => {
65
+ let newItem = { ...item };
66
+ if ((0, core_1.sameGuid)(item.id, id)) {
67
+ if ((0, lodash_1.isFunction)(matchFunc)) {
68
+ newItem = matchFunc(newItem, items, childrenNodeName);
69
+ }
70
+ }
71
+ else {
72
+ if ((0, lodash_1.isFunction)(notMatchFunc))
73
+ newItem = notMatchFunc(newItem, items, childrenNodeName);
74
+ }
75
+ if ((0, core_1.isObject)(newItem) && !(0, lodash_1.isEmpty)(newItem) && childrenNodeName) {
76
+ console.log(4);
77
+ newItem[childrenNodeName] = (0, exports.updateTreeItem)(newItem[childrenNodeName], id, matchFunc, notMatchFunc, childrenNodeName);
78
+ }
79
+ return (0, core_1.isObject)(newItem) ? newItem : null;
80
+ }), null);
81
+ };
82
+ exports.updateTreeItem = updateTreeItem;
83
+ const insertTreeItem = (items, id, newItem, pos, childrenNodeName) => {
84
+ if (!childrenNodeName)
85
+ childrenNodeName = "items";
86
+ const idx = (0, lodash_1.findIndex)(items, (item) => {
87
+ return (0, core_1.sameGuid)(item.id, id);
88
+ });
89
+ if (idx >= 0) {
90
+ switch (pos) {
91
+ case "above": {
92
+ if (!(0, lodash_1.find)(items, (i) => i.text.toLowerCase() == newItem.text.toLowerCase())) {
93
+ items = [
94
+ ...items.slice(0, idx),
95
+ newItem,
96
+ ...items.slice(idx)
97
+ ];
98
+ }
99
+ break;
100
+ }
101
+ case "below": {
102
+ if (!(0, lodash_1.find)(items, (i) => i.text.toLowerCase() == newItem.text.toLowerCase())) {
103
+ items = [
104
+ ...items.slice(0, idx + 1),
105
+ newItem,
106
+ ...items.slice(idx + 1)
107
+ ];
108
+ }
109
+ break;
110
+ }
111
+ default: {
112
+ //child
113
+ if (!(0, lodash_1.isArray)(items[idx].items))
114
+ items[idx].items = [];
115
+ if (!(0, lodash_1.find)(items[idx].items, (i) => i.text.toLowerCase() == newItem.text.toLowerCase())) {
116
+ items[idx].items.unshift(newItem);
117
+ }
118
+ }
119
+ }
120
+ return items;
121
+ }
122
+ else {
123
+ return (0, lodash_1.map)(items, (item) => {
124
+ if (childrenNodeName && (0, lodash_1.isArray)(item[childrenNodeName])) {
125
+ item[childrenNodeName] = (0, exports.insertTreeItem)(item[childrenNodeName], id, newItem, pos, childrenNodeName);
126
+ }
127
+ return item;
128
+ });
129
+ }
130
+ };
131
+ exports.insertTreeItem = insertTreeItem;
132
+ const replaceTreeItem = (items, id, newItem, childrenNodeName) => {
133
+ return (0, exports.updateTreeItem)(items, id, () => {
134
+ return (0, lodash_1.cloneDeep)(newItem);
135
+ }, undefined, childrenNodeName);
136
+ };
137
+ exports.replaceTreeItem = replaceTreeItem;
138
+ const removeTreeItem = (items, id, childrenNodeName) => {
139
+ return (0, exports.updateTreeItem)(items, id, () => {
140
+ return null;
141
+ }, undefined, childrenNodeName);
142
+ };
143
+ exports.removeTreeItem = removeTreeItem;
144
+ //it will return an array that list the parent items
145
+ //{item, path:[grandpaItem, fatherItem]}
146
+ const getTreeItemPath = (items, func, childrenNodeName, result) => {
147
+ if (!childrenNodeName)
148
+ childrenNodeName = "items";
149
+ if (!(0, core_1.isObject)(result))
150
+ result = { path: [] };
151
+ (0, lodash_1.each)(items, (item) => {
152
+ if (func(item, items, childrenNodeName) && result) {
153
+ result.item = (0, lodash_1.cloneDeep)(item);
154
+ }
155
+ else {
156
+ if (!result?.item && childrenNodeName) {
157
+ const parent = (0, lodash_1.cloneDeep)(result);
158
+ parent?.push((0, lodash_1.cloneDeep)(item));
159
+ const child = (0, exports.getTreeItemPath)(item[childrenNodeName], func, childrenNodeName, parent);
160
+ if (child?.item)
161
+ result = (0, lodash_1.cloneDeep)(child);
162
+ }
163
+ }
164
+ });
165
+ return result ? result : { path: [] };
166
+ };
167
+ exports.getTreeItemPath = getTreeItemPath;
168
+ //it will return the prop value of a node
169
+ //if the node does have the prop value, it will return the one from the closest parent node that has the prop value.
170
+ const getTreeItemHavingPropValue = (items, prop, func, childrenNodeName) => {
171
+ const itemInfo = (0, exports.getTreeItemPath)(items, func, childrenNodeName);
172
+ if (!itemInfo.item)
173
+ return undefined; //item not found
174
+ if (itemInfo.item[prop] != undefined)
175
+ return itemInfo.item;
176
+ for (let i = itemInfo.path.length - 1; i >= 0; i--) {
177
+ if (itemInfo.path[i][prop] != undefined)
178
+ return itemInfo.path[i];
179
+ }
180
+ return undefined;
181
+ };
182
+ exports.getTreeItemHavingPropValue = getTreeItemHavingPropValue;
183
+ const getTreeItemAndChildrenIds = (item, ids, childrenNodeName) => {
184
+ if (!(0, core_1.isObject)(item))
185
+ return [];
186
+ ids.push(item.id);
187
+ (0, lodash_1.each)(item[childrenNodeName ? childrenNodeName : "items"], (subItem) => {
188
+ ids = (0, exports.getTreeItemAndChildrenIds)(subItem, ids, childrenNodeName);
189
+ });
190
+ return (0, lodash_1.uniq)(ids);
191
+ };
192
+ exports.getTreeItemAndChildrenIds = getTreeItemAndChildrenIds;
193
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,iCAA4C;AAC5C,mCAWgB;AAET,MAAM,WAAW,GAAG,CACvB,KAAiC,EACjC,IAIY,EACZ,gBAAyB,EACM,EAAE;IACjC,IAAI,CAAC,gBAAgB;QAAE,gBAAgB,GAAG,OAAO,CAAC;IAClD,IAAI,CAAC,GAAoC,SAAS,CAAC;IACnD,IAAI,IAAA,gBAAO,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACb,CAAC,GAAG,IAAI,CAAC;YACb,CAAC;iBAAM,CAAC;gBACJ,IAAI,CAAC,CAAC;oBACF,CAAC,GAAG,IAAA,mBAAW,EACX,IAAI,CAAC,gBAAgB,CAAC,EACtB,IAAI,EACJ,gBAAgB,CACnB,CAAC;YACV,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,CAAC,CAAC;AACb,CAAC,CAAC;AA3BW,QAAA,WAAW,eA2BtB;AAEK,MAAM,kBAAkB,GAAG,CAC9B,KAAiC,EACjC,gBAAyB,EACzB,IAI2C,EACjB,EAAE;IAC5B,IAAI,CAAC,IAAA,gBAAO,EAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC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C,QAAQ,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC,CAAC,gBAAgB;IACtD,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,SAAS;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC;IAC3D,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,SAAS;YAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAtBW,QAAA,0BAA0B,8BAsBrC;AAEK,MAAM,yBAAyB,GAAG,CACrC,IAAyB,EACzB,GAAkB,EAClB,gBAAyB,EACZ,EAAE;IACf,IAAI,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAC/B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,IAAA,aAAI,EAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE;QAClE,GAAG,GAAG,IAAA,iCAAyB,EAAC,OAAO,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IACH,OAAO,IAAA,aAAI,EAAC,GAAG,CAAC,CAAC;AACrB,CAAC,CAAC;AAXW,QAAA,yBAAyB,6BAWpC"}
@@ -0,0 +1,270 @@
1
+ /**
2
+ * @fileoverview Core utility types for EncodeAgent platform
3
+ * @copyright PrimeObjects Software Inc. (C) 2024 All Rights Reserved
4
+ * @author EncodeAgent Team.
5
+ * @copyright © 2024 PrimeObjects Software Inc. All rights reserved.
6
+ * @license Proprietary - Subject to PrimeObjects License Agreements
7
+ * @contact encode.agent@primeobjects.com
8
+ * @website https://www.encodeagent.com/
9
+ *
10
+ * This software contains proprietary and confidential information of
11
+ * PrimeObjects Software Inc. Any reproduction or distribution of this
12
+ * software, in whole or in part, without written permission of
13
+ * PrimeObjects Software Inc. is strictly prohibited.
14
+ *
15
+ * Unauthorized copying of this file, via any medium, is strictly prohibited.
16
+ * This file is proprietary and confidential.
17
+ */
18
+ import { TRequireLog } from "./constants";
19
+ /**
20
+ * Context object containing information about the current execution environment
21
+ * @interface IContext
22
+ */
23
+ export interface IContext {
24
+ /** Unique identifier for the solution */
25
+ solutionId: string;
26
+ /** Domain name for the current request */
27
+ domain?: string;
28
+ /** Source IP address of the request */
29
+ sourceIp?: string;
30
+ /** Unique identifier for the user */
31
+ userId: string;
32
+ /** Unique identifier for the organization */
33
+ organizationId: string;
34
+ /** User object with additional properties */
35
+ user?: Record<string, any>;
36
+ /** Organization object with additional properties */
37
+ organization?: Record<string, any>;
38
+ /** Solution object with additional properties */
39
+ solution?: Record<string, any>;
40
+ /** Error information if any */
41
+ error?: any;
42
+ /** Log information */
43
+ log?: Record<string, any>;
44
+ /** Record data */
45
+ record?: Record<string, any>;
46
+ /** Record data filtered by membership */
47
+ recordByMembership?: Record<string, any>;
48
+ /** Available AI services */
49
+ aiServices?: IService[];
50
+ /** Current stage (development, production, etc.) */
51
+ stage: string;
52
+ }
53
+ /**
54
+ * Error object containing detailed error information
55
+ * @interface IError
56
+ */
57
+ export interface IError {
58
+ /** The reason for the error */
59
+ reason: string;
60
+ /** Optional error message */
61
+ message?: string;
62
+ /** Additional error details */
63
+ detail?: Record<string, any>;
64
+ /** The original exception if any */
65
+ exception?: any;
66
+ }
67
+ /**
68
+ * Surcharge configuration for pricing calculations
69
+ * @interface ISurcharge
70
+ */
71
+ export interface ISurcharge {
72
+ /** Type of surcharge calculation */
73
+ type: "number" | "percentage";
74
+ /** Surcharge value */
75
+ value: number;
76
+ }
77
+ /** Key ownership types */
78
+ export type TKeyOwner = "organization" | "solution" | "platform" | "error";
79
+ /**
80
+ * API key configuration object
81
+ * @interface IKey
82
+ */
83
+ export interface IKey {
84
+ /** The actual key value */
85
+ value: string;
86
+ /** Who owns this key */
87
+ owner: TKeyOwner;
88
+ /** Service provider name */
89
+ provider: string;
90
+ /** Platform identifier */
91
+ platform: string;
92
+ /** Human-readable key name */
93
+ name: string;
94
+ /** Optional service URL */
95
+ url?: string;
96
+ /** API version */
97
+ version?: string;
98
+ /** Additional key details */
99
+ detail?: string | Record<string, any>;
100
+ }
101
+ /**
102
+ * Usage tracking item for billing calculations
103
+ * @interface IUsageItem
104
+ */
105
+ export interface IUsageItem {
106
+ /** Optional name for the usage item */
107
+ name?: string;
108
+ /** Quantity used */
109
+ quantity: number;
110
+ /** Subtotal cost */
111
+ subtotal: number;
112
+ /** Unit price */
113
+ price: number;
114
+ /** Applied surcharge */
115
+ surcharge: number;
116
+ }
117
+ /**
118
+ * Cost calculation key identifier
119
+ * @interface ICostKey
120
+ */
121
+ export interface ICostKey {
122
+ /** Key owner type */
123
+ owner: TKeyOwner;
124
+ /** Service provider */
125
+ provider: string;
126
+ /** Platform identifier */
127
+ platform: string;
128
+ }
129
+ /**
130
+ * Individual cost item in a billing calculation
131
+ * @interface ICostItem
132
+ */
133
+ export interface ICostItem {
134
+ /** Unique identifier for this cost item */
135
+ id: string;
136
+ /** Optional type classification */
137
+ type?: string;
138
+ /** Associated cost key */
139
+ key?: ICostKey;
140
+ /** Function usage costs */
141
+ function: IUsageItem;
142
+ /** Input processing costs */
143
+ input: IUsageItem;
144
+ /** Output processing costs */
145
+ output: IUsageItem;
146
+ /** Optional total cost override */
147
+ cost?: number;
148
+ /** Calculated subtotal */
149
+ subtotal: number;
150
+ /** Subtotal from internal calculation */
151
+ subtotalFromCalculation?: number;
152
+ /** Subtotal from external platform */
153
+ subtotalFromPlatform?: number;
154
+ /** Applied surcharge amount */
155
+ surcharge: number;
156
+ /** Applied discount amount */
157
+ discount: number;
158
+ /** Final total cost */
159
+ total: number;
160
+ }
161
+ /**
162
+ * Complete cost calculation result
163
+ * @interface ICost
164
+ */
165
+ export interface ICost {
166
+ /** Unique identifier for this cost calculation */
167
+ id: string;
168
+ /** Timestamp of calculation */
169
+ ts: number;
170
+ /** System-level pricing configuration */
171
+ system: {
172
+ surcharge: ISurcharge;
173
+ creditExchangeRate: number;
174
+ };
175
+ /** Individual cost items */
176
+ items: ICostItem[];
177
+ /** Optional total cost override */
178
+ cost?: number;
179
+ /** Calculated subtotal */
180
+ subtotal: number;
181
+ /** Total discount applied */
182
+ discount: number;
183
+ /** Total surcharge applied */
184
+ surcharge: number;
185
+ /** Final total cost */
186
+ total: number;
187
+ /** Cost converted to credits */
188
+ credits: number;
189
+ }
190
+ /**
191
+ * AI service configuration and pricing information
192
+ * @interface IService
193
+ */
194
+ export interface IService {
195
+ /** Unique service identifier */
196
+ id: string;
197
+ /** Runtime environment */
198
+ runtime: string;
199
+ /** Platform identifier */
200
+ platform: string;
201
+ /** Service provider name */
202
+ provider: string;
203
+ /** Human-readable service name */
204
+ name: string;
205
+ /** Service type classification */
206
+ type: string;
207
+ /** Development stage (preview, beta, etc.) */
208
+ stage?: string;
209
+ /** Available functions and their pricing */
210
+ functions?: Record<string, {
211
+ price: number;
212
+ }>;
213
+ /** Input token configuration and pricing */
214
+ input: {
215
+ maxTokens?: number;
216
+ price: number;
217
+ };
218
+ /** Output token configuration and pricing */
219
+ output: {
220
+ maxTokens?: number;
221
+ price: number;
222
+ };
223
+ /** Context window configuration */
224
+ context?: {
225
+ maxTokens?: number;
226
+ };
227
+ /** Service-specific surcharge */
228
+ surcharge?: ISurcharge;
229
+ /** Credit exchange rate for this service */
230
+ creditExchangeRate?: number;
231
+ /** Service version */
232
+ version?: string;
233
+ /** Associated API key name */
234
+ keyName: string;
235
+ /** Key owner identifier */
236
+ keyOwner: string;
237
+ /** Average latency in milliseconds */
238
+ latency?: number;
239
+ /** Reference ID for tracking */
240
+ refId?: string;
241
+ }
242
+ /**
243
+ * Properties for action execution
244
+ * @interface IActionProps
245
+ */
246
+ export interface IActionProps {
247
+ /** Execution context */
248
+ context: IContext;
249
+ /** Optional owner identifier */
250
+ ownerId?: string;
251
+ /** Optional owner entity name */
252
+ ownerEntityName?: string;
253
+ /** Optional owner entity type */
254
+ ownerEntityType?: string;
255
+ /** Logging requirements */
256
+ requireLog?: TRequireLog;
257
+ }
258
+ /**
259
+ * Result of action execution
260
+ * @interface IActionResult
261
+ */
262
+ export interface IActionResult {
263
+ /** Service used for the action */
264
+ service: IService;
265
+ /** Error information if action failed */
266
+ error?: IError;
267
+ /** API key used if applicable */
268
+ key?: IKey;
269
+ }
270
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACrB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,+BAA+B;IAC/B,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,sBAAsB;IACtB,GAAG,CAAC,EAAE,M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AAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjC,iCAAiC;IACjC,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,4CAA4C;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB,wBAAwB;IACxB,OAAO,EAAE,QAAQ,CAAC;IAClB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iCAAiC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,WAAW,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,kCAAkC;IAClC,OAAO,EAAE,QAAQ,CAAC;IAClB,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,GAAG,CAAC,EAAE,IAAI,CAAC;CACd"}
package/dist/types.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Core utility types for EncodeAgent platform
4
+ * @copyright PrimeObjects Software Inc. (C) 2024 All Rights Reserved
5
+ * @author EncodeAgent Team.
6
+ * @copyright © 2024 PrimeObjects Software Inc. All rights reserved.
7
+ * @license Proprietary - Subject to PrimeObjects License Agreements
8
+ * @contact encode.agent@primeobjects.com
9
+ * @website https://www.encodeagent.com/
10
+ *
11
+ * This software contains proprietary and confidential information of
12
+ * PrimeObjects Software Inc. Any reproduction or distribution of this
13
+ * software, in whole or in part, without written permission of
14
+ * PrimeObjects Software Inc. is strictly prohibited.
15
+ *
16
+ * Unauthorized copying of this file, via any medium, is strictly prohibited.
17
+ * This file is proprietary and confidential.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ ;
21
+ ;
22
+ ;
23
+ ;
24
+ ;
25
+ ;
26
+ ;
27
+ ;
28
+ ;
29
+ //# sourceMappingURL=types.js.map