Skip to content

Commit

Permalink
Merge branch 'next' into T-23230/js-action-add-missing-account-mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
juangm committed Dec 12, 2024
2 parents 21689e9 + bb4fbe5 commit ac6bdeb
Show file tree
Hide file tree
Showing 22 changed files with 990 additions and 14 deletions.
44 changes: 44 additions & 0 deletions packages/client/src/actions/accountManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ import type {
AccountManagersRequest,
AddAccountManagerRequest,
AddAccountManagerResult,
HideManagedAccountRequest,
RemoveAccountManagerRequest,
RemoveAccountManagerResult,
UnhideManagedAccountRequest,
UpdateAccountManagerRequest,
UpdateAccountManagerResult,
} from '@lens-protocol/graphql';
import {
AccountManagersQuery,
AddAccountManagerMutation,
HideManagedAccountMutation,
RemoveAccountManagerMutation,
UnhideManagedAccountMutation,
UpdateAccountManagerMutation,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';
Expand Down Expand Up @@ -103,3 +107,43 @@ export function updateAccountManager(
): ResultAsync<UpdateAccountManagerResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(UpdateAccountManagerMutation, { request });
}

/**
* Hide a managed account.
*
* ```ts
* const result = await muteAccount(sessionClient, {
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1");
* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns void.
*/
export function hideManagedAccount(
client: SessionClient,
request: HideManagedAccountRequest,
): ResultAsync<void, UnexpectedError | UnauthenticatedError> {
return client.mutation(HideManagedAccountMutation, { request });
}

/**
* Unhide a managed account.
*
* ```ts
* const result = await unhideManagedAccount(sessionClient, {
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1");
* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns void.
*/
export function unhideManagedAccount(
client: SessionClient,
request: UnhideManagedAccountRequest,
): ResultAsync<void, UnexpectedError | UnauthenticatedError> {
return client.mutation(UnhideManagedAccountMutation, { request });
}
53 changes: 53 additions & 0 deletions packages/client/src/actions/admins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type {
AddAdminsRequest,
AddAdminsResult,
RemoveAdminsRequest,
RemoveAdminsResult,
} from '@lens-protocol/graphql';
import { AddAdminsMutation, RemoveAdminsMutation } from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';

/**
* Add Admins
*
* ```ts
* const result = await addAdmins(sessionClient{
* admins: [evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5')],
* address: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* });
* ```
*
* @param client - The session client logged as a builder.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function addAdmins(
client: SessionClient,
request: AddAdminsRequest,
): ResultAsync<AddAdminsResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(AddAdminsMutation, { request });
}

/**
* Remove admins
*
* ```ts
* const result = await removeAdmins(sessionClient{
* admins: [evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5')],
* address: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function removeAdmins(
client: SessionClient,
request: RemoveAdminsRequest,
): ResultAsync<RemoveAdminsResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(RemoveAdminsMutation, { request });
}
24 changes: 24 additions & 0 deletions packages/client/src/actions/feed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { CreateFeedRequest, CreateFeedResult } from '@lens-protocol/graphql';
import { CreateFeedMutation } from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';

/**
* Create a Feed
*
* ```ts
* const result = await createFeed(sessionClient);
* ```
*
* @param client - The session client logged as a builder.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function createFeed(
client: SessionClient,
request: CreateFeedRequest,
): ResultAsync<CreateFeedResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(CreateFeedMutation, { request });
}
24 changes: 24 additions & 0 deletions packages/client/src/actions/graph.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { CreateGraphRequest, CreateGraphResult } from '@lens-protocol/graphql';
import { CreateGraphMutation } from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';

/**
* Create a Graph
*
* ```ts
* const result = await createGraph(sessionClient);
* ```
*
* @param client - The session client logged as a builder.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function createGraph(
client: SessionClient,
request: CreateGraphRequest,
): ResultAsync<CreateGraphResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(CreateGraphMutation, { request });
}
71 changes: 71 additions & 0 deletions packages/client/src/actions/group.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import type {
CreateGroupRequest,
CreateGroupResult,
JoinGroupRequest,
JoinGroupResult,
LeaveGroupRequest,
LeaveGroupResult,
} from '@lens-protocol/graphql';
import { CreateGroupMutation, JoinGroupMutation, LeaveGroupMutation } from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';

/**
* Create a Group
*
* ```ts
* const result = await createGroup(sessionClient);
* ```
*
* @param client - The session client logged as a builder.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function createGroup(
client: SessionClient,
request: CreateGroupRequest,
): ResultAsync<CreateGroupResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(CreateGroupMutation, { request });
}

/**
* Join a Group
*
* ```ts
* const result = await joinGroup(sessionClient, {
* group: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function joinGroup(
client: SessionClient,
request: JoinGroupRequest,
): ResultAsync<JoinGroupResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(JoinGroupMutation, { request });
}

/**
* Leave a Group
*
* ```ts
* const result = await leaveGroup(sessionClient, {
* group: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function leaveGroup(
client: SessionClient,
request: LeaveGroupRequest,
): ResultAsync<LeaveGroupResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(LeaveGroupMutation, { request });
}
9 changes: 8 additions & 1 deletion packages/client/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
export * from './account';
export * from './admins';
export * from './app';
export * from './authentication';
export * from './feed';
export * from './follow';
export * from './health';
export * from './graph';
export * from './namespace';
export * from './group';
export * from './post';
export * from './posts';
export * from './transactions';
export * from './timeline';
export * from './transactions';
export * from './username';
30 changes: 30 additions & 0 deletions packages/client/src/actions/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type {
CreateUsernameNamespaceRequest,
CreateUsernameNamespaceResult,
} from '@lens-protocol/graphql';
import { CreateUsernameNamespaceMutation } from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';

/**
* Create a Namespace
*
* ```ts
* const result = await createUsernameNamespace(sessionClient, {
* symbol: 'NAME',
* namespace: 'custom-namespace',
* });
* ```
*
* @param client - The session client logged as a builder.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function createUsernameNamespace(
client: SessionClient,
request: CreateUsernameNamespaceRequest,
): ResultAsync<CreateUsernameNamespaceResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(CreateUsernameNamespaceMutation, { request });
}
67 changes: 67 additions & 0 deletions packages/client/src/actions/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@ import type {
DeletePostRequest,
DeletePostResult,
EditPostRequest,
HideReplyRequest,
PostResult,
UndoBookmarkPostRequest,
UndoReactionRequest,
UndoReactionResult,
UnhideReplyRequest,
} from '@lens-protocol/graphql';
import {
AddReactionMutation,
BookmarkPostMutation,
DeletePostMutation,
EditPostMutation,
HideReplyMutation,
PostMutation,
ReportPostMutation,
RepostMutation,
UndoBookmarkPostMutation,
UndoReactionMutation,
UnhideReplyMutation,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { ReportPostRequest } from '@lens-protocol/graphql';
import type { SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';

Expand Down Expand Up @@ -189,3 +195,64 @@ export function undoBookmarkPost(
): ResultAsync<void, UnauthenticatedError | UnexpectedError> {
return client.mutation(UndoBookmarkPostMutation, { request });
}

/**
* Hide a reply.
*
* ```ts
* const result = await hideReply(sessionClient, {
* post: post.id,
* });
* ```
*
* @param client - The session client.
* @param request - The mutation request.
* @returns void
*/
export function hideReply(
client: SessionClient,
request: HideReplyRequest,
): ResultAsync<void, UnauthenticatedError | UnexpectedError> {
return client.mutation(HideReplyMutation, { request });
}

/**
* Unhide a reply.
*
* ```ts
* const result = await unhideReply(sessionClient, {
* post: post.id,
* });
* ```
*
* @param client - The session client.
* @param request - The mutation request.
* @returns void
*/
export function unhideReply(
client: SessionClient,
request: UnhideReplyRequest,
): ResultAsync<void, UnauthenticatedError | UnexpectedError> {
return client.mutation(UnhideReplyMutation, { request });
}

/**
* Report a post
*
* ```ts
* const result = await reportPost(sessionClient, {
* reason: "SCAM",
* post: post.id,
* });
* ```
*
* @param client - The session client.
* @param request - The mutation request.
* @returns void
*/
export function reportPost(
client: SessionClient,
request: ReportPostRequest,
): ResultAsync<void, UnauthenticatedError | UnexpectedError> {
return client.mutation(ReportPostMutation, { request });
}
2 changes: 1 addition & 1 deletion packages/client/src/actions/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function fetchTimeline(
}

/**
* Fetch fetchTimelineHighlights from an account.
* Fetch Timeline Highlights for an account.
*
* ```ts
* const result = await fetchTimelineHighlights(anyClient, {
Expand Down
Loading

0 comments on commit ac6bdeb

Please sign in to comment.