@constructive-io/cli 6.0.4 → 6.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.
@@ -15,6 +15,11 @@ export const usageText = `
15
15
  Jobs:
16
16
  jobs up Start combined server (jobs runtime)
17
17
 
18
+ Execution Engine:
19
+ context Manage contexts (create, list, use, current, delete)
20
+ auth Manage authentication (set-token, status, logout)
21
+ execute Execute GraphQL queries against configured endpoints
22
+
18
23
  Global Options:
19
24
  -h, --help Display this help information
20
25
  -v, --version Display version information
@@ -32,6 +37,11 @@ export const usageText = `
32
37
  cnc get-graphql-schema --out schema.graphql Export schema SDL
33
38
  cnc jobs up Start combined server (jobs runtime)
34
39
 
40
+ # Execution Engine
41
+ cnc context create my-api --endpoint https://api.example.com/graphql
42
+ cnc auth set-token
43
+ cnc execute --query 'query { __typename }'
44
+
35
45
  Database Operations:
36
46
  For database migrations, packages, and deployment, use pgpm:
37
47
  https://pgpm.io
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/cli",
3
- "version": "6.0.4",
3
+ "version": "6.1.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "Constructive CLI",
6
6
  "main": "index.js",
@@ -45,18 +45,19 @@
45
45
  "ts-node": "^10.9.2"
46
46
  },
47
47
  "dependencies": {
48
- "@constructive-io/graphql-codegen": "^3.0.4",
48
+ "@constructive-io/graphql-codegen": "^3.1.1",
49
49
  "@constructive-io/graphql-env": "^2.9.4",
50
50
  "@constructive-io/graphql-explorer": "^3.0.3",
51
51
  "@constructive-io/graphql-server": "^3.0.3",
52
- "@constructive-io/knative-job-service": "^1.0.3",
52
+ "@constructive-io/knative-job-service": "^1.0.4",
53
53
  "@inquirerer/utils": "^3.2.0",
54
54
  "@pgpmjs/core": "^5.0.1",
55
55
  "@pgpmjs/logger": "^2.0.0",
56
56
  "@pgpmjs/server-utils": "^3.0.0",
57
57
  "@pgpmjs/types": "^2.15.0",
58
+ "appstash": "^0.3.0",
58
59
  "find-and-require-package-json": "^0.9.0",
59
- "inquirerer": "^4.4.0",
60
+ "inquirerer": "^4.5.0",
60
61
  "js-yaml": "^4.1.0",
61
62
  "pg-cache": "^2.0.0",
62
63
  "pg-env": "^1.3.0",
@@ -75,5 +76,5 @@
75
76
  "postgres",
76
77
  "graphile"
77
78
  ],
78
- "gitHead": "aa8ec75966a41a019eda2003b2d970f0a75608aa"
79
+ "gitHead": "03cfe7dad85283c7364bc38261136933a20ba73d"
79
80
  }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Simple GraphQL client for the CNC execution engine
3
+ * Uses native fetch - no external dependencies
4
+ */
5
+ export interface GraphQLError {
6
+ message: string;
7
+ locations?: Array<{
8
+ line: number;
9
+ column: number;
10
+ }>;
11
+ path?: Array<string | number>;
12
+ extensions?: Record<string, unknown>;
13
+ }
14
+ export interface QueryResult<T> {
15
+ ok: boolean;
16
+ data: T | null;
17
+ errors?: GraphQLError[];
18
+ }
19
+ export interface ClientConfig {
20
+ endpoint: string;
21
+ headers?: Record<string, string>;
22
+ }
23
+ /**
24
+ * Execute a GraphQL query/mutation against an endpoint
25
+ */
26
+ export declare function executeGraphQL<T>(endpoint: string, query: string, variables?: Record<string, unknown>, headers?: Record<string, string>): Promise<QueryResult<T>>;
27
+ /**
28
+ * Create a configured client for a specific endpoint
29
+ */
30
+ export declare function createClient(config: ClientConfig): {
31
+ execute: <T>(query: string, variables?: Record<string, unknown>) => Promise<QueryResult<T>>;
32
+ config: ClientConfig;
33
+ };
package/sdk/client.js ADDED
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /**
3
+ * Simple GraphQL client for the CNC execution engine
4
+ * Uses native fetch - no external dependencies
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.executeGraphQL = executeGraphQL;
8
+ exports.createClient = createClient;
9
+ /**
10
+ * Execute a GraphQL query/mutation against an endpoint
11
+ */
12
+ async function executeGraphQL(endpoint, query, variables, headers) {
13
+ try {
14
+ const response = await fetch(endpoint, {
15
+ method: 'POST',
16
+ headers: {
17
+ 'Content-Type': 'application/json',
18
+ Accept: 'application/json',
19
+ ...headers,
20
+ },
21
+ body: JSON.stringify({
22
+ query,
23
+ variables: variables ?? {},
24
+ }),
25
+ });
26
+ if (!response.ok) {
27
+ return {
28
+ ok: false,
29
+ data: null,
30
+ errors: [
31
+ { message: `HTTP ${response.status}: ${response.statusText}` },
32
+ ],
33
+ };
34
+ }
35
+ const json = (await response.json());
36
+ if (json.errors && json.errors.length > 0) {
37
+ return {
38
+ ok: false,
39
+ data: json.data ?? null,
40
+ errors: json.errors,
41
+ };
42
+ }
43
+ return {
44
+ ok: true,
45
+ data: json.data,
46
+ };
47
+ }
48
+ catch (error) {
49
+ return {
50
+ ok: false,
51
+ data: null,
52
+ errors: [
53
+ {
54
+ message: error instanceof Error ? error.message : 'Unknown error occurred',
55
+ },
56
+ ],
57
+ };
58
+ }
59
+ }
60
+ /**
61
+ * Create a configured client for a specific endpoint
62
+ */
63
+ function createClient(config) {
64
+ return {
65
+ execute: (query, variables) => {
66
+ return executeGraphQL(config.endpoint, query, variables, config.headers);
67
+ },
68
+ config,
69
+ };
70
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Simple GraphQL executor for the CNC execution engine
3
+ * Executes raw GraphQL queries against configured endpoints
4
+ */
5
+ import { QueryResult } from './client';
6
+ import type { ContextConfig } from '../config';
7
+ /**
8
+ * Execution context - bundles context config with credentials
9
+ */
10
+ export interface ExecutionContext {
11
+ context: ContextConfig;
12
+ token: string;
13
+ }
14
+ /**
15
+ * Get execution context for the current or specified context
16
+ */
17
+ export declare function getExecutionContext(contextName?: string): Promise<ExecutionContext>;
18
+ /**
19
+ * Execute a raw GraphQL query/mutation
20
+ */
21
+ export declare function execute<T = unknown>(query: string, variables?: Record<string, unknown>, execContext?: ExecutionContext): Promise<QueryResult<T>>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * Simple GraphQL executor for the CNC execution engine
4
+ * Executes raw GraphQL queries against configured endpoints
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getExecutionContext = getExecutionContext;
8
+ exports.execute = execute;
9
+ const client_1 = require("./client");
10
+ const config_1 = require("../config");
11
+ /**
12
+ * Get execution context for the current or specified context
13
+ */
14
+ async function getExecutionContext(contextName) {
15
+ let context;
16
+ if (contextName) {
17
+ context = (0, config_1.loadContext)(contextName);
18
+ if (!context) {
19
+ throw new Error(`Context "${contextName}" not found.`);
20
+ }
21
+ }
22
+ else {
23
+ context = (0, config_1.getCurrentContext)();
24
+ if (!context) {
25
+ throw new Error('No active context. Run "cnc context create" or "cnc context use" first.');
26
+ }
27
+ }
28
+ if (!(0, config_1.hasValidCredentials)(context.name)) {
29
+ throw new Error(`No valid credentials for context "${context.name}". Run "cnc auth set-token" first.`);
30
+ }
31
+ const creds = (0, config_1.getContextCredentials)(context.name);
32
+ if (!creds || !creds.token) {
33
+ throw new Error(`No token found for context "${context.name}". Run "cnc auth set-token" first.`);
34
+ }
35
+ return {
36
+ context,
37
+ token: creds.token,
38
+ };
39
+ }
40
+ /**
41
+ * Execute a raw GraphQL query/mutation
42
+ */
43
+ async function execute(query, variables, execContext) {
44
+ const ctx = execContext || (await getExecutionContext());
45
+ return (0, client_1.executeGraphQL)(ctx.context.endpoint, query, variables, {
46
+ Authorization: `Bearer ${ctx.token}`,
47
+ });
48
+ }
package/sdk/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * SDK module exports
3
+ */
4
+ export * from './client';
5
+ export * from './executor';
package/sdk/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * SDK module exports
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./client"), exports);
21
+ __exportStar(require("./executor"), exports);
@@ -1 +1 @@
1
- export declare const usageText = "\n Usage: cnc <command> [options]\n constructive <command> [options]\n\n Constructive CLI - API Server and Development Tools\n\n GraphQL Server:\n server Start a GraphQL server\n explorer Launch GraphiQL explorer interface\n\n Code Generation:\n codegen Generate TypeScript types and SDK from GraphQL schema\n get-graphql-schema Fetch or build GraphQL schema SDL\n\n Jobs:\n jobs up Start combined server (jobs runtime)\n\n Global Options:\n -h, --help Display this help information\n -v, --version Display version information\n --cwd <directory> Working directory (default: current directory)\n\n Individual Command Help:\n cnc <command> --help Display detailed help for specific command\n cnc <command> -h Display detailed help for specific command\n\n Examples:\n cnc server Start GraphQL server\n cnc server --port 8080 Start server on custom port\n cnc explorer Launch GraphiQL explorer\n cnc codegen --schema schema.graphql Generate types from schema\n cnc get-graphql-schema --out schema.graphql Export schema SDL\n cnc jobs up Start combined server (jobs runtime)\n\n Database Operations:\n For database migrations, packages, and deployment, use pgpm:\n https://pgpm.io\n ";
1
+ export declare const usageText = "\n Usage: cnc <command> [options]\n constructive <command> [options]\n\n Constructive CLI - API Server and Development Tools\n\n GraphQL Server:\n server Start a GraphQL server\n explorer Launch GraphiQL explorer interface\n\n Code Generation:\n codegen Generate TypeScript types and SDK from GraphQL schema\n get-graphql-schema Fetch or build GraphQL schema SDL\n\n Jobs:\n jobs up Start combined server (jobs runtime)\n\n Execution Engine:\n context Manage contexts (create, list, use, current, delete)\n auth Manage authentication (set-token, status, logout)\n execute Execute GraphQL queries against configured endpoints\n\n Global Options:\n -h, --help Display this help information\n -v, --version Display version information\n --cwd <directory> Working directory (default: current directory)\n\n Individual Command Help:\n cnc <command> --help Display detailed help for specific command\n cnc <command> -h Display detailed help for specific command\n\n Examples:\n cnc server Start GraphQL server\n cnc server --port 8080 Start server on custom port\n cnc explorer Launch GraphiQL explorer\n cnc codegen --schema schema.graphql Generate types from schema\n cnc get-graphql-schema --out schema.graphql Export schema SDL\n cnc jobs up Start combined server (jobs runtime)\n\n # Execution Engine\n cnc context create my-api --endpoint https://api.example.com/graphql\n cnc auth set-token\n cnc execute --query 'query { __typename }'\n\n Database Operations:\n For database migrations, packages, and deployment, use pgpm:\n https://pgpm.io\n ";
package/utils/display.js CHANGED
@@ -18,6 +18,11 @@ exports.usageText = `
18
18
  Jobs:
19
19
  jobs up Start combined server (jobs runtime)
20
20
 
21
+ Execution Engine:
22
+ context Manage contexts (create, list, use, current, delete)
23
+ auth Manage authentication (set-token, status, logout)
24
+ execute Execute GraphQL queries against configured endpoints
25
+
21
26
  Global Options:
22
27
  -h, --help Display this help information
23
28
  -v, --version Display version information
@@ -35,6 +40,11 @@ exports.usageText = `
35
40
  cnc get-graphql-schema --out schema.graphql Export schema SDL
36
41
  cnc jobs up Start combined server (jobs runtime)
37
42
 
43
+ # Execution Engine
44
+ cnc context create my-api --endpoint https://api.example.com/graphql
45
+ cnc auth set-token
46
+ cnc execute --query 'query { __typename }'
47
+
38
48
  Database Operations:
39
49
  For database migrations, packages, and deployment, use pgpm:
40
50
  https://pgpm.io