@nxara/olio-codegen 0.0.0-stage → 0.1.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.
package/dist/log.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export declare const bold: (text: string) => string;
2
+ export declare const dim: (text: string) => string;
3
+ export declare const red: (text: string) => string;
4
+ export declare const green: (text: string) => string;
5
+ export declare const cyan: (text: string) => string;
6
+ export declare function shortPath(path: string): string;
7
+ export declare const row: (label: string, value: string) => string;
8
+ export declare const count: (n: number, word: string) => string;
9
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,IAAI,SAHR,MAAM,KAAG,MAGU,CAAC;AAC7B,eAAO,MAAM,GAAG,SAJP,MAAM,KAAG,MAIS,CAAC;AAC5B,eAAO,MAAM,GAAG,SALP,MAAM,KAAG,MAKU,CAAC;AAC7B,eAAO,MAAM,KAAK,SANT,MAAM,KAAG,MAMY,CAAC;AAC/B,eAAO,MAAM,IAAI,SAPR,MAAM,KAAG,MAOW,CAAC;AAE9B,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG9C;AAED,eAAO,MAAM,GAAG,UAAW,MAAM,SAAS,MAAM,KAAG,MACb,CAAC;AAEvC,eAAO,MAAM,KAAK,MAAO,MAAM,QAAQ,MAAM,KAAG,MACX,CAAC"}
package/dist/log.js ADDED
@@ -0,0 +1,15 @@
1
+ import { relative } from "node:path";
2
+ const color = process.stdout.isTTY === true && !("NO_COLOR" in process.env);
3
+ const paint = (code) => (text) => color ? `\u001B[${code}m${text}\u001B[0m` : text;
4
+ export const bold = paint(1);
5
+ export const dim = paint(2);
6
+ export const red = paint(31);
7
+ export const green = paint(32);
8
+ export const cyan = paint(36);
9
+ export function shortPath(path) {
10
+ const rel = relative(process.cwd(), path);
11
+ return rel.startsWith("..") ? path : rel;
12
+ }
13
+ export const row = (label, value) => ` ${dim(label.padEnd(11))}${value}`;
14
+ export const count = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
15
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;AAC5E,MAAM,KAAK,GACT,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,IAAY,EAAU,EAAE,CACvB,KAAK,CAAC,CAAC,CAAC,UAAU,IAAI,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AAErD,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAC5B,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;AAE9B,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IAC1C,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;AAC3C,CAAC;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,KAAa,EAAE,KAAa,EAAU,EAAE,CAC1D,KAAK,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC;AAEvC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,IAAY,EAAU,EAAE,CACvD,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC"}
@@ -0,0 +1,41 @@
1
+ export interface Scalars {
2
+ ID: {
3
+ input: string;
4
+ output: string;
5
+ };
6
+ String: {
7
+ input: string;
8
+ output: string;
9
+ };
10
+ Int: {
11
+ input: number;
12
+ output: number;
13
+ };
14
+ Float: {
15
+ input: number;
16
+ output: number;
17
+ };
18
+ Boolean: {
19
+ input: boolean;
20
+ output: boolean;
21
+ };
22
+ }
23
+ export interface CustomScalars {
24
+ }
25
+ export type ResolveScalar<Name extends keyof CustomScalars | keyof Scalars | (string & {})> = Name extends keyof CustomScalars ? CustomScalars[Name] extends {
26
+ input: infer Input;
27
+ output: infer Output;
28
+ } ? {
29
+ input: Input;
30
+ output: Output;
31
+ } : {
32
+ input: CustomScalars[Name];
33
+ output: CustomScalars[Name];
34
+ } : Name extends keyof Scalars ? Scalars[Name] : {
35
+ input: unknown;
36
+ output: unknown;
37
+ };
38
+ export interface CustomEnums {
39
+ }
40
+ export type ResolveEnum<Name extends keyof CustomEnums | (string & {}), Names> = Name extends keyof CustomEnums ? CustomEnums[Name] : Names;
41
+ //# sourceMappingURL=scalars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalars.d.ts","sourceRoot":"","sources":["../src/scalars.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IA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appings":""}
@@ -0,0 +1,5 @@
1
+ import { type GraphQLArgument, type GraphQLInputField, type GraphQLType } from "graphql";
2
+ export type ScalarDirection = "input" | "output";
3
+ export declare function typeToTS(type: GraphQLType, direction: ScalarDirection, nullable?: boolean): string;
4
+ export declare function inputMember(input: GraphQLArgument | GraphQLInputField): string;
5
+ //# sourceMappingURL=type-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-map.d.ts","sourceRoot":"","sources":["../src/type-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEjD,wBAAgB,QAAQ,CACtB,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,eAAe,EAC1B,QAAQ,UAAO,GACd,MAAM,CAQR;AAID,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,GAAG,iBAAiB,GACzC,MAAM,CAIR"}
@@ -0,0 +1,16 @@
1
+ import { isListType, isNonNullType, isScalarType } from "graphql";
2
+ export function typeToTS(type, direction, nullable = true) {
3
+ if (isNonNullType(type))
4
+ return typeToTS(type.ofType, direction, false);
5
+ const base = isListType(type)
6
+ ? `${typeToTS(type.ofType, direction)}[]`
7
+ : isScalarType(type)
8
+ ? `Scalars["${type.name}"]["${direction}"]`
9
+ : type.name;
10
+ return nullable ? `Maybe<${base}>` : base;
11
+ }
12
+ export function inputMember(input) {
13
+ const optional = !isNonNullType(input.type) && input.defaultValue === undefined;
14
+ return `${input.name}${optional ? "?" : ""}: ${typeToTS(input.type, "input")}`;
15
+ }
16
+ //# sourceMappingURL=type-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-map.js","sourceRoot":"","sources":["../src/type-map.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,YAAY,EAIb,MAAM,SAAS,CAAC;AAIjB,MAAM,UAAU,QAAQ,CACtB,IAAiB,EACjB,SAA0B,EAC1B,QAAQ,GAAG,IAAI;IAEf,IAAI,aAAa,CAAC,IAAI,CAAC;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACxE,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC3B,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI;QACzC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC;YAClB,CAAC,CAAC,YAAY,IAAI,CAAC,IAAI,OAAO,SAAS,IAAI;YAC3C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAChB,OAAO,QAAQ,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAID,MAAM,UAAU,WAAW,CACzB,KAA0C;IAE1C,MAAM,QAAQ,GACZ,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS,CAAC;IACjE,OAAO,GAAG,KAAK,CAAC,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;AACjF,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { TypeSource } from "@nxara/olio-core";
2
+ import type { SchemaDirective } from "@nxara/olio-schema";
3
+ export type { TypeSource };
4
+ export interface CodegenModule {
5
+ id: string;
6
+ typeDefs: TypeSource | readonly TypeSource[];
7
+ }
8
+ export interface GenerateOptions {
9
+ directives?: readonly SchemaDirective[];
10
+ }
11
+ export interface CodegenOptions {
12
+ root?: string;
13
+ modules: string;
14
+ typeDefs: string | string[];
15
+ output: string;
16
+ schemaOutput?: string;
17
+ watch?: boolean;
18
+ clear?: boolean;
19
+ directives?: readonly SchemaDirective[];
20
+ logs?: boolean;
21
+ }
22
+ export interface ClientCodegenOptions {
23
+ root?: string;
24
+ schema: string;
25
+ documents: string | string[];
26
+ output: string;
27
+ headers?: Record<string, string>;
28
+ watch?: boolean;
29
+ logs?: boolean;
30
+ }
31
+ export declare const BUILTIN_SCALARS: ReadonlySet<string>;
32
+ export declare const RESERVED_NAMES: ReadonlySet<string>;
33
+ export declare const HEADER = "// Generated by @nxara/olio-codegen - do not edit.\n// oxlint-disable no-redeclare";
34
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,UAAU,GAAG,SAAS,UAAU,EAAE,CAAC;CAC9C;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,cAAc;IAK7B,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,OAAO,EAAE,MAAM,CAAC;IAEhB,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IAEf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACxC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IAKnC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,MAAM,CAAC;IAEf,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,CAM9C,CAAC;AAGH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAM7C,CAAC;AAEH,eAAO,MAAM,MAAM,uFACmE,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,16 @@
1
+ export const BUILTIN_SCALARS = new Set([
2
+ "ID",
3
+ "String",
4
+ "Int",
5
+ "Float",
6
+ "Boolean"
7
+ ]);
8
+ export const RESERVED_NAMES = new Set([
9
+ "Application",
10
+ "Maybe",
11
+ "ResolveEnum",
12
+ "ResolveScalar",
13
+ "Scalars"
14
+ ]);
15
+ export const HEADER = "// Generated by @nxara/olio-codegen - do not edit.\n// oxlint-disable no-redeclare";
16
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAmDA,MAAM,CAAC,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC;IAC1D,IAAI;IACJ,QAAQ;IACR,KAAK;IACL,OAAO;IACP,SAAS;CACV,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IACzD,aAAa;IACb,OAAO;IACP,aAAa;IACb,eAAe;IACf,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,MAAM,GACjB,oFAAoF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "@nxara/olio-codegen",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Generate TypeScript types from GraphQL SDL.",
5
+ "keywords": [
6
+ "codegen",
7
+ "graphql",
8
+ "nxara",
9
+ "typescript"
10
+ ],
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/nxara-hub/olio.git",
15
+ "directory": "packages/codegen"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "type": "module",
21
+ "sideEffects": false,
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ }
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc",
33
+ "test": "bun test",
34
+ "check-types": "tsc -p tsconfig.test.json"
35
+ },
36
+ "dependencies": {
37
+ "@nxara/olio-core": "0.1.0",
38
+ "@nxara/olio-schema": "0.1.0"
39
+ },
40
+ "devDependencies": {
41
+ "graphql": "^16.14.2"
42
+ },
43
+ "peerDependencies": {
44
+ "graphql": "^16.13.0"
45
+ },
46
+ "engines": {
47
+ "node": ">=22"
48
+ }
49
+ }