@distilled.cloud/tailscale 1.0.0-rc.19 → 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 (38) hide show
  1. package/README.md +3 -3
  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 +17 -8
  6. package/lib/credentials.d.ts.map +1 -1
  7. package/lib/errors.d.ts +31 -9
  8. package/lib/errors.d.ts.map +1 -1
  9. package/lib/errors.js +1 -1
  10. package/lib/index.d.ts.map +1 -1
  11. package/lib/index.lazy.js.map +1 -1
  12. package/lib/pagination.d.ts.map +1 -1
  13. package/lib/protocol.d.ts +15 -8
  14. package/lib/protocol.d.ts.map +1 -1
  15. package/lib/retry.d.ts.map +1 -1
  16. package/lib/services/index.d.ts.map +1 -1
  17. package/lib/services/tailscale.d.ts +40 -86
  18. package/lib/services/tailscale.d.ts.map +1 -1
  19. package/lib/services/tailscale.js +130 -133
  20. package/lib/services/tailscale.js.map +1 -1
  21. package/lib/services.lazy/tailscale.js +3 -3
  22. package/lib/traits.d.ts.map +1 -1
  23. package/lib/unstable-services/index.d.ts +2 -0
  24. package/lib/unstable-services/index.d.ts.map +1 -0
  25. package/lib/unstable-services/index.js +1 -0
  26. package/lib/unstable-services/tailscale.d.ts +129 -0
  27. package/lib/unstable-services/tailscale.d.ts.map +1 -0
  28. package/lib/unstable-services/tailscale.js +2 -0
  29. package/lib/unstable-services/tailscale.js.map +1 -0
  30. package/lib/unstable-services.lazy/index.js +3 -0
  31. package/lib/unstable-services.lazy/tailscale.js +1 -0
  32. package/package.json +12 -4
  33. package/src/credentials.ts +78 -98
  34. package/src/errors.ts +28 -8
  35. package/src/protocol.ts +43 -50
  36. package/src/services/tailscale.ts +758 -811
  37. package/src/unstable-services/index.ts +2 -0
  38. package/src/unstable-services/tailscale.ts +319 -0
@@ -0,0 +1,2 @@
1
+ // AUTO-GENERATED by scripts/generate.ts. Do not edit.
2
+ export * as tailscale from "./tailscale.ts";
@@ -0,0 +1,319 @@
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 (specs/spec-mirror-tailscale). 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 { TailscaleServiceErrors } from "../errors.ts";
8
+ import { paginateCursor } from "../pagination.ts";
9
+ import { TailscaleProtocol, type TailscaleOpError, type TailscaleOpContext } from "../protocol.ts";
10
+ import * as Retry from "../retry.ts";
11
+ import * as T from "../traits.ts";
12
+ // Schema table, filled on first reach (see __S at the end).
13
+ const __s: any[] = [];
14
+
15
+ export type { TailscaleOpError, TailscaleOpContext };
16
+
17
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
18
+ const TELEMETRY = {
19
+ system: "tailscale-api",
20
+ responseHeaders: [
21
+ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
22
+ { header: "request-id", name: "http.response.header.request-id", transform: "list" },
23
+ ],
24
+ prefix: "Tailscale",
25
+ service: "Tailscale",
26
+ labels: "tailscale",
27
+ propagate: "w3c",
28
+ } as const;
29
+
30
+ export class BadRequest
31
+ extends /*@__PURE__*/ T.applyErrorMatchers(
32
+ /*@__PURE__*/ S.TaggedError<BadRequest>()("BadRequest", {
33
+ message: S.String,
34
+ body: /*@__PURE__*/ S.optional(
35
+ /*@__PURE__*/ S.Union([/*@__PURE__*/ S.suspend(() => __S(0, __c0, 0)), S.String]),
36
+ ),
37
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
38
+ }).pipe(C.withBadRequestError),
39
+ [{ status: 400 }],
40
+ )
41
+ {
42
+ declare readonly body?: Error | string;
43
+ }
44
+
45
+ export class Forbidden
46
+ extends /*@__PURE__*/ T.applyErrorMatchers(
47
+ /*@__PURE__*/ S.TaggedError<Forbidden>()("Forbidden", {
48
+ message: S.String,
49
+ body: /*@__PURE__*/ S.optional(
50
+ /*@__PURE__*/ S.Union([/*@__PURE__*/ S.suspend(() => __S(0, __c0, 0)), S.String]),
51
+ ),
52
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
53
+ }).pipe(C.withAuthError),
54
+ [{ status: 403 }],
55
+ )
56
+ {
57
+ declare readonly body?: Error | string;
58
+ }
59
+
60
+ export class NotFound
61
+ extends /*@__PURE__*/ T.applyErrorMatchers(
62
+ /*@__PURE__*/ S.TaggedError<NotFound>()("NotFound", {
63
+ message: S.String,
64
+ body: /*@__PURE__*/ S.optional(
65
+ /*@__PURE__*/ S.Union([/*@__PURE__*/ S.suspend(() => __S(0, __c0, 0)), S.String]),
66
+ ),
67
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
68
+ }).pipe(C.withBadRequestError),
69
+ [{ status: 404 }],
70
+ )
71
+ {
72
+ declare readonly body?: Error | string;
73
+ }
74
+
75
+ /** Another tailnet in the organization already has this display name (HTTP 400, 'tailnet display names must be unique within the organization'). */
76
+ export class TailnetDisplayNameAlreadyExists
77
+ extends /*@__PURE__*/ T.applyErrorMatchers(
78
+ /*@__PURE__*/ S.TaggedError<TailnetDisplayNameAlreadyExists>()(
79
+ "TailnetDisplayNameAlreadyExists",
80
+ {
81
+ message: S.String,
82
+ body: /*@__PURE__*/ S.optional(
83
+ /*@__PURE__*/ S.Union([/*@__PURE__*/ S.suspend(() => __S(0, __c0, 0)), S.String]),
84
+ ),
85
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
86
+ },
87
+ ).pipe(C.withBadRequestError),
88
+ [{ status: 400, message: { includes: "display names must be unique" } }],
89
+ )
90
+ {
91
+ declare readonly body?: Error | string;
92
+ }
93
+
94
+ export interface CreateOrganizationTailnetRequest {
95
+ /** The organization identifier. Use a dash (`-`) to reference the organization of the access token being used to make the API call. */
96
+ organization: string;
97
+ /** A custom name for the tailnet. It can contain letters, numbers, spaces, apostrophes, and hyphens, and must be unique within the organization. */
98
+ displayName: string;
99
+ }
100
+ /** OAuth client credentials with the `all` scope for the newly created tailnet. The secret is returned only once. */
101
+ export interface TailnetOAuthClient {
102
+ /** A stable, globally unique identifier for the OAuth client. */
103
+ id?: string | undefined;
104
+ /** The OAuth client secret. */
105
+ secret?: Redacted.Redacted<string> | undefined;
106
+ }
107
+ export interface CreateOrganizationTailnetResponse {
108
+ /** A stable, globally unique identifier for the tailnet. */
109
+ id?: string | undefined;
110
+ /** The tailnet name provided in the request. */
111
+ displayName?: string | undefined;
112
+ /** A stable, globally unique identifier for the organization. */
113
+ orgId?: string | undefined;
114
+ /** The DNS suffix used to construct fully qualified domain names for devices in this tailnet. */
115
+ dnsName?: string | undefined;
116
+ /** RFC3339 timestamp of when the tailnet was created. */
117
+ createdAt?: string | undefined;
118
+ oauthClient?: TailnetOAuthClient | undefined;
119
+ /** True if the requested tailnet already exists. */
120
+ alreadyExists?: boolean | undefined;
121
+ }
122
+ export interface DeleteTailnetRequest {
123
+ /** The tailnet ID. Tailnets created before Oct 2025 can still use the legacy ID, but the Tailnet ID is the preferred identifier. When specifying a tailnet in the API, you can: - Provide a dash (`-`) to reference the default tailnet of the access token being used to make the API call. This is the best option for most users. Your API calls would start: ```sh curl "https://api.tailscale.com/api/v2/tailnet/-/..." ``` - Provide the **tailnet ID** found on the **[General Settings](https://login.tailscale.com/admin/settings/general)** page of the Tailscale admin console. For example, if your tailnet ID name is `T1234CNTRL`, your API calls would start: ```sh curl "https://api.tailscale.com/api/v2/tailnet/T1234CNTRL/..." ``` Learn more about [tailnet ID](https://tailscale.com/docs/concepts/tailnet-name#tailnet-id). */
124
+ tailnet: string;
125
+ }
126
+ export interface DeleteTailnetResponse {}
127
+ export interface ListOrganizationTailnetsRequest {
128
+ /** The organization identifier. Use a dash (`-`) to reference the organization of the access token being used to make the API call. */
129
+ organization: string;
130
+ /** Maximum number of tailnets to return per page; defaults to the maximum of 100. */
131
+ limit?: number | undefined;
132
+ /** Opaque pagination cursor from a previous response. */
133
+ cursor?: string | undefined;
134
+ }
135
+ export interface OrganizationTailnet {
136
+ /** A stable, globally unique identifier for the tailnet. */
137
+ id?: string | undefined;
138
+ /** The tailnet's display name. */
139
+ displayName?: string | undefined;
140
+ /** A stable, globally unique identifier for the organization. */
141
+ orgId?: string | undefined;
142
+ /** RFC3339 timestamp of when the tailnet was created. */
143
+ createdAt?: string | undefined;
144
+ }
145
+ /** Tailnets in the organization. */
146
+ export type ListOrganizationTailnetsResponseTailnetsList = Array<OrganizationTailnet>;
147
+ export interface ListOrganizationTailnetsResponse {
148
+ /** Tailnets in the organization. */
149
+ tailnets: ListOrganizationTailnetsResponseTailnetsList;
150
+ /** Opaque pagination cursor for the next page. */
151
+ cursor?: string | undefined;
152
+ /** Total number of tailnets in the organization. */
153
+ totalCount?: number | undefined;
154
+ }
155
+ export interface Error {
156
+ message: string;
157
+ }
158
+ export type CreateOrganizationTailnetError =
159
+ | BadRequest
160
+ | Forbidden
161
+ | NotFound
162
+ | TailnetDisplayNameAlreadyExists
163
+ | TailscaleOpError;
164
+ /** Create a tailnet Create an [API-only tailnet](https://tailscale.com/docs/features/tailnet-creation-api) in the organization. API-only tailnets have no human users and do not appear in the admin console. Use them for applications and infrastructure that manage tailnets entirely through the API. All plans can create a maximum of 10 tailnets, including their original tailnet. If your use case requires more than 10 tailnets, [contact sales](https://tailscale.com/contact/sales). The response includes an OAuth client for the new tailnet. The client secret is returned only in this response and cannot be retrieved later, so be sure to record it. OAuth Scope: `tailnets`. */
165
+ export const createOrganizationTailnet: API.OperationMethod<
166
+ CreateOrganizationTailnetRequest,
167
+ CreateOrganizationTailnetResponse,
168
+ CreateOrganizationTailnetError,
169
+ TailscaleOpContext
170
+ > = /*@__PURE__*/ API.make(() => ({
171
+ input: __S(4, __c1, 0) as any as S.Schema<CreateOrganizationTailnetRequest>,
172
+ output: __S(6, __c1, 2) as any as S.Schema<CreateOrganizationTailnetResponse>,
173
+ errors: [BadRequest, Forbidden, NotFound, TailnetDisplayNameAlreadyExists],
174
+ serviceErrors: TailscaleServiceErrors,
175
+ protocol: TailscaleProtocol,
176
+ retry: Retry.Retry,
177
+ telemetry: TELEMETRY,
178
+ span: "CreateOrganizationTailnet",
179
+ }));
180
+
181
+ export type DeleteTailnetError = BadRequest | Forbidden | NotFound | TailscaleOpError;
182
+ /** Delete a tailnet Delete the specified tailnet and all of its users, devices, and configuration. [API-only tailnets](https://tailscale.com/docs/features/tailnet-creation-api) can be deleted using an access token for the tailnet being deleted. You can get a tailnet-specific access token by exchanging either the OAuth client credentials returned when the tailnet was created or an OAuth client from the creating tailnet that has the `all` scope. OAuth Scope: `all`. */
183
+ export const deleteTailnet: API.OperationMethod<
184
+ DeleteTailnetRequest,
185
+ DeleteTailnetResponse,
186
+ DeleteTailnetError,
187
+ TailscaleOpContext
188
+ > = /*@__PURE__*/ API.make(() => ({
189
+ input: __S(8, __c2, 0) as any as S.Schema<DeleteTailnetRequest>,
190
+ output: __S(9, __c2, 1) as any as S.Schema<DeleteTailnetResponse>,
191
+ errors: [BadRequest, Forbidden, NotFound],
192
+ serviceErrors: TailscaleServiceErrors,
193
+ protocol: TailscaleProtocol,
194
+ retry: Retry.Retry,
195
+ telemetry: TELEMETRY,
196
+ span: "DeleteTailnet",
197
+ }));
198
+
199
+ export type ListOrganizationTailnetsError = BadRequest | Forbidden | NotFound | TailscaleOpError;
200
+ /** List tailnets List all tailnets in the organization, including the original tailnet and any [API-only tailnets](https://tailscale.com/docs/features/tailnet-creation-api) created with the tailnet creation API. OAuth Scope: `tailnets:read`. */
201
+ export const listOrganizationTailnets: API.PaginatedOperationMethod<
202
+ ListOrganizationTailnetsRequest,
203
+ ListOrganizationTailnetsResponse,
204
+ ListOrganizationTailnetsError,
205
+ TailscaleOpContext,
206
+ OrganizationTailnet
207
+ > = /*@__PURE__*/ API.makePaginated(
208
+ () => ({
209
+ input: __S(12, __c3, 0) as any as S.Schema<ListOrganizationTailnetsRequest>,
210
+ output: __S(15, __c3, 3) as any as S.Schema<ListOrganizationTailnetsResponse>,
211
+ errors: [BadRequest, Forbidden, NotFound],
212
+ serviceErrors: TailscaleServiceErrors,
213
+ protocol: TailscaleProtocol,
214
+ retry: Retry.Retry,
215
+ telemetry: TELEMETRY,
216
+ span: "ListOrganizationTailnets",
217
+ pagination: {
218
+ mode: "cursor",
219
+ inputToken: "cursor",
220
+ outputToken: "cursor",
221
+ items: "tailnets",
222
+ pageSize: "limit",
223
+ } as const,
224
+ }),
225
+ paginateCursor,
226
+ ) as any;
227
+
228
+ // Schema builders: each runs one schema initializer, on that schema's first use.
229
+ function __c0(j: number): any {
230
+ switch (j) {
231
+ case 0:
232
+ return S.suspend(() =>
233
+ S.Struct({
234
+ message: S.String,
235
+ }),
236
+ ).annotate({ identifier: "Error" });
237
+ }
238
+ }
239
+ function __c1(j: number): any {
240
+ switch (j) {
241
+ case 0:
242
+ return S.suspend(() =>
243
+ S.Struct({
244
+ organization: S.String.pipe(T.Label()),
245
+ displayName: S.String,
246
+ }).pipe(
247
+ T.Http({ method: "POST", uri: "/organizations/{organization}/tailnets", code: 200 }),
248
+ ),
249
+ ).annotate({ identifier: "CreateOrganizationTailnetRequest" });
250
+ case 1:
251
+ return S.suspend(() =>
252
+ S.Struct({
253
+ id: S.optional(S.String),
254
+ secret: S.optional(S.String.pipe(T.SensitiveValue({}))),
255
+ }),
256
+ ).annotate({ identifier: "TailnetOAuthClient" });
257
+ case 2:
258
+ return S.suspend(() =>
259
+ S.Struct({
260
+ id: S.optional(S.String),
261
+ displayName: S.optional(S.String),
262
+ orgId: S.optional(S.String),
263
+ dnsName: S.optional(S.String),
264
+ createdAt: S.optional(S.String),
265
+ oauthClient: S.optional(__S(5, __c1, 1)),
266
+ alreadyExists: S.optional(S.Boolean),
267
+ }),
268
+ ).annotate({ identifier: "CreateOrganizationTailnetResponse" });
269
+ }
270
+ }
271
+ function __c2(j: number): any {
272
+ switch (j) {
273
+ case 0:
274
+ return S.suspend(() =>
275
+ S.Struct({
276
+ tailnet: S.String.pipe(T.Label()),
277
+ }).pipe(T.Http({ method: "DELETE", uri: "/tailnet/{tailnet}", code: 200 })),
278
+ ).annotate({ identifier: "DeleteTailnetRequest" });
279
+ case 1:
280
+ return S.suspend(() => S.Struct({})).annotate({ identifier: "DeleteTailnetResponse" });
281
+ }
282
+ }
283
+ function __c3(j: number): any {
284
+ switch (j) {
285
+ case 0:
286
+ return S.suspend(() =>
287
+ S.Struct({
288
+ organization: S.String.pipe(T.Label()),
289
+ limit: S.optional(S.Number.pipe(T.Query())),
290
+ cursor: S.optional(S.String.pipe(T.Query())),
291
+ }).pipe(
292
+ T.Http({ method: "GET", uri: "/organizations/{organization}/tailnets", code: 200 }),
293
+ ),
294
+ ).annotate({ identifier: "ListOrganizationTailnetsRequest" });
295
+ case 1:
296
+ return S.suspend(() =>
297
+ S.Struct({
298
+ id: S.optional(S.String),
299
+ displayName: S.optional(S.String),
300
+ orgId: S.optional(S.String),
301
+ createdAt: S.optional(S.String),
302
+ }),
303
+ ).annotate({ identifier: "OrganizationTailnet" });
304
+ case 2:
305
+ return S.Array(__S(13, __c3, 1));
306
+ case 3:
307
+ return S.suspend(() =>
308
+ S.Struct({
309
+ tailnets: __S(14, __c3, 2),
310
+ cursor: S.optional(S.String),
311
+ totalCount: S.optional(S.Number),
312
+ }),
313
+ ).annotate({ identifier: "ListOrganizationTailnetsResponse" });
314
+ }
315
+ }
316
+ // Schema table: entry i is schema j of builder f, made on first reach.
317
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
318
+ return (__s[i] ??= __L.at(f, j));
319
+ }