@aws-amplify/data-schema 1.26.0 → 1.26.1

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.
@@ -128,8 +128,12 @@ function isInputType(type) {
128
128
  return type instanceof Object && 'input' in type;
129
129
  }
130
130
  /**
131
+ * For a list argument this is the *element* type, so `isRequired` — which is
132
+ * element-level for lists — is the correct source for the `!`. The list's own
133
+ * nullability is applied by the caller. See {@link isArgumentRequired}.
134
+ *
131
135
  * @param argDef A single argument definition from a custom operation
132
- * @returns A string naming the base type including the `!` if the arg is required.
136
+ * @returns A string naming the base type including the `!` if that type is non-null.
133
137
  */
134
138
  function argumentBaseTypeString({ type, isRequired }) {
135
139
  const requiredFlag = isRequired ? '!' : '';
@@ -141,6 +145,30 @@ function argumentBaseTypeString({ type, isRequired }) {
141
145
  }
142
146
  return `${type}${requiredFlag}`;
143
147
  }
148
+ /**
149
+ * Determines whether a value must be provided for a custom operation argument,
150
+ * i.e. whether the argument itself is non-null in the GraphQL schema.
151
+ *
152
+ * For list arguments, the model introspection schema encodes *element* nullability
153
+ * in `isRequired` and *list* nullability in `isArrayNullable`. For example, an
154
+ * argument declared as `a.ref('Color').required().array()` is emitted as `[Color!]`
155
+ * and introspected as `{ isArray: true, isRequired: true, isArrayNullable: true }`
156
+ * — a nullable list of non-null elements, so the argument itself is optional. Only
157
+ * the outermost nullability determines whether the caller has to supply a value.
158
+ *
159
+ * `isArrayNullable` is optional in the introspection schema. The generator we
160
+ * build against always emits it for list arguments (`getTypeInfo()` sets
161
+ * `isListNullable` on every list branch), but when it is absent we treat the list
162
+ * as non-null to stay consistent with the `[T]!` that `outerArguments()` renders
163
+ * for the same input — a request declaring a non-null variable with no value
164
+ * would be rejected by the server anyway.
165
+ *
166
+ * @param argDef A single argument definition from a custom operation
167
+ * @returns Boolean: `true` if the argument itself is non-null
168
+ */
169
+ function isArgumentRequired({ isArray, isRequired, isArrayNullable, }) {
170
+ return isArray ? !isArrayNullable : isRequired;
171
+ }
144
172
  /**
145
173
  * Generates "outer" arguments string for a custom operation. For example,
146
174
  * in this operation:
@@ -168,7 +196,7 @@ function outerArguments(operation) {
168
196
  .map(([k, argument]) => {
169
197
  const baseType = argumentBaseTypeString(argument);
170
198
  const finalType = argument.isArray
171
- ? `[${baseType}]${argument.isArrayNullable ? '' : '!'}`
199
+ ? `[${baseType}]${isArgumentRequired(argument) ? '!' : ''}`
172
200
  : baseType;
173
201
  return `$${k}: ${finalType}`;
174
202
  })
@@ -259,7 +287,7 @@ function operationVariables(operation, args = {}) {
259
287
  if (typeof args[argDef.name] !== 'undefined') {
260
288
  variables[argDef.name] = args[argDef.name];
261
289
  }
262
- else if (argDef.isRequired) {
290
+ else if (isArgumentRequired(argDef)) {
263
291
  // At this point, the variable is both required and missing: We don't need
264
292
  // to continue. The operation is expected to fail.
265
293
  throw new Error(`${operation.name} requires arguments '${argDef.name}'`);
@@ -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 = customOpFactory;\nconst rxjs_1 = require(\"rxjs\");\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nconst utils_2 = require(\"../../utils\");\nconst cancellation_1 = require(\"../cancellation\");\nconst getCustomUserAgentDetails_1 = require(\"../ai/getCustomUserAgentDetails\");\n/**\n * Type guard for checking whether a Custom Operation argument is a contextSpec object\n */\nconst argIsContextSpec = (arg) => {\n return typeof arg?.token?.value === 'symbol';\n};\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nfunction customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals, customUserAgentDetails) {\n // .arguments() are defined for the custom operation in the schema builder\n // and are present in the model introspection schema\n const argsDefined = operation.arguments !== undefined;\n const op = (...args) => {\n // options is always the last argument\n const options = args[args.length - 1];\n let contextSpec;\n let arg;\n if (useContext) {\n if (argIsContextSpec(args[0])) {\n contextSpec = args[0];\n }\n else {\n throw new Error(`Invalid first argument passed to ${operation.name}. Expected contextSpec`);\n }\n }\n if (argsDefined) {\n if (useContext) {\n arg = args[1];\n }\n else {\n arg = args[0];\n }\n }\n if (operationType === 'subscription') {\n return _opSubscription(\n // subscriptions are only enabled on the clientside\n client, modelIntrospection, operation, getInternals, arg, options, customUserAgentDetails);\n }\n return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec, customUserAgentDetails);\n };\n return op;\n}\n/**\n * Runtime test and type guard to check whether `o[field]` is a `String`.\n *\n * ```typescript\n * if (hasStringField(o, 'prop')) {\n * const s = o.prop;\n * // ^? const s: string\n * }\n * ```\n *\n * @param o Object to inspect\n * @param field Field to look for\n * @returns Boolean: `true` if the `o[field]` is a `string`\n */\nfunction hasStringField(o, field) {\n return typeof o[field] === 'string';\n}\nfunction isEnumType(type) {\n return type instanceof Object && 'enum' in type;\n}\nfunction isInputType(type) {\n return type instanceof Object && 'input' in type;\n}\n/**\n * @param argDef A single argument definition from a custom operation\n * @returns A string naming the base type including the `!` if the arg is required.\n */\nfunction argumentBaseTypeString({ type, isRequired }) {\n const requiredFlag = isRequired ? '!' : '';\n if (isEnumType(type)) {\n return `${type.enum}${requiredFlag}`;\n }\n if (isInputType(type)) {\n return `${type.input}${requiredFlag}`;\n }\n return `${type}${requiredFlag}`;\n}\n/**\n * Generates \"outer\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the top/outer level arguments as a string:\n *\n * ```json\n * \"InputString: String!\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction outerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.entries(operation.arguments)\n .map(([k, argument]) => {\n const baseType = argumentBaseTypeString(argument);\n const finalType = argument.isArray\n ? `[${baseType}]${argument.isArrayNullable ? '' : '!'}`\n : baseType;\n return `$${k}: ${finalType}`;\n })\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates \"inner\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the inner arguments as a string:\n *\n * ```json\n * \"InputString: $InputString\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction innerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.keys(operation.arguments)\n .map((k) => `${k}: $${k}`)\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates the selection set string for a custom operation. This is slightly\n * different than the selection set generation for models. If the custom op returns\n * a primitive or enum types, it doesn't require a selection set at all.\n *\n * E.g., the graphql might look like this:\n *\n * ```graphql\n * query MyQuery {\n * echoString(inputString: \"whatever\")\n * }\n * # ^\n * # |\n * # +-- no selection set\n * ```\n *\n * Non-primitive return type selection set generation will be similar to other\n * model operations.\n *\n * @param modelIntrospection The full code-generated introspection schema.\n * @param operation The operation object from the schema.\n * @returns The selection set as a string.\n */\nfunction operationSelectionSet(modelIntrospection, operation) {\n if (hasStringField(operation, 'type') ||\n hasStringField(operation.type, 'enum')) {\n return '';\n }\n else if (hasStringField(operation.type, 'nonModel')) {\n const nonModel = modelIntrospection.nonModels[operation.type.nonModel];\n return `{${(0, APIClient_1.selectionSetIRToString)((0, APIClient_1.getDefaultSelectionSetForNonModelWithIR)(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${(0, APIClient_1.generateSelectionSet)(modelIntrospection, operation.type.model)}}`;\n }\n else {\n return '';\n }\n}\n/**\n * Maps an arguments objec to graphql variables, removing superfluous args and\n * screaming loudly when required args are missing.\n *\n * @param operation The operation to construct graphql request variables for.\n * @param args The arguments to map variables from.\n * @returns The graphql variables object.\n */\nfunction operationVariables(operation, args = {}) {\n const variables = {};\n if (operation.arguments === undefined) {\n return variables;\n }\n for (const argDef of Object.values(operation.arguments)) {\n if (typeof args[argDef.name] !== 'undefined') {\n variables[argDef.name] = args[argDef.name];\n }\n else if (argDef.isRequired) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context, customUserAgentDetails) {\n return (0, utils_2.selfAwareAsync)(async (resultPromise) => {\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);\n try {\n const basePromise = context\n ? client.graphql(context, {\n ...auth,\n query,\n variables,\n }, headers)\n : client.graphql({\n ...auth,\n query,\n variables,\n ...userAgentOverride,\n }, headers);\n const extendedPromise = (0, cancellation_1.extendCancellability)(basePromise, resultPromise);\n const { data, extensions } = await extendedPromise;\n // flatten response\n if (data) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n extensions,\n };\n }\n else {\n return { data: null, extensions };\n }\n }\n catch (error) {\n /**\n * The `data` type returned by `error` here could be:\n * 1) `null`\n * 2) an empty object\n * 3) \"populated\" but with a `null` value `{ getPost: null }`\n * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`\n */\n const { data, errors } = error;\n /**\n * `data` is not `null`, and is not an empty object:\n */\n if (data && Object.keys(data).length !== 0 && errors) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n /**\n * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)\n * if `flattenedResult`, result is an actual record:\n */\n if (flattenedResult) {\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n errors,\n };\n }\n else {\n // was `data: { getPost: null }`)\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n else {\n // `data` is `null`:\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n });\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _opSubscription(client, modelIntrospection, operation, getInternals, args, options, customUserAgentDetails) {\n const operationType = 'subscription';\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n ...userAgentOverride,\n }, headers);\n return observable.pipe((0, rxjs_1.map)((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,eAAe,GAAG,eAAe;AACzC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AAC9B,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;AAClC,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;AACtC,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC;AACjD,MAAM,2BAA2B,GAAG,OAAO,CAAC,iCAAiC,CAAC;AAC9E;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK;AAClC,IAAI,OAAO,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,QAAQ;AAChD,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,S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js","sources":["../../../../../src/runtime/internals/operations/custom.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.customOpFactory = customOpFactory;\nconst rxjs_1 = require(\"rxjs\");\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nconst utils_2 = require(\"../../utils\");\nconst cancellation_1 = require(\"../cancellation\");\nconst getCustomUserAgentDetails_1 = require(\"../ai/getCustomUserAgentDetails\");\n/**\n * Type guard for checking whether a Custom Operation argument is a contextSpec object\n */\nconst argIsContextSpec = (arg) => {\n return typeof arg?.token?.value === 'symbol';\n};\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nfunction customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals, customUserAgentDetails) {\n // .arguments() are defined for the custom operation in the schema builder\n // and are present in the model introspection schema\n const argsDefined = operation.arguments !== undefined;\n const op = (...args) => {\n // options is always the last argument\n const options = args[args.length - 1];\n let contextSpec;\n let arg;\n if (useContext) {\n if (argIsContextSpec(args[0])) {\n contextSpec = args[0];\n }\n else {\n throw new Error(`Invalid first argument passed to ${operation.name}. Expected contextSpec`);\n }\n }\n if (argsDefined) {\n if (useContext) {\n arg = args[1];\n }\n else {\n arg = args[0];\n }\n }\n if (operationType === 'subscription') {\n return _opSubscription(\n // subscriptions are only enabled on the clientside\n client, modelIntrospection, operation, getInternals, arg, options, customUserAgentDetails);\n }\n return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec, customUserAgentDetails);\n };\n return op;\n}\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 * For a list argument this is the *element* type, so `isRequired` — which is\n * element-level for lists — is the correct source for the `!`. The list's own\n * nullability is applied by the caller. See {@link isArgumentRequired}.\n *\n * @param argDef A single argument definition from a custom operation\n * @returns A string naming the base type including the `!` if that type is non-null.\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 * Determines whether a value must be provided for a custom operation argument,\n * i.e. whether the argument itself is non-null in the GraphQL schema.\n *\n * For list arguments, the model introspection schema encodes *element* nullability\n * in `isRequired` and *list* nullability in `isArrayNullable`. For example, an\n * argument declared as `a.ref('Color').required().array()` is emitted as `[Color!]`\n * and introspected as `{ isArray: true, isRequired: true, isArrayNullable: true }`\n * — a nullable list of non-null elements, so the argument itself is optional. Only\n * the outermost nullability determines whether the caller has to supply a value.\n *\n * `isArrayNullable` is optional in the introspection schema. The generator we\n * build against always emits it for list arguments (`getTypeInfo()` sets\n * `isListNullable` on every list branch), but when it is absent we treat the list\n * as non-null to stay consistent with the `[T]!` that `outerArguments()` renders\n * for the same input — a request declaring a non-null variable with no value\n * would be rejected by the server anyway.\n *\n * @param argDef A single argument definition from a custom operation\n * @returns Boolean: `true` if the argument itself is non-null\n */\nfunction isArgumentRequired({ isArray, isRequired, isArrayNullable, }) {\n return isArray ? !isArrayNullable : isRequired;\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}]${isArgumentRequired(argument) ? '!' : ''}`\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 (isArgumentRequired(argDef)) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context, customUserAgentDetails) {\n return (0, utils_2.selfAwareAsync)(async (resultPromise) => {\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);\n try {\n const basePromise = context\n ? client.graphql(context, {\n ...auth,\n query,\n variables,\n }, headers)\n : client.graphql({\n ...auth,\n query,\n variables,\n ...userAgentOverride,\n }, headers);\n const extendedPromise = (0, cancellation_1.extendCancellability)(basePromise, resultPromise);\n const { data, extensions } = await extendedPromise;\n // flatten response\n if (data) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n extensions,\n };\n }\n else {\n return { data: null, extensions };\n }\n }\n catch (error) {\n /**\n * The `data` type returned by `error` here could be:\n * 1) `null`\n * 2) an empty object\n * 3) \"populated\" but with a `null` value `{ getPost: null }`\n * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`\n */\n const { data, errors } = error;\n /**\n * `data` is not `null`, and is not an empty object:\n */\n if (data && Object.keys(data).length !== 0 && errors) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n /**\n * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)\n * if `flattenedResult`, result is an actual record:\n */\n if (flattenedResult) {\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n errors,\n };\n }\n else {\n // was `data: { getPost: null }`)\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n else {\n // `data` is `null`:\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n });\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _opSubscription(client, modelIntrospection, operation, getInternals, args, options, customUserAgentDetails) {\n const operationType = 'subscription';\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const userAgentOverride = (0, getCustomUserAgentDetails_1.createUserAgentOverride)(customUserAgentDetails);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n ...userAgentOverride,\n }, headers);\n return observable.pipe((0, rxjs_1.map)((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,eAAe,GAAG,eAAe;AACzC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AAC9B,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;AAClC,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;AACtC,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC;AACjD,MAAM,2BAA2B,GAAG,OAAO,CAAC,iCAAiC,CAAC;AAC9E;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK;AAClC,IAAI,OAAO,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,QAAQ;AAChD,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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7C,QAAQ,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;AACpC,QAAQ,MAAM,CAAC,WAAW,CAAC,GAAG;AAC9B,cAAc,IAAI,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS;AACrI,cAAc,CAAC,IAAI,CAAC;AACpB,QAAQ,OAAO,WAAW;AAC1B,IAAI,CAAC,CAAC,CAAC;AACP;;"}
@@ -125,8 +125,12 @@ function isInputType(type) {
125
125
  return type instanceof Object && 'input' in type;
126
126
  }
127
127
  /**
128
+ * For a list argument this is the *element* type, so `isRequired` — which is
129
+ * element-level for lists — is the correct source for the `!`. The list's own
130
+ * nullability is applied by the caller. See {@link isArgumentRequired}.
131
+ *
128
132
  * @param argDef A single argument definition from a custom operation
129
- * @returns A string naming the base type including the `!` if the arg is required.
133
+ * @returns A string naming the base type including the `!` if that type is non-null.
130
134
  */
131
135
  function argumentBaseTypeString({ type, isRequired }) {
132
136
  const requiredFlag = isRequired ? '!' : '';
@@ -138,6 +142,30 @@ function argumentBaseTypeString({ type, isRequired }) {
138
142
  }
139
143
  return `${type}${requiredFlag}`;
140
144
  }
145
+ /**
146
+ * Determines whether a value must be provided for a custom operation argument,
147
+ * i.e. whether the argument itself is non-null in the GraphQL schema.
148
+ *
149
+ * For list arguments, the model introspection schema encodes *element* nullability
150
+ * in `isRequired` and *list* nullability in `isArrayNullable`. For example, an
151
+ * argument declared as `a.ref('Color').required().array()` is emitted as `[Color!]`
152
+ * and introspected as `{ isArray: true, isRequired: true, isArrayNullable: true }`
153
+ * — a nullable list of non-null elements, so the argument itself is optional. Only
154
+ * the outermost nullability determines whether the caller has to supply a value.
155
+ *
156
+ * `isArrayNullable` is optional in the introspection schema. The generator we
157
+ * build against always emits it for list arguments (`getTypeInfo()` sets
158
+ * `isListNullable` on every list branch), but when it is absent we treat the list
159
+ * as non-null to stay consistent with the `[T]!` that `outerArguments()` renders
160
+ * for the same input — a request declaring a non-null variable with no value
161
+ * would be rejected by the server anyway.
162
+ *
163
+ * @param argDef A single argument definition from a custom operation
164
+ * @returns Boolean: `true` if the argument itself is non-null
165
+ */
166
+ function isArgumentRequired({ isArray, isRequired, isArrayNullable, }) {
167
+ return isArray ? !isArrayNullable : isRequired;
168
+ }
141
169
  /**
142
170
  * Generates "outer" arguments string for a custom operation. For example,
143
171
  * in this operation:
@@ -165,7 +193,7 @@ function outerArguments(operation) {
165
193
  .map(([k, argument]) => {
166
194
  const baseType = argumentBaseTypeString(argument);
167
195
  const finalType = argument.isArray
168
- ? `[${baseType}]${argument.isArrayNullable ? '' : '!'}`
196
+ ? `[${baseType}]${isArgumentRequired(argument) ? '!' : ''}`
169
197
  : baseType;
170
198
  return `$${k}: ${finalType}`;
171
199
  })
@@ -256,7 +284,7 @@ function operationVariables(operation, args = {}) {
256
284
  if (typeof args[argDef.name] !== 'undefined') {
257
285
  variables[argDef.name] = args[argDef.name];
258
286
  }
259
- else if (argDef.isRequired) {
287
+ else if (isArgumentRequired(argDef)) {
260
288
  // At this point, the variable is both required and missing: We don't need
261
289
  // to continue. The operation is expected to fail.
262
290
  throw new Error(`${operation.name} requires arguments '${argDef.name}'`);
@@ -1 +1 @@
1
- {"version":3,"file":"custom.mjs","sources":["../../../../../src/runtime/internals/operations/custom.ts"],"sourcesContent":["import { map } from 'rxjs';\nimport { authModeParams, getDefaultSelectionSetForNonModelWithIR, generateSelectionSet, getCustomHeaders, initializeModel, selectionSetIRToString, } from '../APIClient';\nimport { handleSingularGraphQlError } from './utils';\nimport { selfAwareAsync } from '../../utils';\nimport { extendCancellability } from '../cancellation';\nimport { createUserAgentOverride } from '../ai/getCustomUserAgentDetails';\n/**\n * Type guard for checking whether a Custom Operation argument is a contextSpec object\n */\nconst argIsContextSpec = (arg) => {\n return typeof arg?.token?.value === 'symbol';\n};\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nexport function customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals, customUserAgentDetails) {\n // .arguments() are defined for the custom operation in the schema builder\n // and are present in the model introspection schema\n const argsDefined = operation.arguments !== undefined;\n const op = (...args) => {\n // options is always the last argument\n const options = args[args.length - 1];\n let contextSpec;\n let arg;\n if (useContext) {\n if (argIsContextSpec(args[0])) {\n contextSpec = args[0];\n }\n else {\n throw new Error(`Invalid first argument passed to ${operation.name}. Expected contextSpec`);\n }\n }\n if (argsDefined) {\n if (useContext) {\n arg = args[1];\n }\n else {\n arg = args[0];\n }\n }\n if (operationType === 'subscription') {\n return _opSubscription(\n // subscriptions are only enabled on the clientside\n client, modelIntrospection, operation, getInternals, arg, options, customUserAgentDetails);\n }\n return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec, customUserAgentDetails);\n };\n return op;\n}\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 `{${selectionSetIRToString(getDefaultSelectionSetForNonModelWithIR(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${generateSelectionSet(modelIntrospection, operation.type.model)}}`;\n }\n else {\n return '';\n }\n}\n/**\n * Maps an arguments objec to graphql variables, removing superfluous args and\n * screaming loudly when required args are missing.\n *\n * @param operation The operation to construct graphql request variables for.\n * @param args The arguments to map variables from.\n * @returns The graphql variables object.\n */\nfunction operationVariables(operation, args = {}) {\n const variables = {};\n if (operation.arguments === undefined) {\n return variables;\n }\n for (const argDef of Object.values(operation.arguments)) {\n if (typeof args[argDef.name] !== 'undefined') {\n variables[argDef.name] = args[argDef.name];\n }\n else if (argDef.isRequired) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context, customUserAgentDetails) {\n return selfAwareAsync(async (resultPromise) => {\n const { name: operationName } = operation;\n const auth = authModeParams(client, getInternals, options);\n const headers = getCustomHeaders(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const userAgentOverride = createUserAgentOverride(customUserAgentDetails);\n try {\n const basePromise = context\n ? client.graphql(context, {\n ...auth,\n query,\n variables,\n }, headers)\n : client.graphql({\n ...auth,\n query,\n variables,\n ...userAgentOverride,\n }, headers);\n const extendedPromise = 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 ? 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 ? 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 handleSingularGraphQlError(error);\n }\n }\n else {\n // `data` is `null`:\n return handleSingularGraphQlError(error);\n }\n }\n });\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _opSubscription(client, modelIntrospection, operation, getInternals, args, options, customUserAgentDetails) {\n const operationType = 'subscription';\n const { name: operationName } = operation;\n const auth = authModeParams(client, getInternals, options);\n const headers = getCustomHeaders(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const userAgentOverride = createUserAgentOverride(customUserAgentDetails);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n ...userAgentOverride,\n }, headers);\n return observable.pipe(map((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? initializeModel(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;;;;;;AAMA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK;AAClC,IAAI,OAAO,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,QAAQ;AAChD,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,sBAAsB,EAAE;AACxI;AACA;AACA,IAAI,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,KAAK,SAAS;AACzD,IAAI,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KAAK;AAC5B;AACA,QAAQ,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7C,QAAQ,IAAI,WAAW;AACvB,QAAQ,IAAI,GAAG;AACf,QAAQ,IAAI,UAAU,EAAE;AACxB,YAAY,IAAI,gBAAgB,CAAC,IAA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AK,KAAK;AAC1C,QAAQ,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AAC7C,QAAQ,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;AACpC,QAAQ,MAAM,CAAC,WAAW,CAAC,GAAG;AAC9B,cAAc,eAAe,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS;AACpH,cAAc,CAAC,IAAI,CAAC;AACpB,QAAQ,OAAO,WAAW;AAC1B,IAAI,CAAC,CAAC,CAAC;AACP;;;;"}
1
+ {"version":3,"file":"custom.mjs","sources":["../../../../../src/runtime/internals/operations/custom.ts"],"sourcesContent":["import { map } from 'rxjs';\nimport { authModeParams, getDefaultSelectionSetForNonModelWithIR, generateSelectionSet, getCustomHeaders, initializeModel, selectionSetIRToString, } from '../APIClient';\nimport { handleSingularGraphQlError } from './utils';\nimport { selfAwareAsync } from '../../utils';\nimport { extendCancellability } from '../cancellation';\nimport { createUserAgentOverride } from '../ai/getCustomUserAgentDetails';\n/**\n * Type guard for checking whether a Custom Operation argument is a contextSpec object\n */\nconst argIsContextSpec = (arg) => {\n return typeof arg?.token?.value === 'symbol';\n};\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nexport function customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals, customUserAgentDetails) {\n // .arguments() are defined for the custom operation in the schema builder\n // and are present in the model introspection schema\n const argsDefined = operation.arguments !== undefined;\n const op = (...args) => {\n // options is always the last argument\n const options = args[args.length - 1];\n let contextSpec;\n let arg;\n if (useContext) {\n if (argIsContextSpec(args[0])) {\n contextSpec = args[0];\n }\n else {\n throw new Error(`Invalid first argument passed to ${operation.name}. Expected contextSpec`);\n }\n }\n if (argsDefined) {\n if (useContext) {\n arg = args[1];\n }\n else {\n arg = args[0];\n }\n }\n if (operationType === 'subscription') {\n return _opSubscription(\n // subscriptions are only enabled on the clientside\n client, modelIntrospection, operation, getInternals, arg, options, customUserAgentDetails);\n }\n return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec, customUserAgentDetails);\n };\n return op;\n}\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 * For a list argument this is the *element* type, so `isRequired` — which is\n * element-level for lists — is the correct source for the `!`. The list's own\n * nullability is applied by the caller. See {@link isArgumentRequired}.\n *\n * @param argDef A single argument definition from a custom operation\n * @returns A string naming the base type including the `!` if that type is non-null.\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 * Determines whether a value must be provided for a custom operation argument,\n * i.e. whether the argument itself is non-null in the GraphQL schema.\n *\n * For list arguments, the model introspection schema encodes *element* nullability\n * in `isRequired` and *list* nullability in `isArrayNullable`. For example, an\n * argument declared as `a.ref('Color').required().array()` is emitted as `[Color!]`\n * and introspected as `{ isArray: true, isRequired: true, isArrayNullable: true }`\n * — a nullable list of non-null elements, so the argument itself is optional. Only\n * the outermost nullability determines whether the caller has to supply a value.\n *\n * `isArrayNullable` is optional in the introspection schema. The generator we\n * build against always emits it for list arguments (`getTypeInfo()` sets\n * `isListNullable` on every list branch), but when it is absent we treat the list\n * as non-null to stay consistent with the `[T]!` that `outerArguments()` renders\n * for the same input — a request declaring a non-null variable with no value\n * would be rejected by the server anyway.\n *\n * @param argDef A single argument definition from a custom operation\n * @returns Boolean: `true` if the argument itself is non-null\n */\nfunction isArgumentRequired({ isArray, isRequired, isArrayNullable, }) {\n return isArray ? !isArrayNullable : isRequired;\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}]${isArgumentRequired(argument) ? '!' : ''}`\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 `{${selectionSetIRToString(getDefaultSelectionSetForNonModelWithIR(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${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 (isArgumentRequired(argDef)) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context, customUserAgentDetails) {\n return selfAwareAsync(async (resultPromise) => {\n const { name: operationName } = operation;\n const auth = authModeParams(client, getInternals, options);\n const headers = getCustomHeaders(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const userAgentOverride = createUserAgentOverride(customUserAgentDetails);\n try {\n const basePromise = context\n ? client.graphql(context, {\n ...auth,\n query,\n variables,\n }, headers)\n : client.graphql({\n ...auth,\n query,\n variables,\n ...userAgentOverride,\n }, headers);\n const extendedPromise = 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 ? 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 ? 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 handleSingularGraphQlError(error);\n }\n }\n else {\n // `data` is `null`:\n return handleSingularGraphQlError(error);\n }\n }\n });\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _opSubscription(client, modelIntrospection, operation, getInternals, args, options, customUserAgentDetails) {\n const operationType = 'subscription';\n const { name: operationName } = operation;\n const auth = authModeParams(client, getInternals, options);\n const headers = getCustomHeaders(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const userAgentOverride = createUserAgentOverride(customUserAgentDetails);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n ...userAgentOverride,\n }, headers);\n return observable.pipe(map((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? initializeModel(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;;;;;;AAMA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK;AAClC,IAAI,OAAO,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,QAAQ;AAChD,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,sBAAsB,EA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