@distilled.cloud/namespacelabs 0.0.0-stage → 1.0.0-rc.20

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 (216) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +125 -2
  3. package/lib/.lazy.json +1 -0
  4. package/lib/_bundle/lazy.js +4 -0
  5. package/lib/_bundle/sdk.js +2 -0
  6. package/lib/_bundle/sdk.js.map +1 -0
  7. package/lib/credentials.d.ts +55 -0
  8. package/lib/credentials.d.ts.map +1 -0
  9. package/lib/credentials.js +1 -0
  10. package/lib/errors.d.ts +33 -0
  11. package/lib/errors.d.ts.map +1 -0
  12. package/lib/errors.js +1 -0
  13. package/lib/index.d.ts +42 -0
  14. package/lib/index.d.ts.map +1 -0
  15. package/lib/index.js +7 -0
  16. package/lib/index.lazy.js +7 -0
  17. package/lib/index.lazy.js.map +1 -0
  18. package/lib/pagination.d.ts +2 -0
  19. package/lib/pagination.d.ts.map +1 -0
  20. package/lib/pagination.js +1 -0
  21. package/lib/protocol.d.ts +15 -0
  22. package/lib/protocol.d.ts.map +1 -0
  23. package/lib/protocol.js +1 -0
  24. package/lib/retry.d.ts +12 -0
  25. package/lib/retry.d.ts.map +1 -0
  26. package/lib/retry.js +1 -0
  27. package/lib/services/artifacts.d.ts +260 -0
  28. package/lib/services/artifacts.d.ts.map +1 -0
  29. package/lib/services/artifacts.js +2 -0
  30. package/lib/services/artifacts.js.map +1 -0
  31. package/lib/services/audit.d.ts +149 -0
  32. package/lib/services/audit.d.ts.map +1 -0
  33. package/lib/services/audit.js +2 -0
  34. package/lib/services/audit.js.map +1 -0
  35. package/lib/services/bazel.d.ts +173 -0
  36. package/lib/services/bazel.d.ts.map +1 -0
  37. package/lib/services/bazel.js +2 -0
  38. package/lib/services/bazel.js.map +1 -0
  39. package/lib/services/bazel_cache.d.ts +118 -0
  40. package/lib/services/bazel_cache.d.ts.map +1 -0
  41. package/lib/services/bazel_cache.js +2 -0
  42. package/lib/services/bazel_cache.js.map +1 -0
  43. package/lib/services/builder.d.ts +234 -0
  44. package/lib/services/builder.d.ts.map +1 -0
  45. package/lib/services/builder.js +2 -0
  46. package/lib/services/builder.js.map +1 -0
  47. package/lib/services/buildkite_jobs.d.ts +121 -0
  48. package/lib/services/buildkite_jobs.d.ts.map +1 -0
  49. package/lib/services/buildkite_jobs.js +2 -0
  50. package/lib/services/buildkite_jobs.js.map +1 -0
  51. package/lib/services/buildkite_queue.d.ts +178 -0
  52. package/lib/services/buildkite_queue.d.ts.map +1 -0
  53. package/lib/services/buildkite_queue.js +2 -0
  54. package/lib/services/buildkite_queue.js.map +1 -0
  55. package/lib/services/compute.d.ts +1057 -0
  56. package/lib/services/compute.d.ts.map +1 -0
  57. package/lib/services/compute.js +43 -0
  58. package/lib/services/compute.js.map +1 -0
  59. package/lib/services/compute_command.d.ts +112 -0
  60. package/lib/services/compute_command.d.ts.map +1 -0
  61. package/lib/services/compute_command.js +2 -0
  62. package/lib/services/compute_command.js.map +1 -0
  63. package/lib/services/compute_observability.d.ts +157 -0
  64. package/lib/services/compute_observability.d.ts.map +1 -0
  65. package/lib/services/compute_observability.js +2 -0
  66. package/lib/services/compute_observability.js.map +1 -0
  67. package/lib/services/compute_storage.d.ts +371 -0
  68. package/lib/services/compute_storage.d.ts.map +1 -0
  69. package/lib/services/compute_storage.js +33 -0
  70. package/lib/services/compute_storage.js.map +1 -0
  71. package/lib/services/compute_usage.d.ts +275 -0
  72. package/lib/services/compute_usage.d.ts.map +1 -0
  73. package/lib/services/compute_usage.js +2 -0
  74. package/lib/services/compute_usage.js.map +1 -0
  75. package/lib/services/egress.d.ts +183 -0
  76. package/lib/services/egress.d.ts.map +1 -0
  77. package/lib/services/egress.js +2 -0
  78. package/lib/services/egress.js.map +1 -0
  79. package/lib/services/experimental_compute_reservation.d.ts +662 -0
  80. package/lib/services/experimental_compute_reservation.d.ts.map +1 -0
  81. package/lib/services/experimental_compute_reservation.js +23 -0
  82. package/lib/services/experimental_compute_reservation.js.map +1 -0
  83. package/lib/services/experimental_remote_results.d.ts +488 -0
  84. package/lib/services/experimental_remote_results.d.ts.map +1 -0
  85. package/lib/services/experimental_remote_results.js +2 -0
  86. package/lib/services/experimental_remote_results.js.map +1 -0
  87. package/lib/services/github_image.d.ts +154 -0
  88. package/lib/services/github_image.d.ts.map +1 -0
  89. package/lib/services/github_image.js +2 -0
  90. package/lib/services/github_image.js.map +1 -0
  91. package/lib/services/github_jobs.d.ts +175 -0
  92. package/lib/services/github_jobs.d.ts.map +1 -0
  93. package/lib/services/github_jobs.js +2 -0
  94. package/lib/services/github_jobs.js.map +1 -0
  95. package/lib/services/github_profile.d.ts +288 -0
  96. package/lib/services/github_profile.d.ts.map +1 -0
  97. package/lib/services/github_profile.js +2 -0
  98. package/lib/services/github_profile.js.map +1 -0
  99. package/lib/services/gradle_cache.d.ts +117 -0
  100. package/lib/services/gradle_cache.d.ts.map +1 -0
  101. package/lib/services/gradle_cache.js +2 -0
  102. package/lib/services/gradle_cache.js.map +1 -0
  103. package/lib/services/httpcache.d.ts +117 -0
  104. package/lib/services/httpcache.d.ts.map +1 -0
  105. package/lib/services/httpcache.js +2 -0
  106. package/lib/services/httpcache.js.map +1 -0
  107. package/lib/services/iam_tenant.d.ts +373 -0
  108. package/lib/services/iam_tenant.d.ts.map +1 -0
  109. package/lib/services/iam_tenant.js +39 -0
  110. package/lib/services/iam_tenant.js.map +1 -0
  111. package/lib/services/iam_tenant_membership.d.ts +106 -0
  112. package/lib/services/iam_tenant_membership.d.ts.map +1 -0
  113. package/lib/services/iam_tenant_membership.js +2 -0
  114. package/lib/services/iam_tenant_membership.js.map +1 -0
  115. package/lib/services/iam_token.d.ts +249 -0
  116. package/lib/services/iam_token.d.ts.map +1 -0
  117. package/lib/services/iam_token.js +2 -0
  118. package/lib/services/iam_token.js.map +1 -0
  119. package/lib/services/image.d.ts +214 -0
  120. package/lib/services/image.d.ts.map +1 -0
  121. package/lib/services/image.js +2 -0
  122. package/lib/services/image.js.map +1 -0
  123. package/lib/services/index.d.ts +30 -0
  124. package/lib/services/index.d.ts.map +1 -0
  125. package/lib/services/index.js +29 -0
  126. package/lib/services/private_devbox.d.ts +1156 -0
  127. package/lib/services/private_devbox.d.ts.map +1 -0
  128. package/lib/services/private_devbox.js +81 -0
  129. package/lib/services/private_devbox.js.map +1 -0
  130. package/lib/services/private_user_sessions.d.ts +137 -0
  131. package/lib/services/private_user_sessions.d.ts.map +1 -0
  132. package/lib/services/private_user_sessions.js +2 -0
  133. package/lib/services/private_user_sessions.js.map +1 -0
  134. package/lib/services/registry.d.ts +365 -0
  135. package/lib/services/registry.d.ts.map +1 -0
  136. package/lib/services/registry.js +34 -0
  137. package/lib/services/registry.js.map +1 -0
  138. package/lib/services/testing.d.ts +152 -0
  139. package/lib/services/testing.d.ts.map +1 -0
  140. package/lib/services/testing.js +2 -0
  141. package/lib/services/testing.js.map +1 -0
  142. package/lib/services/vault.d.ts +195 -0
  143. package/lib/services/vault.d.ts.map +1 -0
  144. package/lib/services/vault.js +2 -0
  145. package/lib/services/vault.js.map +1 -0
  146. package/lib/services.lazy/artifacts.js +1 -0
  147. package/lib/services.lazy/audit.js +1 -0
  148. package/lib/services.lazy/bazel.js +1 -0
  149. package/lib/services.lazy/bazel_cache.js +1 -0
  150. package/lib/services.lazy/builder.js +1 -0
  151. package/lib/services.lazy/buildkite_jobs.js +1 -0
  152. package/lib/services.lazy/buildkite_queue.js +1 -0
  153. package/lib/services.lazy/compute.js +4 -0
  154. package/lib/services.lazy/compute_command.js +1 -0
  155. package/lib/services.lazy/compute_observability.js +1 -0
  156. package/lib/services.lazy/compute_storage.js +4 -0
  157. package/lib/services.lazy/compute_usage.js +1 -0
  158. package/lib/services.lazy/egress.js +1 -0
  159. package/lib/services.lazy/experimental_compute_reservation.js +4 -0
  160. package/lib/services.lazy/experimental_remote_results.js +1 -0
  161. package/lib/services.lazy/github_image.js +1 -0
  162. package/lib/services.lazy/github_jobs.js +1 -0
  163. package/lib/services.lazy/github_profile.js +1 -0
  164. package/lib/services.lazy/gradle_cache.js +1 -0
  165. package/lib/services.lazy/httpcache.js +1 -0
  166. package/lib/services.lazy/iam_tenant.js +4 -0
  167. package/lib/services.lazy/iam_tenant_membership.js +1 -0
  168. package/lib/services.lazy/iam_token.js +1 -0
  169. package/lib/services.lazy/image.js +1 -0
  170. package/lib/services.lazy/index.js +3 -0
  171. package/lib/services.lazy/private_devbox.js +4 -0
  172. package/lib/services.lazy/private_user_sessions.js +1 -0
  173. package/lib/services.lazy/registry.js +4 -0
  174. package/lib/services.lazy/testing.js +1 -0
  175. package/lib/services.lazy/vault.js +1 -0
  176. package/lib/traits.d.ts +3 -0
  177. package/lib/traits.d.ts.map +1 -0
  178. package/lib/traits.js +1 -0
  179. package/package.json +87 -3
  180. package/src/credentials.ts +164 -0
  181. package/src/errors.ts +47 -0
  182. package/src/index.ts +48 -0
  183. package/src/pagination.ts +1 -0
  184. package/src/protocol.ts +82 -0
  185. package/src/retry.ts +28 -0
  186. package/src/services/artifacts.ts +761 -0
  187. package/src/services/audit.ts +315 -0
  188. package/src/services/bazel.ts +415 -0
  189. package/src/services/bazel_cache.ts +211 -0
  190. package/src/services/builder.ts +568 -0
  191. package/src/services/buildkite_jobs.ts +222 -0
  192. package/src/services/buildkite_queue.ts +445 -0
  193. package/src/services/compute.ts +2794 -0
  194. package/src/services/compute_command.ts +212 -0
  195. package/src/services/compute_observability.ts +428 -0
  196. package/src/services/compute_storage.ts +1159 -0
  197. package/src/services/compute_usage.ts +730 -0
  198. package/src/services/egress.ts +508 -0
  199. package/src/services/experimental_compute_reservation.ts +1488 -0
  200. package/src/services/experimental_remote_results.ts +1157 -0
  201. package/src/services/github_image.ts +293 -0
  202. package/src/services/github_jobs.ts +381 -0
  203. package/src/services/github_profile.ts +721 -0
  204. package/src/services/gradle_cache.ts +263 -0
  205. package/src/services/httpcache.ts +263 -0
  206. package/src/services/iam_tenant.ts +1355 -0
  207. package/src/services/iam_tenant_membership.ts +245 -0
  208. package/src/services/iam_token.ts +780 -0
  209. package/src/services/image.ts +594 -0
  210. package/src/services/index.ts +30 -0
  211. package/src/services/private_devbox.ts +4217 -0
  212. package/src/services/private_user_sessions.ts +402 -0
  213. package/src/services/registry.ts +1234 -0
  214. package/src/services/testing.ts +386 -0
  215. package/src/services/vault.ts +514 -0
  216. package/src/traits.ts +36 -0
@@ -0,0 +1,263 @@
1
+ import * as API from "@distilled.cloud/core/api";
2
+ import * as C from "@distilled.cloud/core/category";
3
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (buf.build/namespace/cloud -> smithy). Do not edit.
4
+ import * as S from "@distilled.cloud/core/schema-lite";
5
+ import * as __L from "@distilled.cloud/core/schema-lite";
6
+ import type * as Redacted from "effect/Redacted";
7
+ import { UnknownNamespaceLabsError } from "../errors.ts";
8
+ import {
9
+ NamespaceLabsProtocol,
10
+ type NamespaceLabsOpError,
11
+ type NamespaceLabsOpContext,
12
+ } from "../protocol.ts";
13
+ import * as Retry from "../retry.ts";
14
+ import * as T from "../traits.ts";
15
+ // Schema table, filled on first reach (see __S at the end).
16
+ const __s: any[] = [];
17
+
18
+ export type { NamespaceLabsOpError, NamespaceLabsOpContext };
19
+
20
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
21
+ const TELEMETRY = {
22
+ system: "namespacelabs-api",
23
+ responseHeaders: [
24
+ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
25
+ { header: "request-id", name: "http.response.header.request-id", transform: "list" },
26
+ ],
27
+ prefix: "Namespacelabs",
28
+ service: "GradleCacheService",
29
+ propagate: "w3c",
30
+ } as const;
31
+
32
+ export class AlreadyExists
33
+ extends /*@__PURE__*/ T.applyErrorMatchers(
34
+ /*@__PURE__*/ S.TaggedError<AlreadyExists>()("AlreadyExists", {
35
+ message: S.String,
36
+ body: S.Unknown,
37
+ }).pipe(C.withConflictError),
38
+ [{ status: 409, body: { "/code": "already_exists" } }],
39
+ ) {}
40
+
41
+ export class FailedPrecondition
42
+ extends /*@__PURE__*/ T.applyErrorMatchers(
43
+ /*@__PURE__*/ S.TaggedError<FailedPrecondition>()("FailedPrecondition", {
44
+ message: S.String,
45
+ body: S.Unknown,
46
+ }).pipe(C.withBadRequestError),
47
+ [{ status: 400, body: { "/code": "failed_precondition" } }],
48
+ ) {}
49
+
50
+ export class InvalidArgument
51
+ extends /*@__PURE__*/ T.applyErrorMatchers(
52
+ /*@__PURE__*/ S.TaggedError<InvalidArgument>()("InvalidArgument", {
53
+ message: S.String,
54
+ body: S.Unknown,
55
+ }).pipe(C.withBadRequestError),
56
+ [{ status: 400, body: { "/code": "invalid_argument" } }],
57
+ ) {}
58
+
59
+ export class NotFound
60
+ extends /*@__PURE__*/ T.applyErrorMatchers(
61
+ /*@__PURE__*/ S.TaggedError<NotFound>()("NotFound", {
62
+ message: S.String,
63
+ body: S.Unknown,
64
+ }).pipe(C.withBadRequestError),
65
+ [{ status: 404 }],
66
+ ) {}
67
+
68
+ export class PermissionDenied
69
+ extends /*@__PURE__*/ T.applyErrorMatchers(
70
+ /*@__PURE__*/ S.TaggedError<PermissionDenied>()("PermissionDenied", {
71
+ message: S.String,
72
+ body: S.Unknown,
73
+ }).pipe(C.withAuthError),
74
+ [{ status: 403 }],
75
+ ) {}
76
+
77
+ export class ResourceExhausted
78
+ extends /*@__PURE__*/ T.applyErrorMatchers(
79
+ /*@__PURE__*/ S.TaggedError<ResourceExhausted>()("ResourceExhausted", {
80
+ message: S.String,
81
+ body: S.Unknown,
82
+ }).pipe(C.withThrottlingError),
83
+ [{ status: 429 }],
84
+ ) {}
85
+
86
+ export class Unauthenticated
87
+ extends /*@__PURE__*/ T.applyErrorMatchers(
88
+ /*@__PURE__*/ S.TaggedError<Unauthenticated>()("Unauthenticated", {
89
+ message: S.String,
90
+ body: S.Unknown,
91
+ }).pipe(C.withAuthError),
92
+ [{ status: 401 }],
93
+ ) {}
94
+
95
+ export interface EnsureGradleCacheRequest {
96
+ /** A name of the cache. */
97
+ name?: string | undefined;
98
+ /** Optional site preference (e.g., "iad", "ord"). If not set, the site is determined from the caller's location or workload context. */
99
+ site?: string | undefined;
100
+ }
101
+ export interface EnsureGradleCacheResponse {
102
+ /** The URL endpoint for the Gradle build cache. */
103
+ cacheEndpointUrl: string;
104
+ username: string;
105
+ password: string | Redacted.Redacted<string>;
106
+ /** Until when is the returned cache configuration usable. */
107
+ expiresAt?: string | undefined;
108
+ /** The site where the cache is located (e.g., "iad", "ord"). */
109
+ site: string;
110
+ }
111
+ export interface GetAccessPolicyRequest {
112
+ /** A name of the cache. */
113
+ name?: string | undefined;
114
+ }
115
+ export type StringList = Array<string>;
116
+ /** Defines a permission grant on a resource. Permissions are used to restrict what a token is allowed to do. See https://namespace.so/docs/security/permissions for a list of available resource types and actions. */
117
+ export interface Permission {
118
+ /** The type of resource this permission applies to, e.g. "instance", "vault/object", "token/revokable". */
119
+ resourceType: string;
120
+ /** The specific resource ID, or empty for all resources of this type. */
121
+ resourceId: string;
122
+ /** The set of actions allowed on the resource, e.g. "create", "list", "describe". */
123
+ actions: StringList;
124
+ }
125
+ export type PermissionList = Array<Permission>;
126
+ export interface GetAccessPolicyResponse {
127
+ /** The set of permissions that is required to access Gradle caches. */
128
+ requiredPermission: PermissionList;
129
+ }
130
+ export type EnsureGradleCacheError =
131
+ | InvalidArgument
132
+ | FailedPrecondition
133
+ | Unauthenticated
134
+ | PermissionDenied
135
+ | NotFound
136
+ | AlreadyExists
137
+ | ResourceExhausted
138
+ | NamespaceLabsOpError;
139
+ /** Returns cache configuration for the caller's environment. Creates necessary resources if they don't exist. */
140
+ export const ensureGradleCache: API.OperationMethod<
141
+ EnsureGradleCacheRequest,
142
+ EnsureGradleCacheResponse,
143
+ EnsureGradleCacheError,
144
+ NamespaceLabsOpContext
145
+ > = /*@__PURE__*/ API.make(() => ({
146
+ input: __S(0, __c0, 0) as any as S.Schema<EnsureGradleCacheRequest>,
147
+ output: __S(1, __c0, 1) as any as S.Schema<EnsureGradleCacheResponse>,
148
+ errors: [
149
+ InvalidArgument,
150
+ FailedPrecondition,
151
+ Unauthenticated,
152
+ PermissionDenied,
153
+ NotFound,
154
+ AlreadyExists,
155
+ ResourceExhausted,
156
+ UnknownNamespaceLabsError,
157
+ ],
158
+ protocol: NamespaceLabsProtocol,
159
+ retry: Retry.Retry,
160
+ telemetry: TELEMETRY,
161
+ span: "EnsureGradleCache",
162
+ }));
163
+
164
+ export type GetAccessPolicyError =
165
+ | InvalidArgument
166
+ | FailedPrecondition
167
+ | Unauthenticated
168
+ | PermissionDenied
169
+ | NotFound
170
+ | AlreadyExists
171
+ | ResourceExhausted
172
+ | NamespaceLabsOpError;
173
+ /** Returns the required permissions that are needed to access Gradle caches. */
174
+ export const getAccessPolicy: API.OperationMethod<
175
+ GetAccessPolicyRequest,
176
+ GetAccessPolicyResponse,
177
+ GetAccessPolicyError,
178
+ NamespaceLabsOpContext
179
+ > = /*@__PURE__*/ API.make(() => ({
180
+ input: __S(8, __c1, 0) as any as S.Schema<GetAccessPolicyRequest>,
181
+ output: __S(12, __c1, 4) as any as S.Schema<GetAccessPolicyResponse>,
182
+ errors: [
183
+ InvalidArgument,
184
+ FailedPrecondition,
185
+ Unauthenticated,
186
+ PermissionDenied,
187
+ NotFound,
188
+ AlreadyExists,
189
+ ResourceExhausted,
190
+ UnknownNamespaceLabsError,
191
+ ],
192
+ protocol: NamespaceLabsProtocol,
193
+ retry: Retry.Retry,
194
+ telemetry: TELEMETRY,
195
+ span: "GetAccessPolicy",
196
+ }));
197
+
198
+ // Schema builders: each runs one schema initializer, on that schema's first use.
199
+ function __c0(j: number): any {
200
+ switch (j) {
201
+ case 0:
202
+ return S.suspend(() =>
203
+ S.Struct({
204
+ name: S.optional(S.String),
205
+ site: S.optional(S.String),
206
+ }).pipe(
207
+ T.Http({
208
+ method: "POST",
209
+ uri: "/namespace.cloud.integrations.gradle.v1beta.GradleCacheService/EnsureGradleCache",
210
+ code: 200,
211
+ }),
212
+ ),
213
+ ).annotate({ identifier: "EnsureGradleCacheRequest" });
214
+ case 1:
215
+ return S.suspend(() =>
216
+ S.Struct({
217
+ cacheEndpointUrl: S.String,
218
+ username: S.String,
219
+ password: S.String.pipe(T.SensitiveValue({})),
220
+ expiresAt: S.optional(S.String),
221
+ site: S.String,
222
+ }),
223
+ ).annotate({ identifier: "EnsureGradleCacheResponse" });
224
+ }
225
+ }
226
+ function __c1(j: number): any {
227
+ switch (j) {
228
+ case 0:
229
+ return S.suspend(() =>
230
+ S.Struct({
231
+ name: S.optional(S.String),
232
+ }).pipe(
233
+ T.Http({
234
+ method: "POST",
235
+ uri: "/namespace.cloud.integrations.gradle.v1beta.GradleCacheService/GetAccessPolicy",
236
+ code: 200,
237
+ }),
238
+ ),
239
+ ).annotate({ identifier: "GetAccessPolicyRequest" });
240
+ case 1:
241
+ return S.Array(S.String);
242
+ case 2:
243
+ return S.suspend(() =>
244
+ S.Struct({
245
+ resourceType: S.String,
246
+ resourceId: S.String,
247
+ actions: __S(9, __c1, 1),
248
+ }),
249
+ ).annotate({ identifier: "Permission" });
250
+ case 3:
251
+ return S.Array(__S(10, __c1, 2));
252
+ case 4:
253
+ return S.suspend(() =>
254
+ S.Struct({
255
+ requiredPermission: __S(11, __c1, 3),
256
+ }),
257
+ ).annotate({ identifier: "GetAccessPolicyResponse" });
258
+ }
259
+ }
260
+ // Schema table: entry i is schema j of builder f, made on first reach.
261
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
262
+ return (__s[i] ??= __L.at(f, j));
263
+ }
@@ -0,0 +1,263 @@
1
+ import * as API from "@distilled.cloud/core/api";
2
+ import * as C from "@distilled.cloud/core/category";
3
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (buf.build/namespace/cloud -> smithy). Do not edit.
4
+ import * as S from "@distilled.cloud/core/schema-lite";
5
+ import * as __L from "@distilled.cloud/core/schema-lite";
6
+ import type * as Redacted from "effect/Redacted";
7
+ import { UnknownNamespaceLabsError } from "../errors.ts";
8
+ import {
9
+ NamespaceLabsProtocol,
10
+ type NamespaceLabsOpError,
11
+ type NamespaceLabsOpContext,
12
+ } from "../protocol.ts";
13
+ import * as Retry from "../retry.ts";
14
+ import * as T from "../traits.ts";
15
+ // Schema table, filled on first reach (see __S at the end).
16
+ const __s: any[] = [];
17
+
18
+ export type { NamespaceLabsOpError, NamespaceLabsOpContext };
19
+
20
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
21
+ const TELEMETRY = {
22
+ system: "namespacelabs-api",
23
+ responseHeaders: [
24
+ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
25
+ { header: "request-id", name: "http.response.header.request-id", transform: "list" },
26
+ ],
27
+ prefix: "Namespacelabs",
28
+ service: "HttpCacheService",
29
+ propagate: "w3c",
30
+ } as const;
31
+
32
+ export class AlreadyExists
33
+ extends /*@__PURE__*/ T.applyErrorMatchers(
34
+ /*@__PURE__*/ S.TaggedError<AlreadyExists>()("AlreadyExists", {
35
+ message: S.String,
36
+ body: S.Unknown,
37
+ }).pipe(C.withConflictError),
38
+ [{ status: 409, body: { "/code": "already_exists" } }],
39
+ ) {}
40
+
41
+ export class FailedPrecondition
42
+ extends /*@__PURE__*/ T.applyErrorMatchers(
43
+ /*@__PURE__*/ S.TaggedError<FailedPrecondition>()("FailedPrecondition", {
44
+ message: S.String,
45
+ body: S.Unknown,
46
+ }).pipe(C.withBadRequestError),
47
+ [{ status: 400, body: { "/code": "failed_precondition" } }],
48
+ ) {}
49
+
50
+ export class InvalidArgument
51
+ extends /*@__PURE__*/ T.applyErrorMatchers(
52
+ /*@__PURE__*/ S.TaggedError<InvalidArgument>()("InvalidArgument", {
53
+ message: S.String,
54
+ body: S.Unknown,
55
+ }).pipe(C.withBadRequestError),
56
+ [{ status: 400, body: { "/code": "invalid_argument" } }],
57
+ ) {}
58
+
59
+ export class NotFound
60
+ extends /*@__PURE__*/ T.applyErrorMatchers(
61
+ /*@__PURE__*/ S.TaggedError<NotFound>()("NotFound", {
62
+ message: S.String,
63
+ body: S.Unknown,
64
+ }).pipe(C.withBadRequestError),
65
+ [{ status: 404 }],
66
+ ) {}
67
+
68
+ export class PermissionDenied
69
+ extends /*@__PURE__*/ T.applyErrorMatchers(
70
+ /*@__PURE__*/ S.TaggedError<PermissionDenied>()("PermissionDenied", {
71
+ message: S.String,
72
+ body: S.Unknown,
73
+ }).pipe(C.withAuthError),
74
+ [{ status: 403 }],
75
+ ) {}
76
+
77
+ export class ResourceExhausted
78
+ extends /*@__PURE__*/ T.applyErrorMatchers(
79
+ /*@__PURE__*/ S.TaggedError<ResourceExhausted>()("ResourceExhausted", {
80
+ message: S.String,
81
+ body: S.Unknown,
82
+ }).pipe(C.withThrottlingError),
83
+ [{ status: 429 }],
84
+ ) {}
85
+
86
+ export class Unauthenticated
87
+ extends /*@__PURE__*/ T.applyErrorMatchers(
88
+ /*@__PURE__*/ S.TaggedError<Unauthenticated>()("Unauthenticated", {
89
+ message: S.String,
90
+ body: S.Unknown,
91
+ }).pipe(C.withAuthError),
92
+ [{ status: 401 }],
93
+ ) {}
94
+
95
+ export interface EnsureHttpCacheRequest {
96
+ /** A name of the cache. */
97
+ name?: string | undefined;
98
+ /** Optional site preference (e.g., "iad", "ord"). If not set, the site is determined from the caller's location or workload context. */
99
+ site?: string | undefined;
100
+ }
101
+ export interface EnsureHttpCacheResponse {
102
+ /** The URL endpoint for the HTTP build cache. */
103
+ cacheEndpointUrl: string;
104
+ username: string;
105
+ password: string | Redacted.Redacted<string>;
106
+ /** Until when is the returned cache configuration usable. */
107
+ expiresAt?: string | undefined;
108
+ /** The site where the cache is located (e.g., "iad", "ord"). */
109
+ site: string;
110
+ }
111
+ export interface GetAccessPolicyRequest {
112
+ /** A name of the cache. */
113
+ name?: string | undefined;
114
+ }
115
+ export type StringList = Array<string>;
116
+ /** Defines a permission grant on a resource. Permissions are used to restrict what a token is allowed to do. See https://namespace.so/docs/security/permissions for a list of available resource types and actions. */
117
+ export interface Permission {
118
+ /** The type of resource this permission applies to, e.g. "instance", "vault/object", "token/revokable". */
119
+ resourceType: string;
120
+ /** The specific resource ID, or empty for all resources of this type. */
121
+ resourceId: string;
122
+ /** The set of actions allowed on the resource, e.g. "create", "list", "describe". */
123
+ actions: StringList;
124
+ }
125
+ export type PermissionList = Array<Permission>;
126
+ export interface GetAccessPolicyResponse {
127
+ /** The set of permissions that is required to access HTTP caches. */
128
+ requiredPermission: PermissionList;
129
+ }
130
+ export type EnsureHttpCacheError =
131
+ | InvalidArgument
132
+ | FailedPrecondition
133
+ | Unauthenticated
134
+ | PermissionDenied
135
+ | NotFound
136
+ | AlreadyExists
137
+ | ResourceExhausted
138
+ | NamespaceLabsOpError;
139
+ /** Returns cache configuration for the caller's environment. Creates necessary resources if they don't exist. */
140
+ export const ensureHttpCache: API.OperationMethod<
141
+ EnsureHttpCacheRequest,
142
+ EnsureHttpCacheResponse,
143
+ EnsureHttpCacheError,
144
+ NamespaceLabsOpContext
145
+ > = /*@__PURE__*/ API.make(() => ({
146
+ input: __S(0, __c0, 0) as any as S.Schema<EnsureHttpCacheRequest>,
147
+ output: __S(1, __c0, 1) as any as S.Schema<EnsureHttpCacheResponse>,
148
+ errors: [
149
+ InvalidArgument,
150
+ FailedPrecondition,
151
+ Unauthenticated,
152
+ PermissionDenied,
153
+ NotFound,
154
+ AlreadyExists,
155
+ ResourceExhausted,
156
+ UnknownNamespaceLabsError,
157
+ ],
158
+ protocol: NamespaceLabsProtocol,
159
+ retry: Retry.Retry,
160
+ telemetry: TELEMETRY,
161
+ span: "EnsureHttpCache",
162
+ }));
163
+
164
+ export type GetAccessPolicyError =
165
+ | InvalidArgument
166
+ | FailedPrecondition
167
+ | Unauthenticated
168
+ | PermissionDenied
169
+ | NotFound
170
+ | AlreadyExists
171
+ | ResourceExhausted
172
+ | NamespaceLabsOpError;
173
+ /** Returns the required permissions that are needed to access HTTP caches. */
174
+ export const getAccessPolicy: API.OperationMethod<
175
+ GetAccessPolicyRequest,
176
+ GetAccessPolicyResponse,
177
+ GetAccessPolicyError,
178
+ NamespaceLabsOpContext
179
+ > = /*@__PURE__*/ API.make(() => ({
180
+ input: __S(8, __c1, 0) as any as S.Schema<GetAccessPolicyRequest>,
181
+ output: __S(12, __c1, 4) as any as S.Schema<GetAccessPolicyResponse>,
182
+ errors: [
183
+ InvalidArgument,
184
+ FailedPrecondition,
185
+ Unauthenticated,
186
+ PermissionDenied,
187
+ NotFound,
188
+ AlreadyExists,
189
+ ResourceExhausted,
190
+ UnknownNamespaceLabsError,
191
+ ],
192
+ protocol: NamespaceLabsProtocol,
193
+ retry: Retry.Retry,
194
+ telemetry: TELEMETRY,
195
+ span: "GetAccessPolicy",
196
+ }));
197
+
198
+ // Schema builders: each runs one schema initializer, on that schema's first use.
199
+ function __c0(j: number): any {
200
+ switch (j) {
201
+ case 0:
202
+ return S.suspend(() =>
203
+ S.Struct({
204
+ name: S.optional(S.String),
205
+ site: S.optional(S.String),
206
+ }).pipe(
207
+ T.Http({
208
+ method: "POST",
209
+ uri: "/namespace.cloud.integrations.httpcache.v1beta.HttpCacheService/EnsureHttpCache",
210
+ code: 200,
211
+ }),
212
+ ),
213
+ ).annotate({ identifier: "EnsureHttpCacheRequest" });
214
+ case 1:
215
+ return S.suspend(() =>
216
+ S.Struct({
217
+ cacheEndpointUrl: S.String,
218
+ username: S.String,
219
+ password: S.String.pipe(T.SensitiveValue({})),
220
+ expiresAt: S.optional(S.String),
221
+ site: S.String,
222
+ }),
223
+ ).annotate({ identifier: "EnsureHttpCacheResponse" });
224
+ }
225
+ }
226
+ function __c1(j: number): any {
227
+ switch (j) {
228
+ case 0:
229
+ return S.suspend(() =>
230
+ S.Struct({
231
+ name: S.optional(S.String),
232
+ }).pipe(
233
+ T.Http({
234
+ method: "POST",
235
+ uri: "/namespace.cloud.integrations.httpcache.v1beta.HttpCacheService/GetAccessPolicy",
236
+ code: 200,
237
+ }),
238
+ ),
239
+ ).annotate({ identifier: "GetAccessPolicyRequest" });
240
+ case 1:
241
+ return S.Array(S.String);
242
+ case 2:
243
+ return S.suspend(() =>
244
+ S.Struct({
245
+ resourceType: S.String,
246
+ resourceId: S.String,
247
+ actions: __S(9, __c1, 1),
248
+ }),
249
+ ).annotate({ identifier: "Permission" });
250
+ case 3:
251
+ return S.Array(__S(10, __c1, 2));
252
+ case 4:
253
+ return S.suspend(() =>
254
+ S.Struct({
255
+ requiredPermission: __S(11, __c1, 3),
256
+ }),
257
+ ).annotate({ identifier: "GetAccessPolicyResponse" });
258
+ }
259
+ }
260
+ // Schema table: entry i is schema j of builder f, made on first reach.
261
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
262
+ return (__s[i] ??= __L.at(f, j));
263
+ }