Description
This demo mentioned in README.md seems broken:
Compile back from an updated "simple issue" to a new github issue file:
cat ./demo/simple-issue.json | node ./dist/cli.js -l ./demo/github-arthropod.lens.yml -r -b ./demo/github-issue.json
In practice:
$ cat ./demo/simple-issue.json | node ./dist/cli.js -l ./demo/github-arthropod.lens.yml -r -b ./demo/github-issue.json
./dist/json-schema.js:35
throw new Error(`Missing property name in addProperty.\nFound:\n${JSON.stringify(property)}`);
^
Error: Missing property name in addProperty.
Found:
{"op":"add","name":"labels"}
at addProperty (./dist/json-schema.js:35:15)
at applyLensOperation (./dist/json-schema.js:338:20)
at ./cambria-project/dist/json-schema.js:366:16
at Array.reduce (<anonymous>)
at Object.updateSchema (./dist/json-schema.js:363:17)
at Object.applyLensToDoc (./dist/doc.js:51:40)
at Object.<anonymous> (./dist/cli.js:25:22)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
Cause
github-arthropod.lens.yml defines a valid remove op––no type required:
And reverse.ts just swaps in the add op:
|
case 'remove': |
|
return { |
|
...lensOp, |
|
op: 'add', |
|
} |
But an add op must specify a type! It's the type missing, not the name:
|
if (!name || !type) { |
|
throw new Error(`Missing property name in addProperty.\nFound:\n${JSON.stringify(property)}`) |
|
} |
Solutions
- Require types on
remove ops.
- Set an unrestrictive default type when reversing a
remove op without a type. I sketched that out here, and confirmed the demo works as expected and unit tests pass: lukasschwab@77b602e
- Loosen the commitment to reversibility. This seems incompatible with the project goals.
Let me know if you'd like me to open a PR.
Cool stuff––enjoyed the HYTRADBOI talk!
Description
This demo mentioned in README.md seems broken:
In practice:
Cause
github-arthropod.lens.yml defines a valid
removeop––no type required:cambria-project/demo/github-arthropod.lens.yml
Lines 41 to 42 in da89614
And reverse.ts just swaps in the
addop:cambria-project/src/reverse.ts
Lines 30 to 34 in da89614
But an
addop must specify a type! It's the type missing, not the name:cambria-project/src/json-schema.ts
Lines 35 to 37 in da89614
Solutions
removeops.removeop without a type. I sketched that out here, and confirmed the demo works as expected and unit tests pass: lukasschwab@77b602eLet me know if you'd like me to open a PR.
Cool stuff––enjoyed the HYTRADBOI talk!