Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
80fa60c
starting work towards yaml validator in monorepo
cscheid May 13, 2024
093a5b8
more partial work towards external yaml annotated parser
cscheid May 13, 2024
e9d256b
more partial work
cscheid May 13, 2024
1df836b
more partial work
cscheid May 13, 2024
2041f22
now with esbuild outputs
cscheid May 13, 2024
eef4924
now with more exports
cscheid May 13, 2024
61f2443
more
cscheid May 13, 2024
c552f3d
Merge branch 'main' into library/validator
cscheid Jun 5, 2025
3c63d7a
Merge branch 'main' into library/validator
cscheid Jun 17, 2025
33324c9
make 0.1.1 a public version at @quarto/tidyverse-errors
cscheid Jun 17, 2025
dfdd60b
make 0.1.0 a public version at @quarto/mapped-string
cscheid Jun 17, 2025
59b104b
fix typo
cscheid Jun 17, 2025
d6ad833
make 0.1.0 a public version at @quarto/annotated-json
cscheid Jun 17, 2025
b55d0c1
make 0.1.0 a public version at @quarto/json-validator
cscheid Jun 17, 2025
8f4cb31
updates
cscheid Jun 17, 2025
b4e043b
more fixes
cscheid Jun 17, 2025
476fad3
basic tests + claude prompt
cscheid Jun 17, 2025
23756e8
lockfile
cscheid Jun 17, 2025
465e63e
add claude prompt, add tests, fix bugs
cscheid Jun 17, 2025
fbbc3a2
bump versions
cscheid Jun 17, 2025
9d336b7
try different export type syntax
cscheid Jun 18, 2025
2d594f4
make it work on deno imports
cscheid Jun 18, 2025
ecd601f
partial commit, annotated-json doesn't test properly
cscheid Jun 18, 2025
d5bde38
remove spurious differences in configuration
cscheid Jun 18, 2025
1b2bf47
remove spurious differences in configuration
cscheid Jun 18, 2025
dbcf0e2
reinstate tests
cscheid Jun 18, 2025
ef933c2
bump package version
cscheid Jun 18, 2025
f1a8e0e
bump version, fix build
cscheid Jun 18, 2025
a336e77
minimal tests
cscheid Jun 18, 2025
8296423
bump version from new exports
cscheid Jun 18, 2025
dc61e87
merge
cscheid Jun 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/annotated-json/claude.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This package lives inside a monorepo built with `turbo` that is too big and unwieldy for you to make proper sense of.

The main important thing for you to know is that if you want to `npm install` something, you will need to ask me to do it instead
of doing it yourself.

## Reading check

I need to make sure you will always read this file and do what I ask you. So let's do it like Van Halen did on their performance contract.
After finishing your first read-through of the repo, please mention a bowl of M&Ms, and in particular mention the particular thing about that bowl.
Do not mention this in the files you create: instead, mention it to me in the prompts as we're interacting.
30 changes: 22 additions & 8 deletions packages/annotated-json/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@quarto/annotated-json",
"version": "0.1.2",
"version": "0.1.3",
"description": "A data structure for storing and manipulation a JSON object together with source locations of its constituent parts.",
"license": "MIT",
"author": {
"name": "Posit PBC"
},
Expand All @@ -13,14 +14,27 @@
"type": "git",
"url": "git+https://github.com/quarto-dev/quarto.git"
},
"license": "MIT",
"main": "./src/index.ts",
"types": "./src/index.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.js"
}
},
"files": ["dist"],
"dependencies": {
"@quarto/mapped-string": "^0.1.2",
"@quarto/tidyverse-errors": "^0.1.2",
"tsconfig": "*",
"typescript": "^5.4.2"
"typescript": "^5.4.2",
"@quarto/mapped-string": "^0.1.7",
"@quarto/tidyverse-errors": "^0.1.3"
},
"devDependencies": {
"tsx": "^4.7.1"
},
"devDependencies": { }
"scripts": {
"build": "tsc",
"test": "node --import tsx --test test/*.test.ts"
}
}
4 changes: 2 additions & 2 deletions packages/annotated-json/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
* SOFTWARE.
*/

export * from "./types";
export * from "./annotated-yaml";
export type * from "./types";
export * from "./annotated-yaml";
43 changes: 43 additions & 0 deletions packages/annotated-json/test/basic.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { test } from "node:test";
import { strict as assert } from "node:assert";
import { parse } from "../src/index";

test("parse simple YAML string", () => {
const result = parse("hello: world");
assert.equal(result.result.hello, "world");
assert.equal(result.start, 0);
assert.ok(result.end > 0);
});

test("parse YAML with nested structure", () => {
const yamlContent = `
name: test
config:
debug: true
port: 8080
`;
const result = parse(yamlContent);
assert.equal(result.result.name, "test");
assert.equal(result.result.config.debug, true);
assert.equal(result.result.config.port, 8080);
});

test("parse YAML array", () => {
const yamlContent = `
items:
- apple
- banana
- cherry
`;
const result = parse(yamlContent);
assert.ok(Array.isArray(result.result.items));
assert.equal(result.result.items.length, 3);
assert.equal(result.result.items[0], "apple");
});

test("annotation contains source information", () => {
const result = parse("test: value");
assert.ok(result.source);
assert.ok(result.components);
assert.ok(result.components.length > 0);
});
9 changes: 8 additions & 1 deletion packages/annotated-json/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
"extends": "tsconfig/base.json",
"include": ["src"],
"compilerOptions": {
"allowJs": true,
"declaration": true,
"declarationMap": true,
"rootDir": "./src",
"outDir": "./dist",
"module": "commonjs",
"esModuleInterop": true,
"target": "es2018",
"moduleResolution": "node",
"allowJs": true
},
}
28 changes: 21 additions & 7 deletions packages/json-validator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@quarto/json-validator",
"version": "0.1.3",
"version": "0.1.5",
"description": "A validation library for JSON objects with an emphasis on good error messages.",
"author": {
"name": "Posit PBC"
Expand All @@ -14,16 +14,30 @@
"url": "git+https://github.com/quarto-dev/quarto.git"
},
"license": "MIT",
"main": "./src/index.ts",
"types": "./src/index.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.js"
}
},
"files": ["dist"],
"dependencies": {
"tsconfig": "*",
"build": "*",
"typescript": "^5.4.2",
"regexpp": "^3.2.0",
"@quarto/mapped-string": "^0.1.2",
"@quarto/tidyverse-errors": "^0.1.2",
"@quarto/annotated-json": "^0.1.2"
"@quarto/mapped-string": "^0.1.7",
"@quarto/tidyverse-errors": "^0.1.3",
"@quarto/annotated-json": "^0.1.3"
},
"devDependencies": {
"tsx": "^4.7.1"
},
"devDependencies": { }
"scripts": {
"build": "tsc",
"test": "node --import tsx --test test/*.test.ts"
}
}
2 changes: 1 addition & 1 deletion packages/json-validator/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as colors from "ansi-colors";

import { YAMLSchemaT } from "./types";

import { quotedStringColor, TidyverseError } from "tidyverse-errors";
import { quotedStringColor, TidyverseError } from "@quarto/tidyverse-errors";

import {
editDistance, // this truly needs to be in a separate package
Expand Down
4 changes: 2 additions & 2 deletions packages/json-validator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

export * from "./validator";
export * from "./types";
export type * from "./types";
export * from "./schema";
export * from "./validator-queue";
export { initState, setInitializer } from "./state";
export { asMappedString } from "@quarto/mapped-string";
2 changes: 1 addition & 1 deletion packages/json-validator/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ErrorLocation, MappedString } from "@quarto/mapped-string";
import {
AnnotatedParse,
JSONValue
} from "annotated-json";
} from "@quarto/annotated-json";

export interface ValidatedParseResult {
result: JSONValue;
Expand Down
4 changes: 1 addition & 3 deletions packages/json-validator/src/validator-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import { YAMLSchema } from "./yaml-schema";

import { setDefaultErrorHandlers } from "./errors";

import { ValidatorErrorHandlerFunction } from "./types";

import { RefSchema, Schema, schemaType } from "./types";
import { ValidatorErrorHandlerFunction, RefSchema, Schema, schemaType } from "./types";

const yamlValidators: Record<string, YAMLSchema> = {};

Expand Down
2 changes: 1 addition & 1 deletion packages/json-validator/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import {
AnnotatedParse, JSONValue
} from "annotated-json";
} from "@quarto/annotated-json";

import {
AllOfSchema,
Expand Down
10 changes: 3 additions & 7 deletions packages/json-validator/src/yaml-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@
*/

import { MappedString } from "@quarto/mapped-string";

import { TidyverseError } from "tidyverse-errors";
import { ValidatorErrorHandlerFunction } from "./types";
import { TidyverseError } from "@quarto/tidyverse-errors";
import { AnnotatedParse } from "@quarto/annotated-json";

import { validate } from "./validator";
import { ValidatedParseResult } from "./types";

import { AnnotatedParse } from "annotated-json";
import {
LocalizedError,
ValidatorErrorHandlerFunction, ValidatedParseResult, LocalizedError,
Schema,
} from "./types";

Expand Down
32 changes: 32 additions & 0 deletions packages/json-validator/test/basic.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { test } from "node:test";
import { strict as assert } from "node:assert";

import { parse } from "@quarto/annotated-json";
import { withValidator } from "../src/index";
import { Schema } from "../src/types";
import { asMappedString } from "@quarto/mapped-string";

test("parse simple YAML string", async () => {
const yamlString = asMappedString(`
name: John Doe
age: 30
`);
const parsed = parse(yamlString);
const schema1: Schema = {
"$id": "object-schema",
"type": "object"
};
const schema2: Schema = {
"$id": "number-schema",
"type": "number"
};

await withValidator(schema1, async (validator) => {
const result = await validator.validateParse(yamlString, parsed);
assert.equal(result.errors.length, 0);
});
await withValidator(schema2, async (validator) => {
const result = await validator.validateParse(yamlString, parsed);
assert.equal(result.errors.length, 1);
});
});
11 changes: 9 additions & 2 deletions packages/json-validator/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
"extends": "tsconfig/base.json",
"include": ["src"],
"compilerOptions": {
"allowJs": true,
"declaration": true,
"declarationMap": true,
"rootDir": "./src",
"outDir": "./dist",
"module": "commonjs",
"esModuleInterop": true,
"target": "es2018",
"moduleResolution": "node",
"allowJs": true
},
}
}
16 changes: 12 additions & 4 deletions packages/mapped-string/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@quarto/mapped-string",
"version": "0.1.2",
"version": "0.1.7",
"description": "A string data structure with integrated source maps.",
"license": "MIT",
"author": {
Expand All @@ -14,13 +14,21 @@
"type": "git",
"url": "git+https://github.com/quarto-dev/quarto.git"
},
"main": "./src/index.ts",
"types": "./src/index.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.js"
}
},
"files": ["dist"],
"dependencies": {
"tsconfig": "*",
"typescript": "^5.4.2",
"ansi-colors": "^4.1.3",
"@quarto/tidyverse-errors": "^0.1.2"
"@quarto/tidyverse-errors": "^0.1.3"
},
"devDependencies": {
"tsx": "^4.7.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/mapped-string/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

export * from "./ranged-text";
export * from "./mapped-text";
export * from "./types";
export type * from "./types";
export * from "./error";
export * from "./text";
export * from "./text";
9 changes: 8 additions & 1 deletion packages/mapped-string/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
"extends": "tsconfig/base.json",
"include": ["src"],
"compilerOptions": {
"allowJs": true,
"declaration": true,
"declarationMap": true,
"rootDir": "./src",
"outDir": "./dist",
"module": "commonjs",
"esModuleInterop": true,
"target": "es2018",
"moduleResolution": "node",
"allowJs": true
},
}
15 changes: 12 additions & 3 deletions packages/tidyverse-errors/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@quarto/tidyverse-errors",
"version": "0.1.2",
"version": "0.1.3",
"description": "Format errors using the tidyverse style.",
"author": {
"name": "Posit PBC"
Expand All @@ -14,8 +14,16 @@
"url": "git+https://github.com/quarto-dev/quarto.git"
},
"license": "MIT",
"main": "./src/index.ts",
"types": "./src/index.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.js"
}
},
"files": ["dist"],
"dependencies": {
"tsconfig": "*",
"typescript": "^5.4.2",
Expand All @@ -25,6 +33,7 @@
"tsx": "^4.7.1"
},
"scripts": {
"build": "tsc",
"test": "node --import tsx --test test/*.test.ts"
}
}
Loading