@aws-amplify/data-schema 1.12.2 → 1.13.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.
Files changed (48) hide show
  1. package/dist/cjs/ai/ConversationSchemaTypes.js +19 -0
  2. package/dist/cjs/ai/ConversationSchemaTypes.js.map +1 -1
  3. package/dist/cjs/ai/types/ConversationStreamEvent.js +6 -0
  4. package/dist/cjs/ai/types/ConversationStreamEvent.js.map +1 -0
  5. package/dist/cjs/runtime/internals/ai/conversationStreamEventDeserializers.js +41 -0
  6. package/dist/cjs/runtime/internals/ai/conversationStreamEventDeserializers.js.map +1 -0
  7. package/dist/cjs/runtime/internals/ai/convertItemToConversation.js +2 -2
  8. package/dist/cjs/runtime/internals/ai/convertItemToConversation.js.map +1 -1
  9. package/dist/cjs/runtime/internals/ai/convertItemToConversationMessage.js +1 -1
  10. package/dist/cjs/runtime/internals/ai/convertItemToConversationMessage.js.map +1 -1
  11. package/dist/cjs/runtime/internals/ai/{createOnMessageFunction.js → createOnStreamEventFunction.js} +11 -7
  12. package/dist/cjs/runtime/internals/ai/createOnStreamEventFunction.js.map +1 -0
  13. package/dist/cjs/runtime/internals/ai/getCustomUserAgentDetails.js +1 -1
  14. package/dist/cjs/runtime/internals/ai/getCustomUserAgentDetails.js.map +1 -1
  15. package/dist/esm/ClientSchema/ai/ClientConversation.d.ts +2 -1
  16. package/dist/esm/ai/ConversationSchemaTypes.mjs +19 -0
  17. package/dist/esm/ai/ConversationSchemaTypes.mjs.map +1 -1
  18. package/dist/esm/ai/ConversationType.d.ts +9 -4
  19. package/dist/esm/ai/types/ConversationStreamEvent.d.ts +56 -0
  20. package/dist/esm/ai/types/ConversationStreamEvent.mjs +2 -0
  21. package/dist/esm/ai/types/ConversationStreamEvent.mjs.map +1 -0
  22. package/dist/esm/runtime/internals/ai/conversationStreamEventDeserializers.d.ts +6 -0
  23. package/dist/esm/runtime/internals/ai/conversationStreamEventDeserializers.mjs +38 -0
  24. package/dist/esm/runtime/internals/ai/conversationStreamEventDeserializers.mjs.map +1 -0
  25. package/dist/esm/runtime/internals/ai/convertItemToConversation.mjs +2 -2
  26. package/dist/esm/runtime/internals/ai/convertItemToConversation.mjs.map +1 -1
  27. package/dist/esm/runtime/internals/ai/convertItemToConversationMessage.mjs +1 -1
  28. package/dist/esm/runtime/internals/ai/convertItemToConversationMessage.mjs.map +1 -1
  29. package/dist/esm/runtime/internals/ai/createOnStreamEventFunction.d.ts +3 -0
  30. package/dist/esm/runtime/internals/ai/{createOnMessageFunction.mjs → createOnStreamEventFunction.mjs} +10 -6
  31. package/dist/esm/runtime/internals/ai/createOnStreamEventFunction.mjs.map +1 -0
  32. package/dist/esm/runtime/internals/ai/getCustomUserAgentDetails.d.ts +1 -1
  33. package/dist/esm/runtime/internals/ai/getCustomUserAgentDetails.mjs +1 -1
  34. package/dist/esm/runtime/internals/ai/getCustomUserAgentDetails.mjs.map +1 -1
  35. package/dist/meta/cjs.tsbuildinfo +1 -1
  36. package/package.json +1 -1
  37. package/src/ClientSchema/ai/ClientConversation.ts +2 -0
  38. package/src/ai/ConversationSchemaTypes.ts +21 -0
  39. package/src/ai/ConversationType.ts +10 -3
  40. package/src/ai/types/ConversationStreamEvent.ts +70 -0
  41. package/src/runtime/internals/ai/conversationStreamEventDeserializers.ts +62 -0
  42. package/src/runtime/internals/ai/convertItemToConversation.ts +2 -2
  43. package/src/runtime/internals/ai/convertItemToConversationMessage.ts +1 -1
  44. package/src/runtime/internals/ai/{createOnMessageFunction.ts → createOnStreamEventFunction.ts} +7 -5
  45. package/src/runtime/internals/ai/getCustomUserAgentDetails.ts +1 -1
  46. package/dist/cjs/runtime/internals/ai/createOnMessageFunction.js.map +0 -1
  47. package/dist/esm/runtime/internals/ai/createOnMessageFunction.d.ts +0 -3
  48. package/dist/esm/runtime/internals/ai/createOnMessageFunction.mjs.map +0 -1
@@ -1,21 +1,25 @@
1
1
  import { customOpFactory } from '../operations/custom.mjs';
2
- import { convertItemToConversationMessage } from './convertItemToConversationMessage.mjs';
3
2
  import { getCustomUserAgentDetails, AiAction } from './getCustomUserAgentDetails.mjs';
3
+ import { convertItemToConversationStreamEvent } from './conversationStreamEventDeserializers.mjs';
4
4
 
5
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
6
  // SPDX-License-Identifier: Apache-2.0
7
- const createOnMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => (handler) => {
7
+ const createOnStreamEventFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => (handler) => {
8
8
  const { conversations } = modelIntrospection;
9
9
  // Safe guard for standalone function. When called as part of client generation, this should never be falsy.
10
10
  if (!conversations) {
11
11
  return {};
12
12
  }
13
13
  const subscribeSchema = conversations[conversationRouteName].message.subscribe;
14
- const subscribeOperation = customOpFactory(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals, getCustomUserAgentDetails(AiAction.OnMessage));
14
+ const subscribeOperation = customOpFactory(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals, getCustomUserAgentDetails(AiAction.OnStreamEvent));
15
15
  return subscribeOperation({ conversationId }).subscribe((data) => {
16
- handler(convertItemToConversationMessage(data));
16
+ const { next, error } = convertItemToConversationStreamEvent(data);
17
+ if (error)
18
+ handler.error(error);
19
+ if (next)
20
+ handler.next(next);
17
21
  });
18
22
  };
19
23
 
20
- export { createOnMessageFunction };
21
- //# sourceMappingURL=createOnMessageFunction.mjs.map
24
+ export { createOnStreamEventFunction };
25
+ //# sourceMappingURL=createOnStreamEventFunction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createOnStreamEventFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createOnStreamEventFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { customOpFactory } from '../operations/custom';\nimport { AiAction, getCustomUserAgentDetails } from './getCustomUserAgentDetails';\nimport { convertItemToConversationStreamEvent } from './conversationStreamEventDeserializers';\nexport const createOnStreamEventFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => (handler) => {\n const { conversations } = modelIntrospection;\n // Safe guard for standalone function. When called as part of client generation, this should never be falsy.\n if (!conversations) {\n return {};\n }\n const subscribeSchema = conversations[conversationRouteName].message.subscribe;\n const subscribeOperation = customOpFactory(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals, getCustomUserAgentDetails(AiAction.OnStreamEvent));\n return subscribeOperation({ conversationId }).subscribe((data) => {\n const { next, error } = convertItemToConversationStreamEvent(data);\n if (error)\n handler.error(error);\n if (next)\n handler.next(next);\n });\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,2BAA2B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,KAAK,CAAC,OAAO,KAAK;AAC7I,IAAI,MAAM,EAAE,aAAa,EAAE,GAAG,kBAAkB,CAAC;AACjD;AACA,IAAI,IAAI,CAAC,aAAa,EAAE;AACxB,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,eAAe,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;AACnF,IAAI,MAAM,kBAAkB,GAAG,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,EAAE,yBAAyB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AACpL,IAAI,OAAO,kBAAkB,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK;AACtE,QAAQ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,oCAAoC,CAAC,IAAI,CAAC,CAAC;AAC3E,QAAQ,IAAI,KAAK;AACjB,YAAY,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACjC,QAAQ,IAAI,IAAI;AAChB,YAAY,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/B,KAAK,CAAC,CAAC;AACP;;;;"}
@@ -16,7 +16,7 @@ export declare enum AiAction {
16
16
  DeleteConversation = "4",
17
17
  SendMessage = "5",
18
18
  ListMessages = "6",
19
- OnMessage = "7",
19
+ OnStreamEvent = "7",
20
20
  Generation = "8",
21
21
  UpdateConversation = "9"
22
22
  }
@@ -17,7 +17,7 @@ var AiAction;
17
17
  AiAction["DeleteConversation"] = "4";
18
18
  AiAction["SendMessage"] = "5";
19
19
  AiAction["ListMessages"] = "6";
20
- AiAction["OnMessage"] = "7";
20
+ AiAction["OnStreamEvent"] = "7";
21
21
  AiAction["Generation"] = "8";
22
22
  AiAction["UpdateConversation"] = "9";
23
23
  })(AiAction || (AiAction = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"getCustomUserAgentDetails.mjs","sources":["../../../../../src/runtime/internals/ai/getCustomUserAgentDetails.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Symbol used for internal user agent overrides.\n *\n * @internal\n * This symbol is intended for internal use within the Amplify library.\n * It may change or be removed in future versions without notice.\n * External usage of this symbol is discouraged and may lead to unexpected behavior.\n */\nexport const INTERNAL_USER_AGENT_OVERRIDE = Symbol('INTERNAL_USER_AGENT_OVERRIDE');\nexport var AiAction;\n(function (AiAction) {\n AiAction[\"CreateConversation\"] = \"1\";\n AiAction[\"GetConversation\"] = \"2\";\n AiAction[\"ListConversations\"] = \"3\";\n AiAction[\"DeleteConversation\"] = \"4\";\n AiAction[\"SendMessage\"] = \"5\";\n AiAction[\"ListMessages\"] = \"6\";\n AiAction[\"OnMessage\"] = \"7\";\n AiAction[\"Generation\"] = \"8\";\n AiAction[\"UpdateConversation\"] = \"9\";\n})(AiAction || (AiAction = {}));\nexport const getCustomUserAgentDetails = (action) => ({\n category: 'ai',\n action,\n});\n/**\n * Creates a user agent override object based on custom details.\n *\n * @internal\n * This function is intended for internal use within the Amplify library.\n * It may change or be removed in future versions without notice.\n *\n * @param customUserAgentDetails - Optional custom user agent details\n * @returns An object with INTERNAL_USER_AGENT_OVERRIDE symbol as key and customUserAgentDetails as value, or undefined if no details provided\n */\nexport function createUserAgentOverride(customUserAgentDetails) {\n return customUserAgentDetails\n ? { [INTERNAL_USER_AGENT_OVERRIDE]: customUserAgentDetails }\n : undefined;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,4BAA4B,GAAG,MAAM,CAAC,8BAA8B,EAAE;AACzE,IAAC,SAAS;AACpB,CAAC,UAAU,QAAQ,EAAE;AACrB,IAAI,QAAQ,CAAC,oBAAoB,CAAC,GAAG,GAAG,CAAC;AACzC,IAAI,QAAQ,CAAC,iBAAiB,CAAC,GAAG,GAAG,CAAC;AACtC,IAAI,QAAQ,CAAC,mBAAmB,CAAC,GAAG,GAAG,CAAC;AACxC,IAAI,QAAQ,CAAC,oBAAoB,CAAC,GAAG,GAAG,CAAC;AACzC,IAAI,QAAQ,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC;AAClC,IAAI,QAAQ,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC;AACnC,IAAI,QAAQ,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC;AAChC,IAAI,QAAQ,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC;AACjC,IAAI,QAAQ,CAAC,oBAAoB,CAAC,GAAG,GAAG,CAAC;AACzC,CAAC,EAAE,QAAQ,KAAK,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;AACpB,MAAC,yBAAyB,GAAG,CAAC,MAAM,MAAM;AACtD,IAAI,QAAQ,EAAE,IAAI;AAClB,IAAI,MAAM;AACV,CAAC,EAAE;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,sBAAsB,EAAE;AAChE,IAAI,OAAO,sBAAsB;AACjC,UAAU,EAAE,CAAC,4BAA4B,GAAG,sBAAsB,EAAE;AACpE,UAAU,SAAS,CAAC;AACpB;;;;"}
1
+ {"version":3,"file":"getCustomUserAgentDetails.mjs","sources":["../../../../../src/runtime/internals/ai/getCustomUserAgentDetails.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Symbol used for internal user agent overrides.\n *\n * @internal\n * This symbol is intended for internal use within the Amplify library.\n * It may change or be removed in future versions without notice.\n * External usage of this symbol is discouraged and may lead to unexpected behavior.\n */\nexport const INTERNAL_USER_AGENT_OVERRIDE = Symbol('INTERNAL_USER_AGENT_OVERRIDE');\nexport var AiAction;\n(function (AiAction) {\n AiAction[\"CreateConversation\"] = \"1\";\n AiAction[\"GetConversation\"] = \"2\";\n AiAction[\"ListConversations\"] = \"3\";\n AiAction[\"DeleteConversation\"] = \"4\";\n AiAction[\"SendMessage\"] = \"5\";\n AiAction[\"ListMessages\"] = \"6\";\n AiAction[\"OnStreamEvent\"] = \"7\";\n AiAction[\"Generation\"] = \"8\";\n AiAction[\"UpdateConversation\"] = \"9\";\n})(AiAction || (AiAction = {}));\nexport const getCustomUserAgentDetails = (action) => ({\n category: 'ai',\n action,\n});\n/**\n * Creates a user agent override object based on custom details.\n *\n * @internal\n * This function is intended for internal use within the Amplify library.\n * It may change or be removed in future versions without notice.\n *\n * @param customUserAgentDetails - Optional custom user agent details\n * @returns An object with INTERNAL_USER_AGENT_OVERRIDE symbol as key and customUserAgentDetails as value, or undefined if no details provided\n */\nexport function createUserAgentOverride(customUserAgentDetails) {\n return customUserAgentDetails\n ? { [INTERNAL_USER_AGENT_OVERRIDE]: customUserAgentDetails }\n : undefined;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,4BAA4B,GAAG,MAAM,CAAC,8BAA8B,EAAE;AACzE,IAAC,SAAS;AACpB,CAAC,UAAU,QAAQ,EAAE;AACrB,IAAI,QAAQ,CAAC,oBAAoB,CAAC,GAAG,GAAG,CAAC;AACzC,IAAI,QAAQ,CAAC,iBAAiB,CAAC,GAAG,GAAG,CAAC;AACtC,IAAI,QAAQ,CAAC,mBAAmB,CAAC,GAAG,GAAG,CAAC;AACxC,IAAI,QAAQ,CAAC,oBAAoB,CAAC,GAAG,GAAG,CAAC;AACzC,IAAI,QAAQ,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC;AAClC,IAAI,QAAQ,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC;AACnC,IAAI,QAAQ,CAAC,eAAe,CAAC,GAAG,GAAG,CAAC;AACpC,IAAI,QAAQ,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC;AACjC,IAAI,QAAQ,CAAC,oBAAoB,CAAC,GAAG,GAAG,CAAC;AACzC,CAAC,EAAE,QAAQ,KAAK,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;AACpB,MAAC,yBAAyB,GAAG,CAAC,MAAM,MAAM;AACtD,IAAI,QAAQ,EAAE,IAAI;AAClB,IAAI,MAAM;AACV,CAAC,EAAE;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,sBAAsB,EAAE;AAChE,IAAI,OAAO,sBAAsB;AACjC,UAAU,EAAE,CAAC,4BAA4B,GAAG,sBAAsB,EAAE;AACpE,UAAU,SAAS,CAAC;AACpB;;;;"}