@aws-amplify/data-schema 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ClientSchema/ai/ClientConversation.js +6 -0
- package/dist/cjs/ClientSchema/ai/ClientConversation.js.map +1 -0
- package/dist/cjs/CustomOperation.js +22 -2
- package/dist/cjs/CustomOperation.js.map +1 -1
- package/dist/cjs/SchemaProcessor.js +41 -5
- package/dist/cjs/SchemaProcessor.js.map +1 -1
- package/dist/cjs/a.js +9 -1
- package/dist/cjs/a.js.map +1 -1
- package/dist/cjs/ai/ConversationSchemaTypes.js +210 -0
- package/dist/cjs/ai/ConversationSchemaTypes.js.map +1 -0
- package/dist/cjs/ai/ConversationType.js +27 -0
- package/dist/cjs/ai/ConversationType.js.map +1 -0
- package/dist/cjs/ai/ModelType.js +37 -0
- package/dist/cjs/ai/ModelType.js.map +1 -0
- package/dist/cjs/ai/types/ConversationMessageContent.js +6 -0
- package/dist/cjs/ai/types/ConversationMessageContent.js.map +1 -0
- package/dist/cjs/ai/types/ToolConfiguration.js +6 -0
- package/dist/cjs/ai/types/ToolConfiguration.js.map +1 -0
- package/dist/cjs/ai/types/ToolResultContent.js +6 -0
- package/dist/cjs/ai/types/ToolResultContent.js.map +1 -0
- package/dist/cjs/ai/types/contentBlocks.js +6 -0
- package/dist/cjs/ai/types/contentBlocks.js.map +1 -0
- package/dist/cjs/runtime/addSchemaToClient.js +2 -0
- package/dist/cjs/runtime/addSchemaToClient.js.map +1 -1
- package/dist/cjs/runtime/internals/APIClient.js +3 -3
- package/dist/cjs/runtime/internals/APIClient.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/conversationMessageDeserializers.js +54 -0
- package/dist/cjs/runtime/internals/ai/conversationMessageDeserializers.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/conversationMessageSerializers.js +58 -0
- package/dist/cjs/runtime/internals/ai/conversationMessageSerializers.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/convertItemToConversation.js +22 -0
- package/dist/cjs/runtime/internals/ai/convertItemToConversation.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/convertItemToConversationMessage.js +16 -0
- package/dist/cjs/runtime/internals/ai/convertItemToConversationMessage.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createCreateConversationFunction.js +18 -0
- package/dist/cjs/runtime/internals/ai/createCreateConversationFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createGetConversationFunction.js +20 -0
- package/dist/cjs/runtime/internals/ai/createGetConversationFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createListConversationsFunction.js +21 -0
- package/dist/cjs/runtime/internals/ai/createListConversationsFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createListMessagesFunction.js +22 -0
- package/dist/cjs/runtime/internals/ai/createListMessagesFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createOnMessageFunction.js +22 -0
- package/dist/cjs/runtime/internals/ai/createOnMessageFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createSendMessageFunction.js +32 -0
- package/dist/cjs/runtime/internals/ai/createSendMessageFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/index.js +5 -1
- package/dist/cjs/runtime/internals/index.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/custom.js +17 -10
- package/dist/cjs/runtime/internals/operations/custom.js.map +1 -1
- package/dist/cjs/runtime/internals/utils/clientProperties/generateConversationsProperty.js +48 -0
- package/dist/cjs/runtime/internals/utils/clientProperties/generateConversationsProperty.js.map +1 -0
- package/dist/cjs/runtime/internals/utils/clientProperties/generateGenerationsProperty.js +22 -0
- package/dist/cjs/runtime/internals/utils/clientProperties/generateGenerationsProperty.js.map +1 -0
- package/dist/esm/ClientSchema/Core/ClientSchemaProperty.d.ts +1 -1
- package/dist/esm/ClientSchema/ai/ClientConversation.d.ts +7 -0
- package/dist/esm/ClientSchema/ai/ClientConversation.mjs +2 -0
- package/dist/esm/ClientSchema/ai/ClientConversation.mjs.map +1 -0
- package/dist/esm/ClientSchema/index.d.ts +12 -2
- package/dist/esm/CustomOperation.d.ts +33 -2
- package/dist/esm/CustomOperation.mjs +21 -2
- package/dist/esm/CustomOperation.mjs.map +1 -1
- package/dist/esm/ModelSchema.d.ts +3 -1
- package/dist/esm/SchemaProcessor.d.ts +1 -1
- package/dist/esm/SchemaProcessor.mjs +41 -5
- package/dist/esm/SchemaProcessor.mjs.map +1 -1
- package/dist/esm/a.d.ts +7 -2
- package/dist/esm/a.mjs +9 -1
- package/dist/esm/a.mjs.map +1 -1
- package/dist/esm/ai/ConversationSchemaTypes.d.ts +3 -0
- package/dist/esm/ai/ConversationSchemaTypes.mjs +208 -0
- package/dist/esm/ai/ConversationSchemaTypes.mjs.map +1 -0
- package/dist/esm/ai/ConversationType.d.ts +102 -0
- package/dist/esm/ai/ConversationType.mjs +25 -0
- package/dist/esm/ai/ConversationType.mjs.map +1 -0
- package/dist/esm/ai/ModelType.d.ts +30 -0
- package/dist/esm/ai/ModelType.mjs +34 -0
- package/dist/esm/ai/ModelType.mjs.map +1 -0
- package/dist/esm/ai/types/ConversationMessageContent.d.ts +27 -0
- package/dist/esm/ai/types/ConversationMessageContent.mjs +2 -0
- package/dist/esm/ai/types/ConversationMessageContent.mjs.map +1 -0
- package/dist/esm/ai/types/ToolConfiguration.d.ts +18 -0
- package/dist/esm/ai/types/ToolConfiguration.mjs +2 -0
- package/dist/esm/ai/types/ToolConfiguration.mjs.map +1 -0
- package/dist/esm/ai/types/ToolResultContent.d.ts +18 -0
- package/dist/esm/ai/types/ToolResultContent.mjs +2 -0
- package/dist/esm/ai/types/ToolResultContent.mjs.map +1 -0
- package/dist/esm/ai/types/contentBlocks.d.ts +19 -0
- package/dist/esm/ai/types/contentBlocks.mjs +2 -0
- package/dist/esm/ai/types/contentBlocks.mjs.map +1 -0
- package/dist/esm/runtime/addSchemaToClient.mjs +4 -0
- package/dist/esm/runtime/addSchemaToClient.mjs.map +1 -1
- package/dist/esm/runtime/addSchemaToClientWithInstance.mjs +2 -1
- package/dist/esm/runtime/addSchemaToClientWithInstance.mjs.map +1 -1
- package/dist/esm/runtime/bridge-types.d.ts +29 -3
- package/dist/esm/runtime/client/index.d.ts +35 -19
- package/dist/esm/runtime/internals/APIClient.mjs +3 -3
- package/dist/esm/runtime/internals/APIClient.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/conversationMessageDeserializers.d.ts +2 -0
- package/dist/esm/runtime/internals/ai/conversationMessageDeserializers.mjs +52 -0
- package/dist/esm/runtime/internals/ai/conversationMessageDeserializers.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/conversationMessageSerializers.d.ts +37 -0
- package/dist/esm/runtime/internals/ai/conversationMessageSerializers.mjs +54 -0
- package/dist/esm/runtime/internals/ai/conversationMessageSerializers.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversation.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversation.mjs +20 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversation.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversationMessage.d.ts +7 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversationMessage.mjs +14 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversationMessage.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createCreateConversationFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createCreateConversationFunction.mjs +16 -0
- package/dist/esm/runtime/internals/ai/createCreateConversationFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createGetConversationFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createGetConversationFunction.mjs +18 -0
- package/dist/esm/runtime/internals/ai/createGetConversationFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.mjs +19 -0
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createListMessagesFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createListMessagesFunction.mjs +20 -0
- package/dist/esm/runtime/internals/ai/createListMessagesFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createOnMessageFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createOnMessageFunction.mjs +20 -0
- package/dist/esm/runtime/internals/ai/createOnMessageFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.mjs +30 -0
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/index.d.ts +2 -0
- package/dist/esm/runtime/internals/index.mjs +2 -0
- package/dist/esm/runtime/internals/index.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/custom.d.ts +1 -1
- package/dist/esm/runtime/internals/operations/custom.mjs +17 -10
- package/dist/esm/runtime/internals/operations/custom.mjs.map +1 -1
- package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.d.ts +3 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.mjs +46 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.mjs.map +1 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.d.ts +3 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.mjs +20 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.mjs.map +1 -0
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +3 -1
- package/src/ClientSchema/Core/ClientSchemaProperty.ts +3 -1
- package/src/ClientSchema/ai/ClientConversation.ts +15 -0
- package/src/ClientSchema/index.ts +15 -1
- package/src/CustomOperation.ts +48 -5
- package/src/ModelSchema.ts +4 -1
- package/src/SchemaProcessor.ts +73 -8
- package/src/a.ts +10 -1
- package/src/ai/ConversationSchemaTypes.ts +253 -0
- package/src/ai/ConversationType.ts +135 -0
- package/src/ai/ModelType.ts +43 -0
- package/src/ai/types/ConversationMessageContent.ts +43 -0
- package/src/ai/types/ToolConfiguration.ts +24 -0
- package/src/ai/types/ToolResultContent.ts +28 -0
- package/src/ai/types/contentBlocks.ts +26 -0
- package/src/runtime/addSchemaToClient.ts +12 -0
- package/src/runtime/bridge-types.ts +41 -4
- package/src/runtime/client/index.ts +82 -23
- package/src/runtime/internals/APIClient.ts +3 -4
- package/src/runtime/internals/ai/conversationMessageDeserializers.ts +62 -0
- package/src/runtime/internals/ai/conversationMessageSerializers.ts +68 -0
- package/src/runtime/internals/ai/convertItemToConversation.ts +53 -0
- package/src/runtime/internals/ai/convertItemToConversationMessage.ts +18 -0
- package/src/runtime/internals/ai/createCreateConversationFunction.ts +44 -0
- package/src/runtime/internals/ai/createGetConversationFunction.ts +48 -0
- package/src/runtime/internals/ai/createListConversationsFunction.ts +46 -0
- package/src/runtime/internals/ai/createListMessagesFunction.ts +42 -0
- package/src/runtime/internals/ai/createOnMessageFunction.ts +41 -0
- package/src/runtime/internals/ai/createSendMessageFunction.ts +60 -0
- package/src/runtime/internals/index.ts +2 -0
- package/src/runtime/internals/operations/custom.ts +24 -12
- package/src/runtime/internals/utils/clientProperties/generateConversationsProperty.ts +91 -0
- package/src/runtime/internals/utils/clientProperties/generateGenerationsProperty.ts +41 -0
|
@@ -0,0 +1,21 @@
|
|
|
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.createListConversationsFunction = void 0;
|
|
7
|
+
const list_1 = require("../operations/list");
|
|
8
|
+
const convertItemToConversation_1 = require("./convertItemToConversation");
|
|
9
|
+
const createListConversationsFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async (input) => {
|
|
10
|
+
const list = (0, list_1.listFactory)(client, modelIntrospection, conversationModel, getInternals);
|
|
11
|
+
const { data, nextToken, errors } = await list(input);
|
|
12
|
+
return {
|
|
13
|
+
data: data.map((datum) => {
|
|
14
|
+
return (0, convertItemToConversation_1.convertItemToConversation)(client, modelIntrospection, datum.id, conversationRouteName, conversationMessageModel, getInternals);
|
|
15
|
+
}),
|
|
16
|
+
nextToken,
|
|
17
|
+
errors,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.createListConversationsFunction = createListConversationsFunction;
|
|
21
|
+
//# sourceMappingURL=createListConversationsFunction.js.map
|
|
@@ -0,0 +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;AACtG,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;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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.createListMessagesFunction = void 0;
|
|
7
|
+
const list_1 = require("../operations/list");
|
|
8
|
+
const convertItemToConversationMessage_1 = require("./convertItemToConversationMessage");
|
|
9
|
+
const createListMessagesFunction = (client, modelIntrospection, conversationId, conversationMessageModel, getInternals) => async (input) => {
|
|
10
|
+
const list = (0, list_1.listFactory)(client, modelIntrospection, conversationMessageModel, getInternals);
|
|
11
|
+
const { data, nextToken, errors } = await list({
|
|
12
|
+
...input,
|
|
13
|
+
filter: { conversationId: { eq: conversationId } },
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
data: data.map((item) => (0, convertItemToConversationMessage_1.convertItemToConversationMessage)(item)),
|
|
17
|
+
nextToken,
|
|
18
|
+
errors,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.createListMessagesFunction = createListMessagesFunction;
|
|
22
|
+
//# sourceMappingURL=createListMessagesFunction.js.map
|
|
@@ -0,0 +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;AAC7G,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,IAAI,kCAAkC,CAAC,gCAAgC,EAAE,IAAI,CAAC,CAAC;AAChH,QAAQ,SAAS;AACjB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,0BAA0B,GAAG,0BAA0B;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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.createOnMessageFunction = void 0;
|
|
7
|
+
const custom_1 = require("../operations/custom");
|
|
8
|
+
const convertItemToConversationMessage_1 = require("./convertItemToConversationMessage");
|
|
9
|
+
const createOnMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => (handler) => {
|
|
10
|
+
const { conversations } = modelIntrospection;
|
|
11
|
+
// Safe guard for standalone function. When called as part of client generation, this should never be falsy.
|
|
12
|
+
if (!conversations) {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
const subscribeSchema = conversations[conversationRouteName].message.subscribe;
|
|
16
|
+
const subscribeOperation = (0, custom_1.customOpFactory)(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals);
|
|
17
|
+
return subscribeOperation({ conversationId }).subscribe((data) => {
|
|
18
|
+
handler((0, convertItemToConversationMessage_1.convertItemToConversationMessage)(data));
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
exports.createOnMessageFunction = createOnMessageFunction;
|
|
22
|
+
//# sourceMappingURL=createOnMessageFunction.js.map
|
|
@@ -0,0 +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;AAC/I,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;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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.createSendMessageFunction = void 0;
|
|
7
|
+
const custom_1 = require("../operations/custom");
|
|
8
|
+
const convertItemToConversationMessage_1 = require("./convertItemToConversationMessage");
|
|
9
|
+
const conversationMessageSerializers_1 = require("./conversationMessageSerializers");
|
|
10
|
+
const createSendMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => async ({ aiContext, content, toolConfiguration }) => {
|
|
11
|
+
const { conversations } = modelIntrospection;
|
|
12
|
+
// Safe guard for standalone function. When called as part of client generation, this should never be falsy.
|
|
13
|
+
if (!conversations) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
const sendSchema = conversations[conversationRouteName].message.send;
|
|
17
|
+
const sendOperation = (0, custom_1.customOpFactory)(client, modelIntrospection, 'mutation', sendSchema, false, getInternals);
|
|
18
|
+
const { data, errors } = await sendOperation({
|
|
19
|
+
conversationId,
|
|
20
|
+
content: (0, conversationMessageSerializers_1.serializeContent)(content),
|
|
21
|
+
...(aiContext && { aiContext: (0, conversationMessageSerializers_1.serializeAiContext)(aiContext) }),
|
|
22
|
+
...(toolConfiguration && {
|
|
23
|
+
toolConfiguration: (0, conversationMessageSerializers_1.serializeToolConfiguration)(toolConfiguration),
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
data: data ? (0, convertItemToConversationMessage_1.convertItemToConversationMessage)(data) : data,
|
|
28
|
+
errors,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.createSendMessageFunction = createSendMessageFunction;
|
|
32
|
+
//# sourceMappingURL=createSendMessageFunction.js.map
|
|
@@ -0,0 +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;AACjI,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;;"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.upgradeClientCancellation = exports.isConfigureEventWithResourceConfig = exports.isApiGraphQLConfig = exports.isGraphQLResponseWithErrors = exports.generateModelsProperty = exports.generateEnumsProperty = exports.generateCustomSubscriptionsProperty = exports.generateCustomQueriesProperty = exports.generateCustomMutationsProperty = void 0;
|
|
4
|
+
exports.upgradeClientCancellation = exports.isConfigureEventWithResourceConfig = exports.isApiGraphQLConfig = exports.isGraphQLResponseWithErrors = exports.generateModelsProperty = exports.generateEnumsProperty = exports.generateGenerationsProperty = exports.generateConversationsProperty = exports.generateCustomSubscriptionsProperty = exports.generateCustomQueriesProperty = exports.generateCustomMutationsProperty = void 0;
|
|
5
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
7
7
|
var generateCustomOperationsProperty_1 = require("./generateCustomOperationsProperty");
|
|
8
8
|
Object.defineProperty(exports, "generateCustomMutationsProperty", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomMutationsProperty; } });
|
|
9
9
|
Object.defineProperty(exports, "generateCustomQueriesProperty", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomQueriesProperty; } });
|
|
10
10
|
Object.defineProperty(exports, "generateCustomSubscriptionsProperty", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomSubscriptionsProperty; } });
|
|
11
|
+
var generateConversationsProperty_1 = require("./utils/clientProperties/generateConversationsProperty");
|
|
12
|
+
Object.defineProperty(exports, "generateConversationsProperty", { enumerable: true, get: function () { return generateConversationsProperty_1.generateConversationsProperty; } });
|
|
13
|
+
var generateGenerationsProperty_1 = require("./utils/clientProperties/generateGenerationsProperty");
|
|
14
|
+
Object.defineProperty(exports, "generateGenerationsProperty", { enumerable: true, get: function () { return generateGenerationsProperty_1.generateGenerationsProperty; } });
|
|
11
15
|
var generateEnumsProperty_1 = require("./utils/clientProperties/generateEnumsProperty");
|
|
12
16
|
Object.defineProperty(exports, "generateEnumsProperty", { enumerable: true, get: function () { return generateEnumsProperty_1.generateEnumsProperty; } });
|
|
13
17
|
var generateModelsProperty_1 = require("./utils/clientProperties/generateModelsProperty");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/runtime/internals/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.upgradeClientCancellation = exports.isConfigureEventWithResourceConfig = exports.isApiGraphQLConfig = exports.isGraphQLResponseWithErrors = exports.generateModelsProperty = exports.generateEnumsProperty = exports.generateCustomSubscriptionsProperty = exports.generateCustomQueriesProperty = exports.generateCustomMutationsProperty = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar generateCustomOperationsProperty_1 = require(\"./generateCustomOperationsProperty\");\nObject.defineProperty(exports, \"generateCustomMutationsProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomMutationsProperty; } });\nObject.defineProperty(exports, \"generateCustomQueriesProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomQueriesProperty; } });\nObject.defineProperty(exports, \"generateCustomSubscriptionsProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomSubscriptionsProperty; } });\nvar generateEnumsProperty_1 = require(\"./utils/clientProperties/generateEnumsProperty\");\nObject.defineProperty(exports, \"generateEnumsProperty\", { enumerable: true, get: function () { return generateEnumsProperty_1.generateEnumsProperty; } });\nvar generateModelsProperty_1 = require(\"./utils/clientProperties/generateModelsProperty\");\nObject.defineProperty(exports, \"generateModelsProperty\", { enumerable: true, get: function () { return generateModelsProperty_1.generateModelsProperty; } });\nvar isGraphQLResponseWithErrors_1 = require(\"./utils/runtimeTypeGuards/isGraphQLResponseWithErrors\");\nObject.defineProperty(exports, \"isGraphQLResponseWithErrors\", { enumerable: true, get: function () { return isGraphQLResponseWithErrors_1.isGraphQLResponseWithErrors; } });\nvar isApiGraphQLProviderConfig_1 = require(\"./utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nObject.defineProperty(exports, \"isApiGraphQLConfig\", { enumerable: true, get: function () { return isApiGraphQLProviderConfig_1.isApiGraphQLConfig; } });\nvar isConfigureEventWithResourceConfig_1 = require(\"./utils/runtimeTypeGuards/isConfigureEventWithResourceConfig\");\nObject.defineProperty(exports, \"isConfigureEventWithResourceConfig\", { enumerable: true, get: function () { return isConfigureEventWithResourceConfig_1.isConfigureEventWithResourceConfig; } });\nvar cancellation_1 = require(\"./cancellation\");\nObject.defineProperty(exports, \"upgradeClientCancellation\", { enumerable: true, get: function () { return cancellation_1.upgradeClientCancellation; } });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,yBAAyB,GAAG,OAAO,CAAC,kCAAkC,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,2BAA2B,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,mCAAmC,GAAG,OAAO,CAAC,6BAA6B,GAAG,OAAO,CAAC,+BAA+B,GAAG,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/runtime/internals/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.upgradeClientCancellation = exports.isConfigureEventWithResourceConfig = exports.isApiGraphQLConfig = exports.isGraphQLResponseWithErrors = exports.generateModelsProperty = exports.generateEnumsProperty = exports.generateGenerationsProperty = exports.generateConversationsProperty = exports.generateCustomSubscriptionsProperty = exports.generateCustomQueriesProperty = exports.generateCustomMutationsProperty = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar generateCustomOperationsProperty_1 = require(\"./generateCustomOperationsProperty\");\nObject.defineProperty(exports, \"generateCustomMutationsProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomMutationsProperty; } });\nObject.defineProperty(exports, \"generateCustomQueriesProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomQueriesProperty; } });\nObject.defineProperty(exports, \"generateCustomSubscriptionsProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomSubscriptionsProperty; } });\nvar generateConversationsProperty_1 = require(\"./utils/clientProperties/generateConversationsProperty\");\nObject.defineProperty(exports, \"generateConversationsProperty\", { enumerable: true, get: function () { return generateConversationsProperty_1.generateConversationsProperty; } });\nvar generateGenerationsProperty_1 = require(\"./utils/clientProperties/generateGenerationsProperty\");\nObject.defineProperty(exports, \"generateGenerationsProperty\", { enumerable: true, get: function () { return generateGenerationsProperty_1.generateGenerationsProperty; } });\nvar generateEnumsProperty_1 = require(\"./utils/clientProperties/generateEnumsProperty\");\nObject.defineProperty(exports, \"generateEnumsProperty\", { enumerable: true, get: function () { return generateEnumsProperty_1.generateEnumsProperty; } });\nvar generateModelsProperty_1 = require(\"./utils/clientProperties/generateModelsProperty\");\nObject.defineProperty(exports, \"generateModelsProperty\", { enumerable: true, get: function () { return generateModelsProperty_1.generateModelsProperty; } });\nvar isGraphQLResponseWithErrors_1 = require(\"./utils/runtimeTypeGuards/isGraphQLResponseWithErrors\");\nObject.defineProperty(exports, \"isGraphQLResponseWithErrors\", { enumerable: true, get: function () { return isGraphQLResponseWithErrors_1.isGraphQLResponseWithErrors; } });\nvar isApiGraphQLProviderConfig_1 = require(\"./utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nObject.defineProperty(exports, \"isApiGraphQLConfig\", { enumerable: true, get: function () { return isApiGraphQLProviderConfig_1.isApiGraphQLConfig; } });\nvar isConfigureEventWithResourceConfig_1 = require(\"./utils/runtimeTypeGuards/isConfigureEventWithResourceConfig\");\nObject.defineProperty(exports, \"isConfigureEventWithResourceConfig\", { enumerable: true, get: function () { return isConfigureEventWithResourceConfig_1.isConfigureEventWithResourceConfig; } });\nvar cancellation_1 = require(\"./cancellation\");\nObject.defineProperty(exports, \"upgradeClientCancellation\", { enumerable: true, get: function () { return cancellation_1.upgradeClientCancellation; } });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,yBAAyB,GAAG,OAAO,CAAC,kCAAkC,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,2BAA2B,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,2BAA2B,GAAG,OAAO,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Y,EAAE,OAAO,cAAc,CAAC,yBAAyB,CAAC,EAAE,EAAE,CAAC;;"}
|
|
@@ -121,18 +121,25 @@ exports.customOpFactory = customOpFactory;
|
|
|
121
121
|
function hasStringField(o, field) {
|
|
122
122
|
return typeof o[field] === 'string';
|
|
123
123
|
}
|
|
124
|
+
function isEnumType(type) {
|
|
125
|
+
return type instanceof Object && 'enum' in type;
|
|
126
|
+
}
|
|
127
|
+
function isInputType(type) {
|
|
128
|
+
return type instanceof Object && 'input' in type;
|
|
129
|
+
}
|
|
124
130
|
/**
|
|
125
131
|
* @param argDef A single argument definition from a custom operation
|
|
126
132
|
* @returns A string naming the base type including the `!` if the arg is required.
|
|
127
133
|
*/
|
|
128
|
-
function argumentBaseTypeString(
|
|
129
|
-
const requiredFlag =
|
|
130
|
-
if (
|
|
131
|
-
return
|
|
134
|
+
function argumentBaseTypeString({ type, isRequired }) {
|
|
135
|
+
const requiredFlag = isRequired ? '!' : '';
|
|
136
|
+
if (isEnumType(type)) {
|
|
137
|
+
return `${type.enum}${requiredFlag}`;
|
|
132
138
|
}
|
|
133
|
-
|
|
134
|
-
return
|
|
139
|
+
if (isInputType(type)) {
|
|
140
|
+
return `${type.input}${requiredFlag}`;
|
|
135
141
|
}
|
|
142
|
+
return `${type}${requiredFlag}`;
|
|
136
143
|
}
|
|
137
144
|
/**
|
|
138
145
|
* Generates "outer" arguments string for a custom operation. For example,
|
|
@@ -158,10 +165,10 @@ function outerArguments(operation) {
|
|
|
158
165
|
return '';
|
|
159
166
|
}
|
|
160
167
|
const args = Object.entries(operation.arguments)
|
|
161
|
-
.map(([k,
|
|
162
|
-
const baseType = argumentBaseTypeString(
|
|
163
|
-
const finalType =
|
|
164
|
-
? `[${baseType}]${
|
|
168
|
+
.map(([k, argument]) => {
|
|
169
|
+
const baseType = argumentBaseTypeString(argument);
|
|
170
|
+
const finalType = argument.isArray
|
|
171
|
+
? `[${baseType}]${argument.isArrayNullable ? '' : '!'}`
|
|
165
172
|
: baseType;
|
|
166
173
|
return `$${k}: ${finalType}`;
|
|
167
174
|
})
|
|
@@ -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}\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(argDef) {\n const requiredFlag = argDef.isRequired ? '!' : '';\n if (argDef.type instanceof Object && 'enum' in argDef.type) {\n return argDef.type.enum + requiredFlag;\n }\n else {\n return argDef.type + requiredFlag;\n }\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, v]) => {\n const baseType = argumentBaseTypeString(v);\n const finalType = v.isArray\n ? `[${baseType}]${v.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,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACjC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC/B,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;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC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AAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC9C,QAAQ,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrC,QAAQ,MAAM,CAAC,WAAW,CAAC,GAAG,mBAAmB;AACjD,cAAc,IAAI,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,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;;"}
|
|
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":[],"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C3B,KAAK,CAAC,CAAC,CAAC;AACR;;"}
|
|
@@ -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.generateConversationsProperty = void 0;
|
|
7
|
+
const createCreateConversationFunction_1 = require("../../ai/createCreateConversationFunction");
|
|
8
|
+
const createGetConversationFunction_1 = require("../../ai/createGetConversationFunction");
|
|
9
|
+
const createListConversationsFunction_1 = require("../../ai/createListConversationsFunction");
|
|
10
|
+
function generateConversationsProperty(client, apiGraphQLConfig, getInternals) {
|
|
11
|
+
const modelIntrospection = apiGraphQLConfig?.modelIntrospection;
|
|
12
|
+
// conversations will be absent from model intro schema if no conversation routes
|
|
13
|
+
// are present on the source schema.
|
|
14
|
+
if (!modelIntrospection?.conversations) {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
const conversations = {};
|
|
18
|
+
for (const { name, conversation, message, models, nonModels, enums, } of Object.values(modelIntrospection.conversations)) {
|
|
19
|
+
const conversationModel = models[conversation.modelName];
|
|
20
|
+
const conversationMessageModel = models[message.modelName];
|
|
21
|
+
if (!conversationModel || !conversationMessageModel) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
const conversationModelIntrospection = {
|
|
25
|
+
...modelIntrospection,
|
|
26
|
+
models: {
|
|
27
|
+
...modelIntrospection.models,
|
|
28
|
+
...models,
|
|
29
|
+
},
|
|
30
|
+
nonModels: {
|
|
31
|
+
...modelIntrospection.nonModels,
|
|
32
|
+
...nonModels,
|
|
33
|
+
},
|
|
34
|
+
enums: {
|
|
35
|
+
...modelIntrospection.enums,
|
|
36
|
+
...enums,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
conversations[name] = {
|
|
40
|
+
create: (0, createCreateConversationFunction_1.createCreateConversationFunction)(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),
|
|
41
|
+
get: (0, createGetConversationFunction_1.createGetConversationFunction)(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),
|
|
42
|
+
list: (0, createListConversationsFunction_1.createListConversationsFunction)(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return conversations;
|
|
46
|
+
}
|
|
47
|
+
exports.generateConversationsProperty = generateConversationsProperty;
|
|
48
|
+
//# sourceMappingURL=generateConversationsProperty.js.map
|
package/dist/cjs/runtime/internals/utils/clientProperties/generateConversationsProperty.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateConversationsProperty.js","sources":["../../../../../../src/runtime/internals/utils/clientProperties/generateConversationsProperty.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.generateConversationsProperty = void 0;\nconst createCreateConversationFunction_1 = require(\"../../ai/createCreateConversationFunction\");\nconst createGetConversationFunction_1 = require(\"../../ai/createGetConversationFunction\");\nconst createListConversationsFunction_1 = require(\"../../ai/createListConversationsFunction\");\nfunction generateConversationsProperty(client, apiGraphQLConfig, getInternals) {\n const modelIntrospection = apiGraphQLConfig?.modelIntrospection;\n // conversations will be absent from model intro schema if no conversation routes\n // are present on the source schema.\n if (!modelIntrospection?.conversations) {\n return {};\n }\n const conversations = {};\n for (const { name, conversation, message, models, nonModels, enums, } of Object.values(modelIntrospection.conversations)) {\n const conversationModel = models[conversation.modelName];\n const conversationMessageModel = models[message.modelName];\n if (!conversationModel || !conversationMessageModel) {\n return {};\n }\n const conversationModelIntrospection = {\n ...modelIntrospection,\n models: {\n ...modelIntrospection.models,\n ...models,\n },\n nonModels: {\n ...modelIntrospection.nonModels,\n ...nonModels,\n },\n enums: {\n ...modelIntrospection.enums,\n ...enums,\n },\n };\n conversations[name] = {\n create: (0, createCreateConversationFunction_1.createCreateConversationFunction)(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),\n get: (0, createGetConversationFunction_1.createGetConversationFunction)(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),\n list: (0, createListConversationsFunction_1.createListConversationsFunction)(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),\n };\n }\n return conversations;\n}\nexports.generateConversationsProperty = generateConversationsProperty;\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,kCAAkC,GAAG,OAAO,CAAC,2CAA2C,CAAC,CAAC;AAChG,MAAM,+BAA+B,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AAC1F,MAAM,iCAAiC,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AAC9F,SAAS,6BAA6B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE;AAC/E,IAAI,MAAM,kBAAkB,GAAG,gBAAgB,EAAE,kBAAkB,CAAC;AACpE;AACA;AACA,IAAI,IAAI,CAAC,kBAAkB,EAAE,aAAa,EAAE;AAC5C,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,aAAa,GAAG,EAAE,CAAC;AAC7B,IAAI,KAAK,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,aAAa,CAAC,EAAE;AAC9H,QAAQ,MAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AACjE,QAAQ,MAAM,wBAA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
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateGenerationsProperty = void 0;
|
|
7
|
+
const custom_1 = require("../../operations/custom");
|
|
8
|
+
function generateGenerationsProperty(client, apiGraphQLConfig, getInternals) {
|
|
9
|
+
const modelIntrospection = apiGraphQLConfig?.modelIntrospection;
|
|
10
|
+
// generations will be absent from model intro schema if no generation routes
|
|
11
|
+
// are present on the source schema.
|
|
12
|
+
if (!modelIntrospection?.generations) {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
const generations = {};
|
|
16
|
+
for (const generation of Object.values(modelIntrospection.generations)) {
|
|
17
|
+
generations[generation.name] = (0, custom_1.customOpFactory)(client, modelIntrospection, 'query', generation, false, getInternals);
|
|
18
|
+
}
|
|
19
|
+
return generations;
|
|
20
|
+
}
|
|
21
|
+
exports.generateGenerationsProperty = generateGenerationsProperty;
|
|
22
|
+
//# sourceMappingURL=generateGenerationsProperty.js.map
|
|
@@ -0,0 +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;AAC3I,KAAK;AACL,IAAI,OAAO,WAAW,CAAC;AACvB,CAAC;AACD,OAAO,CAAC,2BAA2B,GAAG,2BAA2B;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export interface ClientSchemaProperty {
|
|
2
|
-
__entityType: 'model' | 'enum' | 'customType' | 'customQuery' | 'customMutation' | 'customSubscription';
|
|
2
|
+
__entityType: 'model' | 'enum' | 'customType' | 'customQuery' | 'customMutation' | 'customSubscription' | 'customConversation' | 'customGeneration';
|
|
3
3
|
type: any;
|
|
4
4
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Conversation, ConversationMessage } from '../../ai/ConversationType';
|
|
2
|
+
import type { ClientSchemaProperty } from '../Core';
|
|
3
|
+
export interface ClientConversation extends Pick<ClientSchemaProperty, '__entityType'> {
|
|
4
|
+
__entityType: 'customConversation';
|
|
5
|
+
type: Conversation;
|
|
6
|
+
messageType: ConversationMessage;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientConversation.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import type { __modelMeta__ } from '../runtime/client';
|
|
2
|
-
import type { BaseSchema, CustomOperation, CustomType, EnumType, GenericModelSchema, ModelSchemaContents, ModelType } from '../ModelSchema';
|
|
2
|
+
import type { BaseSchema, ConversationType, CustomOperation, CustomType, EnumType, GenericModelSchema, ModelSchemaContents, ModelType } from '../ModelSchema';
|
|
3
3
|
import type { ClientCustomOperation, ClientCustomType, ClientEnum, ClientModel } from './Core';
|
|
4
4
|
import type { CombinedModelSchema, CombinedSchemaIndexesUnion } from '../CombineSchema';
|
|
5
5
|
import type { SchemaMetadata } from './utilities/SchemaMetadata';
|
|
6
6
|
import type { Brand, Select, SpreadTuple } from '../util';
|
|
7
|
+
import { ClientConversation } from './ai/ClientConversation';
|
|
7
8
|
export type ClientSchema<Schema extends GenericModelSchema<any> | CombinedModelSchema<any>> = Schema extends GenericModelSchema<any> ? InternalClientSchema<Schema> : Schema extends CombinedModelSchema<any> ? InternalCombinedSchema<Schema> : never;
|
|
8
9
|
type InternalClientSchema<CustomerSchema extends ModelSchemaContents | BaseSchema<any, any>, Metadata extends SchemaMetadata<any> = never, IsRDS extends boolean = never> = CustomerSchema extends ModelSchemaContents ? {
|
|
9
10
|
[K in keyof CustomerSchema as K extends string ? K : never]: K extends string ? ClientSchemaProperty<CustomerSchema, Metadata, IsRDS, K> : never;
|
|
10
11
|
} : CustomerSchema extends BaseSchema<any, any> ? InternalClientSchema<CustomerSchema['data']['types'], SchemaMetadata<CustomerSchema>, CustomerSchema extends Brand<'RDSSchema'> ? true : false> : never;
|
|
11
|
-
type ClientSchemaProperty<T extends ModelSchemaContents, Metadata extends SchemaMetadata<any>, IsRDS extends boolean, K extends keyof T & string> = T[K] extends Brand<'enum'> ? RemapEnum<T, T[K]> : T[K] extends Brand<'customType'> ? RemapCustomType<T, Metadata, IsRDS, T[K]> : T[K] extends Brand<'queryCustomOperation' | 'mutationCustomOperation' | 'subscriptionCustomOperation'> ? RemapCustomOperation<T, Metadata, IsRDS, T[K]> : T[K] extends Brand<'modelType'> ? RemapModel<T, Metadata, IsRDS, T[K], K> : never;
|
|
12
|
+
type ClientSchemaProperty<T extends ModelSchemaContents, Metadata extends SchemaMetadata<any>, IsRDS extends boolean, K extends keyof T & string> = T[K] extends Brand<'enum'> ? RemapEnum<T, T[K]> : T[K] extends Brand<'customType'> ? RemapCustomType<T, Metadata, IsRDS, T[K]> : T[K] extends Brand<'queryCustomOperation' | 'mutationCustomOperation' | 'subscriptionCustomOperation' | 'generationCustomOperation'> ? RemapCustomOperation<T, Metadata, IsRDS, T[K]> : T[K] extends Brand<'modelType'> ? RemapModel<T, Metadata, IsRDS, T[K], K> : T[K] extends Brand<'conversationCustomOperation'> ? RemapAIRoute<T, T[K]> : never;
|
|
12
13
|
type RemapEnum<_T extends ModelSchemaContents, E> = E extends EnumType<infer values> ? ClientEnum<values> : never;
|
|
13
14
|
type RemapCustomType<T extends ModelSchemaContents, Metadata extends SchemaMetadata<any>, IsRDS extends boolean, E> = E extends CustomType<infer CT> ? ClientCustomType<InternalClientSchema<T, Metadata, IsRDS>, CT> : never;
|
|
14
15
|
type RemapCustomOperation<T extends ModelSchemaContents, Metadata extends SchemaMetadata<any>, IsRDS extends boolean, E> = E extends CustomOperation<infer CO, any> ? ClientCustomOperation<InternalClientSchema<T, Metadata, IsRDS>, CO> : never;
|
|
15
16
|
type RemapModel<T extends ModelSchemaContents, Metadata extends SchemaMetadata<any>, IsRDS extends boolean, E, K extends keyof T & string> = E extends ModelType<infer MT, any> ? ClientModel<InternalClientSchema<T, Metadata, IsRDS>, Metadata, IsRDS, MT, K> : never;
|
|
17
|
+
type RemapAIRoute<_T extends ModelSchemaContents, E> = E extends ConversationType ? ClientConversation : never;
|
|
16
18
|
type GetInternalClientSchema<Schema> = Schema extends GenericModelSchema<any> ? InternalClientSchema<Schema> : never;
|
|
17
19
|
type CombinedClientSchemas<Schemas extends CombinedModelSchema<any>['schemas']> = {
|
|
18
20
|
[Index in keyof Schemas]: Index extends CombinedSchemaIndexesUnion ? GetInternalClientSchema<Schemas[Index]> : never;
|
|
@@ -35,6 +37,8 @@ export type ClientSchemaByEntityTypeBaseShape = {
|
|
|
35
37
|
queries: Record<string, ClientCustomOperation<any, any>>;
|
|
36
38
|
mutations: Record<string, ClientCustomOperation<any, any>>;
|
|
37
39
|
subscriptions: Record<string, ClientCustomOperation<any, any>>;
|
|
40
|
+
conversations: Record<string, ClientConversation>;
|
|
41
|
+
generations: Record<string, ClientCustomOperation<any, any>>;
|
|
38
42
|
};
|
|
39
43
|
export type ClientSchemaByEntityType<T> = {
|
|
40
44
|
enums: Select<T, {
|
|
@@ -55,5 +59,11 @@ export type ClientSchemaByEntityType<T> = {
|
|
|
55
59
|
subscriptions: Select<T, {
|
|
56
60
|
__entityType: 'customSubscription';
|
|
57
61
|
}>;
|
|
62
|
+
conversations: Select<T, {
|
|
63
|
+
__entityType: 'customConversation';
|
|
64
|
+
}>;
|
|
65
|
+
generations: Select<T, {
|
|
66
|
+
__entityType: 'customGeneration';
|
|
67
|
+
}>;
|
|
58
68
|
};
|
|
59
69
|
export {};
|
|
@@ -6,10 +6,12 @@ import { RefType, InternalRef } from './RefType';
|
|
|
6
6
|
import { EnumType } from './EnumType';
|
|
7
7
|
import { CustomType } from './CustomType';
|
|
8
8
|
import type { CustomHandler, FunctionHandler, HandlerType as Handler } from './Handler';
|
|
9
|
+
import { AiModel, InferenceConfiguration } from './ai/ModelType';
|
|
9
10
|
declare const queryBrand = "queryCustomOperation";
|
|
10
11
|
declare const mutationBrand = "mutationCustomOperation";
|
|
11
12
|
declare const subscriptionBrand = "subscriptionCustomOperation";
|
|
12
|
-
|
|
13
|
+
declare const generationBrand = "generationCustomOperation";
|
|
14
|
+
type CustomOperationBrand = typeof queryBrand | typeof mutationBrand | typeof subscriptionBrand | typeof generationBrand;
|
|
13
15
|
type CustomArguments = Record<string, BaseModelField | EnumType>;
|
|
14
16
|
type SubscriptionSource = RefType<any, any>;
|
|
15
17
|
type InternalSubscriptionSource = InternalRef;
|
|
@@ -17,7 +19,7 @@ type CustomReturnType = RefType<any> | CustomType<any>;
|
|
|
17
19
|
type InternalCustomArguments = Record<string, InternalField>;
|
|
18
20
|
type InternalCustomReturnType = InternalRef;
|
|
19
21
|
type HandlerInputType = FunctionHandler[] | CustomHandler[] | Handler;
|
|
20
|
-
export declare const CustomOperationNames: readonly ["Query", "Mutation", "Subscription"];
|
|
22
|
+
export declare const CustomOperationNames: readonly ["Query", "Mutation", "Subscription", "Generation"];
|
|
21
23
|
type CustomOperationName = (typeof CustomOperationNames)[number];
|
|
22
24
|
type CustomData = {
|
|
23
25
|
arguments: CustomArguments;
|
|
@@ -26,6 +28,7 @@ type CustomData = {
|
|
|
26
28
|
typeName: CustomOperationName;
|
|
27
29
|
handlers: Handler[] | null;
|
|
28
30
|
subscriptionSource: SubscriptionSource[];
|
|
31
|
+
input?: CustomOperationInput;
|
|
29
32
|
};
|
|
30
33
|
type InternalCustomData = CustomData & {
|
|
31
34
|
arguments: InternalCustomArguments;
|
|
@@ -33,12 +36,14 @@ type InternalCustomData = CustomData & {
|
|
|
33
36
|
subscriptionSource: InternalSubscriptionSource[];
|
|
34
37
|
authorization: Authorization<any, any, any>[];
|
|
35
38
|
};
|
|
39
|
+
export type CustomOperationInput = GenerationInput;
|
|
36
40
|
export type CustomOperationParamShape = {
|
|
37
41
|
arguments: CustomArguments | null;
|
|
38
42
|
returnType: CustomReturnType | null;
|
|
39
43
|
authorization: Authorization<any, any, any>[];
|
|
40
44
|
typeName: CustomOperationName;
|
|
41
45
|
handlers: Handler | null;
|
|
46
|
+
input?: CustomOperationInput;
|
|
42
47
|
};
|
|
43
48
|
export type CustomOperation<T extends CustomOperationParamShape, K extends keyof CustomOperation<T> = never, B extends CustomOperationBrand = CustomOperationBrand> = Omit<{
|
|
44
49
|
arguments<Arguments extends CustomArguments>(args: Arguments): CustomOperation<SetTypeSubArg<T, 'arguments', Arguments>, K | 'arguments', B>;
|
|
@@ -124,4 +129,30 @@ export declare function subscription(): CustomOperation<{
|
|
|
124
129
|
typeName: 'Subscription';
|
|
125
130
|
handlers: null;
|
|
126
131
|
}, 'returns', typeof subscriptionBrand>;
|
|
132
|
+
export interface GenerationInput {
|
|
133
|
+
aiModel: AiModel;
|
|
134
|
+
systemPrompt: string;
|
|
135
|
+
inferenceConfiguration?: InferenceConfiguration;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* @experimental
|
|
139
|
+
*
|
|
140
|
+
* Define an AI generation route for single request-response interaction with specified AI model.
|
|
141
|
+
* @example
|
|
142
|
+
* makeRecipe: a.generation({
|
|
143
|
+
* aiModel: { resourcePath },
|
|
144
|
+
* systemPrompt: 'Please make a recipe from the provided ingredients',
|
|
145
|
+
* })
|
|
146
|
+
* .arguments({ ingredients: a.string().array() })
|
|
147
|
+
* .returns(a.ref("Recipe"))
|
|
148
|
+
* @returns a generation route definition
|
|
149
|
+
*/
|
|
150
|
+
export declare function generation(input: GenerationInput): CustomOperation<{
|
|
151
|
+
arguments: null;
|
|
152
|
+
returnType: null;
|
|
153
|
+
authorization: [];
|
|
154
|
+
typeName: 'Generation';
|
|
155
|
+
handlers: null;
|
|
156
|
+
input: GenerationInput;
|
|
157
|
+
}, 'for' | 'handler', typeof generationBrand>;
|
|
127
158
|
export {};
|