@org-quicko/silo-client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/README.md +313 -0
  2. package/dist/collections/collection-definition.d.cts +10 -0
  3. package/dist/collections/collection-definition.d.ts +10 -0
  4. package/dist/collections/collection-handle.d.cts +54 -0
  5. package/dist/collections/collection-handle.d.ts +54 -0
  6. package/dist/collections/collection-schema.d.cts +16 -0
  7. package/dist/collections/collection-schema.d.ts +16 -0
  8. package/dist/collections/collection-summary.d.cts +10 -0
  9. package/dist/collections/collection-summary.d.ts +10 -0
  10. package/dist/collections/collections.d.cts +19 -0
  11. package/dist/collections/collections.d.ts +19 -0
  12. package/dist/collections/json-schema.d.cts +9 -0
  13. package/dist/collections/json-schema.d.ts +9 -0
  14. package/dist/collections/reserved-field-names.d.cts +9 -0
  15. package/dist/collections/reserved-field-names.d.ts +9 -0
  16. package/dist/entries/entry-base.d.cts +31 -0
  17. package/dist/entries/entry-base.d.ts +31 -0
  18. package/dist/entries/entry-list-query.d.cts +11 -0
  19. package/dist/entries/entry-list-query.d.ts +11 -0
  20. package/dist/entries/entry-mapper.d.cts +13 -0
  21. package/dist/entries/entry-mapper.d.ts +13 -0
  22. package/dist/entries/entry-page-stream.d.cts +14 -0
  23. package/dist/entries/entry-page-stream.d.ts +14 -0
  24. package/dist/entries/entry-page.d.cts +16 -0
  25. package/dist/entries/entry-page.d.ts +16 -0
  26. package/dist/entries/entry-payload.d.cts +12 -0
  27. package/dist/entries/entry-payload.d.ts +12 -0
  28. package/dist/entries/entry-reader.d.cts +26 -0
  29. package/dist/entries/entry-reader.d.ts +26 -0
  30. package/dist/entries/entry-stream.d.cts +5 -0
  31. package/dist/entries/entry-stream.d.ts +5 -0
  32. package/dist/entries/entry.d.cts +25 -0
  33. package/dist/entries/entry.d.ts +25 -0
  34. package/dist/entries/resolved-entry.d.cts +11 -0
  35. package/dist/entries/resolved-entry.d.ts +11 -0
  36. package/dist/errors/conflict-error.d.cts +6 -0
  37. package/dist/errors/conflict-error.d.ts +6 -0
  38. package/dist/errors/error-code.d.cts +4 -0
  39. package/dist/errors/error-code.d.ts +4 -0
  40. package/dist/errors/error-factory.d.cts +15 -0
  41. package/dist/errors/error-factory.d.ts +15 -0
  42. package/dist/errors/error-payload.d.cts +13 -0
  43. package/dist/errors/error-payload.d.ts +13 -0
  44. package/dist/errors/forbidden-error.d.cts +5 -0
  45. package/dist/errors/forbidden-error.d.ts +5 -0
  46. package/dist/errors/internal-error.d.cts +6 -0
  47. package/dist/errors/internal-error.d.ts +6 -0
  48. package/dist/errors/invalid-response-error.d.cts +11 -0
  49. package/dist/errors/invalid-response-error.d.ts +11 -0
  50. package/dist/errors/media-delete-stalled-error.d.cts +14 -0
  51. package/dist/errors/media-delete-stalled-error.d.ts +14 -0
  52. package/dist/errors/media-in-use-error.d.cts +21 -0
  53. package/dist/errors/media-in-use-error.d.ts +21 -0
  54. package/dist/errors/network-error.d.cts +11 -0
  55. package/dist/errors/network-error.d.ts +11 -0
  56. package/dist/errors/not-found-error.d.cts +6 -0
  57. package/dist/errors/not-found-error.d.ts +6 -0
  58. package/dist/errors/request-aborted-error.d.cts +10 -0
  59. package/dist/errors/request-aborted-error.d.ts +10 -0
  60. package/dist/errors/silo-error.d.cts +12 -0
  61. package/dist/errors/silo-error.d.ts +12 -0
  62. package/dist/errors/timeout-error.d.cts +11 -0
  63. package/dist/errors/timeout-error.d.ts +11 -0
  64. package/dist/errors/unauthorized-error.d.cts +5 -0
  65. package/dist/errors/unauthorized-error.d.ts +5 -0
  66. package/dist/errors/validation-detail.d.cts +8 -0
  67. package/dist/errors/validation-detail.d.ts +8 -0
  68. package/dist/errors/validation-failed-error.d.cts +11 -0
  69. package/dist/errors/validation-failed-error.d.ts +11 -0
  70. package/dist/index.cjs +2095 -0
  71. package/dist/index.d.cts +96 -0
  72. package/dist/index.d.ts +96 -0
  73. package/dist/index.js +2053 -0
  74. package/dist/instance/health-report.d.cts +5 -0
  75. package/dist/instance/health-report.d.ts +5 -0
  76. package/dist/media/media-asset-mapper.d.cts +31 -0
  77. package/dist/media/media-asset-mapper.d.ts +31 -0
  78. package/dist/media/media-asset-payload.d.cts +20 -0
  79. package/dist/media/media-asset-payload.d.ts +20 -0
  80. package/dist/media/media-asset.d.cts +63 -0
  81. package/dist/media/media-asset.d.ts +63 -0
  82. package/dist/media/media-delete-failure.d.cts +16 -0
  83. package/dist/media/media-delete-failure.d.ts +16 -0
  84. package/dist/media/media-delete-options.d.cts +9 -0
  85. package/dist/media/media-delete-options.d.ts +9 -0
  86. package/dist/media/media-delete-report.d.cts +13 -0
  87. package/dist/media/media-delete-report.d.ts +13 -0
  88. package/dist/media/media-folder-delete.d.cts +10 -0
  89. package/dist/media/media-folder-delete.d.ts +10 -0
  90. package/dist/media/media-folder-move.d.cts +9 -0
  91. package/dist/media/media-folder-move.d.ts +9 -0
  92. package/dist/media/media-folders.d.cts +22 -0
  93. package/dist/media/media-folders.d.ts +22 -0
  94. package/dist/media/media-page-stream.d.cts +10 -0
  95. package/dist/media/media-page-stream.d.ts +10 -0
  96. package/dist/media/media-page.d.cts +19 -0
  97. package/dist/media/media-page.d.ts +19 -0
  98. package/dist/media/media-query.d.cts +24 -0
  99. package/dist/media/media-query.d.ts +24 -0
  100. package/dist/media/media-reference.d.cts +18 -0
  101. package/dist/media/media-reference.d.ts +18 -0
  102. package/dist/media/media-stream.d.cts +7 -0
  103. package/dist/media/media-stream.d.ts +7 -0
  104. package/dist/media/media-upload.d.cts +18 -0
  105. package/dist/media/media-upload.d.ts +18 -0
  106. package/dist/media/media-usage-page.d.cts +35 -0
  107. package/dist/media/media-usage-page.d.ts +35 -0
  108. package/dist/media/media-usage.d.cts +13 -0
  109. package/dist/media/media-usage.d.ts +13 -0
  110. package/dist/media/media.d.cts +37 -0
  111. package/dist/media/media.d.ts +37 -0
  112. package/dist/pagination/page-window.d.cts +14 -0
  113. package/dist/pagination/page-window.d.ts +14 -0
  114. package/dist/pagination/page.d.cts +27 -0
  115. package/dist/pagination/page.d.ts +27 -0
  116. package/dist/pagination/row-stream.d.cts +28 -0
  117. package/dist/pagination/row-stream.d.ts +28 -0
  118. package/dist/query/field-path.d.cts +14 -0
  119. package/dist/query/field-path.d.ts +14 -0
  120. package/dist/query/filter-expression.d.cts +15 -0
  121. package/dist/query/filter-expression.d.ts +15 -0
  122. package/dist/query/filter-field.d.cts +19 -0
  123. package/dist/query/filter-field.d.ts +19 -0
  124. package/dist/query/filter-node.d.cts +9 -0
  125. package/dist/query/filter-node.d.ts +9 -0
  126. package/dist/query/filter-operator.d.cts +7 -0
  127. package/dist/query/filter-operator.d.ts +7 -0
  128. package/dist/query/filter.d.cts +18 -0
  129. package/dist/query/filter.d.ts +18 -0
  130. package/dist/query/sort-term.d.cts +13 -0
  131. package/dist/query/sort-term.d.ts +13 -0
  132. package/dist/query/sort.d.cts +15 -0
  133. package/dist/query/sort.d.ts +15 -0
  134. package/dist/query/typed-filter.d.cts +32 -0
  135. package/dist/query/typed-filter.d.ts +32 -0
  136. package/dist/request-options.d.cts +9 -0
  137. package/dist/request-options.d.ts +9 -0
  138. package/dist/scope/delete-options.d.cts +9 -0
  139. package/dist/scope/delete-options.d.ts +9 -0
  140. package/dist/scope/environment-handle.d.cts +29 -0
  141. package/dist/scope/environment-handle.d.ts +29 -0
  142. package/dist/scope/environment.d.cts +8 -0
  143. package/dist/scope/environment.d.ts +8 -0
  144. package/dist/scope/environments.d.cts +11 -0
  145. package/dist/scope/environments.d.ts +11 -0
  146. package/dist/scope/project-handle.d.cts +22 -0
  147. package/dist/scope/project-handle.d.ts +22 -0
  148. package/dist/scope/project.d.cts +8 -0
  149. package/dist/scope/project.d.ts +8 -0
  150. package/dist/scope/projects.d.cts +10 -0
  151. package/dist/scope/projects.d.ts +10 -0
  152. package/dist/scope/rename-options.d.cts +10 -0
  153. package/dist/scope/rename-options.d.ts +10 -0
  154. package/dist/scope/rename-report.d.cts +21 -0
  155. package/dist/scope/rename-report.d.ts +21 -0
  156. package/dist/scope/scope-reference.d.cts +12 -0
  157. package/dist/scope/scope-reference.d.ts +12 -0
  158. package/dist/search/search-engine.d.cts +3 -0
  159. package/dist/search/search-engine.d.ts +3 -0
  160. package/dist/search/search-hit.d.cts +18 -0
  161. package/dist/search/search-hit.d.ts +18 -0
  162. package/dist/search/search-page.d.cts +19 -0
  163. package/dist/search/search-page.d.ts +19 -0
  164. package/dist/search/search-query.d.cts +11 -0
  165. package/dist/search/search-query.d.ts +11 -0
  166. package/dist/search/search-reach.d.cts +12 -0
  167. package/dist/search/search-reach.d.ts +12 -0
  168. package/dist/search/search-snippet.d.cts +8 -0
  169. package/dist/search/search-snippet.d.ts +8 -0
  170. package/dist/search/search.d.cts +18 -0
  171. package/dist/search/search.d.ts +18 -0
  172. package/dist/silo-options.d.cts +12 -0
  173. package/dist/silo-options.d.ts +12 -0
  174. package/dist/silo.d.cts +42 -0
  175. package/dist/silo.d.ts +42 -0
  176. package/dist/transport/abort-signals.d.cts +23 -0
  177. package/dist/transport/abort-signals.d.ts +23 -0
  178. package/dist/transport/api-path.d.cts +36 -0
  179. package/dist/transport/api-path.d.ts +36 -0
  180. package/dist/transport/fetch-function.d.cts +11 -0
  181. package/dist/transport/fetch-function.d.ts +11 -0
  182. package/dist/transport/page-payload.d.cts +15 -0
  183. package/dist/transport/page-payload.d.ts +15 -0
  184. package/dist/transport/query-string.d.cts +10 -0
  185. package/dist/transport/query-string.d.ts +10 -0
  186. package/dist/transport/response-decoder.d.cts +14 -0
  187. package/dist/transport/response-decoder.d.ts +14 -0
  188. package/dist/transport/route-inventory.d.cts +22 -0
  189. package/dist/transport/route-inventory.d.ts +22 -0
  190. package/dist/transport/transport-request.d.cts +18 -0
  191. package/dist/transport/transport-request.d.ts +18 -0
  192. package/dist/transport/transport.d.cts +45 -0
  193. package/dist/transport/transport.d.ts +45 -0
  194. package/dist/variables/environment-variables.d.cts +14 -0
  195. package/dist/variables/environment-variables.d.ts +14 -0
  196. package/dist/variables/project-variables.d.cts +38 -0
  197. package/dist/variables/project-variables.d.ts +38 -0
  198. package/dist/variables/variable-declaration.d.cts +10 -0
  199. package/dist/variables/variable-declaration.d.ts +10 -0
  200. package/dist/variables/variable.d.cts +17 -0
  201. package/dist/variables/variable.d.ts +17 -0
  202. package/package.json +58 -0
package/dist/silo.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ import type { HealthReport } from "./instance/health-report.js";
2
+ import { Media } from "./media/media.js";
3
+ import type { RequestOptions } from "./request-options.js";
4
+ import { ProjectHandle } from "./scope/project-handle.js";
5
+ import { Projects } from "./scope/projects.js";
6
+ import type { EnvironmentHandle } from "./scope/environment-handle.js";
7
+ import type { SearchPage } from "./search/search-page.js";
8
+ import type { SearchQuery } from "./search/search-query.js";
9
+ import type { SiloOptions } from "./silo-options.js";
10
+ /**
11
+ * One silo instance. Navigate it the way the API is shaped:
12
+ * `silo.project("acme").environment("prod").collection<Post>("posts")`.
13
+ *
14
+ * Handles are value objects and make no request, so nothing in a chain needs
15
+ * an `await` until the call at the end. There is deliberately no default
16
+ * project or environment: both names are always given.
17
+ */
18
+ export declare class Silo {
19
+ /** The projects this key can see, and creating one. */
20
+ readonly projects: Projects;
21
+ /** The media catalog. Media is instance-global, so it takes no scope. */
22
+ readonly media: Media;
23
+ private readonly options;
24
+ private readonly transport;
25
+ constructor(options: SiloOptions);
26
+ /** One project, by the name every path addresses it with. */
27
+ project(name: string): ProjectHandle;
28
+ /** `silo.project(p).environment(e)` in one call. Still takes both names. */
29
+ scope(project: string, environment: string): EnvironmentHandle;
30
+ /**
31
+ * Search everything this key can read. The narrower reaches are
32
+ * `environment.search()` and `collection.search()`, so a reach is always
33
+ * the receiver and never an argument that could be forgotten.
34
+ */
35
+ search(query: SearchQuery, options?: RequestOptions): Promise<SearchPage>;
36
+ /** Liveness and version. The one route that is never authenticated. */
37
+ health(options?: RequestOptions): Promise<HealthReport>;
38
+ /** The same instance read with a different key. */
39
+ withKey(key: string | undefined): Silo;
40
+ /** The same options pointed at a different server. */
41
+ withUrl(url: string): Silo;
42
+ }
@@ -0,0 +1,23 @@
1
+ /** Which source aborted the composed signal, so the caller can raise
2
+ * `TimeoutError` or `RequestAbortedError` instead of one undifferentiated
3
+ * abort. */
4
+ export type AbortReason = "caller" | "timeout";
5
+ /**
6
+ * Composes a caller's `AbortSignal` with a timeout deadline into one signal,
7
+ * and remembers which of the two fired first.
8
+ *
9
+ * Built by hand with an `AbortController` and listeners rather than
10
+ * `AbortSignal.any`, which Node 18 does not have. Call {@link dispose} once
11
+ * the request settles, whichever way, so the timer clears and neither
12
+ * listener outlives the request.
13
+ */
14
+ export declare class AbortSignals {
15
+ readonly signal: AbortSignal;
16
+ private reason;
17
+ private readonly cleanups;
18
+ constructor(callerSignal: AbortSignal | undefined, timeoutMilliseconds: number | undefined);
19
+ /** Which source fired, or `undefined` if the signal never aborted. */
20
+ firedBy(): AbortReason | undefined;
21
+ /** Removes the listeners and clears the timer. Idempotent. */
22
+ dispose(): void;
23
+ }
@@ -0,0 +1,23 @@
1
+ /** Which source aborted the composed signal, so the caller can raise
2
+ * `TimeoutError` or `RequestAbortedError` instead of one undifferentiated
3
+ * abort. */
4
+ export type AbortReason = "caller" | "timeout";
5
+ /**
6
+ * Composes a caller's `AbortSignal` with a timeout deadline into one signal,
7
+ * and remembers which of the two fired first.
8
+ *
9
+ * Built by hand with an `AbortController` and listeners rather than
10
+ * `AbortSignal.any`, which Node 18 does not have. Call {@link dispose} once
11
+ * the request settles, whichever way, so the timer clears and neither
12
+ * listener outlives the request.
13
+ */
14
+ export declare class AbortSignals {
15
+ readonly signal: AbortSignal;
16
+ private reason;
17
+ private readonly cleanups;
18
+ constructor(callerSignal: AbortSignal | undefined, timeoutMilliseconds: number | undefined);
19
+ /** Which source fired, or `undefined` if the signal never aborted. */
20
+ firedBy(): AbortReason | undefined;
21
+ /** Removes the listeners and clears the timer. Idempotent. */
22
+ dispose(): void;
23
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Every path in the client, built in one place. Every dynamic segment goes
3
+ * through `encodeURIComponent`, so a name containing a slash or a space
4
+ * addresses one resource rather than being split across the path.
5
+ *
6
+ * Uses `/envs/`, not `/environments/` — the guide says both are accepted
7
+ *, and one spelling is enough to build with.
8
+ */
9
+ export declare class ApiPath {
10
+ static health(): string;
11
+ static projects(): string;
12
+ static project(project: string): string;
13
+ static environments(project: string): string;
14
+ static environment(project: string, env: string): string;
15
+ static projectVariables(project: string): string;
16
+ static projectVariable(project: string, name: string): string;
17
+ static environmentVariables(project: string, env: string): string;
18
+ static environmentVariable(project: string, env: string, name: string): string;
19
+ static collections(project: string, env: string): string;
20
+ static collection(project: string, env: string, name: string): string;
21
+ static schemas(project: string, env: string): string;
22
+ static collectionSchema(project: string, env: string, name: string): string;
23
+ /** List/create entries: the same address as `collection`, one level down
24
+ * in what it means — the collection's own record versus its rows. */
25
+ static entries(project: string, env: string, name: string): string;
26
+ static entry(project: string, env: string, name: string, id: string): string;
27
+ static collectionSearch(project: string, env: string, name: string): string;
28
+ static environmentSearch(project: string, env: string): string;
29
+ static instanceSearch(): string;
30
+ static media(): string;
31
+ static mediaExtensions(): string;
32
+ static mediaAsset(id: string): string;
33
+ static mediaAssetUsages(id: string): string;
34
+ static mediaBulkDelete(): string;
35
+ static mediaFolders(): string;
36
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Every path in the client, built in one place. Every dynamic segment goes
3
+ * through `encodeURIComponent`, so a name containing a slash or a space
4
+ * addresses one resource rather than being split across the path.
5
+ *
6
+ * Uses `/envs/`, not `/environments/` — the guide says both are accepted
7
+ *, and one spelling is enough to build with.
8
+ */
9
+ export declare class ApiPath {
10
+ static health(): string;
11
+ static projects(): string;
12
+ static project(project: string): string;
13
+ static environments(project: string): string;
14
+ static environment(project: string, env: string): string;
15
+ static projectVariables(project: string): string;
16
+ static projectVariable(project: string, name: string): string;
17
+ static environmentVariables(project: string, env: string): string;
18
+ static environmentVariable(project: string, env: string, name: string): string;
19
+ static collections(project: string, env: string): string;
20
+ static collection(project: string, env: string, name: string): string;
21
+ static schemas(project: string, env: string): string;
22
+ static collectionSchema(project: string, env: string, name: string): string;
23
+ /** List/create entries: the same address as `collection`, one level down
24
+ * in what it means — the collection's own record versus its rows. */
25
+ static entries(project: string, env: string, name: string): string;
26
+ static entry(project: string, env: string, name: string, id: string): string;
27
+ static collectionSearch(project: string, env: string, name: string): string;
28
+ static environmentSearch(project: string, env: string): string;
29
+ static instanceSearch(): string;
30
+ static media(): string;
31
+ static mediaExtensions(): string;
32
+ static mediaAsset(id: string): string;
33
+ static mediaAssetUsages(id: string): string;
34
+ static mediaBulkDelete(): string;
35
+ static mediaFolders(): string;
36
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The shape `Transport` calls to make a request: fetch's call signature, so
3
+ * any drop-in replacement (a test double, a patched runtime fetch) can
4
+ * stand in for it via `SiloOptions.fetch`.
5
+ *
6
+ * A plain function type rather than `typeof fetch`, deliberately: the
7
+ * ambient global `fetch` can carry extra static properties in some runtimes
8
+ * (Bun's `fetch.preconnect`, for one), and this type should demand only the
9
+ * call signature a replacement actually needs.
10
+ */
11
+ export type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The shape `Transport` calls to make a request: fetch's call signature, so
3
+ * any drop-in replacement (a test double, a patched runtime fetch) can
4
+ * stand in for it via `SiloOptions.fetch`.
5
+ *
6
+ * A plain function type rather than `typeof fetch`, deliberately: the
7
+ * ambient global `fetch` can carry extra static properties in some runtimes
8
+ * (Bun's `fetch.preconnect`, for one), and this type should demand only the
9
+ * call signature a replacement actually needs.
10
+ */
11
+ export type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
@@ -0,0 +1,15 @@
1
+ /** What {@link PagePayload.read} extracts from a list response body. */
2
+ export interface PagePayloadRows<Row> {
3
+ rows: Row[];
4
+ total: number;
5
+ limit?: number;
6
+ offset?: number;
7
+ }
8
+ /**
9
+ * Reads a list response body. The wire uses `data` for entries and search
10
+ * and `items` for media, collections and projects — this is the only
11
+ * place in the client that knows both names.
12
+ */
13
+ export declare class PagePayload {
14
+ static read<Row>(body: Record<string, unknown>): PagePayloadRows<Row>;
15
+ }
@@ -0,0 +1,15 @@
1
+ /** What {@link PagePayload.read} extracts from a list response body. */
2
+ export interface PagePayloadRows<Row> {
3
+ rows: Row[];
4
+ total: number;
5
+ limit?: number;
6
+ offset?: number;
7
+ }
8
+ /**
9
+ * Reads a list response body. The wire uses `data` for entries and search
10
+ * and `items` for media, collections and projects — this is the only
11
+ * place in the client that knows both names.
12
+ */
13
+ export declare class PagePayload {
14
+ static read<Row>(body: Record<string, unknown>): PagePayloadRows<Row>;
15
+ }
@@ -0,0 +1,10 @@
1
+ import type { TransportQueryValue } from "./transport-request.cjs";
2
+ /**
3
+ * Builds the `?a=1&b=2` suffix for a request. Omits `undefined` and `null`
4
+ * values, JSON-encodes an object value (the `filter` AST) before
5
+ * URL-encoding it, and returns `""` when nothing is set — so a call site can
6
+ * concatenate the result onto a path unconditionally.
7
+ */
8
+ export declare class QueryString {
9
+ static build(query: Record<string, TransportQueryValue> | undefined): string;
10
+ }
@@ -0,0 +1,10 @@
1
+ import type { TransportQueryValue } from "./transport-request.js";
2
+ /**
3
+ * Builds the `?a=1&b=2` suffix for a request. Omits `undefined` and `null`
4
+ * values, JSON-encodes an object value (the `filter` AST) before
5
+ * URL-encoding it, and returns `""` when nothing is set — so a call site can
6
+ * concatenate the result onto a path unconditionally.
7
+ */
8
+ export declare class QueryString {
9
+ static build(query: Record<string, TransportQueryValue> | undefined): string;
10
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Decodes a successful response by its content type: `204` to `undefined`,
3
+ * `application/json` to parsed JSON, everything else to text.
4
+ *
5
+ * `expectJson` is true for a route documented to answer JSON — a body of any
6
+ * other content type there raises `InvalidResponseError` rather than being
7
+ * handed back as text nobody asked for.
8
+ */
9
+ export declare class ResponseDecoder {
10
+ static decode(response: Response, request: {
11
+ method: string;
12
+ path: string;
13
+ }, expectJson: boolean): Promise<unknown>;
14
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Decodes a successful response by its content type: `204` to `undefined`,
3
+ * `application/json` to parsed JSON, everything else to text.
4
+ *
5
+ * `expectJson` is true for a route documented to answer JSON — a body of any
6
+ * other content type there raises `InvalidResponseError` rather than being
7
+ * handed back as text nobody asked for.
8
+ */
9
+ export declare class ResponseDecoder {
10
+ static decode(response: Response, request: {
11
+ method: string;
12
+ path: string;
13
+ }, expectJson: boolean): Promise<unknown>;
14
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Every route this client reaches, and every route it deliberately does not.
3
+ *
4
+ * The point is that the two lists together must account for the whole API: a
5
+ * route in neither is a gap, and `test/contract/route-inventory.test.ts`
6
+ * checks them against the server's own registrations rather than against
7
+ * `docs/guide/http-api.md`, which can be, and has been, incomplete.
8
+ *
9
+ * Paths use the server's own `:param` spelling and the `/envs/` spelling of
10
+ * the two it accepts.
11
+ */
12
+ export declare class RouteInventory {
13
+ /** Reached by a typed method on the client. */
14
+ static readonly Covered: readonly string[];
15
+ /**
16
+ * Out of scope on purpose, each with the reason. Operator surfaces belong
17
+ * to the admin UI and the CLI; none of them is content.
18
+ */
19
+ static readonly OutOfScope: Readonly<Record<string, string>>;
20
+ /** Whether the inventory accounts for a route at all. */
21
+ static accountsFor(route: string): boolean;
22
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Every route this client reaches, and every route it deliberately does not.
3
+ *
4
+ * The point is that the two lists together must account for the whole API: a
5
+ * route in neither is a gap, and `test/contract/route-inventory.test.ts`
6
+ * checks them against the server's own registrations rather than against
7
+ * `docs/guide/http-api.md`, which can be, and has been, incomplete.
8
+ *
9
+ * Paths use the server's own `:param` spelling and the `/envs/` spelling of
10
+ * the two it accepts.
11
+ */
12
+ export declare class RouteInventory {
13
+ /** Reached by a typed method on the client. */
14
+ static readonly Covered: readonly string[];
15
+ /**
16
+ * Out of scope on purpose, each with the reason. Operator surfaces belong
17
+ * to the admin UI and the CLI; none of them is content.
18
+ */
19
+ static readonly OutOfScope: Readonly<Record<string, string>>;
20
+ /** Whether the inventory accounts for a route at all. */
21
+ static accountsFor(route: string): boolean;
22
+ }
@@ -0,0 +1,18 @@
1
+ /** One query parameter's value. An object (the `filter` AST) is JSON-encoded
2
+ * by {@link QueryString}; everything else is stringified. */
3
+ export type TransportQueryValue = string | number | boolean | object | undefined;
4
+ /**
5
+ * One request through {@link Transport}: an HTTP method and a path already
6
+ * built by {@link ApiPath}, with everything else optional. `signal` and
7
+ * `timeoutMilliseconds` here are the per-call values from {@link RequestOptions};
8
+ * the client's own defaults apply when they are absent.
9
+ */
10
+ export interface TransportRequest {
11
+ method: string;
12
+ path: string;
13
+ query?: Record<string, TransportQueryValue>;
14
+ body?: unknown;
15
+ headers?: Record<string, string>;
16
+ signal?: AbortSignal;
17
+ timeoutMilliseconds?: number;
18
+ }
@@ -0,0 +1,18 @@
1
+ /** One query parameter's value. An object (the `filter` AST) is JSON-encoded
2
+ * by {@link QueryString}; everything else is stringified. */
3
+ export type TransportQueryValue = string | number | boolean | object | undefined;
4
+ /**
5
+ * One request through {@link Transport}: an HTTP method and a path already
6
+ * built by {@link ApiPath}, with everything else optional. `signal` and
7
+ * `timeoutMilliseconds` here are the per-call values from {@link RequestOptions};
8
+ * the client's own defaults apply when they are absent.
9
+ */
10
+ export interface TransportRequest {
11
+ method: string;
12
+ path: string;
13
+ query?: Record<string, TransportQueryValue>;
14
+ body?: unknown;
15
+ headers?: Record<string, string>;
16
+ signal?: AbortSignal;
17
+ timeoutMilliseconds?: number;
18
+ }
@@ -0,0 +1,45 @@
1
+ import type { FetchFunction } from "./fetch-function.cjs";
2
+ import type { TransportRequest } from "./transport-request.cjs";
3
+ /** What `Transport` needs to construct — its own options shape. */
4
+ export interface TransportOptions {
5
+ url: string;
6
+ key?: string;
7
+ headers?: Record<string, string>;
8
+ timeoutMilliseconds?: number;
9
+ fetch?: FetchFunction;
10
+ }
11
+ /**
12
+ * The one place a request is made. Sends `Authorization: Bearer <key>`
13
+ * when a key is set and nothing when it is not, since anonymous reads are
14
+ * legal. A `fetch` rejection becomes `NetworkError`; an abort from the
15
+ * caller's own signal becomes `RequestAbortedError`; an abort from the
16
+ * deadline becomes `TimeoutError` — `AbortSignals` is what tells the three
17
+ * apart.
18
+ */
19
+ export declare class Transport {
20
+ private readonly url;
21
+ private readonly key;
22
+ private readonly headers;
23
+ private readonly timeoutMilliseconds;
24
+ private readonly fetchFunction;
25
+ constructor(options: TransportOptions);
26
+ json<T>(request: TransportRequest): Promise<T>;
27
+ /** For a `204` response: decodes it, and discards the result. */
28
+ empty(request: TransportRequest): Promise<void>;
29
+ stream(request: TransportRequest): Promise<ReadableStream<Uint8Array> | null>;
30
+ /** Multipart upload. Never sets `Content-Type` by hand — the runtime sets
31
+ * it, boundary included, from the `FormData` body. */
32
+ upload<T>(request: TransportRequest, form: FormData): Promise<T>;
33
+ /** A new `Transport` reading a different key, sharing everything else. */
34
+ withKey(key: string | undefined): Transport;
35
+ /** A new `Transport` reading a different base URL, sharing everything
36
+ * else. */
37
+ withUrl(url: string): Transport;
38
+ private snapshot;
39
+ private execute;
40
+ /** Distinguishes why `fetch` itself failed: the deadline, the caller's own
41
+ * signal, or the request never landing at all. */
42
+ private transportFailure;
43
+ private buildHeaders;
44
+ private static normalizeUrl;
45
+ }
@@ -0,0 +1,45 @@
1
+ import type { FetchFunction } from "./fetch-function.js";
2
+ import type { TransportRequest } from "./transport-request.js";
3
+ /** What `Transport` needs to construct — its own options shape. */
4
+ export interface TransportOptions {
5
+ url: string;
6
+ key?: string;
7
+ headers?: Record<string, string>;
8
+ timeoutMilliseconds?: number;
9
+ fetch?: FetchFunction;
10
+ }
11
+ /**
12
+ * The one place a request is made. Sends `Authorization: Bearer <key>`
13
+ * when a key is set and nothing when it is not, since anonymous reads are
14
+ * legal. A `fetch` rejection becomes `NetworkError`; an abort from the
15
+ * caller's own signal becomes `RequestAbortedError`; an abort from the
16
+ * deadline becomes `TimeoutError` — `AbortSignals` is what tells the three
17
+ * apart.
18
+ */
19
+ export declare class Transport {
20
+ private readonly url;
21
+ private readonly key;
22
+ private readonly headers;
23
+ private readonly timeoutMilliseconds;
24
+ private readonly fetchFunction;
25
+ constructor(options: TransportOptions);
26
+ json<T>(request: TransportRequest): Promise<T>;
27
+ /** For a `204` response: decodes it, and discards the result. */
28
+ empty(request: TransportRequest): Promise<void>;
29
+ stream(request: TransportRequest): Promise<ReadableStream<Uint8Array> | null>;
30
+ /** Multipart upload. Never sets `Content-Type` by hand — the runtime sets
31
+ * it, boundary included, from the `FormData` body. */
32
+ upload<T>(request: TransportRequest, form: FormData): Promise<T>;
33
+ /** A new `Transport` reading a different key, sharing everything else. */
34
+ withKey(key: string | undefined): Transport;
35
+ /** A new `Transport` reading a different base URL, sharing everything
36
+ * else. */
37
+ withUrl(url: string): Transport;
38
+ private snapshot;
39
+ private execute;
40
+ /** Distinguishes why `fetch` itself failed: the deadline, the caller's own
41
+ * signal, or the request never landing at all. */
42
+ private transportFailure;
43
+ private buildHeaders;
44
+ private static normalizeUrl;
45
+ }
@@ -0,0 +1,14 @@
1
+ import type { RequestOptions } from "../request-options.cjs";
2
+ import type { ScopeReference } from "../scope/scope-reference.cjs";
3
+ import { Variable } from "./variable.cjs";
4
+ /** This environment's values: `list`, `set`, `unset`. Declaring, renaming
5
+ * and undeclaring a name are project-wide and live on `ProjectVariables`. */
6
+ export declare class EnvironmentVariables {
7
+ private readonly scope;
8
+ constructor(scope: ScopeReference);
9
+ list(options?: RequestOptions): Promise<Variable[]>;
10
+ set(name: string, value: string, options?: RequestOptions): Promise<Variable>;
11
+ /** Clears this environment's value, leaving the name declared — the server
12
+ * answers the updated declaration rather than `204`. */
13
+ unset(name: string, options?: RequestOptions): Promise<Variable>;
14
+ }
@@ -0,0 +1,14 @@
1
+ import type { RequestOptions } from "../request-options.js";
2
+ import type { ScopeReference } from "../scope/scope-reference.js";
3
+ import { Variable } from "./variable.js";
4
+ /** This environment's values: `list`, `set`, `unset`. Declaring, renaming
5
+ * and undeclaring a name are project-wide and live on `ProjectVariables`. */
6
+ export declare class EnvironmentVariables {
7
+ private readonly scope;
8
+ constructor(scope: ScopeReference);
9
+ list(options?: RequestOptions): Promise<Variable[]>;
10
+ set(name: string, value: string, options?: RequestOptions): Promise<Variable>;
11
+ /** Clears this environment's value, leaving the name declared — the server
12
+ * answers the updated declaration rather than `204`. */
13
+ unset(name: string, options?: RequestOptions): Promise<Variable>;
14
+ }
@@ -0,0 +1,38 @@
1
+ import type { RequestOptions } from "../request-options.cjs";
2
+ import type { Transport } from "../transport/transport.cjs";
3
+ import { Variable } from "./variable.cjs";
4
+ /** `declare()`'s options: `environment` is where the initial `value` lands,
5
+ * when one is given at all. */
6
+ export interface DeclareVariableOptions extends RequestOptions {
7
+ description?: string;
8
+ environment?: string;
9
+ value?: string;
10
+ }
11
+ /**
12
+ * `rename()`/`describe()`/`undeclare()`'s options. `environment` is not
13
+ * load-bearing for what these three do — declaring, renaming and
14
+ * undeclaring reach every environment in the project regardless of which one
15
+ * is named (`VariableService.updateDeclaration`/`undeclare` only ever
16
+ * rewrite the one project-wide record). It still matters for two things: the
17
+ * scope has to resolve to a real environment at all, and — for `rename`/
18
+ * `describe` only — it picks which environment's `value` comes back on the
19
+ * `Variable` the call answers. Left unset, the server assumes `"prod"`
20
+ * (`Scope.Default`), which is a 404 waiting to happen for a project that
21
+ * never created one; set it explicitly for any other project shape.
22
+ */
23
+ export interface VariableEnvironmentOptions extends RequestOptions {
24
+ environment?: string;
25
+ }
26
+ /** Declarations within one project: `declare`, `rename`, `describe`,
27
+ * `undeclare`. Values live on `EnvironmentVariables` instead. */
28
+ export declare class ProjectVariables {
29
+ private readonly transport;
30
+ private readonly project;
31
+ constructor(transport: Transport, project: string);
32
+ declare(name: string, options?: DeclareVariableOptions): Promise<Variable>;
33
+ rename(name: string, to: string, options?: VariableEnvironmentOptions): Promise<Variable>;
34
+ describe(name: string, description: string, options?: VariableEnvironmentOptions): Promise<Variable>;
35
+ /** Forgets the name and every environment's value with it. */
36
+ undeclare(name: string, options?: VariableEnvironmentOptions): Promise<void>;
37
+ private updateDeclaration;
38
+ }
@@ -0,0 +1,38 @@
1
+ import type { RequestOptions } from "../request-options.js";
2
+ import type { Transport } from "../transport/transport.js";
3
+ import { Variable } from "./variable.js";
4
+ /** `declare()`'s options: `environment` is where the initial `value` lands,
5
+ * when one is given at all. */
6
+ export interface DeclareVariableOptions extends RequestOptions {
7
+ description?: string;
8
+ environment?: string;
9
+ value?: string;
10
+ }
11
+ /**
12
+ * `rename()`/`describe()`/`undeclare()`'s options. `environment` is not
13
+ * load-bearing for what these three do — declaring, renaming and
14
+ * undeclaring reach every environment in the project regardless of which one
15
+ * is named (`VariableService.updateDeclaration`/`undeclare` only ever
16
+ * rewrite the one project-wide record). It still matters for two things: the
17
+ * scope has to resolve to a real environment at all, and — for `rename`/
18
+ * `describe` only — it picks which environment's `value` comes back on the
19
+ * `Variable` the call answers. Left unset, the server assumes `"prod"`
20
+ * (`Scope.Default`), which is a 404 waiting to happen for a project that
21
+ * never created one; set it explicitly for any other project shape.
22
+ */
23
+ export interface VariableEnvironmentOptions extends RequestOptions {
24
+ environment?: string;
25
+ }
26
+ /** Declarations within one project: `declare`, `rename`, `describe`,
27
+ * `undeclare`. Values live on `EnvironmentVariables` instead. */
28
+ export declare class ProjectVariables {
29
+ private readonly transport;
30
+ private readonly project;
31
+ constructor(transport: Transport, project: string);
32
+ declare(name: string, options?: DeclareVariableOptions): Promise<Variable>;
33
+ rename(name: string, to: string, options?: VariableEnvironmentOptions): Promise<Variable>;
34
+ describe(name: string, description: string, options?: VariableEnvironmentOptions): Promise<Variable>;
35
+ /** Forgets the name and every environment's value with it. */
36
+ undeclare(name: string, options?: VariableEnvironmentOptions): Promise<void>;
37
+ private updateDeclaration;
38
+ }
@@ -0,0 +1,10 @@
1
+ /** The wire's `VariableView`: one declaration as one environment sees it.
2
+ * `value: null` means this environment has not set it. */
3
+ export interface VariableDeclaration {
4
+ name: string;
5
+ description: string;
6
+ value: string | null;
7
+ set_in: number;
8
+ created_at: string;
9
+ updated_at: string;
10
+ }
@@ -0,0 +1,10 @@
1
+ /** The wire's `VariableView`: one declaration as one environment sees it.
2
+ * `value: null` means this environment has not set it. */
3
+ export interface VariableDeclaration {
4
+ name: string;
5
+ description: string;
6
+ value: string | null;
7
+ set_in: number;
8
+ created_at: string;
9
+ updated_at: string;
10
+ }
@@ -0,0 +1,17 @@
1
+ import type { VariableDeclaration } from "./variable-declaration.cjs";
2
+ /**
3
+ * One `{{NAME}}` declaration as one environment sees it. `value` is
4
+ * `null` when this environment has given it nothing — not `""`, which is a
5
+ * value in its own right. The name itself is never rewritten: it is
6
+ * case-sensitive `UPPER_SNAKE` content, not metadata.
7
+ */
8
+ export declare class Variable {
9
+ readonly name: string;
10
+ readonly description: string;
11
+ readonly value: string | null;
12
+ readonly setIn: number;
13
+ readonly createdAt: Date;
14
+ readonly updatedAt: Date;
15
+ private constructor();
16
+ static fromWire(payload: VariableDeclaration): Variable;
17
+ }
@@ -0,0 +1,17 @@
1
+ import type { VariableDeclaration } from "./variable-declaration.js";
2
+ /**
3
+ * One `{{NAME}}` declaration as one environment sees it. `value` is
4
+ * `null` when this environment has given it nothing — not `""`, which is a
5
+ * value in its own right. The name itself is never rewritten: it is
6
+ * case-sensitive `UPPER_SNAKE` content, not metadata.
7
+ */
8
+ export declare class Variable {
9
+ readonly name: string;
10
+ readonly description: string;
11
+ readonly value: string | null;
12
+ readonly setIn: number;
13
+ readonly createdAt: Date;
14
+ readonly updatedAt: Date;
15
+ private constructor();
16
+ static fromWire(payload: VariableDeclaration): Variable;
17
+ }