New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lens-protocol/api-bindings

Package Overview
Dependencies
Maintainers
9
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lens-protocol/api-bindings - npm Package Compare versions

Comparing version

to
0.4.0

dist/apollo/__tests__/LensApolloClient.spec.d.ts

14

dist/apollo/__helpers__/mocks.d.ts

@@ -1,4 +0,6 @@

import { ApolloCache, ApolloClient, NormalizedCacheObject, ReactiveVar } from '@apollo/client';
import { ApolloCache, NormalizedCacheObject, ReactiveVar } from '@apollo/client';
import { MockedResponse } from '@apollo/client/testing';
import { WalletData } from '@lens-protocol/domain/use-cases/wallets';
import { DocumentNode, GraphQLError } from 'graphql';
import { LensApolloClient } from '../LensApolloClient';
type MockCacheConfiguration = {

@@ -8,4 +10,12 @@ activeWalletVar?: ReactiveVar<WalletData | null>;

export declare function createMockApolloCache({ activeWalletVar, }?: MockCacheConfiguration): ApolloCache<NormalizedCacheObject>;
export declare function createMockApolloClientWithMultipleResponses(mocks: ReadonlyArray<MockedResponse<unknown>>, cacheConfiguration?: MockCacheConfiguration): ApolloClient<NormalizedCacheObject>;
export declare function createMockApolloClientWithMultipleResponses(mocks: ReadonlyArray<MockedResponse<unknown>>, cacheConfiguration?: MockCacheConfiguration): LensApolloClient<NormalizedCacheObject>;
export declare function createGraphQLError({ code, message, }: {
code: string;
message: string;
}): GraphQLError;
export declare function createGraphQLValidationError(message?: string): GraphQLError;
export declare function createValidationErrorMockedResponse(document: DocumentNode): MockedResponse<unknown>;
export declare function createGenericErrorMockedResponse(document: DocumentNode): MockedResponse<unknown>;
export declare function createUnauthenticatedResponse(): Response;
export {};
//# sourceMappingURL=mocks.d.ts.map

2

dist/apollo/createPublicationsFieldPolicy.d.ts
import { PublicationsQueryRequest } from '../graphql';
export declare function getPublicationsFieldName(request: Pick<PublicationsQueryRequest, 'profileId' | 'publicationTypes' | 'commentsOf' | 'collectedBy'>): string;
export declare function getPublicationsFieldName(request: Pick<PublicationsQueryRequest, 'profileId' | 'publicationTypes' | 'commentsOf' | 'collectedBy' | 'metadata'>): string;
export declare function createPublicationsFieldPolicy(): import("@apollo/client").FieldPolicy<{

@@ -4,0 +4,0 @@ items: import("@apollo/client").StoreValue[];

@@ -1,4 +0,5 @@

import { ApolloClient, ReactiveVar } from '@apollo/client';
import { ReactiveVar } from '@apollo/client';
import { WalletData } from '@lens-protocol/domain/use-cases/wallets';
import { IAccessTokenStorage } from './IAccessTokenStorage';
import { LensApolloClient } from './LensApolloClient';
export type ApolloClientConfig = {

@@ -8,4 +9,5 @@ activeWalletVar: ReactiveVar<WalletData | null>;

backendURL: string;
pollingInterval: number;
};
export declare function createApolloClient({ backendURL, accessTokenStorage, activeWalletVar, }: ApolloClientConfig): ApolloClient<import("@apollo/client").NormalizedCacheObject>;
export declare function createApolloClient({ backendURL, accessTokenStorage, activeWalletVar, pollingInterval, }: ApolloClientConfig): LensApolloClient<import("@apollo/client").NormalizedCacheObject>;
export type AnonymousApolloClientConfig = {

@@ -15,4 +17,7 @@ backendURL: string;

};
export declare function createAnonymousApolloClient({ backendURL, activeWalletVar, }: AnonymousApolloClientConfig): ApolloClient<import("@apollo/client").NormalizedCacheObject>;
export { IAccessTokenStorage };
export declare function createAnonymousApolloClient({ backendURL, activeWalletVar, }: AnonymousApolloClientConfig): LensApolloClient<import("@apollo/client").NormalizedCacheObject>;
export type { IAccessTokenStorage };
export type { IGraphQLClient } from './IGraphQLClient';
export * from './errors';
export type { LensApolloClient };
//# sourceMappingURL=index.d.ts.map

@@ -1,13 +0,17 @@

import { FieldFunctionOptions, FieldPolicy, TypePolicy as UnpatchedTypePolicy } from '@apollo/client';
import { FieldFunctionOptions as UnpatchedFieldFunctionOptions, FieldPolicy as UnpatchedFieldPolicy, TypePolicy as UnpatchedTypePolicy } from '@apollo/client';
import { Overwrite } from '@lens-protocol/shared-kernel';
type TypedFieldFunctionOptions<TAll> = Overwrite<FieldFunctionOptions, {
type FieldFunctionOptions<TAll> = Overwrite<UnpatchedFieldFunctionOptions, {
readField: <T extends keyof NO, O = TAll, NO = NonNullable<O>>(fieldName: T, from?: O) => Readonly<NO[T]> | undefined;
}>;
type TypedFieldReadFunction<TExisting, TAll> = (existing: Readonly<TExisting> | undefined, options: TypedFieldFunctionOptions<TAll>) => TExisting | undefined;
export type FieldReadFunction<TExisting, TAll> = (existing: Readonly<TExisting> | undefined, options: FieldFunctionOptions<TAll>) => TExisting | undefined;
export type FieldPolicy<TExisting, TAll> = Overwrite<UnpatchedFieldPolicy<TExisting>, {
read?: FieldReadFunction<TExisting, TAll>;
}>;
type FieldPolicies<T> = Partial<{
[key in keyof T]: FieldPolicy<T[key], T> | FieldReadFunction<T[key], T>;
}>;
export type TypePolicy<T> = Overwrite<UnpatchedTypePolicy, {
fields?: Partial<{
[key in keyof T]: FieldPolicy<T[key]> | TypedFieldReadFunction<T[key], T>;
}>;
fields?: FieldPolicies<T>;
}>;
export {};
//# sourceMappingURL=TypePolicy.d.ts.map
import { Amount, Erc20 } from '@lens-protocol/shared-kernel';
import { FollowPolicy } from '../FollowPolicy';
import { AttributeFragment, CommentFragment, EnabledModuleFragment, EnabledModulesFragment, Erc20AmountFragment, FeedItemFragment, MediaFragment, MirrorFragment, ModuleInfoFragment, PostFragment, ProfileFragment, ProfileFollowModuleSettings, ProfileFollowRevenueFragment, ProfileMediaFragment, PublicationRevenueFragment, PublicationStatsFragment, RelayerResultFragment, RelayErrorFragment, RelayErrorReasons, RevenueFragment, WalletFragment, WhoReactedResultFragment } from '../generated';
import { AttributeFragment, CommentFragment, EnabledModuleFragment, EnabledModulesFragment, Erc20AmountFragment, FeedItemFragment, MediaFragment, MirrorFragment, ModuleInfoFragment, PostFragment, ProfileFollowModuleSettings, ProfileFollowRevenueFragment, ProfileFragment, ProfileMediaFragment, PublicationRevenueFragment, PublicationStatsFragment, RelayerResultFragment, RelayErrorFragment, RelayErrorReasons, RevenueFragment, WalletFragment, WhoReactedResultFragment } from '../generated';
export declare function mockMediaFragment(overrides?: Partial<MediaFragment>): MediaFragment;

@@ -5,0 +5,0 @@ export declare function mockProfileMediaFragment(overrides?: Partial<ProfileMediaFragment>): ProfileMediaFragment;

import { MockedResponse } from '@apollo/client/testing';
import { Nonce } from '@lens-protocol/domain/entities';
import { AddReactionMutation, AddReactionMutationVariables, BroadcastProtocolCallMutation, BroadcastProtocolCallMutationVariables, CreateCommentTypedDataMutation, CreateFollowTypedDataMutation, CreatePostTypedDataMutation, CreateProfileMutation, CreateSetFollowModuleTypedDataMutation, CreateSetDispatcherTypedDataMutation, CreateUnfollowTypedDataMutation, CreateSetProfileImageUriTypedDataMutation, CreateSetProfileImageUriTypedDataMutationVariables, CreatePublicSetProfileMetadataUriRequest, CreateSetProfileMetadataTypedDataMutation, CreateSetProfileMetadataViaDispatcherMutation, CreateSetProfileMetadataViaDispatcherMutationVariables, HidePublicationMutation, HidePublicationMutationVariables, ProxyActionMutation, ProxyActionMutationVariables, RelayResult, RemoveReactionMutation, RemoveReactionMutationVariables, CreateCommentTypedDataMutationVariables, CreateCommentViaDispatcherMutationVariables, CreateCommentViaDispatcherMutation, CreatePostTypedDataMutationVariables, CreatePostViaDispatcherMutationVariables, CreatePostViaDispatcherMutation, CreateSetProfileImageUriViaDispatcherMutationVariables, CreateSetProfileImageUriViaDispatcherMutation, ReportPublicationMutationVariables, ReportPublicationMutation } from '../generated';
export declare function mockCreateProfileMutation(result: Required<RelayResult>): CreateProfileMutation;
import { AddReactionMutation, AddReactionMutationVariables, BroadcastProtocolCallMutation, BroadcastProtocolCallMutationVariables, CreateCommentTypedDataMutation, CreateFollowTypedDataMutation, CreatePostTypedDataMutation, CreateProfileMutation, CreateSetFollowModuleTypedDataMutation, CreateSetDispatcherTypedDataMutation, CreateUnfollowTypedDataMutation, CreateSetProfileImageUriTypedDataMutation, CreateSetProfileImageUriTypedDataMutationVariables, CreatePublicSetProfileMetadataUriRequest, CreateSetProfileMetadataTypedDataMutation, CreateSetProfileMetadataViaDispatcherMutation, CreateSetProfileMetadataViaDispatcherMutationVariables, HidePublicationMutation, HidePublicationMutationVariables, ProxyActionMutation, ProxyActionMutationVariables, RelayResult, RemoveReactionMutation, RemoveReactionMutationVariables, CreateCommentTypedDataMutationVariables, CreateCommentViaDispatcherMutationVariables, CreateCommentViaDispatcherMutation, CreatePostTypedDataMutationVariables, CreatePostViaDispatcherMutationVariables, CreatePostViaDispatcherMutation, CreateSetProfileImageUriViaDispatcherMutationVariables, CreateSetProfileImageUriViaDispatcherMutation, CreateCollectTypedDataMutation, ReportPublicationMutationVariables, ReportPublicationMutation, CreateProfileMutationVariables } from '../generated';
export declare function createCreateProfileMutationMockedResponse({ request, result, }: {
request: CreateProfileMutationVariables['request'];
result: Required<RelayResult>;
}): MockedResponse<CreateProfileMutation>;
export declare function createBroadcastProtocolCallMutationMockedResponse(instructions: {

@@ -27,5 +30,2 @@ error: Error;

}): MockedResponse<RemoveReactionMutation>;
export declare function createAddReactionMutationWithGraphqlValidationErrorResponse(args: {
variables: AddReactionMutationVariables;
}): MockedResponse<AddReactionMutation>;
export declare function createRemoveReactionMutationWithGraphqlValidationErrorResponse(args: {

@@ -89,8 +89,8 @@ variables: RemoveReactionMutationVariables;

}): MockedResponse<CreateSetProfileImageUriViaDispatcherMutation>;
export declare function mockCreateCollectTypedDataMutation({ nonce, }?: {
nonce?: Nonce;
}): CreateCollectTypedDataMutation;
export declare function createReportPublicationMutationMockedResponse(args: {
variables: ReportPublicationMutationVariables;
}): MockedResponse<ReportPublicationMutation>;
export declare function createReportPublicationMutationWithErrorMockedResponse(args: {
variables: ReportPublicationMutationVariables;
}): MockedResponse<ReportPublicationMutation>;
//# sourceMappingURL=mutations.d.ts.map
import { MockedResponse } from '@apollo/client/testing';
import { ProfileId } from '@lens-protocol/domain/entities';
import { Erc20, EthereumAddress } from '@lens-protocol/shared-kernel';
import { CommentFragment, CommentWithFirstCommentFragment, CommonPaginatedResultInfoFragment, EnabledModuleCurrenciesQuery, EnabledModulesFragment, EnabledModulesQuery, ExplorePublicationsQuery, ExplorePublicationsQueryVariables, FeedItemFragment, FeedQuery, FeedQueryVariables, GetAllProfilesByOwnerAddressQuery, GetProfileQuery, HasTxHashBeenIndexedQuery, HasTxHashBeenIndexedQueryVariables, Maybe, MirrorFragment, MutualFollowersProfilesQuery, MutualFollowersProfilesQueryVariables, PostFragment, ProfileFragment, ProfileFollowRevenueFragment, ProfileFollowRevenueQuery, ProfileFollowRevenueQueryVariables, ProfilePublicationRevenueQuery, ProfilePublicationRevenueQueryVariables, ProfilesToFollowQuery, ProxyActionStatusQuery, ProxyActionStatusQueryVariables, ProxyActionStatusResult, PublicationByTxHashQuery, PublicationQuery, PublicationRevenueFragment, PublicationRevenueQuery, PublicationRevenueQueryVariables, PublicationsQuery, PublicationsQueryVariables, RevenueFragment, SearchProfilesQuery, SearchProfilesQueryVariables, SearchPublicationsQuery, SearchPublicationsQueryVariables, SingleProfileQueryRequest, TransactionErrorReasons, WalletFragment, WhoCollectedPublicationQuery, WhoCollectedPublicationQueryVariables, WhoReactedPublicationQuery, WhoReactedPublicationQueryVariables, WhoReactedResultFragment } from '../generated';
import { CommentFragment, CommentWithFirstCommentFragment, CommonPaginatedResultInfoFragment, EnabledModuleCurrenciesQuery, EnabledModulesFragment, EnabledModulesQuery, ExplorePublicationsQuery, ExplorePublicationsQueryVariables, FeedItemFragment, FeedQuery, FeedQueryVariables, GetAllProfilesByOwnerAddressQuery, GetAllProfilesByWhoMirroredPublicationQueryVariables, GetProfileQuery, HasTxHashBeenIndexedQuery, HasTxHashBeenIndexedQueryVariables, Maybe, MirrorFragment, MutualFollowersProfilesQuery, MutualFollowersProfilesQueryVariables, PostFragment, ProfileFragment, ProfileFollowRevenueFragment, ProfileFollowRevenueQuery, ProfileFollowRevenueQueryVariables, ProfilePublicationRevenueQuery, ProfilePublicationRevenueQueryVariables, ProfilesToFollowQuery, ProxyActionStatusQuery, ProxyActionStatusQueryVariables, ProxyActionStatusResult, PublicationByTxHashQuery, PublicationQuery, PublicationRevenueFragment, PublicationRevenueQuery, PublicationRevenueQueryVariables, PublicationsQuery, PublicationsQueryVariables, RevenueFragment, SearchProfilesQuery, SearchProfilesQueryVariables, SearchPublicationsQuery, SearchPublicationsQueryVariables, SingleProfileQueryRequest, TransactionErrorReasons, WalletFragment, WhoCollectedPublicationQuery, WhoCollectedPublicationQueryVariables, WhoReactedPublicationQuery, WhoReactedPublicationQueryVariables, WhoReactedResultFragment } from '../generated';
export declare function createProfilesToFollowQueryMockedResponse(args: {

@@ -52,3 +52,6 @@ profiles: ProfileFragment[];

export declare function mockFeedQuery({ items, pageInfo, }?: MockFeedQueryArgs): FeedQuery;
export declare function createPublicationQueryMockedResponse(publication: PostFragment): MockedResponse<PublicationQuery>;
export declare function createPublicationQueryMockedResponse({ publicationId, result, }: {
publicationId: string;
result: PostFragment | null;
}): MockedResponse<PublicationQuery>;
export declare function createPublicationsQueryMockedResponse(args: {

@@ -68,3 +71,3 @@ variables: PublicationsQueryVariables;

variables: PublicationRevenueQueryVariables;
revenue: RevenueFragment;
revenue: RevenueFragment | null;
}): MockedResponse<PublicationRevenueQuery>;

@@ -87,2 +90,6 @@ export declare function createProfilePublicationRevenueQueryMockedResponse(args: {

}): MockedResponse<SearchProfilesQuery>;
export declare function createProfilesWhoMirroredPublicationMockedResponse(args: {
variables: GetAllProfilesByWhoMirroredPublicationQueryVariables;
items: ProfileFragment[];
}): MockedResponse<SearchProfilesQuery>;
export declare function createSearchPublicationsQueryMockedResponse(args: {

@@ -89,0 +96,0 @@ variables: SearchPublicationsQueryVariables;

@@ -5,3 +5,4 @@ export * from './generated';

export * from './FollowPolicy';
export * from './CollectPolicy';
export * from './utils';
//# sourceMappingURL=index.d.ts.map
export * from './amount';
export * from './errors';
export * from './isValidHandle';
export * from './omitTypename';
export * from './publication';
export * from './transaction';
export * from './types';
//# sourceMappingURL=index.d.ts.map

@@ -1,13 +0,12 @@

import { PublicationType, ReactionType } from '@lens-protocol/domain/entities';
import { ReactionType } from '@lens-protocol/domain/entities';
import { CollectRequest } from '@lens-protocol/domain/use-cases/publications';
import { Overwrite } from '@lens-protocol/shared-kernel';
import { Comment, CommentFragment, Mirror, MirrorFragment, Post, PostFragment, ProfileFragment, ReactionTypes } from '../generated';
import { Typename, PickByTypename, JustTypename } from './types';
type PublicationTypename = JustTypename<Mirror> | JustTypename<Comment> | JustTypename<Post>;
export declare const isPostPublication: <T extends Typename<string>>(publication: T) => publication is PickByTypename<T, "Post">;
export declare const isCommentPublication: <T extends Typename<string>>(publication: T) => publication is PickByTypename<T, "Comment">;
export declare const isMirrorPublication: <T extends Typename<string>>(publication: T) => publication is PickByTypename<T, "Mirror">;
export declare const getPublicationType: <T extends PublicationTypename>(publication: T) => PublicationType;
export declare const getPublicationTypename: <T extends PublicationType>(publication: T) => PublicationTypename['__typename'];
export declare const getDomainReactionType: (reaction: ReactionTypes) => ReactionType;
export declare const getApiReactionType: (reaction: ReactionType) => ReactionTypes;
import { CollectPolicy } from '../CollectPolicy';
import { CollectModuleFragment, CommentFragment, FeeCollectModuleSettingsFragment, FreeCollectModuleSettingsFragment, LimitedFeeCollectModuleSettingsFragment, LimitedTimedFeeCollectModuleSettingsFragment, MirrorFragment, PostFragment, ProfileFragment, PublicationStatsFragment, ReactionTypes, TimedFeeCollectModuleSettingsFragment } from '../generated';
import { PickByTypename, Typename } from './types';
export declare function isPostPublication<T extends Typename<string>>(publication: T): publication is PickByTypename<T, 'Post'>;
export declare function isCommentPublication<T extends Typename<string>>(publication: T): publication is PickByTypename<T, 'Comment'>;
export declare function isMirrorPublication<T extends Typename<string>>(publication: T): publication is PickByTypename<T, 'Mirror'>;
export declare function getDomainReactionType(reaction: ReactionTypes): ReactionType;
export declare function getApiReactionType(reaction: ReactionType): ReactionTypes;
export type PublicationFragment = PostFragment | CommentFragment | MirrorFragment;

@@ -19,4 +18,13 @@ export type PublicationOwnedByMeFragment = Overwrite<PublicationFragment, {

}>;
export declare const isPublicationOwnedByMe: (publication: PublicationFragment) => publication is PublicationOwnedByMeFragment;
export {};
export declare function isPublicationOwnedByMe(publication: PublicationFragment): publication is PublicationOwnedByMeFragment;
export declare function createCollectRequest(publication: PublicationFragment, collector: ProfileFragment): CollectRequest;
export type CollectableCollectModuleSettingsFragment = FreeCollectModuleSettingsFragment | FeeCollectModuleSettingsFragment | LimitedFeeCollectModuleSettingsFragment | TimedFeeCollectModuleSettingsFragment | LimitedTimedFeeCollectModuleSettingsFragment;
export type PublicationFragmentWithCollectableCollectModule = PublicationFragment & {
collectModule: CollectableCollectModuleSettingsFragment;
};
export declare function resolveCollectPolicy({ profile, collectModule, publicationStats, }: {
collectModule: CollectModuleFragment;
profile: ProfileFragment;
publicationStats: PublicationStatsFragment;
}): CollectPolicy;
//# sourceMappingURL=publication.d.ts.map

@@ -11,2 +11,3 @@ import {

CollectModules,
CollectState,
CommentBaseFragmentDoc,

@@ -19,2 +20,3 @@ CommentFragmentDoc,

ContractType,
CreateCollectTypedDataDocument,
CreateCommentTypedDataDocument,

@@ -57,2 +59,3 @@ CreateCommentViaDispatcherDocument,

GetAllProfilesByOwnerAddressDocument,
GetAllProfilesByWhoMirroredPublicationDocument,
GetProfileDocument,

@@ -62,2 +65,3 @@ HasTxHashBeenIndexedDocument,

IdKitPhoneVerifyWebhookResultStatusType,
LensApolloClient,
LimitedFeeCollectModuleSettingsFragmentDoc,

@@ -143,2 +147,4 @@ LimitedTimedFeeCollectModuleSettingsFragmentDoc,

UnreadNotificationCountDocument,
UnspecifiedError,
ValidationError,
WalletCollectedPublicationsDocument,

@@ -161,2 +167,3 @@ WalletFragmentDoc,

useCommentsQuery,
useCreateCollectTypedDataMutation,
useCreateCommentTypedDataMutation,

@@ -189,2 +196,4 @@ useCreateCommentViaDispatcherMutation,

useGetAllProfilesByOwnerAddressQuery,
useGetAllProfilesByWhoMirroredPublicationLazyQuery,
useGetAllProfilesByWhoMirroredPublicationQuery,
useGetProfileLazyQuery,

@@ -234,15 +243,4 @@ useGetProfileQuery,

useWhoReactedPublicationQuery
} from "./chunk-745PSAJX.js";
} from "./chunk-OLWTIJFY.js";
// src/graphql/utils/errors.ts
import { ApolloError } from "@apollo/client";
function isGraphqlValidationError(e) {
if (e instanceof ApolloError) {
if (e.graphQLErrors[0] && e.graphQLErrors[0].extensions && e.graphQLErrors[0].extensions.code === "GRAPHQL_VALIDATION_FAILED") {
return true;
}
}
return false;
}
// src/graphql/utils/isValidHandle.ts

@@ -261,38 +259,18 @@ var validationRegex = /^[a-z](?:[a-z0-9_]{4,25})$/;

// src/graphql/utils/publication.ts
import { PublicationType, ReactionType } from "@lens-protocol/domain/entities";
import { never } from "@lens-protocol/shared-kernel";
var isPostPublication = (publication) => {
import { ReactionType, TransactionKind } from "@lens-protocol/domain/entities";
import {
CollectPolicyType,
CollectType
} from "@lens-protocol/domain/use-cases/publications";
import { DateUtils, never } from "@lens-protocol/shared-kernel";
function isPostPublication(publication) {
return publication.__typename === "Post";
};
var isCommentPublication = (publication) => {
}
function isCommentPublication(publication) {
return publication.__typename === "Comment";
};
var isMirrorPublication = (publication) => {
}
function isMirrorPublication(publication) {
return publication.__typename === "Mirror";
};
var getPublicationType = (publication) => {
switch (publication.__typename) {
case "Mirror":
return PublicationType.MIRROR;
case "Comment":
return PublicationType.COMMENT;
case "Post":
return PublicationType.POST;
default:
never("Can't infer publication type");
}
};
var getPublicationTypename = (publication) => {
switch (publication) {
case PublicationType.MIRROR:
return "Mirror";
case PublicationType.POST:
return "Post";
case PublicationType.COMMENT:
return "Comment";
default:
never("Can't infer publication typename");
}
};
var getDomainReactionType = (reaction) => {
}
function getDomainReactionType(reaction) {
switch (reaction) {

@@ -306,4 +284,4 @@ case "UPVOTE" /* Upvote */:

}
};
var getApiReactionType = (reaction) => {
}
function getApiReactionType(reaction) {
switch (reaction) {

@@ -317,17 +295,113 @@ case ReactionType.UPVOTE:

}
};
var isPublicationOwnedByMe = (publication) => {
}
function isPublicationOwnedByMe(publication) {
return publication.profile.ownedByMe;
};
// src/graphql/utils/transaction.ts
var isTransactionError = (publication) => {
return publication.__typename === "TransactionError";
};
function isProxyActionError(proxyActionResult) {
return proxyActionResult.__typename === "ProxyActionError";
}
function createCollectRequest(publication, collector) {
switch (publication.__collectModule.__typename) {
case "FreeCollectModuleSettings":
return {
profileId: collector.id,
kind: TransactionKind.COLLECT_PUBLICATION,
publicationId: publication.id,
type: CollectType.FREE
};
case "FeeCollectModuleSettings":
case "LimitedFeeCollectModuleSettings":
case "TimedFeeCollectModuleSettings":
case "LimitedTimedFeeCollectModuleSettings":
return {
profileId: collector.id,
kind: TransactionKind.COLLECT_PUBLICATION,
publicationId: publication.id,
type: CollectType.PAID,
fee: {
amount: erc20Amount({ from: publication.__collectModule.amount }),
contractAddress: publication.__collectModule.contractAddress
}
};
case "RevertCollectModuleSettings":
case "UnknownCollectModuleSettings":
never(
`Cannot collect publication with "${publication.__collectModule.__typename}" collect module`
);
}
}
function resolveTimeLimitReached(collectModule) {
if (DateUtils.unix() > DateUtils.toUnix(collectModule.endTimestamp)) {
return "COLLECT_TIME_EXPIRED" /* COLLECT_TIME_EXPIRED */;
}
return null;
}
function resolveLimitReached(collectModule, publicationStats) {
if (publicationStats.totalAmountOfCollects >= parseInt(collectModule.collectLimit)) {
return "COLLECT_LIMIT_REACHED" /* COLLECT_LIMIT_REACHED */;
}
return null;
}
function resolveNotFollower(collectModule, author) {
if (collectModule.followerOnly && !author.isFollowedByMe) {
return "NOT_A_FOLLOWER" /* NOT_A_FOLLOWER */;
}
return null;
}
function resolveCollectPolicy({
profile,
collectModule,
publicationStats
}) {
switch (collectModule.__typename) {
case "FeeCollectModuleSettings":
return {
type: CollectPolicyType.CHARGE,
state: resolveNotFollower(collectModule, profile) ?? "CAN_BE_COLLECTED" /* CAN_BE_COLLECTED */,
amount: erc20Amount({ from: collectModule.amount }),
referralFee: collectModule.referralFee,
followerOnly: collectModule.followerOnly
};
case "LimitedFeeCollectModuleSettings":
return {
type: CollectPolicyType.CHARGE,
state: resolveNotFollower(collectModule, profile) ?? resolveLimitReached(collectModule, publicationStats) ?? "CAN_BE_COLLECTED" /* CAN_BE_COLLECTED */,
amount: erc20Amount({ from: collectModule.amount }),
referralFee: collectModule.referralFee,
collectLimit: parseInt(collectModule.collectLimit),
followerOnly: collectModule.followerOnly
};
case "TimedFeeCollectModuleSettings":
return {
type: CollectPolicyType.CHARGE,
state: resolveNotFollower(collectModule, profile) ?? resolveTimeLimitReached(collectModule) ?? "CAN_BE_COLLECTED" /* CAN_BE_COLLECTED */,
amount: erc20Amount({ from: collectModule.amount }),
referralFee: collectModule.referralFee,
endTimestamp: collectModule.endTimestamp,
followerOnly: collectModule.followerOnly
};
case "LimitedTimedFeeCollectModuleSettings":
return {
type: CollectPolicyType.CHARGE,
state: resolveNotFollower(collectModule, profile) ?? resolveLimitReached(collectModule, publicationStats) ?? resolveTimeLimitReached(collectModule) ?? "CAN_BE_COLLECTED" /* CAN_BE_COLLECTED */,
amount: erc20Amount({ from: collectModule.amount }),
referralFee: collectModule.referralFee,
collectLimit: parseInt(collectModule.collectLimit),
endTimestamp: collectModule.endTimestamp,
followerOnly: collectModule.followerOnly
};
case "FreeCollectModuleSettings":
return {
type: CollectPolicyType.FREE,
state: resolveNotFollower(collectModule, profile) ?? "CAN_BE_COLLECTED" /* CAN_BE_COLLECTED */,
followerOnly: collectModule.followerOnly
};
case "RevertCollectModuleSettings":
case "UnknownCollectModuleSettings":
return {
type: CollectPolicyType.NO_COLLECT,
state: "CANNOT_BE_COLLECTED" /* CANNOT_BE_COLLECTED */
};
}
}
// src/apollo/index.ts
import { ApolloClient, ApolloLink, from as from2, HttpLink } from "@apollo/client";
import { from as from2, HttpLink } from "@apollo/client";

@@ -360,24 +434,2 @@ // src/apollo/createAuthLink.ts

// src/apollo/transforms.ts
import { visit } from "graphql";
function removeClientTypeFromExtendedUnion(fragmentName, doc) {
function enter(node) {
if (fragmentName === node.name.value) {
return null;
}
}
return visit(doc, {
InlineFragment: {
enter: (node) => {
if (node.typeCondition?.name.value === fragmentName) {
return null;
}
return;
}
},
FragmentSpread: { enter },
FragmentDefinition: { enter }
});
}
// src/apollo/index.ts

@@ -387,9 +439,6 @@ function createApolloClient({

accessTokenStorage,
activeWalletVar
activeWalletVar,
pollingInterval
}) {
const uri = `${backendURL}/graphql`;
const cleanerLink = new ApolloLink((operation, forward) => {
operation.query = removeClientTypeFromExtendedUnion("PendingPost", operation.query);
return forward(operation);
});
const authLink = createAuthLink(accessTokenStorage);

@@ -399,6 +448,6 @@ const httpLink = new HttpLink({

});
return new ApolloClient({
return new LensApolloClient({
cache: createApolloCache({ activeWalletVar }),
link: from2([cleanerLink, authLink, httpLink]),
connectToDevTools: true
link: from2([authLink, httpLink]),
pollingInterval
});

@@ -411,5 +460,5 @@ }

const uri = `${backendURL}/graphql`;
return new ApolloClient({
return new LensApolloClient({
cache: createApolloCache({ activeWalletVar }),
uri
link: new HttpLink({ uri })
});

@@ -427,2 +476,3 @@ }

CollectModules,
CollectState,
CommentBaseFragmentDoc,

@@ -435,2 +485,3 @@ CommentFragmentDoc,

ContractType,
CreateCollectTypedDataDocument,
CreateCommentTypedDataDocument,

@@ -473,2 +524,3 @@ CreateCommentViaDispatcherDocument,

GetAllProfilesByOwnerAddressDocument,
GetAllProfilesByWhoMirroredPublicationDocument,
GetProfileDocument,

@@ -558,2 +610,4 @@ HasTxHashBeenIndexedDocument,

UnreadNotificationCountDocument,
UnspecifiedError,
ValidationError,
WalletCollectedPublicationsDocument,

@@ -567,17 +621,14 @@ WalletFragmentDoc,

createApolloClient,
createCollectRequest,
erc20Amount,
getApiReactionType,
getDomainReactionType,
getPublicationType,
getPublicationTypename,
isCommentPublication,
isGraphqlValidationError,
isMirrorPublication,
isPostPublication,
isProxyActionError,
isPublicationOwnedByMe,
isTransactionError,
isValidHandle,
moduleFeeAmountParams,
omitTypename,
resolveCollectPolicy,
useAddReactionMutation,

@@ -591,2 +642,3 @@ useAuthAuthenticateMutation,

useCommentsQuery,
useCreateCollectTypedDataMutation,
useCreateCommentTypedDataMutation,

@@ -619,2 +671,4 @@ useCreateCommentViaDispatcherMutation,

useGetAllProfilesByOwnerAddressQuery,
useGetAllProfilesByWhoMirroredPublicationLazyQuery,
useGetAllProfilesByWhoMirroredPublicationQuery,
useGetProfileLazyQuery,

@@ -621,0 +675,0 @@ useGetProfileQuery,

@@ -8,2 +8,3 @@ import {

CreatePostViaDispatcherDocument,
CreateProfileDocument,
CreateSetProfileImageUriTypedDataDocument,

@@ -18,5 +19,7 @@ CreateSetProfileImageUriViaDispatcherDocument,

GetAllProfilesByOwnerAddressDocument,
GetAllProfilesByWhoMirroredPublicationDocument,
GetProfileDocument,
HasTxHashBeenIndexedDocument,
HidePublicationDocument,
LensApolloClient,
MutualFollowersProfilesDocument,

@@ -40,3 +43,3 @@ ProfileFollowRevenueDocument,

erc20Amount
} from "./chunk-745PSAJX.js";
} from "./chunk-OLWTIJFY.js";

@@ -47,2 +50,6 @@ // src/graphql/__helpers__/fragments.ts

import { FollowPolicyType } from "@lens-protocol/domain/use-cases/profile";
import {
CollectPolicyType,
ReferencePolicyType
} from "@lens-protocol/domain/use-cases/publications";
import { mockDaiAmount, mockEthereumAddress } from "@lens-protocol/shared-kernel/mocks";

@@ -104,2 +111,17 @@ function mockMediaFragment(overrides) {

dispatcher: null,
onChainIdentity: {
proofOfHumanity: false,
ens: null,
sybilDotOrg: {
verified: false,
source: {
twitter: {
handle: null
}
}
},
worldcoin: {
isHuman: false
}
},
__followModule: null,

@@ -143,2 +165,3 @@ followPolicy: mockAnyoneFollowPolicy(),

totalUpvotes: faker.datatype.number({ max: 42e3, min: 0, precision: 1 }),
totalDownvotes: faker.datatype.number({ max: 42e3, min: 0, precision: 1 }),
...overrides,

@@ -166,2 +189,10 @@ __typename: "PublicationStats"

}
function mockNoFeeCollectPolicy(overrides) {
return {
type: CollectPolicyType.FREE,
state: "CAN_BE_COLLECTED" /* CAN_BE_COLLECTED */,
followerOnly: false,
...overrides
};
}
function mockPostFragment(overrides) {

@@ -175,3 +206,4 @@ return {

collectedBy: null,
collectModule: mockFreeCollectModuleSettings(),
__collectModule: mockFreeCollectModuleSettings(),
collectPolicy: mockNoFeeCollectPolicy(),
referenceModule: null,

@@ -191,2 +223,5 @@ hasCollectedByMe: false,

},
referencePolicy: {
type: ReferencePolicyType.ANYONE
},
...overrides,

@@ -215,3 +250,4 @@ __typename: "Post"

mainPost,
collectModule: mockFreeCollectModuleSettings(),
__collectModule: mockFreeCollectModuleSettings(),
collectPolicy: mockNoFeeCollectPolicy(),
referenceModule: null,

@@ -231,2 +267,5 @@ hasCollectedByMe: false,

},
referencePolicy: {
type: ReferencePolicyType.ANYONE
},
...overrides,

@@ -252,7 +291,6 @@ __typename: "Comment"

createdAt: faker.date.past().toISOString(),
collectModule: mockFreeCollectModuleSettings(),
referenceModule: null,
__collectModule: mockFreeCollectModuleSettings(),
collectPolicy: mockNoFeeCollectPolicy(),
hasCollectedByMe: false,
hasOptimisticCollectedByMe: false,
isOptimisticMirroredByMe: false,
mirrorOf: mainPost,

@@ -262,8 +300,2 @@ reaction: null,

isGated: false,
canComment: {
result: true
},
canMirror: {
result: true
},
...overrides,

@@ -580,14 +612,13 @@ __typename: "Mirror"

}
function createPublicationQueryMockedResponse(publication) {
function createPublicationQueryMockedResponse({
publicationId,
result
}) {
return {
request: {
query: PublicationDocument,
variables: {
publicationId: publication.id
}
variables: { publicationId }
},
result: {
data: {
result: publication
}
data: { result }
}

@@ -752,2 +783,24 @@ };

}
function createProfilesWhoMirroredPublicationMockedResponse(args) {
return {
request: {
query: GetAllProfilesByWhoMirroredPublicationDocument,
variables: args.variables
},
result: {
data: {
result: {
__typename: "ProfileSearchResult",
items: args.items,
pageInfo: {
__typename: "PaginatedResultInfo",
prev: null,
next: null,
totalCount: args.items.length
}
}
}
}
};
}
function createSearchPublicationsQueryMockedResponse(args) {

@@ -814,8 +867,93 @@ return {

import { mockEthereumAddress as mockEthereumAddress2 } from "@lens-protocol/shared-kernel/mocks";
// src/apollo/__helpers__/mocks.ts
import { makeVar } from "@apollo/client";
import { mockSingleLink } from "@apollo/client/testing";
import { GraphQLError } from "graphql";
function mockCreateProfileMutation(result) {
function createMockApolloCache({
activeWalletVar = makeVar(null)
} = {}) {
return createApolloCache({ activeWalletVar });
}
function createMockApolloClientWithMultipleResponses(mocks, cacheConfiguration = {}) {
return new LensApolloClient({
cache: createMockApolloCache(cacheConfiguration),
link: mockSingleLink(...mocks).setOnError((error) => {
throw error;
}),
pollingInterval: 1
});
}
function createGraphQLError({
code,
message = "No pings please!"
}) {
return new GraphQLError(message, void 0, void 0, void 0, void 0, void 0, { code });
}
function createGraphQLValidationError(message = "No pings please!") {
return createGraphQLError({
message,
code: "GRAPHQL_VALIDATION_FAILED" /* GRAPHQL_VALIDATION_FAILED */
});
}
function createValidationErrorMockedResponse(document) {
return {
result
request: {
query: document
},
result: {
errors: [createGraphQLValidationError()]
}
};
}
function createGenericErrorMockedResponse(document) {
return {
request: {
query: document
},
result: {
errors: [
createGraphQLError({
message: "No pings please!",
code: "INTERNAL_SERVER_ERROR" /* INTERNAL_SERVER_ERROR */
})
]
}
};
}
function createJSONResponse(status, body) {
return new Response(JSON.stringify(body), {
status,
headers: {
"Content-Type": "application/json"
}
});
}
function createUnauthenticatedResponse() {
return createJSONResponse(401, {
data: null,
errors: [
createGraphQLError({
message: "Authentication required",
code: "UNAUTHENTICATED"
})
]
});
}
// src/graphql/__helpers__/mutations.ts
function createCreateProfileMutationMockedResponse({
request,
result
}) {
return {
request: {
query: CreateProfileDocument,
variables: { request }
},
result: {
data: { result }
}
};
}
function mockBroadcastProtocolCallMutation(result) {

@@ -956,21 +1094,6 @@ return {

}
function createAddReactionMutationWithGraphqlValidationErrorResponse(args) {
return {
request: {
query: AddReactionDocument,
variables: args.variables
},
result: {
errors: [
new GraphQLError("Wrong vars", void 0, void 0, void 0, void 0, void 0, {
code: "GRAPHQL_VALIDATION_FAILED"
})
]
}
};
}
function createRemoveReactionMutationWithGraphqlValidationErrorResponse(args) {
return {
request: {
query: AddReactionDocument,
query: RemoveReactionDocument,
variables: args.variables

@@ -980,12 +1103,4 @@ },

errors: [
new GraphQLError(
"You have not reacted to this publication with action UPVOTE",
void 0,
void 0,
void 0,
void 0,
void 0,
{
code: "GRAPHQL_VALIDATION_FAILED"
}
createGraphQLValidationError(
`You have not reacted to this publication with action ${args.variables.reaction}}`
)

@@ -1245,12 +1360,25 @@ ]

}
function createReportPublicationMutationMockedResponse(args) {
function mockCreateCollectTypedDataMutation({
nonce = mockNonce()
} = {}) {
return {
request: {
query: ReportPublicationDocument,
variables: args.variables
},
result: { data: { reportPublication: null } }
result: mockCreateTypedDataResult("CreateCollectBroadcastItemResult", {
__typename: "CreateCollectEIP712TypedData",
types: {
__typename: "CreateCollectEIP712TypedDataTypes",
CollectWithSig: [mockEIP712TypedDataField()]
},
domain: mockEIP712TypedDataDomain(),
value: {
__typename: "CreateCollectEIP712TypedDataValue",
nonce,
deadline: "0",
profileId: faker2.datatype.uuid(),
pubId: faker2.datatype.uuid(),
data: ["0x00"]
}
})
};
}
function createReportPublicationMutationWithErrorMockedResponse(args) {
function createReportPublicationMutationMockedResponse(args) {
return {

@@ -1261,32 +1389,7 @@ request: {

},
result: {
errors: [new GraphQLError("Publication already reported")]
}
result: { data: { reportPublication: null } }
};
}
// src/apollo/__helpers__/mocks.ts
import {
ApolloClient,
makeVar
} from "@apollo/client";
import { mockSingleLink } from "@apollo/client/testing";
function createMockApolloCache({
activeWalletVar
} = {}) {
return createApolloCache({
activeWalletVar: activeWalletVar ?? makeVar(null)
});
}
function createMockApolloClientWithMultipleResponses(mocks, cacheConfiguration = {}) {
return new ApolloClient({
link: mockSingleLink(...mocks).setOnError((error) => {
throw error;
}),
cache: createMockApolloCache(cacheConfiguration)
});
}
export {
createAddReactionMutationMockedResponse,
createAddReactionMutationWithGraphqlValidationErrorResponse,
createBroadcastProtocolCallMutationMockedResponse,

@@ -1298,2 +1401,3 @@ createBroadcastProxyActionCallMutationMockedResponse,

createCreatePostViaDispatcherMutationMockedResponse,
createCreateProfileMutationMockedResponse,
createCreateSetProfileMetadataTypedDataMutationMockedResponse,

@@ -1305,3 +1409,6 @@ createCreateSetProfileMetadataViaDispatcherMutationMockedResponse,

createFeedQueryMockedResponse,
createGenericErrorMockedResponse,
createGetAllProfilesByOwnerAddressQueryMockedResponse,
createGraphQLError,
createGraphQLValidationError,
createHasTxHashBeenIndexedQueryMockedResponse,

@@ -1315,2 +1422,3 @@ createHidePublicationMutationMockedResponse,

createProfilesToFollowQueryMockedResponse,
createProfilesWhoMirroredPublicationMockedResponse,
createProxyActionStatusMockedResponse,

@@ -1323,6 +1431,7 @@ createPublicationQueryMockedResponse,

createReportPublicationMutationMockedResponse,
createReportPublicationMutationWithErrorMockedResponse,
createSearchProfilesQueryMockedResponse,
createSearchPublicationsQueryMockedResponse,
createSetProfileImageURIViaDispatcherMutationMockedResponse,
createUnauthenticatedResponse,
createValidationErrorMockedResponse,
createWhoCollectedPublicationQueryMockedResponse,

@@ -1333,6 +1442,6 @@ createWhoReactedPublicationQueryMockedResponse,

mockCommentFragment,
mockCreateCollectTypedDataMutation,
mockCreateCommentTypedDataMutation,
mockCreateFollowTypedDataMutation,
mockCreatePostTypedDataMutation,
mockCreateProfileMutation,
mockCreateSetDispatcherTypedDataMutation,

@@ -1339,0 +1448,0 @@ mockCreateSetFollowModuleTypedDataMutation,

{
"name": "@lens-protocol/api-bindings",
"version": "0.3.0",
"version": "0.4.0",
"description": "Graphql fragments, react hooks, typescript types of lens API.",

@@ -35,7 +35,6 @@ "repository": {

"tslib": "^2.4.1",
"@lens-protocol/domain": "0.3.0",
"@lens-protocol/shared-kernel": "0.3.0"
"@lens-protocol/shared-kernel": "0.4.0",
"@lens-protocol/domain": "0.4.0"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@faker-js/faker": "^7.6.0",

@@ -53,11 +52,11 @@ "@graphql-codegen/add": "^3.2.3",

"eslint": "^8.28.0",
"jest": "^29.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"jest": "^29.3.1",
"rimraf": "^3.0.2",
"ts-jest": "^29.0.3",
"tsup": "^6.5.0",
"typescript": "^4.9.3",
"tsup": "^6.5.0",
"@lens-protocol/prettier-config": "0.3.0",
"@lens-protocol/eslint-config": "0.3.0"
"@lens-protocol/eslint-config": "0.4.0",
"@lens-protocol/prettier-config": "0.4.0"
},

@@ -71,3 +70,3 @@ "peerDependencies": {

"clean": "rimraf ./dist",
"test": "jest --passWithNoTests",
"test": "jest",
"eslint:fix": "pnpm run eslint --fix",

@@ -74,0 +73,0 @@ "eslint": "eslint src",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet