@constructive-sdk/cli 0.21.7 → 0.21.9
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/admin/cli/executor.js +2 -2
- package/admin/orm/select-types.d.ts +1 -1
- package/auth/cli/executor.js +2 -2
- package/auth/orm/select-types.d.ts +1 -1
- package/esm/admin/cli/executor.js +2 -2
- package/esm/admin/orm/select-types.d.ts +1 -1
- package/esm/auth/cli/executor.js +2 -2
- package/esm/auth/orm/select-types.d.ts +1 -1
- package/esm/objects/cli/executor.js +2 -2
- package/esm/objects/orm/select-types.d.ts +1 -1
- package/esm/public/cli/commands/api-setting.js +22 -0
- package/esm/public/cli/commands/database-setting.js +22 -0
- package/esm/public/cli/commands.js +3 -3
- package/esm/public/cli/executor.d.ts +1 -1
- package/esm/public/cli/executor.js +2 -2
- package/esm/public/orm/index.d.ts +2 -2
- package/esm/public/orm/index.js +2 -2
- package/esm/public/orm/input-types.d.ts +204 -186
- package/esm/public/orm/models/index.d.ts +1 -1
- package/esm/public/orm/models/index.js +1 -1
- package/esm/public/orm/select-types.d.ts +1 -1
- package/objects/cli/executor.js +2 -2
- package/objects/orm/select-types.d.ts +1 -1
- package/package.json +4 -4
- package/public/cli/commands/api-setting.js +22 -0
- package/public/cli/commands/database-setting.js +22 -0
- package/public/cli/commands.js +3 -3
- package/public/cli/executor.d.ts +1 -1
- package/public/cli/executor.js +2 -2
- package/public/orm/index.d.ts +2 -2
- package/public/orm/index.js +2 -2
- package/public/orm/input-types.d.ts +204 -186
- package/public/orm/models/index.d.ts +1 -1
- package/public/orm/models/index.js +3 -3
- package/public/orm/select-types.d.ts +1 -1
- package/admin/cli/node-fetch.d.ts +0 -26
- package/admin/cli/node-fetch.js +0 -129
- package/admin/orm/node-fetch.d.ts +0 -26
- package/admin/orm/node-fetch.js +0 -129
- package/auth/cli/node-fetch.d.ts +0 -26
- package/auth/cli/node-fetch.js +0 -129
- package/auth/orm/node-fetch.d.ts +0 -26
- package/auth/orm/node-fetch.js +0 -129
- package/esm/admin/cli/node-fetch.d.ts +0 -26
- package/esm/admin/cli/node-fetch.js +0 -122
- package/esm/admin/orm/node-fetch.d.ts +0 -26
- package/esm/admin/orm/node-fetch.js +0 -122
- package/esm/auth/cli/node-fetch.d.ts +0 -26
- package/esm/auth/cli/node-fetch.js +0 -122
- package/esm/auth/orm/node-fetch.d.ts +0 -26
- package/esm/auth/orm/node-fetch.js +0 -122
- package/esm/objects/cli/node-fetch.d.ts +0 -26
- package/esm/objects/cli/node-fetch.js +0 -122
- package/esm/objects/orm/node-fetch.d.ts +0 -26
- package/esm/objects/orm/node-fetch.js +0 -122
- package/esm/public/cli/node-fetch.d.ts +0 -26
- package/esm/public/cli/node-fetch.js +0 -122
- package/esm/public/orm/node-fetch.d.ts +0 -26
- package/esm/public/orm/node-fetch.js +0 -122
- package/objects/cli/node-fetch.d.ts +0 -26
- package/objects/cli/node-fetch.js +0 -129
- package/objects/orm/node-fetch.d.ts +0 -26
- package/objects/orm/node-fetch.js +0 -129
- package/public/cli/node-fetch.d.ts +0 -26
- package/public/cli/node-fetch.js +0 -129
- package/public/orm/node-fetch.d.ts +0 -26
- package/public/orm/node-fetch.js +0 -129
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node HTTP adapter for localhost subdomain routing
|
|
3
|
-
* @generated by @constructive-io/graphql-codegen
|
|
4
|
-
* DO NOT EDIT - changes will be overwritten
|
|
5
|
-
*/
|
|
6
|
-
import http from 'node:http';
|
|
7
|
-
import https from 'node:https';
|
|
8
|
-
/**
|
|
9
|
-
* Check if a hostname is a localhost subdomain that needs special handling.
|
|
10
|
-
* Returns true for *.localhost (e.g. auth.localhost) but not bare "localhost".
|
|
11
|
-
*/
|
|
12
|
-
function isLocalhostSubdomain(hostname) {
|
|
13
|
-
return hostname.endsWith('.localhost') && hostname !== 'localhost';
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Make an HTTP/HTTPS request using native Node modules.
|
|
17
|
-
* Supports optional AbortSignal for request cancellation.
|
|
18
|
-
*/
|
|
19
|
-
function makeRequest(url, options, body, signal) {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
if (signal?.aborted) {
|
|
22
|
-
reject(new Error('The operation was aborted'));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const protocol = url.protocol === 'https:' ? https : http;
|
|
26
|
-
const req = protocol.request(url, options, (res) => {
|
|
27
|
-
let data = '';
|
|
28
|
-
res.setEncoding('utf8');
|
|
29
|
-
res.on('data', (chunk) => {
|
|
30
|
-
data += chunk;
|
|
31
|
-
});
|
|
32
|
-
res.on('end', () => {
|
|
33
|
-
resolve({
|
|
34
|
-
statusCode: res.statusCode || 0,
|
|
35
|
-
statusMessage: res.statusMessage || '',
|
|
36
|
-
data,
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
req.on('error', reject);
|
|
41
|
-
if (signal) {
|
|
42
|
-
const onAbort = () => {
|
|
43
|
-
req.destroy(new Error('The operation was aborted'));
|
|
44
|
-
};
|
|
45
|
-
signal.addEventListener('abort', onAbort, { once: true });
|
|
46
|
-
req.on('close', () => {
|
|
47
|
-
signal.removeEventListener('abort', onAbort);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
req.write(body);
|
|
51
|
-
req.end();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* GraphQL adapter that uses node:http/node:https for requests.
|
|
56
|
-
*
|
|
57
|
-
* Handles *.localhost subdomains by rewriting the hostname to "localhost"
|
|
58
|
-
* and injecting the original Host header for server-side subdomain routing.
|
|
59
|
-
*/
|
|
60
|
-
export class NodeHttpAdapter {
|
|
61
|
-
endpoint;
|
|
62
|
-
headers;
|
|
63
|
-
url;
|
|
64
|
-
constructor(endpoint, headers) {
|
|
65
|
-
this.endpoint = endpoint;
|
|
66
|
-
this.headers = headers ?? {};
|
|
67
|
-
this.url = new URL(endpoint);
|
|
68
|
-
}
|
|
69
|
-
async execute(document, variables, options) {
|
|
70
|
-
const requestUrl = new URL(this.url.href);
|
|
71
|
-
const requestHeaders = {
|
|
72
|
-
'Content-Type': 'application/json',
|
|
73
|
-
Accept: 'application/json',
|
|
74
|
-
...this.headers,
|
|
75
|
-
...options?.headers,
|
|
76
|
-
};
|
|
77
|
-
// For *.localhost subdomains, rewrite hostname and inject Host header
|
|
78
|
-
if (isLocalhostSubdomain(requestUrl.hostname)) {
|
|
79
|
-
requestHeaders['Host'] = requestUrl.host;
|
|
80
|
-
requestUrl.hostname = 'localhost';
|
|
81
|
-
}
|
|
82
|
-
const body = JSON.stringify({
|
|
83
|
-
query: document,
|
|
84
|
-
variables: variables ?? {},
|
|
85
|
-
});
|
|
86
|
-
const requestOptions = {
|
|
87
|
-
method: 'POST',
|
|
88
|
-
headers: requestHeaders,
|
|
89
|
-
};
|
|
90
|
-
const response = await makeRequest(requestUrl, requestOptions, body, options?.signal);
|
|
91
|
-
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
92
|
-
return {
|
|
93
|
-
ok: false,
|
|
94
|
-
data: null,
|
|
95
|
-
errors: [
|
|
96
|
-
{
|
|
97
|
-
message: `HTTP ${response.statusCode}: ${response.statusMessage}`,
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const json = JSON.parse(response.data);
|
|
103
|
-
if (json.errors && json.errors.length > 0) {
|
|
104
|
-
return {
|
|
105
|
-
ok: false,
|
|
106
|
-
data: null,
|
|
107
|
-
errors: json.errors,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
ok: true,
|
|
112
|
-
data: json.data,
|
|
113
|
-
errors: undefined,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
setHeaders(headers) {
|
|
117
|
-
this.headers = { ...this.headers, ...headers };
|
|
118
|
-
}
|
|
119
|
-
getEndpoint() {
|
|
120
|
-
return this.endpoint;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -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,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node HTTP adapter for localhost subdomain routing
|
|
3
|
-
* @generated by @constructive-io/graphql-codegen
|
|
4
|
-
* DO NOT EDIT - changes will be overwritten
|
|
5
|
-
*/
|
|
6
|
-
import http from 'node:http';
|
|
7
|
-
import https from 'node:https';
|
|
8
|
-
/**
|
|
9
|
-
* Check if a hostname is a localhost subdomain that needs special handling.
|
|
10
|
-
* Returns true for *.localhost (e.g. auth.localhost) but not bare "localhost".
|
|
11
|
-
*/
|
|
12
|
-
function isLocalhostSubdomain(hostname) {
|
|
13
|
-
return hostname.endsWith('.localhost') && hostname !== 'localhost';
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Make an HTTP/HTTPS request using native Node modules.
|
|
17
|
-
* Supports optional AbortSignal for request cancellation.
|
|
18
|
-
*/
|
|
19
|
-
function makeRequest(url, options, body, signal) {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
if (signal?.aborted) {
|
|
22
|
-
reject(new Error('The operation was aborted'));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const protocol = url.protocol === 'https:' ? https : http;
|
|
26
|
-
const req = protocol.request(url, options, (res) => {
|
|
27
|
-
let data = '';
|
|
28
|
-
res.setEncoding('utf8');
|
|
29
|
-
res.on('data', (chunk) => {
|
|
30
|
-
data += chunk;
|
|
31
|
-
});
|
|
32
|
-
res.on('end', () => {
|
|
33
|
-
resolve({
|
|
34
|
-
statusCode: res.statusCode || 0,
|
|
35
|
-
statusMessage: res.statusMessage || '',
|
|
36
|
-
data,
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
req.on('error', reject);
|
|
41
|
-
if (signal) {
|
|
42
|
-
const onAbort = () => {
|
|
43
|
-
req.destroy(new Error('The operation was aborted'));
|
|
44
|
-
};
|
|
45
|
-
signal.addEventListener('abort', onAbort, { once: true });
|
|
46
|
-
req.on('close', () => {
|
|
47
|
-
signal.removeEventListener('abort', onAbort);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
req.write(body);
|
|
51
|
-
req.end();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* GraphQL adapter that uses node:http/node:https for requests.
|
|
56
|
-
*
|
|
57
|
-
* Handles *.localhost subdomains by rewriting the hostname to "localhost"
|
|
58
|
-
* and injecting the original Host header for server-side subdomain routing.
|
|
59
|
-
*/
|
|
60
|
-
export class NodeHttpAdapter {
|
|
61
|
-
endpoint;
|
|
62
|
-
headers;
|
|
63
|
-
url;
|
|
64
|
-
constructor(endpoint, headers) {
|
|
65
|
-
this.endpoint = endpoint;
|
|
66
|
-
this.headers = headers ?? {};
|
|
67
|
-
this.url = new URL(endpoint);
|
|
68
|
-
}
|
|
69
|
-
async execute(document, variables, options) {
|
|
70
|
-
const requestUrl = new URL(this.url.href);
|
|
71
|
-
const requestHeaders = {
|
|
72
|
-
'Content-Type': 'application/json',
|
|
73
|
-
Accept: 'application/json',
|
|
74
|
-
...this.headers,
|
|
75
|
-
...options?.headers,
|
|
76
|
-
};
|
|
77
|
-
// For *.localhost subdomains, rewrite hostname and inject Host header
|
|
78
|
-
if (isLocalhostSubdomain(requestUrl.hostname)) {
|
|
79
|
-
requestHeaders['Host'] = requestUrl.host;
|
|
80
|
-
requestUrl.hostname = 'localhost';
|
|
81
|
-
}
|
|
82
|
-
const body = JSON.stringify({
|
|
83
|
-
query: document,
|
|
84
|
-
variables: variables ?? {},
|
|
85
|
-
});
|
|
86
|
-
const requestOptions = {
|
|
87
|
-
method: 'POST',
|
|
88
|
-
headers: requestHeaders,
|
|
89
|
-
};
|
|
90
|
-
const response = await makeRequest(requestUrl, requestOptions, body, options?.signal);
|
|
91
|
-
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
92
|
-
return {
|
|
93
|
-
ok: false,
|
|
94
|
-
data: null,
|
|
95
|
-
errors: [
|
|
96
|
-
{
|
|
97
|
-
message: `HTTP ${response.statusCode}: ${response.statusMessage}`,
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const json = JSON.parse(response.data);
|
|
103
|
-
if (json.errors && json.errors.length > 0) {
|
|
104
|
-
return {
|
|
105
|
-
ok: false,
|
|
106
|
-
data: null,
|
|
107
|
-
errors: json.errors,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
ok: true,
|
|
112
|
-
data: json.data,
|
|
113
|
-
errors: undefined,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
setHeaders(headers) {
|
|
117
|
-
this.headers = { ...this.headers, ...headers };
|
|
118
|
-
}
|
|
119
|
-
getEndpoint() {
|
|
120
|
-
return this.endpoint;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -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,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node HTTP adapter for localhost subdomain routing
|
|
3
|
-
* @generated by @constructive-io/graphql-codegen
|
|
4
|
-
* DO NOT EDIT - changes will be overwritten
|
|
5
|
-
*/
|
|
6
|
-
import http from 'node:http';
|
|
7
|
-
import https from 'node:https';
|
|
8
|
-
/**
|
|
9
|
-
* Check if a hostname is a localhost subdomain that needs special handling.
|
|
10
|
-
* Returns true for *.localhost (e.g. auth.localhost) but not bare "localhost".
|
|
11
|
-
*/
|
|
12
|
-
function isLocalhostSubdomain(hostname) {
|
|
13
|
-
return hostname.endsWith('.localhost') && hostname !== 'localhost';
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Make an HTTP/HTTPS request using native Node modules.
|
|
17
|
-
* Supports optional AbortSignal for request cancellation.
|
|
18
|
-
*/
|
|
19
|
-
function makeRequest(url, options, body, signal) {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
if (signal?.aborted) {
|
|
22
|
-
reject(new Error('The operation was aborted'));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const protocol = url.protocol === 'https:' ? https : http;
|
|
26
|
-
const req = protocol.request(url, options, (res) => {
|
|
27
|
-
let data = '';
|
|
28
|
-
res.setEncoding('utf8');
|
|
29
|
-
res.on('data', (chunk) => {
|
|
30
|
-
data += chunk;
|
|
31
|
-
});
|
|
32
|
-
res.on('end', () => {
|
|
33
|
-
resolve({
|
|
34
|
-
statusCode: res.statusCode || 0,
|
|
35
|
-
statusMessage: res.statusMessage || '',
|
|
36
|
-
data,
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
req.on('error', reject);
|
|
41
|
-
if (signal) {
|
|
42
|
-
const onAbort = () => {
|
|
43
|
-
req.destroy(new Error('The operation was aborted'));
|
|
44
|
-
};
|
|
45
|
-
signal.addEventListener('abort', onAbort, { once: true });
|
|
46
|
-
req.on('close', () => {
|
|
47
|
-
signal.removeEventListener('abort', onAbort);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
req.write(body);
|
|
51
|
-
req.end();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* GraphQL adapter that uses node:http/node:https for requests.
|
|
56
|
-
*
|
|
57
|
-
* Handles *.localhost subdomains by rewriting the hostname to "localhost"
|
|
58
|
-
* and injecting the original Host header for server-side subdomain routing.
|
|
59
|
-
*/
|
|
60
|
-
export class NodeHttpAdapter {
|
|
61
|
-
endpoint;
|
|
62
|
-
headers;
|
|
63
|
-
url;
|
|
64
|
-
constructor(endpoint, headers) {
|
|
65
|
-
this.endpoint = endpoint;
|
|
66
|
-
this.headers = headers ?? {};
|
|
67
|
-
this.url = new URL(endpoint);
|
|
68
|
-
}
|
|
69
|
-
async execute(document, variables, options) {
|
|
70
|
-
const requestUrl = new URL(this.url.href);
|
|
71
|
-
const requestHeaders = {
|
|
72
|
-
'Content-Type': 'application/json',
|
|
73
|
-
Accept: 'application/json',
|
|
74
|
-
...this.headers,
|
|
75
|
-
...options?.headers,
|
|
76
|
-
};
|
|
77
|
-
// For *.localhost subdomains, rewrite hostname and inject Host header
|
|
78
|
-
if (isLocalhostSubdomain(requestUrl.hostname)) {
|
|
79
|
-
requestHeaders['Host'] = requestUrl.host;
|
|
80
|
-
requestUrl.hostname = 'localhost';
|
|
81
|
-
}
|
|
82
|
-
const body = JSON.stringify({
|
|
83
|
-
query: document,
|
|
84
|
-
variables: variables ?? {},
|
|
85
|
-
});
|
|
86
|
-
const requestOptions = {
|
|
87
|
-
method: 'POST',
|
|
88
|
-
headers: requestHeaders,
|
|
89
|
-
};
|
|
90
|
-
const response = await makeRequest(requestUrl, requestOptions, body, options?.signal);
|
|
91
|
-
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
92
|
-
return {
|
|
93
|
-
ok: false,
|
|
94
|
-
data: null,
|
|
95
|
-
errors: [
|
|
96
|
-
{
|
|
97
|
-
message: `HTTP ${response.statusCode}: ${response.statusMessage}`,
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const json = JSON.parse(response.data);
|
|
103
|
-
if (json.errors && json.errors.length > 0) {
|
|
104
|
-
return {
|
|
105
|
-
ok: false,
|
|
106
|
-
data: null,
|
|
107
|
-
errors: json.errors,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
ok: true,
|
|
112
|
-
data: json.data,
|
|
113
|
-
errors: undefined,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
setHeaders(headers) {
|
|
117
|
-
this.headers = { ...this.headers, ...headers };
|
|
118
|
-
}
|
|
119
|
-
getEndpoint() {
|
|
120
|
-
return this.endpoint;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -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,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node HTTP adapter for localhost subdomain routing
|
|
3
|
-
* @generated by @constructive-io/graphql-codegen
|
|
4
|
-
* DO NOT EDIT - changes will be overwritten
|
|
5
|
-
*/
|
|
6
|
-
import http from 'node:http';
|
|
7
|
-
import https from 'node:https';
|
|
8
|
-
/**
|
|
9
|
-
* Check if a hostname is a localhost subdomain that needs special handling.
|
|
10
|
-
* Returns true for *.localhost (e.g. auth.localhost) but not bare "localhost".
|
|
11
|
-
*/
|
|
12
|
-
function isLocalhostSubdomain(hostname) {
|
|
13
|
-
return hostname.endsWith('.localhost') && hostname !== 'localhost';
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Make an HTTP/HTTPS request using native Node modules.
|
|
17
|
-
* Supports optional AbortSignal for request cancellation.
|
|
18
|
-
*/
|
|
19
|
-
function makeRequest(url, options, body, signal) {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
if (signal?.aborted) {
|
|
22
|
-
reject(new Error('The operation was aborted'));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const protocol = url.protocol === 'https:' ? https : http;
|
|
26
|
-
const req = protocol.request(url, options, (res) => {
|
|
27
|
-
let data = '';
|
|
28
|
-
res.setEncoding('utf8');
|
|
29
|
-
res.on('data', (chunk) => {
|
|
30
|
-
data += chunk;
|
|
31
|
-
});
|
|
32
|
-
res.on('end', () => {
|
|
33
|
-
resolve({
|
|
34
|
-
statusCode: res.statusCode || 0,
|
|
35
|
-
statusMessage: res.statusMessage || '',
|
|
36
|
-
data,
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
req.on('error', reject);
|
|
41
|
-
if (signal) {
|
|
42
|
-
const onAbort = () => {
|
|
43
|
-
req.destroy(new Error('The operation was aborted'));
|
|
44
|
-
};
|
|
45
|
-
signal.addEventListener('abort', onAbort, { once: true });
|
|
46
|
-
req.on('close', () => {
|
|
47
|
-
signal.removeEventListener('abort', onAbort);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
req.write(body);
|
|
51
|
-
req.end();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* GraphQL adapter that uses node:http/node:https for requests.
|
|
56
|
-
*
|
|
57
|
-
* Handles *.localhost subdomains by rewriting the hostname to "localhost"
|
|
58
|
-
* and injecting the original Host header for server-side subdomain routing.
|
|
59
|
-
*/
|
|
60
|
-
export class NodeHttpAdapter {
|
|
61
|
-
endpoint;
|
|
62
|
-
headers;
|
|
63
|
-
url;
|
|
64
|
-
constructor(endpoint, headers) {
|
|
65
|
-
this.endpoint = endpoint;
|
|
66
|
-
this.headers = headers ?? {};
|
|
67
|
-
this.url = new URL(endpoint);
|
|
68
|
-
}
|
|
69
|
-
async execute(document, variables, options) {
|
|
70
|
-
const requestUrl = new URL(this.url.href);
|
|
71
|
-
const requestHeaders = {
|
|
72
|
-
'Content-Type': 'application/json',
|
|
73
|
-
Accept: 'application/json',
|
|
74
|
-
...this.headers,
|
|
75
|
-
...options?.headers,
|
|
76
|
-
};
|
|
77
|
-
// For *.localhost subdomains, rewrite hostname and inject Host header
|
|
78
|
-
if (isLocalhostSubdomain(requestUrl.hostname)) {
|
|
79
|
-
requestHeaders['Host'] = requestUrl.host;
|
|
80
|
-
requestUrl.hostname = 'localhost';
|
|
81
|
-
}
|
|
82
|
-
const body = JSON.stringify({
|
|
83
|
-
query: document,
|
|
84
|
-
variables: variables ?? {},
|
|
85
|
-
});
|
|
86
|
-
const requestOptions = {
|
|
87
|
-
method: 'POST',
|
|
88
|
-
headers: requestHeaders,
|
|
89
|
-
};
|
|
90
|
-
const response = await makeRequest(requestUrl, requestOptions, body, options?.signal);
|
|
91
|
-
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
92
|
-
return {
|
|
93
|
-
ok: false,
|
|
94
|
-
data: null,
|
|
95
|
-
errors: [
|
|
96
|
-
{
|
|
97
|
-
message: `HTTP ${response.statusCode}: ${response.statusMessage}`,
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const json = JSON.parse(response.data);
|
|
103
|
-
if (json.errors && json.errors.length > 0) {
|
|
104
|
-
return {
|
|
105
|
-
ok: false,
|
|
106
|
-
data: null,
|
|
107
|
-
errors: json.errors,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
ok: true,
|
|
112
|
-
data: json.data,
|
|
113
|
-
errors: undefined,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
setHeaders(headers) {
|
|
117
|
-
this.headers = { ...this.headers, ...headers };
|
|
118
|
-
}
|
|
119
|
-
getEndpoint() {
|
|
120
|
-
return this.endpoint;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -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
|
-
}
|