@herd-labs/sdk 0.3.1 → 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 +5 -5
- 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 +4 -4
- package/dist/src/live/http.js +13 -13
- 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 -51
- package/dist/src/schemas/auth.js +6 -6
- 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 +13 -18
package/dist/src/config.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Context, Schema } from "effect";
|
|
2
|
-
import * as
|
|
2
|
+
import * as effect_Result0 from "effect/Result";
|
|
3
3
|
|
|
4
4
|
//#region src/config.d.ts
|
|
5
|
-
declare const HerdConfigSchema: Schema.
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
declare const HerdConfigSchema: Schema.Result<Schema.Struct<{
|
|
6
|
+
readonly apiKey: Schema.String;
|
|
7
|
+
readonly baseUrl: Schema.String;
|
|
8
8
|
}>, Schema.Struct<{
|
|
9
|
-
baseUrl:
|
|
10
|
-
oauthAccessToken:
|
|
9
|
+
readonly baseUrl: Schema.String;
|
|
10
|
+
readonly oauthAccessToken: Schema.String;
|
|
11
11
|
}>>;
|
|
12
12
|
type HerdConfigType = typeof HerdConfigSchema.Type;
|
|
13
|
-
declare const HerdConfig_base: Context.
|
|
14
|
-
readonly baseUrl: string;
|
|
13
|
+
declare const HerdConfig_base: Context.ServiceClass<HerdConfig, "HerdConfig", effect_Result0.Result<{
|
|
15
14
|
readonly apiKey: string;
|
|
15
|
+
readonly baseUrl: string;
|
|
16
16
|
}, {
|
|
17
17
|
readonly baseUrl: string;
|
|
18
18
|
readonly oauthAccessToken: string;
|
package/dist/src/config.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { Context, Schema } from "effect";
|
|
2
2
|
|
|
3
3
|
//#region src/config.ts
|
|
4
|
-
const HerdConfigSchema = Schema.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})
|
|
13
|
-
});
|
|
14
|
-
var HerdConfig = class extends Context.Tag("HerdConfig")() {};
|
|
4
|
+
const HerdConfigSchema = Schema.Result(Schema.Struct({
|
|
5
|
+
apiKey: Schema.String,
|
|
6
|
+
baseUrl: Schema.String
|
|
7
|
+
}), Schema.Struct({
|
|
8
|
+
baseUrl: Schema.String,
|
|
9
|
+
oauthAccessToken: Schema.String
|
|
10
|
+
}));
|
|
11
|
+
var HerdConfig = class extends Context.Service()("HerdConfig") {};
|
|
15
12
|
|
|
16
13
|
//#endregion
|
|
17
14
|
export { HerdConfig, HerdConfigSchema };
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -1,57 +1,42 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
import * as effect_Cause0 from "effect/Cause";
|
|
2
3
|
|
|
3
4
|
//#region src/errors.d.ts
|
|
4
|
-
declare const ServiceError_base: Schema.
|
|
5
|
-
readonly
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
metadata: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
9
|
-
}>;
|
|
5
|
+
declare const ServiceError_base: Schema.Class<ServiceError, Schema.TaggedStruct<"ServiceError", {
|
|
6
|
+
readonly message: Schema.String;
|
|
7
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
8
|
+
}>, effect_Cause0.YieldableError>;
|
|
10
9
|
declare class ServiceError extends ServiceError_base {}
|
|
11
|
-
declare const ActionNotFoundError_base: Schema.
|
|
12
|
-
readonly
|
|
13
|
-
}
|
|
14
|
-
id: typeof Schema.String;
|
|
15
|
-
}>;
|
|
10
|
+
declare const ActionNotFoundError_base: Schema.Class<ActionNotFoundError, Schema.TaggedStruct<"ActionNotFoundError", {
|
|
11
|
+
readonly id: Schema.String;
|
|
12
|
+
}>, effect_Cause0.YieldableError>;
|
|
16
13
|
declare class ActionNotFoundError extends ActionNotFoundError_base {}
|
|
17
|
-
declare const CodeBlockNotFoundError_base: Schema.
|
|
18
|
-
readonly
|
|
19
|
-
}
|
|
20
|
-
id: typeof Schema.String;
|
|
21
|
-
}>;
|
|
14
|
+
declare const CodeBlockNotFoundError_base: Schema.Class<CodeBlockNotFoundError, Schema.TaggedStruct<"CodeBlockNotFoundError", {
|
|
15
|
+
readonly id: Schema.String;
|
|
16
|
+
}>, effect_Cause0.YieldableError>;
|
|
22
17
|
declare class CodeBlockNotFoundError extends CodeBlockNotFoundError_base {}
|
|
23
|
-
declare const CollectionNotFoundError_base: Schema.
|
|
24
|
-
readonly
|
|
25
|
-
}
|
|
26
|
-
id: typeof Schema.String;
|
|
27
|
-
}>;
|
|
18
|
+
declare const CollectionNotFoundError_base: Schema.Class<CollectionNotFoundError, Schema.TaggedStruct<"CollectionNotFoundError", {
|
|
19
|
+
readonly id: Schema.String;
|
|
20
|
+
}>, effect_Cause0.YieldableError>;
|
|
28
21
|
declare class CollectionNotFoundError extends CollectionNotFoundError_base {}
|
|
29
|
-
declare const TransactionNotFoundError_base: Schema.
|
|
30
|
-
readonly
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
blockchain: typeof Schema.String;
|
|
34
|
-
}>;
|
|
22
|
+
declare const TransactionNotFoundError_base: Schema.Class<TransactionNotFoundError, Schema.TaggedStruct<"TransactionNotFoundError", {
|
|
23
|
+
readonly blockchain: Schema.String;
|
|
24
|
+
readonly txHash: Schema.String;
|
|
25
|
+
}>, effect_Cause0.YieldableError>;
|
|
35
26
|
declare class TransactionNotFoundError extends TransactionNotFoundError_base {}
|
|
36
|
-
declare const DocNotFoundError_base: Schema.
|
|
37
|
-
readonly
|
|
38
|
-
}
|
|
39
|
-
docId: typeof Schema.String;
|
|
40
|
-
}>;
|
|
27
|
+
declare const DocNotFoundError_base: Schema.Class<DocNotFoundError, Schema.TaggedStruct<"DocNotFoundError", {
|
|
28
|
+
readonly docId: Schema.String;
|
|
29
|
+
}>, effect_Cause0.YieldableError>;
|
|
41
30
|
declare class DocNotFoundError extends DocNotFoundError_base {}
|
|
42
|
-
declare const AuthError_base: Schema.
|
|
43
|
-
readonly
|
|
44
|
-
}
|
|
45
|
-
message: typeof Schema.String;
|
|
46
|
-
}>;
|
|
31
|
+
declare const AuthError_base: Schema.Class<AuthError, Schema.TaggedStruct<"AuthError", {
|
|
32
|
+
readonly message: Schema.String;
|
|
33
|
+
}>, effect_Cause0.YieldableError>;
|
|
47
34
|
declare class AuthError extends AuthError_base {}
|
|
48
|
-
declare const SimulationError_base: Schema.
|
|
49
|
-
readonly
|
|
50
|
-
|
|
51
|
-
name:
|
|
52
|
-
|
|
53
|
-
hint: Schema.optional<typeof Schema.String>;
|
|
54
|
-
}>;
|
|
35
|
+
declare const SimulationError_base: Schema.Class<SimulationError, Schema.TaggedStruct<"SimulationError", {
|
|
36
|
+
readonly hint: Schema.optional<Schema.String>;
|
|
37
|
+
readonly message: Schema.String;
|
|
38
|
+
readonly name: Schema.String;
|
|
39
|
+
}>, effect_Cause0.YieldableError>;
|
|
55
40
|
declare class SimulationError extends SimulationError_base {}
|
|
56
41
|
declare const ensureServiceError: (fallbackMessage: string) => (error: unknown) => ServiceError;
|
|
57
42
|
//#endregion
|
package/dist/src/errors.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.ts
|
|
4
|
-
var ServiceError = class extends Schema.
|
|
4
|
+
var ServiceError = class extends Schema.TaggedErrorClass()("ServiceError", {
|
|
5
5
|
message: Schema.String,
|
|
6
|
-
metadata: Schema.Record(
|
|
7
|
-
key: Schema.String,
|
|
8
|
-
value: Schema.Unknown
|
|
9
|
-
})
|
|
6
|
+
metadata: Schema.Record(Schema.String, Schema.Unknown)
|
|
10
7
|
}) {};
|
|
11
|
-
var ActionNotFoundError = class extends Schema.
|
|
12
|
-
var CodeBlockNotFoundError = class extends Schema.
|
|
13
|
-
var CollectionNotFoundError = class extends Schema.
|
|
14
|
-
var TransactionNotFoundError = class extends Schema.
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
var ActionNotFoundError = class extends Schema.TaggedErrorClass()("ActionNotFoundError", { id: Schema.String }) {};
|
|
9
|
+
var CodeBlockNotFoundError = class extends Schema.TaggedErrorClass()("CodeBlockNotFoundError", { id: Schema.String }) {};
|
|
10
|
+
var CollectionNotFoundError = class extends Schema.TaggedErrorClass()("CollectionNotFoundError", { id: Schema.String }) {};
|
|
11
|
+
var TransactionNotFoundError = class extends Schema.TaggedErrorClass()("TransactionNotFoundError", {
|
|
12
|
+
blockchain: Schema.String,
|
|
13
|
+
txHash: Schema.String
|
|
17
14
|
}) {};
|
|
18
|
-
var DocNotFoundError = class extends Schema.
|
|
19
|
-
var AuthError = class extends Schema.
|
|
20
|
-
var SimulationError = class extends Schema.
|
|
21
|
-
|
|
15
|
+
var DocNotFoundError = class extends Schema.TaggedErrorClass()("DocNotFoundError", { docId: Schema.String }) {};
|
|
16
|
+
var AuthError = class extends Schema.TaggedErrorClass()("AuthError", { message: Schema.String }) {};
|
|
17
|
+
var SimulationError = class extends Schema.TaggedErrorClass()("SimulationError", {
|
|
18
|
+
hint: Schema.optional(Schema.String),
|
|
22
19
|
message: Schema.String,
|
|
23
|
-
|
|
20
|
+
name: Schema.String
|
|
24
21
|
}) {};
|
|
25
22
|
const ensureServiceError = (fallbackMessage) => (error) => {
|
|
26
23
|
if (error instanceof ServiceError) return error;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { ActionsService } from "../services/ActionsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient0 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/ActionsServiceLive.d.ts
|
|
7
|
-
declare const ActionsServiceLive: Layer.Layer<ActionsService, never, HerdConfig |
|
|
7
|
+
declare const ActionsServiceLive: Layer.Layer<ActionsService, never, HerdConfig | effect_unstable_http_HttpClient0.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { ActionsServiceLive };
|
|
@@ -3,31 +3,31 @@ import { Action, ActionVersionsResponse, ActionsSearchResponse, CreateActionResp
|
|
|
3
3
|
import { ActionsService } from "../services/ActionsService.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/ActionsServiceLive.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 ActionNotFoundError({ id }));
|
|
11
11
|
return Effect.fail(error);
|
|
12
12
|
});
|
|
13
13
|
const ActionsServiceLive = Layer.effect(ActionsService, Effect.gen(function* () {
|
|
14
14
|
const { baseUrl, client } = yield* authorizedClient;
|
|
15
15
|
return {
|
|
16
|
+
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions"), { body: jsonBody({
|
|
17
|
+
...params,
|
|
18
|
+
expressionType: "action"
|
|
19
|
+
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateActionResponse)), Effect.mapError(ensureServiceError("Failed to create action"))),
|
|
20
|
+
delete: (id) => pipe(client.del(makeUrl(baseUrl, `/v1/actions/${id}`)), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to delete action")), mapNotFound(id)),
|
|
16
21
|
get: (id, options) => pipe(client.get(makeUrl(baseUrl, `/v1/actions/${id}`, options?.includeReferences === true ? { includeReferences: "true" } : void 0)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(Action)), Effect.mapError(ensureServiceError("Failed to get action")), mapNotFound(id)),
|
|
17
22
|
getVersions: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/versions"), { body: jsonBody({
|
|
18
23
|
actionIds: params.actionIds,
|
|
19
24
|
latest: params.latest
|
|
20
25
|
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ActionVersionsResponse)), Effect.mapError(ensureServiceError("Failed to get action versions"))),
|
|
26
|
+
publishExpression: (id, expressionId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/${id}/expressions/${expressionId}/publish`), { body: jsonBody(params ?? {}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(PublishExpressionResponse)), Effect.mapError(ensureServiceError("Failed to publish expression")), mapNotFound(id)),
|
|
21
27
|
search: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/query"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ActionsSearchResponse)), Effect.mapError(ensureServiceError("Failed to search actions"))),
|
|
22
28
|
searchRelatedAdapters: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/related-adapters/query"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(RelatedAdaptersResponse)), Effect.mapError(ensureServiceError("Failed to search related adapters"))),
|
|
23
|
-
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions"), { body: jsonBody({
|
|
24
|
-
...params,
|
|
25
|
-
expressionType: "action"
|
|
26
|
-
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateActionResponse)), Effect.mapError(ensureServiceError("Failed to create action"))),
|
|
27
|
-
updateMetadata: (id, params) => pipe(client.patch(makeUrl(baseUrl, `/v1/actions/${id}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update action metadata")), mapNotFound(id)),
|
|
28
29
|
updateExpression: (id, expressionId, params) => pipe(client.put(makeUrl(baseUrl, `/v1/actions/${id}/expressions/${expressionId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update expression")), mapNotFound(id)),
|
|
29
|
-
|
|
30
|
-
delete: (id) => pipe(client.del(makeUrl(baseUrl, `/v1/actions/${id}`)), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to delete action")), mapNotFound(id))
|
|
30
|
+
updateMetadata: (id, params) => pipe(client.patch(makeUrl(baseUrl, `/v1/actions/${id}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update action metadata")), mapNotFound(id))
|
|
31
31
|
};
|
|
32
32
|
}));
|
|
33
33
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { AdaptersService } from "../services/AdaptersService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient1 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/AdaptersServiceLive.d.ts
|
|
7
|
-
declare const AdaptersServiceLive: Layer.Layer<AdaptersService, never, HerdConfig |
|
|
7
|
+
declare const AdaptersServiceLive: Layer.Layer<AdaptersService, never, HerdConfig | effect_unstable_http_HttpClient1.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { AdaptersServiceLive };
|
|
@@ -3,25 +3,25 @@ import { Action, CreateActionResponse, PublishExpressionResponse } from "../sche
|
|
|
3
3
|
import { AdaptersService } from "../services/AdaptersService.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/AdaptersServiceLive.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 ActionNotFoundError({ id }));
|
|
11
11
|
return Effect.fail(error);
|
|
12
12
|
});
|
|
13
13
|
const AdaptersServiceLive = Layer.effect(AdaptersService, Effect.gen(function* () {
|
|
14
14
|
const { baseUrl, client } = yield* authorizedClient;
|
|
15
15
|
return {
|
|
16
|
-
get: (id) => pipe(client.get(makeUrl(baseUrl, `/v1/actions/${id}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(Action)), Effect.mapError(ensureServiceError("Failed to get adapter")), mapNotFound(id)),
|
|
17
16
|
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions"), { body: jsonBody({
|
|
18
17
|
...params,
|
|
19
18
|
expressionType: "adapter"
|
|
20
19
|
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateActionResponse)), Effect.mapError(ensureServiceError("Failed to create adapter"))),
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
delete: (id) => pipe(client.del(makeUrl(baseUrl, `/v1/actions/${id}`)), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to delete adapter")), mapNotFound(id)),
|
|
21
|
+
get: (id) => pipe(client.get(makeUrl(baseUrl, `/v1/actions/${id}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(Action)), Effect.mapError(ensureServiceError("Failed to get adapter")), mapNotFound(id)),
|
|
23
22
|
publishExpression: (id, expressionId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/${id}/expressions/${expressionId}/publish`), { body: jsonBody(params ?? {}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(PublishExpressionResponse)), Effect.mapError(ensureServiceError("Failed to publish adapter expression")), mapNotFound(id)),
|
|
24
|
-
|
|
23
|
+
updateExpression: (id, expressionId, params) => pipe(client.put(makeUrl(baseUrl, `/v1/actions/${id}/expressions/${expressionId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update adapter expression")), mapNotFound(id)),
|
|
24
|
+
updateMetadata: (id, params) => pipe(client.patch(makeUrl(baseUrl, `/v1/actions/${id}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update adapter metadata")), mapNotFound(id))
|
|
25
25
|
};
|
|
26
26
|
}));
|
|
27
27
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { AgentSafesService } from "../services/AgentSafesService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient2 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/AgentSafesServiceLive.d.ts
|
|
7
|
-
declare const AgentSafesServiceLive: Layer.Layer<AgentSafesService, never, HerdConfig |
|
|
7
|
+
declare const AgentSafesServiceLive: Layer.Layer<AgentSafesService, never, HerdConfig | effect_unstable_http_HttpClient2.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { AgentSafesServiceLive };
|
|
@@ -3,15 +3,15 @@ import { AgentSafe, AgentSafeMetadata, SetSafeProposerResponse } from "../schema
|
|
|
3
3
|
import { AgentSafesService } from "../services/AgentSafesService.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/AgentSafesServiceLive.ts
|
|
9
9
|
const AgentSafesServiceLive = Layer.effect(AgentSafesService, Effect.gen(function* () {
|
|
10
10
|
const { baseUrl, client } = yield* authorizedClient;
|
|
11
11
|
return {
|
|
12
|
+
editAgentSafeMetadata: (blockchain, safeAddress, params) => pipe(client.patch(makeUrl(baseUrl, `/v1/agent-safes/${blockchain}/${safeAddress}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(AgentSafeMetadata)), Effect.mapError(ensureServiceError("Failed to edit agent Safe metadata"))),
|
|
12
13
|
getAgentSafe: (blockchain, safeAddress) => pipe(client.get(makeUrl(baseUrl, `/v1/agent-safes/${blockchain}/${safeAddress}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(AgentSafe)), Effect.mapError(ensureServiceError("Failed to get agent Safe"))),
|
|
13
|
-
setSafeProposer: (blockchain, safeAddress, params) => pipe(client.post(makeUrl(baseUrl, `/v1/agent-safes/${blockchain}/${safeAddress}/proposers`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(SetSafeProposerResponse)), Effect.mapError(ensureServiceError("Failed to set agent Safe proposer")))
|
|
14
|
-
editAgentSafeMetadata: (blockchain, safeAddress, params) => pipe(client.patch(makeUrl(baseUrl, `/v1/agent-safes/${blockchain}/${safeAddress}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(AgentSafeMetadata)), Effect.mapError(ensureServiceError("Failed to edit agent Safe metadata")))
|
|
14
|
+
setSafeProposer: (blockchain, safeAddress, params) => pipe(client.post(makeUrl(baseUrl, `/v1/agent-safes/${blockchain}/${safeAddress}/proposers`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(SetSafeProposerResponse)), Effect.mapError(ensureServiceError("Failed to set agent Safe proposer")))
|
|
15
15
|
};
|
|
16
16
|
}));
|
|
17
17
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { AgentWalletsService } from "../services/AgentWalletsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient0 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/AgentWalletsServiceLive.d.ts
|
|
7
|
-
declare const AgentWalletsServiceLive: Layer.Layer<AgentWalletsService, never, HerdConfig |
|
|
7
|
+
declare const AgentWalletsServiceLive: Layer.Layer<AgentWalletsService, never, HerdConfig | effect_unstable_http_HttpClient0.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { AgentWalletsServiceLive };
|
|
@@ -3,14 +3,14 @@ import { AgentWalletSafesList, AgentWalletsList } from "../schemas/agent-wallets
|
|
|
3
3
|
import { AgentWalletsService } from "../services/AgentWalletsService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, 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/AgentWalletsServiceLive.ts
|
|
9
9
|
const AgentWalletsServiceLive = Layer.effect(AgentWalletsService, Effect.gen(function* () {
|
|
10
10
|
const { baseUrl, client } = yield* authorizedClient;
|
|
11
11
|
return {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
listAgentWalletSafes: (agentWalletAddress) => pipe(client.get(makeUrl(baseUrl, `/v1/agent-wallets/${agentWalletAddress}/safes`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(AgentWalletSafesList)), Effect.mapError(ensureServiceError("Failed to list agent wallet Safes"))),
|
|
13
|
+
listAgentWallets: (params) => pipe(client.get(makeUrl(baseUrl, "/v1/agent-wallets", { groupId: params?.groupId })), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(AgentWalletsList)), Effect.mapError(ensureServiceError("Failed to list agent wallets")))
|
|
14
14
|
};
|
|
15
15
|
}));
|
|
16
16
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { AgentWorkflowsService } from "../services/AgentWorkflowsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient3 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/AgentWorkflowsServiceLive.d.ts
|
|
7
|
-
declare const AgentWorkflowsServiceLive: Layer.Layer<AgentWorkflowsService, never, HerdConfig |
|
|
7
|
+
declare const AgentWorkflowsServiceLive: Layer.Layer<AgentWorkflowsService, never, HerdConfig | effect_unstable_http_HttpClient3.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { AgentWorkflowsServiceLive };
|
|
@@ -3,14 +3,14 @@ import { AgentWorkflowWithRuns, CreateAgentWorkflowResponse, CreateAgentWorkflow
|
|
|
3
3
|
import { AgentWorkflowNotFoundError, AgentWorkflowRunNotFoundError, AgentWorkflowsService } from "../services/AgentWorkflowsService.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/AgentWorkflowsServiceLive.ts
|
|
9
|
-
const mapWorkflowNotFound = (workflowId) => Effect.
|
|
9
|
+
const mapWorkflowNotFound = (workflowId) => Effect.catch((error) => {
|
|
10
10
|
if (error instanceof ServiceError && error.metadata["status"] === 404) return Effect.fail(new AgentWorkflowNotFoundError(workflowId));
|
|
11
11
|
return Effect.fail(error);
|
|
12
12
|
});
|
|
13
|
-
const mapRunNotFound = (runId) => Effect.
|
|
13
|
+
const mapRunNotFound = (runId) => Effect.catch((error) => {
|
|
14
14
|
if (error instanceof ServiceError && error.metadata["status"] === 404) return Effect.fail(new AgentWorkflowRunNotFoundError(runId));
|
|
15
15
|
return Effect.fail(error);
|
|
16
16
|
});
|
|
@@ -18,18 +18,18 @@ const AgentWorkflowsServiceLive = Layer.effect(AgentWorkflowsService, Effect.gen
|
|
|
18
18
|
const { baseUrl, client } = yield* authorizedClient;
|
|
19
19
|
return {
|
|
20
20
|
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/agent-workflows"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateAgentWorkflowResponse)), Effect.mapError(ensureServiceError("Failed to create agent workflow"))),
|
|
21
|
-
list: (params) => pipe(client.get(makeUrl(baseUrl, "/v1/agent-workflows", {
|
|
22
|
-
groupId: params.groupId,
|
|
23
|
-
type: params.type
|
|
24
|
-
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ListAgentWorkflowsResponse)), Effect.mapError(ensureServiceError("Failed to list agent workflows"))),
|
|
25
|
-
get: (agentWorkflowId) => pipe(client.get(makeUrl(baseUrl, `/v1/agent-workflows/${agentWorkflowId}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(AgentWorkflowWithRuns)), Effect.mapError(ensureServiceError("Failed to get agent workflow")), mapWorkflowNotFound(agentWorkflowId)),
|
|
26
21
|
createRun: (params) => pipe(client.post(makeUrl(baseUrl, `/v1/agent-workflows/${params.agentWorkflowId}/runs`), { body: jsonBody({
|
|
27
22
|
outputs: params.outputs,
|
|
28
23
|
changelog: params.changelog
|
|
29
24
|
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateAgentWorkflowRunResponse)), Effect.mapError(ensureServiceError("Failed to create agent workflow run")), mapWorkflowNotFound(params.agentWorkflowId)),
|
|
30
|
-
|
|
25
|
+
executeSafeTx: (params) => pipe(client.post(makeUrl(baseUrl, `/v1/agent-workflows/runs/${params.agentWorkflowRunId}/push/execute`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ExecuteSafeTxResponse)), Effect.mapError(ensureServiceError("Failed to execute safe transaction")), mapRunNotFound(params.agentWorkflowRunId)),
|
|
26
|
+
get: (agentWorkflowId) => pipe(client.get(makeUrl(baseUrl, `/v1/agent-workflows/${agentWorkflowId}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(AgentWorkflowWithRuns)), Effect.mapError(ensureServiceError("Failed to get agent workflow")), mapWorkflowNotFound(agentWorkflowId)),
|
|
27
|
+
list: (params) => pipe(client.get(makeUrl(baseUrl, "/v1/agent-workflows", {
|
|
28
|
+
groupId: params.groupId,
|
|
29
|
+
type: params.type
|
|
30
|
+
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ListAgentWorkflowsResponse)), Effect.mapError(ensureServiceError("Failed to list agent workflows"))),
|
|
31
31
|
push: (params) => pipe(client.post(makeUrl(baseUrl, `/v1/agent-workflows/runs/${params.agentWorkflowRunId}/push`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(PushAgentWorkflowResponse)), Effect.mapError(ensureServiceError("Failed to push agent workflow")), mapRunNotFound(params.agentWorkflowRunId)),
|
|
32
|
-
|
|
32
|
+
submitDecision: (params) => pipe(client.post(makeUrl(baseUrl, `/v1/agent-workflows/runs/${params.agentWorkflowRunId}/decisions`), { body: jsonBody({ decision: params.decision }) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(SubmitAgentWorkflowDecisionResponse)), Effect.mapError(ensureServiceError("Failed to submit agent workflow decision")), mapRunNotFound(params.agentWorkflowRunId))
|
|
33
33
|
};
|
|
34
34
|
}));
|
|
35
35
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { AuthService } from "../services/AuthService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient10 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/AuthServiceLive.d.ts
|
|
7
|
-
declare const AuthServiceLive: Layer.Layer<AuthService, never, HerdConfig |
|
|
7
|
+
declare const AuthServiceLive: Layer.Layer<AuthService, never, HerdConfig | effect_unstable_http_HttpClient10.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { AuthServiceLive };
|
|
@@ -3,22 +3,22 @@ import { ApiKeyListResponse, CreatedApiKey, TokenResponse, WhoamiResponse } from
|
|
|
3
3
|
import { AuthService } from "../services/AuthService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, jsonBody, makeUrl, urlEncodedBody } 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/AuthServiceLive.ts
|
|
9
9
|
const AuthServiceLive = Layer.effect(AuthService, Effect.gen(function* () {
|
|
10
10
|
const { baseUrl, client } = yield* authorizedClient;
|
|
11
11
|
return {
|
|
12
|
-
|
|
12
|
+
listApiKeys: pipe(client.get(makeUrl(baseUrl, "/v1/api-keys")), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ApiKeyListResponse)), Effect.mapError((error) => new AuthError({ message: String(error) }))),
|
|
13
|
+
provisionApiKey: (name) => pipe(client.post(makeUrl(baseUrl, "/v1/api-keys"), { body: jsonBody({ name }) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreatedApiKey)), Effect.mapError((error) => new AuthError({ message: String(error) }))),
|
|
13
14
|
refreshToken: (refreshToken, clientId) => pipe(client.post(makeUrl(baseUrl, "/api/auth/oauth2/token"), { body: urlEncodedBody({
|
|
14
15
|
grant_type: "refresh_token",
|
|
15
16
|
refresh_token: refreshToken,
|
|
16
17
|
client_id: clientId,
|
|
17
18
|
resource: baseUrl
|
|
18
19
|
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(TokenResponse)), Effect.mapError((error) => new AuthError({ message: String(error) }))),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
revokeApiKey: (keyId) => pipe(client.del(makeUrl(baseUrl, `/v1/api-keys/${keyId}`)), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError((error) => new AuthError({ message: String(error) })))
|
|
20
|
+
revokeApiKey: (keyId) => pipe(client.del(makeUrl(baseUrl, `/v1/api-keys/${keyId}`)), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError((error) => new AuthError({ message: String(error) }))),
|
|
21
|
+
whoami: pipe(client.get(makeUrl(baseUrl, "/v1/users/me")), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(WhoamiResponse)), Effect.mapError((error) => new AuthError({ message: String(error) })))
|
|
22
22
|
};
|
|
23
23
|
}));
|
|
24
24
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { BookmarksService } from "../services/BookmarksService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient6 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/BookmarksServiceLive.d.ts
|
|
7
|
-
declare const BookmarksServiceLive: Layer.Layer<BookmarksService, never, HerdConfig |
|
|
7
|
+
declare const BookmarksServiceLive: Layer.Layer<BookmarksService, never, HerdConfig | effect_unstable_http_HttpClient6.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { BookmarksServiceLive };
|
|
@@ -3,13 +3,12 @@ import { BookmarkResponse, BookmarksList } from "../schemas/bookmarks.js";
|
|
|
3
3
|
import { BookmarksService } from "../services/BookmarksService.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/BookmarksServiceLive.ts
|
|
9
9
|
const BookmarksServiceLive = Layer.effect(BookmarksService, Effect.gen(function* () {
|
|
10
10
|
const { baseUrl, client } = yield* authorizedClient;
|
|
11
11
|
return {
|
|
12
|
-
list: (params) => pipe(client.get(makeUrl(baseUrl, "/v1/bookmarks", { objectTypes: params?.objectTypes?.join(",") })), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(BookmarksList)), Effect.mapError(ensureServiceError("Failed to list bookmarks"))),
|
|
13
12
|
addContract: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/bookmarks"), { body: jsonBody({
|
|
14
13
|
objectType: "contract",
|
|
15
14
|
contractAddress: params.address,
|
|
@@ -18,7 +17,7 @@ const BookmarksServiceLive = Layer.effect(BookmarksService, Effect.gen(function*
|
|
|
18
17
|
savedFunctions: [],
|
|
19
18
|
savedEvents: []
|
|
20
19
|
},
|
|
21
|
-
...params.label
|
|
20
|
+
...params.label === void 0 ? {} : { userLabel: params.label }
|
|
22
21
|
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(BookmarkResponse)), Effect.mapError(ensureServiceError("Failed to add contract bookmark"))),
|
|
23
22
|
addTransaction: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/bookmarks"), { body: jsonBody({
|
|
24
23
|
objectType: "transaction",
|
|
@@ -28,29 +27,30 @@ const BookmarksServiceLive = Layer.effect(BookmarksService, Effect.gen(function*
|
|
|
28
27
|
savedFunctions: [],
|
|
29
28
|
savedEvents: []
|
|
30
29
|
},
|
|
31
|
-
...params.label
|
|
30
|
+
...params.label === void 0 ? {} : { userLabel: params.label }
|
|
32
31
|
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(BookmarkResponse)), Effect.mapError(ensureServiceError("Failed to add transaction bookmark"))),
|
|
33
32
|
addWallet: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/bookmarks"), { body: jsonBody({
|
|
34
33
|
objectType: "wallet",
|
|
35
34
|
walletAddress: params.address,
|
|
36
35
|
details: {},
|
|
37
|
-
...params.label
|
|
36
|
+
...params.label === void 0 ? {} : { userLabel: params.label }
|
|
38
37
|
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(BookmarkResponse)), Effect.mapError(ensureServiceError("Failed to add wallet bookmark"))),
|
|
39
|
-
|
|
38
|
+
delete: (params) => pipe(client.del(makeUrl(baseUrl, "/v1/bookmarks"), { body: jsonBody({
|
|
40
39
|
objectType: params.objectType,
|
|
41
|
-
...params.address
|
|
40
|
+
...params.address === void 0 ? {} : { contractAddress: params.address },
|
|
42
41
|
...params.address !== void 0 && params.objectType === "wallet" ? { walletAddress: params.address } : {},
|
|
43
|
-
...params.txHash
|
|
44
|
-
...params.blockchain
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
...params.txHash === void 0 ? {} : { transactionHash: params.txHash },
|
|
43
|
+
...params.blockchain === void 0 ? {} : { blockchain: params.blockchain }
|
|
44
|
+
}) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to delete bookmark"))),
|
|
45
|
+
list: (params) => pipe(client.get(makeUrl(baseUrl, "/v1/bookmarks", { objectTypes: params?.objectTypes?.join(",") })), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(BookmarksList)), Effect.mapError(ensureServiceError("Failed to list bookmarks"))),
|
|
46
|
+
updateLabel: (params) => pipe(client.patch(makeUrl(baseUrl, "/v1/bookmarks/label"), { body: jsonBody({
|
|
48
47
|
objectType: params.objectType,
|
|
49
|
-
...params.address
|
|
48
|
+
...params.address === void 0 ? {} : { contractAddress: params.address },
|
|
50
49
|
...params.address !== void 0 && params.objectType === "wallet" ? { walletAddress: params.address } : {},
|
|
51
|
-
...params.txHash
|
|
52
|
-
...params.blockchain
|
|
53
|
-
|
|
50
|
+
...params.txHash === void 0 ? {} : { transactionHash: params.txHash },
|
|
51
|
+
...params.blockchain === void 0 ? {} : { blockchain: params.blockchain },
|
|
52
|
+
userLabel: params.label
|
|
53
|
+
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(BookmarkResponse)), Effect.mapError(ensureServiceError("Failed to update bookmark label")))
|
|
54
54
|
};
|
|
55
55
|
}));
|
|
56
56
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HerdConfig } from "../config.js";
|
|
2
2
|
import { CodeBlocksService } from "../services/CodeBlocksService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient8 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/CodeBlocksServiceLive.d.ts
|
|
7
|
-
declare const CodeBlocksServiceLive: Layer.Layer<CodeBlocksService, never, HerdConfig |
|
|
7
|
+
declare const CodeBlocksServiceLive: Layer.Layer<CodeBlocksService, never, HerdConfig | effect_unstable_http_HttpClient8.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { CodeBlocksServiceLive };
|