@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
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.addSchemaToClientWithInstance = exports.addSchemaToClient = void 0;
|
|
6
|
+
exports.INTERNAL_USER_AGENT_OVERRIDE = exports.addSchemaToClientWithInstance = exports.addSchemaToClient = void 0;
|
|
7
7
|
const tslib_1 = require("tslib");
|
|
8
8
|
tslib_1.__exportStar(require("./client"), exports);
|
|
9
9
|
var addSchemaToClient_1 = require("./addSchemaToClient");
|
|
10
10
|
Object.defineProperty(exports, "addSchemaToClient", { enumerable: true, get: function () { return addSchemaToClient_1.addSchemaToClient; } });
|
|
11
11
|
var addSchemaToClientWithInstance_1 = require("./addSchemaToClientWithInstance");
|
|
12
12
|
Object.defineProperty(exports, "addSchemaToClientWithInstance", { enumerable: true, get: function () { return addSchemaToClientWithInstance_1.addSchemaToClientWithInstance; } });
|
|
13
|
+
var getCustomUserAgentDetails_1 = require("./internals/ai/getCustomUserAgentDetails");
|
|
14
|
+
Object.defineProperty(exports, "INTERNAL_USER_AGENT_OVERRIDE", { enumerable: true, get: function () { return getCustomUserAgentDetails_1.INTERNAL_USER_AGENT_OVERRIDE; } });
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/runtime/index.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.addSchemaToClientWithInstance = exports.addSchemaToClient = void 0;\nconst tslib_1 = require(\"tslib\");\ntslib_1.__exportStar(require(\"./client\"), exports);\nvar addSchemaToClient_1 = require(\"./addSchemaToClient\");\nObject.defineProperty(exports, \"addSchemaToClient\", { enumerable: true, get: function () { return addSchemaToClient_1.addSchemaToClient; } });\nvar addSchemaToClientWithInstance_1 = require(\"./addSchemaToClientWithInstance\");\nObject.defineProperty(exports, \"addSchemaToClientWithInstance\", { enumerable: true, get: function () { return addSchemaToClientWithInstance_1.addSchemaToClientWithInstance; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,6BAA6B,GAAG,OAAO,CAAC,iBAAiB,GAAG,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/runtime/index.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.INTERNAL_USER_AGENT_OVERRIDE = exports.addSchemaToClientWithInstance = exports.addSchemaToClient = void 0;\nconst tslib_1 = require(\"tslib\");\ntslib_1.__exportStar(require(\"./client\"), exports);\nvar addSchemaToClient_1 = require(\"./addSchemaToClient\");\nObject.defineProperty(exports, \"addSchemaToClient\", { enumerable: true, get: function () { return addSchemaToClient_1.addSchemaToClient; } });\nvar addSchemaToClientWithInstance_1 = require(\"./addSchemaToClientWithInstance\");\nObject.defineProperty(exports, \"addSchemaToClientWithInstance\", { enumerable: true, get: function () { return addSchemaToClientWithInstance_1.addSchemaToClientWithInstance; } });\nvar getCustomUserAgentDetails_1 = require(\"./internals/ai/getCustomUserAgentDetails\");\nObject.defineProperty(exports, \"INTERNAL_USER_AGENT_OVERRIDE\", { enumerable: true, get: function () { return getCustomUserAgentDetails_1.INTERNAL_USER_AGENT_OVERRIDE; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,4BAA4B,GAAG,OAAO,CAAC,6BAA6B,GAAG,OAAO,CAAC,iBAAiB,GAAG,KAAK,CAAC,CAAC;AAClH,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACjC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC;AACnD,IAAI,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACzD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,mBAAmB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9I,IAAI,+BAA+B,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAC;AACjF,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,+BAA+B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,+BAA+B,CAAC,6BAA6B,CAAC,EAAE,EAAE,CAAC,CAAC;AAClL,IAAI,2BAA2B,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AACtF,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,8BAA8B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,2BAA2B,CAAC,4BAA4B,CAAC,EAAE,EAAE,CAAC;;"}
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createCreateConversationFunction = void 0;
|
|
7
7
|
const get_1 = require("../operations/get");
|
|
8
8
|
const convertItemToConversation_1 = require("./convertItemToConversation");
|
|
9
|
+
const getCustomUserAgentDetails_1 = require("./getCustomUserAgentDetails");
|
|
9
10
|
const createCreateConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async () => {
|
|
10
|
-
const get = (0, get_1.getFactory)(client, modelIntrospection, conversationModel, 'CREATE', getInternals);
|
|
11
|
+
const get = (0, get_1.getFactory)(client, modelIntrospection, conversationModel, 'CREATE', getInternals, false, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.CreateConversation));
|
|
11
12
|
const { data, errors } = await get();
|
|
12
13
|
return {
|
|
13
14
|
data: (0, convertItemToConversation_1.convertItemToConversation)(client, modelIntrospection, data?.id, conversationRouteName, conversationMessageModel, getInternals),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCreateConversationFunction.js","sources":["../../../../../src/runtime/internals/ai/createCreateConversationFunction.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.createCreateConversationFunction = void 0;\nconst get_1 = require(\"../operations/get\");\nconst convertItemToConversation_1 = require(\"./convertItemToConversation\");\nconst createCreateConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async () => {\n const get = (0, get_1.getFactory)(client, modelIntrospection, conversationModel, 'CREATE', getInternals);\n const { data, errors } = await get();\n return {\n data: (0, convertItemToConversation_1.convertItemToConversation)(client, modelIntrospection, data?.id, conversationRouteName, conversationMessageModel, getInternals),\n errors,\n };\n};\nexports.createCreateConversationFunction = createCreateConversationFunction;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gCAAgC,GAAG,KAAK,CAAC,CAAC;AAClD,MAAM,KAAK,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC3C,MAAM,2BAA2B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,gCAAgC,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,YAAY;AACvK,IAAI,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"createCreateConversationFunction.js","sources":["../../../../../src/runtime/internals/ai/createCreateConversationFunction.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.createCreateConversationFunction = void 0;\nconst get_1 = require(\"../operations/get\");\nconst convertItemToConversation_1 = require(\"./convertItemToConversation\");\nconst getCustomUserAgentDetails_1 = require(\"./getCustomUserAgentDetails\");\nconst createCreateConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async () => {\n const get = (0, get_1.getFactory)(client, modelIntrospection, conversationModel, 'CREATE', getInternals, false, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.CreateConversation));\n const { data, errors } = await get();\n return {\n data: (0, convertItemToConversation_1.convertItemToConversation)(client, modelIntrospection, data?.id, conversationRouteName, conversationMessageModel, getInternals),\n errors,\n };\n};\nexports.createCreateConversationFunction = createCreateConversationFunction;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gCAAgC,GAAG,KAAK,CAAC,CAAC;AAClD,MAAM,KAAK,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC3C,MAAM,2BAA2B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,2BAA2B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,gCAAgC,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,YAAY;AACvK,IAAI,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,2BAA2B,CAAC,yBAAyB,EAAE,2BAA2B,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC;AACzO,IAAI,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,EAAE,CAAC;AACzC,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,IAAI,2BAA2B,CAAC,yBAAyB,EAAE,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,YAAY,CAAC;AAC7K,QAAQ,MAAM;AACd,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,gCAAgC,GAAG,gCAAgC;;"}
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createGetConversationFunction = void 0;
|
|
7
7
|
const get_1 = require("../operations/get");
|
|
8
8
|
const convertItemToConversation_1 = require("./convertItemToConversation");
|
|
9
|
+
const getCustomUserAgentDetails_1 = require("./getCustomUserAgentDetails");
|
|
9
10
|
const createGetConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async ({ id }) => {
|
|
10
|
-
const get = (0, get_1.getFactory)(client, modelIntrospection, conversationModel, 'GET', getInternals);
|
|
11
|
+
const get = (0, get_1.getFactory)(client, modelIntrospection, conversationModel, 'GET', getInternals, false, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.GetConversation));
|
|
11
12
|
const { data, errors } = await get({ id });
|
|
12
13
|
return {
|
|
13
14
|
data: data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGetConversationFunction.js","sources":["../../../../../src/runtime/internals/ai/createGetConversationFunction.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.createGetConversationFunction = void 0;\nconst get_1 = require(\"../operations/get\");\nconst convertItemToConversation_1 = require(\"./convertItemToConversation\");\nconst createGetConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async ({ id }) => {\n const get = (0, get_1.getFactory)(client, modelIntrospection, conversationModel, 'GET', getInternals);\n const { data, errors } = await get({ id });\n return {\n data: data\n ? (0, convertItemToConversation_1.convertItemToConversation)(client, modelIntrospection, data.id, conversationRouteName, conversationMessageModel, getInternals)\n : data,\n errors,\n };\n};\nexports.createGetConversationFunction = createGetConversationFunction;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,6BAA6B,GAAG,KAAK,CAAC,CAAC;AAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC3C,MAAM,2BAA2B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,6BAA6B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,OAAO,EAAE,EAAE,EAAE,KAAK;AAC1K,IAAI,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"createGetConversationFunction.js","sources":["../../../../../src/runtime/internals/ai/createGetConversationFunction.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.createGetConversationFunction = void 0;\nconst get_1 = require(\"../operations/get\");\nconst convertItemToConversation_1 = require(\"./convertItemToConversation\");\nconst getCustomUserAgentDetails_1 = require(\"./getCustomUserAgentDetails\");\nconst createGetConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async ({ id }) => {\n const get = (0, get_1.getFactory)(client, modelIntrospection, conversationModel, 'GET', getInternals, false, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.GetConversation));\n const { data, errors } = await get({ id });\n return {\n data: data\n ? (0, convertItemToConversation_1.convertItemToConversation)(client, modelIntrospection, data.id, conversationRouteName, conversationMessageModel, getInternals)\n : data,\n errors,\n };\n};\nexports.createGetConversationFunction = createGetConversationFunction;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,6BAA6B,GAAG,KAAK,CAAC,CAAC;AAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC3C,MAAM,2BAA2B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,2BAA2B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,6BAA6B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,OAAO,EAAE,EAAE,EAAE,KAAK;AAC1K,IAAI,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,2BAA2B,CAAC,yBAAyB,EAAE,2BAA2B,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;AACnO,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,IAAI,2BAA2B,CAAC,yBAAyB,EAAE,MAAM,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,YAAY,CAAC;AAC5K,cAAc,IAAI;AAClB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,6BAA6B,GAAG,6BAA6B;;"}
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createListConversationsFunction = void 0;
|
|
7
7
|
const list_1 = require("../operations/list");
|
|
8
8
|
const convertItemToConversation_1 = require("./convertItemToConversation");
|
|
9
|
+
const getCustomUserAgentDetails_1 = require("./getCustomUserAgentDetails");
|
|
9
10
|
const createListConversationsFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async (input) => {
|
|
10
|
-
const list = (0, list_1.listFactory)(client, modelIntrospection, conversationModel, getInternals);
|
|
11
|
+
const list = (0, list_1.listFactory)(client, modelIntrospection, conversationModel, getInternals, false, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.ListConversations));
|
|
11
12
|
const { data, nextToken, errors } = await list(input);
|
|
12
13
|
return {
|
|
13
14
|
data: data.map((datum) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createListConversationsFunction.js","sources":["../../../../../src/runtime/internals/ai/createListConversationsFunction.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.createListConversationsFunction = void 0;\nconst list_1 = require(\"../operations/list\");\nconst convertItemToConversation_1 = require(\"./convertItemToConversation\");\nconst createListConversationsFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async (input) => {\n const list = (0, list_1.listFactory)(client, modelIntrospection, conversationModel, getInternals);\n const { data, nextToken, errors } = await list(input);\n return {\n data: data.map((datum) => {\n return (0, convertItemToConversation_1.convertItemToConversation)(client, modelIntrospection, datum.id, conversationRouteName, conversationMessageModel, getInternals);\n }),\n nextToken,\n errors,\n };\n};\nexports.createListConversationsFunction = createListConversationsFunction;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,+BAA+B,GAAG,KAAK,CAAC,CAAC;AACjD,MAAM,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC7C,MAAM,2BAA2B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,+BAA+B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,OAAO,KAAK,KAAK;AAC3K,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"createListConversationsFunction.js","sources":["../../../../../src/runtime/internals/ai/createListConversationsFunction.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.createListConversationsFunction = void 0;\nconst list_1 = require(\"../operations/list\");\nconst convertItemToConversation_1 = require(\"./convertItemToConversation\");\nconst getCustomUserAgentDetails_1 = require(\"./getCustomUserAgentDetails\");\nconst createListConversationsFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async (input) => {\n const list = (0, list_1.listFactory)(client, modelIntrospection, conversationModel, getInternals, false, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.ListConversations));\n const { data, nextToken, errors } = await list(input);\n return {\n data: data.map((datum) => {\n return (0, convertItemToConversation_1.convertItemToConversation)(client, modelIntrospection, datum.id, conversationRouteName, conversationMessageModel, getInternals);\n }),\n nextToken,\n errors,\n };\n};\nexports.createListConversationsFunction = createListConversationsFunction;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,+BAA+B,GAAG,KAAK,CAAC,CAAC;AACjD,MAAM,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC7C,MAAM,2BAA2B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,2BAA2B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,+BAA+B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,OAAO,KAAK,KAAK;AAC3K,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,2BAA2B,CAAC,yBAAyB,EAAE,2BAA2B,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC;AACjO,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,IAAI,2BAA2B,CAAC,yBAAyB,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,CAAC,EAAE,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,YAAY,CAAC,CAAC;AACnL,SAAS,CAAC;AACV,QAAQ,SAAS;AACjB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,+BAA+B,GAAG,+BAA+B;;"}
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createListMessagesFunction = void 0;
|
|
7
7
|
const list_1 = require("../operations/list");
|
|
8
8
|
const convertItemToConversationMessage_1 = require("./convertItemToConversationMessage");
|
|
9
|
+
const getCustomUserAgentDetails_1 = require("./getCustomUserAgentDetails");
|
|
9
10
|
const createListMessagesFunction = (client, modelIntrospection, conversationId, conversationMessageModel, getInternals) => async (input) => {
|
|
10
|
-
const list = (0, list_1.listFactory)(client, modelIntrospection, conversationMessageModel, getInternals);
|
|
11
|
+
const list = (0, list_1.listFactory)(client, modelIntrospection, conversationMessageModel, getInternals, false, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.ListMessages));
|
|
11
12
|
const { data, nextToken, errors } = await list({
|
|
12
13
|
...input,
|
|
13
14
|
filter: { conversationId: { eq: conversationId } },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createListMessagesFunction.js","sources":["../../../../../src/runtime/internals/ai/createListMessagesFunction.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.createListMessagesFunction = void 0;\nconst list_1 = require(\"../operations/list\");\nconst convertItemToConversationMessage_1 = require(\"./convertItemToConversationMessage\");\nconst createListMessagesFunction = (client, modelIntrospection, conversationId, conversationMessageModel, getInternals) => async (input) => {\n const list = (0, list_1.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) => (0, convertItemToConversationMessage_1.convertItemToConversationMessage)(item)),\n nextToken,\n errors,\n };\n};\nexports.createListMessagesFunction = createListMessagesFunction;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,0BAA0B,GAAG,KAAK,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC7C,MAAM,kCAAkC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AACzF,MAAM,0BAA0B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,wBAAwB,EAAE,YAAY,KAAK,OAAO,KAAK,KAAK;AAC5I,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"createListMessagesFunction.js","sources":["../../../../../src/runtime/internals/ai/createListMessagesFunction.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.createListMessagesFunction = void 0;\nconst list_1 = require(\"../operations/list\");\nconst convertItemToConversationMessage_1 = require(\"./convertItemToConversationMessage\");\nconst getCustomUserAgentDetails_1 = require(\"./getCustomUserAgentDetails\");\nconst createListMessagesFunction = (client, modelIntrospection, conversationId, conversationMessageModel, getInternals) => async (input) => {\n const list = (0, list_1.listFactory)(client, modelIntrospection, conversationMessageModel, getInternals, false, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.ListMessages));\n const { data, nextToken, errors } = await list({\n ...input,\n filter: { conversationId: { eq: conversationId } },\n });\n return {\n data: data.map((item) => (0, convertItemToConversationMessage_1.convertItemToConversationMessage)(item)),\n nextToken,\n errors,\n };\n};\nexports.createListMessagesFunction = createListMessagesFunction;\n"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;
|
|
7
7
|
const custom_1 = require("../operations/custom");
|
|
8
8
|
const convertItemToConversationMessage_1 = require("./convertItemToConversationMessage");
|
|
9
|
+
const getCustomUserAgentDetails_1 = require("./getCustomUserAgentDetails");
|
|
9
10
|
const createOnMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => (handler) => {
|
|
10
11
|
const { conversations } = modelIntrospection;
|
|
11
12
|
// Safe guard for standalone function. When called as part of client generation, this should never be falsy.
|
|
@@ -13,7 +14,7 @@ const createOnMessageFunction = (client, modelIntrospection, conversationId, con
|
|
|
13
14
|
return {};
|
|
14
15
|
}
|
|
15
16
|
const subscribeSchema = conversations[conversationRouteName].message.subscribe;
|
|
16
|
-
const subscribeOperation = (0, custom_1.customOpFactory)(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals);
|
|
17
|
+
const subscribeOperation = (0, custom_1.customOpFactory)(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.OnMessage));
|
|
17
18
|
return subscribeOperation({ conversationId }).subscribe((data) => {
|
|
18
19
|
handler((0, convertItemToConversationMessage_1.convertItemToConversationMessage)(data));
|
|
19
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOnMessageFunction.js","sources":["../../../../../src/runtime/internals/ai/createOnMessageFunction.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.createOnMessageFunction = void 0;\nconst custom_1 = require(\"../operations/custom\");\nconst convertItemToConversationMessage_1 = require(\"./convertItemToConversationMessage\");\nconst 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 = (0, custom_1.customOpFactory)(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals);\n return subscribeOperation({ conversationId }).subscribe((data) => {\n handler((0, convertItemToConversationMessage_1.convertItemToConversationMessage)(data));\n });\n};\nexports.createOnMessageFunction = createOnMessageFunction;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;AACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACjD,MAAM,kCAAkC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AACzF,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,KAAK,CAAC,OAAO,KAAK;AAClI,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,IAAI,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"createOnMessageFunction.js","sources":["../../../../../src/runtime/internals/ai/createOnMessageFunction.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.createOnMessageFunction = void 0;\nconst custom_1 = require(\"../operations/custom\");\nconst convertItemToConversationMessage_1 = require(\"./convertItemToConversationMessage\");\nconst getCustomUserAgentDetails_1 = require(\"./getCustomUserAgentDetails\");\nconst 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 = (0, custom_1.customOpFactory)(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.OnMessage));\n return subscribeOperation({ conversationId }).subscribe((data) => {\n handler((0, convertItemToConversationMessage_1.convertItemToConversationMessage)(data));\n });\n};\nexports.createOnMessageFunction = createOnMessageFunction;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;AACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACjD,MAAM,kCAAkC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AACzF,MAAM,2BAA2B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,KAAK,CAAC,OAAO,KAAK;AAClI,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,IAAI,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,2BAA2B,CAAC,yBAAyB,EAAE,2BAA2B,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AAC3P,IAAI,OAAO,kBAAkB,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK;AACtE,QAAQ,OAAO,CAAC,IAAI,kCAAkC,CAAC,gCAAgC,EAAE,IAAI,CAAC,CAAC,CAAC;AAChG,KAAK,CAAC,CAAC;AACP,CAAC,CAAC;AACF,OAAO,CAAC,uBAAuB,GAAG,uBAAuB;;"}
|
|
@@ -7,6 +7,7 @@ exports.createSendMessageFunction = void 0;
|
|
|
7
7
|
const custom_1 = require("../operations/custom");
|
|
8
8
|
const convertItemToConversationMessage_1 = require("./convertItemToConversationMessage");
|
|
9
9
|
const conversationMessageSerializers_1 = require("./conversationMessageSerializers");
|
|
10
|
+
const getCustomUserAgentDetails_1 = require("./getCustomUserAgentDetails");
|
|
10
11
|
const createSendMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => async ({ aiContext, content, toolConfiguration }) => {
|
|
11
12
|
const { conversations } = modelIntrospection;
|
|
12
13
|
// Safe guard for standalone function. When called as part of client generation, this should never be falsy.
|
|
@@ -14,7 +15,7 @@ const createSendMessageFunction = (client, modelIntrospection, conversationId, c
|
|
|
14
15
|
return {};
|
|
15
16
|
}
|
|
16
17
|
const sendSchema = conversations[conversationRouteName].message.send;
|
|
17
|
-
const sendOperation = (0, custom_1.customOpFactory)(client, modelIntrospection, 'mutation', sendSchema, false, getInternals);
|
|
18
|
+
const sendOperation = (0, custom_1.customOpFactory)(client, modelIntrospection, 'mutation', sendSchema, false, getInternals, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.SendMessage));
|
|
18
19
|
const { data, errors } = await sendOperation({
|
|
19
20
|
conversationId,
|
|
20
21
|
content: (0, conversationMessageSerializers_1.serializeContent)(content),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSendMessageFunction.js","sources":["../../../../../src/runtime/internals/ai/createSendMessageFunction.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.createSendMessageFunction = void 0;\nconst custom_1 = require(\"../operations/custom\");\nconst convertItemToConversationMessage_1 = require(\"./convertItemToConversationMessage\");\nconst conversationMessageSerializers_1 = require(\"./conversationMessageSerializers\");\nconst 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 = (0, custom_1.customOpFactory)(client, modelIntrospection, 'mutation', sendSchema, false, getInternals);\n const { data, errors } = await sendOperation({\n conversationId,\n content: (0, conversationMessageSerializers_1.serializeContent)(content),\n ...(aiContext && { aiContext: (0, conversationMessageSerializers_1.serializeAiContext)(aiContext) }),\n ...(toolConfiguration && {\n toolConfiguration: (0, conversationMessageSerializers_1.serializeToolConfiguration)(toolConfiguration),\n }),\n });\n return {\n data: data ? (0, convertItemToConversationMessage_1.convertItemToConversationMessage)(data) : data,\n errors,\n };\n};\nexports.createSendMessageFunction = createSendMessageFunction;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,yBAAyB,GAAG,KAAK,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACjD,MAAM,kCAAkC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AACzF,MAAM,gCAAgC,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACrF,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,KAAK,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAK;AAC5K,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,IAAI,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"createSendMessageFunction.js","sources":["../../../../../src/runtime/internals/ai/createSendMessageFunction.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.createSendMessageFunction = void 0;\nconst custom_1 = require(\"../operations/custom\");\nconst convertItemToConversationMessage_1 = require(\"./convertItemToConversationMessage\");\nconst conversationMessageSerializers_1 = require(\"./conversationMessageSerializers\");\nconst getCustomUserAgentDetails_1 = require(\"./getCustomUserAgentDetails\");\nconst 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 = (0, custom_1.customOpFactory)(client, modelIntrospection, 'mutation', sendSchema, false, getInternals, (0, getCustomUserAgentDetails_1.getCustomUserAgentDetails)(getCustomUserAgentDetails_1.AiAction.SendMessage));\n const { data, errors } = await sendOperation({\n conversationId,\n content: (0, conversationMessageSerializers_1.serializeContent)(content),\n ...(aiContext && { aiContext: (0, conversationMessageSerializers_1.serializeAiContext)(aiContext) }),\n ...(toolConfiguration && {\n toolConfiguration: (0, conversationMessageSerializers_1.serializeToolConfiguration)(toolConfiguration),\n }),\n });\n return {\n data: data ? (0, convertItemToConversationMessage_1.convertItemToConversationMessage)(data) : data,\n errors,\n };\n};\nexports.createSendMessageFunction = createSendMessageFunction;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,yBAAyB,GAAG,KAAK,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACjD,MAAM,kCAAkC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AACzF,MAAM,gCAAgC,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACrF,MAAM,2BAA2B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,KAAK,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAK;AAC5K,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,IAAI,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,2BAA2B,CAAC,yBAAyB,EAAE,2BAA2B,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;AAC/O,IAAI,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC;AACjD,QAAQ,cAAc;AACtB,QAAQ,OAAO,EAAE,IAAI,gCAAgC,CAAC,gBAAgB,EAAE,OAAO,CAAC;AAChF,QAAQ,IAAI,SAAS,IAAI,EAAE,SAAS,EAAE,IAAI,gCAAgC,CAAC,kBAAkB,EAAE,SAAS,CAAC,EAAE;AAC3G,QAAQ,IAAI,iBAAiB,IAAI;AACjC,YAAY,iBAAiB,EAAE,IAAI,gCAAgC,CAAC,0BAA0B,EAAE,iBAAiB,CAAC;AAClH,SAAS;AACT,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,IAAI,GAAG,IAAI,kCAAkC,CAAC,gCAAgC,EAAE,IAAI,CAAC,GAAG,IAAI;AAC1G,QAAQ,MAAM;AACd,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,yBAAyB,GAAG,yBAAyB;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createUserAgentOverride = exports.getCustomUserAgentDetails = exports.AiAction = exports.INTERNAL_USER_AGENT_OVERRIDE = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Symbol used for internal user agent overrides.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
* This symbol is intended for internal use within the Amplify library.
|
|
12
|
+
* It may change or be removed in future versions without notice.
|
|
13
|
+
* External usage of this symbol is discouraged and may lead to unexpected behavior.
|
|
14
|
+
*/
|
|
15
|
+
exports.INTERNAL_USER_AGENT_OVERRIDE = Symbol('INTERNAL_USER_AGENT_OVERRIDE');
|
|
16
|
+
var AiAction;
|
|
17
|
+
(function (AiAction) {
|
|
18
|
+
AiAction["CreateConversation"] = "1";
|
|
19
|
+
AiAction["GetConversation"] = "2";
|
|
20
|
+
AiAction["ListConversations"] = "3";
|
|
21
|
+
AiAction["SendMessage"] = "4";
|
|
22
|
+
AiAction["ListMessages"] = "5";
|
|
23
|
+
AiAction["OnMessage"] = "6";
|
|
24
|
+
AiAction["Generation"] = "7";
|
|
25
|
+
AiAction["Delete"] = "8";
|
|
26
|
+
})(AiAction || (exports.AiAction = AiAction = {}));
|
|
27
|
+
const getCustomUserAgentDetails = (action) => ({
|
|
28
|
+
category: 'ai',
|
|
29
|
+
action,
|
|
30
|
+
});
|
|
31
|
+
exports.getCustomUserAgentDetails = getCustomUserAgentDetails;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a user agent override object based on custom details.
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
* This function is intended for internal use within the Amplify library.
|
|
37
|
+
* It may change or be removed in future versions without notice.
|
|
38
|
+
*
|
|
39
|
+
* @param customUserAgentDetails - Optional custom user agent details
|
|
40
|
+
* @returns An object with INTERNAL_USER_AGENT_OVERRIDE symbol as key and customUserAgentDetails as value, or undefined if no details provided
|
|
41
|
+
*/
|
|
42
|
+
function createUserAgentOverride(customUserAgentDetails) {
|
|
43
|
+
return customUserAgentDetails
|
|
44
|
+
? { [exports.INTERNAL_USER_AGENT_OVERRIDE]: customUserAgentDetails }
|
|
45
|
+
: undefined;
|
|
46
|
+
}
|
|
47
|
+
exports.createUserAgentOverride = createUserAgentOverride;
|
|
48
|
+
//# sourceMappingURL=getCustomUserAgentDetails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCustomUserAgentDetails.js","sources":["../../../../../src/runtime/internals/ai/getCustomUserAgentDetails.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.createUserAgentOverride = exports.getCustomUserAgentDetails = exports.AiAction = exports.INTERNAL_USER_AGENT_OVERRIDE = void 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 */\nexports.INTERNAL_USER_AGENT_OVERRIDE = Symbol('INTERNAL_USER_AGENT_OVERRIDE');\nvar 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 || (exports.AiAction = AiAction = {}));\nconst getCustomUserAgentDetails = (action) => ({\n category: 'ai',\n action,\n});\nexports.getCustomUserAgentDetails = getCustomUserAgentDetails;\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 */\nfunction createUserAgentOverride(customUserAgentDetails) {\n return customUserAgentDetails\n ? { [exports.INTERNAL_USER_AGENT_OVERRIDE]: customUserAgentDetails }\n : undefined;\n}\nexports.createUserAgentOverride = createUserAgentOverride;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,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AE;AAC5E,UAAU,SAAS,CAAC;AACpB,CAAC;AACD,OAAO,CAAC,uBAAuB,GAAG,uBAAuB;;"}
|
|
@@ -7,6 +7,7 @@ const APIClient_1 = require("../APIClient");
|
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
8
|
const utils_2 = require("../../utils");
|
|
9
9
|
const cancellation_1 = require("../cancellation");
|
|
10
|
+
const getCustomUserAgentDetails_1 = require("../ai/getCustomUserAgentDetails");
|
|
10
11
|
/**
|
|
11
12
|
* Type guard for checking whether a Custom Operation argument is a contextSpec object
|
|
12
13
|
*/
|
|
@@ -69,7 +70,7 @@ const argIsContextSpec = (arg) => {
|
|
|
69
70
|
* @param useContext Whether the function needs to accept an SSR context.
|
|
70
71
|
* @returns The operation function to attach to query, mutations, etc.
|
|
71
72
|
*/
|
|
72
|
-
function customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals) {
|
|
73
|
+
function customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals, customUserAgentDetails) {
|
|
73
74
|
// .arguments() are defined for the custom operation in the schema builder
|
|
74
75
|
// and are present in the model introspection schema
|
|
75
76
|
const argsDefined = operation.arguments !== undefined;
|
|
@@ -97,9 +98,9 @@ function customOpFactory(client, modelIntrospection, operationType, operation, u
|
|
|
97
98
|
if (operationType === 'subscription') {
|
|
98
99
|
return _opSubscription(
|
|
99
100
|
// subscriptions are only enabled on the clientside
|
|
100
|
-
client, modelIntrospection, operation, getInternals, arg, options);
|
|
101
|
+
client, modelIntrospection, operation, getInternals, arg, options, customUserAgentDetails);
|
|
101
102
|
}
|
|
102
|
-
return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec);
|
|
103
|
+
return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec, customUserAgentDetails);
|
|
103
104
|
};
|
|
104
105
|
return op;
|
|
105
106
|
}
|
|
@@ -280,7 +281,7 @@ function operationVariables(operation, args = {}) {
|
|
|
280
281
|
* @param context SSR context if relevant.
|
|
281
282
|
* @returns Result from the graphql request, model-instantiated when relevant.
|
|
282
283
|
*/
|
|
283
|
-
function _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context) {
|
|
284
|
+
function _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context, customUserAgentDetails) {
|
|
284
285
|
return (0, utils_2.selfAwareAsync)(async (resultPromise) => {
|
|
285
286
|
const { name: operationName } = operation;
|
|
286
287
|
const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);
|
|
@@ -297,6 +298,7 @@ function _op(client, modelIntrospection, operationType, operation, getInternals,
|
|
|
297
298
|
}
|
|
298
299
|
`;
|
|
299
300
|
const variables = operationVariables(operation, args);
|
|
301
|
+
const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);
|
|
300
302
|
try {
|
|
301
303
|
const basePromise = context
|
|
302
304
|
? client.graphql(context, {
|
|
@@ -308,6 +310,7 @@ function _op(client, modelIntrospection, operationType, operation, getInternals,
|
|
|
308
310
|
...auth,
|
|
309
311
|
query,
|
|
310
312
|
variables,
|
|
313
|
+
...userAgentOverride,
|
|
311
314
|
}, headers);
|
|
312
315
|
const extendedPromise = (0, cancellation_1.extendCancellability)(basePromise, resultPromise);
|
|
313
316
|
const { data, extensions } = await extendedPromise;
|
|
@@ -400,7 +403,7 @@ function _op(client, modelIntrospection, operationType, operation, getInternals,
|
|
|
400
403
|
* @param options Request options like headers, etc.
|
|
401
404
|
* @returns Result from the graphql request, model-instantiated when relevant.
|
|
402
405
|
*/
|
|
403
|
-
function _opSubscription(client, modelIntrospection, operation, getInternals, args, options) {
|
|
406
|
+
function _opSubscription(client, modelIntrospection, operation, getInternals, args, options, customUserAgentDetails) {
|
|
404
407
|
const operationType = 'subscription';
|
|
405
408
|
const { name: operationName } = operation;
|
|
406
409
|
const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);
|
|
@@ -417,10 +420,12 @@ function _opSubscription(client, modelIntrospection, operation, getInternals, ar
|
|
|
417
420
|
}
|
|
418
421
|
`;
|
|
419
422
|
const variables = operationVariables(operation, args);
|
|
423
|
+
const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);
|
|
420
424
|
const observable = client.graphql({
|
|
421
425
|
...auth,
|
|
422
426
|
query,
|
|
423
427
|
variables,
|
|
428
|
+
...userAgentOverride,
|
|
424
429
|
}, headers);
|
|
425
430
|
return observable.pipe((0, rxjs_1.map)((value) => {
|
|
426
431
|
const [key] = Object.keys(value.data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.js","sources":["../../../../../src/runtime/internals/operations/custom.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.customOpFactory = void 0;\nconst rxjs_1 = require(\"rxjs\");\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nconst utils_2 = require(\"../../utils\");\nconst cancellation_1 = require(\"../cancellation\");\n/**\n * Type guard for checking whether a Custom Operation argument is a contextSpec object\n */\nconst argIsContextSpec = (arg) => {\n return typeof arg?.token?.value === 'symbol';\n};\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nfunction customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals) {\n // .arguments() are defined for the custom operation in the schema builder\n // and are present in the model introspection schema\n const argsDefined = operation.arguments !== undefined;\n const op = (...args) => {\n // options is always the last argument\n const options = args[args.length - 1];\n let contextSpec;\n let arg;\n if (useContext) {\n if (argIsContextSpec(args[0])) {\n contextSpec = args[0];\n }\n else {\n throw new Error(`Invalid first argument passed to ${operation.name}. Expected contextSpec`);\n }\n }\n if (argsDefined) {\n if (useContext) {\n arg = args[1];\n }\n else {\n arg = args[0];\n }\n }\n if (operationType === 'subscription') {\n return _opSubscription(\n // subscriptions are only enabled on the clientside\n client, modelIntrospection, operation, getInternals, arg, options);\n }\n return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec);\n };\n return op;\n}\nexports.customOpFactory = customOpFactory;\n/**\n * Runtime test and type guard to check whether `o[field]` is a `String`.\n *\n * ```typescript\n * if (hasStringField(o, 'prop')) {\n * const s = o.prop;\n * // ^? const s: string\n * }\n * ```\n *\n * @param o Object to inspect\n * @param field Field to look for\n * @returns Boolean: `true` if the `o[field]` is a `string`\n */\nfunction hasStringField(o, field) {\n return typeof o[field] === 'string';\n}\nfunction isEnumType(type) {\n return type instanceof Object && 'enum' in type;\n}\nfunction isInputType(type) {\n return type instanceof Object && 'input' in type;\n}\n/**\n * @param argDef A single argument definition from a custom operation\n * @returns A string naming the base type including the `!` if the arg is required.\n */\nfunction argumentBaseTypeString({ type, isRequired }) {\n const requiredFlag = isRequired ? '!' : '';\n if (isEnumType(type)) {\n return `${type.enum}${requiredFlag}`;\n }\n if (isInputType(type)) {\n return `${type.input}${requiredFlag}`;\n }\n return `${type}${requiredFlag}`;\n}\n/**\n * Generates \"outer\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the top/outer level arguments as a string:\n *\n * ```json\n * \"InputString: String!\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction outerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.entries(operation.arguments)\n .map(([k, argument]) => {\n const baseType = argumentBaseTypeString(argument);\n const finalType = argument.isArray\n ? `[${baseType}]${argument.isArrayNullable ? '' : '!'}`\n : baseType;\n return `$${k}: ${finalType}`;\n })\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates \"inner\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the inner arguments as a string:\n *\n * ```json\n * \"InputString: $InputString\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction innerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.keys(operation.arguments)\n .map((k) => `${k}: $${k}`)\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates the selection set string for a custom operation. This is slightly\n * different than the selection set generation for models. If the custom op returns\n * a primitive or enum types, it doesn't require a selection set at all.\n *\n * E.g., the graphql might look like this:\n *\n * ```graphql\n * query MyQuery {\n * echoString(inputString: \"whatever\")\n * }\n * # ^\n * # |\n * # +-- no selection set\n * ```\n *\n * Non-primitive return type selection set generation will be similar to other\n * model operations.\n *\n * @param modelIntrospection The full code-generated introspection schema.\n * @param operation The operation object from the schema.\n * @returns The selection set as a string.\n */\nfunction operationSelectionSet(modelIntrospection, operation) {\n if (hasStringField(operation, 'type') ||\n hasStringField(operation.type, 'enum')) {\n return '';\n }\n else if (hasStringField(operation.type, 'nonModel')) {\n const nonModel = modelIntrospection.nonModels[operation.type.nonModel];\n return `{${(0, APIClient_1.selectionSetIRToString)((0, APIClient_1.getDefaultSelectionSetForNonModelWithIR)(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${(0, APIClient_1.generateSelectionSet)(modelIntrospection, operation.type.model)}}`;\n }\n else {\n return '';\n }\n}\n/**\n * Maps an arguments objec to graphql variables, removing superfluous args and\n * screaming loudly when required args are missing.\n *\n * @param operation The operation to construct graphql request variables for.\n * @param args The arguments to map variables from.\n * @returns The graphql variables object.\n */\nfunction operationVariables(operation, args = {}) {\n const variables = {};\n if (operation.arguments === undefined) {\n return variables;\n }\n for (const argDef of Object.values(operation.arguments)) {\n if (typeof args[argDef.name] !== 'undefined') {\n variables[argDef.name] = args[argDef.name];\n }\n else if (argDef.isRequired) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context) {\n return (0, utils_2.selfAwareAsync)(async (resultPromise) => {\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n try {\n const basePromise = context\n ? client.graphql(context, {\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) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n extensions,\n };\n }\n else {\n return { data: null, extensions };\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 `{ getPost: null }`\n * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`\n */\n const { data, errors } = error;\n /**\n * `data` is not `null`, and is not an empty object:\n */\n if (data && Object.keys(data).length !== 0 && errors) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n /**\n * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)\n * if `flattenedResult`, result is an actual record:\n */\n if (flattenedResult) {\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n errors,\n };\n }\n else {\n // was `data: { getPost: null }`)\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n else {\n // `data` is `null`:\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n });\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _opSubscription(client, modelIntrospection, operation, getInternals, args, options) {\n const operationType = 'subscription';\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n }, headers);\n return observable.pipe((0, rxjs_1.map)((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAA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"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.customOpFactory = void 0;\nconst rxjs_1 = require(\"rxjs\");\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\");\n/**\n * Type guard for checking whether a Custom Operation argument is a contextSpec object\n */\nconst argIsContextSpec = (arg) => {\n return typeof arg?.token?.value === 'symbol';\n};\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nfunction customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals, customUserAgentDetails) {\n // .arguments() are defined for the custom operation in the schema builder\n // and are present in the model introspection schema\n const argsDefined = operation.arguments !== undefined;\n const op = (...args) => {\n // options is always the last argument\n const options = args[args.length - 1];\n let contextSpec;\n let arg;\n if (useContext) {\n if (argIsContextSpec(args[0])) {\n contextSpec = args[0];\n }\n else {\n throw new Error(`Invalid first argument passed to ${operation.name}. Expected contextSpec`);\n }\n }\n if (argsDefined) {\n if (useContext) {\n arg = args[1];\n }\n else {\n arg = args[0];\n }\n }\n if (operationType === 'subscription') {\n return _opSubscription(\n // subscriptions are only enabled on the clientside\n client, modelIntrospection, operation, getInternals, arg, options, customUserAgentDetails);\n }\n return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec, customUserAgentDetails);\n };\n return op;\n}\nexports.customOpFactory = customOpFactory;\n/**\n * Runtime test and type guard to check whether `o[field]` is a `String`.\n *\n * ```typescript\n * if (hasStringField(o, 'prop')) {\n * const s = o.prop;\n * // ^? const s: string\n * }\n * ```\n *\n * @param o Object to inspect\n * @param field Field to look for\n * @returns Boolean: `true` if the `o[field]` is a `string`\n */\nfunction hasStringField(o, field) {\n return typeof o[field] === 'string';\n}\nfunction isEnumType(type) {\n return type instanceof Object && 'enum' in type;\n}\nfunction isInputType(type) {\n return type instanceof Object && 'input' in type;\n}\n/**\n * @param argDef A single argument definition from a custom operation\n * @returns A string naming the base type including the `!` if the arg is required.\n */\nfunction argumentBaseTypeString({ type, isRequired }) {\n const requiredFlag = isRequired ? '!' : '';\n if (isEnumType(type)) {\n return `${type.enum}${requiredFlag}`;\n }\n if (isInputType(type)) {\n return `${type.input}${requiredFlag}`;\n }\n return `${type}${requiredFlag}`;\n}\n/**\n * Generates \"outer\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the top/outer level arguments as a string:\n *\n * ```json\n * \"InputString: String!\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction outerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.entries(operation.arguments)\n .map(([k, argument]) => {\n const baseType = argumentBaseTypeString(argument);\n const finalType = argument.isArray\n ? `[${baseType}]${argument.isArrayNullable ? '' : '!'}`\n : baseType;\n return `$${k}: ${finalType}`;\n })\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates \"inner\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the inner arguments as a string:\n *\n * ```json\n * \"InputString: $InputString\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction innerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.keys(operation.arguments)\n .map((k) => `${k}: $${k}`)\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates the selection set string for a custom operation. This is slightly\n * different than the selection set generation for models. If the custom op returns\n * a primitive or enum types, it doesn't require a selection set at all.\n *\n * E.g., the graphql might look like this:\n *\n * ```graphql\n * query MyQuery {\n * echoString(inputString: \"whatever\")\n * }\n * # ^\n * # |\n * # +-- no selection set\n * ```\n *\n * Non-primitive return type selection set generation will be similar to other\n * model operations.\n *\n * @param modelIntrospection The full code-generated introspection schema.\n * @param operation The operation object from the schema.\n * @returns The selection set as a string.\n */\nfunction operationSelectionSet(modelIntrospection, operation) {\n if (hasStringField(operation, 'type') ||\n hasStringField(operation.type, 'enum')) {\n return '';\n }\n else if (hasStringField(operation.type, 'nonModel')) {\n const nonModel = modelIntrospection.nonModels[operation.type.nonModel];\n return `{${(0, APIClient_1.selectionSetIRToString)((0, APIClient_1.getDefaultSelectionSetForNonModelWithIR)(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${(0, APIClient_1.generateSelectionSet)(modelIntrospection, operation.type.model)}}`;\n }\n else {\n return '';\n }\n}\n/**\n * Maps an arguments objec to graphql variables, removing superfluous args and\n * screaming loudly when required args are missing.\n *\n * @param operation The operation to construct graphql request variables for.\n * @param args The arguments to map variables from.\n * @returns The graphql variables object.\n */\nfunction operationVariables(operation, args = {}) {\n const variables = {};\n if (operation.arguments === undefined) {\n return variables;\n }\n for (const argDef of Object.values(operation.arguments)) {\n if (typeof args[argDef.name] !== 'undefined') {\n variables[argDef.name] = args[argDef.name];\n }\n else if (argDef.isRequired) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context, customUserAgentDetails) {\n return (0, utils_2.selfAwareAsync)(async (resultPromise) => {\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);\n try {\n const basePromise = context\n ? client.graphql(context, {\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) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n extensions,\n };\n }\n else {\n return { data: null, extensions };\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 `{ getPost: null }`\n * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`\n */\n const { data, errors } = error;\n /**\n * `data` is not `null`, and is not an empty object:\n */\n if (data && Object.keys(data).length !== 0 && errors) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n /**\n * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)\n * if `flattenedResult`, result is an actual record:\n */\n if (flattenedResult) {\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n errors,\n };\n }\n else {\n // was `data: { getPost: null }`)\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n else {\n // `data` is `null`:\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n });\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _opSubscription(client, modelIntrospection, operation, getInternals, args, options, customUserAgentDetails) {\n const operationType = 'subscription';\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n ...userAgentOverride,\n }, headers);\n return observable.pipe((0, rxjs_1.map)((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACjC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,WAAW,GAAG,OA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kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;AACtI,cAAc,CAAC,IAAI,CAAC,CAAC;AACrB,QAAQ,OAAO,WAAW,CAAC;AAC3B,KAAK,CAAC,CAAC,CAAC;AACR;;"}
|
|
@@ -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 getFactory(client, modelIntrospection, model, operation, getInternals, useContext = false, customUserAgentDetails) {
|
|
10
11
|
const getWithContext = (contextSpec, arg, options) => {
|
|
11
|
-
return _get(client, modelIntrospection, model, arg, options, operation, getInternals, contextSpec);
|
|
12
|
+
return _get(client, modelIntrospection, model, arg, options, operation, getInternals, contextSpec, customUserAgentDetails);
|
|
12
13
|
};
|
|
13
14
|
const get = (arg, options) => {
|
|
14
|
-
return _get(client, modelIntrospection, model, arg, options, operation, getInternals);
|
|
15
|
+
return _get(client, modelIntrospection, model, arg, options, operation, getInternals, undefined, customUserAgentDetails);
|
|
15
16
|
};
|
|
16
17
|
return useContext ? getWithContext : get;
|
|
17
18
|
}
|
|
18
19
|
exports.getFactory = getFactory;
|
|
19
|
-
function _get(client, modelIntrospection, model, arg, options, operation, getInternals, context) {
|
|
20
|
+
function _get(client, modelIntrospection, model, arg, options, operation, getInternals, context, 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, operation, options);
|
|
23
24
|
const variables = (0, APIClient_1.buildGraphQLVariables)(model, operation, arg, modelIntrospection);
|
|
24
25
|
const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);
|
|
26
|
+
const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);
|
|
27
|
+
const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);
|
|
25
28
|
try {
|
|
26
|
-
const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);
|
|
27
29
|
const basePromise = context
|
|
28
30
|
? client.graphql(context, {
|
|
29
31
|
...auth,
|
|
@@ -34,6 +36,7 @@ function _get(client, modelIntrospection, model, arg, options, operation, getInt
|
|
|
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":"get.js","sources":["../../../../../src/runtime/internals/operations/get.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nconst utils_2 = require(\"../../utils\");\nconst cancellation_1 = require(\"../cancellation\");\nfunction getFactory(client, modelIntrospection, model, operation, getInternals, useContext = false) {\n const getWithContext = (contextSpec, arg, options) => {\n return _get(client, modelIntrospection, model, arg, options, operation, getInternals, contextSpec);\n };\n const get = (arg, options) => {\n return _get(client, modelIntrospection, model, arg, options, operation, getInternals);\n };\n return useContext ? getWithContext : get;\n}\nexports.getFactory = getFactory;\nfunction _get(client, modelIntrospection, model, arg, options, operation, getInternals, context) {\n return (0, utils_2.selfAwareAsync)(async (resultPromise) => {\n const { name } = model;\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, operation, options);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, operation, arg, modelIntrospection);\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n
|
|
1
|
+
{"version":3,"file":"get.js","sources":["../../../../../src/runtime/internals/operations/get.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getFactory = 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 getFactory(client, modelIntrospection, model, operation, getInternals, useContext = false, customUserAgentDetails) {\n const getWithContext = (contextSpec, arg, options) => {\n return _get(client, modelIntrospection, model, arg, options, operation, getInternals, contextSpec, customUserAgentDetails);\n };\n const get = (arg, options) => {\n return _get(client, modelIntrospection, model, arg, options, operation, getInternals, undefined, customUserAgentDetails);\n };\n return useContext ? getWithContext : get;\n}\nexports.getFactory = getFactory;\nfunction _get(client, modelIntrospection, model, arg, options, operation, getInternals, context, customUserAgentDetails) {\n return (0, utils_2.selfAwareAsync)(async (resultPromise) => {\n const { name } = model;\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, operation, options);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, operation, arg, modelIntrospection);\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);\n try {\n const basePromise = context\n ? client.graphql(context, {\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) {\n const [key] = Object.keys(data);\n const flattenedResult = (0, APIClient_1.flattenItems)(modelIntrospection, name, data[key]);\n if (flattenedResult === null) {\n return { data: null, extensions };\n }\n else if (options?.selectionSet) {\n return { data: flattenedResult, extensions };\n }\n else {\n // TODO: refactor to avoid destructuring here\n const [initialized] = (0, APIClient_1.initializeModel)(client, name, [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context);\n return { data: initialized, extensions };\n }\n }\n else {\n return { data: null, extensions };\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 `{ getPost: null }`\n * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`\n */\n const { data, errors } = error;\n /**\n * `data` is not `null`, and is not an empty object:\n */\n if (data && Object.keys(data).length !== 0 && errors) {\n const [key] = Object.keys(data);\n const flattenedResult = (0, APIClient_1.flattenItems)(modelIntrospection, name, data[key]);\n /**\n * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)\n * if `flattenedResult`, result is an actual record:\n */\n if (flattenedResult) {\n if (options?.selectionSet) {\n return { data: flattenedResult, errors };\n }\n else {\n // TODO: refactor to avoid destructuring here\n const [initialized] = (0, APIClient_1.initializeModel)(client, name, [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context);\n return { data: initialized, errors };\n }\n }\n else {\n // was `data: { getPost: null }`)\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n else {\n // `data` is `null`:\n return (0, utils_1.handleSingularGraphQlError)(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,UAAU,GAAG,KAAK,CAAC,CAAC;AAC5B,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,MAAM,2BAA2B,GAAG,OAAO,CAAC,iCAAiC,CAA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