@aws-amplify/api-graphql 4.0.20-unstable.1a45c2f.0 → 4.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/cjs/internals/APIClient.js +2 -1
  2. package/dist/cjs/internals/APIClient.js.map +1 -1
  3. package/dist/cjs/internals/generateClient.js +4 -4
  4. package/dist/cjs/internals/generateClient.js.map +1 -1
  5. package/dist/cjs/internals/operations/custom.js +3 -19
  6. package/dist/cjs/internals/operations/custom.js.map +1 -1
  7. package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +2 -2
  8. package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -1
  9. package/dist/cjs/internals/utils/clientProperties/generateEnumsProperty.js.map +1 -0
  10. package/dist/cjs/internals/utils/{generateModelsProperty.js → clientProperties/generateModelsProperty.js} +7 -7
  11. package/dist/cjs/internals/utils/clientProperties/generateModelsProperty.js.map +1 -0
  12. package/dist/cjs/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.js.map +1 -0
  13. package/dist/cjs/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.js.map +1 -0
  14. package/dist/esm/internals/APIClient.d.ts +2 -0
  15. package/dist/esm/internals/APIClient.mjs +1 -1
  16. package/dist/esm/internals/APIClient.mjs.map +1 -1
  17. package/dist/esm/internals/generateClient.mjs +4 -4
  18. package/dist/esm/internals/generateClient.mjs.map +1 -1
  19. package/dist/esm/internals/operations/custom.mjs +4 -20
  20. package/dist/esm/internals/operations/custom.mjs.map +1 -1
  21. package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +2 -2
  22. package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
  23. package/dist/esm/internals/utils/clientProperties/generateEnumsProperty.mjs.map +1 -0
  24. package/dist/esm/internals/utils/{generateModelsProperty.d.ts → clientProperties/generateModelsProperty.d.ts} +1 -1
  25. package/dist/esm/internals/utils/{generateModelsProperty.mjs → clientProperties/generateModelsProperty.mjs} +7 -7
  26. package/dist/esm/internals/utils/clientProperties/generateModelsProperty.mjs.map +1 -0
  27. package/dist/esm/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs.map +1 -0
  28. package/dist/esm/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs.map +1 -0
  29. package/package.json +6 -6
  30. package/src/internals/APIClient.ts +1 -1
  31. package/src/internals/generateClient.ts +4 -4
  32. package/src/internals/operations/custom.ts +8 -25
  33. package/src/internals/server/generateClientWithAmplifyInstance.ts +2 -2
  34. package/src/internals/utils/{generateModelsProperty.ts → clientProperties/generateModelsProperty.ts} +8 -8
  35. package/dist/cjs/internals/utils/generateEnumsProperty.js.map +0 -1
  36. package/dist/cjs/internals/utils/generateModelsProperty.js.map +0 -1
  37. package/dist/cjs/internals/utils/isApiGraphQLProviderConfig.js.map +0 -1
  38. package/dist/cjs/internals/utils/isConfigureEventWithResourceConfig.js.map +0 -1
  39. package/dist/esm/internals/utils/generateEnumsProperty.mjs.map +0 -1
  40. package/dist/esm/internals/utils/generateModelsProperty.mjs.map +0 -1
  41. package/dist/esm/internals/utils/isApiGraphQLProviderConfig.mjs.map +0 -1
  42. package/dist/esm/internals/utils/isConfigureEventWithResourceConfig.mjs.map +0 -1
  43. /package/dist/cjs/internals/utils/{generateEnumsProperty.js → clientProperties/generateEnumsProperty.js} +0 -0
  44. /package/dist/cjs/internals/utils/{isApiGraphQLProviderConfig.js → runtimeTypeGuards/isApiGraphQLProviderConfig.js} +0 -0
  45. /package/dist/cjs/internals/utils/{isConfigureEventWithResourceConfig.js → runtimeTypeGuards/isConfigureEventWithResourceConfig.js} +0 -0
  46. /package/dist/esm/internals/utils/{generateEnumsProperty.d.ts → clientProperties/generateEnumsProperty.d.ts} +0 -0
  47. /package/dist/esm/internals/utils/{generateEnumsProperty.mjs → clientProperties/generateEnumsProperty.mjs} +0 -0
  48. /package/dist/esm/internals/utils/{isApiGraphQLProviderConfig.d.ts → runtimeTypeGuards/isApiGraphQLProviderConfig.d.ts} +0 -0
  49. /package/dist/esm/internals/utils/{isApiGraphQLProviderConfig.mjs → runtimeTypeGuards/isApiGraphQLProviderConfig.mjs} +0 -0
  50. /package/dist/esm/internals/utils/{isConfigureEventWithResourceConfig.d.ts → runtimeTypeGuards/isConfigureEventWithResourceConfig.d.ts} +0 -0
  51. /package/dist/esm/internals/utils/{isConfigureEventWithResourceConfig.mjs → runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs} +0 -0
  52. /package/src/internals/utils/{generateEnumsProperty.ts → clientProperties/generateEnumsProperty.ts} +0 -0
  53. /package/src/internals/utils/{isApiGraphQLProviderConfig.ts → runtimeTypeGuards/isApiGraphQLProviderConfig.ts} +0 -0
  54. /package/src/internals/utils/{isConfigureEventWithResourceConfig.ts → runtimeTypeGuards/isConfigureEventWithResourceConfig.ts} +0 -0
@@ -6,6 +6,9 @@ import {
6
6
  flattenItems,
7
7
  authModeParams,
8
8
  getCustomHeaders,
9
+ generateSelectionSet,
10
+ selectionSetIRToString,
11
+ defaultSelectionSetForNonModelWithIR,
9
12
  } from '../APIClient';
10
13
  import {
11
14
  AuthModeParams,
@@ -197,27 +200,6 @@ function innerArguments(operation: CustomOperation): string {
197
200
  return args.length > 0 ? `(${args})` : '';
198
201
  }
199
202
 
200
- /**
201
- * Accepts a Model or NonModel from generated introspection schema and
202
- * generates the selection set string.
203
- *
204
- * @param nonModel Model or nonModel object from introspection schema.
205
- * @returns String selection set.
206
- */
207
- function modelishTypeSelectionSet(
208
- nonModel: SchemaModel | SchemaNonModel,
209
- ): string {
210
- return Object.values(nonModel.fields)
211
- .filter(
212
- field =>
213
- hasStringField(field, 'type') ||
214
- hasStringField(field.type, 'nonModel') ||
215
- hasStringField(field.type, 'enum'),
216
- )
217
- .map(field => field.name)
218
- .join(' ');
219
- }
220
-
221
203
  /**
222
204
  * Generates the selection set string for a custom operation. This is slightly
223
205
  * different than the selection set generation for models. If the custom op returns
@@ -251,11 +233,12 @@ function operationSelectionSet(
251
233
  ) {
252
234
  return '';
253
235
  } else if (hasStringField(operation.type, 'nonModel')) {
254
- const model = modelIntrospection.nonModels[operation.type.nonModel];
255
- return `{${modelishTypeSelectionSet(model)}}`;
236
+ const nonModel = modelIntrospection.nonModels[operation.type.nonModel];
237
+ return `{${selectionSetIRToString(
238
+ defaultSelectionSetForNonModelWithIR(nonModel, modelIntrospection),
239
+ )}}`;
256
240
  } else if (hasStringField(operation.type, 'model')) {
257
- const nonModel = modelIntrospection.models[operation.type.model];
258
- return `{${modelishTypeSelectionSet(nonModel)}}`;
241
+ return `{${generateSelectionSet(modelIntrospection, operation.type.model)}}`;
259
242
  } else {
260
243
  return '';
261
244
  }
@@ -14,8 +14,8 @@ import {
14
14
  ServerClientGenerationParams,
15
15
  CommonPublicClientOptions,
16
16
  } from '../../types';
17
- import { isApiGraphQLConfig } from '../utils/isApiGraphQLProviderConfig';
18
- import { generateEnumsProperty } from '../utils/generateEnumsProperty';
17
+ import { isApiGraphQLConfig } from '../utils/runtimeTypeGuards/isApiGraphQLProviderConfig';
18
+ import { generateEnumsProperty } from '../utils/clientProperties/generateEnumsProperty';
19
19
  import {
20
20
  generateCustomMutationsProperty,
21
21
  generateCustomQueriesProperty,
@@ -1,18 +1,18 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { ModelTypes } from '@aws-amplify/data-schema-types';
4
- import { graphQLOperationsInfo, ModelOperation } from '../APIClient';
5
- import { V6Client, __authMode, __authToken } from '../../types';
6
- import { listFactory } from '../operations/list';
7
- import { indexQueryFactory } from '../operations/indexQuery';
8
- import { getFactory } from '../operations/get';
9
- import { subscriptionFactory } from '../operations/subscription';
10
- import { observeQueryFactory } from '../operations/observeQuery';
4
+ import { graphQLOperationsInfo, ModelOperation } from '../../APIClient';
5
+ import { V6Client, __authMode, __authToken } from '../../../types';
6
+ import { listFactory } from '../../operations/list';
7
+ import { indexQueryFactory } from '../../operations/indexQuery';
8
+ import { getFactory } from '../../operations/get';
9
+ import { subscriptionFactory } from '../../operations/subscription';
10
+ import { observeQueryFactory } from '../../operations/observeQuery';
11
11
  import {
12
12
  ModelIntrospectionSchema,
13
13
  GraphQLProviderConfig,
14
14
  } from '@aws-amplify/core/internals/utils';
15
- import { getSecondaryIndexesFromSchemaModel } from '../clientUtils';
15
+ import { getSecondaryIndexesFromSchemaModel } from '../../clientUtils';
16
16
 
17
17
  export function generateModelsProperty<T extends Record<any, any> = never>(
18
18
  client: V6Client<Record<string, any>>,
@@ -1 +0,0 @@
1
- {"version":3,"file":"generateEnumsProperty.js","sources":["../../../../src/internals/utils/generateEnumsProperty.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateEnumsProperty = void 0;\nconst generateEnumsProperty = (graphqlConfig) => {\n const modelIntrospection = graphqlConfig.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const enums = {};\n for (const [_, enumData] of Object.entries(modelIntrospection.enums)) {\n enums[enumData.name] = {\n values: () => enumData.values,\n };\n }\n return enums;\n};\nexports.generateEnumsProperty = generateEnumsProperty;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,qBAAqB,GAAG,KAAK,CAAC,CAAC;AACvC,MAAM,qBAAqB,GAAG,CAAC,aAAa,KAAK;AACjD,IAAI,MAAM,kBAAkB,GAAG,aAAa,CAAC,kBAAkB,CAAC;AAChE,IAAI,IAAI,CAAC,kBAAkB,EAAE;AAC7B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;AACrB,IAAI,KAAK,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;AAC1E,QAAQ,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG;AAC/B,YAAY,MAAM,EAAE,MAAM,QAAQ,CAAC,MAAM;AACzC,SAAS,CAAC;AACV,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AACF,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generateModelsProperty.js","sources":["../../../../src/internals/utils/generateModelsProperty.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateModelsProperty = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst list_1 = require(\"../operations/list\");\nconst indexQuery_1 = require(\"../operations/indexQuery\");\nconst get_1 = require(\"../operations/get\");\nconst subscription_1 = require(\"../operations/subscription\");\nconst observeQuery_1 = require(\"../operations/observeQuery\");\nconst clientUtils_1 = require(\"../clientUtils\");\nfunction generateModelsProperty(client, apiGraphQLConfig) {\n const models = {};\n const modelIntrospection = apiGraphQLConfig.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SUBSCRIPTION_OPS = ['ONCREATE', 'ONUPDATE', 'ONDELETE'];\n for (const model of Object.values(modelIntrospection.models)) {\n const { name } = model;\n models[name] = {};\n Object.entries(APIClient_1.graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n if (operation === 'LIST') {\n models[name][operationPrefix] = (0, list_1.listFactory)(client, modelIntrospection, model);\n }\n else if (SUBSCRIPTION_OPS.includes(operation)) {\n models[name][operationPrefix] = (0, subscription_1.subscriptionFactory)(client, modelIntrospection, model, operation);\n }\n else if (operation === 'OBSERVE_QUERY') {\n models[name][operationPrefix] = (0, observeQuery_1.observeQueryFactory)(models, model);\n }\n else {\n models[name][operationPrefix] = (0, get_1.getFactory)(client, modelIntrospection, model, operation);\n }\n });\n const secondaryIdxs = (0, clientUtils_1.getSecondaryIndexesFromSchemaModel)(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField] = (0, indexQuery_1.indexQueryFactory)(client, modelIntrospection, model, idx);\n }\n }\n return models;\n}\nexports.generateModelsProperty = generateModelsProperty;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAC;AACxC,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC7C,MAAM,YAAY,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACzD,MAAM,KAAK,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC3C,MAAM,cAAc,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC7D,MAAM,cAAc,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC7D,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAChD,SAAS,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE;AAC1D,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC;AACnE,IAAI,IAAI,CAAC,kBAAkB,EAAE;AAC7B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAClE,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE;AAClE,QAAQ,MAAM,EAAE,IAAI,EAAE,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,CAAC,UAAU,CAAC,GAAG,IAAI,YAAY,CAAC,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AACvH,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,sBAAsB,GAAG,sBAAsB;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isApiGraphQLProviderConfig.js","sources":["../../../../src/internals/utils/isApiGraphQLProviderConfig.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isApiGraphQLConfig = void 0;\nfunction isApiGraphQLConfig(apiGraphQLConfig) {\n return apiGraphQLConfig !== undefined;\n}\nexports.isApiGraphQLConfig = isApiGraphQLConfig;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,SAAS,kBAAkB,CAAC,gBAAgB,EAAE;AAC9C,IAAI,OAAO,gBAAgB,KAAK,SAAS,CAAC;AAC1C,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isConfigureEventWithResourceConfig.js","sources":["../../../../src/internals/utils/isConfigureEventWithResourceConfig.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isConfigureEventWithResourceConfig = void 0;\nfunction isConfigureEventWithResourceConfig(payload) {\n return payload.event === 'configure';\n}\nexports.isConfigureEventWithResourceConfig = isConfigureEventWithResourceConfig;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kCAAkC,GAAG,KAAK,CAAC,CAAC;AACpD,SAAS,kCAAkC,CAAC,OAAO,EAAE;AACrD,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,WAAW,CAAC;AACzC,CAAC;AACD,OAAO,CAAC,kCAAkC,GAAG,kCAAkC;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generateEnumsProperty.mjs","sources":["../../../../src/internals/utils/generateEnumsProperty.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const generateEnumsProperty = (graphqlConfig) => {\n const modelIntrospection = graphqlConfig.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const enums = {};\n for (const [_, enumData] of Object.entries(modelIntrospection.enums)) {\n enums[enumData.name] = {\n values: () => enumData.values,\n };\n }\n return enums;\n};\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,qBAAqB,GAAG,CAAC,aAAa,KAAK;AACxD,IAAI,MAAM,kBAAkB,GAAG,aAAa,CAAC,kBAAkB,CAAC;AAChE,IAAI,IAAI,CAAC,kBAAkB,EAAE;AAC7B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;AACrB,IAAI,KAAK,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;AAC1E,QAAQ,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG;AAC/B,YAAY,MAAM,EAAE,MAAM,QAAQ,CAAC,MAAM;AACzC,SAAS,CAAC;AACV,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../src/internals/utils/generateModelsProperty.ts"],"sourcesContent":["import { graphQLOperationsInfo } from '../APIClient';\nimport { listFactory } from '../operations/list';\nimport { indexQueryFactory } from '../operations/indexQuery';\nimport { getFactory } from '../operations/get';\nimport { subscriptionFactory } from '../operations/subscription';\nimport { observeQueryFactory } from '../operations/observeQuery';\nimport { getSecondaryIndexesFromSchemaModel } from '../clientUtils';\nexport function generateModelsProperty(client, apiGraphQLConfig) {\n const models = {};\n const modelIntrospection = apiGraphQLConfig.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SUBSCRIPTION_OPS = ['ONCREATE', 'ONUPDATE', 'ONDELETE'];\n for (const model of Object.values(modelIntrospection.models)) {\n const { name } = model;\n models[name] = {};\n Object.entries(graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n if (operation === 'LIST') {\n models[name][operationPrefix] = listFactory(client, modelIntrospection, model);\n }\n else if (SUBSCRIPTION_OPS.includes(operation)) {\n models[name][operationPrefix] = subscriptionFactory(client, modelIntrospection, model, operation);\n }\n else if (operation === 'OBSERVE_QUERY') {\n models[name][operationPrefix] = observeQueryFactory(models, model);\n }\n else {\n models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation);\n }\n });\n const secondaryIdxs = getSecondaryIndexesFromSchemaModel(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField] = indexQueryFactory(client, modelIntrospection, model, idx);\n }\n }\n return models;\n}\n"],"names":[],"mappings":";;;;;;;;AAOO,SAAS,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE;AACjE,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC;AACnE,IAAI,IAAI,CAAC,kBAAkB,EAAE;AAC7B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG,CAAC,UAAU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AAI,aAAa,EAAE;AACzC,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AACrG,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isApiGraphQLProviderConfig.mjs","sources":["../../../../src/internals/utils/isApiGraphQLProviderConfig.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isApiGraphQLConfig(apiGraphQLConfig) {\n return apiGraphQLConfig !== undefined;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,kBAAkB,CAAC,gBAAgB,EAAE;AACrD,IAAI,OAAO,gBAAgB,KAAK,SAAS,CAAC;AAC1C;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isConfigureEventWithResourceConfig.mjs","sources":["../../../../src/internals/utils/isConfigureEventWithResourceConfig.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isConfigureEventWithResourceConfig(payload) {\n return payload.event === 'configure';\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,kCAAkC,CAAC,OAAO,EAAE;AAC5D,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,WAAW,CAAC;AACzC;;;;"}