@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
@@ -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;