@wictorwilen/cocogen 1.0.0

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 (90) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +149 -0
  3. package/RELEASING.md +36 -0
  4. package/THIRD_PARTY_NOTICES.md +11 -0
  5. package/dist/cli.d.ts +3 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +288 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/emit/emit.d.ts +3 -0
  10. package/dist/emit/emit.d.ts.map +1 -0
  11. package/dist/emit/emit.js +13 -0
  12. package/dist/emit/emit.js.map +1 -0
  13. package/dist/index.d.ts +4 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +6 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/init/init.d.ts +34 -0
  18. package/dist/init/init.d.ts.map +1 -0
  19. package/dist/init/init.js +886 -0
  20. package/dist/init/init.js.map +1 -0
  21. package/dist/init/template.d.ts +2 -0
  22. package/dist/init/template.d.ts.map +1 -0
  23. package/dist/init/template.js +19 -0
  24. package/dist/init/template.js.map +1 -0
  25. package/dist/init/templates/dotnet/.env.example.ejs +12 -0
  26. package/dist/init/templates/dotnet/.gitignore.ejs +6 -0
  27. package/dist/init/templates/dotnet/Datasource/CsvItemSource.cs.ejs +42 -0
  28. package/dist/init/templates/dotnet/Datasource/IItemSource.cs.ejs +12 -0
  29. package/dist/init/templates/dotnet/Generated/Constants.cs.ejs +17 -0
  30. package/dist/init/templates/dotnet/Generated/CsvParser.cs.ejs +119 -0
  31. package/dist/init/templates/dotnet/Generated/FromCsvRow.cs.ejs +14 -0
  32. package/dist/init/templates/dotnet/Generated/ItemPayload.cs.ejs +41 -0
  33. package/dist/init/templates/dotnet/Generated/Model.cs.ejs +28 -0
  34. package/dist/init/templates/dotnet/Generated/PersonEntityDefaults.cs.ejs +48 -0
  35. package/dist/init/templates/dotnet/Generated/PropertyTransforms.cs.ejs +22 -0
  36. package/dist/init/templates/dotnet/Generated/SchemaPayload.cs.ejs +18 -0
  37. package/dist/init/templates/dotnet/PersonEntityOverrides.cs.ejs +49 -0
  38. package/dist/init/templates/dotnet/Program.commandline.cs.ejs +426 -0
  39. package/dist/init/templates/dotnet/Program.cs.ejs +487 -0
  40. package/dist/init/templates/dotnet/README.md.ejs +56 -0
  41. package/dist/init/templates/dotnet/appsettings.json.ejs +21 -0
  42. package/dist/init/templates/dotnet/package.json.ejs +7 -0
  43. package/dist/init/templates/dotnet/project.csproj.ejs +29 -0
  44. package/dist/init/templates/dotnet/tspconfig.yaml.ejs +2 -0
  45. package/dist/init/templates/ts/.env.example.ejs +20 -0
  46. package/dist/init/templates/ts/README.md.ejs +54 -0
  47. package/dist/init/templates/ts/package.json.ejs +25 -0
  48. package/dist/init/templates/ts/src/cli.ts.ejs +299 -0
  49. package/dist/init/templates/ts/src/datasource/csvItemSource.ts.ejs +25 -0
  50. package/dist/init/templates/ts/src/datasource/itemSource.ts.ejs +8 -0
  51. package/dist/init/templates/ts/src/generated/constants.ts.ejs +10 -0
  52. package/dist/init/templates/ts/src/generated/csv.ts.ejs +44 -0
  53. package/dist/init/templates/ts/src/generated/fromCsvRow.ts.ejs +43 -0
  54. package/dist/init/templates/ts/src/generated/index.ts.ejs +5 -0
  55. package/dist/init/templates/ts/src/generated/itemPayload.ts.ejs +21 -0
  56. package/dist/init/templates/ts/src/generated/model.ts.ejs +16 -0
  57. package/dist/init/templates/ts/src/generated/personEntityDefaults.ts.ejs +33 -0
  58. package/dist/init/templates/ts/src/generated/propertyTransforms.ts.ejs +23 -0
  59. package/dist/init/templates/ts/src/generated/schemaPayload.ts.ejs +1 -0
  60. package/dist/init/templates/ts/src/index.ts.ejs +1 -0
  61. package/dist/init/templates/ts/src/personEntityOverrides.ts.ejs +36 -0
  62. package/dist/init/templates/ts/tsconfig.json.ejs +13 -0
  63. package/dist/init/templates/ts/tspconfig.yaml.ejs +2 -0
  64. package/dist/ir.d.ts +49 -0
  65. package/dist/ir.d.ts.map +1 -0
  66. package/dist/ir.js +2 -0
  67. package/dist/ir.js.map +1 -0
  68. package/dist/tsp/init-tsp.d.ts +14 -0
  69. package/dist/tsp/init-tsp.d.ts.map +1 -0
  70. package/dist/tsp/init-tsp.js +126 -0
  71. package/dist/tsp/init-tsp.js.map +1 -0
  72. package/dist/tsp/loader.d.ts +8 -0
  73. package/dist/tsp/loader.d.ts.map +1 -0
  74. package/dist/tsp/loader.js +264 -0
  75. package/dist/tsp/loader.js.map +1 -0
  76. package/dist/typespec/decorators.d.ts +14 -0
  77. package/dist/typespec/decorators.d.ts.map +1 -0
  78. package/dist/typespec/decorators.js +139 -0
  79. package/dist/typespec/decorators.js.map +1 -0
  80. package/dist/typespec/state.d.ts +37 -0
  81. package/dist/typespec/state.d.ts.map +1 -0
  82. package/dist/typespec/state.js +13 -0
  83. package/dist/typespec/state.js.map +1 -0
  84. package/dist/validate/validator.d.ts +9 -0
  85. package/dist/validate/validator.d.ts.map +1 -0
  86. package/dist/validate/validator.js +204 -0
  87. package/dist/validate/validator.js.map +1 -0
  88. package/package.json +66 -0
  89. package/typespec/main.tsp +117 -0
  90. package/typespec/tsp-index.js +6 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wictor Wilén <wictor@wictorwilen.se>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # cocogen
2
+
3
+ A TypeSpec-driven generator (run via `npx`) for scaffolding Microsoft Graph External Connections (Microsoft 365 Copilot connectors) projects.
4
+
5
+ - Input: a TypeSpec (`.tsp`) file describing the external item schema
6
+ - Output: a runnable project in TypeScript/Node.js or C#/.NET that can:
7
+ - create an external connection
8
+ - register/update the schema
9
+ - ingest content from CSV (with a swappable datasource abstraction)
10
+
11
+ Design spec: see docs/architecture.md
12
+
13
+ End-user guide:
14
+ - docs/end-user.md
15
+
16
+ ## TypeSpec format
17
+ `cocogen` expects a single “item model” decorated with `@coco.item()` and a single ID property decorated with `@coco.id`.
18
+
19
+ Start here:
20
+ - docs/typespec.md
21
+
22
+ Examples:
23
+ - examples/content-connector.tsp
24
+ - examples/people-connector.tsp
25
+
26
+ ## Requirements
27
+ - Node.js 22+ (the generator targets Node 22 LTS)
28
+ - A TypeSpec schema file (`.tsp`)
29
+
30
+ ## Install / Run
31
+ No install needed:
32
+
33
+ ```bash
34
+ npx @wictorwilen/cocogen@latest --help
35
+ ```
36
+
37
+ ## Commands
38
+
39
+ ### Create a starter TypeSpec file (prompt)
40
+
41
+ ```bash
42
+ npx @wictorwilen/cocogen@latest init-tsp --prompt
43
+ ```
44
+
45
+ Non-interactive:
46
+
47
+ ```bash
48
+ npx @wictorwilen/cocogen@latest init-tsp --out ./schema.tsp --kind content
49
+ ```
50
+
51
+ ### Validate a schema
52
+
53
+ ```bash
54
+ npx @wictorwilen/cocogen@latest validate --tsp ./schema.tsp
55
+ ```
56
+
57
+ If your schema uses Graph beta features (for example `contentCategory` or people connectors), add:
58
+
59
+ ```bash
60
+ npx @wictorwilen/cocogen@latest validate --tsp ./schema.tsp --use-preview-features
61
+ ```
62
+
63
+ JSON output (useful in CI):
64
+
65
+ ```bash
66
+ npx @wictorwilen/cocogen@latest validate --tsp ./schema.tsp --json
67
+ ```
68
+
69
+ ### Emit IR JSON
70
+
71
+ ```bash
72
+ npx @wictorwilen/cocogen@latest emit --tsp ./schema.tsp
73
+ ```
74
+
75
+ For beta schemas:
76
+
77
+ ```bash
78
+ npx @wictorwilen/cocogen@latest emit --tsp ./schema.tsp --use-preview-features
79
+ ```
80
+
81
+ Write to a file:
82
+
83
+ ```bash
84
+ npx @wictorwilen/cocogen@latest emit --tsp ./schema.tsp --out ./connector.ir.json
85
+ ```
86
+
87
+ ### Generate a runnable TypeScript project
88
+
89
+ ```bash
90
+ npx @wictorwilen/cocogen@latest init --tsp ./schema.tsp --out ./my-connector
91
+ ```
92
+
93
+ For beta schemas:
94
+
95
+ ```bash
96
+ npx @wictorwilen/cocogen@latest init --tsp ./schema.tsp --out ./my-connector --use-preview-features
97
+ ```
98
+
99
+ Overwrite an existing non-empty folder:
100
+
101
+ ```bash
102
+ npx @wictorwilen/cocogen@latest init --tsp ./schema.tsp --out ./my-connector --force
103
+ ```
104
+
105
+ Notes:
106
+ - `cocogen` will fail fast if the schema is invalid.
107
+ - Beta features require `--use-preview-features`.
108
+
109
+ ### Update generated code after changing TypeSpec
110
+
111
+ After `init`, the project contains a `cocogen.json` that records which `.tsp` file to use.
112
+
113
+ When you change the schema, regenerate only the TypeSpec-derived files:
114
+
115
+ ```bash
116
+ npx @wictorwilen/cocogen@latest update --out ./my-connector
117
+ ```
118
+
119
+ Override the TypeSpec entrypoint (also updates `cocogen.json`):
120
+
121
+ ```bash
122
+ npx @wictorwilen/cocogen@latest update --out ./my-connector --tsp ../schema.tsp
123
+ ```
124
+
125
+ ## Generated project layout (TypeScript)
126
+ `cocogen` intentionally separates:
127
+
128
+ - `src/schema/**` — generated from TypeSpec (safe to overwrite on `cocogen update`)
129
+ - `src/**` (non-generated) — runtime code you can edit safely (should not change on update)
130
+
131
+ ## CLI output & colors
132
+ - Colors are enabled by default in TTYs.
133
+ - Set `NO_COLOR=1` to disable colors/spinners.
134
+ - In CI/non-TTY, spinners are automatically disabled.
135
+
136
+ ## Development
137
+
138
+ ```bash
139
+ npm install
140
+ npm test
141
+ ```
142
+
143
+ Build output is in `dist/`. The CLI is `dist/cli.js`.
144
+
145
+ ## License
146
+ MIT. See LICENSE.
147
+
148
+ ## Trademarks
149
+ Microsoft, Microsoft Graph, and Microsoft 365 are trademarks of Microsoft Corporation.
package/RELEASING.md ADDED
@@ -0,0 +1,36 @@
1
+ # Releasing `@wictorwilen/cocogen`
2
+
3
+ This repo publishes to npm via GitHub Actions when you push a semver tag.
4
+
5
+ ## Prerequisites (one-time)
6
+ - Configure npm Trusted Publishing (OIDC) for `@wictorwilen/cocogen`.
7
+ - Add GitHub Actions as a trusted publisher in npm for this repo.
8
+ - Ensure the workflow has `id-token: write` permission (already set).
9
+ - Ensure the npm package scope is configured for public publishing.
10
+ - This repo sets `publishConfig.access = "public"` in package.json.
11
+
12
+ ## Release process
13
+ 1) Pick a version number (semver).
14
+
15
+ 2) Bump the version in `package.json`.
16
+ - Recommended: `npm version <patch|minor|major> --no-git-tag-version`
17
+ - Or edit `package.json` manually.
18
+
19
+ 3) Commit the version bump.
20
+ - Use a Conventional Commit message, for example: `chore(release): v0.0.1`
21
+
22
+ 4) Create a tag that matches the workflow pattern `v*.*.*`.
23
+ - Example: `git tag v0.0.1`
24
+
25
+ 5) Push to GitHub.
26
+ - `git push origin main`
27
+ - `git push origin v0.0.1`
28
+
29
+ 6) Verify the publish.
30
+ - Check the GitHub Actions run for “Release (npm)”.
31
+ - Confirm on npm: `npm view @wictorwilen/cocogen version`
32
+
33
+ ## Notes
34
+ - The publish workflow builds from the tagged commit and runs `npm publish --provenance --access public` using OIDC.
35
+ - If you need to re-run without a new tag, you can use `workflow_dispatch` in GitHub Actions.
36
+ - Avoid reusing tags; npm won’t allow republishing the same version.
@@ -0,0 +1,11 @@
1
+ # Third-party notices
2
+
3
+ This project includes third-party open source software packages that are licensed under their own terms.
4
+
5
+ The full list of dependencies is captured in package.json and package-lock.json.
6
+
7
+ To review dependency licenses:
8
+ - inspect package.json and package-lock.json
9
+ - or run a license report tool such as `npx license-checker --production --summary`
10
+
11
+ No third-party code is copied into this repository directly; dependencies are consumed via npm.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export declare function main(argv: string[]): Promise<void>;
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA+DA,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA+OxD"}
package/dist/cli.js ADDED
@@ -0,0 +1,288 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync } from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { Command } from "commander";
6
+ import pc from "picocolors";
7
+ import ora from "ora";
8
+ import { writeIrJson } from "./emit/emit.js";
9
+ import { initDotnetProject, initTsProject, updateProject } from "./init/init.js";
10
+ import { initStarterTsp } from "./tsp/init-tsp.js";
11
+ import { loadIrFromTypeSpec } from "./tsp/loader.js";
12
+ import { validateIr } from "./validate/validator.js";
13
+ function isCiOrNoTty() {
14
+ return Boolean(process.env.CI) || !process.stdout.isTTY;
15
+ }
16
+ function shouldShowBanner() {
17
+ return !process.env.CI && Boolean(process.stderr.isTTY);
18
+ }
19
+ function getVersionLabel() {
20
+ try {
21
+ const dir = path.dirname(fileURLToPath(import.meta.url));
22
+ const pkgPath = path.resolve(dir, "..", "package.json");
23
+ const raw = readFileSync(pkgPath, "utf8");
24
+ const parsed = JSON.parse(raw);
25
+ if (parsed.version && parsed.version.trim().length > 0) {
26
+ return `v${parsed.version.trim()}`;
27
+ }
28
+ }
29
+ catch {
30
+ // Ignore version lookup errors.
31
+ }
32
+ return "v0.0.0";
33
+ }
34
+ function printBanner() {
35
+ if (!shouldShowBanner())
36
+ return;
37
+ const title = pc.bold(pc.cyan(`cocogen ${getVersionLabel()}`));
38
+ const subtitle = pc.dim("TypeSpec → Microsoft 365 Copilot connector scaffolding");
39
+ const art = [
40
+ `${pc.cyan(" ██████╗")} ${pc.blue(" ██████╗ ")} ${pc.cyan(" ██████╗")} ${pc.blue(" ██████╗")} ${pc.green(" ██████╗ ")} ${pc.magenta("███████╗")} ${pc.yellow(" ███╗ ██╗")}`,
41
+ `${pc.cyan(" ██╔════╝")} ${pc.blue("██╔═══██╗")} ${pc.cyan("██╔════╝")} ${pc.blue("██╔═══██╗")} ${pc.green("██╔════╝ ")} ${pc.magenta("██╔════╝")} ${pc.yellow(" ████╗ ██║")}`,
42
+ `${pc.cyan(" ██║ ")} ${pc.blue("██║ ██║")} ${pc.cyan("██║ ")} ${pc.blue("██║ ██║")} ${pc.green("██║ ███╗")} ${pc.magenta("█████╗ ")} ${pc.yellow(" ██╔██╗ ██║")}`,
43
+ `${pc.cyan(" ██║ ")} ${pc.blue("██║ ██║")} ${pc.cyan("██║ ")} ${pc.blue("██║ ██║")} ${pc.green("██║ ██║")} ${pc.magenta("██╔══╝ ")} ${pc.yellow(" ██║╚██╗██║")}`,
44
+ `${pc.cyan(" ╚██████╗")} ${pc.blue("╚██████╔╝")} ${pc.cyan("╚██████╗")} ${pc.blue("╚██████╔╝")} ${pc.green("╚██████╔╝")} ${pc.magenta("███████╗")} ${pc.yellow(" ██║ ╚████║")}`,
45
+ `${pc.cyan(" ╚═════╝")} ${pc.blue(" ╚═════╝ ")} ${pc.cyan(" ╚═════╝")} ${pc.blue(" ╚═════╝ ")} ${pc.green(" ╚═════╝ ")} ${pc.magenta("╚══════╝")} ${pc.yellow(" ╚═╝ ╚═══╝")}`,
46
+ ].join("\n");
47
+ const credit = `${pc.dim("made with")} ${pc.red("❤")}${pc.dim(" by Wictor Wilén")}`;
48
+ process.stderr.write(`${art}\n${title} ${subtitle}\n${credit}\n\n`);
49
+ }
50
+ function shouldUseSpinner() {
51
+ return !process.env.NO_COLOR && !isCiOrNoTty();
52
+ }
53
+ function printIssues(list) {
54
+ const errors = list.filter((i) => i.severity === "error");
55
+ const warnings = list.filter((i) => i.severity === "warning");
56
+ const summary = `${errors.length} error(s), ${warnings.length} warning(s)`;
57
+ process.stdout.write(`${pc.bold("validate")}: ${summary}\n`);
58
+ const printGroup = (title, group, color) => {
59
+ if (group.length === 0)
60
+ return;
61
+ process.stdout.write(`${color(title)}\n`);
62
+ for (const issue of group) {
63
+ process.stdout.write(`- ${issue.message}\n`);
64
+ if (issue.hint)
65
+ process.stdout.write(` ${pc.dim("hint:")} ${issue.hint}\n`);
66
+ }
67
+ };
68
+ printGroup("errors", errors, pc.red);
69
+ printGroup("warnings", warnings, pc.yellow);
70
+ }
71
+ export async function main(argv) {
72
+ printBanner();
73
+ const program = new Command();
74
+ program
75
+ .name("cocogen")
76
+ .description("TypeSpec-driven Microsoft Copilot connector generator")
77
+ .version("0.0.0")
78
+ .option("--verbose", "Enable verbose output", false)
79
+ .option("--use-preview-features", "Allow Graph beta endpoints and SDKs", false);
80
+ const requirePreviewIfNeeded = (ir, allow) => {
81
+ if (ir.connection.graphApiVersion === "beta" && !allow) {
82
+ throw new Error("This schema requires Graph beta. Re-run with --use-preview-features.");
83
+ }
84
+ };
85
+ program
86
+ .command("validate")
87
+ .description("Validate a TypeSpec schema against connector constraints")
88
+ .requiredOption("--tsp <path>", "Entry TypeSpec file")
89
+ .option("--json", "Output validation result as JSON", false)
90
+ .action(async (options) => {
91
+ const spinner = shouldUseSpinner() ? ora("Validating TypeSpec...").start() : undefined;
92
+ try {
93
+ const ir = await loadIrFromTypeSpec(options.tsp);
94
+ requirePreviewIfNeeded(ir, program.opts().usePreviewFeatures);
95
+ const issues = validateIr(ir);
96
+ const errors = issues.filter((i) => i.severity === "error");
97
+ const warnings = issues.filter((i) => i.severity === "warning");
98
+ if (options.json) {
99
+ spinner?.stop();
100
+ process.stdout.write(JSON.stringify({
101
+ ok: errors.length === 0,
102
+ errors,
103
+ warnings,
104
+ }, null, 2) + "\n");
105
+ process.exitCode = errors.length === 0 ? 0 : 1;
106
+ return;
107
+ }
108
+ const summary = `${errors.length} error(s), ${warnings.length} warning(s)`;
109
+ if (errors.length === 0 && warnings.length === 0) {
110
+ spinner?.succeed(`Valid ✅ (${ir.item.typeName})`);
111
+ if (!spinner)
112
+ process.stdout.write(`${pc.green("ok")}: Valid (${ir.item.typeName})\n`);
113
+ process.exitCode = 0;
114
+ return;
115
+ }
116
+ spinner?.stop();
117
+ printIssues(issues);
118
+ process.exitCode = errors.length === 0 ? 0 : 1;
119
+ }
120
+ catch (error) {
121
+ spinner?.stop();
122
+ const message = error instanceof Error ? error.message : String(error);
123
+ process.stderr.write(`${pc.red("error")}: ${message}\n`);
124
+ process.exitCode = 1;
125
+ }
126
+ });
127
+ program
128
+ .command("emit")
129
+ .description("Emit cocogen IR as JSON (useful for debugging and CI)")
130
+ .requiredOption("--tsp <path>", "Entry TypeSpec file")
131
+ .option("--out <path>", "Write IR JSON to a file instead of stdout")
132
+ .action(async (options) => {
133
+ const spinner = shouldUseSpinner() ? ora("Compiling TypeSpec...").start() : undefined;
134
+ try {
135
+ const ir = await loadIrFromTypeSpec(options.tsp);
136
+ requirePreviewIfNeeded(ir, program.opts().usePreviewFeatures);
137
+ const issues = validateIr(ir);
138
+ const errors = issues.filter((i) => i.severity === "error");
139
+ if (errors.length > 0) {
140
+ spinner?.stop();
141
+ printIssues(issues);
142
+ process.exitCode = 1;
143
+ return;
144
+ }
145
+ const result = await writeIrJson(ir, options.out);
146
+ spinner?.stop();
147
+ if (options.out) {
148
+ process.stdout.write(`${pc.green("ok")}: wrote ${result}\n`);
149
+ }
150
+ else {
151
+ process.stdout.write(result);
152
+ }
153
+ process.exitCode = 0;
154
+ }
155
+ catch (error) {
156
+ spinner?.stop();
157
+ const message = error instanceof Error ? error.message : String(error);
158
+ process.stderr.write(`${pc.red("error")}: ${message}\n`);
159
+ process.exitCode = 1;
160
+ }
161
+ });
162
+ program
163
+ .command("init-tsp")
164
+ .description("Create a starter TypeSpec file with guidance comments")
165
+ .option("--out <path>", "Output path for the .tsp file", "schema.tsp")
166
+ .option("--kind <kind>", "Connector kind (content|people)", "content")
167
+ .option("--prompt", "Use interactive prompts", false)
168
+ .option("--force", "Overwrite existing file", false)
169
+ .action(async (options) => {
170
+ const spinner = shouldUseSpinner() ? ora("Creating starter TypeSpec...").start() : undefined;
171
+ try {
172
+ const kind = options.kind === "people" ? "people" : "content";
173
+ const result = await initStarterTsp({
174
+ outPath: options.out,
175
+ kind,
176
+ prompt: options.prompt,
177
+ force: options.force,
178
+ });
179
+ spinner?.succeed(pc.green("Created"));
180
+ process.stdout.write(`${pc.green("ok")}: Starter TypeSpec created\n`);
181
+ process.stdout.write(` ${pc.dim("path")}: ${result.outPath}\n`);
182
+ process.stdout.write(` ${pc.dim("kind")}: ${result.kind}\n`);
183
+ process.stdout.write(` ${pc.dim("next")}: cocogen validate --tsp ${result.outPath}\n`);
184
+ if (result.kind === "people") {
185
+ process.stdout.write(` ${pc.dim("note")}: re-run validate/init with --use-preview-features\n`);
186
+ }
187
+ process.exitCode = 0;
188
+ }
189
+ catch (error) {
190
+ spinner?.stop();
191
+ const message = error instanceof Error ? error.message : String(error);
192
+ process.stderr.write(`${pc.red("error")}: ${message}\n`);
193
+ process.exitCode = 1;
194
+ }
195
+ });
196
+ program
197
+ .command("init")
198
+ .description("Generate a runnable connector project")
199
+ .requiredOption("--tsp <path>", "Entry TypeSpec file")
200
+ .requiredOption("--out <dir>", "Output directory")
201
+ .option("--lang <lang>", "Target language (ts|dotnet)", "ts")
202
+ .option("--name <name>", "Project name (defaults to folder name)")
203
+ .option("--force", "Overwrite files in a non-empty output directory", false)
204
+ .action(async (options) => {
205
+ const spinner = shouldUseSpinner() ? ora("Generating project...").start() : undefined;
206
+ try {
207
+ const lang = options.lang === "dotnet" ? "dotnet" : "ts";
208
+ const usePreviewFeatures = program.opts().usePreviewFeatures;
209
+ const result = lang === "ts"
210
+ ? await initTsProject({
211
+ tspPath: options.tsp,
212
+ outDir: options.out,
213
+ ...(options.name ? { projectName: options.name } : {}),
214
+ force: options.force,
215
+ usePreviewFeatures,
216
+ })
217
+ : await initDotnetProject({
218
+ tspPath: options.tsp,
219
+ outDir: options.out,
220
+ ...(options.name ? { projectName: options.name } : {}),
221
+ force: options.force,
222
+ usePreviewFeatures,
223
+ });
224
+ spinner?.succeed(pc.green("Generated"));
225
+ process.stdout.write(`${pc.green("ok")}: Project generated\n`);
226
+ process.stdout.write(` ${pc.dim("path")}: ${result.outDir}\n`);
227
+ process.stdout.write(` ${pc.dim("schema")}: ${result.ir.item.typeName}\n`);
228
+ process.stdout.write(` ${pc.dim("graph")}: ${result.ir.connection.graphApiVersion}\n`);
229
+ if (result.ir.connection.contentCategory) {
230
+ process.stdout.write(` ${pc.dim("category")}: ${result.ir.connection.contentCategory}\n`);
231
+ if (result.ir.connection.graphApiVersion === "beta") {
232
+ process.stdout.write(` ${pc.yellow("note")}: contentCategory is a Graph /beta property; provisioning will use /beta\n`);
233
+ }
234
+ }
235
+ const nextCmd = lang === "ts" ? "npm install" : "dotnet build";
236
+ process.stdout.write(` ${pc.dim("next")}: cd ${result.outDir} && ${nextCmd}\n`);
237
+ process.exitCode = 0;
238
+ }
239
+ catch (error) {
240
+ spinner?.stop();
241
+ const message = error instanceof Error ? error.message : String(error);
242
+ process.stderr.write(`${pc.red("error")}: ${message}\n`);
243
+ process.exitCode = 1;
244
+ }
245
+ });
246
+ program
247
+ .command("update")
248
+ .description("Regenerate TypeSpec-derived code inside an existing generated project")
249
+ .requiredOption("--out <dir>", "Project directory (must contain cocogen.json)")
250
+ .option("--tsp <path>", "Override TypeSpec entrypoint (also updates cocogen.json)")
251
+ .action(async (options) => {
252
+ const spinner = shouldUseSpinner() ? ora("Updating generated files...").start() : undefined;
253
+ try {
254
+ const usePreviewFeatures = program.opts().usePreviewFeatures;
255
+ const result = await updateProject({
256
+ outDir: options.out,
257
+ ...(options.tsp ? { tspPath: options.tsp } : {}),
258
+ usePreviewFeatures,
259
+ });
260
+ spinner?.succeed(pc.green("Updated"));
261
+ process.stdout.write(`${pc.green("ok")}: Regenerated TypeSpec-derived files\n`);
262
+ process.stdout.write(` ${pc.dim("path")}: ${result.outDir}\n`);
263
+ process.stdout.write(` ${pc.dim("schema")}: ${result.ir.item.typeName}\n`);
264
+ process.stdout.write(` ${pc.dim("graph")}: ${result.ir.connection.graphApiVersion}\n`);
265
+ if (result.ir.connection.contentCategory) {
266
+ process.stdout.write(` ${pc.dim("category")}: ${result.ir.connection.contentCategory}\n`);
267
+ if (result.ir.connection.graphApiVersion === "beta") {
268
+ process.stdout.write(` ${pc.yellow("note")}: contentCategory is a Graph /beta property; provisioning will use /beta\n`);
269
+ }
270
+ }
271
+ process.exitCode = 0;
272
+ }
273
+ catch (error) {
274
+ spinner?.stop();
275
+ const message = error instanceof Error ? error.message : String(error);
276
+ process.stderr.write(`${pc.red("error")}: ${message}\n`);
277
+ process.exitCode = 1;
278
+ }
279
+ });
280
+ await program.parseAsync(argv);
281
+ }
282
+ // eslint-disable-next-line unicorn/prefer-top-level-await
283
+ main(process.argv).catch((error) => {
284
+ const message = error instanceof Error ? error.message : String(error);
285
+ process.stderr.write(`${pc.red("error")}: ${message}\n`);
286
+ process.exitCode = 1;
287
+ });
288
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,GAAG,MAAM,KA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AO,CAAC,KAAK,OAAO,IAAI,CAAC,CAAC;YACzD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,0DAA0D;AAC1D,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC1C,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,OAAO,IAAI,CAAC,CAAC;IACzD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ConnectorIr } from "../ir.js";
2
+ export declare function writeIrJson(ir: ConnectorIr, outPath?: string): Promise<string>;
3
+ //# sourceMappingURL=emit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/emit/emit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,wBAAsB,WAAW,CAAC,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAWpF"}
@@ -0,0 +1,13 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ export async function writeIrJson(ir, outPath) {
4
+ const json = JSON.stringify(ir, null, 2) + "\n";
5
+ if (!outPath) {
6
+ return json;
7
+ }
8
+ const absolute = path.resolve(outPath);
9
+ await mkdir(path.dirname(absolute), { recursive: true });
10
+ await writeFile(absolute, json, "utf8");
11
+ return absolute;
12
+ }
13
+ //# sourceMappingURL=emit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.js","sourceRoot":"","sources":["../../src/emit/emit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAAe,EAAE,OAAgB;IACjE,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;IAEhD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,MAAM,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACxC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { main } from "./cli.js";
2
+ export * from "./typespec/decorators.js";
3
+ export * from "./typespec/state.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAIhC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { main } from "./cli.js";
2
+ // TypeSpec decorator implementations.
3
+ // These are invoked by the TypeSpec compiler when a .tsp file imports this package.
4
+ export * from "./typespec/decorators.js";
5
+ export * from "./typespec/state.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,sCAAsC;AACtC,oFAAoF;AACpF,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { ConnectorIr } from "../ir.js";
2
+ export type InitOptions = {
3
+ tspPath: string;
4
+ outDir: string;
5
+ projectName?: string;
6
+ force?: boolean;
7
+ usePreviewFeatures?: boolean;
8
+ };
9
+ export type UpdateOptions = {
10
+ outDir: string;
11
+ tspPath?: string;
12
+ usePreviewFeatures?: boolean;
13
+ };
14
+ export declare function updateTsProject(options: UpdateOptions): Promise<{
15
+ outDir: string;
16
+ ir: ConnectorIr;
17
+ }>;
18
+ export declare function updateDotnetProject(options: UpdateOptions): Promise<{
19
+ outDir: string;
20
+ ir: ConnectorIr;
21
+ }>;
22
+ export declare function updateProject(options: UpdateOptions): Promise<{
23
+ outDir: string;
24
+ ir: ConnectorIr;
25
+ }>;
26
+ export declare function initTsProject(options: InitOptions): Promise<{
27
+ outDir: string;
28
+ ir: ConnectorIr;
29
+ }>;
30
+ export declare function initDotnetProject(options: InitOptions): Promise<{
31
+ outDir: string;
32
+ ir: ConnectorIr;
33
+ }>;
34
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/init/init.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,UAAU,CAAC;AAK1D,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,MAA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