Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
export type ConversationMessagePirateChat = {
__typename: 'ConversationMessagePirateChat';
aiContext?: string | null;
associatedUserMessageId?: string | null;
content?: Array<ContentBlock | null> | null;
conversation?: ConversationPirateChat | null;
conversationId: string;
Expand Down Expand Up @@ -130,6 +131,7 @@ export type ToolInputSchema = {
export type ModelConversationMessagePirateChatFilterInput = {
aiContext?: ModelStringInput | null;
and?: Array<ModelConversationMessagePirateChatFilterInput | null> | null;
associatedUserMessageId?: ModelIDInput | null;
conversationId?: ModelIDInput | null;
createdAt?: ModelStringInput | null;
id?: ModelIDInput | null;
Expand Down Expand Up @@ -273,6 +275,7 @@ export type ToolUseBlockInput = {
export type ModelConversationMessagePirateChatConditionInput = {
aiContext?: ModelStringInput | null;
and?: Array<ModelConversationMessagePirateChatConditionInput | null> | null;
associatedUserMessageId?: ModelIDInput | null;
conversationId?: ModelIDInput | null;
createdAt?: ModelStringInput | null;
not?: ModelConversationMessagePirateChatConditionInput | null;
Expand All @@ -284,6 +287,7 @@ export type ModelConversationMessagePirateChatConditionInput = {

export type CreateConversationMessagePirateChatInput = {
aiContext?: string | null;
associatedUserMessageId?: string | null;
content?: Array<ContentBlockInput | null> | null;
conversationId: string;
id?: string | null;
Expand Down Expand Up @@ -334,9 +338,16 @@ export type DeleteConversationPirateChatInput = {
id: string;
};

export type UpdateConversationPirateChatInput = {
id: string;
metadata?: string | null;
name?: string | null;
};

export type ModelSubscriptionConversationMessagePirateChatFilterInput = {
aiContext?: ModelSubscriptionStringInput | null;
and?: Array<ModelSubscriptionConversationMessagePirateChatFilterInput | null> | null;
associatedUserMessageId?: ModelSubscriptionIDInput | null;
conversationId?: ModelSubscriptionIDInput | null;
createdAt?: ModelSubscriptionStringInput | null;
id?: ModelSubscriptionIDInput | null;
Expand Down Expand Up @@ -384,6 +395,7 @@ export type GetConversationMessagePirateChatQuery = {
getConversationMessagePirateChat?: {
__typename: 'ConversationMessagePirateChat';
aiContext?: string | null;
associatedUserMessageId?: string | null;
content?: Array<{
__typename: 'ContentBlock';
text?: string | null;
Expand Down Expand Up @@ -441,6 +453,7 @@ export type ListConversationMessagePirateChatsQuery = {
items: Array<{
__typename: 'ConversationMessagePirateChat';
aiContext?: string | null;
associatedUserMessageId?: string | null;
conversationId: string;
createdAt: string;
id: string;
Expand Down Expand Up @@ -482,6 +495,7 @@ export type CreateAssistantResponsePirateChatMutation = {
createAssistantResponsePirateChat?: {
__typename: 'ConversationMessagePirateChat';
aiContext?: string | null;
associatedUserMessageId?: string | null;
content?: Array<{
__typename: 'ContentBlock';
text?: string | null;
Expand Down Expand Up @@ -516,6 +530,7 @@ export type CreateConversationMessagePirateChatMutation = {
createConversationMessagePirateChat?: {
__typename: 'ConversationMessagePirateChat';
aiContext?: string | null;
associatedUserMessageId?: string | null;
content?: Array<{
__typename: 'ContentBlock';
text?: string | null;
Expand Down Expand Up @@ -571,6 +586,7 @@ export type DeleteConversationMessagePirateChatMutation = {
deleteConversationMessagePirateChat?: {
__typename: 'ConversationMessagePirateChat';
aiContext?: string | null;
associatedUserMessageId?: string | null;
content?: Array<{
__typename: 'ContentBlock';
text?: string | null;
Expand Down Expand Up @@ -641,6 +657,7 @@ export type PirateChatMutation = {
__typename: 'ToolConfiguration';
} | null;
updatedAt?: string | null;
associatedUserMessageId?: string | null;
conversation?: {
__typename: 'ConversationPirateChat';
createdAt: string;
Expand All @@ -653,6 +670,27 @@ export type PirateChatMutation = {
} | null;
};

export type UpdateConversationPirateChatMutationVariables = {
condition?: ModelConversationPirateChatConditionInput | null;
input: UpdateConversationPirateChatInput;
};

export type UpdateConversationPirateChatMutation = {
updateConversationPirateChat?: {
__typename: 'ConversationPirateChat';
createdAt: string;
id: string;
messages?: {
__typename: 'ModelConversationMessagePirateChatConnection';
nextToken?: string | null;
} | null;
metadata?: string | null;
name?: string | null;
owner?: string | null;
updatedAt: string;
} | null;
};

export type OnCreateAssistantResponsePirateChatSubscriptionVariables = {
conversationId?: string | null;
};
Expand All @@ -661,6 +699,7 @@ export type OnCreateAssistantResponsePirateChatSubscription = {
onCreateAssistantResponsePirateChat?: {
__typename: 'ConversationMessagePirateChat';
aiContext?: string | null;
associatedUserMessageId?: string | null;
content?: Array<{
__typename: 'ContentBlock';
text?: string | null;
Expand Down Expand Up @@ -695,6 +734,7 @@ export type OnCreateConversationMessagePirateChatSubscription = {
onCreateConversationMessagePirateChat?: {
__typename: 'ConversationMessagePirateChat';
aiContext?: string | null;
associatedUserMessageId?: string | null;
content?: Array<{
__typename: 'ContentBlock';
text?: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { createNewProjectDir, deleteProjectDir } from 'amplify-category-api-e2e-
import { cdkDeploy, cdkDestroy, initCDKProject } from '../../commands';
import { DDB_AMPLIFY_MANAGED_DATASOURCE_STRATEGY } from '@aws-amplify/graphql-transformer-core';
import { createCognitoUser, signInCognitoUser, TestDefinition, writeStackConfig, writeTestDefinitions } from '../../utils';
import { doCreateConversationPirateChat, doListConversationMessagesPirateChat, doSendMessagePirateChat } from './test-implementations';
import {
doCreateConversationPirateChat,
doListConversationMessagesPirateChat,
doSendMessagePirateChat,
doUpdateConversationPirateChat,
} from './test-implementations';

jest.setTimeout(DURATION_20_MINUTES);

Expand Down Expand Up @@ -104,6 +109,20 @@ describe('conversation', () => {
expect(messages.body.data.listConversationMessagePirateChats.items[0].conversationId).toBe(id);
});

test('update conversation', async () => {
const conversationResult = await doCreateConversationPirateChat(apiEndpoint, accessToken);

const { id } = conversationResult.body.data.createConversationPirateChat;
expect(id).toBeDefined();

const updateConversationResult = await doUpdateConversationPirateChat(apiEndpoint, accessToken, id, 'updated conversation name');

const updatedConversation = updateConversationResult.body.data.updateConversationPirateChat;
const { name, id: updatedId } = updatedConversation;
expect(name).toEqual('updated conversation name');
expect(updatedId).toEqual(id);
});

describe('conversation owner auth negative tests', () => {
test('userB cannot send message to userAs conversation', async () => {
const conversationResult = await doCreateConversationPirateChat(apiEndpoint, accessToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const createAssistantResponsePirateChat = /* GraphQL */ `mutation CreateA
) {
createAssistantResponsePirateChat(input: $input) {
aiContext
associatedUserMessageId
content {
text
__typename
Expand Down Expand Up @@ -45,6 +46,7 @@ export const createConversationMessagePirateChat = /* GraphQL */ `mutation Creat
) {
createConversationMessagePirateChat(condition: $condition, input: $input) {
aiContext
associatedUserMessageId
content {
text
__typename
Expand Down Expand Up @@ -96,6 +98,7 @@ export const deleteConversationMessagePirateChat = /* GraphQL */ `mutation Delet
) {
deleteConversationMessagePirateChat(condition: $condition, input: $input) {
aiContext
associatedUserMessageId
content {
text
__typename
Expand Down Expand Up @@ -169,6 +172,7 @@ export const pirateChat = /* GraphQL */ `mutation PirateChat(
updatedAt

... on ConversationMessagePirateChat {
associatedUserMessageId
conversation {
createdAt
id
Expand All @@ -182,3 +186,22 @@ export const pirateChat = /* GraphQL */ `mutation PirateChat(
}
}
` as GeneratedMutation<APITypes.PirateChatMutationVariables, APITypes.PirateChatMutation>;
export const updateConversationPirateChat = /* GraphQL */ `mutation UpdateConversationPirateChat(
$condition: ModelConversationPirateChatConditionInput
$input: UpdateConversationPirateChatInput!
) {
updateConversationPirateChat(condition: $condition, input: $input) {
createdAt
id
messages {
nextToken
__typename
}
metadata
name
owner
updatedAt
__typename
}
}
` as GeneratedMutation<APITypes.UpdateConversationPirateChatMutationVariables, APITypes.UpdateConversationPirateChatMutation>;
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type GeneratedQuery<InputType, OutputType> = string & {
export const getConversationMessagePirateChat = /* GraphQL */ `query GetConversationMessagePirateChat($id: ID!) {
getConversationMessagePirateChat(id: $id) {
aiContext
associatedUserMessageId
content {
text
__typename
Expand Down Expand Up @@ -65,6 +66,7 @@ export const listConversationMessagePirateChats = /* GraphQL */ `query ListConve
) {
items {
aiContext
associatedUserMessageId
conversationId
createdAt
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ type GeneratedSubscription<InputType, OutputType> = string & {
export const onCreateAssistantResponsePirateChat = /* GraphQL */ `subscription OnCreateAssistantResponsePirateChat($conversationId: ID) {
onCreateAssistantResponsePirateChat(conversationId: $conversationId) {
aiContext
assistantContent {
text
__typename
}
associatedUserMessageId
content {
text
__typename
Expand Down Expand Up @@ -50,10 +47,7 @@ export const onCreateConversationMessagePirateChat = /* GraphQL */ `subscription
) {
onCreateConversationMessagePirateChat(filter: $filter, owner: $owner) {
aiContext
assistantContent {
text
__typename
}
associatedUserMessageId
content {
text
__typename
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { AppSyncGraphqlResponse, doAppSyncGraphqlMutation, doAppSyncGraphqlOperation, doAppSyncGraphqlQuery } from '../../utils';
import { AppSyncGraphqlResponse, doAppSyncGraphqlOperation, doAppSyncGraphqlQuery } from '../../utils';
import {
CreateConversationPirateChatMutation,
GetConversationPirateChatQuery,
ListConversationMessagePirateChatsQuery,
PirateChatMutation,
UpdateConversationPirateChatMutation,
} from './API';
import { createConversationPirateChat, pirateChat } from './graphql/mutations';
import { createConversationPirateChat, pirateChat, updateConversationPirateChat } from './graphql/mutations';
import { getConversationPirateChat, listConversationMessagePirateChats } from './graphql/queries';

export const doCreateConversationPirateChat = async (
Expand Down Expand Up @@ -35,6 +36,20 @@ export const doGetConversationPirateChat = async (
});
};

export const doUpdateConversationPirateChat = async (
apiEndpoint: string,
accessToken: string,
conversationId: string,
name: string,
): Promise<AppSyncGraphqlResponse<UpdateConversationPirateChatMutation>> => {
return doAppSyncGraphqlOperation({
apiEndpoint,
auth: { accessToken: accessToken },
query: updateConversationPirateChat,
variables: { input: { id: conversationId, name } },
});
};

export const doSendMessagePirateChat = async (
apiEndpoint: string,
accessToken: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ const createSessionModelDirective = (): DirectiveNode => {
},
],
};
return makeDirective('model', [
makeArgument('subscriptions', subscriptionsOffValue),
makeArgument('mutations', makeValueNode({ update: null })),
]);
return makeDirective('model', [makeArgument('subscriptions', subscriptionsOffValue)]);
};

/**
Expand Down
Loading