@distilled.cloud/namespacelabs 1.0.0-rc.20 → 1.0.0-rc.21

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 (310) hide show
  1. package/README.md +19 -10
  2. package/lib/.lazy.json +1 -1
  3. package/lib/_bundle/sdk.js +1 -1
  4. package/lib/_bundle/sdk.js.map +1 -1
  5. package/lib/credentials.d.ts +27 -9
  6. package/lib/credentials.d.ts.map +1 -1
  7. package/lib/errors.d.ts +26 -0
  8. package/lib/errors.d.ts.map +1 -1
  9. package/lib/errors.js +1 -1
  10. package/lib/index.d.ts +10 -8
  11. package/lib/index.d.ts.map +1 -1
  12. package/lib/index.js +0 -1
  13. package/lib/pagination.d.ts.map +1 -1
  14. package/lib/protocol.d.ts +11 -7
  15. package/lib/protocol.d.ts.map +1 -1
  16. package/lib/retry.d.ts.map +1 -1
  17. package/lib/services/buildkite_jobs.d.ts +8 -0
  18. package/lib/services/buildkite_jobs.d.ts.map +1 -1
  19. package/lib/services/buildkite_jobs.js +1 -1
  20. package/lib/services/buildkite_jobs.js.map +1 -1
  21. package/lib/services/buildkite_queue.d.ts +8 -0
  22. package/lib/services/buildkite_queue.d.ts.map +1 -1
  23. package/lib/services/buildkite_queue.js +1 -1
  24. package/lib/services/buildkite_queue.js.map +1 -1
  25. package/lib/services/index.d.ts +0 -27
  26. package/lib/services/index.d.ts.map +1 -1
  27. package/lib/services/index.js +0 -27
  28. package/lib/services.lazy/index.js +2 -2
  29. package/lib/traits.d.ts.map +1 -1
  30. package/lib/{services → unstable-services}/artifacts.d.ts +8 -0
  31. package/lib/unstable-services/artifacts.d.ts.map +1 -0
  32. package/lib/unstable-services/artifacts.js +2 -0
  33. package/lib/unstable-services/artifacts.js.map +1 -0
  34. package/lib/{services → unstable-services}/audit.d.ts +8 -0
  35. package/lib/unstable-services/audit.d.ts.map +1 -0
  36. package/lib/unstable-services/audit.js +2 -0
  37. package/lib/unstable-services/audit.js.map +1 -0
  38. package/lib/{services → unstable-services}/bazel.d.ts +8 -0
  39. package/lib/unstable-services/bazel.d.ts.map +1 -0
  40. package/lib/unstable-services/bazel.js +2 -0
  41. package/lib/unstable-services/bazel.js.map +1 -0
  42. package/lib/{services → unstable-services}/bazel_cache.d.ts +8 -0
  43. package/lib/unstable-services/bazel_cache.d.ts.map +1 -0
  44. package/lib/unstable-services/bazel_cache.js +2 -0
  45. package/lib/unstable-services/bazel_cache.js.map +1 -0
  46. package/lib/{services → unstable-services}/builder.d.ts +8 -0
  47. package/lib/unstable-services/builder.d.ts.map +1 -0
  48. package/lib/unstable-services/builder.js +2 -0
  49. package/lib/unstable-services/builder.js.map +1 -0
  50. package/lib/{services → unstable-services}/compute.d.ts +67 -0
  51. package/lib/unstable-services/compute.d.ts.map +1 -0
  52. package/lib/unstable-services/compute.js +47 -0
  53. package/lib/unstable-services/compute.js.map +1 -0
  54. package/lib/{services → unstable-services}/compute_command.d.ts +8 -0
  55. package/lib/unstable-services/compute_command.d.ts.map +1 -0
  56. package/lib/unstable-services/compute_command.js +2 -0
  57. package/lib/unstable-services/compute_command.js.map +1 -0
  58. package/lib/{services → unstable-services}/compute_observability.d.ts +8 -0
  59. package/lib/unstable-services/compute_observability.d.ts.map +1 -0
  60. package/lib/unstable-services/compute_observability.js +2 -0
  61. package/lib/unstable-services/compute_observability.js.map +1 -0
  62. package/lib/{services → unstable-services}/compute_storage.d.ts +8 -0
  63. package/lib/unstable-services/compute_storage.d.ts.map +1 -0
  64. package/lib/unstable-services/compute_storage.js +33 -0
  65. package/lib/unstable-services/compute_storage.js.map +1 -0
  66. package/lib/{services → unstable-services}/compute_usage.d.ts +8 -0
  67. package/lib/unstable-services/compute_usage.d.ts.map +1 -0
  68. package/lib/unstable-services/compute_usage.js +2 -0
  69. package/lib/unstable-services/compute_usage.js.map +1 -0
  70. package/lib/{services → unstable-services}/egress.d.ts +8 -0
  71. package/lib/unstable-services/egress.d.ts.map +1 -0
  72. package/lib/unstable-services/egress.js +2 -0
  73. package/lib/unstable-services/egress.js.map +1 -0
  74. package/lib/{services → unstable-services}/experimental_compute_reservation.d.ts +11 -1
  75. package/lib/unstable-services/experimental_compute_reservation.d.ts.map +1 -0
  76. package/lib/unstable-services/experimental_compute_reservation.js +23 -0
  77. package/lib/unstable-services/experimental_compute_reservation.js.map +1 -0
  78. package/lib/{services → unstable-services}/experimental_remote_results.d.ts +8 -0
  79. package/lib/unstable-services/experimental_remote_results.d.ts.map +1 -0
  80. package/lib/unstable-services/experimental_remote_results.js +2 -0
  81. package/lib/unstable-services/experimental_remote_results.js.map +1 -0
  82. package/lib/{services → unstable-services}/github_image.d.ts +8 -0
  83. package/lib/unstable-services/github_image.d.ts.map +1 -0
  84. package/lib/unstable-services/github_image.js +2 -0
  85. package/lib/unstable-services/github_image.js.map +1 -0
  86. package/lib/{services → unstable-services}/github_jobs.d.ts +8 -0
  87. package/lib/unstable-services/github_jobs.d.ts.map +1 -0
  88. package/lib/unstable-services/github_jobs.js +2 -0
  89. package/lib/unstable-services/github_jobs.js.map +1 -0
  90. package/lib/{services → unstable-services}/github_profile.d.ts +8 -0
  91. package/lib/unstable-services/github_profile.d.ts.map +1 -0
  92. package/lib/unstable-services/github_profile.js +2 -0
  93. package/lib/unstable-services/github_profile.js.map +1 -0
  94. package/lib/{services → unstable-services}/gradle_cache.d.ts +8 -0
  95. package/lib/unstable-services/gradle_cache.d.ts.map +1 -0
  96. package/lib/unstable-services/gradle_cache.js +2 -0
  97. package/lib/unstable-services/gradle_cache.js.map +1 -0
  98. package/lib/{services → unstable-services}/httpcache.d.ts +8 -0
  99. package/lib/unstable-services/httpcache.d.ts.map +1 -0
  100. package/lib/unstable-services/httpcache.js +2 -0
  101. package/lib/unstable-services/httpcache.js.map +1 -0
  102. package/lib/{services → unstable-services}/iam_tenant.d.ts +95 -11
  103. package/lib/unstable-services/iam_tenant.d.ts.map +1 -0
  104. package/lib/unstable-services/iam_tenant.js +45 -0
  105. package/lib/unstable-services/iam_tenant.js.map +1 -0
  106. package/lib/{services → unstable-services}/iam_tenant_membership.d.ts +8 -0
  107. package/lib/unstable-services/iam_tenant_membership.d.ts.map +1 -0
  108. package/lib/unstable-services/iam_tenant_membership.js +2 -0
  109. package/lib/unstable-services/iam_tenant_membership.js.map +1 -0
  110. package/lib/{services → unstable-services}/iam_token.d.ts +8 -0
  111. package/lib/unstable-services/iam_token.d.ts.map +1 -0
  112. package/lib/unstable-services/iam_token.js +2 -0
  113. package/lib/unstable-services/iam_token.js.map +1 -0
  114. package/lib/{services → unstable-services}/image.d.ts +8 -0
  115. package/lib/unstable-services/image.d.ts.map +1 -0
  116. package/lib/unstable-services/image.js +2 -0
  117. package/lib/unstable-services/image.js.map +1 -0
  118. package/lib/unstable-services/index.d.ts +28 -0
  119. package/lib/unstable-services/index.d.ts.map +1 -0
  120. package/lib/unstable-services/index.js +27 -0
  121. package/lib/{services → unstable-services}/private_devbox.d.ts +24 -0
  122. package/lib/unstable-services/private_devbox.d.ts.map +1 -0
  123. package/lib/unstable-services/private_devbox.js +81 -0
  124. package/lib/unstable-services/private_devbox.js.map +1 -0
  125. package/lib/{services → unstable-services}/private_user_sessions.d.ts +8 -0
  126. package/lib/unstable-services/private_user_sessions.d.ts.map +1 -0
  127. package/lib/unstable-services/private_user_sessions.js +2 -0
  128. package/lib/unstable-services/private_user_sessions.js.map +1 -0
  129. package/lib/{services → unstable-services}/registry.d.ts +8 -0
  130. package/lib/unstable-services/registry.d.ts.map +1 -0
  131. package/lib/unstable-services/registry.js +34 -0
  132. package/lib/unstable-services/registry.js.map +1 -0
  133. package/lib/{services → unstable-services}/testing.d.ts +8 -0
  134. package/lib/unstable-services/testing.d.ts.map +1 -0
  135. package/lib/unstable-services/testing.js +2 -0
  136. package/lib/unstable-services/testing.js.map +1 -0
  137. package/lib/{services → unstable-services}/vault.d.ts +8 -0
  138. package/lib/unstable-services/vault.d.ts.map +1 -0
  139. package/lib/unstable-services/vault.js +2 -0
  140. package/lib/unstable-services/vault.js.map +1 -0
  141. package/lib/unstable-services.lazy/artifacts.js +1 -0
  142. package/lib/unstable-services.lazy/audit.js +1 -0
  143. package/lib/unstable-services.lazy/bazel.js +1 -0
  144. package/lib/unstable-services.lazy/bazel_cache.js +1 -0
  145. package/lib/unstable-services.lazy/builder.js +1 -0
  146. package/lib/unstable-services.lazy/compute.js +4 -0
  147. package/lib/unstable-services.lazy/compute_command.js +1 -0
  148. package/lib/unstable-services.lazy/compute_observability.js +1 -0
  149. package/lib/{services.lazy → unstable-services.lazy}/compute_storage.js +1 -1
  150. package/lib/unstable-services.lazy/compute_usage.js +1 -0
  151. package/lib/unstable-services.lazy/egress.js +1 -0
  152. package/lib/{services.lazy → unstable-services.lazy}/experimental_compute_reservation.js +1 -1
  153. package/lib/unstable-services.lazy/experimental_remote_results.js +1 -0
  154. package/lib/unstable-services.lazy/github_image.js +1 -0
  155. package/lib/unstable-services.lazy/github_jobs.js +1 -0
  156. package/lib/unstable-services.lazy/github_profile.js +1 -0
  157. package/lib/unstable-services.lazy/gradle_cache.js +1 -0
  158. package/lib/unstable-services.lazy/httpcache.js +1 -0
  159. package/lib/unstable-services.lazy/iam_tenant.js +4 -0
  160. package/lib/unstable-services.lazy/iam_tenant_membership.js +1 -0
  161. package/lib/unstable-services.lazy/iam_token.js +1 -0
  162. package/lib/unstable-services.lazy/image.js +1 -0
  163. package/lib/unstable-services.lazy/index.js +3 -0
  164. package/lib/{services.lazy → unstable-services.lazy}/private_devbox.js +1 -1
  165. package/lib/unstable-services.lazy/private_user_sessions.js +1 -0
  166. package/lib/{services.lazy → unstable-services.lazy}/registry.js +1 -1
  167. package/lib/unstable-services.lazy/testing.js +1 -0
  168. package/lib/unstable-services.lazy/vault.js +1 -0
  169. package/package.json +12 -5
  170. package/src/credentials.ts +84 -40
  171. package/src/errors.ts +24 -0
  172. package/src/index.ts +10 -8
  173. package/src/protocol.ts +27 -26
  174. package/src/services/buildkite_jobs.ts +10 -2
  175. package/src/services/buildkite_queue.ts +12 -4
  176. package/src/services/index.ts +0 -27
  177. package/src/{services → unstable-services}/artifacts.ts +16 -8
  178. package/src/{services → unstable-services}/audit.ts +10 -2
  179. package/src/{services → unstable-services}/bazel.ts +12 -4
  180. package/src/{services → unstable-services}/bazel_cache.ts +10 -2
  181. package/src/{services → unstable-services}/builder.ts +13 -5
  182. package/src/{services → unstable-services}/compute.ts +422 -225
  183. package/src/{services → unstable-services}/compute_command.ts +10 -2
  184. package/src/{services → unstable-services}/compute_observability.ts +12 -4
  185. package/src/{services → unstable-services}/compute_storage.ts +20 -12
  186. package/src/{services → unstable-services}/compute_usage.ts +14 -6
  187. package/src/{services → unstable-services}/egress.ts +13 -5
  188. package/src/{services → unstable-services}/experimental_compute_reservation.ts +44 -33
  189. package/src/{services → unstable-services}/experimental_remote_results.ts +15 -7
  190. package/src/{services → unstable-services}/github_image.ts +10 -2
  191. package/src/{services → unstable-services}/github_jobs.ts +11 -3
  192. package/src/{services → unstable-services}/github_profile.ts +14 -6
  193. package/src/{services → unstable-services}/gradle_cache.ts +11 -3
  194. package/src/{services → unstable-services}/httpcache.ts +11 -3
  195. package/src/{services → unstable-services}/iam_tenant.ts +524 -159
  196. package/src/{services → unstable-services}/iam_tenant_membership.ts +11 -3
  197. package/src/{services → unstable-services}/iam_token.ts +17 -9
  198. package/src/{services → unstable-services}/image.ts +14 -6
  199. package/src/unstable-services/index.ts +28 -0
  200. package/src/{services → unstable-services}/private_devbox.ts +82 -43
  201. package/src/{services → unstable-services}/private_user_sessions.ts +13 -5
  202. package/src/{services → unstable-services}/registry.ts +22 -14
  203. package/src/{services → unstable-services}/testing.ts +12 -4
  204. package/src/{services → unstable-services}/vault.ts +14 -6
  205. package/lib/index.lazy.js +0 -7
  206. package/lib/index.lazy.js.map +0 -1
  207. package/lib/services/artifacts.d.ts.map +0 -1
  208. package/lib/services/artifacts.js +0 -2
  209. package/lib/services/artifacts.js.map +0 -1
  210. package/lib/services/audit.d.ts.map +0 -1
  211. package/lib/services/audit.js +0 -2
  212. package/lib/services/audit.js.map +0 -1
  213. package/lib/services/bazel.d.ts.map +0 -1
  214. package/lib/services/bazel.js +0 -2
  215. package/lib/services/bazel.js.map +0 -1
  216. package/lib/services/bazel_cache.d.ts.map +0 -1
  217. package/lib/services/bazel_cache.js +0 -2
  218. package/lib/services/bazel_cache.js.map +0 -1
  219. package/lib/services/builder.d.ts.map +0 -1
  220. package/lib/services/builder.js +0 -2
  221. package/lib/services/builder.js.map +0 -1
  222. package/lib/services/compute.d.ts.map +0 -1
  223. package/lib/services/compute.js +0 -43
  224. package/lib/services/compute.js.map +0 -1
  225. package/lib/services/compute_command.d.ts.map +0 -1
  226. package/lib/services/compute_command.js +0 -2
  227. package/lib/services/compute_command.js.map +0 -1
  228. package/lib/services/compute_observability.d.ts.map +0 -1
  229. package/lib/services/compute_observability.js +0 -2
  230. package/lib/services/compute_observability.js.map +0 -1
  231. package/lib/services/compute_storage.d.ts.map +0 -1
  232. package/lib/services/compute_storage.js +0 -33
  233. package/lib/services/compute_storage.js.map +0 -1
  234. package/lib/services/compute_usage.d.ts.map +0 -1
  235. package/lib/services/compute_usage.js +0 -2
  236. package/lib/services/compute_usage.js.map +0 -1
  237. package/lib/services/egress.d.ts.map +0 -1
  238. package/lib/services/egress.js +0 -2
  239. package/lib/services/egress.js.map +0 -1
  240. package/lib/services/experimental_compute_reservation.d.ts.map +0 -1
  241. package/lib/services/experimental_compute_reservation.js +0 -23
  242. package/lib/services/experimental_compute_reservation.js.map +0 -1
  243. package/lib/services/experimental_remote_results.d.ts.map +0 -1
  244. package/lib/services/experimental_remote_results.js +0 -2
  245. package/lib/services/experimental_remote_results.js.map +0 -1
  246. package/lib/services/github_image.d.ts.map +0 -1
  247. package/lib/services/github_image.js +0 -2
  248. package/lib/services/github_image.js.map +0 -1
  249. package/lib/services/github_jobs.d.ts.map +0 -1
  250. package/lib/services/github_jobs.js +0 -2
  251. package/lib/services/github_jobs.js.map +0 -1
  252. package/lib/services/github_profile.d.ts.map +0 -1
  253. package/lib/services/github_profile.js +0 -2
  254. package/lib/services/github_profile.js.map +0 -1
  255. package/lib/services/gradle_cache.d.ts.map +0 -1
  256. package/lib/services/gradle_cache.js +0 -2
  257. package/lib/services/gradle_cache.js.map +0 -1
  258. package/lib/services/httpcache.d.ts.map +0 -1
  259. package/lib/services/httpcache.js +0 -2
  260. package/lib/services/httpcache.js.map +0 -1
  261. package/lib/services/iam_tenant.d.ts.map +0 -1
  262. package/lib/services/iam_tenant.js +0 -39
  263. package/lib/services/iam_tenant.js.map +0 -1
  264. package/lib/services/iam_tenant_membership.d.ts.map +0 -1
  265. package/lib/services/iam_tenant_membership.js +0 -2
  266. package/lib/services/iam_tenant_membership.js.map +0 -1
  267. package/lib/services/iam_token.d.ts.map +0 -1
  268. package/lib/services/iam_token.js +0 -2
  269. package/lib/services/iam_token.js.map +0 -1
  270. package/lib/services/image.d.ts.map +0 -1
  271. package/lib/services/image.js +0 -2
  272. package/lib/services/image.js.map +0 -1
  273. package/lib/services/private_devbox.d.ts.map +0 -1
  274. package/lib/services/private_devbox.js +0 -81
  275. package/lib/services/private_devbox.js.map +0 -1
  276. package/lib/services/private_user_sessions.d.ts.map +0 -1
  277. package/lib/services/private_user_sessions.js +0 -2
  278. package/lib/services/private_user_sessions.js.map +0 -1
  279. package/lib/services/registry.d.ts.map +0 -1
  280. package/lib/services/registry.js +0 -34
  281. package/lib/services/registry.js.map +0 -1
  282. package/lib/services/testing.d.ts.map +0 -1
  283. package/lib/services/testing.js +0 -2
  284. package/lib/services/testing.js.map +0 -1
  285. package/lib/services/vault.d.ts.map +0 -1
  286. package/lib/services/vault.js +0 -2
  287. package/lib/services/vault.js.map +0 -1
  288. package/lib/services.lazy/artifacts.js +0 -1
  289. package/lib/services.lazy/audit.js +0 -1
  290. package/lib/services.lazy/bazel.js +0 -1
  291. package/lib/services.lazy/bazel_cache.js +0 -1
  292. package/lib/services.lazy/builder.js +0 -1
  293. package/lib/services.lazy/compute.js +0 -4
  294. package/lib/services.lazy/compute_command.js +0 -1
  295. package/lib/services.lazy/compute_observability.js +0 -1
  296. package/lib/services.lazy/compute_usage.js +0 -1
  297. package/lib/services.lazy/egress.js +0 -1
  298. package/lib/services.lazy/experimental_remote_results.js +0 -1
  299. package/lib/services.lazy/github_image.js +0 -1
  300. package/lib/services.lazy/github_jobs.js +0 -1
  301. package/lib/services.lazy/github_profile.js +0 -1
  302. package/lib/services.lazy/gradle_cache.js +0 -1
  303. package/lib/services.lazy/httpcache.js +0 -1
  304. package/lib/services.lazy/iam_tenant.js +0 -4
  305. package/lib/services.lazy/iam_tenant_membership.js +0 -1
  306. package/lib/services.lazy/iam_token.js +0 -1
  307. package/lib/services.lazy/image.js +0 -1
  308. package/lib/services.lazy/private_user_sessions.js +0 -1
  309. package/lib/services.lazy/testing.js +0 -1
  310. package/lib/services.lazy/vault.js +0 -1
@@ -1,11 +1,13 @@
1
1
  import * as EffectConfig from "@distilled.cloud/core/config";
2
2
  import { ConfigError } from "@distilled.cloud/core/errors";
3
+ import { invalidHostLabelConfig } from "@distilled.cloud/core/protocol-http";
3
4
  import * as Context from "effect/Context";
4
5
  import * as Effect from "effect/Effect";
5
6
  import * as FileSystem from "effect/FileSystem";
6
7
  import * as Layer from "effect/Layer";
7
8
  import * as Option from "effect/Option";
8
9
  import * as Redacted from "effect/Redacted";
10
+ import { TokenFileUnreadable } from "./errors.ts";
9
11
 
10
12
  export const DEFAULT_REGION = "us";
11
13
  export const DEFAULT_GLOBAL_BASE_URL = "https://global.namespaceapis.com";
@@ -55,8 +57,27 @@ export const resolveConfig = (options: Options): Config => {
55
57
  };
56
58
  };
57
59
 
60
+ /**
61
+ * `hosts`, failing with `ConfigError` when the region is not one DNS label:
62
+ * it becomes a label of the compute and storage host names. The layers run
63
+ * this once, when they are built.
64
+ */
65
+ const checkHosts = <H extends Hosts>(hosts: H): Effect.Effect<H, ConfigError> => {
66
+ const invalid =
67
+ hosts.region === undefined
68
+ ? undefined
69
+ : invalidHostLabelConfig("Namespace region", hosts.region);
70
+ return invalid === undefined ? Effect.succeed(hosts) : Effect.fail(invalid);
71
+ };
72
+
73
+ /**
74
+ * Resolves the current credentials on every request. A layer here reads and
75
+ * checks the region and host settings when it is built, so the effect fails
76
+ * only for what it does at run time: the token-file layers read the file
77
+ * again on every resolution, and fail with {@link TokenFileUnreadable}.
78
+ */
58
79
  export class Credentials
59
- extends /*@__PURE__*/ Context.Service<Credentials, Effect.Effect<Config, ConfigError>>()(
80
+ extends /*@__PURE__*/ Context.Service<Credentials, Effect.Effect<Config, TokenFileUnreadable>>()(
60
81
  "NamespaceLabsCredentials",
61
82
  ) {}
62
83
 
@@ -85,80 +106,103 @@ const hostsConfig = /*@__PURE__*/ EffectConfig.all({
85
106
 
86
107
  const configError = (message: string) => () => new ConfigError({ message });
87
108
 
88
- /** Credentials from the environment: `NSC_TOKEN` (required) plus the host variables. */
89
- export const CredentialsFromEnv: Layer.Layer<Credentials> = /*@__PURE__*/ Layer.succeed(
109
+ /**
110
+ * Credentials from the environment: `NSC_TOKEN` (required) plus the host
111
+ * variables. The environment is read, and the region checked, once: when
112
+ * the layer is built.
113
+ */
114
+ export const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError> = /*@__PURE__*/ Layer.effect(
90
115
  Credentials,
91
116
  /*@__PURE__*/ EffectConfig.all({
92
117
  token: /*@__PURE__*/ EffectConfig.Redacted("NSC_TOKEN"),
93
118
  hosts: hostsConfig,
94
119
  }).pipe(
95
- /*@__PURE__*/ Effect.map(({ token, hosts }) => resolveConfig({ token, ...hosts })),
96
120
  /*@__PURE__*/ Effect.mapError(configError("NSC_TOKEN environment variable is required")),
121
+ /*@__PURE__*/ Effect.flatMap(({ token, hosts }) => checkHosts({ token, ...hosts })),
122
+ /*@__PURE__*/ Effect.map((options) => Effect.succeed(resolveConfig(options))),
97
123
  ),
98
124
  );
99
125
 
100
126
  const readTokenFile = (
101
127
  fs: FileSystem.FileSystem,
102
128
  path: string,
103
- ): Effect.Effect<Redacted.Redacted<string>, ConfigError> =>
104
- fs.readFileString(path).pipe(
105
- Effect.mapError(configError(`Namespace token file ${path} could not be read`)),
129
+ ): Effect.Effect<Redacted.Redacted<string>, TokenFileUnreadable> => {
130
+ const unreadable = (message: string) => () => new TokenFileUnreadable({ message, path });
131
+ return fs.readFileString(path).pipe(
132
+ Effect.mapError(unreadable(`Namespace token file ${path} could not be read`)),
106
133
  Effect.flatMap((text) => {
107
134
  const parsed = Effect.try({
108
135
  try: () => JSON.parse(text) as { readonly bearer_token?: unknown },
109
- catch: configError(`Namespace token file ${path} is not JSON`),
136
+ catch: unreadable(`Namespace token file ${path} is not JSON`),
110
137
  });
111
138
  return Effect.flatMap(parsed, ({ bearer_token }) =>
112
139
  typeof bearer_token === "string" && bearer_token.length > 0
113
140
  ? Effect.succeed(Redacted.make(bearer_token))
114
141
  : Effect.fail(
115
- new ConfigError({
116
- message: `Namespace token file ${path} has no bearer_token; exchange a session token with privateUserSessions.issueTenantTokenFromSession`,
117
- }),
142
+ unreadable(
143
+ `Namespace token file ${path} has no bearer_token; exchange a session token with privateUserSessions.issueTenantTokenFromSession`,
144
+ )(),
118
145
  ),
119
146
  );
120
147
  }),
121
148
  );
149
+ };
150
+
151
+ /** A layer for checked `hosts` that reads `bearer_token` from `path` on every resolution. */
152
+ const tokenFileLayer = (
153
+ settings: Effect.Effect<{ readonly path: string; readonly hosts: Hosts }, ConfigError>,
154
+ ): Layer.Layer<Credentials, ConfigError, FileSystem.FileSystem> =>
155
+ Layer.effect(
156
+ Credentials,
157
+ Effect.gen(function* () {
158
+ const fs = yield* FileSystem.FileSystem;
159
+ const { path, hosts: unchecked } = yield* settings;
160
+ const hosts = yield* checkHosts(unchecked);
161
+ return Effect.map(readTokenFile(fs, path), (token) => resolveConfig({ token, ...hosts }));
162
+ }),
163
+ );
122
164
 
123
165
  /**
124
166
  * Credentials from the token file a Namespace workload is given: `NSC_TOKEN_FILE`,
125
167
  * else `/var/run/nsc/token.json`. The file is re-read on every resolution because
126
- * Namespace refreshes it; host variables as in {@link CredentialsFromEnv}.
168
+ * Namespace refreshes it; host variables as in {@link CredentialsFromEnv}. The
169
+ * variables are read, and the region checked, once: when the layer is built.
127
170
  */
128
- export const CredentialsFromTokenFile: Layer.Layer<Credentials, never, FileSystem.FileSystem> =
129
- /*@__PURE__*/ Layer.effect(
130
- Credentials,
131
- /*@__PURE__*/ Effect.map(FileSystem.FileSystem, (fs) =>
132
- EffectConfig.all({
133
- path: EffectConfig.String("NSC_TOKEN_FILE").pipe(
134
- EffectConfig.withDefault(DEFAULT_TOKEN_FILE),
135
- ),
136
- hosts: hostsConfig,
137
- }).pipe(
138
- Effect.mapError(configError("Namespace host configuration could not be read")),
139
- Effect.flatMap(({ path, hosts }) =>
140
- Effect.map(readTokenFile(fs, path), (token) => resolveConfig({ token, ...hosts })),
141
- ),
142
- ),
171
+ export const CredentialsFromTokenFile: Layer.Layer<
172
+ Credentials,
173
+ ConfigError,
174
+ FileSystem.FileSystem
175
+ > = /*@__PURE__*/ tokenFileLayer(
176
+ /*@__PURE__*/ EffectConfig.all({
177
+ path: /*@__PURE__*/ EffectConfig.String("NSC_TOKEN_FILE").pipe(
178
+ /*@__PURE__*/ EffectConfig.withDefault(DEFAULT_TOKEN_FILE),
143
179
  ),
144
- );
180
+ hosts: hostsConfig,
181
+ }).pipe(
182
+ /*@__PURE__*/ Effect.mapError(configError("Namespace host configuration could not be read")),
183
+ ),
184
+ );
145
185
 
146
- /** Convenience layer from a tenant token, an optional region and host overrides. */
147
- export const credentials = (options: Options): Layer.Layer<Credentials> =>
148
- Layer.succeed(Credentials, Effect.succeed(resolveConfig(options)));
186
+ /**
187
+ * Convenience layer from a tenant token, an optional region and host
188
+ * overrides. The region is checked when the layer is built.
189
+ */
190
+ export const credentials = (options: Options): Layer.Layer<Credentials, ConfigError> =>
191
+ Layer.effect(
192
+ Credentials,
193
+ Effect.map(checkHosts(options), (checked) => Effect.succeed(resolveConfig(checked))),
194
+ );
149
195
 
150
196
  /** Convenience layer from a tenant token alone. */
151
197
  export const fromToken = (token: Redacted.Redacted<string>): Layer.Layer<Credentials> =>
152
- credentials({ token });
198
+ Layer.succeed(Credentials, Effect.succeed(resolveConfig({ token })));
153
199
 
154
- /** Convenience layer reading `bearer_token` from a token file on every resolution. */
200
+ /**
201
+ * Convenience layer reading `bearer_token` from a token file on every
202
+ * resolution. The region is checked when the layer is built.
203
+ */
155
204
  export const fromTokenFile = (
156
205
  path: string,
157
206
  hosts: Hosts = {},
158
- ): Layer.Layer<Credentials, never, FileSystem.FileSystem> =>
159
- Layer.effect(
160
- Credentials,
161
- Effect.map(FileSystem.FileSystem, (fs) =>
162
- Effect.map(readTokenFile(fs, path), (token) => resolveConfig({ token, ...hosts })),
163
- ),
164
- );
207
+ ): Layer.Layer<Credentials, ConfigError, FileSystem.FileSystem> =>
208
+ tokenFileLayer(Effect.succeed({ path, hosts }));
package/src/errors.ts CHANGED
@@ -17,6 +17,7 @@ export {
17
17
  UnprocessableEntity,
18
18
  } from "@distilled.cloud/core/errors";
19
19
  import * as Category from "@distilled.cloud/core/category";
20
+ import { API_ERRORS } from "@distilled.cloud/core/errors";
20
21
  import type { DefaultErrors as CoreDefaultErrors } from "@distilled.cloud/core/errors";
21
22
  import * as Schema from "@distilled.cloud/core/schema-lite-typed";
22
23
 
@@ -42,6 +43,29 @@ export class NamespaceLabsParseError
42
43
  cause: Schema.Unknown,
43
44
  }).pipe(Category.withParseError) {}
44
45
 
46
+ /**
47
+ * The token file the credentials read on every request could not be used:
48
+ * it could not be read, is not JSON, or holds no `bearer_token`. It is a
49
+ * failure at run time (Namespace rewrites the file), so it is not a
50
+ * `ConfigError`.
51
+ */
52
+ export class TokenFileUnreadable
53
+ extends /*@__PURE__*/ Schema.TaggedError<TokenFileUnreadable>()("TokenFileUnreadable", {
54
+ message: Schema.String,
55
+ /** The path of the token file. */
56
+ path: Schema.String,
57
+ }).pipe(Category.withAuthError) {}
58
+
45
59
  export type ClientErrors = UnknownNamespaceLabsError | NamespaceLabsParseError;
46
60
 
47
61
  export type DefaultErrors = CoreDefaultErrors | ClientErrors;
62
+
63
+ /**
64
+ * The errors declared on the Namespace service: any operation can return
65
+ * them, and every generated operation lists them as its `serviceErrors`.
66
+ * Today that is each of core's status classes (401, 403, 404, 429, the
67
+ * 5xx ...), for a failed response whose status and Connect code match none
68
+ * of the operation's own errors.
69
+ */
70
+ export const NamespaceLabsServiceErrors = API_ERRORS;
71
+ export type NamespaceLabsServiceError = InstanceType<(typeof NamespaceLabsServiceErrors)[number]>;
package/src/index.ts CHANGED
@@ -1,32 +1,35 @@
1
1
  /**
2
2
  * @distilled.cloud/namespacelabs -- Namespace (namespace.so) SDK for Effect.
3
3
  *
4
- * `./services` is generated by `scripts/generate.ts` from the Smithy models
5
- * that `scripts/convert.ts` converts from Namespace's public protobuf API
6
- * (`buf.build/namespace/cloud`). Everything else in this folder is hand-written.
4
+ * `./services` and `./unstable-services` are generated by
5
+ * `scripts/generate.ts` from the Smithy models that `scripts/convert.ts`
6
+ * converts from Namespace's public protobuf API (`buf.build/namespace/cloud`).
7
+ * Services in `v1beta` and `namespace.experimental.*` packages are under
8
+ * `@distilled.cloud/namespacelabs/unstable/<name>`. Everything else in this
9
+ * folder is hand-written.
7
10
  *
8
11
  * @example
9
12
  * ```ts
10
13
  * import { Effect, Layer } from "effect";
11
14
  * import * as FetchHttpClient from "effect/http/FetchHttpClient";
12
15
  * import * as NamespaceLabs from "@distilled.cloud/namespacelabs";
16
+ * import * as Compute from "@distilled.cloud/namespacelabs/unstable/compute";
13
17
  *
14
18
  * const program = Effect.gen(function* () {
15
- * const created = yield* NamespaceLabs.compute.createInstance({
19
+ * const created = yield* Compute.createInstance({
16
20
  * shape: { virtualCpu: 2, memoryMegabytes: 4096, os: "linux", machineArch: "amd64" },
17
21
  * deadline: new Date(Date.now() + 10 * 60 * 1000).toISOString(),
18
22
  * });
19
23
  * const instanceId = created.metadata?.instanceId;
20
24
  * if (instanceId === undefined) return undefined;
21
- * const instance = yield* NamespaceLabs.compute.describeInstance({ instanceId });
22
- * yield* NamespaceLabs.compute.destroyInstance({ instanceId });
25
+ * const instance = yield* Compute.describeInstance({ instanceId });
26
+ * yield* Compute.destroyInstance({ instanceId });
23
27
  * return instance.metadata?.status;
24
28
  * });
25
29
  *
26
30
  * const Live = Layer.mergeAll(
27
31
  * FetchHttpClient.layer,
28
32
  * NamespaceLabs.CredentialsFromEnv,
29
- * NamespaceLabs.NamespaceLabsProtocol,
30
33
  * );
31
34
  *
32
35
  * program.pipe(Effect.provide(Live), Effect.runPromise);
@@ -45,4 +48,3 @@ export {
45
48
  } from "./protocol.ts";
46
49
  export { paginateCursor } from "./pagination.ts";
47
50
  export * as Retry from "./retry.ts";
48
- export * from "./services/index.ts";
package/src/protocol.ts CHANGED
@@ -1,23 +1,25 @@
1
- import type * as API from "@distilled.cloud/core/api";
2
- import type { ConfigError, InvalidInput } from "@distilled.cloud/core/errors";
3
- import { makeRestProtocol, type RestErrorEnvelope } from "@distilled.cloud/core/protocol-rest";
1
+ import type { ErrorOf } from "@distilled.cloud/core/protocol";
2
+ import { restProtocol, type RestErrorEnvelope } from "@distilled.cloud/core/protocol-rest";
4
3
  import * as Effect from "effect/Effect";
5
4
  import type * as HttpClient from "effect/http/HttpClient";
6
- import type * as HttpClientError from "effect/http/HttpClientError";
7
- import type * as Layer from "effect/Layer";
8
5
  import * as Redacted from "effect/Redacted";
9
6
  import { Credentials, type Config } from "./credentials.ts";
10
7
  import {
11
8
  UnknownNamespaceLabsError,
12
- type DefaultErrors,
13
9
  NamespaceLabsParseError,
10
+ type NamespaceLabsServiceError,
14
11
  } from "./errors.ts";
15
12
 
13
+ /**
14
+ * What every generated Namespace operation fails with besides its own
15
+ * errors: the service's errors, the protocol's, and what resolving the
16
+ * credentials fails with. Generated service files annotate operations with
17
+ * `API.OperationMethod<I, O, NamespaceLabsOpError, NamespaceLabsOpContext>`
18
+ * explicitly.
19
+ */
16
20
  export type NamespaceLabsOpError =
17
- | DefaultErrors
18
- | ConfigError
19
- | HttpClientError.HttpClientError
20
- | InvalidInput;
21
+ | NamespaceLabsServiceError
22
+ | ErrorOf<typeof NamespaceLabsProtocol>;
21
23
 
22
24
  export type NamespaceLabsOpContext = Credentials | HttpClient.HttpClient;
23
25
 
@@ -64,19 +66,18 @@ const errorEnvelope = (body: unknown): RestErrorEnvelope | undefined => {
64
66
  const errorDetails = (body: unknown): unknown =>
65
67
  body !== null && typeof body === "object" ? (body as Record<string, unknown>).details : undefined;
66
68
 
67
- export const NamespaceLabsProtocol: Layer.Layer<API.Protocol> =
68
- /*@__PURE__*/ makeRestProtocol<Config>({
69
- credentials: /*@__PURE__*/ Effect.flatMap(Credentials, (resolve) => resolve),
70
- baseUrl: (creds, target) => baseUrlFor(creds, target.uri),
71
- headers: (creds) => ({ Authorization: `Bearer ${Redacted.value(creds.token)}` }),
72
- emptyJsonBody: true,
73
- errorEnvelope,
74
- unknownError: ({ code, message, body }) =>
75
- new UnknownNamespaceLabsError({
76
- code: typeof code === "string" ? code : code !== undefined ? String(code) : undefined,
77
- message,
78
- details: errorDetails(body),
79
- body,
80
- }),
81
- parseError: ({ body, cause }) => new NamespaceLabsParseError({ body, cause }),
82
- });
69
+ export const NamespaceLabsProtocol = /*@__PURE__*/ restProtocol({
70
+ credentials: /*@__PURE__*/ Effect.flatten(Credentials),
71
+ baseUrl: (creds, target) => baseUrlFor(creds, target.uri),
72
+ headers: (creds) => ({ Authorization: `Bearer ${Redacted.value(creds.token)}` }),
73
+ emptyJsonBody: true,
74
+ errorEnvelope,
75
+ unknownError: ({ code, message, body }) =>
76
+ new UnknownNamespaceLabsError({
77
+ code: typeof code === "string" ? code : code !== undefined ? String(code) : undefined,
78
+ message,
79
+ details: errorDetails(body),
80
+ body,
81
+ }),
82
+ parseError: ({ body, cause }) => new NamespaceLabsParseError({ body, cause }),
83
+ });
@@ -3,7 +3,7 @@ import * as C from "@distilled.cloud/core/category";
3
3
  // AUTO-GENERATED by scripts/generate.ts from .generated-specs (buf.build/namespace/cloud -> smithy). Do not edit.
4
4
  import * as S from "@distilled.cloud/core/schema-lite";
5
5
  import * as __L from "@distilled.cloud/core/schema-lite";
6
- import { UnknownNamespaceLabsError } from "../errors.ts";
6
+ import { NamespaceLabsServiceErrors } from "../errors.ts";
7
7
  import {
8
8
  NamespaceLabsProtocol,
9
9
  type NamespaceLabsOpError,
@@ -33,6 +33,7 @@ export class AlreadyExists
33
33
  /*@__PURE__*/ S.TaggedError<AlreadyExists>()("AlreadyExists", {
34
34
  message: S.String,
35
35
  body: S.Unknown,
36
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
36
37
  }).pipe(C.withConflictError),
37
38
  [{ status: 409, body: { "/code": "already_exists" } }],
38
39
  ) {}
@@ -42,6 +43,7 @@ export class FailedPrecondition
42
43
  /*@__PURE__*/ S.TaggedError<FailedPrecondition>()("FailedPrecondition", {
43
44
  message: S.String,
44
45
  body: S.Unknown,
46
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
45
47
  }).pipe(C.withBadRequestError),
46
48
  [{ status: 400, body: { "/code": "failed_precondition" } }],
47
49
  ) {}
@@ -51,6 +53,7 @@ export class InvalidArgument
51
53
  /*@__PURE__*/ S.TaggedError<InvalidArgument>()("InvalidArgument", {
52
54
  message: S.String,
53
55
  body: S.Unknown,
56
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
54
57
  }).pipe(C.withBadRequestError),
55
58
  [{ status: 400, body: { "/code": "invalid_argument" } }],
56
59
  ) {}
@@ -60,6 +63,7 @@ export class NotFound
60
63
  /*@__PURE__*/ S.TaggedError<NotFound>()("NotFound", {
61
64
  message: S.String,
62
65
  body: S.Unknown,
66
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
63
67
  }).pipe(C.withBadRequestError),
64
68
  [{ status: 404 }],
65
69
  ) {}
@@ -69,6 +73,7 @@ export class PermissionDenied
69
73
  /*@__PURE__*/ S.TaggedError<PermissionDenied>()("PermissionDenied", {
70
74
  message: S.String,
71
75
  body: S.Unknown,
76
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
72
77
  }).pipe(C.withAuthError),
73
78
  [{ status: 403 }],
74
79
  ) {}
@@ -78,6 +83,8 @@ export class ResourceExhausted
78
83
  /*@__PURE__*/ S.TaggedError<ResourceExhausted>()("ResourceExhausted", {
79
84
  message: S.String,
80
85
  body: S.Unknown,
86
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
87
+ retryAfter: /*@__PURE__*/ S.optional(S.Duration),
81
88
  }).pipe(C.withThrottlingError),
82
89
  [{ status: 429 }],
83
90
  ) {}
@@ -87,6 +94,7 @@ export class Unauthenticated
87
94
  /*@__PURE__*/ S.TaggedError<Unauthenticated>()("Unauthenticated", {
88
95
  message: S.String,
89
96
  body: S.Unknown,
97
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
90
98
  }).pipe(C.withAuthError),
91
99
  [{ status: 401 }],
92
100
  ) {}
@@ -160,8 +168,8 @@ export const describeJob: API.OperationMethod<
160
168
  NotFound,
161
169
  AlreadyExists,
162
170
  ResourceExhausted,
163
- UnknownNamespaceLabsError,
164
171
  ],
172
+ serviceErrors: NamespaceLabsServiceErrors,
165
173
  protocol: NamespaceLabsProtocol,
166
174
  retry: Retry.Retry,
167
175
  telemetry: TELEMETRY,
@@ -3,7 +3,7 @@ import * as C from "@distilled.cloud/core/category";
3
3
  // AUTO-GENERATED by scripts/generate.ts from .generated-specs (buf.build/namespace/cloud -> smithy). Do not edit.
4
4
  import * as S from "@distilled.cloud/core/schema-lite";
5
5
  import * as __L from "@distilled.cloud/core/schema-lite";
6
- import { UnknownNamespaceLabsError } from "../errors.ts";
6
+ import { NamespaceLabsServiceErrors } from "../errors.ts";
7
7
  import {
8
8
  NamespaceLabsProtocol,
9
9
  type NamespaceLabsOpError,
@@ -33,6 +33,7 @@ export class AlreadyExists
33
33
  /*@__PURE__*/ S.TaggedError<AlreadyExists>()("AlreadyExists", {
34
34
  message: S.String,
35
35
  body: S.Unknown,
36
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
36
37
  }).pipe(C.withConflictError),
37
38
  [{ status: 409, body: { "/code": "already_exists" } }],
38
39
  ) {}
@@ -42,6 +43,7 @@ export class FailedPrecondition
42
43
  /*@__PURE__*/ S.TaggedError<FailedPrecondition>()("FailedPrecondition", {
43
44
  message: S.String,
44
45
  body: S.Unknown,
46
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
45
47
  }).pipe(C.withBadRequestError),
46
48
  [{ status: 400, body: { "/code": "failed_precondition" } }],
47
49
  ) {}
@@ -51,6 +53,7 @@ export class InvalidArgument
51
53
  /*@__PURE__*/ S.TaggedError<InvalidArgument>()("InvalidArgument", {
52
54
  message: S.String,
53
55
  body: S.Unknown,
56
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
54
57
  }).pipe(C.withBadRequestError),
55
58
  [{ status: 400, body: { "/code": "invalid_argument" } }],
56
59
  ) {}
@@ -60,6 +63,7 @@ export class NotFound
60
63
  /*@__PURE__*/ S.TaggedError<NotFound>()("NotFound", {
61
64
  message: S.String,
62
65
  body: S.Unknown,
66
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
63
67
  }).pipe(C.withBadRequestError),
64
68
  [{ status: 404 }],
65
69
  ) {}
@@ -69,6 +73,7 @@ export class PermissionDenied
69
73
  /*@__PURE__*/ S.TaggedError<PermissionDenied>()("PermissionDenied", {
70
74
  message: S.String,
71
75
  body: S.Unknown,
76
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
72
77
  }).pipe(C.withAuthError),
73
78
  [{ status: 403 }],
74
79
  ) {}
@@ -78,6 +83,8 @@ export class ResourceExhausted
78
83
  /*@__PURE__*/ S.TaggedError<ResourceExhausted>()("ResourceExhausted", {
79
84
  message: S.String,
80
85
  body: S.Unknown,
86
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
87
+ retryAfter: /*@__PURE__*/ S.optional(S.Duration),
81
88
  }).pipe(C.withThrottlingError),
82
89
  [{ status: 429 }],
83
90
  ) {}
@@ -87,6 +94,7 @@ export class Unauthenticated
87
94
  /*@__PURE__*/ S.TaggedError<Unauthenticated>()("Unauthenticated", {
88
95
  message: S.String,
89
96
  body: S.Unknown,
97
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
90
98
  }).pipe(C.withAuthError),
91
99
  [{ status: 401 }],
92
100
  ) {}
@@ -214,8 +222,8 @@ export const getQueue: API.OperationMethod<
214
222
  NotFound,
215
223
  AlreadyExists,
216
224
  ResourceExhausted,
217
- UnknownNamespaceLabsError,
218
225
  ],
226
+ serviceErrors: NamespaceLabsServiceErrors,
219
227
  protocol: NamespaceLabsProtocol,
220
228
  retry: Retry.Retry,
221
229
  telemetry: TELEMETRY,
@@ -248,8 +256,8 @@ export const listQueues: API.OperationMethod<
248
256
  NotFound,
249
257
  AlreadyExists,
250
258
  ResourceExhausted,
251
- UnknownNamespaceLabsError,
252
259
  ],
260
+ serviceErrors: NamespaceLabsServiceErrors,
253
261
  protocol: NamespaceLabsProtocol,
254
262
  retry: Retry.Retry,
255
263
  telemetry: TELEMETRY,
@@ -282,8 +290,8 @@ export const updateQueue: API.OperationMethod<
282
290
  NotFound,
283
291
  AlreadyExists,
284
292
  ResourceExhausted,
285
- UnknownNamespaceLabsError,
286
293
  ],
294
+ serviceErrors: NamespaceLabsServiceErrors,
287
295
  protocol: NamespaceLabsProtocol,
288
296
  retry: Retry.Retry,
289
297
  telemetry: TELEMETRY,
@@ -1,30 +1,3 @@
1
1
  // AUTO-GENERATED by scripts/generate.ts. Do not edit.
2
- export * as artifacts from "./artifacts.ts";
3
- export * as audit from "./audit.ts";
4
- export * as bazelCache from "./bazel_cache.ts";
5
- export * as bazel from "./bazel.ts";
6
- export * as builder from "./builder.ts";
7
2
  export * as buildkiteJobs from "./buildkite_jobs.ts";
8
3
  export * as buildkiteQueue from "./buildkite_queue.ts";
9
- export * as computeCommand from "./compute_command.ts";
10
- export * as computeObservability from "./compute_observability.ts";
11
- export * as computeStorage from "./compute_storage.ts";
12
- export * as computeUsage from "./compute_usage.ts";
13
- export * as compute from "./compute.ts";
14
- export * as egress from "./egress.ts";
15
- export * as experimentalComputeReservation from "./experimental_compute_reservation.ts";
16
- export * as experimentalRemoteResults from "./experimental_remote_results.ts";
17
- export * as githubImage from "./github_image.ts";
18
- export * as githubJobs from "./github_jobs.ts";
19
- export * as githubProfile from "./github_profile.ts";
20
- export * as gradleCache from "./gradle_cache.ts";
21
- export * as httpcache from "./httpcache.ts";
22
- export * as iamTenantMembership from "./iam_tenant_membership.ts";
23
- export * as iamTenant from "./iam_tenant.ts";
24
- export * as iamToken from "./iam_token.ts";
25
- export * as image from "./image.ts";
26
- export * as privateDevbox from "./private_devbox.ts";
27
- export * as privateUserSessions from "./private_user_sessions.ts";
28
- export * as registry from "./registry.ts";
29
- export * as testing from "./testing.ts";
30
- export * as vault from "./vault.ts";
@@ -3,7 +3,7 @@ import * as C from "@distilled.cloud/core/category";
3
3
  // AUTO-GENERATED by scripts/generate.ts from .generated-specs (buf.build/namespace/cloud -> smithy). Do not edit.
4
4
  import * as S from "@distilled.cloud/core/schema-lite";
5
5
  import * as __L from "@distilled.cloud/core/schema-lite";
6
- import { UnknownNamespaceLabsError } from "../errors.ts";
6
+ import { NamespaceLabsServiceErrors } from "../errors.ts";
7
7
  import { paginateCursor } from "../pagination.ts";
8
8
  import {
9
9
  NamespaceLabsProtocol,
@@ -34,6 +34,7 @@ export class AlreadyExists
34
34
  /*@__PURE__*/ S.TaggedError<AlreadyExists>()("AlreadyExists", {
35
35
  message: S.String,
36
36
  body: S.Unknown,
37
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
37
38
  }).pipe(C.withConflictError),
38
39
  [{ status: 409, body: { "/code": "already_exists" } }],
39
40
  ) {}
@@ -43,6 +44,7 @@ export class FailedPrecondition
43
44
  /*@__PURE__*/ S.TaggedError<FailedPrecondition>()("FailedPrecondition", {
44
45
  message: S.String,
45
46
  body: S.Unknown,
47
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
46
48
  }).pipe(C.withBadRequestError),
47
49
  [{ status: 400, body: { "/code": "failed_precondition" } }],
48
50
  ) {}
@@ -52,6 +54,7 @@ export class InvalidArgument
52
54
  /*@__PURE__*/ S.TaggedError<InvalidArgument>()("InvalidArgument", {
53
55
  message: S.String,
54
56
  body: S.Unknown,
57
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
55
58
  }).pipe(C.withBadRequestError),
56
59
  [{ status: 400, body: { "/code": "invalid_argument" } }],
57
60
  ) {}
@@ -61,6 +64,7 @@ export class NotFound
61
64
  /*@__PURE__*/ S.TaggedError<NotFound>()("NotFound", {
62
65
  message: S.String,
63
66
  body: S.Unknown,
67
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
64
68
  }).pipe(C.withBadRequestError),
65
69
  [{ status: 404 }],
66
70
  ) {}
@@ -70,6 +74,7 @@ export class PermissionDenied
70
74
  /*@__PURE__*/ S.TaggedError<PermissionDenied>()("PermissionDenied", {
71
75
  message: S.String,
72
76
  body: S.Unknown,
77
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
73
78
  }).pipe(C.withAuthError),
74
79
  [{ status: 403 }],
75
80
  ) {}
@@ -79,6 +84,8 @@ export class ResourceExhausted
79
84
  /*@__PURE__*/ S.TaggedError<ResourceExhausted>()("ResourceExhausted", {
80
85
  message: S.String,
81
86
  body: S.Unknown,
87
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
88
+ retryAfter: /*@__PURE__*/ S.optional(S.Duration),
82
89
  }).pipe(C.withThrottlingError),
83
90
  [{ status: 429 }],
84
91
  ) {}
@@ -88,6 +95,7 @@ export class Unauthenticated
88
95
  /*@__PURE__*/ S.TaggedError<Unauthenticated>()("Unauthenticated", {
89
96
  message: S.String,
90
97
  body: S.Unknown,
98
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
91
99
  }).pipe(C.withAuthError),
92
100
  [{ status: 401 }],
93
101
  ) {}
@@ -280,8 +288,8 @@ export const createArtifact: API.OperationMethod<
280
288
  NotFound,
281
289
  AlreadyExists,
282
290
  ResourceExhausted,
283
- UnknownNamespaceLabsError,
284
291
  ],
292
+ serviceErrors: NamespaceLabsServiceErrors,
285
293
  protocol: NamespaceLabsProtocol,
286
294
  retry: Retry.Retry,
287
295
  telemetry: TELEMETRY,
@@ -314,8 +322,8 @@ export const expireArtifact: API.OperationMethod<
314
322
  NotFound,
315
323
  AlreadyExists,
316
324
  ResourceExhausted,
317
- UnknownNamespaceLabsError,
318
325
  ],
326
+ serviceErrors: NamespaceLabsServiceErrors,
319
327
  protocol: NamespaceLabsProtocol,
320
328
  retry: Retry.Retry,
321
329
  telemetry: TELEMETRY,
@@ -348,8 +356,8 @@ export const extendArtifact: API.OperationMethod<
348
356
  NotFound,
349
357
  AlreadyExists,
350
358
  ResourceExhausted,
351
- UnknownNamespaceLabsError,
352
359
  ],
360
+ serviceErrors: NamespaceLabsServiceErrors,
353
361
  protocol: NamespaceLabsProtocol,
354
362
  retry: Retry.Retry,
355
363
  telemetry: TELEMETRY,
@@ -382,8 +390,8 @@ export const finalizeArtifact: API.OperationMethod<
382
390
  NotFound,
383
391
  AlreadyExists,
384
392
  ResourceExhausted,
385
- UnknownNamespaceLabsError,
386
393
  ],
394
+ serviceErrors: NamespaceLabsServiceErrors,
387
395
  protocol: NamespaceLabsProtocol,
388
396
  retry: Retry.Retry,
389
397
  telemetry: TELEMETRY,
@@ -418,8 +426,8 @@ export const listArtifacts: API.PaginatedOperationMethod<
418
426
  NotFound,
419
427
  AlreadyExists,
420
428
  ResourceExhausted,
421
- UnknownNamespaceLabsError,
422
429
  ],
430
+ serviceErrors: NamespaceLabsServiceErrors,
423
431
  protocol: NamespaceLabsProtocol,
424
432
  retry: Retry.Retry,
425
433
  telemetry: TELEMETRY,
@@ -461,8 +469,8 @@ export const listNamespaces: API.OperationMethod<
461
469
  NotFound,
462
470
  AlreadyExists,
463
471
  ResourceExhausted,
464
- UnknownNamespaceLabsError,
465
472
  ],
473
+ serviceErrors: NamespaceLabsServiceErrors,
466
474
  protocol: NamespaceLabsProtocol,
467
475
  retry: Retry.Retry,
468
476
  telemetry: TELEMETRY,
@@ -495,8 +503,8 @@ export const resolveArtifact: API.OperationMethod<
495
503
  NotFound,
496
504
  AlreadyExists,
497
505
  ResourceExhausted,
498
- UnknownNamespaceLabsError,
499
506
  ],
507
+ serviceErrors: NamespaceLabsServiceErrors,
500
508
  protocol: NamespaceLabsProtocol,
501
509
  retry: Retry.Retry,
502
510
  telemetry: TELEMETRY,