@xschemadev/core 0.0.6

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.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import type { ConvertInput, ConvertResult } from "./types.js";
2
+ /**
3
+ * Creates a CLI handler for xschema adapters.
4
+ * Reads JSON array of ConvertInput from stdin, calls convert for each, outputs JSON array of ConvertResult.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * #!/usr/bin/env node
9
+ * import { createAdapterCLI } from "@xschemadev/core";
10
+ * import { convert } from "./index";
11
+ *
12
+ * createAdapterCLI(convert);
13
+ * ```
14
+ */
15
+ export declare function createAdapterCLI(convert: (input: ConvertInput) => ConvertResult): void;
16
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9D;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,aAAa,GAC9C,IAAI,CAaN"}
package/dist/cli.js ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Creates a CLI handler for xschema adapters.
3
+ * Reads JSON array of ConvertInput from stdin, calls convert for each, outputs JSON array of ConvertResult.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * #!/usr/bin/env node
8
+ * import { createAdapterCLI } from "@xschemadev/core";
9
+ * import { convert } from "./index";
10
+ *
11
+ * createAdapterCLI(convert);
12
+ * ```
13
+ */
14
+ export function createAdapterCLI(convert) {
15
+ const chunks = [];
16
+ process.stdin.on("data", (chunk) => chunks.push(String(chunk)));
17
+ process.stdin.on("end", () => {
18
+ try {
19
+ const inputs = JSON.parse(chunks.join(""));
20
+ const outputs = inputs.map(convert);
21
+ console.log(JSON.stringify(outputs));
22
+ }
23
+ catch (err) {
24
+ console.error(err instanceof Error ? err.message : err);
25
+ process.exit(1);
26
+ }
27
+ });
28
+ }
29
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAA+C;IAE/C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;QAC3B,IAAI,CAAC;YACH,MAAM,MAAM,GAAmB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YAC3D,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type { XSchemaAdapter, ConvertInput, ConvertResult } from "./types.js";
2
+ export { createAdapterCLI } from "./cli.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { createAdapterCLI } from "./cli.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,18 @@
1
+ export interface XSchemaAdapter {
2
+ readonly __brand: "xschema-adapter";
3
+ readonly name: string;
4
+ readonly language: string;
5
+ }
6
+ export interface ConvertInput {
7
+ namespace: string;
8
+ id: string;
9
+ schema: object;
10
+ }
11
+ export interface ConvertResult {
12
+ namespace: string;
13
+ id: string;
14
+ imports: string[];
15
+ schema: string;
16
+ type: string;
17
+ }
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@xschemadev/core",
3
+ "version": "0.0.6",
4
+ "type": "module",
5
+ "description": "XSchema Adapter CLI helper and protocol types",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "typecheck": "tsc --noEmit"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "^22.0.0"
21
+ }
22
+ }