@elevasis/core 0.15.1 → 0.17.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.
Files changed (72) hide show
  1. package/dist/index.d.ts +1662 -23
  2. package/dist/index.js +171 -24
  3. package/dist/knowledge/index.d.ts +1340 -0
  4. package/dist/knowledge/index.js +138 -0
  5. package/dist/organization-model/index.d.ts +1662 -23
  6. package/dist/organization-model/index.js +171 -24
  7. package/dist/test-utils/index.d.ts +711 -10
  8. package/dist/test-utils/index.js +159 -16
  9. package/package.json +7 -3
  10. package/src/__tests__/publish.test.ts +14 -13
  11. package/src/__tests__/template-core-compatibility.test.ts +4 -4
  12. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +1265 -1154
  13. package/src/auth/multi-tenancy/index.ts +3 -0
  14. package/src/auth/multi-tenancy/theme-presets.ts +45 -0
  15. package/src/auth/multi-tenancy/types.ts +57 -83
  16. package/src/auth/multi-tenancy/users/api-schemas.ts +165 -194
  17. package/src/business/acquisition/activity-events.ts +1 -1
  18. package/src/business/acquisition/api-schemas.ts +1196 -1177
  19. package/src/business/acquisition/crm-state-actions.test.ts +139 -139
  20. package/src/business/acquisition/types.ts +381 -390
  21. package/src/business/crm/api-schemas.ts +40 -0
  22. package/src/business/crm/index.ts +1 -0
  23. package/src/business/deals/api-schemas.ts +79 -0
  24. package/src/business/deals/index.ts +1 -0
  25. package/src/business/projects/types.ts +124 -88
  26. package/src/execution/core/runner-types.ts +61 -80
  27. package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-tools.ts +105 -104
  28. package/src/execution/engine/tools/integration/server/adapters/instantly/instantly-tools.ts +1474 -1473
  29. package/src/execution/engine/tools/integration/server/adapters/millionverifier/millionverifier-tools.ts +103 -102
  30. package/src/execution/engine/tools/integration/server/adapters/signature-api/signature-api-tools.ts +182 -179
  31. package/src/execution/engine/tools/integration/server/adapters/stripe/stripe-tools.ts +310 -309
  32. package/src/execution/engine/tools/integration/tool.ts +255 -253
  33. package/src/execution/engine/tools/lead-service-types.ts +895 -894
  34. package/src/execution/engine/tools/messages.ts +43 -0
  35. package/src/execution/engine/tools/platform/acquisition/types.ts +2 -1
  36. package/src/execution/engine/tools/platform/email/types.ts +97 -96
  37. package/src/execution/engine/tools/types.ts +234 -233
  38. package/src/execution/engine/workflow/types.ts +195 -193
  39. package/src/execution/external/api-schemas.ts +40 -0
  40. package/src/execution/external/index.ts +1 -0
  41. package/src/knowledge/README.md +32 -0
  42. package/src/knowledge/__tests__/queries.test.ts +504 -0
  43. package/src/knowledge/format.ts +99 -0
  44. package/src/knowledge/index.ts +5 -0
  45. package/src/knowledge/published.ts +5 -0
  46. package/src/knowledge/queries.ts +256 -0
  47. package/src/organization-model/__tests__/defaults.test.ts +172 -172
  48. package/src/organization-model/__tests__/foundation.test.ts +7 -7
  49. package/src/organization-model/__tests__/icons.test.ts +27 -0
  50. package/src/organization-model/__tests__/knowledge.test.ts +214 -0
  51. package/src/organization-model/contracts.ts +17 -15
  52. package/src/organization-model/defaults.ts +74 -19
  53. package/src/organization-model/domains/knowledge.ts +53 -0
  54. package/src/organization-model/domains/navigation.ts +416 -399
  55. package/src/organization-model/domains/shared.ts +6 -5
  56. package/src/organization-model/foundation.ts +10 -6
  57. package/src/organization-model/graph/build.ts +209 -182
  58. package/src/organization-model/graph/schema.ts +37 -34
  59. package/src/organization-model/graph/types.ts +47 -31
  60. package/src/organization-model/icons.ts +81 -0
  61. package/src/organization-model/index.ts +8 -3
  62. package/src/organization-model/organization-model.mdx +1 -1
  63. package/src/organization-model/published.ts +103 -86
  64. package/src/organization-model/schema.ts +90 -85
  65. package/src/organization-model/types.ts +40 -33
  66. package/src/platform/index.ts +23 -27
  67. package/src/platform/registry/index.ts +0 -4
  68. package/src/platform/registry/resource-registry.ts +0 -77
  69. package/src/platform/registry/serialized-types.ts +148 -219
  70. package/src/platform/registry/stats-types.ts +60 -60
  71. package/src/reference/_generated/contracts.md +1265 -1154
  72. package/src/platform/registry/__tests__/resource-registry.list-executable.test.ts +0 -393
@@ -0,0 +1,138 @@
1
+ // src/knowledge/queries.ts
2
+ function toGraphNodeId(omNodeId) {
3
+ return `knowledge:${omNodeId}`;
4
+ }
5
+ function buildKnowledgeSourceIdMap(graph) {
6
+ const map = /* @__PURE__ */ new Map();
7
+ for (const node of graph.nodes) {
8
+ if (node.kind === "knowledge" && node.sourceId) {
9
+ map.set(node.id, node.sourceId);
10
+ }
11
+ }
12
+ return map;
13
+ }
14
+ function byFeature(graph, featureId, knowledgeNodes) {
15
+ const targetGraphNodeId = `feature:${featureId}`;
16
+ const governingKnowledgeNodeIds = /* @__PURE__ */ new Set();
17
+ for (const edge of graph.edges) {
18
+ if (edge.kind === "governs" && edge.targetId === targetGraphNodeId && edge.sourceId.startsWith("knowledge:")) {
19
+ governingKnowledgeNodeIds.add(edge.sourceId);
20
+ }
21
+ }
22
+ const sourceIdMap = buildKnowledgeSourceIdMap(graph);
23
+ const matchingOmIds = /* @__PURE__ */ new Set();
24
+ for (const graphNodeId of governingKnowledgeNodeIds) {
25
+ const omId = sourceIdMap.get(graphNodeId);
26
+ if (omId) matchingOmIds.add(omId);
27
+ }
28
+ return knowledgeNodes.filter((n) => matchingOmIds.has(n.id));
29
+ }
30
+ function byKind(_graph, kind, knowledgeNodes) {
31
+ return knowledgeNodes.filter((n) => n.kind === kind);
32
+ }
33
+ function byOwner(_graph, ownerId, knowledgeNodes) {
34
+ return knowledgeNodes.filter((n) => n.ownerIds.includes(ownerId));
35
+ }
36
+ function governs(graph, nodeId) {
37
+ const graphNodeId = nodeId.startsWith("knowledge:") ? nodeId : toGraphNodeId(nodeId);
38
+ const results = [];
39
+ for (const edge of graph.edges) {
40
+ if (edge.kind === "governs" && edge.sourceId === graphNodeId) {
41
+ results.push(edge.targetId);
42
+ }
43
+ }
44
+ return results;
45
+ }
46
+ function governedBy(graph, nodeId) {
47
+ const targetId = nodeId.startsWith("feature:") || nodeId.startsWith("knowledge:") || nodeId.startsWith("resource:") ? nodeId : `feature:${nodeId}`;
48
+ const results = [];
49
+ for (const edge of graph.edges) {
50
+ if (edge.kind === "governs" && edge.targetId === targetId) {
51
+ results.push(edge.sourceId);
52
+ }
53
+ }
54
+ return results;
55
+ }
56
+ function parsePath(pathString) {
57
+ if (!pathString || typeof pathString !== "string") {
58
+ throw new Error("parsePath: path must be a non-empty string");
59
+ }
60
+ if (!pathString.startsWith("/")) {
61
+ throw new Error(`parsePath: path must start with "/", got: "${pathString}"`);
62
+ }
63
+ const normalized = pathString.replace(/\/+$/, "");
64
+ const segments = normalized.split("/").filter((s) => s.length > 0);
65
+ if (segments.length === 0) {
66
+ throw new Error(`parsePath: path resolves to root with no mount: "${pathString}"`);
67
+ }
68
+ const [first, ...rest] = segments;
69
+ if (first === "by-feature") {
70
+ if (rest.length === 0) {
71
+ throw new Error(`parsePath: /by-feature requires a featureId argument, got: "${pathString}"`);
72
+ }
73
+ return { mount: "by-feature", args: [rest.join("/")] };
74
+ }
75
+ if (first === "by-kind") {
76
+ if (rest.length === 0) {
77
+ throw new Error(`parsePath: /by-kind requires a kind argument, got: "${pathString}"`);
78
+ }
79
+ return { mount: "by-kind", args: [rest[0]] };
80
+ }
81
+ if (first === "by-owner") {
82
+ if (rest.length === 0) {
83
+ throw new Error(`parsePath: /by-owner requires an ownerId argument, got: "${pathString}"`);
84
+ }
85
+ return { mount: "by-owner", args: [rest.join("/")] };
86
+ }
87
+ if (first === "graph") {
88
+ if (rest.length < 2) {
89
+ throw new Error(`parsePath: /graph requires <nodeId>/<verb> (governs|governed-by), got: "${pathString}"`);
90
+ }
91
+ const graphNodeId = rest.slice(0, -1).join("/");
92
+ const verb = rest[rest.length - 1];
93
+ if (verb !== "governs" && verb !== "governed-by") {
94
+ throw new Error(
95
+ `parsePath: /graph/<nodeId> verb must be "governs" or "governed-by", got: "${verb}" in "${pathString}"`
96
+ );
97
+ }
98
+ return { mount: "graph", args: [graphNodeId, verb] };
99
+ }
100
+ if (segments.length === 1) {
101
+ return { mount: "node", args: [first] };
102
+ }
103
+ throw new Error(
104
+ `parsePath: unrecognized path pattern "${pathString}". Supported: /by-feature/<id>, /by-kind/<kind>, /by-owner/<id>, /graph/<nodeId>/governs, /graph/<nodeId>/governed-by, /<nodeId>`
105
+ );
106
+ }
107
+
108
+ // src/knowledge/format.ts
109
+ function formatText(results) {
110
+ if (results.length === 0) {
111
+ return "(no results)";
112
+ }
113
+ const kindWidth = Math.max(...results.map((n) => n.kind.length), 8);
114
+ const idWidth = Math.max(...results.map((n) => n.id.length), 4);
115
+ const header = `${"KIND".padEnd(kindWidth)} ${"ID".padEnd(idWidth)} TITLE`;
116
+ const divider = "-".repeat(header.length + 20);
117
+ const rows = results.map((n) => {
118
+ const summary = n.summary.length > 80 ? n.summary.slice(0, 77) + "..." : n.summary;
119
+ return `${n.kind.padEnd(kindWidth)} ${n.id.padEnd(idWidth)} ${n.title} \u2014 ${summary}`;
120
+ });
121
+ return [header, divider, ...rows].join("\n");
122
+ }
123
+ function formatJson(input) {
124
+ const envelope = {
125
+ path: input.path,
126
+ mount: input.parsed.mount,
127
+ args: input.parsed.args,
128
+ results: input.results
129
+ };
130
+ return JSON.stringify(envelope, null, 2);
131
+ }
132
+ function formatIdsOnly(results) {
133
+ if (results.length === 0) return "";
134
+ const ids = results.map((r) => typeof r === "string" ? r : r.id);
135
+ return ids.join("\n");
136
+ }
137
+
138
+ export { byFeature, byKind, byOwner, formatIdsOnly, formatJson, formatText, governedBy, governs, parsePath };