@herd-labs/sdk 0.3.0 → 0.4.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.
- package/dist/src/config.d.ts +8 -8
- package/dist/src/config.js +8 -11
- package/dist/src/errors.d.ts +29 -44
- package/dist/src/errors.js +13 -16
- package/dist/src/live/ActionsServiceLive.d.ts +2 -2
- package/dist/src/live/ActionsServiceLive.js +9 -9
- package/dist/src/live/AdaptersServiceLive.d.ts +2 -2
- package/dist/src/live/AdaptersServiceLive.js +6 -6
- package/dist/src/live/AgentSafesServiceLive.d.ts +2 -2
- package/dist/src/live/AgentSafesServiceLive.js +3 -3
- package/dist/src/live/AgentWalletsServiceLive.d.ts +2 -2
- package/dist/src/live/AgentWalletsServiceLive.js +3 -3
- package/dist/src/live/AgentWorkflowsServiceLive.d.ts +2 -2
- package/dist/src/live/AgentWorkflowsServiceLive.js +10 -10
- package/dist/src/live/AuthServiceLive.d.ts +2 -2
- package/dist/src/live/AuthServiceLive.js +7 -7
- package/dist/src/live/BookmarksServiceLive.d.ts +2 -2
- package/dist/src/live/BookmarksServiceLive.js +16 -16
- package/dist/src/live/CodeBlocksServiceLive.d.ts +2 -2
- package/dist/src/live/CodeBlocksServiceLive.js +8 -8
- package/dist/src/live/CollectionsServiceLive.d.ts +2 -2
- package/dist/src/live/CollectionsServiceLive.js +3 -3
- package/dist/src/live/ContractsServiceLive.d.ts +2 -2
- package/dist/src/live/ContractsServiceLive.js +6 -6
- package/dist/src/live/DocsServiceLive.d.ts +2 -2
- package/dist/src/live/DocsServiceLive.js +2 -2
- package/dist/src/live/GroupsServiceLive.d.ts +2 -2
- package/dist/src/live/GroupsServiceLive.js +5 -5
- package/dist/src/live/HalServiceLive.d.ts +2 -2
- package/dist/src/live/HalServiceLive.js +9 -9
- package/dist/src/live/TransactionsServiceLive.d.ts +2 -2
- package/dist/src/live/TransactionsServiceLive.js +17 -17
- package/dist/src/live/WalletsServiceLive.d.ts +2 -2
- package/dist/src/live/WalletsServiceLive.js +14 -14
- package/dist/src/live/http.d.ts +6 -5
- package/dist/src/live/http.js +16 -18
- package/dist/src/schemas/actions.d.ts +95 -323
- package/dist/src/schemas/actions.js +41 -37
- package/dist/src/schemas/adapters.d.ts +5 -15
- package/dist/src/schemas/adapters.js +2 -2
- package/dist/src/schemas/agent-wallets.d.ts +66 -210
- package/dist/src/schemas/agent-wallets.js +25 -25
- package/dist/src/schemas/agent-workflows.d.ts +62 -62
- package/dist/src/schemas/agent-workflows.js +35 -31
- package/dist/src/schemas/auth.d.ts +22 -47
- package/dist/src/schemas/auth.js +10 -7
- package/dist/src/schemas/bookmarks.d.ts +64 -204
- package/dist/src/schemas/bookmarks.js +27 -23
- package/dist/src/schemas/codeblocks.d.ts +98 -294
- package/dist/src/schemas/codeblocks.js +41 -36
- package/dist/src/schemas/collections.d.ts +68 -224
- package/dist/src/schemas/collections.js +28 -24
- package/dist/src/schemas/common.d.ts +9 -25
- package/dist/src/schemas/common.js +5 -5
- package/dist/src/schemas/contracts.d.ts +125 -431
- package/dist/src/schemas/contracts.js +52 -63
- package/dist/src/schemas/docs.d.ts +9 -26
- package/dist/src/schemas/docs.js +4 -4
- package/dist/src/schemas/groups.d.ts +47 -47
- package/dist/src/schemas/groups.js +18 -18
- package/dist/src/schemas/hal.d.ts +57 -211
- package/dist/src/schemas/hal.js +32 -30
- package/dist/src/schemas/transactions.d.ts +404 -890
- package/dist/src/schemas/transactions.js +128 -132
- package/dist/src/schemas/wallets.d.ts +205 -709
- package/dist/src/schemas/wallets.js +112 -96
- package/dist/src/services/ActionsService.d.ts +1 -1
- package/dist/src/services/ActionsService.js +2 -2
- package/dist/src/services/AdaptersService.d.ts +1 -1
- package/dist/src/services/AdaptersService.js +2 -2
- package/dist/src/services/AgentSafesService.d.ts +1 -1
- package/dist/src/services/AgentSafesService.js +2 -2
- package/dist/src/services/AgentWalletsService.d.ts +1 -1
- package/dist/src/services/AgentWalletsService.js +2 -2
- package/dist/src/services/AgentWorkflowsService.d.ts +3 -3
- package/dist/src/services/AgentWorkflowsService.js +6 -2
- package/dist/src/services/AuthService.d.ts +3 -3
- package/dist/src/services/AuthService.js +2 -2
- package/dist/src/services/BookmarksService.d.ts +2 -2
- package/dist/src/services/BookmarksService.js +2 -2
- package/dist/src/services/CodeBlocksService.d.ts +1 -1
- package/dist/src/services/CodeBlocksService.js +2 -2
- package/dist/src/services/CollectionsService.d.ts +1 -1
- package/dist/src/services/CollectionsService.js +2 -2
- package/dist/src/services/ContractsService.d.ts +1 -1
- package/dist/src/services/ContractsService.js +2 -2
- package/dist/src/services/DocsService.d.ts +2 -2
- package/dist/src/services/DocsService.js +2 -2
- package/dist/src/services/GroupsService.d.ts +3 -3
- package/dist/src/services/GroupsService.js +4 -2
- package/dist/src/services/HalService.d.ts +1 -1
- package/dist/src/services/HalService.js +2 -2
- package/dist/src/services/TransactionsService.d.ts +1 -1
- package/dist/src/services/TransactionsService.js +2 -2
- package/dist/src/services/WalletsService.d.ts +1 -1
- package/dist/src/services/WalletsService.js +2 -2
- package/package.json +14 -19
|
@@ -3,16 +3,20 @@ import { CodeBlockExecuteResponse, CodeBlocksSearchResponse, CreateCodeBlockResp
|
|
|
3
3
|
import { CodeBlocksService } from "../services/CodeBlocksService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
5
5
|
import { Array, Effect, Layer, Option, pipe } from "effect";
|
|
6
|
-
import { HttpClientResponse } from "
|
|
6
|
+
import { HttpClientResponse } from "effect/unstable/http";
|
|
7
7
|
|
|
8
8
|
//#region src/live/CodeBlocksServiceLive.ts
|
|
9
|
-
const mapNotFound = (id) => Effect.
|
|
9
|
+
const mapNotFound = (id) => Effect.catch((error) => {
|
|
10
10
|
if (error instanceof ServiceError && error.metadata["status"] === 404) return Effect.fail(new CodeBlockNotFoundError({ id }));
|
|
11
11
|
return Effect.fail(error);
|
|
12
12
|
});
|
|
13
13
|
const CodeBlocksServiceLive = Layer.effect(CodeBlocksService, Effect.gen(function* () {
|
|
14
14
|
const { baseUrl, client } = yield* authorizedClient;
|
|
15
15
|
return {
|
|
16
|
+
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/code/definitions"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateCodeBlockResponse)), Effect.mapError(ensureServiceError("Failed to create code block"))),
|
|
17
|
+
createCode: (definitionId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateCodeVersionResponse)), Effect.mapError(ensureServiceError("Failed to create code version")), mapNotFound(definitionId)),
|
|
18
|
+
delete: (definitionId) => pipe(client.del(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}`)), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to delete code block")), mapNotFound(definitionId)),
|
|
19
|
+
execute: (definitionId, codeId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes/${codeId}/execute`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CodeBlockExecuteResponse)), Effect.mapError(ensureServiceError("Failed to execute code block")), mapNotFound(definitionId)),
|
|
16
20
|
get: (id) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/code/definitions/query"), { body: jsonBody({
|
|
17
21
|
scope: "user",
|
|
18
22
|
limit: 1,
|
|
@@ -21,14 +25,10 @@ const CodeBlocksServiceLive = Layer.effect(CodeBlocksService, Effect.gen(functio
|
|
|
21
25
|
onNone: () => Effect.fail(new CodeBlockNotFoundError({ id })),
|
|
22
26
|
onSome: Effect.succeed
|
|
23
27
|
})))),
|
|
28
|
+
publishCode: (definitionId, codeId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes/${codeId}/publish`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(PublishCodeBlockResponse)), Effect.mapError(ensureServiceError("Failed to publish code block")), mapNotFound(definitionId)),
|
|
24
29
|
search: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/code/definitions/query"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CodeBlocksSearchResponse)), Effect.mapError(ensureServiceError("Failed to search code blocks"))),
|
|
25
|
-
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/code/definitions"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateCodeBlockResponse)), Effect.mapError(ensureServiceError("Failed to create code block"))),
|
|
26
|
-
updateMetadata: (definitionId, params) => pipe(client.put(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update code block metadata")), mapNotFound(definitionId)),
|
|
27
|
-
createCode: (definitionId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateCodeVersionResponse)), Effect.mapError(ensureServiceError("Failed to create code version")), mapNotFound(definitionId)),
|
|
28
30
|
updateCode: (definitionId, codeId, params) => pipe(client.put(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes/${codeId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update code")), mapNotFound(definitionId)),
|
|
29
|
-
|
|
30
|
-
execute: (definitionId, codeId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes/${codeId}/execute`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CodeBlockExecuteResponse)), Effect.mapError(ensureServiceError("Failed to execute code block")), mapNotFound(definitionId)),
|
|
31
|
-
delete: (definitionId) => pipe(client.del(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}`)), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to delete code block")), mapNotFound(definitionId))
|
|
31
|
+
updateMetadata: (definitionId, params) => pipe(client.put(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update code block metadata")), mapNotFound(definitionId))
|
|
32
32
|
};
|
|
33
33
|
}));
|
|
34
34
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { CollectionsService } from "../services/CollectionsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient9 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/CollectionsServiceLive.d.ts
|
|
7
|
-
declare const CollectionsServiceLive: Layer.Layer<CollectionsService, never, HerdConfig |
|
|
7
|
+
declare const CollectionsServiceLive: Layer.Layer<CollectionsService, never, HerdConfig | effect_unstable_http_HttpClient9.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { CollectionsServiceLive };
|
|
@@ -3,19 +3,19 @@ import { Collection, CollectionsSearchResponse, CreateCollectionResponse } from
|
|
|
3
3
|
import { CollectionsService } from "../services/CollectionsService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
5
5
|
import { Effect, Layer, pipe } from "effect";
|
|
6
|
-
import { HttpClientResponse } from "
|
|
6
|
+
import { HttpClientResponse } from "effect/unstable/http";
|
|
7
7
|
|
|
8
8
|
//#region src/live/CollectionsServiceLive.ts
|
|
9
|
-
const mapNotFound = (id) => Effect.
|
|
9
|
+
const mapNotFound = (id) => Effect.catch((error) => {
|
|
10
10
|
if (error instanceof ServiceError && error.metadata["status"] === 404) return Effect.fail(new CollectionNotFoundError({ id }));
|
|
11
11
|
return Effect.fail(error);
|
|
12
12
|
});
|
|
13
13
|
const CollectionsServiceLive = Layer.effect(CollectionsService, Effect.gen(function* () {
|
|
14
14
|
const { baseUrl, client } = yield* authorizedClient;
|
|
15
15
|
return {
|
|
16
|
+
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/collections"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateCollectionResponse)), Effect.mapError(ensureServiceError("Failed to create collection"))),
|
|
16
17
|
get: (collectionId) => pipe(client.get(makeUrl(baseUrl, `/v1/collections/${collectionId}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(Collection)), Effect.mapError(ensureServiceError("Failed to get collection")), mapNotFound(collectionId)),
|
|
17
18
|
search: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/collections/query"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CollectionsSearchResponse)), Effect.mapError(ensureServiceError("Failed to search collections"))),
|
|
18
|
-
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/collections"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateCollectionResponse)), Effect.mapError(ensureServiceError("Failed to create collection"))),
|
|
19
19
|
update: (collectionId, params) => pipe(client.patch(makeUrl(baseUrl, `/v1/collections/${collectionId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update collection")), mapNotFound(collectionId))
|
|
20
20
|
};
|
|
21
21
|
}));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { ContractsService } from "../services/ContractsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient7 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/ContractsServiceLive.d.ts
|
|
7
|
-
declare const ContractsServiceLive: Layer.Layer<ContractsService, never, HerdConfig |
|
|
7
|
+
declare const ContractsServiceLive: Layer.Layer<ContractsService, never, HerdConfig | effect_unstable_http_HttpClient7.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { ContractsServiceLive };
|
|
@@ -4,16 +4,12 @@ import { DeployedContracts } from "../schemas/wallets.js";
|
|
|
4
4
|
import { ContractsService } from "../services/ContractsService.js";
|
|
5
5
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
6
6
|
import { Effect, Layer, pipe } from "effect";
|
|
7
|
-
import { HttpClientResponse } from "
|
|
7
|
+
import { HttpClientResponse } from "effect/unstable/http";
|
|
8
8
|
|
|
9
9
|
//#region src/live/ContractsServiceLive.ts
|
|
10
10
|
const ContractsServiceLive = Layer.effect(ContractsService, Effect.gen(function* () {
|
|
11
11
|
const { baseUrl, client } = yield* authorizedClient;
|
|
12
12
|
return {
|
|
13
|
-
getMetadata: (address, blockchain) => pipe(client.post(makeUrl(baseUrl, "/v1/contracts/metadata_enriched"), { body: jsonBody({
|
|
14
|
-
contractAddress: address,
|
|
15
|
-
blockchain
|
|
16
|
-
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ContractMetadata)), Effect.mapError(ensureServiceError("Failed to get contract metadata"))),
|
|
17
13
|
diffVersions: (address, blockchain, params) => pipe(client.post(makeUrl(baseUrl, "/v1/contracts/diff_versions"), { body: jsonBody({
|
|
18
14
|
contractAddress: address,
|
|
19
15
|
blockchain,
|
|
@@ -23,7 +19,11 @@ const ContractsServiceLive = Layer.effect(ContractsService, Effect.gen(function*
|
|
|
23
19
|
blockchain,
|
|
24
20
|
...params
|
|
25
21
|
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(GetContractCodeResponse)), Effect.mapError(ensureServiceError("Failed to get contract code"))),
|
|
26
|
-
getDeployedContracts: (blockchain, address, params) => pipe(client.get(makeUrl(baseUrl, `/v1/wallets/${blockchain}/${address}/created_contracts`, params)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(DeployedContracts)), Effect.mapError(ensureServiceError("Failed to get deployed contracts")))
|
|
22
|
+
getDeployedContracts: (blockchain, address, params) => pipe(client.get(makeUrl(baseUrl, `/v1/wallets/${blockchain}/${address}/created_contracts`, params)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(DeployedContracts)), Effect.mapError(ensureServiceError("Failed to get deployed contracts"))),
|
|
23
|
+
getMetadata: (address, blockchain) => pipe(client.post(makeUrl(baseUrl, "/v1/contracts/metadata_enriched"), { body: jsonBody({
|
|
24
|
+
contractAddress: address,
|
|
25
|
+
blockchain
|
|
26
|
+
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ContractMetadata)), Effect.mapError(ensureServiceError("Failed to get contract metadata")))
|
|
27
27
|
};
|
|
28
28
|
}));
|
|
29
29
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { DocsService } from "../services/DocsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient11 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/DocsServiceLive.d.ts
|
|
7
|
-
declare const DocsServiceLive: Layer.Layer<DocsService, never, HerdConfig |
|
|
7
|
+
declare const DocsServiceLive: Layer.Layer<DocsService, never, HerdConfig | effect_unstable_http_HttpClient11.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { DocsServiceLive };
|
|
@@ -3,13 +3,13 @@ import { DocContent, DocEntry } from "../schemas/docs.js";
|
|
|
3
3
|
import { DocsService } from "../services/DocsService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, makeUrl } from "./http.js";
|
|
5
5
|
import { Effect, Layer, Schema, pipe } from "effect";
|
|
6
|
-
import { HttpClientResponse } from "
|
|
6
|
+
import { HttpClientResponse } from "effect/unstable/http";
|
|
7
7
|
|
|
8
8
|
//#region src/live/DocsServiceLive.ts
|
|
9
9
|
const DocsServiceLive = Layer.effect(DocsService, Effect.gen(function* () {
|
|
10
10
|
const { baseUrl, client } = yield* authorizedClient;
|
|
11
11
|
return {
|
|
12
|
-
list:
|
|
12
|
+
list: pipe(client.get(makeUrl(baseUrl, "/v1/docs")), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Array(DocEntry))), Effect.mapError(ensureServiceError("Failed to list docs"))),
|
|
13
13
|
read: (docId) => Effect.gen(function* () {
|
|
14
14
|
const response = yield* pipe(client.get(makeUrl(baseUrl, `/v1/docs/${encodeURIComponent(docId)}`)), Effect.flatMap(checkStatus), Effect.mapError((error) => {
|
|
15
15
|
const wrapped = ensureServiceError("Failed to read doc")(error);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { GroupsService } from "../services/GroupsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient12 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/GroupsServiceLive.d.ts
|
|
7
|
-
declare const GroupsServiceLive: Layer.Layer<GroupsService, never, HerdConfig |
|
|
7
|
+
declare const GroupsServiceLive: Layer.Layer<GroupsService, never, HerdConfig | effect_unstable_http_HttpClient12.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { GroupsServiceLive };
|
|
@@ -3,10 +3,10 @@ import { CreateGroupResponse, EditGroupMetadataResponse, GroupDetails, ListGroup
|
|
|
3
3
|
import { GroupNotFoundError, GroupsService } from "../services/GroupsService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
5
5
|
import { Effect, Layer, pipe } from "effect";
|
|
6
|
-
import { HttpClientResponse } from "
|
|
6
|
+
import { HttpClientResponse } from "effect/unstable/http";
|
|
7
7
|
|
|
8
8
|
//#region src/live/GroupsServiceLive.ts
|
|
9
|
-
const mapNotFound = (groupId) => Effect.
|
|
9
|
+
const mapNotFound = (groupId) => Effect.catch((error) => {
|
|
10
10
|
if (error instanceof ServiceError && error.metadata["status"] === 404) return Effect.fail(new GroupNotFoundError(groupId));
|
|
11
11
|
return Effect.fail(error);
|
|
12
12
|
});
|
|
@@ -14,11 +14,11 @@ const GroupsServiceLive = Layer.effect(GroupsService, Effect.gen(function* () {
|
|
|
14
14
|
const { baseUrl, client } = yield* authorizedClient;
|
|
15
15
|
return {
|
|
16
16
|
create: ({ params }) => pipe(client.post(makeUrl(baseUrl, "/v1/groups"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateGroupResponse)), Effect.mapError(ensureServiceError("Failed to create group"))),
|
|
17
|
-
|
|
17
|
+
editMetadata: ({ groupId, params }) => pipe(client.patch(makeUrl(baseUrl, `/v1/groups/${groupId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(EditGroupMetadataResponse)), Effect.mapError(ensureServiceError("Failed to edit group metadata")), mapNotFound(groupId)),
|
|
18
18
|
get: ({ groupId }) => pipe(client.get(makeUrl(baseUrl, `/v1/groups/${groupId}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(GroupDetails)), Effect.mapError(ensureServiceError("Failed to get group")), mapNotFound(groupId)),
|
|
19
|
+
list: pipe(client.get(makeUrl(baseUrl, "/v1/groups")), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ListGroupsResponse)), Effect.mapError(ensureServiceError("Failed to list groups"))),
|
|
19
20
|
proposeMemberChange: ({ groupId, params }) => pipe(client.post(makeUrl(baseUrl, `/v1/groups/${groupId}/proposals/member`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ProposalResponse)), Effect.mapError(ensureServiceError("Failed to propose member change")), mapNotFound(groupId)),
|
|
20
|
-
proposeQuorumChange: ({ groupId, params }) => pipe(client.post(makeUrl(baseUrl, `/v1/groups/${groupId}/proposals/quorum`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ProposalResponse)), Effect.mapError(ensureServiceError("Failed to propose quorum change")), mapNotFound(groupId))
|
|
21
|
-
editMetadata: ({ groupId, params }) => pipe(client.patch(makeUrl(baseUrl, `/v1/groups/${groupId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(EditGroupMetadataResponse)), Effect.mapError(ensureServiceError("Failed to edit group metadata")), mapNotFound(groupId))
|
|
21
|
+
proposeQuorumChange: ({ groupId, params }) => pipe(client.post(makeUrl(baseUrl, `/v1/groups/${groupId}/proposals/quorum`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ProposalResponse)), Effect.mapError(ensureServiceError("Failed to propose quorum change")), mapNotFound(groupId))
|
|
22
22
|
};
|
|
23
23
|
}));
|
|
24
24
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { HalService } from "../services/HalService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient13 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/HalServiceLive.d.ts
|
|
7
|
-
declare const HalServiceLive: Layer.Layer<HalService, never, HerdConfig |
|
|
7
|
+
declare const HalServiceLive: Layer.Layer<HalService, never, HerdConfig | effect_unstable_http_HttpClient13.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { HalServiceLive };
|
|
@@ -3,13 +3,13 @@ import { EvaluateExistingResponse, EvaluateResponse } from "../schemas/hal.js";
|
|
|
3
3
|
import { HalService } from "../services/HalService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
5
5
|
import { Effect, Layer, pipe } from "effect";
|
|
6
|
-
import { HttpClientResponse } from "
|
|
6
|
+
import { HttpClientResponse } from "effect/unstable/http";
|
|
7
7
|
|
|
8
8
|
//#region src/live/HalServiceLive.ts
|
|
9
|
-
const mapSimulationError = Effect.
|
|
9
|
+
const mapSimulationError = Effect.catch((error) => {
|
|
10
10
|
if (error instanceof ServiceError && error.metadata["status"] === 400) return Effect.fail(new SimulationError({
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
message: String(error.metadata["body"]),
|
|
12
|
+
name: "SimulationError"
|
|
13
13
|
}));
|
|
14
14
|
return Effect.fail(error);
|
|
15
15
|
});
|
|
@@ -21,19 +21,19 @@ const HalServiceLive = Layer.effect(HalService, Effect.gen(function* () {
|
|
|
21
21
|
evaluate: (params) => callEvaluate({
|
|
22
22
|
expression: params.expression,
|
|
23
23
|
inputValues: params.inputValues ?? {},
|
|
24
|
-
walletAddress: params.walletAddress,
|
|
25
24
|
simulationBalanceFunding: params.simulationBalanceFunding ?? [],
|
|
25
|
+
simulationBlockNumber: params.simulationBlockNumber,
|
|
26
26
|
tevmForkId: params.tevmForkId,
|
|
27
|
-
|
|
27
|
+
walletAddress: params.walletAddress
|
|
28
28
|
}),
|
|
29
29
|
evaluateExisting: (params) => callEvaluateExisting({
|
|
30
|
-
actionId: params.actionId,
|
|
31
30
|
actionExpressionId: params.actionExpressionId,
|
|
32
|
-
|
|
31
|
+
actionId: params.actionId,
|
|
33
32
|
inputValues: params.inputValues ?? {},
|
|
34
33
|
simulationBalanceFunding: params.simulationBalanceFunding ?? [],
|
|
34
|
+
simulationBlockNumber: params.simulationBlockNumber,
|
|
35
35
|
tevmForkId: params.tevmForkId,
|
|
36
|
-
|
|
36
|
+
walletAddress: params.walletAddress
|
|
37
37
|
})
|
|
38
38
|
};
|
|
39
39
|
}));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { TransactionsService } from "../services/TransactionsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient4 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/TransactionsServiceLive.d.ts
|
|
7
|
-
declare const TransactionsServiceLive: Layer.Layer<TransactionsService, never, HerdConfig |
|
|
7
|
+
declare const TransactionsServiceLive: Layer.Layer<TransactionsService, never, HerdConfig | effect_unstable_http_HttpClient4.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { TransactionsServiceLive };
|
|
@@ -2,44 +2,44 @@ import { ensureServiceError } from "../errors.js";
|
|
|
2
2
|
import { LatestEventTransactions, LatestFunctionTransactions, TransactionQueryResponse } from "../schemas/transactions.js";
|
|
3
3
|
import { TransactionsService } from "../services/TransactionsService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, makeUrl } from "./http.js";
|
|
5
|
-
import { Effect,
|
|
6
|
-
import { HttpClientResponse } from "
|
|
5
|
+
import { Effect, Layer, Option, Record, pipe } from "effect";
|
|
6
|
+
import { HttpClientResponse } from "effect/unstable/http";
|
|
7
7
|
|
|
8
8
|
//#region src/live/TransactionsServiceLive.ts
|
|
9
|
-
const toOptionalQuery = (input) =>
|
|
10
|
-
const latestTxParamsToSnakeCaseQuery = (params) =>
|
|
9
|
+
const toOptionalQuery = (input) => Record.getSomes(Record.map(input, Option.fromNullishOr));
|
|
10
|
+
const latestTxParamsToSnakeCaseQuery = (params) => Record.getSomes(Record.map({
|
|
11
|
+
after_blocknumber: params?.afterBlocknumber,
|
|
12
|
+
after_timestamp: params?.afterTimestamp,
|
|
13
|
+
before_blocknumber: params?.beforeBlocknumber,
|
|
14
|
+
before_timestamp: params?.beforeTimestamp,
|
|
15
|
+
called_by: params?.calledBy,
|
|
16
|
+
direction: params?.direction,
|
|
11
17
|
limit: params?.limit,
|
|
12
18
|
offset: params?.offset,
|
|
13
19
|
page: params?.page,
|
|
14
|
-
before_timestamp: params?.beforeTimestamp,
|
|
15
|
-
after_timestamp: params?.afterTimestamp,
|
|
16
|
-
before_blocknumber: params?.beforeBlocknumber,
|
|
17
|
-
after_blocknumber: params?.afterBlocknumber,
|
|
18
20
|
success_only: params?.successOnly === true ? true : void 0,
|
|
19
|
-
direction: params?.direction,
|
|
20
21
|
topic1: params?.topic1,
|
|
21
22
|
topic2: params?.topic2,
|
|
22
|
-
topic3: params?.topic3
|
|
23
|
-
|
|
24
|
-
}, Record.filterMap(Option.liftNullable(Function.identity)));
|
|
23
|
+
topic3: params?.topic3
|
|
24
|
+
}, Option.fromNullishOr));
|
|
25
25
|
const TransactionsServiceLive = Layer.effect(TransactionsService, Effect.gen(function* () {
|
|
26
26
|
const { baseUrl, client } = yield* authorizedClient;
|
|
27
27
|
return {
|
|
28
|
-
|
|
29
|
-
getLatestFunctionTransactions: (blockchain, address, filter, params) => pipe(client.get(makeUrl(baseUrl, `/v1/contracts/${blockchain}/${address}/latest_function_transactions`, {
|
|
28
|
+
getLatestEventTransactions: (blockchain, address, filter, params) => pipe(client.get(makeUrl(baseUrl, `/v1/contracts/${blockchain}/${address}/latest_event_transactions`, {
|
|
30
29
|
...latestTxParamsToSnakeCaseQuery(params),
|
|
31
30
|
...toOptionalQuery({
|
|
32
31
|
name: filter.name,
|
|
33
32
|
signature: filter.signature
|
|
34
33
|
})
|
|
35
|
-
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
36
|
-
|
|
34
|
+
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(LatestEventTransactions)), Effect.mapError(ensureServiceError("Failed to get latest event transactions"))),
|
|
35
|
+
getLatestFunctionTransactions: (blockchain, address, filter, params) => pipe(client.get(makeUrl(baseUrl, `/v1/contracts/${blockchain}/${address}/latest_function_transactions`, {
|
|
37
36
|
...latestTxParamsToSnakeCaseQuery(params),
|
|
38
37
|
...toOptionalQuery({
|
|
39
38
|
name: filter.name,
|
|
40
39
|
signature: filter.signature
|
|
41
40
|
})
|
|
42
|
-
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
41
|
+
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(LatestFunctionTransactions)), Effect.mapError(ensureServiceError("Failed to get latest function transactions"))),
|
|
42
|
+
getTransaction: (blockchain, txHash) => pipe(client.get(makeUrl(baseUrl, `/v1/transactions/${blockchain}/${txHash}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(TransactionQueryResponse)), Effect.mapError(ensureServiceError("Failed to get transaction")))
|
|
43
43
|
};
|
|
44
44
|
}));
|
|
45
45
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { WalletsService } from "../services/WalletsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient5 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/WalletsServiceLive.d.ts
|
|
7
|
-
declare const WalletsServiceLive: Layer.Layer<WalletsService, never, HerdConfig |
|
|
7
|
+
declare const WalletsServiceLive: Layer.Layer<WalletsService, never, HerdConfig | effect_unstable_http_HttpClient5.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { WalletsServiceLive };
|
|
@@ -2,13 +2,20 @@ import { ensureServiceError } from "../errors.js";
|
|
|
2
2
|
import { DeployedContracts, TokenActivity, TransactionActivity, WalletOverview } from "../schemas/wallets.js";
|
|
3
3
|
import { WalletsService } from "../services/WalletsService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
5
|
-
import { Effect,
|
|
6
|
-
import { HttpClientResponse } from "
|
|
5
|
+
import { Effect, Layer, Option, Record, pipe } from "effect";
|
|
6
|
+
import { HttpClientResponse } from "effect/unstable/http";
|
|
7
7
|
|
|
8
8
|
//#region src/live/WalletsServiceLive.ts
|
|
9
9
|
const WalletsServiceLive = Layer.effect(WalletsService, Effect.gen(function* () {
|
|
10
10
|
const { baseUrl, client } = yield* authorizedClient;
|
|
11
11
|
return {
|
|
12
|
+
getDeployedContracts: (blockchain, address, params) => pipe(client.get(makeUrl(baseUrl, `/v1/wallets/${blockchain}/${address}/created_contracts`, {
|
|
13
|
+
page: params?.page,
|
|
14
|
+
before_timestamp: params?.beforeTimestamp,
|
|
15
|
+
after_timestamp: params?.afterTimestamp,
|
|
16
|
+
before_blocknumber: params?.beforeBlocknumber,
|
|
17
|
+
after_blocknumber: params?.afterBlocknumber
|
|
18
|
+
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(DeployedContracts)), Effect.mapError(ensureServiceError("Failed to get deployed contracts"))),
|
|
12
19
|
getOverview: (blockchain, address, params) => pipe(client.get(makeUrl(baseUrl, `/v1/wallets/${blockchain}/${address}/overview`, {
|
|
13
20
|
before_timestamp: params?.beforeTimestamp,
|
|
14
21
|
after_timestamp: params?.afterTimestamp,
|
|
@@ -25,28 +32,21 @@ const WalletsServiceLive = Layer.effect(WalletsService, Effect.gen(function* ()
|
|
|
25
32
|
to_address: params?.toAddress
|
|
26
33
|
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(TokenActivity)), Effect.mapError(ensureServiceError("Failed to get token activity"))),
|
|
27
34
|
getTransactions: (query) => {
|
|
28
|
-
const optionalFields =
|
|
35
|
+
const optionalFields = Record.getSomes(Record.map({
|
|
29
36
|
from_address: query.fromAddress,
|
|
30
37
|
to_addresses: query.toAddresses,
|
|
31
|
-
before_timestamp: query.beforeBlocknumber
|
|
32
|
-
after_timestamp: query.afterBlocknumber
|
|
38
|
+
before_timestamp: query.beforeBlocknumber === void 0 ? query.beforeTimestamp : void 0,
|
|
39
|
+
after_timestamp: query.afterBlocknumber === void 0 ? query.afterTimestamp : void 0,
|
|
33
40
|
before_blocknumber: query.beforeBlocknumber,
|
|
34
41
|
after_blocknumber: query.afterBlocknumber,
|
|
35
42
|
success_only: query.successOnly === true ? true : void 0
|
|
36
|
-
},
|
|
43
|
+
}, Option.fromNullishOr));
|
|
37
44
|
return pipe(client.post(makeUrl(baseUrl, "/v1/wallets/transaction-activity"), { body: jsonBody({
|
|
38
45
|
blockchain: query.blockchain,
|
|
39
46
|
page: query.page ?? 1,
|
|
40
47
|
...optionalFields
|
|
41
48
|
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(TransactionActivity)), Effect.mapError(ensureServiceError("Failed to get wallet transactions")));
|
|
42
|
-
}
|
|
43
|
-
getDeployedContracts: (blockchain, address, params) => pipe(client.get(makeUrl(baseUrl, `/v1/wallets/${blockchain}/${address}/created_contracts`, {
|
|
44
|
-
page: params?.page,
|
|
45
|
-
before_timestamp: params?.beforeTimestamp,
|
|
46
|
-
after_timestamp: params?.afterTimestamp,
|
|
47
|
-
before_blocknumber: params?.beforeBlocknumber,
|
|
48
|
-
after_blocknumber: params?.afterBlocknumber
|
|
49
|
-
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(DeployedContracts)), Effect.mapError(ensureServiceError("Failed to get deployed contracts")))
|
|
49
|
+
}
|
|
50
50
|
};
|
|
51
51
|
}));
|
|
52
52
|
|
package/dist/src/live/http.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { ServiceError } from "../errors.js";
|
|
3
3
|
import { Effect, Schema } from "effect";
|
|
4
|
-
import { HttpBody, HttpClient, HttpClientResponse } from "
|
|
5
|
-
import * as
|
|
4
|
+
import { HttpBody, HttpClient, HttpClientResponse, UrlParams } from "effect/unstable/http";
|
|
5
|
+
import * as effect_unstable_http_HttpClientError0 from "effect/unstable/http/HttpClientError";
|
|
6
6
|
|
|
7
7
|
//#region src/live/http.d.ts
|
|
8
8
|
declare const makeUrl: (baseUrl: string, path: string, queryParams?: object) => string;
|
|
9
9
|
declare const authorizedClient: Effect.Effect<{
|
|
10
10
|
baseUrl: string;
|
|
11
|
-
client: HttpClient.HttpClient.With<
|
|
11
|
+
client: HttpClient.HttpClient.With<effect_unstable_http_HttpClientError0.HttpClientError, never>;
|
|
12
12
|
}, never, HerdConfig | HttpClient.HttpClient>;
|
|
13
|
-
declare const handleJsonResponse: <
|
|
13
|
+
declare const handleJsonResponse: <S extends Schema.Top>(schema: S) => (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<S["Type"], ServiceError, S["DecodingServices"]>;
|
|
14
14
|
declare const checkStatus: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<HttpClientResponse.HttpClientResponse, ServiceError>;
|
|
15
15
|
declare const jsonBody: (body: unknown) => HttpBody.HttpBody;
|
|
16
|
+
declare const urlEncodedBody: (body: UrlParams.Input) => HttpBody.HttpBody;
|
|
16
17
|
//#endregion
|
|
17
|
-
export { authorizedClient, checkStatus, handleJsonResponse, jsonBody, makeUrl };
|
|
18
|
+
export { authorizedClient, checkStatus, handleJsonResponse, jsonBody, makeUrl, urlEncodedBody };
|
package/dist/src/live/http.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { ServiceError } from "../errors.js";
|
|
3
|
-
import { Effect,
|
|
4
|
-
import { HttpBody, HttpClient, HttpClientRequest, HttpClientResponse } from "
|
|
3
|
+
import { Effect, Function, Result, pipe } from "effect";
|
|
4
|
+
import { HttpBody, HttpClient, HttpClientRequest, HttpClientResponse, UrlParams } from "effect/unstable/http";
|
|
5
5
|
|
|
6
6
|
//#region src/live/http.ts
|
|
7
7
|
const makeUrl = (baseUrl, path, queryParams) => {
|
|
@@ -15,22 +15,19 @@ const makeUrl = (baseUrl, path, queryParams) => {
|
|
|
15
15
|
const authorizedClient = Effect.gen(function* () {
|
|
16
16
|
const config = yield* HerdConfig;
|
|
17
17
|
const client = yield* HttpClient.HttpClient;
|
|
18
|
-
const { baseUrl, authHeaders } =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const { baseUrl, authHeaders } = Result.match(config, {
|
|
19
|
+
onFailure: ({ baseUrl: innerBaseUrl, oauthAccessToken }) => ({
|
|
20
|
+
authHeaders: { Authorization: `Bearer ${oauthAccessToken}` },
|
|
21
|
+
baseUrl: innerBaseUrl
|
|
22
22
|
}),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
onSuccess: ({ baseUrl: innerBaseUrl, apiKey }) => ({
|
|
24
|
+
authHeaders: { "x-api-key": apiKey },
|
|
25
|
+
baseUrl: innerBaseUrl
|
|
26
26
|
})
|
|
27
27
|
});
|
|
28
28
|
return {
|
|
29
29
|
baseUrl,
|
|
30
|
-
client: client.pipe(HttpClient.mapRequest(HttpClientRequest.setHeaders(
|
|
31
|
-
...authHeaders,
|
|
32
|
-
"Content-Type": "application/json"
|
|
33
|
-
})))
|
|
30
|
+
client: client.pipe(HttpClient.mapRequest(HttpClientRequest.setHeaders(authHeaders)))
|
|
34
31
|
};
|
|
35
32
|
});
|
|
36
33
|
const handleJsonResponse = (schema) => (response) => pipe(HttpClientResponse.schemaBodyJson(schema)(response), Effect.mapError((error) => new ServiceError({
|
|
@@ -48,18 +45,19 @@ const extractErrorMessage = (body) => {
|
|
|
48
45
|
};
|
|
49
46
|
const checkStatus = (response) => {
|
|
50
47
|
if (response.status >= 200 && response.status < 300) return Effect.succeed(response);
|
|
51
|
-
return pipe(response.json, Effect.
|
|
48
|
+
return pipe(response.json, Effect.catch(() => response.text.pipe(Effect.map((text) => text))), Effect.orElseSucceed(Function.constNull), Effect.flatMap((body) => {
|
|
52
49
|
const message = extractErrorMessage(body) ?? `HTTP ${String(response.status)} error`;
|
|
53
50
|
return Effect.fail(new ServiceError({
|
|
54
51
|
message,
|
|
55
52
|
metadata: {
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
body,
|
|
54
|
+
status: response.status
|
|
58
55
|
}
|
|
59
56
|
}));
|
|
60
57
|
}));
|
|
61
58
|
};
|
|
62
|
-
const jsonBody = (body) => HttpBody.
|
|
59
|
+
const jsonBody = (body) => HttpBody.jsonUnsafe(body);
|
|
60
|
+
const urlEncodedBody = (body) => HttpBody.urlParams(UrlParams.fromInput(body));
|
|
63
61
|
|
|
64
62
|
//#endregion
|
|
65
|
-
export { authorizedClient, checkStatus, handleJsonResponse, jsonBody, makeUrl };
|
|
63
|
+
export { authorizedClient, checkStatus, handleJsonResponse, jsonBody, makeUrl, urlEncodedBody };
|