@aws-amplify/data-schema 1.5.1 → 1.6.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/CustomOperation.js +21 -0
- package/dist/cjs/CustomOperation.js.map +1 -1
- package/dist/cjs/Handler.js +20 -1
- package/dist/cjs/Handler.js.map +1 -1
- package/dist/cjs/SchemaProcessor.js +54 -11
- package/dist/cjs/SchemaProcessor.js.map +1 -1
- package/dist/esm/ClientSchema/Core/ClientCustomOperations.d.ts +2 -2
- package/dist/esm/CustomOperation.d.ts +16 -4
- package/dist/esm/CustomOperation.mjs +21 -1
- package/dist/esm/CustomOperation.mjs.map +1 -1
- package/dist/esm/Handler.d.ts +57 -9
- package/dist/esm/Handler.mjs +20 -1
- package/dist/esm/Handler.mjs.map +1 -1
- package/dist/esm/SchemaProcessor.mjs +54 -12
- package/dist/esm/SchemaProcessor.mjs.map +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/ClientSchema/Core/ClientCustomOperations.ts +32 -3
- package/src/CustomOperation.ts +68 -5
- package/src/Handler.ts +92 -21
- package/src/SchemaProcessor.ts +73 -23
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.generation = exports.subscription = exports.mutation = exports.query = exports.CustomOperationNames = void 0;
|
|
5
5
|
const util_1 = require("./util");
|
|
6
6
|
const Authorization_1 = require("./Authorization");
|
|
7
|
+
const Brand_1 = require("./util/Brand");
|
|
7
8
|
const queryBrand = 'queryCustomOperation';
|
|
8
9
|
const mutationBrand = 'mutationCustomOperation';
|
|
9
10
|
const subscriptionBrand = 'subscriptionCustomOperation';
|
|
@@ -45,6 +46,9 @@ function _custom(typeName, brand, input) {
|
|
|
45
46
|
data.handlers = Array.isArray(handlers)
|
|
46
47
|
? handlers
|
|
47
48
|
: [handlers];
|
|
49
|
+
if (lastHandlerIsAsyncFunction(handlers)) {
|
|
50
|
+
data.returnType = eventInvocationResponse;
|
|
51
|
+
}
|
|
48
52
|
return this;
|
|
49
53
|
},
|
|
50
54
|
for(source) {
|
|
@@ -112,6 +116,23 @@ function subscription() {
|
|
|
112
116
|
return _custom('Subscription', subscriptionBrand);
|
|
113
117
|
}
|
|
114
118
|
exports.subscription = subscription;
|
|
119
|
+
const eventInvocationResponse = {
|
|
120
|
+
data: {
|
|
121
|
+
type: 'ref',
|
|
122
|
+
link: 'EventInvocationResponse',
|
|
123
|
+
valueRequired: false,
|
|
124
|
+
array: false,
|
|
125
|
+
arrayRequired: false,
|
|
126
|
+
mutationOperations: [],
|
|
127
|
+
authorization: [],
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
function lastHandlerIsAsyncFunction(handlers) {
|
|
131
|
+
const lastHandlerBrandSymbol = Array.isArray(handlers)
|
|
132
|
+
? handlers[handlers.length - 1][Brand_1.brandSymbol]
|
|
133
|
+
: handlers[Brand_1.brandSymbol];
|
|
134
|
+
return lastHandlerBrandSymbol === 'asyncFunctionHandler';
|
|
135
|
+
}
|
|
115
136
|
/**
|
|
116
137
|
* @experimental
|
|
117
138
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomOperation.js","sources":["../../src/CustomOperation.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generation = exports.subscription = exports.mutation = exports.query = exports.CustomOperationNames = void 0;\nconst util_1 = require(\"./util\");\nconst Authorization_1 = require(\"./Authorization\");\nconst queryBrand = 'queryCustomOperation';\nconst mutationBrand = 'mutationCustomOperation';\nconst subscriptionBrand = 'subscriptionCustomOperation';\nconst generationBrand = 'generationCustomOperation';\nexports.CustomOperationNames = [\n 'Query',\n 'Mutation',\n 'Subscription',\n 'Generation',\n];\nfunction brandedBuilder(builder, brandValue) {\n return { ...builder, ...(0, util_1.brand)(brandValue) };\n}\nfunction _custom(typeName, brand, input) {\n const data = {\n arguments: {},\n returnType: null,\n authorization: [],\n typeName: typeName,\n handlers: null,\n subscriptionSource: [],\n input,\n };\n const builder = brandedBuilder({\n arguments(args) {\n data.arguments = args;\n return this;\n },\n returns(returnType) {\n data.returnType = returnType;\n return this;\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allowForCustomOperations);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n handler(handlers) {\n data.handlers = Array.isArray(handlers)\n ? handlers\n : [handlers];\n return this;\n },\n for(source) {\n data.subscriptionSource = Array.isArray(source) ? source : [source];\n return this;\n },\n }, brand);\n return { ...builder, data };\n}\n/**\n * Use a custom query to define an API request that will retrieve backend data.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @example\n * const schema = a.schema({\n * echo: a\n * .query()\n * .arguments({ content: a.string() })\n * .returns(a.ref('EchoResponse'))\n * .authorization(allow => [allow.publicApiKey()])\n * // 3. set the function has the handler\n * .handler(a.handler.function(echoHandler)),\n *\n * EchoResponse: a.customType({\n * content: a.string(),\n * executionDuration: a.float()\n * }),\n * });\n * @returns a custom query\n */\nfunction query() {\n return _custom('Query', queryBrand);\n}\nexports.query = query;\n/**\n * Use a custom mutation to define an API request that will modify backend data or trigger a subscription event.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @example\n * likePost: a\n * .mutation()\n * .arguments({ postId: a.string() })\n * .returns(a.ref('Post'))\n * .authorization(allow => [allow.publicApiKey()])\n * .handler(a.handler.function(echoHandler))\n * @returns a custom mutation\n */\nfunction mutation() {\n return _custom('Mutation', mutationBrand);\n}\nexports.mutation = mutation;\n/**\n * Define a custom subscription to receive an event when a mutation is triggered\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-subscription/}\n * @example\n * // Subscribe to incoming messages\n * receive: a.subscription()\n * // subscribes to the 'publish' mutation\n * .for(a.ref('publish'))\n * // subscription handler to set custom filters\n * .handler(a.handler.custom({entry: './receive.js'}))\n * // authorization rules as to who can subscribe to the data\n * .authorization(allow => [allow.publicApiKey()]),\n * @returns a custom subscription\n */\nfunction subscription() {\n return _custom('Subscription', subscriptionBrand);\n}\nexports.subscription = subscription;\n/**\n * @experimental\n *\n * Define an AI generation route for single request-response interaction with specified AI model.\n * @example\n * makeRecipe: a.generation({\n * aiModel: { resourcePath },\n * systemPrompt: 'Please make a recipe from the provided ingredients',\n * })\n * .arguments({ ingredients: a.string().array() })\n * .returns(a.ref(\"Recipe\"))\n * @returns a generation route definition\n */\nfunction generation(input) {\n return _custom('Generation', generationBrand, input);\n}\nexports.generation = generation;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC,CAAC;AACrH,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACnD,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAChD,MAAM,iBAAiB,GAAG,6BAA6B,CAAC;AACxD,MAAM,eAAe,GAAG,2BAA2B,CAAC;AACpD,OAAO,CAAC,oBAAoB,GAAG;AAC/B,IAAI,OAAO;AACX,IAAI,UAAU;AACd,IAAI,cAAc;AAClB,IAAI,YAAY;AAChB,CAAC,CAAC;AACF,SAAS,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE;AAC7C,IAAI,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC;AAC5D,CAAC;AACD,SAAS,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE;AACzC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SAAS;AACT,KAAK,EAAE,KAAK,CAAC,CAAC;AACd,IAAI,OAAO,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC;AAChC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,KAAK,GAAG;AACjB,IAAI,OAAO,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AACxC,CAAC;AACD,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,QAAQ,GAAG;AACpB,IAAI,OAAO,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAC9C,CAAC;AACD,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,YAAY,GAAG;AACxB,IAAI,OAAO,OAAO,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;AACtD,CAAC;AACD,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,UAAU,CAAC,KAAK,EAAE;AAC3B,IAAI,OAAO,OAAO,CAAC,YAAY,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC;AACzD,CAAC;AACD,OAAO,CAAC,UAAU,GAAG,UAAU;;"}
|
|
1
|
+
{"version":3,"file":"CustomOperation.js","sources":["../../src/CustomOperation.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generation = exports.subscription = exports.mutation = exports.query = exports.CustomOperationNames = void 0;\nconst util_1 = require(\"./util\");\nconst Authorization_1 = require(\"./Authorization\");\nconst Brand_1 = require(\"./util/Brand\");\nconst queryBrand = 'queryCustomOperation';\nconst mutationBrand = 'mutationCustomOperation';\nconst subscriptionBrand = 'subscriptionCustomOperation';\nconst generationBrand = 'generationCustomOperation';\nexports.CustomOperationNames = [\n 'Query',\n 'Mutation',\n 'Subscription',\n 'Generation',\n];\nfunction brandedBuilder(builder, brandValue) {\n return { ...builder, ...(0, util_1.brand)(brandValue) };\n}\nfunction _custom(typeName, brand, input) {\n const data = {\n arguments: {},\n returnType: null,\n authorization: [],\n typeName: typeName,\n handlers: null,\n subscriptionSource: [],\n input,\n };\n const builder = brandedBuilder({\n arguments(args) {\n data.arguments = args;\n return this;\n },\n returns(returnType) {\n data.returnType = returnType;\n return this;\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allowForCustomOperations);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n handler(handlers) {\n data.handlers = Array.isArray(handlers)\n ? handlers\n : [handlers];\n if (lastHandlerIsAsyncFunction(handlers)) {\n data.returnType = eventInvocationResponse;\n }\n return this;\n },\n for(source) {\n data.subscriptionSource = Array.isArray(source) ? source : [source];\n return this;\n },\n }, brand);\n return { ...builder, data };\n}\n/**\n * Use a custom query to define an API request that will retrieve backend data.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @example\n * const schema = a.schema({\n * echo: a\n * .query()\n * .arguments({ content: a.string() })\n * .returns(a.ref('EchoResponse'))\n * .authorization(allow => [allow.publicApiKey()])\n * // 3. set the function has the handler\n * .handler(a.handler.function(echoHandler)),\n *\n * EchoResponse: a.customType({\n * content: a.string(),\n * executionDuration: a.float()\n * }),\n * });\n * @returns a custom query\n */\nfunction query() {\n return _custom('Query', queryBrand);\n}\nexports.query = query;\n/**\n * Use a custom mutation to define an API request that will modify backend data or trigger a subscription event.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @example\n * likePost: a\n * .mutation()\n * .arguments({ postId: a.string() })\n * .returns(a.ref('Post'))\n * .authorization(allow => [allow.publicApiKey()])\n * .handler(a.handler.function(echoHandler))\n * @returns a custom mutation\n */\nfunction mutation() {\n return _custom('Mutation', mutationBrand);\n}\nexports.mutation = mutation;\n/**\n * Define a custom subscription to receive an event when a mutation is triggered\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-subscription/}\n * @example\n * // Subscribe to incoming messages\n * receive: a.subscription()\n * // subscribes to the 'publish' mutation\n * .for(a.ref('publish'))\n * // subscription handler to set custom filters\n * .handler(a.handler.custom({entry: './receive.js'}))\n * // authorization rules as to who can subscribe to the data\n * .authorization(allow => [allow.publicApiKey()]),\n * @returns a custom subscription\n */\nfunction subscription() {\n return _custom('Subscription', subscriptionBrand);\n}\nexports.subscription = subscription;\nconst eventInvocationResponse = {\n data: {\n type: 'ref',\n link: 'EventInvocationResponse',\n valueRequired: false,\n array: false,\n arrayRequired: false,\n mutationOperations: [],\n authorization: [],\n },\n};\nfunction lastHandlerIsAsyncFunction(handlers) {\n const lastHandlerBrandSymbol = Array.isArray(handlers)\n ? handlers[handlers.length - 1][Brand_1.brandSymbol]\n : handlers[Brand_1.brandSymbol];\n return lastHandlerBrandSymbol === 'asyncFunctionHandler';\n}\n/**\n * @experimental\n *\n * Define an AI generation route for single request-response interaction with specified AI model.\n * @example\n * makeRecipe: a.generation({\n * aiModel: { resourcePath },\n * systemPrompt: 'Please make a recipe from the provided ingredients',\n * })\n * .arguments({ ingredients: a.string().array() })\n * .returns(a.ref(\"Recipe\"))\n * @returns a generation route definition\n */\nfunction generation(input) {\n return _custom('Generation', generationBrand, input);\n}\nexports.generation = generation;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC,CAAC;AACrH,MAAM,M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65
|
}
|
|
66
66
|
const functionHandlerBrand = 'functionHandler';
|
|
67
|
+
const asyncFunctionHandlerBrand = 'asyncFunctionHandler';
|
|
67
68
|
/**
|
|
68
69
|
* Use a function created via `defineFunction` to handle the custom query/mutation/subscription. In your function handler,
|
|
69
70
|
* you can use the `Schema["YOUR_QUERY_OR_MUTATION_NAME"]["functionHandler"]` utility type to type the handler function.
|
|
@@ -100,7 +101,25 @@ const functionHandlerBrand = 'functionHandler';
|
|
|
100
101
|
* @returns A handler for the query / mutation / subscription
|
|
101
102
|
*/
|
|
102
103
|
function fcn(fn) {
|
|
103
|
-
return {
|
|
104
|
+
return {
|
|
105
|
+
[dataSymbol]: {
|
|
106
|
+
handler: fn,
|
|
107
|
+
invocationType: 'RequestResponse',
|
|
108
|
+
},
|
|
109
|
+
async() {
|
|
110
|
+
return _async(this);
|
|
111
|
+
},
|
|
112
|
+
...buildHandler(functionHandlerBrand),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function _async(fnHandler) {
|
|
116
|
+
return {
|
|
117
|
+
[dataSymbol]: {
|
|
118
|
+
handler: fnHandler[dataSymbol].handler,
|
|
119
|
+
invocationType: 'Event',
|
|
120
|
+
},
|
|
121
|
+
...buildHandler(asyncFunctionHandlerBrand),
|
|
122
|
+
};
|
|
104
123
|
}
|
|
105
124
|
//#endregion
|
|
106
125
|
exports.handler = {
|
package/dist/cjs/Handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Handler.js","sources":["../../src/Handler.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.handler = exports.getHandlerData = void 0;\nconst util_1 = require(\"./util\");\nconst dataSymbol = Symbol('Data');\nfunction buildHandler(brandName) {\n return (0, util_1.brand)(brandName);\n}\nfunction getHandlerData(handler) {\n return handler[dataSymbol];\n}\nexports.getHandlerData = getHandlerData;\n//#region handler.inlineSql\nconst inlineSqlBrand = 'inlineSql';\nfunction inlineSql(sql) {\n return { [dataSymbol]: sql, ...buildHandler(inlineSqlBrand) };\n}\n//#endregion\n//#region handler.sqlReference\nconst sqlReferenceBrand = 'sqlReference';\nfunction sqlReference(sqlFilePath) {\n // used to determine caller directory in order to resolve relative path downstream\n const stack = new Error().stack;\n return {\n [dataSymbol]: { stack, entry: sqlFilePath },\n ...buildHandler(sqlReferenceBrand),\n };\n}\nconst customHandlerBrand = 'customHandler';\n/**\n * Use a custom JavaScript resolver to handle a query, mutation, or subscription.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/#step-2---configure-custom-business-logic-handler-code}\n * @param customHandler `{ entry: \"path-to-javascript-resolver-file.js\", dataSource: \"Data Source name added via \"backend.data.add*DataSoruce(...)\"}`\n * @returns A JavaScript resolver attached to the query, mutation, or subscription.\n * @example\n * const schema = a.schema({\n * Post: a.model({\n * content: a.string(),\n * likes: a.integer()\n * .authorization(allow => [allow.authenticated().to(['read'])])\n * }).authorization(allow => [\n * allow.owner(),\n * allow.authenticated().to(['read'])\n * ]),\n *\n * likePost: a\n * .mutation()\n * .arguments({ postId: a.id() })\n * .returns(a.ref('Post'))\n * .authorization(allow => [allow.authenticated()])\n * .handler(a.handler.custom({\n * dataSource: a.ref('Post'),\n * entry: './increment-like.js'\n * }))\n * });\n */\nfunction custom(customHandler) {\n // used to determine caller directory in order to resolve relative path downstream\n const stack = new Error().stack;\n return {\n [dataSymbol]: { ...customHandler, stack },\n ...buildHandler(customHandlerBrand),\n };\n}\nconst functionHandlerBrand = 'functionHandler';\n/**\n * Use a function created via `defineFunction` to handle the custom query/mutation/subscription. In your function handler,\n * you can use the `Schema[\"YOUR_QUERY_OR_MUTATION_NAME\"][\"functionHandler\"]` utility type to type the handler function.\n * @example\n * import {\n * type ClientSchema,\n * a,\n * defineData,\n * defineFunction // 1.Import \"defineFunction\" to create new functions\n * } from '@aws-amplify/backend';\n *\n * // 2. define a function\n * const echoHandler = defineFunction({\n * entry: './echo-handler/handler.ts'\n * })\n *\n * const schema = a.schema({\n * EchoResponse: a.customType({\n * content: a.string(),\n * executionDuration: a.float()\n * }),\n *\n * echo: a\n * .query()\n * .arguments({ content: a.string() })\n * .returns(a.ref('EchoResponse'))\n * .authorization(allow => [allow.publicApiKey()])\n * // 3. set the function has the handler\n * .handler(a.handler.function(echoHandler))\n * });\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @param fn A function created via `defineFunction`. Alternatively, you can pass in a \"string\" of the function name and pass\n * in a corresponding value into the `functionMap` property of defineData.\n * @returns A handler for the query / mutation / subscription\n */\nfunction fcn(fn) {\n return {
|
|
1
|
+
{"version":3,"file":"Handler.js","sources":["../../src/Handler.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.handler = exports.getHandlerData = void 0;\nconst util_1 = require(\"./util\");\nconst dataSymbol = Symbol('Data');\nfunction buildHandler(brandName) {\n return (0, util_1.brand)(brandName);\n}\nfunction getHandlerData(handler) {\n return handler[dataSymbol];\n}\nexports.getHandlerData = getHandlerData;\n//#region handler.inlineSql\nconst inlineSqlBrand = 'inlineSql';\nfunction inlineSql(sql) {\n return { [dataSymbol]: sql, ...buildHandler(inlineSqlBrand) };\n}\n//#endregion\n//#region handler.sqlReference\nconst sqlReferenceBrand = 'sqlReference';\nfunction sqlReference(sqlFilePath) {\n // used to determine caller directory in order to resolve relative path downstream\n const stack = new Error().stack;\n return {\n [dataSymbol]: { stack, entry: sqlFilePath },\n ...buildHandler(sqlReferenceBrand),\n };\n}\nconst customHandlerBrand = 'customHandler';\n/**\n * Use a custom JavaScript resolver to handle a query, mutation, or subscription.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/#step-2---configure-custom-business-logic-handler-code}\n * @param customHandler `{ entry: \"path-to-javascript-resolver-file.js\", dataSource: \"Data Source name added via \"backend.data.add*DataSoruce(...)\"}`\n * @returns A JavaScript resolver attached to the query, mutation, or subscription.\n * @example\n * const schema = a.schema({\n * Post: a.model({\n * content: a.string(),\n * likes: a.integer()\n * .authorization(allow => [allow.authenticated().to(['read'])])\n * }).authorization(allow => [\n * allow.owner(),\n * allow.authenticated().to(['read'])\n * ]),\n *\n * likePost: a\n * .mutation()\n * .arguments({ postId: a.id() })\n * .returns(a.ref('Post'))\n * .authorization(allow => [allow.authenticated()])\n * .handler(a.handler.custom({\n * dataSource: a.ref('Post'),\n * entry: './increment-like.js'\n * }))\n * });\n */\nfunction custom(customHandler) {\n // used to determine caller directory in order to resolve relative path downstream\n const stack = new Error().stack;\n return {\n [dataSymbol]: { ...customHandler, stack },\n ...buildHandler(customHandlerBrand),\n };\n}\nconst functionHandlerBrand = 'functionHandler';\nconst asyncFunctionHandlerBrand = 'asyncFunctionHandler';\n/**\n * Use a function created via `defineFunction` to handle the custom query/mutation/subscription. In your function handler,\n * you can use the `Schema[\"YOUR_QUERY_OR_MUTATION_NAME\"][\"functionHandler\"]` utility type to type the handler function.\n * @example\n * import {\n * type ClientSchema,\n * a,\n * defineData,\n * defineFunction // 1.Import \"defineFunction\" to create new functions\n * } from '@aws-amplify/backend';\n *\n * // 2. define a function\n * const echoHandler = defineFunction({\n * entry: './echo-handler/handler.ts'\n * })\n *\n * const schema = a.schema({\n * EchoResponse: a.customType({\n * content: a.string(),\n * executionDuration: a.float()\n * }),\n *\n * echo: a\n * .query()\n * .arguments({ content: a.string() })\n * .returns(a.ref('EchoResponse'))\n * .authorization(allow => [allow.publicApiKey()])\n * // 3. set the function has the handler\n * .handler(a.handler.function(echoHandler))\n * });\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @param fn A function created via `defineFunction`. Alternatively, you can pass in a \"string\" of the function name and pass\n * in a corresponding value into the `functionMap` property of defineData.\n * @returns A handler for the query / mutation / subscription\n */\nfunction fcn(fn) {\n return {\n [dataSymbol]: {\n handler: fn,\n invocationType: 'RequestResponse',\n },\n async() {\n return _async(this);\n },\n ...buildHandler(functionHandlerBrand),\n };\n}\nfunction _async(fnHandler) {\n return {\n [dataSymbol]: {\n handler: fnHandler[dataSymbol].handler,\n invocationType: 'Event',\n },\n ...buildHandler(asyncFunctionHandlerBrand),\n };\n}\n//#endregion\nexports.handler = {\n inlineSql,\n sqlReference,\n custom,\n function: fcn,\n};\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAClD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAClC,SAAS,YAAY,CAAC,SAAS,EAAE;AACjC,IAAI,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACxC,CAAC;AACD,SAAS,cAAc,CAAC,OAAO,EAAE;AACjC,IAAI,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC;AACxC;AACA,MAAM,cAAc,GAAG,WAAW,CAAC;AACnC,SAAS,SAAS,CAAC,GAAG,EAAE;AACxB,IAAI,OAAO,EAAE,CAAC,UAAU,GAAG,GAAG,EAAE,GAAG,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;AAClE,CAAC;AACD;AACA;AACA,MAAM,iBAAiB,GAAG,cAAc,CAAC;AACzC,SAAS,YAAY,CAAC,WAAW,EAAE;AACnC;AACA,IAAI,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC;AACpC,IAAI,OAAO;AACX,QAAQ,CAAC,UAAU,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE;AACnD,QAAQ,GAAG,YAAY,CAAC,iBAAiB,CAAC;AAC1C,KAAK,CAAC;AACN,CAAC;AACD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;AAClD,KAAK,CAAC;AACN,CAAC;AACD;AACA,OAAO,CAAC,OAAO,GAAG;AAClB,IAAI,SAAS;AACb,IAAI,YAAY;AAChB,IAAI,MAAM;AACV,IAAI,QAAQ,EAAE,GAAG;AACjB,CAAC;;"}
|
|
@@ -11,6 +11,7 @@ const util_1 = require("./util");
|
|
|
11
11
|
const Handler_1 = require("./Handler");
|
|
12
12
|
const os = tslib_1.__importStar(require("os"));
|
|
13
13
|
const path = tslib_1.__importStar(require("path"));
|
|
14
|
+
const Brand_1 = require("./util/Brand");
|
|
14
15
|
const ConversationType_1 = require("./ai/ConversationType");
|
|
15
16
|
const ConversationSchemaTypes_1 = require("./ai/ConversationSchemaTypes");
|
|
16
17
|
function isInternalModel(model) {
|
|
@@ -153,19 +154,23 @@ function transformFunctionHandler(handlers, functionFieldName) {
|
|
|
153
154
|
const lambdaFunctionDefinition = {};
|
|
154
155
|
handlers.forEach((handler, idx) => {
|
|
155
156
|
const handlerData = (0, Handler_1.getHandlerData)(handler);
|
|
156
|
-
if (typeof handlerData === 'string') {
|
|
157
|
-
gqlHandlerContent += `@function(name: "${handlerData}") `;
|
|
157
|
+
if (typeof handlerData.handler === 'string') {
|
|
158
|
+
gqlHandlerContent += `@function(name: "${handlerData.handler}") `;
|
|
158
159
|
}
|
|
159
|
-
else if (typeof handlerData.getInstance === 'function') {
|
|
160
|
+
else if (typeof handlerData.handler.getInstance === 'function') {
|
|
160
161
|
const fnName = `Fn${capitalize(functionFieldName)}${idx === 0 ? '' : `${idx + 1}`}`;
|
|
161
|
-
lambdaFunctionDefinition[fnName] = handlerData;
|
|
162
|
-
|
|
162
|
+
lambdaFunctionDefinition[fnName] = handlerData.handler;
|
|
163
|
+
const invocationTypeArg = handlerData.invocationType === 'Event' ? ', invocationType: Event)' : ')';
|
|
164
|
+
gqlHandlerContent += `@function(name: "${fnName}"${invocationTypeArg} `;
|
|
163
165
|
}
|
|
164
166
|
else {
|
|
165
167
|
throw new Error(`Invalid value specified for ${functionFieldName} handler.function(). Expected: defineFunction or string.`);
|
|
166
168
|
}
|
|
167
169
|
});
|
|
168
|
-
return {
|
|
170
|
+
return {
|
|
171
|
+
gqlHandlerContent,
|
|
172
|
+
lambdaFunctionDefinition,
|
|
173
|
+
};
|
|
169
174
|
}
|
|
170
175
|
function customOperationToGql(typeName, typeDef, authorization, isCustom = false, databaseType, getRefType) {
|
|
171
176
|
const { arguments: fieldArgs, typeName: opType, returnType, handlers, subscriptionSource, } = typeDef.data;
|
|
@@ -818,6 +823,18 @@ const schemaPreprocessor = (schema) => {
|
|
|
818
823
|
? 'dynamodb'
|
|
819
824
|
: 'sql';
|
|
820
825
|
const staticSchema = databaseType === 'sql';
|
|
826
|
+
// If the schema contains a custom operation with an async lambda handler,
|
|
827
|
+
// we need to add the EventInvocationResponse custom type to the schema.
|
|
828
|
+
// This is done here so that:
|
|
829
|
+
// - it only happens once per schema
|
|
830
|
+
// - downstream validation based on `getRefTypeForSchema` finds the EventInvocationResponse type
|
|
831
|
+
const containsAsyncLambdaCustomOperation = Object.entries(schema.data.types).find(([_, typeDef]) => {
|
|
832
|
+
return isCustomOperation(typeDef)
|
|
833
|
+
&& finalHandlerIsAsyncFunctionHandler(typeDef.data.handlers);
|
|
834
|
+
});
|
|
835
|
+
if (containsAsyncLambdaCustomOperation) {
|
|
836
|
+
schema.data.types['EventInvocationResponse'] = eventInvocationResponseCustomType;
|
|
837
|
+
}
|
|
821
838
|
const topLevelTypes = sortTopLevelTypes(Object.entries(schema.data.types));
|
|
822
839
|
const { schemaAuth, functionSchemaAccess } = extractFunctionSchemaAccess(schema.data.authorization);
|
|
823
840
|
const getRefType = getRefTypeForSchema(schema);
|
|
@@ -980,14 +997,22 @@ function validateCustomOperations(typeDef, typeName, authRules, getRefType) {
|
|
|
980
997
|
configuredHandlers.add((0, util_1.getBrand)(handler));
|
|
981
998
|
}
|
|
982
999
|
if (configuredHandlers.size > 1) {
|
|
983
|
-
|
|
984
|
-
|
|
1000
|
+
configuredHandlers.delete('asyncFunctionHandler');
|
|
1001
|
+
configuredHandlers.delete('functionHandler');
|
|
1002
|
+
if (configuredHandlers.size > 0) {
|
|
1003
|
+
const configuredHandlersStr = JSON.stringify(Array.from(configuredHandlers));
|
|
1004
|
+
throw new Error(`Field handlers must be of the same type. ${typeName} has been configured with ${configuredHandlersStr}`);
|
|
1005
|
+
}
|
|
985
1006
|
}
|
|
986
1007
|
}
|
|
987
1008
|
if (typeDef.data.returnType === null &&
|
|
988
1009
|
(opType === 'Query' || opType === 'Mutation' || opType === 'Generation')) {
|
|
989
|
-
|
|
990
|
-
|
|
1010
|
+
// TODO: There should be a more elegant and readable way to handle this check.
|
|
1011
|
+
// Maybe it's not even necessary anymore since we're the setting returnType in the handler() method.
|
|
1012
|
+
if (!handlers || handlers.length === 0 || handlers[handlers.length - 1][Brand_1.brandSymbol] !== 'asyncFunctionHandler') {
|
|
1013
|
+
const typeDescription = opType === 'Generation' ? 'Generation Route' : `Custom ${opType}`;
|
|
1014
|
+
throw new Error(`Invalid ${typeDescription} definition. A ${typeDescription} must include a return type. ${typeName} has no return type specified.`);
|
|
1015
|
+
}
|
|
991
1016
|
}
|
|
992
1017
|
if (opType !== 'Subscription' && subscriptionSource.length > 0) {
|
|
993
1018
|
throw new Error(`The .for() modifier function can only be used with a custom subscription. ${typeName} is not a custom subscription.`);
|
|
@@ -1042,7 +1067,10 @@ const isCustomHandler = (handler) => {
|
|
|
1042
1067
|
return Array.isArray(handler) && (0, util_1.getBrand)(handler[0]) === 'customHandler';
|
|
1043
1068
|
};
|
|
1044
1069
|
const isFunctionHandler = (handler) => {
|
|
1045
|
-
return Array.isArray(handler) && (0, util_1.getBrand)(handler[0])
|
|
1070
|
+
return Array.isArray(handler) && ['functionHandler', 'asyncFunctionHandler'].includes((0, util_1.getBrand)(handler[0]));
|
|
1071
|
+
};
|
|
1072
|
+
const finalHandlerIsAsyncFunctionHandler = (handler) => {
|
|
1073
|
+
return Array.isArray(handler) && (0, util_1.getBrand)(handler[handler.length - 1]) === 'asyncFunctionHandler';
|
|
1046
1074
|
};
|
|
1047
1075
|
const normalizeDataSourceName = (dataSource) => {
|
|
1048
1076
|
// default data source
|
|
@@ -1096,6 +1124,21 @@ const handleCustom = (handlers, opType, typeName) => {
|
|
|
1096
1124
|
};
|
|
1097
1125
|
return jsFn;
|
|
1098
1126
|
};
|
|
1127
|
+
const eventInvocationResponseCustomType = {
|
|
1128
|
+
data: {
|
|
1129
|
+
fields: {
|
|
1130
|
+
success: {
|
|
1131
|
+
data: {
|
|
1132
|
+
fieldType: ModelField_1.ModelFieldType.Boolean,
|
|
1133
|
+
required: true,
|
|
1134
|
+
array: false,
|
|
1135
|
+
arrayRequired: false,
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
},
|
|
1139
|
+
type: 'customType'
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1099
1142
|
function transformCustomOperations(typeDef, typeName, authRules, databaseType, getRefType) {
|
|
1100
1143
|
const { typeName: opType, handlers } = typeDef.data;
|
|
1101
1144
|
let jsFunctionForField = undefined;
|