@constructive-sdk/cli 0.21.7 → 0.21.8

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 (41) hide show
  1. package/admin/cli/executor.js +2 -2
  2. package/auth/cli/executor.js +2 -2
  3. package/esm/admin/cli/executor.js +2 -2
  4. package/esm/auth/cli/executor.js +2 -2
  5. package/esm/objects/cli/executor.js +2 -2
  6. package/esm/public/cli/executor.js +2 -2
  7. package/objects/cli/executor.js +2 -2
  8. package/package.json +3 -3
  9. package/public/cli/executor.js +2 -2
  10. package/admin/cli/node-fetch.d.ts +0 -26
  11. package/admin/cli/node-fetch.js +0 -129
  12. package/admin/orm/node-fetch.d.ts +0 -26
  13. package/admin/orm/node-fetch.js +0 -129
  14. package/auth/cli/node-fetch.d.ts +0 -26
  15. package/auth/cli/node-fetch.js +0 -129
  16. package/auth/orm/node-fetch.d.ts +0 -26
  17. package/auth/orm/node-fetch.js +0 -129
  18. package/esm/admin/cli/node-fetch.d.ts +0 -26
  19. package/esm/admin/cli/node-fetch.js +0 -122
  20. package/esm/admin/orm/node-fetch.d.ts +0 -26
  21. package/esm/admin/orm/node-fetch.js +0 -122
  22. package/esm/auth/cli/node-fetch.d.ts +0 -26
  23. package/esm/auth/cli/node-fetch.js +0 -122
  24. package/esm/auth/orm/node-fetch.d.ts +0 -26
  25. package/esm/auth/orm/node-fetch.js +0 -122
  26. package/esm/objects/cli/node-fetch.d.ts +0 -26
  27. package/esm/objects/cli/node-fetch.js +0 -122
  28. package/esm/objects/orm/node-fetch.d.ts +0 -26
  29. package/esm/objects/orm/node-fetch.js +0 -122
  30. package/esm/public/cli/node-fetch.d.ts +0 -26
  31. package/esm/public/cli/node-fetch.js +0 -122
  32. package/esm/public/orm/node-fetch.d.ts +0 -26
  33. package/esm/public/orm/node-fetch.js +0 -122
  34. package/objects/cli/node-fetch.d.ts +0 -26
  35. package/objects/cli/node-fetch.js +0 -129
  36. package/objects/orm/node-fetch.d.ts +0 -26
  37. package/objects/orm/node-fetch.js +0 -129
  38. package/public/cli/node-fetch.d.ts +0 -26
  39. package/public/cli/node-fetch.js +0 -129
  40. package/public/orm/node-fetch.d.ts +0 -26
  41. package/public/orm/node-fetch.js +0 -129
@@ -7,7 +7,6 @@ exports.getClient = getClient;
7
7
  * @generated by @constructive-io/graphql-codegen
8
8
  * DO NOT EDIT - changes will be overwritten
9
9
  */
10
- const node_fetch_1 = require("./node-fetch");
11
10
  const appstash_1 = require("appstash");
12
11
  const orm_1 = require("../orm");
13
12
  const store = (0, appstash_1.createConfigStore)('csdk');
@@ -35,6 +34,7 @@ function getClient(contextName) {
35
34
  }
36
35
  }
37
36
  return (0, orm_1.createClient)({
38
- adapter: new node_fetch_1.NodeHttpAdapter(ctx.endpoint, headers),
37
+ endpoint: ctx.endpoint,
38
+ headers,
39
39
  });
40
40
  }
@@ -7,7 +7,6 @@ exports.getClient = getClient;
7
7
  * @generated by @constructive-io/graphql-codegen
8
8
  * DO NOT EDIT - changes will be overwritten
9
9
  */
10
- const node_fetch_1 = require("./node-fetch");
11
10
  const appstash_1 = require("appstash");
12
11
  const orm_1 = require("../orm");
13
12
  const store = (0, appstash_1.createConfigStore)('csdk');
@@ -35,6 +34,7 @@ function getClient(contextName) {
35
34
  }
36
35
  }
37
36
  return (0, orm_1.createClient)({
38
- adapter: new node_fetch_1.NodeHttpAdapter(ctx.endpoint, headers),
37
+ endpoint: ctx.endpoint,
38
+ headers,
39
39
  });
40
40
  }
@@ -3,7 +3,6 @@
3
3
  * @generated by @constructive-io/graphql-codegen
4
4
  * DO NOT EDIT - changes will be overwritten
5
5
  */
6
- import { NodeHttpAdapter } from './node-fetch';
7
6
  import { createConfigStore } from 'appstash';
8
7
  import { createClient } from '../orm';
9
8
  const store = createConfigStore('csdk');
@@ -30,6 +29,7 @@ export function getClient(contextName) {
30
29
  }
31
30
  }
32
31
  return createClient({
33
- adapter: new NodeHttpAdapter(ctx.endpoint, headers),
32
+ endpoint: ctx.endpoint,
33
+ headers,
34
34
  });
35
35
  }
@@ -3,7 +3,6 @@
3
3
  * @generated by @constructive-io/graphql-codegen
4
4
  * DO NOT EDIT - changes will be overwritten
5
5
  */
6
- import { NodeHttpAdapter } from './node-fetch';
7
6
  import { createConfigStore } from 'appstash';
8
7
  import { createClient } from '../orm';
9
8
  const store = createConfigStore('csdk');
@@ -30,6 +29,7 @@ export function getClient(contextName) {
30
29
  }
31
30
  }
32
31
  return createClient({
33
- adapter: new NodeHttpAdapter(ctx.endpoint, headers),
32
+ endpoint: ctx.endpoint,
33
+ headers,
34
34
  });
35
35
  }
@@ -3,7 +3,6 @@
3
3
  * @generated by @constructive-io/graphql-codegen
4
4
  * DO NOT EDIT - changes will be overwritten
5
5
  */
6
- import { NodeHttpAdapter } from './node-fetch';
7
6
  import { createConfigStore } from 'appstash';
8
7
  import { createClient } from '../orm';
9
8
  const store = createConfigStore('csdk');
@@ -30,6 +29,7 @@ export function getClient(contextName) {
30
29
  }
31
30
  }
32
31
  return createClient({
33
- adapter: new NodeHttpAdapter(ctx.endpoint, headers),
32
+ endpoint: ctx.endpoint,
33
+ headers,
34
34
  });
35
35
  }
@@ -3,7 +3,6 @@
3
3
  * @generated by @constructive-io/graphql-codegen
4
4
  * DO NOT EDIT - changes will be overwritten
5
5
  */
6
- import { NodeHttpAdapter } from './node-fetch';
7
6
  import { createConfigStore } from 'appstash';
8
7
  import { createClient } from '../orm';
9
8
  const store = createConfigStore('csdk');
@@ -30,6 +29,7 @@ export function getClient(contextName) {
30
29
  }
31
30
  }
32
31
  return createClient({
33
- adapter: new NodeHttpAdapter(ctx.endpoint, headers),
32
+ endpoint: ctx.endpoint,
33
+ headers,
34
34
  });
35
35
  }
@@ -7,7 +7,6 @@ exports.getClient = getClient;
7
7
  * @generated by @constructive-io/graphql-codegen
8
8
  * DO NOT EDIT - changes will be overwritten
9
9
  */
10
- const node_fetch_1 = require("./node-fetch");
11
10
  const appstash_1 = require("appstash");
12
11
  const orm_1 = require("../orm");
13
12
  const store = (0, appstash_1.createConfigStore)('csdk');
@@ -35,6 +34,7 @@ function getClient(contextName) {
35
34
  }
36
35
  }
37
36
  return (0, orm_1.createClient)({
38
- adapter: new node_fetch_1.NodeHttpAdapter(ctx.endpoint, headers),
37
+ endpoint: ctx.endpoint,
38
+ headers,
39
39
  });
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-sdk/cli",
3
- "version": "0.21.7",
3
+ "version": "0.21.8",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "Constructive CLI SDK - Auto-generated GraphQL CLI with ORM client, context management, and interactive prompts",
6
6
  "main": "index.js",
@@ -56,11 +56,11 @@
56
56
  "yanse": "^0.2.1"
57
57
  },
58
58
  "devDependencies": {
59
- "@constructive-io/graphql-codegen": "^4.41.0",
59
+ "@constructive-io/graphql-codegen": "^4.41.1",
60
60
  "@types/node": "^22.19.11",
61
61
  "makage": "^0.3.0",
62
62
  "tsx": "^4.19.0",
63
63
  "typescript": "^5.9.3"
64
64
  },
65
- "gitHead": "70f9d2052fe9218c65b82e896d1660d4dc6a51c8"
65
+ "gitHead": "0b23c8c5c65e408576cd1fe3e21b20ae6db8f492"
66
66
  }
@@ -7,7 +7,6 @@ exports.getClient = getClient;
7
7
  * @generated by @constructive-io/graphql-codegen
8
8
  * DO NOT EDIT - changes will be overwritten
9
9
  */
10
- const node_fetch_1 = require("./node-fetch");
11
10
  const appstash_1 = require("appstash");
12
11
  const orm_1 = require("../orm");
13
12
  const store = (0, appstash_1.createConfigStore)('csdk');
@@ -35,6 +34,7 @@ function getClient(contextName) {
35
34
  }
36
35
  }
37
36
  return (0, orm_1.createClient)({
38
- adapter: new node_fetch_1.NodeHttpAdapter(ctx.endpoint, headers),
37
+ endpoint: ctx.endpoint,
38
+ headers,
39
39
  });
40
40
  }
@@ -1,26 +0,0 @@
1
- import type { GraphQLAdapter, QueryResult } from '@constructive-io/graphql-types';
2
- /**
3
- * Options for individual execute calls.
4
- * Allows per-request header overrides and request cancellation.
5
- */
6
- export interface NodeHttpExecuteOptions {
7
- /** Additional headers to include in this request only */
8
- headers?: Record<string, string>;
9
- /** AbortSignal for request cancellation */
10
- signal?: AbortSignal;
11
- }
12
- /**
13
- * GraphQL adapter that uses node:http/node:https for requests.
14
- *
15
- * Handles *.localhost subdomains by rewriting the hostname to "localhost"
16
- * and injecting the original Host header for server-side subdomain routing.
17
- */
18
- export declare class NodeHttpAdapter implements GraphQLAdapter {
19
- private endpoint;
20
- private headers;
21
- private url;
22
- constructor(endpoint: string, headers?: Record<string, string>);
23
- execute<T>(document: string, variables?: Record<string, unknown>, options?: NodeHttpExecuteOptions): Promise<QueryResult<T>>;
24
- setHeaders(headers: Record<string, string>): void;
25
- getEndpoint(): string;
26
- }
@@ -1,129 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NodeHttpAdapter = void 0;
7
- /**
8
- * Node HTTP adapter for localhost subdomain routing
9
- * @generated by @constructive-io/graphql-codegen
10
- * DO NOT EDIT - changes will be overwritten
11
- */
12
- const node_http_1 = __importDefault(require("node:http"));
13
- const node_https_1 = __importDefault(require("node:https"));
14
- /**
15
- * Check if a hostname is a localhost subdomain that needs special handling.
16
- * Returns true for *.localhost (e.g. auth.localhost) but not bare "localhost".
17
- */
18
- function isLocalhostSubdomain(hostname) {
19
- return hostname.endsWith('.localhost') && hostname !== 'localhost';
20
- }
21
- /**
22
- * Make an HTTP/HTTPS request using native Node modules.
23
- * Supports optional AbortSignal for request cancellation.
24
- */
25
- function makeRequest(url, options, body, signal) {
26
- return new Promise((resolve, reject) => {
27
- if (signal?.aborted) {
28
- reject(new Error('The operation was aborted'));
29
- return;
30
- }
31
- const protocol = url.protocol === 'https:' ? node_https_1.default : node_http_1.default;
32
- const req = protocol.request(url, options, (res) => {
33
- let data = '';
34
- res.setEncoding('utf8');
35
- res.on('data', (chunk) => {
36
- data += chunk;
37
- });
38
- res.on('end', () => {
39
- resolve({
40
- statusCode: res.statusCode || 0,
41
- statusMessage: res.statusMessage || '',
42
- data,
43
- });
44
- });
45
- });
46
- req.on('error', reject);
47
- if (signal) {
48
- const onAbort = () => {
49
- req.destroy(new Error('The operation was aborted'));
50
- };
51
- signal.addEventListener('abort', onAbort, { once: true });
52
- req.on('close', () => {
53
- signal.removeEventListener('abort', onAbort);
54
- });
55
- }
56
- req.write(body);
57
- req.end();
58
- });
59
- }
60
- /**
61
- * GraphQL adapter that uses node:http/node:https for requests.
62
- *
63
- * Handles *.localhost subdomains by rewriting the hostname to "localhost"
64
- * and injecting the original Host header for server-side subdomain routing.
65
- */
66
- class NodeHttpAdapter {
67
- endpoint;
68
- headers;
69
- url;
70
- constructor(endpoint, headers) {
71
- this.endpoint = endpoint;
72
- this.headers = headers ?? {};
73
- this.url = new URL(endpoint);
74
- }
75
- async execute(document, variables, options) {
76
- const requestUrl = new URL(this.url.href);
77
- const requestHeaders = {
78
- 'Content-Type': 'application/json',
79
- Accept: 'application/json',
80
- ...this.headers,
81
- ...options?.headers,
82
- };
83
- // For *.localhost subdomains, rewrite hostname and inject Host header
84
- if (isLocalhostSubdomain(requestUrl.hostname)) {
85
- requestHeaders['Host'] = requestUrl.host;
86
- requestUrl.hostname = 'localhost';
87
- }
88
- const body = JSON.stringify({
89
- query: document,
90
- variables: variables ?? {},
91
- });
92
- const requestOptions = {
93
- method: 'POST',
94
- headers: requestHeaders,
95
- };
96
- const response = await makeRequest(requestUrl, requestOptions, body, options?.signal);
97
- if (response.statusCode < 200 || response.statusCode >= 300) {
98
- return {
99
- ok: false,
100
- data: null,
101
- errors: [
102
- {
103
- message: `HTTP ${response.statusCode}: ${response.statusMessage}`,
104
- },
105
- ],
106
- };
107
- }
108
- const json = JSON.parse(response.data);
109
- if (json.errors && json.errors.length > 0) {
110
- return {
111
- ok: false,
112
- data: null,
113
- errors: json.errors,
114
- };
115
- }
116
- return {
117
- ok: true,
118
- data: json.data,
119
- errors: undefined,
120
- };
121
- }
122
- setHeaders(headers) {
123
- this.headers = { ...this.headers, ...headers };
124
- }
125
- getEndpoint() {
126
- return this.endpoint;
127
- }
128
- }
129
- exports.NodeHttpAdapter = NodeHttpAdapter;
@@ -1,26 +0,0 @@
1
- import type { GraphQLAdapter, QueryResult } from '@constructive-io/graphql-types';
2
- /**
3
- * Options for individual execute calls.
4
- * Allows per-request header overrides and request cancellation.
5
- */
6
- export interface NodeHttpExecuteOptions {
7
- /** Additional headers to include in this request only */
8
- headers?: Record<string, string>;
9
- /** AbortSignal for request cancellation */
10
- signal?: AbortSignal;
11
- }
12
- /**
13
- * GraphQL adapter that uses node:http/node:https for requests.
14
- *
15
- * Handles *.localhost subdomains by rewriting the hostname to "localhost"
16
- * and injecting the original Host header for server-side subdomain routing.
17
- */
18
- export declare class NodeHttpAdapter implements GraphQLAdapter {
19
- private endpoint;
20
- private headers;
21
- private url;
22
- constructor(endpoint: string, headers?: Record<string, string>);
23
- execute<T>(document: string, variables?: Record<string, unknown>, options?: NodeHttpExecuteOptions): Promise<QueryResult<T>>;
24
- setHeaders(headers: Record<string, string>): void;
25
- getEndpoint(): string;
26
- }
@@ -1,129 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NodeHttpAdapter = void 0;
7
- /**
8
- * Node HTTP adapter for localhost subdomain routing
9
- * @generated by @constructive-io/graphql-codegen
10
- * DO NOT EDIT - changes will be overwritten
11
- */
12
- const node_http_1 = __importDefault(require("node:http"));
13
- const node_https_1 = __importDefault(require("node:https"));
14
- /**
15
- * Check if a hostname is a localhost subdomain that needs special handling.
16
- * Returns true for *.localhost (e.g. auth.localhost) but not bare "localhost".
17
- */
18
- function isLocalhostSubdomain(hostname) {
19
- return hostname.endsWith('.localhost') && hostname !== 'localhost';
20
- }
21
- /**
22
- * Make an HTTP/HTTPS request using native Node modules.
23
- * Supports optional AbortSignal for request cancellation.
24
- */
25
- function makeRequest(url, options, body, signal) {
26
- return new Promise((resolve, reject) => {
27
- if (signal?.aborted) {
28
- reject(new Error('The operation was aborted'));
29
- return;
30
- }
31
- const protocol = url.protocol === 'https:' ? node_https_1.default : node_http_1.default;
32
- const req = protocol.request(url, options, (res) => {
33
- let data = '';
34
- res.setEncoding('utf8');
35
- res.on('data', (chunk) => {
36
- data += chunk;
37
- });
38
- res.on('end', () => {
39
- resolve({
40
- statusCode: res.statusCode || 0,
41
- statusMessage: res.statusMessage || '',
42
- data,
43
- });
44
- });
45
- });
46
- req.on('error', reject);
47
- if (signal) {
48
- const onAbort = () => {
49
- req.destroy(new Error('The operation was aborted'));
50
- };
51
- signal.addEventListener('abort', onAbort, { once: true });
52
- req.on('close', () => {
53
- signal.removeEventListener('abort', onAbort);
54
- });
55
- }
56
- req.write(body);
57
- req.end();
58
- });
59
- }
60
- /**
61
- * GraphQL adapter that uses node:http/node:https for requests.
62
- *
63
- * Handles *.localhost subdomains by rewriting the hostname to "localhost"
64
- * and injecting the original Host header for server-side subdomain routing.
65
- */
66
- class NodeHttpAdapter {
67
- endpoint;
68
- headers;
69
- url;
70
- constructor(endpoint, headers) {
71
- this.endpoint = endpoint;
72
- this.headers = headers ?? {};
73
- this.url = new URL(endpoint);
74
- }
75
- async execute(document, variables, options) {
76
- const requestUrl = new URL(this.url.href);
77
- const requestHeaders = {
78
- 'Content-Type': 'application/json',
79
- Accept: 'application/json',
80
- ...this.headers,
81
- ...options?.headers,
82
- };
83
- // For *.localhost subdomains, rewrite hostname and inject Host header
84
- if (isLocalhostSubdomain(requestUrl.hostname)) {
85
- requestHeaders['Host'] = requestUrl.host;
86
- requestUrl.hostname = 'localhost';
87
- }
88
- const body = JSON.stringify({
89
- query: document,
90
- variables: variables ?? {},
91
- });
92
- const requestOptions = {
93
- method: 'POST',
94
- headers: requestHeaders,
95
- };
96
- const response = await makeRequest(requestUrl, requestOptions, body, options?.signal);
97
- if (response.statusCode < 200 || response.statusCode >= 300) {
98
- return {
99
- ok: false,
100
- data: null,
101
- errors: [
102
- {
103
- message: `HTTP ${response.statusCode}: ${response.statusMessage}`,
104
- },
105
- ],
106
- };
107
- }
108
- const json = JSON.parse(response.data);
109
- if (json.errors && json.errors.length > 0) {
110
- return {
111
- ok: false,
112
- data: null,
113
- errors: json.errors,
114
- };
115
- }
116
- return {
117
- ok: true,
118
- data: json.data,
119
- errors: undefined,
120
- };
121
- }
122
- setHeaders(headers) {
123
- this.headers = { ...this.headers, ...headers };
124
- }
125
- getEndpoint() {
126
- return this.endpoint;
127
- }
128
- }
129
- exports.NodeHttpAdapter = NodeHttpAdapter;
@@ -1,26 +0,0 @@
1
- import type { GraphQLAdapter, QueryResult } from '@constructive-io/graphql-types';
2
- /**
3
- * Options for individual execute calls.
4
- * Allows per-request header overrides and request cancellation.
5
- */
6
- export interface NodeHttpExecuteOptions {
7
- /** Additional headers to include in this request only */
8
- headers?: Record<string, string>;
9
- /** AbortSignal for request cancellation */
10
- signal?: AbortSignal;
11
- }
12
- /**
13
- * GraphQL adapter that uses node:http/node:https for requests.
14
- *
15
- * Handles *.localhost subdomains by rewriting the hostname to "localhost"
16
- * and injecting the original Host header for server-side subdomain routing.
17
- */
18
- export declare class NodeHttpAdapter implements GraphQLAdapter {
19
- private endpoint;
20
- private headers;
21
- private url;
22
- constructor(endpoint: string, headers?: Record<string, string>);
23
- execute<T>(document: string, variables?: Record<string, unknown>, options?: NodeHttpExecuteOptions): Promise<QueryResult<T>>;
24
- setHeaders(headers: Record<string, string>): void;
25
- getEndpoint(): string;
26
- }
@@ -1,129 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NodeHttpAdapter = void 0;
7
- /**
8
- * Node HTTP adapter for localhost subdomain routing
9
- * @generated by @constructive-io/graphql-codegen
10
- * DO NOT EDIT - changes will be overwritten
11
- */
12
- const node_http_1 = __importDefault(require("node:http"));
13
- const node_https_1 = __importDefault(require("node:https"));
14
- /**
15
- * Check if a hostname is a localhost subdomain that needs special handling.
16
- * Returns true for *.localhost (e.g. auth.localhost) but not bare "localhost".
17
- */
18
- function isLocalhostSubdomain(hostname) {
19
- return hostname.endsWith('.localhost') && hostname !== 'localhost';
20
- }
21
- /**
22
- * Make an HTTP/HTTPS request using native Node modules.
23
- * Supports optional AbortSignal for request cancellation.
24
- */
25
- function makeRequest(url, options, body, signal) {
26
- return new Promise((resolve, reject) => {
27
- if (signal?.aborted) {
28
- reject(new Error('The operation was aborted'));
29
- return;
30
- }
31
- const protocol = url.protocol === 'https:' ? node_https_1.default : node_http_1.default;
32
- const req = protocol.request(url, options, (res) => {
33
- let data = '';
34
- res.setEncoding('utf8');
35
- res.on('data', (chunk) => {
36
- data += chunk;
37
- });
38
- res.on('end', () => {
39
- resolve({
40
- statusCode: res.statusCode || 0,
41
- statusMessage: res.statusMessage || '',
42
- data,
43
- });
44
- });
45
- });
46
- req.on('error', reject);
47
- if (signal) {
48
- const onAbort = () => {
49
- req.destroy(new Error('The operation was aborted'));
50
- };
51
- signal.addEventListener('abort', onAbort, { once: true });
52
- req.on('close', () => {
53
- signal.removeEventListener('abort', onAbort);
54
- });
55
- }
56
- req.write(body);
57
- req.end();
58
- });
59
- }
60
- /**
61
- * GraphQL adapter that uses node:http/node:https for requests.
62
- *
63
- * Handles *.localhost subdomains by rewriting the hostname to "localhost"
64
- * and injecting the original Host header for server-side subdomain routing.
65
- */
66
- class NodeHttpAdapter {
67
- endpoint;
68
- headers;
69
- url;
70
- constructor(endpoint, headers) {
71
- this.endpoint = endpoint;
72
- this.headers = headers ?? {};
73
- this.url = new URL(endpoint);
74
- }
75
- async execute(document, variables, options) {
76
- const requestUrl = new URL(this.url.href);
77
- const requestHeaders = {
78
- 'Content-Type': 'application/json',
79
- Accept: 'application/json',
80
- ...this.headers,
81
- ...options?.headers,
82
- };
83
- // For *.localhost subdomains, rewrite hostname and inject Host header
84
- if (isLocalhostSubdomain(requestUrl.hostname)) {
85
- requestHeaders['Host'] = requestUrl.host;
86
- requestUrl.hostname = 'localhost';
87
- }
88
- const body = JSON.stringify({
89
- query: document,
90
- variables: variables ?? {},
91
- });
92
- const requestOptions = {
93
- method: 'POST',
94
- headers: requestHeaders,
95
- };
96
- const response = await makeRequest(requestUrl, requestOptions, body, options?.signal);
97
- if (response.statusCode < 200 || response.statusCode >= 300) {
98
- return {
99
- ok: false,
100
- data: null,
101
- errors: [
102
- {
103
- message: `HTTP ${response.statusCode}: ${response.statusMessage}`,
104
- },
105
- ],
106
- };
107
- }
108
- const json = JSON.parse(response.data);
109
- if (json.errors && json.errors.length > 0) {
110
- return {
111
- ok: false,
112
- data: null,
113
- errors: json.errors,
114
- };
115
- }
116
- return {
117
- ok: true,
118
- data: json.data,
119
- errors: undefined,
120
- };
121
- }
122
- setHeaders(headers) {
123
- this.headers = { ...this.headers, ...headers };
124
- }
125
- getEndpoint() {
126
- return this.endpoint;
127
- }
128
- }
129
- exports.NodeHttpAdapter = NodeHttpAdapter;
@@ -1,26 +0,0 @@
1
- import type { GraphQLAdapter, QueryResult } from '@constructive-io/graphql-types';
2
- /**
3
- * Options for individual execute calls.
4
- * Allows per-request header overrides and request cancellation.
5
- */
6
- export interface NodeHttpExecuteOptions {
7
- /** Additional headers to include in this request only */
8
- headers?: Record<string, string>;
9
- /** AbortSignal for request cancellation */
10
- signal?: AbortSignal;
11
- }
12
- /**
13
- * GraphQL adapter that uses node:http/node:https for requests.
14
- *
15
- * Handles *.localhost subdomains by rewriting the hostname to "localhost"
16
- * and injecting the original Host header for server-side subdomain routing.
17
- */
18
- export declare class NodeHttpAdapter implements GraphQLAdapter {
19
- private endpoint;
20
- private headers;
21
- private url;
22
- constructor(endpoint: string, headers?: Record<string, string>);
23
- execute<T>(document: string, variables?: Record<string, unknown>, options?: NodeHttpExecuteOptions): Promise<QueryResult<T>>;
24
- setHeaders(headers: Record<string, string>): void;
25
- getEndpoint(): string;
26
- }