@aws-amplify/data-schema 1.6.2 → 1.6.3
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/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/generateGenerationsProperty.js +2 -1
- package/dist/cjs/runtime/internals/utils/clientProperties/generateGenerationsProperty.js.map +1 -1
- 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/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/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/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/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/generateGenerationsProperty.ts +5 -0
|
@@ -6,24 +6,26 @@ const APIClient_1 = require("../APIClient");
|
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
const utils_2 = require("../../utils");
|
|
8
8
|
const cancellation_1 = require("../cancellation");
|
|
9
|
-
|
|
9
|
+
const getCustomUserAgentDetails_1 = require("../ai/getCustomUserAgentDetails");
|
|
10
|
+
function listFactory(client, modelIntrospection, model, getInternals, context = false, customUserAgentDetails) {
|
|
10
11
|
const listWithContext = (contextSpec, args) => {
|
|
11
|
-
return _list(client, modelIntrospection, model, getInternals, args, contextSpec);
|
|
12
|
+
return _list(client, modelIntrospection, model, getInternals, args, contextSpec, customUserAgentDetails);
|
|
12
13
|
};
|
|
13
14
|
const list = (args) => {
|
|
14
|
-
return _list(client, modelIntrospection, model, getInternals, args);
|
|
15
|
+
return _list(client, modelIntrospection, model, getInternals, args, undefined, customUserAgentDetails);
|
|
15
16
|
};
|
|
16
17
|
return context ? listWithContext : list;
|
|
17
18
|
}
|
|
18
19
|
exports.listFactory = listFactory;
|
|
19
|
-
function _list(client, modelIntrospection, model, getInternals, args, contextSpec) {
|
|
20
|
+
function _list(client, modelIntrospection, model, getInternals, args, contextSpec, customUserAgentDetails) {
|
|
20
21
|
return (0, utils_2.selfAwareAsync)(async (resultPromise) => {
|
|
21
22
|
const { name } = model;
|
|
22
23
|
const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, 'LIST', args);
|
|
23
24
|
const variables = (0, APIClient_1.buildGraphQLVariables)(model, 'LIST', args, modelIntrospection);
|
|
24
25
|
const auth = (0, APIClient_1.authModeParams)(client, getInternals, args);
|
|
26
|
+
const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, args?.headers);
|
|
27
|
+
const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);
|
|
25
28
|
try {
|
|
26
|
-
const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, args?.headers);
|
|
27
29
|
const basePromise = contextSpec
|
|
28
30
|
? client.graphql(contextSpec, {
|
|
29
31
|
...auth,
|
|
@@ -34,6 +36,7 @@ function _list(client, modelIntrospection, model, getInternals, args, contextSpe
|
|
|
34
36
|
...auth,
|
|
35
37
|
query,
|
|
36
38
|
variables,
|
|
39
|
+
...userAgentOverride,
|
|
37
40
|
}, headers);
|
|
38
41
|
const extendedPromise = (0, cancellation_1.extendCancellability)(basePromise, resultPromise);
|
|
39
42
|
const { data, extensions } = await extendedPromise;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sources":["../../../../../src/runtime/internals/operations/list.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.listFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nconst utils_2 = require(\"../../utils\");\nconst cancellation_1 = require(\"../cancellation\");\nfunction listFactory(client, modelIntrospection, model, getInternals, context = false) {\n const listWithContext = (contextSpec, args) => {\n return _list(client, modelIntrospection, model, getInternals, args, contextSpec);\n };\n const list = (args) => {\n return _list(client, modelIntrospection, model, getInternals, args);\n };\n return context ? listWithContext : list;\n}\nexports.listFactory = listFactory;\nfunction _list(client, modelIntrospection, model, getInternals, args, contextSpec) {\n return (0, utils_2.selfAwareAsync)(async (resultPromise) => {\n const { name } = model;\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, 'LIST', args);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, 'LIST', args, modelIntrospection);\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, args);\n try {\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, args?.headers);\n const basePromise = contextSpec\n ? client.graphql(contextSpec, {\n ...auth,\n query,\n variables,\n }, headers)\n : client.graphql({\n ...auth,\n query,\n variables,\n }, headers);\n const extendedPromise = (0, cancellation_1.extendCancellability)(basePromise, resultPromise);\n const { data, extensions } = await extendedPromise;\n // flatten response\n if (data !== undefined) {\n const [key] = Object.keys(data);\n if (data[key].items) {\n const flattenedResult = data[key].items.map((value) => (0, APIClient_1.flattenItems)(modelIntrospection, name, value));\n // don't init if custom selection set\n if (args?.selectionSet) {\n return {\n data: flattenedResult,\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n else {\n const initialized = (0, APIClient_1.initializeModel)(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\n return {\n data: initialized,\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n }\n return {\n data: data[key],\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n }\n catch (error) {\n /**\n * The `data` type returned by `error` here could be:\n * 1) `null`\n * 2) an empty object\n * 3) \"populated\" but with a `null` value `data: { listPosts: null }`\n * 4) actual records `data: { listPosts: items: [{ id: '1', ...etc }] }`\n */\n const { data, errors } = error;\n // `data` is not `null`, and is not an empty object:\n if (data !== undefined &&\n data !== null &&\n Object.keys(data).length !== 0 &&\n errors) {\n const [key] = Object.keys(data);\n if (data[key]?.items) {\n const flattenedResult = data[key].items.map((value) => (0, APIClient_1.flattenItems)(modelIntrospection, name, value));\n /**\n * Check exists since `flattenedResult` could be `null`.\n * if `flattenedResult` exists, result is an actual record.\n */\n if (flattenedResult) {\n // don't init if custom selection set\n if (args?.selectionSet) {\n return {\n data: flattenedResult,\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n else {\n const initialized = (0, APIClient_1.initializeModel)(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\n // data is full record w/out selection set:\n return {\n data: initialized,\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n }\n return {\n data: data[key],\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n else {\n // response is of type `data: { getPost: null }`)\n return (0, utils_1.handleListGraphQlError)(error);\n }\n }\n else {\n // `data` is `null` or an empty object:\n return (0, utils_1.handleListGraphQlError)(error);\n }\n }\n });\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;AAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAClD,SAAS,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,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AAI,EAAE,YAAY,EAAE;AAChD,4BAA4B,OAAO;AACnC,gCAAgC,IAAI,EAAE,eAAe;AACrD,gCAAgC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS;AAC/D,gCAAgC,MAAM;AACtC,6BAA6B,CAAC;AAC9B,yBAAyB;AACzB,6BAA6B;AAC7B,4BAA4B,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;AAClL;AACA,4BAA4B,OAAO;AACnC,gCAAgC,IAAI,EAAE,WAAW;AACjD,gCAAgC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS;AAC/D,gCAAgC,MAAM;AACtC,6BAA6B,CAAC;AAC9B,yBAAyB;AACzB,qBAAqB;AACrB,oBAAoB,OAAO;AAC3B,wBAAwB,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AACvC,wBAAwB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS;AACvD,wBAAwB,MAAM;AAC9B,qBAAqB,CAAC;AACtB,iBAAiB;AACjB,qBAAqB;AACrB;AACA,oBAAoB,OAAO,IAAI,OAAO,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;AACtE,iBAAiB;AACjB,aAAa;AACb,iBAAiB;AACjB;AACA,gBAAgB,OAAO,IAAI,OAAO,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;AAClE,aAAa;AACb,SAAS;AACT,KAAK,CAAC,CAAC;AACP;;"}
|
|
1
|
+
{"version":3,"file":"list.js","sources":["../../../../../src/runtime/internals/operations/list.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.listFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nconst utils_2 = require(\"../../utils\");\nconst cancellation_1 = require(\"../cancellation\");\nconst getCustomUserAgentDetails_1 = require(\"../ai/getCustomUserAgentDetails\");\nfunction listFactory(client, modelIntrospection, model, getInternals, context = false, customUserAgentDetails) {\n const listWithContext = (contextSpec, args) => {\n return _list(client, modelIntrospection, model, getInternals, args, contextSpec, customUserAgentDetails);\n };\n const list = (args) => {\n return _list(client, modelIntrospection, model, getInternals, args, undefined, customUserAgentDetails);\n };\n return context ? listWithContext : list;\n}\nexports.listFactory = listFactory;\nfunction _list(client, modelIntrospection, model, getInternals, args, contextSpec, customUserAgentDetails) {\n return (0, utils_2.selfAwareAsync)(async (resultPromise) => {\n const { name } = model;\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, 'LIST', args);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, 'LIST', args, modelIntrospection);\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, args);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, args?.headers);\n const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);\n try {\n const basePromise = contextSpec\n ? client.graphql(contextSpec, {\n ...auth,\n query,\n variables,\n }, headers)\n : client.graphql({\n ...auth,\n query,\n variables,\n ...userAgentOverride,\n }, headers);\n const extendedPromise = (0, cancellation_1.extendCancellability)(basePromise, resultPromise);\n const { data, extensions } = await extendedPromise;\n // flatten response\n if (data !== undefined) {\n const [key] = Object.keys(data);\n if (data[key].items) {\n const flattenedResult = data[key].items.map((value) => (0, APIClient_1.flattenItems)(modelIntrospection, name, value));\n // don't init if custom selection set\n if (args?.selectionSet) {\n return {\n data: flattenedResult,\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n else {\n const initialized = (0, APIClient_1.initializeModel)(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\n return {\n data: initialized,\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n }\n return {\n data: data[key],\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n }\n catch (error) {\n /**\n * The `data` type returned by `error` here could be:\n * 1) `null`\n * 2) an empty object\n * 3) \"populated\" but with a `null` value `data: { listPosts: null }`\n * 4) actual records `data: { listPosts: items: [{ id: '1', ...etc }] }`\n */\n const { data, errors } = error;\n // `data` is not `null`, and is not an empty object:\n if (data !== undefined &&\n data !== null &&\n Object.keys(data).length !== 0 &&\n errors) {\n const [key] = Object.keys(data);\n if (data[key]?.items) {\n const flattenedResult = data[key].items.map((value) => (0, APIClient_1.flattenItems)(modelIntrospection, name, value));\n /**\n * Check exists since `flattenedResult` could be `null`.\n * if `flattenedResult` exists, result is an actual record.\n */\n if (flattenedResult) {\n // don't init if custom selection set\n if (args?.selectionSet) {\n return {\n data: flattenedResult,\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n else {\n const initialized = (0, APIClient_1.initializeModel)(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\n // data is full record w/out selection set:\n return {\n data: initialized,\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n }\n return {\n data: data[key],\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n else {\n // response is of type `data: { getPost: null }`)\n return (0, utils_1.handleListGraphQlError)(error);\n }\n }\n else {\n // `data` is `null` or an empty object:\n return (0, utils_1.handleListGraphQlError)(error);\n }\n }\n });\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;AAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAA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AAO,IAAI,OAAO,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;AAClE,aAAa;AACb,SAAS;AACT,KAAK,CAAC,CAAC;AACP;;"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.generateGenerationsProperty = void 0;
|
|
7
7
|
const custom_1 = require("../../operations/custom");
|
|
8
|
+
const getCustomUserAgentDetails_1 = require("../../ai/getCustomUserAgentDetails");
|
|
8
9
|
function generateGenerationsProperty(client, apiGraphQLConfig, getInternals) {
|
|
9
10
|
const modelIntrospection = apiGraphQLConfig?.modelIntrospection;
|
|
10
11
|
// generations will be absent from model intro schema if no generation routes
|
|
@@ -14,7 +15,7 @@ function generateGenerationsProperty(client, apiGraphQLConfig, getInternals) {
|
|
|
14
15
|
}
|
|
15
16
|
const generations = {};
|
|
16
17
|
for (const generation of Object.values(modelIntrospection.generations)) {
|
|
17
|
-
generations[generation.name] = (0, custom_1.customOpFactory)(client, modelIntrospection, 'query', generation, false, getInternals);
|
|
18
|
+
generations[generation.name] = (0, custom_1.customOpFactory)(client, modelIntrospection, 'query', generation, false, getInternals, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.Generation));
|
|
18
19
|
}
|
|
19
20
|
return generations;
|
|
20
21
|
}
|
package/dist/cjs/runtime/internals/utils/clientProperties/generateGenerationsProperty.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateGenerationsProperty.js","sources":["../../../../../../src/runtime/internals/utils/clientProperties/generateGenerationsProperty.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateGenerationsProperty = void 0;\nconst custom_1 = require(\"../../operations/custom\");\nfunction generateGenerationsProperty(client, apiGraphQLConfig, getInternals) {\n const modelIntrospection = apiGraphQLConfig?.modelIntrospection;\n // generations will be absent from model intro schema if no generation routes\n // are present on the source schema.\n if (!modelIntrospection?.generations) {\n return {};\n }\n const generations = {};\n for (const generation of Object.values(modelIntrospection.generations)) {\n generations[generation.name] = (0, custom_1.customOpFactory)(client, modelIntrospection, 'query', generation, false, getInternals);\n }\n return generations;\n}\nexports.generateGenerationsProperty = generateGenerationsProperty;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,2BAA2B,GAAG,KAAK,CAAC,CAAC;AAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACpD,SAAS,2BAA2B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE;AAC7E,IAAI,MAAM,kBAAkB,GAAG,gBAAgB,EAAE,kBAAkB,CAAC;AACpE;AACA;AACA,IAAI,IAAI,CAAC,kBAAkB,EAAE,WAAW,EAAE;AAC1C,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,WAAW,GAAG,EAAE,CAAC;AAC3B,IAAI,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE;AAC5E,QAAQ,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"generateGenerationsProperty.js","sources":["../../../../../../src/runtime/internals/utils/clientProperties/generateGenerationsProperty.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateGenerationsProperty = void 0;\nconst custom_1 = require(\"../../operations/custom\");\nconst getCustomUserAgentDetails_1 = require(\"../../ai/getCustomUserAgentDetails\");\nfunction generateGenerationsProperty(client, apiGraphQLConfig, getInternals) {\n const modelIntrospection = apiGraphQLConfig?.modelIntrospection;\n // generations will be absent from model intro schema if no generation routes\n // are present on the source schema.\n if (!modelIntrospection?.generations) {\n return {};\n }\n const generations = {};\n for (const generation of Object.values(modelIntrospection.generations)) {\n generations[generation.name] = (0, custom_1.customOpFactory)(client, modelIntrospection, 'query', generation, false, getInternals, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.Generation));\n }\n return generations;\n}\nexports.generateGenerationsProperty = generateGenerationsProperty;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,2BAA2B,GAAG,KAAK,CAAC,CAAC;AAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACpD,MAAM,2BAA2B,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAClF,SAAS,2BAA2B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE;AAC7E,IAAI,MAAM,kBAAkB,GAAG,gBAAgB,EAAE,kBAAkB,CAAC;AACpE;AACA;AACA,IAAI,IAAI,CAAC,kBAAkB,EAAE,WAAW,EAAE;AAC1C,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,WAAW,GAAG,EAAE,CAAC;AAC3B,IAAI,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE;AAC5E,QAAQ,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,2BAA2B,CAAC,yBAAyB,EAAE,2BAA2B,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AACxP,KAAK;AACL,IAAI,OAAO,WAAW,CAAC;AACvB,CAAC;AACD,OAAO,CAAC,2BAA2B,GAAG,2BAA2B;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isApiGraphQLConfig } from './internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs';
|
|
2
2
|
import { generateCustomQueriesProperty, generateCustomMutationsProperty } from './internals/generateCustomOperationsProperty.mjs';
|
|
3
3
|
import { upgradeClientCancellation } from './internals/cancellation.mjs';
|
|
4
|
+
import './internals/ai/getCustomUserAgentDetails.mjs';
|
|
4
5
|
import '@smithy/util-base64';
|
|
5
6
|
import 'rxjs';
|
|
6
7
|
import { generateEnumsProperty } from './internals/utils/clientProperties/generateEnumsProperty.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addSchemaToClientWithInstance.mjs","sources":["../../../src/runtime/addSchemaToClientWithInstance.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { isApiGraphQLConfig } from './internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig';\nimport { generateCustomQueriesProperty, generateCustomMutationsProperty, generateEnumsProperty, upgradeClientCancellation, } from './internals';\nimport { generateModelsProperty as generateModelsPropertyServer } from './internals/server';\n// TODO: separate import path\nexport function addSchemaToClientWithInstance(client, params, getInternals) {\n const apiGraphqlConfig = params.config?.API?.GraphQL;\n if (isApiGraphQLConfig(apiGraphqlConfig)) {\n upgradeClientCancellation(client);\n client.models = generateModelsPropertyServer(client, params, getInternals);\n client.enums = generateEnumsProperty(apiGraphqlConfig);\n client.queries = generateCustomQueriesProperty(client, apiGraphqlConfig, getInternals);\n client.mutations = generateCustomMutationsProperty(client, apiGraphqlConfig, getInternals);\n }\n return client;\n}\n"],"names":["generateModelsPropertyServer"],"mappings":"
|
|
1
|
+
{"version":3,"file":"addSchemaToClientWithInstance.mjs","sources":["../../../src/runtime/addSchemaToClientWithInstance.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { isApiGraphQLConfig } from './internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig';\nimport { generateCustomQueriesProperty, generateCustomMutationsProperty, generateEnumsProperty, upgradeClientCancellation, } from './internals';\nimport { generateModelsProperty as generateModelsPropertyServer } from './internals/server';\n// TODO: separate import path\nexport function addSchemaToClientWithInstance(client, params, getInternals) {\n const apiGraphqlConfig = params.config?.API?.GraphQL;\n if (isApiGraphQLConfig(apiGraphqlConfig)) {\n upgradeClientCancellation(client);\n client.models = generateModelsPropertyServer(client, params, getInternals);\n client.enums = generateEnumsProperty(apiGraphqlConfig);\n client.queries = generateCustomQueriesProperty(client, apiGraphqlConfig, getInternals);\n client.mutations = generateCustomMutationsProperty(client, apiGraphqlConfig, getInternals);\n }\n return client;\n}\n"],"names":["generateModelsPropertyServer"],"mappings":";;;;;;;;;AAAA;AACA;AAIA;AACO,SAAS,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE;AAC5E,IAAI,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;AACzD,IAAI,IAAI,kBAAkB,CAAC,gBAAgB,CAAC,EAAE;AAC9C,QAAQ,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAC1C,QAAQ,MAAM,CAAC,MAAM,GAAGA,sBAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACnF,QAAQ,MAAM,CAAC,KAAK,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;AAC/D,QAAQ,MAAM,CAAC,OAAO,GAAG,6BAA6B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC/F,QAAQ,MAAM,CAAC,SAAS,GAAG,+BAA+B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AACnG,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { Observable } from 'rxjs';
|
|
12
12
|
import { CustomHeaders, ModelSortDirection } from './client';
|
|
13
|
+
import { AiAction, AiCategory } from './internals/ai/getCustomUserAgentDetails';
|
|
13
14
|
export declare namespace AmplifyServer {
|
|
14
15
|
interface ContextToken {
|
|
15
16
|
readonly value: symbol;
|
|
@@ -302,6 +303,10 @@ export type BaseSSRClient = {
|
|
|
302
303
|
cancel(promise: Promise<any>, message?: string): boolean;
|
|
303
304
|
isCancelError(error: any): boolean;
|
|
304
305
|
};
|
|
305
|
-
export
|
|
306
|
+
export interface CustomUserAgentDetails {
|
|
307
|
+
category: AiCategory;
|
|
308
|
+
action: AiAction;
|
|
309
|
+
}
|
|
310
|
+
export type GraphQLMethod = (options: GraphQLOptions, additionalHeaders?: CustomHeaders | undefined, customUserAgentDetails?: CustomUserAgentDetails) => Promise<GraphQLResult> | GraphqlSubscriptionResult;
|
|
306
311
|
export type GraphQLMethodSSR = (contextSpec: AmplifyServer.ContextSpec, options: GraphQLOptions, additionalHeaders?: CustomHeaders | undefined) => Promise<GraphQLResult> | GraphqlSubscriptionResult;
|
|
307
312
|
export {};
|
|
@@ -2,3 +2,4 @@ export * from './client';
|
|
|
2
2
|
export { addSchemaToClient } from './addSchemaToClient';
|
|
3
3
|
export { addSchemaToClientWithInstance } from './addSchemaToClientWithInstance';
|
|
4
4
|
export { BaseClient, ClientInternals } from './bridge-types';
|
|
5
|
+
export { INTERNAL_USER_AGENT_OVERRIDE } from './internals/ai/getCustomUserAgentDetails';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { __modelMeta__ } from '@aws-amplify/data-schema-types';
|
|
2
2
|
export { addSchemaToClient } from './addSchemaToClient.mjs';
|
|
3
3
|
export { addSchemaToClientWithInstance } from './addSchemaToClientWithInstance.mjs';
|
|
4
|
+
export { INTERNAL_USER_AGENT_OVERRIDE } from './internals/ai/getCustomUserAgentDetails.mjs';
|
|
4
5
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ConversationRoute } from '../../../ai/ConversationType';
|
|
2
|
-
import
|
|
2
|
+
import { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema, SchemaModel } from '../../bridge-types';
|
|
3
3
|
export declare const createCreateConversationFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationRouteName: string, conversationModel: SchemaModel, conversationMessageModel: SchemaModel, getInternals: ClientInternalsGetter) => ConversationRoute['create'];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getFactory } from '../operations/get.mjs';
|
|
2
2
|
import { convertItemToConversation } from './convertItemToConversation.mjs';
|
|
3
|
+
import { getCustomUserAgentDetails, AiAction } from './getCustomUserAgentDetails.mjs';
|
|
3
4
|
|
|
4
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
7
|
const createCreateConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async () => {
|
|
7
|
-
const get = getFactory(client, modelIntrospection, conversationModel, 'CREATE', getInternals);
|
|
8
|
+
const get = getFactory(client, modelIntrospection, conversationModel, 'CREATE', getInternals, false, getCustomUserAgentDetails(AiAction.CreateConversation));
|
|
8
9
|
const { data, errors } = await get();
|
|
9
10
|
return {
|
|
10
11
|
data: convertItemToConversation(client, modelIntrospection, data?.id, conversationRouteName, conversationMessageModel, getInternals),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCreateConversationFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createCreateConversationFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getFactory } from '../operations/get';\nimport { convertItemToConversation } from './convertItemToConversation';\nexport const createCreateConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async () => {\n const get = getFactory(client, modelIntrospection, conversationModel, 'CREATE', getInternals);\n const { data, errors } = await get();\n return {\n data: convertItemToConversation(client, modelIntrospection, data?.id, conversationRouteName, conversationMessageModel, getInternals),\n errors,\n };\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createCreateConversationFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createCreateConversationFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getFactory } from '../operations/get';\nimport { convertItemToConversation } from './convertItemToConversation';\nimport { AiAction, getCustomUserAgentDetails, } from './getCustomUserAgentDetails';\nexport const createCreateConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async () => {\n const get = getFactory(client, modelIntrospection, conversationModel, 'CREATE', getInternals, false, getCustomUserAgentDetails(AiAction.CreateConversation));\n const { data, errors } = await get();\n return {\n data: convertItemToConversation(client, modelIntrospection, data?.id, conversationRouteName, conversationMessageModel, getInternals),\n errors,\n };\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,gCAAgC,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,YAAY;AAC9K,IAAI,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,yBAAyB,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC;AACjK,IAAI,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,EAAE,CAAC;AACzC,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,YAAY,CAAC;AAC5I,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ConversationRoute } from '../../../ai/ConversationType';
|
|
2
|
-
import
|
|
2
|
+
import { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema, SchemaModel } from '../../bridge-types';
|
|
3
3
|
export declare const createGetConversationFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationRouteName: string, conversationModel: SchemaModel, conversationMessageModel: SchemaModel, getInternals: ClientInternalsGetter) => ConversationRoute['get'];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getFactory } from '../operations/get.mjs';
|
|
2
2
|
import { convertItemToConversation } from './convertItemToConversation.mjs';
|
|
3
|
+
import { getCustomUserAgentDetails, AiAction } from './getCustomUserAgentDetails.mjs';
|
|
3
4
|
|
|
4
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
7
|
const createGetConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async ({ id }) => {
|
|
7
|
-
const get = getFactory(client, modelIntrospection, conversationModel, 'GET', getInternals);
|
|
8
|
+
const get = getFactory(client, modelIntrospection, conversationModel, 'GET', getInternals, false, getCustomUserAgentDetails(AiAction.GetConversation));
|
|
8
9
|
const { data, errors } = await get({ id });
|
|
9
10
|
return {
|
|
10
11
|
data: data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGetConversationFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createGetConversationFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getFactory } from '../operations/get';\nimport { convertItemToConversation } from './convertItemToConversation';\nexport const createGetConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async ({ id }) => {\n const get = getFactory(client, modelIntrospection, conversationModel, 'GET', getInternals);\n const { data, errors } = await get({ id });\n return {\n data: data\n ? convertItemToConversation(client, modelIntrospection, data.id, conversationRouteName, conversationMessageModel, getInternals)\n : data,\n errors,\n };\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createGetConversationFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createGetConversationFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getFactory } from '../operations/get';\nimport { convertItemToConversation } from './convertItemToConversation';\nimport { AiAction, getCustomUserAgentDetails, } from './getCustomUserAgentDetails';\nexport const createGetConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async ({ id }) => {\n const get = getFactory(client, modelIntrospection, conversationModel, 'GET', getInternals, false, getCustomUserAgentDetails(AiAction.GetConversation));\n const { data, errors } = await get({ id });\n return {\n data: data\n ? convertItemToConversation(client, modelIntrospection, data.id, conversationRouteName, conversationMessageModel, getInternals)\n : data,\n errors,\n };\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,6BAA6B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,OAAO,EAAE,EAAE,EAAE,KAAK;AACjL,IAAI,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,yBAAyB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;AAC3J,IAAI,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/C,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,IAAI;AAClB,cAAc,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,YAAY,CAAC;AAC3I,cAAc,IAAI;AAClB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ConversationRoute } from '../../../ai/ConversationType';
|
|
2
|
-
import
|
|
2
|
+
import { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema, SchemaModel } from '../../bridge-types';
|
|
3
3
|
export declare const createListConversationsFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationRouteName: string, conversationModel: SchemaModel, conversationMessageModel: SchemaModel, getInternals: ClientInternalsGetter) => ConversationRoute['list'];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { listFactory } from '../operations/list.mjs';
|
|
2
2
|
import { convertItemToConversation } from './convertItemToConversation.mjs';
|
|
3
|
+
import { getCustomUserAgentDetails, AiAction } from './getCustomUserAgentDetails.mjs';
|
|
3
4
|
|
|
4
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
7
|
const createListConversationsFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async (input) => {
|
|
7
|
-
const list = listFactory(client, modelIntrospection, conversationModel, getInternals);
|
|
8
|
+
const list = listFactory(client, modelIntrospection, conversationModel, getInternals, false, getCustomUserAgentDetails(AiAction.ListConversations));
|
|
8
9
|
const { data, nextToken, errors } = await list(input);
|
|
9
10
|
return {
|
|
10
11
|
data: data.map((datum) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createListConversationsFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createListConversationsFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { listFactory } from '../operations/list';\nimport { convertItemToConversation } from './convertItemToConversation';\nexport const createListConversationsFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async (input) => {\n const list = listFactory(client, modelIntrospection, conversationModel, getInternals);\n const { data, nextToken, errors } = await list(input);\n return {\n data: data.map((datum) => {\n return convertItemToConversation(client, modelIntrospection, datum.id, conversationRouteName, conversationMessageModel, getInternals);\n }),\n nextToken,\n errors,\n };\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createListConversationsFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createListConversationsFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { listFactory } from '../operations/list';\nimport { convertItemToConversation } from './convertItemToConversation';\nimport { AiAction, getCustomUserAgentDetails, } from './getCustomUserAgentDetails';\nexport const createListConversationsFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async (input) => {\n const list = listFactory(client, modelIntrospection, conversationModel, getInternals, false, getCustomUserAgentDetails(AiAction.ListConversations));\n const { data, nextToken, errors } = await list(input);\n return {\n data: data.map((datum) => {\n return convertItemToConversation(client, modelIntrospection, datum.id, conversationRouteName, conversationMessageModel, getInternals);\n }),\n nextToken,\n errors,\n };\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,+BAA+B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,OAAO,KAAK,KAAK;AAClL,IAAI,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,YAAY,EAAE,KAAK,EAAE,yBAAyB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC;AACxJ,IAAI,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1D,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK;AAClC,YAAY,OAAO,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,CAAC,EAAE,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,YAAY,CAAC,CAAC;AAClJ,SAAS,CAAC;AACV,QAAQ,SAAS;AACjB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Conversation } from '../../../ai/ConversationType';
|
|
2
|
-
import
|
|
2
|
+
import { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema, SchemaModel } from '../../bridge-types';
|
|
3
3
|
export declare const createListMessagesFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationId: string, conversationMessageModel: SchemaModel, getInternals: ClientInternalsGetter) => Conversation['listMessages'];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { listFactory } from '../operations/list.mjs';
|
|
2
2
|
import { convertItemToConversationMessage } from './convertItemToConversationMessage.mjs';
|
|
3
|
+
import { getCustomUserAgentDetails, AiAction } from './getCustomUserAgentDetails.mjs';
|
|
3
4
|
|
|
4
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
7
|
const createListMessagesFunction = (client, modelIntrospection, conversationId, conversationMessageModel, getInternals) => async (input) => {
|
|
7
|
-
const list = listFactory(client, modelIntrospection, conversationMessageModel, getInternals);
|
|
8
|
+
const list = listFactory(client, modelIntrospection, conversationMessageModel, getInternals, false, getCustomUserAgentDetails(AiAction.ListMessages));
|
|
8
9
|
const { data, nextToken, errors } = await list({
|
|
9
10
|
...input,
|
|
10
11
|
filter: { conversationId: { eq: conversationId } },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createListMessagesFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createListMessagesFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { listFactory } from '../operations/list';\nimport { convertItemToConversationMessage } from './convertItemToConversationMessage';\nexport const createListMessagesFunction = (client, modelIntrospection, conversationId, conversationMessageModel, getInternals) => async (input) => {\n const list = listFactory(client, modelIntrospection, conversationMessageModel, getInternals);\n const { data, nextToken, errors } = await list({\n ...input,\n filter: { conversationId: { eq: conversationId } },\n });\n return {\n data: data.map((item) => convertItemToConversationMessage(item)),\n nextToken,\n errors,\n };\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createListMessagesFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createListMessagesFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { listFactory } from '../operations/list';\nimport { convertItemToConversationMessage } from './convertItemToConversationMessage';\nimport { AiAction, getCustomUserAgentDetails, } from './getCustomUserAgentDetails';\nexport const createListMessagesFunction = (client, modelIntrospection, conversationId, conversationMessageModel, getInternals) => async (input) => {\n const list = listFactory(client, modelIntrospection, conversationMessageModel, getInternals, false, getCustomUserAgentDetails(AiAction.ListMessages));\n const { data, nextToken, errors } = await list({\n ...input,\n filter: { conversationId: { eq: conversationId } },\n });\n return {\n data: data.map((item) => convertItemToConversationMessage(item)),\n nextToken,\n errors,\n };\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,0BAA0B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,wBAAwB,EAAE,YAAY,KAAK,OAAO,KAAK,KAAK;AACnJ,IAAI,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,YAAY,EAAE,KAAK,EAAE,yBAAyB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;AAC1J,IAAI,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC;AACnD,QAAQ,GAAG,KAAK;AAChB,QAAQ,MAAM,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE;AAC1D,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,gCAAgC,CAAC,IAAI,CAAC,CAAC;AACxE,QAAQ,SAAS;AACjB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Conversation } from '../../../ai/ConversationType';
|
|
2
|
-
import
|
|
2
|
+
import { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema } from '../../bridge-types';
|
|
3
3
|
export declare const createOnMessageFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationId: string, conversationRouteName: string, getInternals: ClientInternalsGetter) => Conversation['onMessage'];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { customOpFactory } from '../operations/custom.mjs';
|
|
2
2
|
import { convertItemToConversationMessage } from './convertItemToConversationMessage.mjs';
|
|
3
|
+
import { getCustomUserAgentDetails, AiAction } from './getCustomUserAgentDetails.mjs';
|
|
3
4
|
|
|
4
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -10,7 +11,7 @@ const createOnMessageFunction = (client, modelIntrospection, conversationId, con
|
|
|
10
11
|
return {};
|
|
11
12
|
}
|
|
12
13
|
const subscribeSchema = conversations[conversationRouteName].message.subscribe;
|
|
13
|
-
const subscribeOperation = customOpFactory(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals);
|
|
14
|
+
const subscribeOperation = customOpFactory(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals, getCustomUserAgentDetails(AiAction.OnMessage));
|
|
14
15
|
return subscribeOperation({ conversationId }).subscribe((data) => {
|
|
15
16
|
handler(convertItemToConversationMessage(data));
|
|
16
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOnMessageFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createOnMessageFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { customOpFactory } from '../operations/custom';\nimport { convertItemToConversationMessage } from './convertItemToConversationMessage';\nexport const createOnMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => (handler) => {\n const { conversations } = modelIntrospection;\n // Safe guard for standalone function. When called as part of client generation, this should never be falsy.\n if (!conversations) {\n return {};\n }\n const subscribeSchema = conversations[conversationRouteName].message.subscribe;\n const subscribeOperation = customOpFactory(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals);\n return subscribeOperation({ conversationId }).subscribe((data) => {\n handler(convertItemToConversationMessage(data));\n });\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createOnMessageFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createOnMessageFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { customOpFactory } from '../operations/custom';\nimport { convertItemToConversationMessage } from './convertItemToConversationMessage';\nimport { AiAction, getCustomUserAgentDetails } from './getCustomUserAgentDetails';\nexport const createOnMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => (handler) => {\n const { conversations } = modelIntrospection;\n // Safe guard for standalone function. When called as part of client generation, this should never be falsy.\n if (!conversations) {\n return {};\n }\n const subscribeSchema = conversations[conversationRouteName].message.subscribe;\n const subscribeOperation = customOpFactory(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals, getCustomUserAgentDetails(AiAction.OnMessage));\n return subscribeOperation({ conversationId }).subscribe((data) => {\n handler(convertItemToConversationMessage(data));\n });\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,uBAAuB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,KAAK,CAAC,OAAO,KAAK;AACzI,IAAI,MAAM,EAAE,aAAa,EAAE,GAAG,kBAAkB,CAAC;AACjD;AACA,IAAI,IAAI,CAAC,aAAa,EAAE;AACxB,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,eAAe,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;AACnF,IAAI,MAAM,kBAAkB,GAAG,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,EAAE,yBAAyB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AAChL,IAAI,OAAO,kBAAkB,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK;AACtE,QAAQ,OAAO,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,KAAK,CAAC,CAAC;AACP;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Conversation } from '../../../ai/ConversationType';
|
|
2
|
-
import
|
|
2
|
+
import { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema } from '../../bridge-types';
|
|
3
3
|
export declare const createSendMessageFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationId: string, conversationRouteName: string, getInternals: ClientInternalsGetter) => Conversation['sendMessage'];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { customOpFactory } from '../operations/custom.mjs';
|
|
2
2
|
import { convertItemToConversationMessage } from './convertItemToConversationMessage.mjs';
|
|
3
3
|
import { serializeContent, serializeAiContext, serializeToolConfiguration } from './conversationMessageSerializers.mjs';
|
|
4
|
+
import { getCustomUserAgentDetails, AiAction } from './getCustomUserAgentDetails.mjs';
|
|
4
5
|
|
|
5
6
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
7
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -11,7 +12,7 @@ const createSendMessageFunction = (client, modelIntrospection, conversationId, c
|
|
|
11
12
|
return {};
|
|
12
13
|
}
|
|
13
14
|
const sendSchema = conversations[conversationRouteName].message.send;
|
|
14
|
-
const sendOperation = customOpFactory(client, modelIntrospection, 'mutation', sendSchema, false, getInternals);
|
|
15
|
+
const sendOperation = customOpFactory(client, modelIntrospection, 'mutation', sendSchema, false, getInternals, getCustomUserAgentDetails(AiAction.SendMessage));
|
|
15
16
|
const { data, errors } = await sendOperation({
|
|
16
17
|
conversationId,
|
|
17
18
|
content: serializeContent(content),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSendMessageFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createSendMessageFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { customOpFactory } from '../operations/custom';\nimport { convertItemToConversationMessage } from './convertItemToConversationMessage';\nimport { serializeAiContext, serializeContent, serializeToolConfiguration, } from './conversationMessageSerializers';\nexport const createSendMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => async ({ aiContext, content, toolConfiguration }) => {\n const { conversations } = modelIntrospection;\n // Safe guard for standalone function. When called as part of client generation, this should never be falsy.\n if (!conversations) {\n return {};\n }\n const sendSchema = conversations[conversationRouteName].message.send;\n const sendOperation = customOpFactory(client, modelIntrospection, 'mutation', sendSchema, false, getInternals);\n const { data, errors } = await sendOperation({\n conversationId,\n content: serializeContent(content),\n ...(aiContext && { aiContext: serializeAiContext(aiContext) }),\n ...(toolConfiguration && {\n toolConfiguration: serializeToolConfiguration(toolConfiguration),\n }),\n });\n return {\n data: data ? convertItemToConversationMessage(data) : data,\n errors,\n };\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createSendMessageFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createSendMessageFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { customOpFactory } from '../operations/custom';\nimport { convertItemToConversationMessage } from './convertItemToConversationMessage';\nimport { serializeAiContext, serializeContent, serializeToolConfiguration, } from './conversationMessageSerializers';\nimport { AiAction, getCustomUserAgentDetails, } from './getCustomUserAgentDetails';\nexport const createSendMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => async ({ aiContext, content, toolConfiguration }) => {\n const { conversations } = modelIntrospection;\n // Safe guard for standalone function. When called as part of client generation, this should never be falsy.\n if (!conversations) {\n return {};\n }\n const sendSchema = conversations[conversationRouteName].message.send;\n const sendOperation = customOpFactory(client, modelIntrospection, 'mutation', sendSchema, false, getInternals, getCustomUserAgentDetails(AiAction.SendMessage));\n const { data, errors } = await sendOperation({\n conversationId,\n content: serializeContent(content),\n ...(aiContext && { aiContext: serializeAiContext(aiContext) }),\n ...(toolConfiguration && {\n toolConfiguration: serializeToolConfiguration(toolConfiguration),\n }),\n });\n return {\n data: data ? convertItemToConversationMessage(data) : data,\n errors,\n };\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKY,MAAC,yBAAyB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,KAAK,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAK;AACnL,IAAI,MAAM,EAAE,aAAa,EAAE,GAAG,kBAAkB,CAAC;AACjD;AACA,IAAI,IAAI,CAAC,aAAa,EAAE;AACxB,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,UAAU,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;AACzE,IAAI,MAAM,aAAa,GAAG,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,yBAAyB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;AACpK,IAAI,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC;AACjD,QAAQ,cAAc;AACtB,QAAQ,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC;AAC1C,QAAQ,IAAI,SAAS,IAAI,EAAE,SAAS,EAAE,kBAAkB,CAAC,SAAS,CAAC,EAAE;AACrE,QAAQ,IAAI,iBAAiB,IAAI;AACjC,YAAY,iBAAiB,EAAE,0BAA0B,CAAC,iBAAiB,CAAC;AAC5E,SAAS;AACT,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,IAAI,GAAG,gCAAgC,CAAC,IAAI,CAAC,GAAG,IAAI;AAClE,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CustomUserAgentDetails } from '../../bridge-types';
|
|
2
|
+
/**
|
|
3
|
+
* Symbol used for internal user agent overrides.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
* This symbol is intended for internal use within the Amplify library.
|
|
7
|
+
* It may change or be removed in future versions without notice.
|
|
8
|
+
* External usage of this symbol is discouraged and may lead to unexpected behavior.
|
|
9
|
+
*/
|
|
10
|
+
export declare const INTERNAL_USER_AGENT_OVERRIDE: unique symbol;
|
|
11
|
+
export type AiCategory = 'ai';
|
|
12
|
+
export declare enum AiAction {
|
|
13
|
+
CreateConversation = "1",
|
|
14
|
+
GetConversation = "2",
|
|
15
|
+
ListConversations = "3",
|
|
16
|
+
SendMessage = "4",
|
|
17
|
+
ListMessages = "5",
|
|
18
|
+
OnMessage = "6",
|
|
19
|
+
Generation = "7",
|
|
20
|
+
Delete = "8"
|
|
21
|
+
}
|
|
22
|
+
export declare const getCustomUserAgentDetails: (action: AiAction) => CustomUserAgentDetails;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a user agent override object based on custom details.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
* This function is intended for internal use within the Amplify library.
|
|
28
|
+
* It may change or be removed in future versions without notice.
|
|
29
|
+
*
|
|
30
|
+
* @param customUserAgentDetails - Optional custom user agent details
|
|
31
|
+
* @returns An object with INTERNAL_USER_AGENT_OVERRIDE symbol as key and customUserAgentDetails as value, or undefined if no details provided
|
|
32
|
+
*/
|
|
33
|
+
export declare function createUserAgentOverride(customUserAgentDetails?: CustomUserAgentDetails): {
|
|
34
|
+
[INTERNAL_USER_AGENT_OVERRIDE]?: CustomUserAgentDetails;
|
|
35
|
+
} | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* Symbol used for internal user agent overrides.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
* This symbol is intended for internal use within the Amplify library.
|
|
8
|
+
* It may change or be removed in future versions without notice.
|
|
9
|
+
* External usage of this symbol is discouraged and may lead to unexpected behavior.
|
|
10
|
+
*/
|
|
11
|
+
const INTERNAL_USER_AGENT_OVERRIDE = Symbol('INTERNAL_USER_AGENT_OVERRIDE');
|
|
12
|
+
var AiAction;
|
|
13
|
+
(function (AiAction) {
|
|
14
|
+
AiAction["CreateConversation"] = "1";
|
|
15
|
+
AiAction["GetConversation"] = "2";
|
|
16
|
+
AiAction["ListConversations"] = "3";
|
|
17
|
+
AiAction["SendMessage"] = "4";
|
|
18
|
+
AiAction["ListMessages"] = "5";
|
|
19
|
+
AiAction["OnMessage"] = "6";
|
|
20
|
+
AiAction["Generation"] = "7";
|
|
21
|
+
AiAction["Delete"] = "8";
|
|
22
|
+
})(AiAction || (AiAction = {}));
|
|
23
|
+
const getCustomUserAgentDetails = (action) => ({
|
|
24
|
+
category: 'ai',
|
|
25
|
+
action,
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Creates a user agent override object based on custom details.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
* This function is intended for internal use within the Amplify library.
|
|
32
|
+
* It may change or be removed in future versions without notice.
|
|
33
|
+
*
|
|
34
|
+
* @param customUserAgentDetails - Optional custom user agent details
|
|
35
|
+
* @returns An object with INTERNAL_USER_AGENT_OVERRIDE symbol as key and customUserAgentDetails as value, or undefined if no details provided
|
|
36
|
+
*/
|
|
37
|
+
function createUserAgentOverride(customUserAgentDetails) {
|
|
38
|
+
return customUserAgentDetails
|
|
39
|
+
? { [INTERNAL_USER_AGENT_OVERRIDE]: customUserAgentDetails }
|
|
40
|
+
: undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { AiAction, INTERNAL_USER_AGENT_OVERRIDE, createUserAgentOverride, getCustomUserAgentDetails };
|
|
44
|
+
//# sourceMappingURL=getCustomUserAgentDetails.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCustomUserAgentDetails.mjs","sources":["../../../../../src/runtime/internals/ai/getCustomUserAgentDetails.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Symbol used for internal user agent overrides.\n *\n * @internal\n * This symbol is intended for internal use within the Amplify library.\n * It may change or be removed in future versions without notice.\n * External usage of this symbol is discouraged and may lead to unexpected behavior.\n */\nexport const INTERNAL_USER_AGENT_OVERRIDE = Symbol('INTERNAL_USER_AGENT_OVERRIDE');\nexport var AiAction;\n(function (AiAction) {\n AiAction[\"CreateConversation\"] = \"1\";\n AiAction[\"GetConversation\"] = \"2\";\n AiAction[\"ListConversations\"] = \"3\";\n AiAction[\"SendMessage\"] = \"4\";\n AiAction[\"ListMessages\"] = \"5\";\n AiAction[\"OnMessage\"] = \"6\";\n AiAction[\"Generation\"] = \"7\";\n AiAction[\"Delete\"] = \"8\";\n})(AiAction || (AiAction = {}));\nexport const getCustomUserAgentDetails = (action) => ({\n category: 'ai',\n action,\n});\n/**\n * Creates a user agent override object based on custom details.\n *\n * @internal\n * This function is intended for internal use within the Amplify library.\n * It may change or be removed in future versions without notice.\n *\n * @param customUserAgentDetails - Optional custom user agent details\n * @returns An object with INTERNAL_USER_AGENT_OVERRIDE symbol as key and customUserAgentDetails as value, or undefined if no details provided\n */\nexport function createUserAgentOverride(customUserAgentDetails) {\n return customUserAgentDetails\n ? { [INTERNAL_USER_AGENT_OVERRIDE]: customUserAgentDetails }\n : undefined;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,4BAA4B,GAAG,MAAM,CAAC,8BAA8B,EAAE;AACzE,IAAC,SAAS;AACpB,CAAC,UAAU,QAAQ,EAAE;AACrB,IAAI,QAAQ,CAAC,oBAAoB,CAAC,GAAG,GAAG,CAAC;AACzC,IAAI,QAAQ,CAAC,iBAAiB,CAAC,GAAG,GAAG,CAAC;AACtC,IAAI,QAAQ,CAAC,mBAAmB,CAAC,GAAG,GAAG,CAAC;AACxC,IAAI,QAAQ,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC;AAClC,IAAI,QAAQ,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC;AACnC,IAAI,QAAQ,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC;AAChC,IAAI,QAAQ,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC;AACjC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;AAC7B,CAAC,EAAE,QAAQ,KAAK,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;AACpB,MAAC,yBAAyB,GAAG,CAAC,MAAM,MAAM;AACtD,IAAI,QAAQ,EAAE,IAAI;AAClB,IAAI,MAAM;AACV,CAAC,EAAE;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,sBAAsB,EAAE;AAChE,IAAI,OAAO,sBAAsB;AACjC,UAAU,EAAE,CAAC,4BAA4B,GAAG,sBAAsB,EAAE;AACpE,UAAU,SAAS,CAAC;AACpB;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthModeParams, AmplifyServer, BaseClient, ClientInternalsGetter, CustomOperation, ListArgs, QueryArgs, ModelIntrospectionSchema } from '../../bridge-types';
|
|
1
|
+
import { AuthModeParams, AmplifyServer, BaseClient, ClientInternalsGetter, CustomOperation, ListArgs, QueryArgs, ModelIntrospectionSchema, CustomUserAgentDetails } from '../../bridge-types';
|
|
2
2
|
type CustomOperationOptions = AuthModeParams & ListArgs;
|
|
3
3
|
type OpArgs = [AmplifyServer.ContextSpec, QueryArgs, CustomOperationOptions] | [AmplifyServer.ContextSpec, CustomOperationOptions] | [QueryArgs, CustomOperationOptions] | [CustomOperationOptions];
|
|
4
4
|
/**
|
|
@@ -57,5 +57,5 @@ type OpArgs = [AmplifyServer.ContextSpec, QueryArgs, CustomOperationOptions] | [
|
|
|
57
57
|
* @param useContext Whether the function needs to accept an SSR context.
|
|
58
58
|
* @returns The operation function to attach to query, mutations, etc.
|
|
59
59
|
*/
|
|
60
|
-
export declare function customOpFactory(client: BaseClient, modelIntrospection: ModelIntrospectionSchema, operationType: 'query' | 'mutation' | 'subscription', operation: CustomOperation, useContext: boolean, getInternals: ClientInternalsGetter): (...args: OpArgs) => import("rxjs").Observable<any> | Promise<unknown>;
|
|
60
|
+
export declare function customOpFactory(client: BaseClient, modelIntrospection: ModelIntrospectionSchema, operationType: 'query' | 'mutation' | 'subscription', operation: CustomOperation, useContext: boolean, getInternals: ClientInternalsGetter, customUserAgentDetails?: CustomUserAgentDetails): (...args: OpArgs) => import("rxjs").Observable<any> | Promise<unknown>;
|
|
61
61
|
export {};
|
|
@@ -3,6 +3,7 @@ import { authModeParams, getCustomHeaders, initializeModel, selectionSetIRToStri
|
|
|
3
3
|
import { handleSingularGraphQlError } from './utils.mjs';
|
|
4
4
|
import { selfAwareAsync } from '../../utils/selfAwareAsync.mjs';
|
|
5
5
|
import { extendCancellability } from '../cancellation.mjs';
|
|
6
|
+
import { createUserAgentOverride } from '../ai/getCustomUserAgentDetails.mjs';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Type guard for checking whether a Custom Operation argument is a contextSpec object
|
|
@@ -66,7 +67,7 @@ const argIsContextSpec = (arg) => {
|
|
|
66
67
|
* @param useContext Whether the function needs to accept an SSR context.
|
|
67
68
|
* @returns The operation function to attach to query, mutations, etc.
|
|
68
69
|
*/
|
|
69
|
-
function customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals) {
|
|
70
|
+
function customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals, customUserAgentDetails) {
|
|
70
71
|
// .arguments() are defined for the custom operation in the schema builder
|
|
71
72
|
// and are present in the model introspection schema
|
|
72
73
|
const argsDefined = operation.arguments !== undefined;
|
|
@@ -94,9 +95,9 @@ function customOpFactory(client, modelIntrospection, operationType, operation, u
|
|
|
94
95
|
if (operationType === 'subscription') {
|
|
95
96
|
return _opSubscription(
|
|
96
97
|
// subscriptions are only enabled on the clientside
|
|
97
|
-
client, modelIntrospection, operation, getInternals, arg, options);
|
|
98
|
+
client, modelIntrospection, operation, getInternals, arg, options, customUserAgentDetails);
|
|
98
99
|
}
|
|
99
|
-
return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec);
|
|
100
|
+
return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec, customUserAgentDetails);
|
|
100
101
|
};
|
|
101
102
|
return op;
|
|
102
103
|
}
|
|
@@ -276,7 +277,7 @@ function operationVariables(operation, args = {}) {
|
|
|
276
277
|
* @param context SSR context if relevant.
|
|
277
278
|
* @returns Result from the graphql request, model-instantiated when relevant.
|
|
278
279
|
*/
|
|
279
|
-
function _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context) {
|
|
280
|
+
function _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context, customUserAgentDetails) {
|
|
280
281
|
return selfAwareAsync(async (resultPromise) => {
|
|
281
282
|
const { name: operationName } = operation;
|
|
282
283
|
const auth = authModeParams(client, getInternals, options);
|
|
@@ -293,6 +294,7 @@ function _op(client, modelIntrospection, operationType, operation, getInternals,
|
|
|
293
294
|
}
|
|
294
295
|
`;
|
|
295
296
|
const variables = operationVariables(operation, args);
|
|
297
|
+
const userAgentOverride = createUserAgentOverride(customUserAgentDetails);
|
|
296
298
|
try {
|
|
297
299
|
const basePromise = context
|
|
298
300
|
? client.graphql(context, {
|
|
@@ -304,6 +306,7 @@ function _op(client, modelIntrospection, operationType, operation, getInternals,
|
|
|
304
306
|
...auth,
|
|
305
307
|
query,
|
|
306
308
|
variables,
|
|
309
|
+
...userAgentOverride,
|
|
307
310
|
}, headers);
|
|
308
311
|
const extendedPromise = extendCancellability(basePromise, resultPromise);
|
|
309
312
|
const { data, extensions } = await extendedPromise;
|
|
@@ -396,7 +399,7 @@ function _op(client, modelIntrospection, operationType, operation, getInternals,
|
|
|
396
399
|
* @param options Request options like headers, etc.
|
|
397
400
|
* @returns Result from the graphql request, model-instantiated when relevant.
|
|
398
401
|
*/
|
|
399
|
-
function _opSubscription(client, modelIntrospection, operation, getInternals, args, options) {
|
|
402
|
+
function _opSubscription(client, modelIntrospection, operation, getInternals, args, options, customUserAgentDetails) {
|
|
400
403
|
const operationType = 'subscription';
|
|
401
404
|
const { name: operationName } = operation;
|
|
402
405
|
const auth = authModeParams(client, getInternals, options);
|
|
@@ -413,10 +416,12 @@ function _opSubscription(client, modelIntrospection, operation, getInternals, ar
|
|
|
413
416
|
}
|
|
414
417
|
`;
|
|
415
418
|
const variables = operationVariables(operation, args);
|
|
419
|
+
const userAgentOverride = createUserAgentOverride(customUserAgentDetails);
|
|
416
420
|
const observable = client.graphql({
|
|
417
421
|
...auth,
|
|
418
422
|
query,
|
|
419
423
|
variables,
|
|
424
|
+
...userAgentOverride,
|
|
420
425
|
}, headers);
|
|
421
426
|
return observable.pipe(map((value) => {
|
|
422
427
|
const [key] = Object.keys(value.data);
|