Closed mspaulik closed 1 year ago
@mspaulik I updated everything to use the latest cadl. I'm not sure what version you're using over there, but what's here should work with 0.37.x and above. I don't think I regressed any functionality, can you take a look and see? You will need to npm install
after you pull the changes.
There are I think two notable changes in the new versions of Cadl since this package was authored:
extern dec
declarations, see rdf.cadl
for an example. This gives you nice intellisense and makes validation easier:
scalar
- previously, types like integers were just models. Now they are scalars, which actually more closely aligns with how RDF works and so I think this was overall a simplification.There were a few other modifications I made to remove usage of deprecated APIs. Anyway, try it out and let me know what you think.
Hey @bterlson
I did look over - everything makes sense. Thanks!
Just maybe one thing until we merge this PR: I seem to be unable to specify @ispii decorator without providing value (true or false). I remember you saying that once this line is written like that context.call($extension, target, "x-ms-pii", isPii ?? true); , we should be able to use decorator without passing any values.
However, I am still getting this issue : Expected 2 arguments, but got 1.Cadl(invalid-argument-count) for this model: @isPii model Person { name: string; color: Colors; }
Hey @bterlson ,
One more question regarding cadl-project.yaml. How do you specify the output folder?
Because if I dont have "cadl-output" folder manually created before running emitter, I am getting this error: _Unhandled promise rejection! Internal compiler error! File issue at https://github.com/microsoft/cadl
[Error: ENOENT: no such file or directory, open 'C:\Users\Administrator\Desktop\cadl-rdf\cadl-rdfs\cadl-output\models.ttl'] { errno: -4058, code: 'ENOENT', syscall: 'open', path: 'C:\Users\Administrator\Desktop\cadl-rdf\cadl-rdfs\cadl-output\models.ttl' }_
However, if I create "cadl-output" folder - the emitter puts the result successfully in there.
So, I guess, we need some extra line in cadl-project.yaml to handle this? Thanks!
You can use the emitFile
function from the compiler, and it will handle creating the parent directories for you. It looks something like:
import { emitFile } from "@cadl-lang/compiler";
await emitFile(program, { path: "cadl-output/whatever.rdf", content: "...." });
Hmm, I can't repro the issue you point out with @isPii
. If I check out this branch and build, the sample.cadl
file emits the expected output... Can you give me more precise repro steps or maybe double-check that you were checking against the latest code in this branch? Might try starting from a clean repo also, in case there are stale things sitting around.
Hey @bterlson ,
I ran again isPii decorator - all works fine now, I probably did not compile index.ts correctly before. We should be able to merge now?
@bterlson Pii custom decorator still does not work I believe. Could you have a look into that and I am happy to merge then?