Skip to content

Commit 048fe8d

Browse files
committed
Update package.json to include license and keywords, modify formatting scripts to use oxfmt, and ensure consistency in pnpm-workspace.yaml. Refactor README for improved clarity and conciseness. Enhance vitest.config.ts and CI workflow with format check step. Clean up code formatting across various files for better readability.
1 parent 4ae8e61 commit 048fe8d

324 files changed

Lines changed: 8742 additions & 18463 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
- name: Lint
3636
run: pnpm run lint
3737

38+
- name: Format check
39+
run: pnpm run format:check
40+
3841
- name: Build
3942
run: pnpm run build
4043

.oxfmtrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"ignorePatterns": ["**/grammar.js", "**/grammar.d.ts"]
4+
}

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ const bob = graph.addVertex("Person", { name: "Bob", age: 25 });
6868
graph.addEdge(alice, "knows", bob, {});
6969

7070
// 4. Query with Cypher
71-
const results = graph.query(
72-
"MATCH (a:Person)-[:knows]->(b:Person) RETURN a.name, b.name",
73-
);
71+
const results = graph.query("MATCH (a:Person)-[:knows]->(b:Person) RETURN a.name, b.name");
7472
// [{ a: { name: "Alice" }, b: { name: "Bob" } }]
7573
```
7674

@@ -286,7 +284,7 @@ pnpm install
286284
| `pnpm typecheck` | Type-check all packages |
287285
| `pnpm lint` | Lint with oxlint |
288286
| `pnpm lint:fix` | Lint and auto-fix |
289-
| `pnpm format` | Format with Prettier |
287+
| `pnpm format` | Format with oxfmt |
290288
| `pnpm format:check` | Check formatting |
291289

292290
### Package-level commands

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"name": "@codemix/graph-monorepo",
33
"version": "1.0.0",
4+
"private": true,
45
"description": "The codemix graph database monorepo",
6+
"keywords": [],
7+
"license": "MIT",
58
"workspaces": [
69
"packages/*"
710
],
@@ -12,16 +15,13 @@
1215
"test:coverage": "vitest run --coverage",
1316
"lint": "oxlint --ignore-pattern '**/grammar.js' .",
1417
"lint:fix": "pnpm run lint --fix",
15-
"format": "prettier --write .",
16-
"format:check": "prettier --check ."
18+
"format": "oxfmt --write .",
19+
"format:check": "oxfmt --check ."
1720
},
18-
"keywords": [],
19-
"license": "MIT",
20-
"private": true,
2121
"devDependencies": {
2222
"@vitest/coverage-istanbul": "catalog:",
23-
"oxlint": "^1.59.0",
2423
"oxfmt": "^0.44.0",
24+
"oxlint": "^1.59.0",
2525
"typescript": "catalog:",
2626
"vitest": "catalog:"
2727
}

packages/graph/README.md

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ pnpm add @codemix/graph
6666
## Quick Start
6767

6868
```ts
69-
import {
70-
Graph,
71-
GraphSchema,
72-
InMemoryGraphStorage,
73-
GraphTraversal,
74-
} from "@codemix/graph";
69+
import { Graph, GraphSchema, InMemoryGraphStorage, GraphTraversal } from "@codemix/graph";
7570
import * as v from "valibot"; // any Standard Schema library
7671

7772
const schema = {
@@ -229,12 +224,7 @@ graph.deleteEdge(edge);
229224
Use `parseQueryToSteps` to compile a Cypher string and get back executable steps plus a result mapper:
230225

231226
```ts
232-
import {
233-
Graph,
234-
InMemoryGraphStorage,
235-
parseQueryToSteps,
236-
GraphTraversal,
237-
} from "@codemix/graph";
227+
import { Graph, InMemoryGraphStorage, parseQueryToSteps, GraphTraversal } from "@codemix/graph";
238228

239229
const { steps, postprocess } = parseQueryToSteps(
240230
"MATCH (p:Person)-[:ACTED_IN]->(m:Movie) WHERE p.name = $name RETURN p.name, m.title",
@@ -377,12 +367,7 @@ g.V()
377367
### Labeling and Selection
378368

379369
```ts
380-
g.V()
381-
.hasLabel("Person")
382-
.as("actor")
383-
.out("ACTED_IN")
384-
.as("movie")
385-
.select("actor", "movie");
370+
g.V().hasLabel("Person").as("actor").out("ACTED_IN").as("movie").select("actor", "movie");
386371
// yields { actor: TraversalPath, movie: TraversalPath }
387372
```
388373

@@ -510,11 +495,7 @@ Duplicate inserts into a unique-indexed property throw `UniqueConstraintViolatio
510495
**Server side:**
511496

512497
```ts
513-
import {
514-
Graph,
515-
InMemoryGraphStorage,
516-
handleAsyncCommand,
517-
} from "@codemix/graph";
498+
import { Graph, InMemoryGraphStorage, handleAsyncCommand } from "@codemix/graph";
518499

519500
const graph = new Graph({ schema, storage: new InMemoryGraphStorage() });
520501

@@ -553,12 +534,7 @@ for await (const path of remote.query((g) => g.V().hasLabel("Person"))) {
553534
Implement the `GraphStorage` interface to plug in any backend:
554535

555536
```ts
556-
import {
557-
GraphStorage,
558-
StoredVertex,
559-
StoredEdge,
560-
ElementId,
561-
} from "@codemix/graph";
537+
import { GraphStorage, StoredVertex, StoredEdge, ElementId } from "@codemix/graph";
562538

563539
class MyStorage implements GraphStorage {
564540
getVertexById(id: ElementId): StoredVertex | undefined {
@@ -612,10 +588,7 @@ const graph = new Graph({ schema, storage: new MyStorage() });
612588
Generate a human (or LLM) readable description of the query language and your schema for use in prompts or documentation:
613589

614590
```ts
615-
import {
616-
generateGrammarDescription,
617-
generateSchemaGuide,
618-
} from "@codemix/graph";
591+
import { generateGrammarDescription, generateSchemaGuide } from "@codemix/graph";
619592

620593
// Language grammar description (schema-agnostic)
621594
const grammar = generateGrammarDescription();

packages/graph/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"name": "@codemix/graph",
33
"version": "0.0.1",
44
"description": "The codemix graph database.",
5+
"license": "MIT",
56
"type": "module",
7+
"types": "./dist/index.d.ts",
68
"exports": {
79
".": {
810
"import": {
@@ -11,23 +13,21 @@
1113
}
1214
}
1315
},
14-
"types": "./dist/index.d.ts",
15-
"license": "MIT",
1616
"scripts": {
1717
"build": "pnpm run build:grammar && tsc",
1818
"build:grammar": "peggy --format es src/grammar.peggy -o src/grammar.js --dts --return-types '{\"MultiStatement\": \"import('\\''./AST.js'\\'').Query | import('\\''./AST.js'\\'').UnionQuery | import('\\''./AST.js'\\'').MultiStatement\", \"CypherStatement\": \"import('\\''./AST.js'\\'').Query | import('\\''./AST.js'\\'').UnionQuery\"}' && mkdir -p dist && cp src/grammar.* dist",
1919
"typecheck": "tsc --noEmit",
2020
"test": "vitest",
2121
"test:coverage": "vitest run --coverage"
2222
},
23-
"devDependencies": {
24-
"@vitest/coverage-istanbul": "catalog:",
25-
"vitest": "catalog:",
26-
"typescript": "catalog:",
27-
"peggy": "^5.1.0"
28-
},
2923
"dependencies": {
3024
"@codemix/text-search": "workspace:*",
3125
"@standard-schema/spec": "^1.1.0"
26+
},
27+
"devDependencies": {
28+
"@vitest/coverage-istanbul": "catalog:",
29+
"peggy": "^5.1.0",
30+
"typescript": "catalog:",
31+
"vitest": "catalog:"
3232
}
3333
}

packages/graph/scripts/tck-audit.ts

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -119,22 +119,16 @@ function extractSkippedTests(filePath: string): SkippedTest[] {
119119
const fullTestName = match[1];
120120
// Extract reason after the last " - "
121121
const lastDashIndex = fullTestName.lastIndexOf(" - ");
122-
const skipReason =
123-
lastDashIndex > 0 ? fullTestName.slice(lastDashIndex + 3) : "";
124-
const testName =
125-
lastDashIndex > 0 ? fullTestName.slice(0, lastDashIndex) : fullTestName;
122+
const skipReason = lastDashIndex > 0 ? fullTestName.slice(lastDashIndex + 3) : "";
123+
const testName = lastDashIndex > 0 ? fullTestName.slice(0, lastDashIndex) : fullTestName;
126124

127125
// Categorize
128126
let category: "design" | "now_working" | "unknown" = "unknown";
129127

130128
const reasonLower = skipReason.toLowerCase();
131-
if (
132-
DESIGN_EXCLUSIONS.some((d) => reasonLower.includes(d.toLowerCase()))
133-
) {
129+
if (DESIGN_EXCLUSIONS.some((d) => reasonLower.includes(d.toLowerCase()))) {
134130
category = "design";
135-
} else if (
136-
NOW_WORKING_PATTERNS.some((p) => reasonLower.includes(p.toLowerCase()))
137-
) {
131+
} else if (NOW_WORKING_PATTERNS.some((p) => reasonLower.includes(p.toLowerCase()))) {
138132
category = "now_working";
139133
}
140134

@@ -180,10 +174,7 @@ function tryRunTest(test: SkippedTest): TestResult {
180174
try {
181175
// Run just this test file with a filter for this specific test
182176
const testPattern = test.testName.replace(/[[\]()]/g, "\\$&");
183-
const relativePath = path.relative(
184-
path.join(import.meta.dirname, ".."),
185-
test.file,
186-
);
177+
const relativePath = path.relative(path.join(import.meta.dirname, ".."), test.file);
187178

188179
const result = spawnSync(
189180
"npx",
@@ -250,10 +241,7 @@ function applyUnskips(results: TestResult[]): void {
250241
/**
251242
* Generate markdown report
252243
*/
253-
function generateReport(
254-
skippedTests: SkippedTest[],
255-
results: TestResult[],
256-
): string {
244+
function generateReport(skippedTests: SkippedTest[], results: TestResult[]): string {
257245
const lines: string[] = [];
258246

259247
lines.push("# TCK Audit Results");
@@ -292,9 +280,7 @@ function generateReport(
292280
// Design exclusions
293281
lines.push("## Design Exclusions (Will Not Be Fixed)");
294282
lines.push("");
295-
lines.push(
296-
"These tests require features that conflict with design decisions:",
297-
);
283+
lines.push("These tests require features that conflict with design decisions:");
298284
lines.push("");
299285
for (const test of design.slice(0, 20)) {
300286
const relPath = path.relative(TCK_DIR, test.file);
@@ -308,9 +294,7 @@ function generateReport(
308294
// Now working candidates
309295
lines.push('## Candidates: Citing "Now Working" Features');
310296
lines.push("");
311-
lines.push(
312-
"These tests cite features that are now implemented. They should be verified:",
313-
);
297+
lines.push("These tests cite features that are now implemented. They should be verified:");
314298
lines.push("");
315299
for (const test of nowWorking.slice(0, 30)) {
316300
const relPath = path.relative(TCK_DIR, test.file);
@@ -327,9 +311,7 @@ function generateReport(
327311
lines.push("");
328312
for (const result of passed) {
329313
const relPath = path.relative(TCK_DIR, result.test.file);
330-
lines.push(
331-
`- \`${relPath}:${result.test.lineNumber}\`: ${result.test.testName}`,
332-
);
314+
lines.push(`- \`${relPath}:${result.test.lineNumber}\`: ${result.test.testName}`);
333315
}
334316
lines.push("");
335317
}
@@ -382,15 +364,11 @@ async function main(): Promise<void> {
382364
allSkipped.push(...extractSkippedTests(file));
383365
}
384366
console.log(`Found ${allSkipped.length} skipped tests`);
385-
console.log(
386-
` - Design exclusions: ${allSkipped.filter((t) => t.category === "design").length}`,
387-
);
367+
console.log(` - Design exclusions: ${allSkipped.filter((t) => t.category === "design").length}`);
388368
console.log(
389369
` - Now working candidates: ${allSkipped.filter((t) => t.category === "now_working").length}`,
390370
);
391-
console.log(
392-
` - Unknown: ${allSkipped.filter((t) => t.category === "unknown").length}`,
393-
);
371+
console.log(` - Unknown: ${allSkipped.filter((t) => t.category === "unknown").length}`);
394372
console.log("");
395373

396374
let results: TestResult[] = [];

packages/graph/src/AST.ts

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,7 @@ export interface CreateChainPattern {
196196
elements: CreateChainElement[];
197197
}
198198

199-
export type CreateChainElement =
200-
| CreateNodePattern
201-
| CreateVariableRef
202-
| CreateEdgePattern;
199+
export type CreateChainElement = CreateNodePattern | CreateVariableRef | CreateEdgePattern;
203200

204201
export interface CreateEdgePattern {
205202
type: "CreateEdgePattern";
@@ -346,11 +343,7 @@ export interface ForeachClause {
346343
operations: ForeachOperation[];
347344
}
348345

349-
export type ListExpression =
350-
| PropertyAccess
351-
| ListLiteralExpr
352-
| FunctionCall
353-
| VariableRef;
346+
export type ListExpression = PropertyAccess | ListLiteralExpr | FunctionCall | VariableRef;
354347

355348
export interface PropertyAccess {
356349
type: "PropertyAccess";
@@ -501,10 +494,7 @@ export interface MultiPattern {
501494
patterns: Pattern[];
502495
}
503496

504-
export type PatternElement =
505-
| NodePattern
506-
| EdgePattern
507-
| ParenthesizedPathPattern;
497+
export type PatternElement = NodePattern | EdgePattern | ParenthesizedPathPattern;
508498

509499
export interface NodePattern {
510500
type: "NodePattern";
@@ -529,11 +519,7 @@ export interface NestedMap {
529519
* Parameter references (e.g., $name) are resolved at query execution time.
530520
* Nested maps allow object-valued properties like {schema: {type: "string"}}.
531521
*/
532-
export type PropertyValue =
533-
| Literal
534-
| ParameterRef
535-
| NestedMap
536-
| ListLiteralExpr;
522+
export type PropertyValue = Literal | ParameterRef | NestedMap | ListLiteralExpr;
537523

538524
/**
539525
* Property map for node and relationship patterns.
@@ -563,12 +549,7 @@ export interface Quantifier {
563549

564550
// Advanced label expressions for complex label matching
565551
// Supports: :A|B (OR), :A&B (AND), :!A (NOT), :% (wildcard), parenthesized
566-
export type LabelExpression =
567-
| LabelName
568-
| LabelOr
569-
| LabelAnd
570-
| LabelNot
571-
| LabelWildcard;
552+
export type LabelExpression = LabelName | LabelOr | LabelAnd | LabelNot | LabelWildcard;
572553

573554
/** Single label identifier */
574555
export interface LabelName {

packages/graph/src/AsyncGraph.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
import { Graph } from "./Graph.js";
22
import { GraphSchema } from "./GraphSchema.js";
3-
import {
4-
ElementId,
5-
InMemoryGraphStorage,
6-
StoredEdge,
7-
StoredVertex,
8-
} from "./GraphStorage.js";
3+
import { ElementId, InMemoryGraphStorage, StoredEdge, StoredVertex } from "./GraphStorage.js";
94
import { createStepsFromJSON, createTraverser, StepJSON } from "./Steps.js";
10-
import {
11-
GraphTraversal,
12-
Traversal,
13-
TraversalPath,
14-
TraversalPathJSON,
15-
} from "./Traversals.js";
5+
import { GraphTraversal, Traversal, TraversalPath, TraversalPathJSON } from "./Traversals.js";
166

177
/**
188
* Serialize a value to JSON and back. Alias for JSON.parse(JSON.stringify(value)).
@@ -127,9 +117,7 @@ export class AsyncGraph<const TSchema extends GraphSchema> {
127117
value = this.instantiateResult(value);
128118
}
129119
return new TraversalPath(
130-
result.parent == null
131-
? undefined
132-
: this.instantiateResult(result.parent),
120+
result.parent == null ? undefined : this.instantiateResult(result.parent),
133121
value,
134122
result.labels,
135123
) as TPath;
@@ -248,11 +236,7 @@ function* handleAsyncTransaction<TSchema extends GraphSchema>(
248236
break;
249237
}
250238
case "UpdatePropertyOperation": {
251-
graph.storage.updateProperty(
252-
operation.id,
253-
operation.key,
254-
operation.value,
255-
);
239+
graph.storage.updateProperty(operation.id, operation.key, operation.value);
256240
yield {
257241
"@type": "AsyncOperationSuccess",
258242
};

0 commit comments

Comments
 (0)