@madebyentropy/tnl 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.
Files changed (198) hide show
  1. package/LICENSE +28 -0
  2. package/NOTICE +5 -0
  3. package/THIRD_PARTY_LICENSES.txt +3297 -0
  4. package/dist/adapters/ioredis.d.ts +7 -0
  5. package/dist/adapters/ioredis.js +87 -0
  6. package/dist/adapters/node-postgres.d.ts +8 -0
  7. package/dist/adapters/node-postgres.js +41 -0
  8. package/dist/adapters/postgres-js.d.ts +7 -0
  9. package/dist/adapters/postgres-js.js +55 -0
  10. package/dist/bin/tnl.d.ts +2 -0
  11. package/dist/bin/tnl.js +16 -0
  12. package/dist/browser.d.ts +18 -0
  13. package/dist/browser.js +43 -0
  14. package/dist/bun.d.ts +9 -0
  15. package/dist/bun.js +6 -0
  16. package/dist/cloudflare.d.ts +9 -0
  17. package/dist/cloudflare.js +16 -0
  18. package/dist/config.d.ts +107 -0
  19. package/dist/config.gen.d.ts +1185 -0
  20. package/dist/config.gen.js +2 -0
  21. package/dist/config.js +3 -0
  22. package/dist/control.d.ts +5 -0
  23. package/dist/control.js +9 -0
  24. package/dist/durable-object.d.ts +51 -0
  25. package/dist/durable-object.js +374 -0
  26. package/dist/durable-object.worker.d.ts +5 -0
  27. package/dist/durable-object.worker.js +11 -0
  28. package/dist/errors.d.ts +17 -0
  29. package/dist/errors.js +230 -0
  30. package/dist/index.d.ts +10 -0
  31. package/dist/index.js +2 -0
  32. package/dist/internal/connector/cancellation.d.ts +7 -0
  33. package/dist/internal/connector/cancellation.js +30 -0
  34. package/dist/internal/connector/client.d.ts +62 -0
  35. package/dist/internal/connector/client.js +504 -0
  36. package/dist/internal/connector/client_factory.d.ts +6 -0
  37. package/dist/internal/connector/client_factory.js +123 -0
  38. package/dist/internal/connector/connection.d.ts +39 -0
  39. package/dist/internal/connector/connection.js +739 -0
  40. package/dist/internal/connector/connection_ipc.d.ts +12 -0
  41. package/dist/internal/connector/connection_ipc.js +198 -0
  42. package/dist/internal/connector/context.d.ts +28 -0
  43. package/dist/internal/connector/context.js +19 -0
  44. package/dist/internal/connector/contract.d.ts +392 -0
  45. package/dist/internal/connector/contract.js +56 -0
  46. package/dist/internal/connector/deployment_types.d.ts +27 -0
  47. package/dist/internal/connector/deployment_types.js +1 -0
  48. package/dist/internal/connector/driver_socket.d.ts +21 -0
  49. package/dist/internal/connector/driver_socket.js +129 -0
  50. package/dist/internal/connector/management.d.ts +29 -0
  51. package/dist/internal/connector/management.js +118 -0
  52. package/dist/internal/connector/native_operations.d.ts +16 -0
  53. package/dist/internal/connector/native_operations.js +30 -0
  54. package/dist/internal/connector/native_stream.d.ts +7 -0
  55. package/dist/internal/connector/native_stream.js +219 -0
  56. package/dist/internal/connector/operation_handles.d.ts +9 -0
  57. package/dist/internal/connector/operation_handles.js +18 -0
  58. package/dist/internal/connector/portable_operations.d.ts +13 -0
  59. package/dist/internal/connector/portable_operations.js +25 -0
  60. package/dist/internal/connector/snapshot.d.ts +183 -0
  61. package/dist/internal/connector/snapshot.js +47 -0
  62. package/dist/internal/connector/wasm_abi.d.ts +76 -0
  63. package/dist/internal/connector/wasm_abi.js +5 -0
  64. package/dist/internal/connector/wasm_client.d.ts +58 -0
  65. package/dist/internal/connector/wasm_client.js +545 -0
  66. package/dist/internal/connector/wasm_loader.d.ts +15 -0
  67. package/dist/internal/connector/wasm_loader.js +99 -0
  68. package/dist/internal/connector/wasm_stream.d.ts +4 -0
  69. package/dist/internal/connector/wasm_stream.js +177 -0
  70. package/dist/internal/connector/workload/contract.d.ts +54 -0
  71. package/dist/internal/connector/workload/contract.js +14 -0
  72. package/dist/internal/connector/workload/provider.d.ts +24 -0
  73. package/dist/internal/connector/workload/provider.js +130 -0
  74. package/dist/internal/enrollment_source.d.ts +4 -0
  75. package/dist/internal/enrollment_source.js +34 -0
  76. package/dist/internal/management/client/client.gen.d.ts +2 -0
  77. package/dist/internal/management/client/client.gen.js +216 -0
  78. package/dist/internal/management/client/index.d.ts +10 -0
  79. package/dist/internal/management/client/index.js +6 -0
  80. package/dist/internal/management/client/types.gen.d.ts +120 -0
  81. package/dist/internal/management/client/types.gen.js +2 -0
  82. package/dist/internal/management/client/utils.gen.d.ts +37 -0
  83. package/dist/internal/management/client/utils.gen.js +228 -0
  84. package/dist/internal/management/client.gen.d.ts +12 -0
  85. package/dist/internal/management/client.gen.js +3 -0
  86. package/dist/internal/management/core/auth.gen.d.ts +25 -0
  87. package/dist/internal/management/core/auth.gen.js +14 -0
  88. package/dist/internal/management/core/bodySerializer.gen.d.ts +25 -0
  89. package/dist/internal/management/core/bodySerializer.gen.js +57 -0
  90. package/dist/internal/management/core/params.gen.d.ts +43 -0
  91. package/dist/internal/management/core/params.gen.js +109 -0
  92. package/dist/internal/management/core/pathSerializer.gen.d.ts +33 -0
  93. package/dist/internal/management/core/pathSerializer.gen.js +106 -0
  94. package/dist/internal/management/core/queryKeySerializer.gen.d.ts +18 -0
  95. package/dist/internal/management/core/queryKeySerializer.gen.js +92 -0
  96. package/dist/internal/management/core/serverSentEvents.gen.d.ts +71 -0
  97. package/dist/internal/management/core/serverSentEvents.gen.js +132 -0
  98. package/dist/internal/management/core/types.gen.d.ts +83 -0
  99. package/dist/internal/management/core/types.gen.js +2 -0
  100. package/dist/internal/management/core/utils.gen.d.ts +19 -0
  101. package/dist/internal/management/core/utils.gen.js +87 -0
  102. package/dist/internal/management/index.d.ts +2 -0
  103. package/dist/internal/management/index.js +2 -0
  104. package/dist/internal/management/sdk.gen.d.ts +73 -0
  105. package/dist/internal/management/sdk.gen.js +191 -0
  106. package/dist/internal/management/types.gen.d.ts +464 -0
  107. package/dist/internal/management/types.gen.js +2 -0
  108. package/dist/internal/management/zod.gen.d.ts +850 -0
  109. package/dist/internal/management/zod.gen.js +252 -0
  110. package/dist/internal/native/launcher.d.ts +8 -0
  111. package/dist/internal/native/launcher.js +75 -0
  112. package/dist/internal/native/native-targets.d.ts +9 -0
  113. package/dist/internal/native/native-targets.js +8 -0
  114. package/dist/internal/portable/cloudflare-publisher-client.d.ts +54 -0
  115. package/dist/internal/portable/cloudflare-publisher-client.js +91 -0
  116. package/dist/internal/portable/cloudflare-publisher.d.ts +19 -0
  117. package/dist/internal/portable/cloudflare-publisher.js +210 -0
  118. package/dist/internal/portable/durable-deployment.d.ts +10 -0
  119. package/dist/internal/portable/durable-deployment.js +22 -0
  120. package/dist/internal/portable/enrollment.d.ts +26 -0
  121. package/dist/internal/portable/enrollment.js +196 -0
  122. package/dist/internal/portable/publication.d.ts +54 -0
  123. package/dist/internal/portable/publication.js +304 -0
  124. package/dist/internal/portable/request.d.ts +1 -0
  125. package/dist/internal/portable/request.js +20 -0
  126. package/dist/internal/portable/storage-browser.d.ts +9 -0
  127. package/dist/internal/portable/storage-browser.js +115 -0
  128. package/dist/internal/portable/storage-durable-object.d.ts +11 -0
  129. package/dist/internal/portable/storage-durable-object.js +110 -0
  130. package/dist/internal/portable/storage-host.d.ts +8 -0
  131. package/dist/internal/portable/storage-host.js +142 -0
  132. package/dist/internal/portable/storage.d.ts +15 -0
  133. package/dist/internal/portable/storage.js +29 -0
  134. package/dist/internal/project/native_runtime.d.ts +24 -0
  135. package/dist/internal/project/native_runtime.js +23 -0
  136. package/dist/internal/project/runtime.d.ts +467 -0
  137. package/dist/internal/project/runtime.js +183 -0
  138. package/dist/internal/project/service_metadata.d.ts +3 -0
  139. package/dist/internal/project/service_metadata.js +12 -0
  140. package/dist/internal/publication_certificate.d.ts +28 -0
  141. package/dist/internal/publication_certificate.js +32 -0
  142. package/dist/internal/publication_run.d.ts +8 -0
  143. package/dist/internal/publication_run.js +19 -0
  144. package/dist/internal/publisher/app.d.ts +33 -0
  145. package/dist/internal/publisher/app.js +317 -0
  146. package/dist/internal/publisher/fetch.d.ts +6 -0
  147. package/dist/internal/publisher/fetch.js +135 -0
  148. package/dist/internal/publisher/fetch_types.d.ts +1 -0
  149. package/dist/internal/publisher/fetch_types.js +1 -0
  150. package/dist/internal/publisher/framework.d.ts +27 -0
  151. package/dist/internal/publisher/framework.js +82 -0
  152. package/dist/internal/publisher/local.d.ts +39 -0
  153. package/dist/internal/publisher/local.js +312 -0
  154. package/dist/internal/publisher/native_publisher.d.ts +25 -0
  155. package/dist/internal/publisher/native_publisher.js +228 -0
  156. package/dist/internal/publisher/port.d.ts +2 -0
  157. package/dist/internal/publisher/port.js +15 -0
  158. package/dist/internal/publisher/publication.d.ts +88 -0
  159. package/dist/internal/publisher/publication.js +627 -0
  160. package/dist/internal/publisher/register.d.ts +31 -0
  161. package/dist/internal/publisher/register.js +136 -0
  162. package/dist/internal/publisher/registration.d.ts +385 -0
  163. package/dist/internal/publisher/registration.js +223 -0
  164. package/dist/internal/publisher/status.d.ts +47 -0
  165. package/dist/internal/publisher/status.js +137 -0
  166. package/dist/internal/publisher/target.d.ts +6 -0
  167. package/dist/internal/publisher/target.js +44 -0
  168. package/dist/internal/runtime_resources.d.ts +38 -0
  169. package/dist/internal/runtime_resources.js +52 -0
  170. package/dist/internal/tracing.d.ts +10 -0
  171. package/dist/internal/tracing.js +78 -0
  172. package/dist/internal/validation.d.ts +3 -0
  173. package/dist/internal/validation.js +9 -0
  174. package/dist/internal/values.d.ts +27 -0
  175. package/dist/internal/values.js +54 -0
  176. package/dist/next.d.ts +12 -0
  177. package/dist/next.js +82 -0
  178. package/dist/node.d.ts +9 -0
  179. package/dist/node.js +6 -0
  180. package/dist/project.d.ts +173 -0
  181. package/dist/project.js +1 -0
  182. package/dist/response.d.ts +1 -0
  183. package/dist/response.js +34 -0
  184. package/dist/third-party-licenses.txt +1537 -0
  185. package/dist/vite.d.ts +5 -0
  186. package/dist/vite.js +200 -0
  187. package/dist/wasm/build.json +16 -0
  188. package/dist/wasm/connector.wasm +0 -0
  189. package/dist/wasm/go-license.txt +27 -0
  190. package/dist/wasm/publisher.wasm +0 -0
  191. package/dist/wasm/third-party-licenses.txt +3297 -0
  192. package/dist/wasm/wasm_exec.d.ts +1 -0
  193. package/dist/wasm/wasm_exec.js +575 -0
  194. package/dist/workload.d.ts +11 -0
  195. package/dist/workload.js +4 -0
  196. package/package.json +159 -4
  197. package/readme.md +13 -0
  198. package/README.md +0 -3
package/dist/errors.js ADDED
@@ -0,0 +1,230 @@
1
+ const definitions = {
2
+ "sdk.publication_failed": {
3
+ class: "unavailable",
4
+ retry: "later",
5
+ message: "the public URL did not become available; check tnl status and the local listener",
6
+ },
7
+ "sdk.certificate_unavailable": {
8
+ class: "unavailable",
9
+ retry: "later",
10
+ message: "the publication has no valid installed certificate",
11
+ },
12
+ "sdk.certificate_invalid": {
13
+ class: "invalid",
14
+ retry: "after_change",
15
+ message: "the supplied certificate and key are invalid",
16
+ },
17
+ "sdk.publication_cleanup_failed": {
18
+ class: "unavailable",
19
+ retry: "never",
20
+ message: "the publication stopped, but cleanup failed; the temporary public URL may remain until control expires it",
21
+ },
22
+ "sdk.owner_conflict": {
23
+ class: "conflict",
24
+ retry: "after_change",
25
+ message: "another live app owns this service; stop it before starting another",
26
+ },
27
+ "sdk.registration_stale": {
28
+ class: "conflict",
29
+ retry: "later",
30
+ message: "app registration expired; prepare and register its listener again",
31
+ },
32
+ "sdk.authentication_required": {
33
+ class: "unavailable",
34
+ retry: "after_change",
35
+ message: "tnl needs a saved login; run tnl auth login, then start the app again",
36
+ },
37
+ "sdk.publisher_setup_required": {
38
+ class: "invalid",
39
+ retry: "after_change",
40
+ message: "no namespace publisher is set up; run tnl publisher setup --namespace, then try again",
41
+ },
42
+ "sdk.publisher_credential_file_invalid": {
43
+ class: "invalid",
44
+ retry: "after_change",
45
+ message: "the selected publisher file is invalid; check the file and its permissions",
46
+ },
47
+ "sdk.configuration_invalid": {
48
+ class: "invalid",
49
+ retry: "after_change",
50
+ message: "tnl framework configuration is invalid; check the integration options and project configuration",
51
+ },
52
+ "sdk.service_unprepared": {
53
+ class: "unavailable",
54
+ retry: "after_change",
55
+ message: "tnl service metadata is unavailable; start the app with its tnl integration before reading tnl.services",
56
+ },
57
+ "sdk.connection_unavailable": {
58
+ class: "unavailable",
59
+ retry: "later",
60
+ message: "the connector owner is unavailable; prepare connections again",
61
+ },
62
+ "sdk.local_connection_unavailable": {
63
+ class: "unavailable",
64
+ retry: "later",
65
+ message: "could not resolve the local PostgreSQL listener; check the project target and Docker, then try again",
66
+ },
67
+ "sdk.connection_server_only": {
68
+ class: "unavailable",
69
+ retry: "after_change",
70
+ message: "connector connections require Node.js or Bun; create a deployment client in server code",
71
+ },
72
+ "sdk.capability_unsupported": {
73
+ class: "invalid",
74
+ retry: "after_change",
75
+ message: "this operation needs a native tnl process; use Node.js or Bun, or select a remote stream-backed connection",
76
+ },
77
+ "sdk.wasm_unavailable": {
78
+ class: "unavailable",
79
+ retry: "after_change",
80
+ message: "the tnl Go/WASM runtime could not start; check the packaged WASM files and runtime support",
81
+ },
82
+ "sdk.wasm_invalid": {
83
+ class: "internal",
84
+ retry: "after_change",
85
+ message: "the tnl Go/WASM runtime returned an invalid result; check SDK compatibility",
86
+ },
87
+ "sdk.client_closed": {
88
+ class: "invalid",
89
+ retry: "after_change",
90
+ message: "the client factory is closed; create a new factory",
91
+ },
92
+ "sdk.client_capacity": {
93
+ class: "unavailable",
94
+ retry: "after_change",
95
+ message: "the client factory has too many retained bindings; close it before creating another",
96
+ },
97
+ "sdk.workload_required": {
98
+ class: "invalid",
99
+ retry: "after_change",
100
+ message: "select one saved workload with TNL_WORKLOAD or configureWorkload before connecting",
101
+ },
102
+ "sdk.workload_manifest_invalid": {
103
+ class: "invalid",
104
+ retry: "after_change",
105
+ message: "the workload manifest is missing or invalid; package .tnl/generated/workloads.json from tnl generate with the server artifact",
106
+ },
107
+ "sdk.workload_assertion_unavailable": {
108
+ class: "unavailable",
109
+ retry: "after_change",
110
+ message: "the selected workload assertion is unavailable; check its request-scoped provider or configured token source",
111
+ },
112
+ "sdk.workload_denied": {
113
+ class: "conflict",
114
+ retry: "after_change",
115
+ message: "workload access was denied; check the saved workload policy and service access",
116
+ },
117
+ "sdk.workload_unavailable": {
118
+ class: "unavailable",
119
+ retry: "later",
120
+ message: "workload request preparation failed; check control availability before trying a new request",
121
+ },
122
+ "sdk.workload_response_invalid": {
123
+ class: "internal",
124
+ retry: "after_change",
125
+ message: "control returned an invalid workload response; check server and SDK compatibility",
126
+ },
127
+ "sdk.runtime_invalid": {
128
+ class: "invalid",
129
+ retry: "after_change",
130
+ message: "tnl project metadata is invalid; restart the app to prepare it again",
131
+ },
132
+ "sdk.protocol_unsupported": {
133
+ class: "invalid",
134
+ retry: "after_change",
135
+ message: "unsupported local publisher protocol; upgrade tnl and its framework integrations",
136
+ },
137
+ "sdk.project_unavailable": {
138
+ class: "unavailable",
139
+ retry: "after_change",
140
+ message: "tnl project metadata is unavailable; check file access and restart the app",
141
+ },
142
+ "sdk.target_invalid": {
143
+ class: "invalid",
144
+ retry: "after_change",
145
+ message: "tnl development target must be an HTTP or HTTPS listener on a port between 1 and 65535",
146
+ },
147
+ "sdk.dev_unavailable": {
148
+ class: "unavailable",
149
+ retry: "later",
150
+ message: "the local tnl publisher is unavailable; restart the app to reconnect",
151
+ },
152
+ "sdk.response_invalid": {
153
+ class: "internal",
154
+ retry: "after_change",
155
+ message: "the local publisher returned an invalid response; upgrade tnl and its integrations and restart the app",
156
+ },
157
+ "sdk.request_rejected": {
158
+ class: "conflict",
159
+ retry: "after_change",
160
+ message: "the local publisher rejected the framework request; check tnl status",
161
+ },
162
+ "sdk.listener_failed": {
163
+ class: "unavailable",
164
+ retry: "after_change",
165
+ message: "the development listener could not start; check the listener and restart the app",
166
+ },
167
+ "sdk.cleanup_failed": {
168
+ class: "internal",
169
+ retry: "after_change",
170
+ message: "development listener setup and cleanup failed; stop the local service before retrying",
171
+ },
172
+ "sdk.native_unsupported": {
173
+ class: "invalid",
174
+ retry: "never",
175
+ message: "unsupported platform; tnl supports macOS and Linux on arm64 and x64",
176
+ },
177
+ "sdk.native_missing": {
178
+ class: "invalid",
179
+ retry: "after_change",
180
+ message: "the native tnl package is missing; reinstall @madebyentropy/tnl without disabling optional dependencies",
181
+ },
182
+ "sdk.native_invalid": {
183
+ class: "invalid",
184
+ retry: "after_change",
185
+ message: "the native tnl package is invalid or does not match the launcher; reinstall @madebyentropy/tnl",
186
+ },
187
+ "sdk.process_unavailable": {
188
+ class: "unavailable",
189
+ retry: "after_change",
190
+ message: "the tnl launcher could not start the native process; check Node.js support and the installed package",
191
+ },
192
+ "sdk.unexpected": {
193
+ class: "internal",
194
+ retry: "never",
195
+ message: "the tnl integration failed unexpectedly; restart the local service and report the failure if it continues",
196
+ },
197
+ };
198
+ export class TnlError extends Error {
199
+ code;
200
+ class;
201
+ retry;
202
+ constructor(code, options) {
203
+ super(definitions[code].message, options);
204
+ this.name = "TnlError";
205
+ this.code = code;
206
+ this.class = definitions[code].class;
207
+ this.retry = definitions[code].retry;
208
+ }
209
+ }
210
+ // private causes can contain assertions, headers, or response bodies. retain
211
+ // their identity without exposing them through Error.cause, inspection, or JSON.
212
+ const privateCauses = new WeakMap();
213
+ export function privateTnlError(code, cause) {
214
+ const error = new TnlError(code);
215
+ privateCauses.set(error, cause);
216
+ return error;
217
+ }
218
+ export class TnlCleanupError extends TnlError {
219
+ errors;
220
+ constructor(error, cleanupError) {
221
+ super("sdk.cleanup_failed", { cause: error });
222
+ this.errors = [error, cleanupError];
223
+ }
224
+ }
225
+ export function classifyTnlError(error, code) {
226
+ return error instanceof TnlError ? error : new TnlError(code, { cause: error });
227
+ }
228
+ export function safeTnlMessage(error) {
229
+ return definitions[error instanceof TnlError ? error.code : "sdk.unexpected"].message;
230
+ }
@@ -0,0 +1,10 @@
1
+ export type * from "./project.js";
2
+ export type { Deployment, DeploymentOptions } from "./internal/connector/deployment_types.js";
3
+ export type { FetchHandler } from "./internal/publisher/fetch_types.js";
4
+ export type { ConnectorResources, PublisherResources } from "./internal/runtime_resources.js";
5
+ export type { Publication, PublicationRun, NamedPublicationOptions, TemporaryPublicationOptions, ExportedCertificate, ServiceCertificate, ServiceCertificateSource, } from "./internal/publisher/publication.js";
6
+ export { TnlError, type TnlErrorCode } from "./errors.js";
7
+ export { response } from "./response.js";
8
+ /** extended by `.tnl/generated/project.d.ts` for all runtime paths. */
9
+ export interface TnlProjectConfig {
10
+ }
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { TnlError } from "./errors.js";
2
+ export { response } from "./response.js";
@@ -0,0 +1,7 @@
1
+ /** stop waiting even when a provider ignores cancellation; observe late failures. */
2
+ export declare function cancellable<Value>(signal: AbortSignal, run: () => Promise<Value>): Promise<Value>;
3
+ export declare function shutdownBudget(original?: number): {
4
+ until: number;
5
+ signal: AbortSignal;
6
+ finish(): void;
7
+ };
@@ -0,0 +1,30 @@
1
+ /** stop waiting even when a provider ignores cancellation; observe late failures. */
2
+ export async function cancellable(signal, run) {
3
+ signal.throwIfAborted();
4
+ return new Promise((resolve, reject) => {
5
+ const aborted = () => reject(signal.reason);
6
+ signal.addEventListener("abort", aborted, { once: true });
7
+ void Promise.resolve()
8
+ .then(() => {
9
+ signal.throwIfAborted();
10
+ return run();
11
+ })
12
+ .then((value) => {
13
+ signal.throwIfAborted();
14
+ resolve(value);
15
+ })
16
+ .catch(reject)
17
+ .finally(() => signal.removeEventListener("abort", aborted));
18
+ });
19
+ }
20
+ // callers retain until across retries; finishing a phase never grants more time.
21
+ export function shutdownBudget(original) {
22
+ const until = Math.min(original ?? Infinity, Date.now() + 10_000);
23
+ const controller = new AbortController();
24
+ const abort = () => controller.abort(new DOMException("shutdown timed out; remote cleanup may be unconfirmed", "TimeoutError"));
25
+ const remaining = until - Date.now();
26
+ const timer = setTimeout(abort, Math.max(0, remaining));
27
+ if (remaining <= 0)
28
+ abort();
29
+ return { until, signal: controller.signal, finish: () => clearTimeout(timer) };
30
+ }
@@ -0,0 +1,62 @@
1
+ import type { TnlClientFactory, TnlClientOptions, TnlFetch, TnlNativeTLSOptions, TnlConnectionRegistry, ServiceFacts } from "../../project.js";
2
+ import type { DeploymentOptions, HTTPNames, ServiceNames as Names } from "./deployment_types.js";
3
+ import type { LocalHTTPServer } from "../publisher/register.js";
4
+ import type { FetchHandler } from "../publisher/fetch_types.js";
5
+ import type { Publication, NamedPublicationOptions, TemporaryPublicationOptions } from "../publisher/publication.js";
6
+ export type { ServiceFacts } from "../../project.js";
7
+ type Connection<Services extends ServiceFacts, Name extends Names<Services>, Local extends boolean> = (Local extends true ? LocalConnectionRegistry : TnlConnectionRegistry)[Services[Name]["protocol"]];
8
+ export interface LocalPostgresConnection {
9
+ readonly host: string;
10
+ readonly port: number;
11
+ readonly ssl: false | TnlNativeTLSOptions;
12
+ }
13
+ export type LocalConnectionRegistry = {
14
+ postgres: LocalPostgresConnection;
15
+ mysql: Readonly<{
16
+ host: string;
17
+ port: number;
18
+ ssl: false | (TnlNativeTLSOptions & {
19
+ readonly verifyIdentity: true;
20
+ });
21
+ stream: () => import("node:net").Socket;
22
+ }>;
23
+ tcp: Readonly<{
24
+ host: string;
25
+ port: number;
26
+ ssl?: TnlNativeTLSOptions;
27
+ }>;
28
+ http: Readonly<{
29
+ url: `${"http" | "https"}://${string}`;
30
+ fetch: TnlFetch;
31
+ }>;
32
+ kubernetes: Readonly<{
33
+ server: `https://${string}`;
34
+ kubeconfig: string;
35
+ context: string;
36
+ }>;
37
+ };
38
+ export type LocalDeployment<Services extends ServiceFacts> = Deployment<Services, true>;
39
+ export interface Deployment<Services extends ServiceFacts, Local extends boolean = false> {
40
+ publish<Name extends HTTPNames<Services>>(name: Name, server: LocalHTTPServer | FetchHandler, options?: NamedPublicationOptions): Promise<Publication>;
41
+ publish(server: LocalHTTPServer | FetchHandler, options?: TemporaryPublicationOptions): Promise<Publication>;
42
+ connect<Name extends Names<Services>>(name: Name): Promise<Connection<Services, Name, Local>>;
43
+ client<Name extends Names<Services>, Client>(name: Name, options: TnlClientOptions<Connection<Services, Name, Local>, Client>): TnlClientFactory<Client>;
44
+ close(): Promise<void>;
45
+ }
46
+ /** construct explicit deployment handles from portable service names and protocols. */
47
+ export declare function createClient<const Services extends ServiceFacts = Record<never, never>>(options: DeploymentOptions<Services>): Readonly<{
48
+ deployments: Readonly<{
49
+ create(body: import("../management/types.gen.js").CreateDeploymentRequest, request: import("./management.js").CreationOptions): Promise<import("./management.js").SavedDeployment>;
50
+ list(page?: import("./management.js").PageOptions): Promise<import("../management/types.gen.js").DeploymentPage>;
51
+ get(deployment: string): Promise<import("./management.js").SavedDeployment>;
52
+ update(deployment: string, body: import("../management/types.gen.js").UpdateDeploymentRequest, request: import("./management.js").MutationOptions): Promise<import("./management.js").SavedDeployment>;
53
+ delete(deployment: string, request: import("./management.js").MutationOptions): Promise<void>;
54
+ }>;
55
+ publishers: Readonly<{
56
+ createEnrollment(deployment: string, body: import("../management/types.gen.js").CreateDeploymentPublisherEnrollmentRequest, request: import("./management.js").CreationOptions): Promise<import("../management/types.gen.js").DeploymentPublisherEnrollment>;
57
+ list(deployment: string, page?: import("./management.js").PageOptions): Promise<import("../management/types.gen.js").DeploymentPublisherPage>;
58
+ get(deployment: string, publisher: string): Promise<import("../management/types.gen.js").DeploymentPublisher>;
59
+ revoke(deployment: string, publisher: string): Promise<void>;
60
+ }>;
61
+ deployment<Selected extends string>(name: Selected): Deployment<Services, Selected extends "local" ? true : false>;
62
+ }>;