@grovemotorco/manifold 0.0.0-stage → 0.0.1
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.
- package/LICENSE +201 -0
- package/README.md +50 -2
- package/dist/api.d.ts +6515 -0
- package/dist/api.js +643 -0
- package/dist/client.d.ts +2603 -0
- package/dist/client.js +42 -0
- package/dist/domain-Dye3ZdC_.js +922 -0
- package/dist/filter-DQnhobby.js +240 -0
- package/dist/ids-Ced7gYBp.d.ts +1704 -0
- package/dist/index.d.ts +640 -0
- package/dist/index.js +1339 -0
- package/dist/listen.d.ts +530 -0
- package/dist/listen.js +566 -0
- package/package.json +49 -3
package/dist/client.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { API_PREFIX, AdminActor, AdminAuth, ApiErrorHandling, ApiErrors, AuditGroup, AuditPage, BadRequest, ConfigApply, ConfigGroup, Conflict, DeliveriesGroup, DeliveryPage, LISTEN_TOKEN_DEFAULT_DAYS, LISTEN_TOKEN_ENDPOINTS, LISTEN_TOKEN_MAX_DAYS, ListenGroup, ListenTokenCreate, ListenTokenCreated, ListenTokenPage, ListenerPage, ListenerRef, MaintenanceGroup, ManifoldApi, NotFound, PageQuery, PayloadTooLarge, PresetPage, PresetsGroup, ReencryptResult, RelayCreate, RelayCreateWithDefaults, RelayCreated, RelayPage, RelayPatch, RelaySecretRotated, RelaysGroup, ReplayRange, ReplayRangeResult, ReplayRequest, ReplayResult, RequestPage, RequestsGroup, RouteCreate, RoutePage, RoutePatch, RoutesGroup, SecretAdd, SecretChanged, SendLocal, SendLocalRange, SendLocalResult, SourceCreate, SourceCreateWithDefaults, SourcePage, SourcePatch, SourcesGroup, Unauthorized, Unavailable, actorLabel, isListenTokenEndpoint, sourceKeyOfApiPath } from "./api.js";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
6
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
7
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
8
|
+
import * as HttpApiClient from "effect/http-api/HttpApiClient";
|
|
9
|
+
// src/api/client.ts
|
|
10
|
+
/**
|
|
11
|
+
* `@grovemotorco/manifold/client`: a typed client derived from `ManifoldApi`.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const client = makeClient("https://manifold.example.com", process.env.MANIFOLD_ADMIN_TOKEN!)
|
|
15
|
+
* const sources = await Effect.runPromise(client.sources.list({ query: {} }))
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Builds the client from the `HttpClient` in context. `baseUrl` is the
|
|
20
|
+
* service origin (the `/api/v1` prefix is part of the API definition).
|
|
21
|
+
* With `token` undefined no `authorization` header is added: behind
|
|
22
|
+
* Cloudflare Access, or when `transformClient` adds the credentials itself
|
|
23
|
+
* (the dashboard reads the tab's current token per request).
|
|
24
|
+
*/
|
|
25
|
+
const makeClientEffect = (baseUrl, token, options = {}) => HttpApiClient.make(ManifoldApi, {
|
|
26
|
+
baseUrl,
|
|
27
|
+
transformClient: (client) => {
|
|
28
|
+
const authed = token === void 0 ? client : client.pipe(HttpClient.mapRequest(HttpClientRequest.bearerToken(token)));
|
|
29
|
+
return options.transformClient === void 0 ? authed : options.transformClient(authed);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
/** The admin API client as a service, for programs that compose Layers. */
|
|
33
|
+
var ManifoldApiClient = class ManifoldApiClient extends Context.Service()("manifold/api/Client") {
|
|
34
|
+
/** Builds the client from the `HttpClient` in context (see `makeClientEffect`). */
|
|
35
|
+
static layer = (baseUrl, token, options = {}) => Layer.effect(ManifoldApiClient, makeClientEffect(baseUrl, token, options));
|
|
36
|
+
};
|
|
37
|
+
/** A ready client over `fetch`, authenticated with the admin token. */
|
|
38
|
+
const makeClient = (baseUrl, token, options = {}) => {
|
|
39
|
+
const program = makeClientEffect(baseUrl, token, options).pipe(Effect.provide(FetchHttpClient.layer));
|
|
40
|
+
return Effect.runSync(options.fetch === void 0 ? program : program.pipe(Effect.provideService(FetchHttpClient.Fetch, options.fetch)));
|
|
41
|
+
};
|
|
42
|
+
export { API_PREFIX, AdminActor, AdminAuth, ApiErrorHandling, ApiErrors, AuditGroup, AuditPage, BadRequest, ConfigApply, ConfigGroup, Conflict, DeliveriesGroup, DeliveryPage, LISTEN_TOKEN_DEFAULT_DAYS, LISTEN_TOKEN_ENDPOINTS, LISTEN_TOKEN_MAX_DAYS, ListenGroup, ListenTokenCreate, ListenTokenCreated, ListenTokenPage, ListenerPage, ListenerRef, MaintenanceGroup, ManifoldApi, ManifoldApiClient, NotFound, PageQuery, PayloadTooLarge, PresetPage, PresetsGroup, ReencryptResult, RelayCreate, RelayCreateWithDefaults, RelayCreated, RelayPage, RelayPatch, RelaySecretRotated, RelaysGroup, ReplayRange, ReplayRangeResult, ReplayRequest, ReplayResult, RequestPage, RequestsGroup, RouteCreate, RoutePage, RoutePatch, RoutesGroup, SecretAdd, SecretChanged, SendLocal, SendLocalRange, SendLocalResult, SourceCreate, SourceCreateWithDefaults, SourcePage, SourcePatch, SourcesGroup, Unauthorized, Unavailable, actorLabel, isListenTokenEndpoint, makeClient, makeClientEffect, sourceKeyOfApiPath };
|