Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/plugins/onepassword/src/api/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,15 @@ const GetConfigResponse = Schema.NullOr(RedactedOnePasswordConfig);
// ---------------------------------------------------------------------------

export const OnePasswordGroup = HttpApiGroup.make("onepassword")
.add(
HttpApiEndpoint.get("listConfigs", "/onepassword/configs", {
success: Schema.Struct({ configs: Schema.Array(RedactedOnePasswordConfig) }),
error: [InternalError, OnePasswordError],
}),
)
.add(
HttpApiEndpoint.get("getConfig", "/onepassword/config", {
query: Schema.Struct({ id: Schema.optional(Schema.String) }),
success: GetConfigResponse,
error: [InternalError, OnePasswordError],
}),
Expand All @@ -66,12 +73,14 @@ export const OnePasswordGroup = HttpApiGroup.make("onepassword")
)
.add(
HttpApiEndpoint.delete("removeConfig", "/onepassword/config", {
query: Schema.Struct({ id: Schema.optional(Schema.String) }),
success: Schema.Void,
error: [InternalError, OnePasswordError],
}),
)
.add(
HttpApiEndpoint.get("status", "/onepassword/status", {
query: Schema.Struct({ id: Schema.optional(Schema.String) }),
success: ConnectionStatus,
error: [InternalError, OnePasswordError],
}),
Expand Down
21 changes: 15 additions & 6 deletions packages/plugins/onepassword/src/api/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,20 @@ export const OnePasswordHandlers = HttpApiBuilder.group(
"onepassword",
(handlers) =>
handlers
.handle("getConfig", () =>
.handle("listConfigs", () =>
capture(
Effect.gen(function* () {
const ext = yield* OnePasswordExtensionService;
return yield* ext.getConfig();
const configs = yield* ext.listConfigs();
return { configs: [...configs] };
}),
),
)
.handle("getConfig", ({ query }) =>
capture(
Effect.gen(function* () {
const ext = yield* OnePasswordExtensionService;
return yield* ext.getConfig(query.id);
}),
),
)
Expand All @@ -58,19 +67,19 @@ export const OnePasswordHandlers = HttpApiBuilder.group(
}),
),
)
.handle("removeConfig", () =>
.handle("removeConfig", ({ query }) =>
capture(
Effect.gen(function* () {
const ext = yield* OnePasswordExtensionService;
yield* ext.removeConfig();
yield* ext.removeConfig(query.id);
}),
),
)
.handle("status", () =>
.handle("status", ({ query }) =>
capture(
Effect.gen(function* () {
const ext = yield* OnePasswordExtensionService;
return yield* ext.status();
return yield* ext.status(query.id);
}),
),
)
Expand Down
Loading
Loading