@aws-amplify/data-schema 1.6.2 → 1.7.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/cjs/runtime/index.js +3 -1
- package/dist/cjs/runtime/index.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createCreateConversationFunction.js +2 -1
- package/dist/cjs/runtime/internals/ai/createCreateConversationFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createDeleteConversationFunction.js +21 -0
- package/dist/cjs/runtime/internals/ai/createDeleteConversationFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createGetConversationFunction.js +2 -1
- package/dist/cjs/runtime/internals/ai/createGetConversationFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createListConversationsFunction.js +2 -1
- package/dist/cjs/runtime/internals/ai/createListConversationsFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createListMessagesFunction.js +2 -1
- package/dist/cjs/runtime/internals/ai/createListMessagesFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createOnMessageFunction.js +2 -1
- package/dist/cjs/runtime/internals/ai/createOnMessageFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createSendMessageFunction.js +2 -1
- package/dist/cjs/runtime/internals/ai/createSendMessageFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/getCustomUserAgentDetails.js +48 -0
- package/dist/cjs/runtime/internals/ai/getCustomUserAgentDetails.js.map +1 -0
- package/dist/cjs/runtime/internals/operations/custom.js +10 -5
- package/dist/cjs/runtime/internals/operations/custom.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/get.js +8 -5
- package/dist/cjs/runtime/internals/operations/get.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/list.js +8 -5
- package/dist/cjs/runtime/internals/operations/list.js.map +1 -1
- package/dist/cjs/runtime/internals/utils/clientProperties/generateConversationsProperty.js +2 -0
- package/dist/cjs/runtime/internals/utils/clientProperties/generateConversationsProperty.js.map +1 -1
- package/dist/cjs/runtime/internals/utils/clientProperties/generateGenerationsProperty.js +2 -1
- package/dist/cjs/runtime/internals/utils/clientProperties/generateGenerationsProperty.js.map +1 -1
- package/dist/esm/ai/ConversationType.d.ts +9 -0
- package/dist/esm/runtime/addSchemaToClientWithInstance.mjs +1 -0
- package/dist/esm/runtime/addSchemaToClientWithInstance.mjs.map +1 -1
- package/dist/esm/runtime/bridge-types.d.ts +6 -1
- package/dist/esm/runtime/index.d.ts +1 -0
- package/dist/esm/runtime/index.mjs +1 -0
- package/dist/esm/runtime/index.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createCreateConversationFunction.d.ts +1 -1
- package/dist/esm/runtime/internals/ai/createCreateConversationFunction.mjs +2 -1
- package/dist/esm/runtime/internals/ai/createCreateConversationFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createDeleteConversationFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createDeleteConversationFunction.mjs +19 -0
- package/dist/esm/runtime/internals/ai/createDeleteConversationFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createGetConversationFunction.d.ts +1 -1
- package/dist/esm/runtime/internals/ai/createGetConversationFunction.mjs +2 -1
- package/dist/esm/runtime/internals/ai/createGetConversationFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.d.ts +1 -1
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.mjs +2 -1
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createListMessagesFunction.d.ts +1 -1
- package/dist/esm/runtime/internals/ai/createListMessagesFunction.mjs +2 -1
- package/dist/esm/runtime/internals/ai/createListMessagesFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createOnMessageFunction.d.ts +1 -1
- package/dist/esm/runtime/internals/ai/createOnMessageFunction.mjs +2 -1
- package/dist/esm/runtime/internals/ai/createOnMessageFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.d.ts +1 -1
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.mjs +2 -1
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/getCustomUserAgentDetails.d.ts +35 -0
- package/dist/esm/runtime/internals/ai/getCustomUserAgentDetails.mjs +44 -0
- package/dist/esm/runtime/internals/ai/getCustomUserAgentDetails.mjs.map +1 -0
- package/dist/esm/runtime/internals/operations/custom.d.ts +2 -2
- package/dist/esm/runtime/internals/operations/custom.mjs +10 -5
- package/dist/esm/runtime/internals/operations/custom.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/get.d.ts +2 -2
- package/dist/esm/runtime/internals/operations/get.mjs +8 -5
- package/dist/esm/runtime/internals/operations/get.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/list.d.ts +2 -2
- package/dist/esm/runtime/internals/operations/list.mjs +8 -5
- package/dist/esm/runtime/internals/operations/list.mjs.map +1 -1
- package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.mjs +2 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.mjs.map +1 -1
- package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.mjs +2 -1
- package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.mjs.map +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/ai/ConversationType.ts +10 -0
- package/src/runtime/bridge-types.ts +8 -0
- package/src/runtime/index.ts +1 -0
- package/src/runtime/internals/ai/createCreateConversationFunction.ts +7 -1
- package/src/runtime/internals/ai/createDeleteConversationFunction.ts +54 -0
- package/src/runtime/internals/ai/createGetConversationFunction.ts +7 -1
- package/src/runtime/internals/ai/createListConversationsFunction.ts +7 -1
- package/src/runtime/internals/ai/createListMessagesFunction.ts +7 -1
- package/src/runtime/internals/ai/createOnMessageFunction.ts +3 -1
- package/src/runtime/internals/ai/createSendMessageFunction.ts +6 -1
- package/src/runtime/internals/ai/getCustomUserAgentDetails.ts +54 -0
- package/src/runtime/internals/operations/custom.ts +13 -0
- package/src/runtime/internals/operations/get.ts +11 -2
- package/src/runtime/internals/operations/list.ts +18 -3
- package/src/runtime/internals/utils/clientProperties/generateConversationsProperty.ts +9 -0
- package/src/runtime/internals/utils/clientProperties/generateGenerationsProperty.ts +5 -0
package/package.json
CHANGED
|
@@ -29,6 +29,10 @@ interface ConversationRouteGetInput {
|
|
|
29
29
|
id: string;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
interface ConversationRouteDeleteInput {
|
|
33
|
+
id: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
interface ConversationRouteListInput {
|
|
33
37
|
limit?: number;
|
|
34
38
|
nextToken?: string | null;
|
|
@@ -47,6 +51,12 @@ export interface ConversationRoute {
|
|
|
47
51
|
* Gets an existing {@link Conversation} based on ID.
|
|
48
52
|
*/
|
|
49
53
|
get: (input: ConversationRouteGetInput) => SingularReturnValue<Conversation>;
|
|
54
|
+
/**
|
|
55
|
+
* @experimental
|
|
56
|
+
*
|
|
57
|
+
* Deletes an existing {@link Conversation} based on ID.
|
|
58
|
+
*/
|
|
59
|
+
delete: (input: ConversationRouteDeleteInput) => SingularReturnValue<Conversation>;
|
|
50
60
|
/**
|
|
51
61
|
* @experimental
|
|
52
62
|
*
|
|
@@ -15,6 +15,8 @@ import { Observable } from 'rxjs';
|
|
|
15
15
|
|
|
16
16
|
import { CustomHeaders, ModelSortDirection } from './client';
|
|
17
17
|
|
|
18
|
+
import { AiAction, AiCategory } from './internals/ai/getCustomUserAgentDetails';
|
|
19
|
+
|
|
18
20
|
export declare namespace AmplifyServer {
|
|
19
21
|
export interface ContextToken {
|
|
20
22
|
readonly value: symbol;
|
|
@@ -408,9 +410,15 @@ export type BaseSSRClient = {
|
|
|
408
410
|
isCancelError(error: any): boolean;
|
|
409
411
|
};
|
|
410
412
|
|
|
413
|
+
export interface CustomUserAgentDetails {
|
|
414
|
+
category: AiCategory;
|
|
415
|
+
action: AiAction;
|
|
416
|
+
}
|
|
417
|
+
|
|
411
418
|
export type GraphQLMethod = (
|
|
412
419
|
options: GraphQLOptions,
|
|
413
420
|
additionalHeaders?: CustomHeaders | undefined,
|
|
421
|
+
customUserAgentDetails?: CustomUserAgentDetails,
|
|
414
422
|
) => Promise<GraphQLResult> | GraphqlSubscriptionResult;
|
|
415
423
|
|
|
416
424
|
export type GraphQLMethodSSR = (
|
package/src/runtime/index.ts
CHANGED
|
@@ -5,3 +5,4 @@ export * from './client';
|
|
|
5
5
|
export { addSchemaToClient } from './addSchemaToClient';
|
|
6
6
|
export { addSchemaToClientWithInstance } from './addSchemaToClientWithInstance';
|
|
7
7
|
export { BaseClient, ClientInternals } from './bridge-types';
|
|
8
|
+
export { INTERNAL_USER_AGENT_OVERRIDE } from './internals/ai/getCustomUserAgentDetails';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { ConversationRoute } from '../../../ai/ConversationType';
|
|
5
5
|
import type { SingularReturnValue } from '../../../runtime/client';
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
7
|
BaseClient,
|
|
8
8
|
ClientInternalsGetter,
|
|
9
9
|
ModelIntrospectionSchema,
|
|
@@ -11,6 +11,10 @@ import type {
|
|
|
11
11
|
} from '../../bridge-types';
|
|
12
12
|
import { getFactory } from '../operations/get';
|
|
13
13
|
import { convertItemToConversation } from './convertItemToConversation';
|
|
14
|
+
import {
|
|
15
|
+
AiAction,
|
|
16
|
+
getCustomUserAgentDetails,
|
|
17
|
+
} from './getCustomUserAgentDetails';
|
|
14
18
|
|
|
15
19
|
export const createCreateConversationFunction =
|
|
16
20
|
(
|
|
@@ -28,6 +32,8 @@ export const createCreateConversationFunction =
|
|
|
28
32
|
conversationModel,
|
|
29
33
|
'CREATE',
|
|
30
34
|
getInternals,
|
|
35
|
+
false,
|
|
36
|
+
getCustomUserAgentDetails(AiAction.CreateConversation),
|
|
31
37
|
) as () => SingularReturnValue<Record<string, any>>;
|
|
32
38
|
const { data, errors } = await get();
|
|
33
39
|
return {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { ConversationRoute } from '../../../ai/ConversationType';
|
|
5
|
+
import type { SingularReturnValue } from '../../../runtime/client';
|
|
6
|
+
import {
|
|
7
|
+
BaseClient,
|
|
8
|
+
ClientInternalsGetter,
|
|
9
|
+
ModelIntrospectionSchema,
|
|
10
|
+
SchemaModel,
|
|
11
|
+
} from '../../bridge-types';
|
|
12
|
+
import { getFactory } from '../operations/get';
|
|
13
|
+
import { convertItemToConversation } from './convertItemToConversation';
|
|
14
|
+
import {
|
|
15
|
+
AiAction,
|
|
16
|
+
getCustomUserAgentDetails,
|
|
17
|
+
} from './getCustomUserAgentDetails';
|
|
18
|
+
|
|
19
|
+
export const createDeleteConversationFunction =
|
|
20
|
+
(
|
|
21
|
+
client: BaseClient,
|
|
22
|
+
modelIntrospection: ModelIntrospectionSchema,
|
|
23
|
+
conversationRouteName: string,
|
|
24
|
+
conversationModel: SchemaModel,
|
|
25
|
+
conversationMessageModel: SchemaModel,
|
|
26
|
+
getInternals: ClientInternalsGetter,
|
|
27
|
+
): ConversationRoute['delete'] =>
|
|
28
|
+
async ({ id }) => {
|
|
29
|
+
const deleteOperation = getFactory(
|
|
30
|
+
client,
|
|
31
|
+
modelIntrospection,
|
|
32
|
+
conversationModel,
|
|
33
|
+
'DELETE',
|
|
34
|
+
getInternals,
|
|
35
|
+
false,
|
|
36
|
+
getCustomUserAgentDetails(AiAction.DeleteConversation),
|
|
37
|
+
) as (
|
|
38
|
+
args?: Record<string, any>,
|
|
39
|
+
) => SingularReturnValue<Record<string, any>>;
|
|
40
|
+
const { data, errors } = await deleteOperation({ id });
|
|
41
|
+
return {
|
|
42
|
+
data: data
|
|
43
|
+
? convertItemToConversation(
|
|
44
|
+
client,
|
|
45
|
+
modelIntrospection,
|
|
46
|
+
data?.id,
|
|
47
|
+
conversationRouteName,
|
|
48
|
+
conversationMessageModel,
|
|
49
|
+
getInternals,
|
|
50
|
+
)
|
|
51
|
+
: data,
|
|
52
|
+
errors,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { ConversationRoute } from '../../../ai/ConversationType';
|
|
5
5
|
import type { SingularReturnValue } from '../../../runtime/client';
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
7
|
BaseClient,
|
|
8
8
|
ClientInternalsGetter,
|
|
9
9
|
ModelIntrospectionSchema,
|
|
@@ -11,6 +11,10 @@ import type {
|
|
|
11
11
|
} from '../../bridge-types';
|
|
12
12
|
import { getFactory } from '../operations/get';
|
|
13
13
|
import { convertItemToConversation } from './convertItemToConversation';
|
|
14
|
+
import {
|
|
15
|
+
AiAction,
|
|
16
|
+
getCustomUserAgentDetails,
|
|
17
|
+
} from './getCustomUserAgentDetails';
|
|
14
18
|
|
|
15
19
|
export const createGetConversationFunction =
|
|
16
20
|
(
|
|
@@ -28,6 +32,8 @@ export const createGetConversationFunction =
|
|
|
28
32
|
conversationModel,
|
|
29
33
|
'GET',
|
|
30
34
|
getInternals,
|
|
35
|
+
false,
|
|
36
|
+
getCustomUserAgentDetails(AiAction.GetConversation),
|
|
31
37
|
) as (
|
|
32
38
|
args?: Record<string, any>,
|
|
33
39
|
) => SingularReturnValue<Record<string, any>>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { ConversationRoute } from '../../../ai/ConversationType';
|
|
5
5
|
import type { ListReturnValue } from '../../../runtime/client';
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
7
|
BaseClient,
|
|
8
8
|
ClientInternalsGetter,
|
|
9
9
|
ModelIntrospectionSchema,
|
|
@@ -11,6 +11,10 @@ import type {
|
|
|
11
11
|
} from '../../bridge-types';
|
|
12
12
|
import { listFactory } from '../operations/list';
|
|
13
13
|
import { convertItemToConversation } from './convertItemToConversation';
|
|
14
|
+
import {
|
|
15
|
+
AiAction,
|
|
16
|
+
getCustomUserAgentDetails,
|
|
17
|
+
} from './getCustomUserAgentDetails';
|
|
14
18
|
|
|
15
19
|
export const createListConversationsFunction =
|
|
16
20
|
(
|
|
@@ -27,6 +31,8 @@ export const createListConversationsFunction =
|
|
|
27
31
|
modelIntrospection,
|
|
28
32
|
conversationModel,
|
|
29
33
|
getInternals,
|
|
34
|
+
false,
|
|
35
|
+
getCustomUserAgentDetails(AiAction.ListConversations),
|
|
30
36
|
) as (args?: Record<string, any>) => ListReturnValue<Record<string, any>>;
|
|
31
37
|
const { data, nextToken, errors } = await list(input);
|
|
32
38
|
return {
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
ConversationMessage,
|
|
7
7
|
} from '../../../ai/ConversationType';
|
|
8
8
|
import type { ListReturnValue } from '../../../runtime/client';
|
|
9
|
-
import
|
|
9
|
+
import {
|
|
10
10
|
BaseClient,
|
|
11
11
|
ClientInternalsGetter,
|
|
12
12
|
ModelIntrospectionSchema,
|
|
@@ -14,6 +14,10 @@ import type {
|
|
|
14
14
|
} from '../../bridge-types';
|
|
15
15
|
import { listFactory } from '../operations/list';
|
|
16
16
|
import { convertItemToConversationMessage } from './convertItemToConversationMessage';
|
|
17
|
+
import {
|
|
18
|
+
AiAction,
|
|
19
|
+
getCustomUserAgentDetails,
|
|
20
|
+
} from './getCustomUserAgentDetails';
|
|
17
21
|
|
|
18
22
|
export const createListMessagesFunction =
|
|
19
23
|
(
|
|
@@ -29,6 +33,8 @@ export const createListMessagesFunction =
|
|
|
29
33
|
modelIntrospection,
|
|
30
34
|
conversationMessageModel,
|
|
31
35
|
getInternals,
|
|
36
|
+
false,
|
|
37
|
+
getCustomUserAgentDetails(AiAction.ListMessages),
|
|
32
38
|
) as (args?: Record<string, any>) => ListReturnValue<ConversationMessage>;
|
|
33
39
|
const { data, nextToken, errors } = await list({
|
|
34
40
|
...input,
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
import type { Observable, Subscription } from 'rxjs';
|
|
5
5
|
import type { Conversation } from '../../../ai/ConversationType';
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
7
|
BaseClient,
|
|
8
8
|
ClientInternalsGetter,
|
|
9
9
|
ModelIntrospectionSchema,
|
|
10
10
|
} from '../../bridge-types';
|
|
11
11
|
import { customOpFactory } from '../operations/custom';
|
|
12
12
|
import { convertItemToConversationMessage } from './convertItemToConversationMessage';
|
|
13
|
+
import { AiAction, getCustomUserAgentDetails } from './getCustomUserAgentDetails';
|
|
13
14
|
|
|
14
15
|
export const createOnMessageFunction =
|
|
15
16
|
(
|
|
@@ -34,6 +35,7 @@ export const createOnMessageFunction =
|
|
|
34
35
|
subscribeSchema,
|
|
35
36
|
false,
|
|
36
37
|
getInternals,
|
|
38
|
+
getCustomUserAgentDetails(AiAction.OnMessage),
|
|
37
39
|
) as (args?: Record<string, any>) => Observable<any>;
|
|
38
40
|
return subscribeOperation({ conversationId }).subscribe((data) => {
|
|
39
41
|
handler(convertItemToConversationMessage(data));
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
Conversation,
|
|
7
7
|
ConversationMessage,
|
|
8
8
|
} from '../../../ai/ConversationType';
|
|
9
|
-
import
|
|
9
|
+
import {
|
|
10
10
|
BaseClient,
|
|
11
11
|
ClientInternalsGetter,
|
|
12
12
|
ModelIntrospectionSchema,
|
|
@@ -18,6 +18,10 @@ import {
|
|
|
18
18
|
serializeContent,
|
|
19
19
|
serializeToolConfiguration,
|
|
20
20
|
} from './conversationMessageSerializers';
|
|
21
|
+
import {
|
|
22
|
+
AiAction,
|
|
23
|
+
getCustomUserAgentDetails,
|
|
24
|
+
} from './getCustomUserAgentDetails';
|
|
21
25
|
|
|
22
26
|
export const createSendMessageFunction =
|
|
23
27
|
(
|
|
@@ -42,6 +46,7 @@ export const createSendMessageFunction =
|
|
|
42
46
|
sendSchema,
|
|
43
47
|
false,
|
|
44
48
|
getInternals,
|
|
49
|
+
getCustomUserAgentDetails(AiAction.SendMessage),
|
|
45
50
|
) as (
|
|
46
51
|
args?: Record<string, any>,
|
|
47
52
|
) => SingularReturnValue<ConversationMessage>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { CustomUserAgentDetails } from '../../bridge-types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Symbol used for internal user agent overrides.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
* This symbol is intended for internal use within the Amplify library.
|
|
11
|
+
* It may change or be removed in future versions without notice.
|
|
12
|
+
* External usage of this symbol is discouraged and may lead to unexpected behavior.
|
|
13
|
+
*/
|
|
14
|
+
export const INTERNAL_USER_AGENT_OVERRIDE = Symbol(
|
|
15
|
+
'INTERNAL_USER_AGENT_OVERRIDE',
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export type AiCategory = 'ai';
|
|
19
|
+
|
|
20
|
+
export enum AiAction {
|
|
21
|
+
CreateConversation = '1',
|
|
22
|
+
GetConversation = '2',
|
|
23
|
+
ListConversations = '3',
|
|
24
|
+
DeleteConversation = '4',
|
|
25
|
+
SendMessage = '5',
|
|
26
|
+
ListMessages = '6',
|
|
27
|
+
OnMessage = '7',
|
|
28
|
+
Generation = '8',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const getCustomUserAgentDetails = (
|
|
32
|
+
action: AiAction,
|
|
33
|
+
): CustomUserAgentDetails => ({
|
|
34
|
+
category: 'ai',
|
|
35
|
+
action,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a user agent override object based on custom details.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
* This function is intended for internal use within the Amplify library.
|
|
43
|
+
* It may change or be removed in future versions without notice.
|
|
44
|
+
*
|
|
45
|
+
* @param customUserAgentDetails - Optional custom user agent details
|
|
46
|
+
* @returns An object with INTERNAL_USER_AGENT_OVERRIDE symbol as key and customUserAgentDetails as value, or undefined if no details provided
|
|
47
|
+
*/
|
|
48
|
+
export function createUserAgentOverride(
|
|
49
|
+
customUserAgentDetails?: CustomUserAgentDetails,
|
|
50
|
+
): { [INTERNAL_USER_AGENT_OVERRIDE]?: CustomUserAgentDetails } | undefined {
|
|
51
|
+
return customUserAgentDetails
|
|
52
|
+
? { [INTERNAL_USER_AGENT_OVERRIDE]: customUserAgentDetails }
|
|
53
|
+
: undefined;
|
|
54
|
+
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
InputFieldType,
|
|
18
18
|
EnumType,
|
|
19
19
|
InputType,
|
|
20
|
+
CustomUserAgentDetails,
|
|
20
21
|
} from '../../bridge-types';
|
|
21
22
|
|
|
22
23
|
import { map } from 'rxjs';
|
|
@@ -34,6 +35,7 @@ import { handleSingularGraphQlError } from './utils';
|
|
|
34
35
|
import { selfAwareAsync } from '../../utils';
|
|
35
36
|
|
|
36
37
|
import { extendCancellability } from '../cancellation';
|
|
38
|
+
import { createUserAgentOverride } from '../ai/getCustomUserAgentDetails';
|
|
37
39
|
|
|
38
40
|
type CustomOperationOptions = AuthModeParams & ListArgs;
|
|
39
41
|
|
|
@@ -120,6 +122,7 @@ export function customOpFactory(
|
|
|
120
122
|
operation: CustomOperation,
|
|
121
123
|
useContext: boolean,
|
|
122
124
|
getInternals: ClientInternalsGetter,
|
|
125
|
+
customUserAgentDetails?: CustomUserAgentDetails,
|
|
123
126
|
) {
|
|
124
127
|
// .arguments() are defined for the custom operation in the schema builder
|
|
125
128
|
// and are present in the model introspection schema
|
|
@@ -159,6 +162,7 @@ export function customOpFactory(
|
|
|
159
162
|
getInternals,
|
|
160
163
|
arg,
|
|
161
164
|
options,
|
|
165
|
+
customUserAgentDetails,
|
|
162
166
|
);
|
|
163
167
|
}
|
|
164
168
|
|
|
@@ -171,6 +175,7 @@ export function customOpFactory(
|
|
|
171
175
|
arg,
|
|
172
176
|
options,
|
|
173
177
|
contextSpec,
|
|
178
|
+
customUserAgentDetails,
|
|
174
179
|
);
|
|
175
180
|
};
|
|
176
181
|
|
|
@@ -384,6 +389,7 @@ function _op(
|
|
|
384
389
|
args?: QueryArgs,
|
|
385
390
|
options?: AuthModeParams & ListArgs,
|
|
386
391
|
context?: AmplifyServer.ContextSpec,
|
|
392
|
+
customUserAgentDetails?: CustomUserAgentDetails,
|
|
387
393
|
) {
|
|
388
394
|
return selfAwareAsync(async (resultPromise) => {
|
|
389
395
|
const { name: operationName } = operation;
|
|
@@ -405,6 +411,8 @@ function _op(
|
|
|
405
411
|
|
|
406
412
|
const variables = operationVariables(operation, args);
|
|
407
413
|
|
|
414
|
+
const userAgentOverride = createUserAgentOverride(customUserAgentDetails);
|
|
415
|
+
|
|
408
416
|
try {
|
|
409
417
|
const basePromise = context
|
|
410
418
|
? ((client as BaseSSRClient).graphql(
|
|
@@ -421,6 +429,7 @@ function _op(
|
|
|
421
429
|
...auth,
|
|
422
430
|
query,
|
|
423
431
|
variables,
|
|
432
|
+
...userAgentOverride,
|
|
424
433
|
},
|
|
425
434
|
headers,
|
|
426
435
|
) as Promise<GraphQLResult>);
|
|
@@ -548,6 +557,7 @@ function _opSubscription(
|
|
|
548
557
|
getInternals: ClientInternalsGetter,
|
|
549
558
|
args?: QueryArgs,
|
|
550
559
|
options?: AuthModeParams & ListArgs,
|
|
560
|
+
customUserAgentDetails?: CustomUserAgentDetails,
|
|
551
561
|
) {
|
|
552
562
|
const operationType = 'subscription';
|
|
553
563
|
const { name: operationName } = operation;
|
|
@@ -569,11 +579,14 @@ function _opSubscription(
|
|
|
569
579
|
|
|
570
580
|
const variables = operationVariables(operation, args);
|
|
571
581
|
|
|
582
|
+
const userAgentOverride = createUserAgentOverride(customUserAgentDetails);
|
|
583
|
+
|
|
572
584
|
const observable = client.graphql(
|
|
573
585
|
{
|
|
574
586
|
...auth,
|
|
575
587
|
query,
|
|
576
588
|
variables,
|
|
589
|
+
...userAgentOverride,
|
|
577
590
|
},
|
|
578
591
|
headers,
|
|
579
592
|
) as GraphqlSubscriptionResult;
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
ModelIntrospectionSchema,
|
|
14
14
|
SchemaModel,
|
|
15
15
|
QueryArgs,
|
|
16
|
+
CustomUserAgentDetails,
|
|
16
17
|
} from '../../bridge-types';
|
|
17
18
|
|
|
18
19
|
import {
|
|
@@ -29,6 +30,7 @@ import { handleSingularGraphQlError } from './utils';
|
|
|
29
30
|
import { selfAwareAsync } from '../../utils';
|
|
30
31
|
|
|
31
32
|
import { extendCancellability } from '../cancellation';
|
|
33
|
+
import { createUserAgentOverride } from '../ai/getCustomUserAgentDetails';
|
|
32
34
|
|
|
33
35
|
export function getFactory(
|
|
34
36
|
client: BaseClient,
|
|
@@ -37,6 +39,7 @@ export function getFactory(
|
|
|
37
39
|
operation: ModelOperation,
|
|
38
40
|
getInternals: ClientInternalsGetter,
|
|
39
41
|
useContext = false,
|
|
42
|
+
customUserAgentDetails?: CustomUserAgentDetails,
|
|
40
43
|
) {
|
|
41
44
|
const getWithContext = (
|
|
42
45
|
contextSpec: AmplifyServer.ContextSpec & GraphQLOptions,
|
|
@@ -52,6 +55,7 @@ export function getFactory(
|
|
|
52
55
|
operation,
|
|
53
56
|
getInternals,
|
|
54
57
|
contextSpec,
|
|
58
|
+
customUserAgentDetails,
|
|
55
59
|
);
|
|
56
60
|
};
|
|
57
61
|
|
|
@@ -64,6 +68,8 @@ export function getFactory(
|
|
|
64
68
|
options,
|
|
65
69
|
operation,
|
|
66
70
|
getInternals,
|
|
71
|
+
undefined,
|
|
72
|
+
customUserAgentDetails,
|
|
67
73
|
);
|
|
68
74
|
};
|
|
69
75
|
|
|
@@ -79,6 +85,7 @@ function _get(
|
|
|
79
85
|
operation: ModelOperation,
|
|
80
86
|
getInternals: ClientInternalsGetter,
|
|
81
87
|
context?: AmplifyServer.ContextSpec,
|
|
88
|
+
customUserAgentDetails?: CustomUserAgentDetails,
|
|
82
89
|
) {
|
|
83
90
|
return selfAwareAsync(async (resultPromise) => {
|
|
84
91
|
const { name } = model;
|
|
@@ -97,10 +104,11 @@ function _get(
|
|
|
97
104
|
);
|
|
98
105
|
|
|
99
106
|
const auth = authModeParams(client, getInternals, options);
|
|
107
|
+
const headers = getCustomHeaders(client, getInternals, options?.headers);
|
|
100
108
|
|
|
101
|
-
|
|
102
|
-
const headers = getCustomHeaders(client, getInternals, options?.headers);
|
|
109
|
+
const userAgentOverride = createUserAgentOverride(customUserAgentDetails);
|
|
103
110
|
|
|
111
|
+
try {
|
|
104
112
|
const basePromise = context
|
|
105
113
|
? ((client as BaseSSRClient).graphql(
|
|
106
114
|
context,
|
|
@@ -116,6 +124,7 @@ function _get(
|
|
|
116
124
|
...auth,
|
|
117
125
|
query,
|
|
118
126
|
variables,
|
|
127
|
+
...userAgentOverride,
|
|
119
128
|
},
|
|
120
129
|
headers,
|
|
121
130
|
) as Promise<GraphQLResult>);
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ListArgs,
|
|
12
12
|
ModelIntrospectionSchema,
|
|
13
13
|
SchemaModel,
|
|
14
|
+
CustomUserAgentDetails,
|
|
14
15
|
} from '../../bridge-types';
|
|
15
16
|
|
|
16
17
|
import {
|
|
@@ -26,6 +27,7 @@ import { handleListGraphQlError } from './utils';
|
|
|
26
27
|
import { selfAwareAsync } from '../../utils';
|
|
27
28
|
|
|
28
29
|
import { extendCancellability } from '../cancellation';
|
|
30
|
+
import { createUserAgentOverride } from '../ai/getCustomUserAgentDetails';
|
|
29
31
|
|
|
30
32
|
export function listFactory(
|
|
31
33
|
client: BaseClient,
|
|
@@ -33,6 +35,7 @@ export function listFactory(
|
|
|
33
35
|
model: SchemaModel,
|
|
34
36
|
getInternals: ClientInternalsGetter,
|
|
35
37
|
context = false,
|
|
38
|
+
customUserAgentDetails?: CustomUserAgentDetails,
|
|
36
39
|
) {
|
|
37
40
|
const listWithContext = (
|
|
38
41
|
contextSpec: AmplifyServer.ContextSpec,
|
|
@@ -45,11 +48,20 @@ export function listFactory(
|
|
|
45
48
|
getInternals,
|
|
46
49
|
args,
|
|
47
50
|
contextSpec,
|
|
51
|
+
customUserAgentDetails,
|
|
48
52
|
);
|
|
49
53
|
};
|
|
50
54
|
|
|
51
55
|
const list = (args?: Record<string, any>) => {
|
|
52
|
-
return _list(
|
|
56
|
+
return _list(
|
|
57
|
+
client,
|
|
58
|
+
modelIntrospection,
|
|
59
|
+
model,
|
|
60
|
+
getInternals,
|
|
61
|
+
args,
|
|
62
|
+
undefined,
|
|
63
|
+
customUserAgentDetails
|
|
64
|
+
);
|
|
53
65
|
};
|
|
54
66
|
|
|
55
67
|
return context ? listWithContext : list;
|
|
@@ -62,6 +74,7 @@ function _list(
|
|
|
62
74
|
getInternals: ClientInternalsGetter,
|
|
63
75
|
args?: ListArgs & AuthModeParams,
|
|
64
76
|
contextSpec?: AmplifyServer.ContextSpec,
|
|
77
|
+
customUserAgentDetails?: CustomUserAgentDetails,
|
|
65
78
|
) {
|
|
66
79
|
return selfAwareAsync(async (resultPromise) => {
|
|
67
80
|
const { name } = model;
|
|
@@ -80,10 +93,11 @@ function _list(
|
|
|
80
93
|
);
|
|
81
94
|
|
|
82
95
|
const auth = authModeParams(client, getInternals, args);
|
|
96
|
+
const headers = getCustomHeaders(client, getInternals, args?.headers);
|
|
83
97
|
|
|
84
|
-
|
|
85
|
-
const headers = getCustomHeaders(client, getInternals, args?.headers);
|
|
98
|
+
const userAgentOverride = createUserAgentOverride(customUserAgentDetails);
|
|
86
99
|
|
|
100
|
+
try {
|
|
87
101
|
const basePromise = contextSpec
|
|
88
102
|
? ((client as BaseSSRClient).graphql(
|
|
89
103
|
contextSpec,
|
|
@@ -99,6 +113,7 @@ function _list(
|
|
|
99
113
|
...auth,
|
|
100
114
|
query,
|
|
101
115
|
variables,
|
|
116
|
+
...userAgentOverride,
|
|
102
117
|
},
|
|
103
118
|
headers,
|
|
104
119
|
) as Promise<GraphQLResult>);
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { createCreateConversationFunction } from '../../ai/createCreateConversationFunction';
|
|
12
12
|
import { createGetConversationFunction } from '../../ai/createGetConversationFunction';
|
|
13
13
|
import { createListConversationsFunction } from '../../ai/createListConversationsFunction';
|
|
14
|
+
import { createDeleteConversationFunction } from '../../ai/createDeleteConversationFunction';
|
|
14
15
|
|
|
15
16
|
export function generateConversationsProperty(
|
|
16
17
|
client: BaseClient,
|
|
@@ -76,6 +77,14 @@ export function generateConversationsProperty(
|
|
|
76
77
|
conversationMessageModel,
|
|
77
78
|
getInternals,
|
|
78
79
|
),
|
|
80
|
+
delete: createDeleteConversationFunction(
|
|
81
|
+
client,
|
|
82
|
+
conversationModelIntrospection,
|
|
83
|
+
name,
|
|
84
|
+
conversationModel,
|
|
85
|
+
conversationMessageModel,
|
|
86
|
+
getInternals,
|
|
87
|
+
),
|
|
79
88
|
list: createListConversationsFunction(
|
|
80
89
|
client,
|
|
81
90
|
conversationModelIntrospection,
|
|
@@ -9,6 +9,10 @@ import {
|
|
|
9
9
|
} from '../../../bridge-types';
|
|
10
10
|
import { CustomQueries } from '../../../client';
|
|
11
11
|
import { customOpFactory } from '../../operations/custom';
|
|
12
|
+
import {
|
|
13
|
+
AiAction,
|
|
14
|
+
getCustomUserAgentDetails,
|
|
15
|
+
} from '../../ai/getCustomUserAgentDetails';
|
|
12
16
|
|
|
13
17
|
export function generateGenerationsProperty<T extends Record<any, any>>(
|
|
14
18
|
client: BaseClient,
|
|
@@ -34,6 +38,7 @@ export function generateGenerationsProperty<T extends Record<any, any>>(
|
|
|
34
38
|
generation,
|
|
35
39
|
false,
|
|
36
40
|
getInternals,
|
|
41
|
+
getCustomUserAgentDetails(AiAction.Generation),
|
|
37
42
|
);
|
|
38
43
|
}
|
|
39
44
|
|