@zabaca/lattice 0.3.2 → 0.3.3

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 (2) hide show
  1. package/dist/main.js +0 -175
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -106,55 +106,6 @@ class GraphService {
106
106
  throw error;
107
107
  }
108
108
  }
109
- async getStats() {
110
- try {
111
- const labels = await this.getLabels();
112
- const relationshipTypes = await this.getRelationshipTypes();
113
- const nodeCountResult = await this.query("MATCH (n) RETURN count(n) as count");
114
- const nodeCount = nodeCountResult.resultSet?.[0]?.[0] || 0;
115
- const edgeCountResult = await this.query("MATCH ()-[r]-() RETURN count(r) as count");
116
- const edgeCount = edgeCountResult.resultSet?.[0]?.[0] || 0;
117
- const entityCounts = {};
118
- for (const label of labels) {
119
- const result = await this.query(`MATCH (n:\`${label}\`) RETURN count(n) as count`);
120
- entityCounts[label] = result.resultSet?.[0]?.[0] || 0;
121
- }
122
- const relationshipCounts = {};
123
- for (const relType of relationshipTypes) {
124
- const result = await this.query(`MATCH ()-[r:\`${relType}\`]-() RETURN count(r) as count`);
125
- relationshipCounts[relType] = result.resultSet?.[0]?.[0] || 0;
126
- }
127
- return {
128
- nodeCount,
129
- edgeCount,
130
- labels,
131
- relationshipTypes,
132
- entityCounts,
133
- relationshipCounts
134
- };
135
- } catch (error) {
136
- this.logger.error(`Failed to get stats: ${error instanceof Error ? error.message : String(error)}`);
137
- throw error;
138
- }
139
- }
140
- async getLabels() {
141
- try {
142
- const result = await this.query("CALL db.labels() YIELD label RETURN label");
143
- return (result.resultSet || []).map((row) => row[0]);
144
- } catch (error) {
145
- this.logger.error(`Failed to get labels: ${error instanceof Error ? error.message : String(error)}`);
146
- return [];
147
- }
148
- }
149
- async getRelationshipTypes() {
150
- try {
151
- const result = await this.query("CALL db.relationshipTypes() YIELD relationshipType RETURN relationshipType");
152
- return (result.resultSet || []).map((row) => row[0]);
153
- } catch (error) {
154
- this.logger.error(`Failed to get relationship types: ${error instanceof Error ? error.message : String(error)}`);
155
- return [];
156
- }
157
- }
158
109
  async upsertNode(label, properties) {
159
110
  try {
160
111
  const { name, ...otherProps } = properties;
@@ -2445,51 +2396,6 @@ StatusCommand = __legacyDecorateClassTS([
2445
2396
  // src/commands/query.command.ts
2446
2397
  import { Injectable as Injectable12 } from "@nestjs/common";
2447
2398
  import { Command as Command3, CommandRunner as CommandRunner3, Option as Option3 } from "nest-commander";
2448
- class StatsCommand extends CommandRunner3 {
2449
- graphService;
2450
- constructor(graphService) {
2451
- super();
2452
- this.graphService = graphService;
2453
- }
2454
- async run() {
2455
- try {
2456
- const stats = await this.graphService.getStats();
2457
- console.log(`
2458
- === Graph Statistics ===
2459
- `);
2460
- console.log(`Total Nodes: ${stats.nodeCount}`);
2461
- console.log(`Total Relationships: ${stats.edgeCount}
2462
- `);
2463
- console.log(`Node Labels (${stats.labels.length}):`);
2464
- stats.labels.forEach((label) => {
2465
- const count = stats.entityCounts[label] || 0;
2466
- console.log(` - ${label}: ${count}`);
2467
- });
2468
- console.log(`
2469
- Relationship Types (${stats.relationshipTypes.length}):`);
2470
- stats.relationshipTypes.forEach((relType) => {
2471
- const count = stats.relationshipCounts[relType] || 0;
2472
- console.log(` - ${relType}: ${count}`);
2473
- });
2474
- console.log();
2475
- process.exit(0);
2476
- } catch (error) {
2477
- console.error("Error:", error instanceof Error ? error.message : String(error));
2478
- process.exit(1);
2479
- }
2480
- }
2481
- }
2482
- StatsCommand = __legacyDecorateClassTS([
2483
- Injectable12(),
2484
- Command3({
2485
- name: "stats",
2486
- description: "Show graph statistics"
2487
- }),
2488
- __legacyMetadataTS("design:paramtypes", [
2489
- typeof GraphService === "undefined" ? Object : GraphService
2490
- ])
2491
- ], StatsCommand);
2492
-
2493
2399
  class SearchCommand extends CommandRunner3 {
2494
2400
  graphService;
2495
2401
  embeddingService;
@@ -2698,85 +2604,6 @@ CypherCommand = __legacyDecorateClassTS([
2698
2604
  typeof GraphService === "undefined" ? Object : GraphService
2699
2605
  ])
2700
2606
  ], CypherCommand);
2701
-
2702
- class RelatedCommand extends CommandRunner3 {
2703
- graphService;
2704
- pathResolverService;
2705
- constructor(graphService, pathResolverService) {
2706
- super();
2707
- this.graphService = graphService;
2708
- this.pathResolverService = pathResolverService;
2709
- }
2710
- async run(inputs, options) {
2711
- const path = inputs[0];
2712
- const limit = Math.min(parseInt(options.limit || "10", 10), 50);
2713
- try {
2714
- const absolutePath = this.pathResolverService.resolveDocPath(path, {
2715
- requireExists: true,
2716
- requireInDocs: true
2717
- });
2718
- const escapedPath = absolutePath.replace(/'/g, "\\'");
2719
- const cypher = `
2720
- MATCH (d:Document { name: '${escapedPath}' })<-[:APPEARS_IN]-(e)-[:APPEARS_IN]->(other:Document)
2721
- WHERE other.name <> '${escapedPath}'
2722
- RETURN DISTINCT other.name as path, other.title as title, count(e) as shared
2723
- ORDER BY shared DESC
2724
- LIMIT ${limit}
2725
- `;
2726
- const result = await this.graphService.query(cypher);
2727
- const results = result.resultSet || [];
2728
- console.log(`
2729
- === Documents Related to "${path}" ===
2730
- `);
2731
- if (results.length === 0) {
2732
- console.log(`No related documents found.
2733
- `);
2734
- process.exit(0);
2735
- }
2736
- results.forEach((row) => {
2737
- const docPath = row[0];
2738
- const title = row[1];
2739
- const shared = row[2];
2740
- console.log(`[${shared} shared entities] ${docPath}`);
2741
- if (title) {
2742
- console.log(` Title: ${title}`);
2743
- }
2744
- });
2745
- console.log();
2746
- process.exit(0);
2747
- } catch (error) {
2748
- console.error("Error:", error instanceof Error ? error.message : String(error));
2749
- process.exit(1);
2750
- }
2751
- }
2752
- parseLimit(value) {
2753
- return value;
2754
- }
2755
- }
2756
- __legacyDecorateClassTS([
2757
- Option3({
2758
- flags: "--limit <n>",
2759
- description: "Limit results",
2760
- defaultValue: "10"
2761
- }),
2762
- __legacyMetadataTS("design:type", Function),
2763
- __legacyMetadataTS("design:paramtypes", [
2764
- String
2765
- ]),
2766
- __legacyMetadataTS("design:returntype", String)
2767
- ], RelatedCommand.prototype, "parseLimit", null);
2768
- RelatedCommand = __legacyDecorateClassTS([
2769
- Injectable12(),
2770
- Command3({
2771
- name: "related",
2772
- arguments: "<path>",
2773
- description: "Find documents related to the given document"
2774
- }),
2775
- __legacyMetadataTS("design:paramtypes", [
2776
- typeof GraphService === "undefined" ? Object : GraphService,
2777
- typeof PathResolverService === "undefined" ? Object : PathResolverService
2778
- ])
2779
- ], RelatedCommand);
2780
2607
  // src/commands/validate.command.ts
2781
2608
  import { Injectable as Injectable13 } from "@nestjs/common";
2782
2609
  import { Command as Command4, CommandRunner as CommandRunner4, Option as Option4 } from "nest-commander";
@@ -3013,11 +2840,9 @@ AppModule = __legacyDecorateClassTS([
3013
2840
  providers: [
3014
2841
  SyncCommand,
3015
2842
  StatusCommand,
3016
- StatsCommand,
3017
2843
  SearchCommand,
3018
2844
  RelsCommand,
3019
2845
  CypherCommand,
3020
- RelatedCommand,
3021
2846
  ValidateCommand,
3022
2847
  OntologyCommand,
3023
2848
  InitCommand
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zabaca/lattice",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Human-initiated, AI-powered knowledge graph for markdown documentation",
5
5
  "type": "module",
6
6
  "bin": {