@aws-amplify/api-graphql 4.0.2-unstable.ff4e8d7.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/GraphQLAPI.js +1 -1
- package/dist/cjs/GraphQLAPI.js.map +1 -1
- package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +1 -1
- package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/dist/cjs/internals/APIClient.js +528 -0
- package/dist/cjs/internals/APIClient.js.map +1 -0
- package/dist/cjs/internals/InternalGraphQLAPI.js +14 -23
- package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
- package/dist/cjs/internals/generateClient.js +33 -0
- package/dist/cjs/internals/generateClient.js.map +1 -0
- package/dist/cjs/internals/generateModelsProperty.js +43 -0
- package/dist/cjs/internals/generateModelsProperty.js.map +1 -0
- package/dist/cjs/internals/index.js +3 -1
- package/dist/cjs/internals/index.js.map +1 -1
- package/dist/cjs/internals/operations/get.js +61 -0
- package/dist/cjs/internals/operations/get.js.map +1 -0
- package/dist/cjs/internals/operations/list.js +73 -0
- package/dist/cjs/internals/operations/list.js.map +1 -0
- package/dist/cjs/internals/operations/observeQuery.js +121 -0
- package/dist/cjs/internals/operations/observeQuery.js.map +1 -0
- package/dist/cjs/internals/operations/subscription.js +30 -0
- package/dist/cjs/internals/operations/subscription.js.map +1 -0
- package/dist/cjs/internals/server/generateClient.js +32 -0
- package/dist/cjs/internals/server/generateClient.js.map +1 -0
- package/dist/cjs/internals/server/generateModelsProperty.js +47 -0
- package/dist/cjs/internals/server/generateModelsProperty.js.map +1 -0
- package/dist/cjs/internals/server/index.js +9 -0
- package/dist/cjs/internals/server/index.js.map +1 -0
- package/dist/cjs/internals/types.js +4 -0
- package/dist/cjs/internals/types.js.map +1 -0
- package/dist/cjs/types/index.js +3 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/findIndexByFields.js +25 -0
- package/dist/cjs/utils/findIndexByFields.js.map +1 -0
- package/dist/cjs/utils/index.js +5 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/resolveOwnerFields.js +42 -0
- package/dist/cjs/utils/resolveOwnerFields.js.map +1 -0
- package/dist/cjs/utils/resolvePKFields.js +17 -0
- package/dist/cjs/utils/resolvePKFields.js.map +1 -0
- package/dist/esm/GraphQLAPI.mjs +1 -1
- package/dist/esm/GraphQLAPI.mjs.map +1 -1
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +1 -1
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internals/APIClient.d.ts +112 -0
- package/dist/esm/internals/APIClient.mjs +518 -0
- package/dist/esm/internals/APIClient.mjs.map +1 -0
- package/dist/esm/internals/InternalGraphQLAPI.d.ts +0 -11
- package/dist/esm/internals/InternalGraphQLAPI.mjs +14 -22
- package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
- package/dist/esm/internals/generateClient.d.ts +12 -0
- package/dist/esm/internals/generateClient.mjs +31 -0
- package/dist/esm/internals/generateClient.mjs.map +1 -0
- package/dist/esm/internals/generateModelsProperty.d.ts +4 -0
- package/dist/esm/internals/generateModelsProperty.mjs +41 -0
- package/dist/esm/internals/generateModelsProperty.mjs.map +1 -0
- package/dist/esm/internals/index.d.ts +1 -0
- package/dist/esm/internals/index.mjs +1 -0
- package/dist/esm/internals/index.mjs.map +1 -1
- package/dist/esm/internals/operations/get.d.ts +5 -0
- package/dist/esm/internals/operations/get.mjs +59 -0
- package/dist/esm/internals/operations/get.mjs.map +1 -0
- package/dist/esm/internals/operations/list.d.ts +4 -0
- package/dist/esm/internals/operations/list.mjs +71 -0
- package/dist/esm/internals/operations/list.mjs.map +1 -0
- package/dist/esm/internals/operations/observeQuery.d.ts +3 -0
- package/dist/esm/internals/operations/observeQuery.mjs +122 -0
- package/dist/esm/internals/operations/observeQuery.mjs.map +1 -0
- package/dist/esm/internals/operations/subscription.d.ts +3 -0
- package/dist/esm/internals/operations/subscription.mjs +28 -0
- package/dist/esm/internals/operations/subscription.mjs.map +1 -0
- package/dist/esm/internals/server/generateClient.d.ts +11 -0
- package/dist/esm/internals/server/generateClient.mjs +34 -0
- package/dist/esm/internals/server/generateClient.mjs.map +1 -0
- package/dist/esm/internals/server/generateModelsProperty.d.ts +3 -0
- package/dist/esm/internals/server/generateModelsProperty.mjs +45 -0
- package/dist/esm/internals/server/generateModelsProperty.mjs.map +1 -0
- package/dist/esm/internals/server/index.d.ts +1 -0
- package/dist/esm/internals/server/index.mjs +2 -0
- package/dist/esm/internals/server/index.mjs.map +1 -0
- package/dist/esm/internals/types.d.ts +17 -0
- package/dist/esm/internals/types.mjs +2 -0
- package/dist/esm/internals/types.mjs.map +1 -0
- package/dist/esm/types/index.d.ts +32 -2
- package/dist/esm/types/index.mjs +3 -1
- package/dist/esm/types/index.mjs.map +1 -1
- package/dist/esm/utils/findIndexByFields.d.ts +9 -0
- package/dist/esm/utils/findIndexByFields.mjs +22 -0
- package/dist/esm/utils/findIndexByFields.mjs.map +1 -0
- package/dist/esm/utils/index.d.ts +2 -0
- package/dist/esm/utils/index.mjs +2 -0
- package/dist/esm/utils/index.mjs.map +1 -1
- package/dist/esm/utils/resolveOwnerFields.d.ts +12 -0
- package/dist/esm/utils/resolveOwnerFields.mjs +39 -0
- package/dist/esm/utils/resolveOwnerFields.mjs.map +1 -0
- package/dist/esm/utils/resolvePKFields.d.ts +13 -0
- package/dist/esm/utils/resolvePKFields.mjs +14 -0
- package/dist/esm/utils/resolvePKFields.mjs.map +1 -0
- package/internals/server/package.json +8 -0
- package/package.json +148 -146
- package/src/GraphQLAPI.ts +2 -2
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +9 -4
- package/src/internals/APIClient.ts +780 -0
- package/src/internals/InternalGraphQLAPI.ts +21 -31
- package/src/internals/generateClient.ts +33 -0
- package/src/internals/generateModelsProperty.ts +73 -0
- package/src/internals/index.ts +1 -0
- package/src/internals/operations/get.ts +131 -0
- package/src/internals/operations/list.ts +132 -0
- package/src/internals/operations/observeQuery.ts +144 -0
- package/src/internals/operations/subscription.ts +65 -0
- package/src/internals/server/generateClient.ts +45 -0
- package/src/internals/server/generateModelsProperty.ts +80 -0
- package/src/internals/server/index.ts +4 -0
- package/src/internals/types.ts +21 -0
- package/src/types/index.ts +42 -2
- package/src/utils/ConnectionStateMonitor.ts +3 -1
- package/src/utils/findIndexByFields.ts +31 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/resolveOwnerFields.ts +65 -0
- package/src/utils/resolvePKFields.ts +22 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { map } from 'rxjs';
|
|
2
|
+
import { generateGraphQLDocument, buildGraphQLVariables, authModeParams, initializeModel } from '../APIClient.mjs';
|
|
3
|
+
|
|
4
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
function subscriptionFactory(client, modelIntrospection, model, operation) {
|
|
7
|
+
const { name } = model;
|
|
8
|
+
const subscription = (args) => {
|
|
9
|
+
const query = generateGraphQLDocument(modelIntrospection.models, name, operation);
|
|
10
|
+
const variables = buildGraphQLVariables(model, operation, args, modelIntrospection);
|
|
11
|
+
const auth = authModeParams(client, args);
|
|
12
|
+
const observable = client.graphql({
|
|
13
|
+
...auth,
|
|
14
|
+
query,
|
|
15
|
+
variables,
|
|
16
|
+
});
|
|
17
|
+
return observable.pipe(map(value => {
|
|
18
|
+
const [key] = Object.keys(value.data);
|
|
19
|
+
const data = value.data[key];
|
|
20
|
+
const [initialized] = initializeModel(client, name, [data], modelIntrospection, auth.authMode, auth.authToken);
|
|
21
|
+
return initialized;
|
|
22
|
+
}));
|
|
23
|
+
};
|
|
24
|
+
return subscription;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { subscriptionFactory };
|
|
28
|
+
//# sourceMappingURL=subscription.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription.mjs","sources":["../../../../src/internals/operations/subscription.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { map } from 'rxjs';\nimport { initializeModel, generateGraphQLDocument, buildGraphQLVariables, authModeParams, } from '../APIClient';\nexport function subscriptionFactory(client, modelIntrospection, model, operation) {\n const { name } = model;\n const subscription = (args) => {\n const query = generateGraphQLDocument(modelIntrospection.models, name, operation);\n const variables = buildGraphQLVariables(model, operation, args, modelIntrospection);\n const auth = authModeParams(client, args);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n });\n return observable.pipe(map(value => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = initializeModel(client, name, [data], modelIntrospection, auth.authMode, auth.authToken);\n return initialized;\n }));\n };\n return subscription;\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGO,SAAS,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE;AAClF,IAAI,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAC3B,IAAI,MAAM,YAAY,GAAG,CAAC,IAAI,KAAK;AACnC,QAAQ,MAAM,KAAK,GAAG,uBAAuB,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;AAC1F,QAAQ,MAAM,SAAS,GAAG,qBAAqB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC;AAC5F,QAAQ,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAClD,QAAQ,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;AAC1C,YAAY,GAAG,IAAI;AACnB,YAAY,KAAK;AACjB,YAAY,SAAS;AACrB,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI;AAC5C,YAAY,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAClD,YAAY,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,YAAY,MAAM,CAAC,WAAW,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;AAC3H,YAAY,OAAO,WAAW,CAAC;AAC/B,SAAS,CAAC,CAAC,CAAC;AACZ,KAAK,CAAC;AACN,IAAI,OAAO,YAAY,CAAC;AACxB;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { V6ClientSSRRequest, V6ClientSSRCookies, ServerClientGenerationParams, CommonPublicClientOptions } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
*
|
|
5
|
+
* Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`
|
|
6
|
+
* compatible context object for config and auth fetching.
|
|
7
|
+
*
|
|
8
|
+
* @param params
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function generateClient<T extends Record<any, any> = never, ClientType extends V6ClientSSRRequest<T> | V6ClientSSRCookies<T> = V6ClientSSRCookies<T>>(params: ServerClientGenerationParams & CommonPublicClientOptions): ClientType;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import '../InternalGraphQLAPI.mjs';
|
|
2
|
+
import { graphql, cancel, isCancelError } from '../v6.mjs';
|
|
3
|
+
import { __amplify, __authMode, __authToken } from '../../types/index.mjs';
|
|
4
|
+
import 'rxjs';
|
|
5
|
+
import '@aws-amplify/core/internals/utils';
|
|
6
|
+
import '../../utils/errors/validation.mjs';
|
|
7
|
+
import { generateModelsProperty } from './generateModelsProperty.mjs';
|
|
8
|
+
|
|
9
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
*
|
|
14
|
+
* Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`
|
|
15
|
+
* compatible context object for config and auth fetching.
|
|
16
|
+
*
|
|
17
|
+
* @param params
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
function generateClient(params) {
|
|
21
|
+
const client = {
|
|
22
|
+
[__amplify]: params.amplify,
|
|
23
|
+
[__authMode]: params.authMode,
|
|
24
|
+
[__authToken]: params.authToken,
|
|
25
|
+
graphql,
|
|
26
|
+
cancel,
|
|
27
|
+
isCancelError,
|
|
28
|
+
};
|
|
29
|
+
client.models = generateModelsProperty(client, params);
|
|
30
|
+
return client;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { generateClient };
|
|
34
|
+
//# sourceMappingURL=generateClient.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateClient.mjs","sources":["../../../../src/internals/server/generateClient.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { graphql, cancel, isCancelError } from '../';\nimport { generateModelsProperty } from './generateModelsProperty';\nimport { __amplify, __authMode, __authToken, } from '../../types';\n/**\n * @private\n *\n * Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`\n * compatible context object for config and auth fetching.\n *\n * @param params\n * @returns\n */\nexport function generateClient(params) {\n const client = {\n [__amplify]: params.amplify,\n [__authMode]: params.authMode,\n [__authToken]: params.authToken,\n graphql,\n cancel,\n isCancelError,\n };\n client.models = generateModelsProperty(client, params);\n return client;\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,MAAM,EAAE;AACvC,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AACnC,QAAQ,CAAC,UAAU,GAAG,MAAM,CAAC,QAAQ;AACrC,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS;AACvC,QAAQ,OAAO;AACf,QAAQ,MAAM;AACd,QAAQ,aAAa;AACrB,KAAK,CAAC;AACN,IAAI,MAAM,CAAC,MAAM,GAAG,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3D,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ServerClientGenerationParams } from '../../types/';
|
|
2
|
+
import { V6ClientSSRRequest, V6ClientSSRCookies } from '../../types';
|
|
3
|
+
export declare function generateModelsProperty<T extends Record<any, any> = never, ClientType extends V6ClientSSRRequest<Record<string, any>> | V6ClientSSRCookies<Record<string, any>> = V6ClientSSRCookies<Record<string, any>>>(client: ClientType, params: ServerClientGenerationParams): ClientType;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { graphQLOperationsInfo } from '../APIClient.mjs';
|
|
2
|
+
import { listFactory } from '../operations/list.mjs';
|
|
3
|
+
import { getFactory } from '../operations/get.mjs';
|
|
4
|
+
|
|
5
|
+
function generateModelsProperty(client, params) {
|
|
6
|
+
const models = {};
|
|
7
|
+
const config = params.config;
|
|
8
|
+
const useContext = client === null;
|
|
9
|
+
if (!config) {
|
|
10
|
+
throw new Error('generateModelsProperty cannot retrieve Amplify config');
|
|
11
|
+
}
|
|
12
|
+
if (!config.API?.GraphQL) {
|
|
13
|
+
throw new Error('The API configuration is missing. This is likely due to Amplify.configure() not being called prior to generateClient().');
|
|
14
|
+
}
|
|
15
|
+
const modelIntrospection = config.API.GraphQL.modelIntrospection;
|
|
16
|
+
if (!modelIntrospection) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
const SSR_UNSUPORTED_OPS = [
|
|
20
|
+
'ONCREATE',
|
|
21
|
+
'ONUPDATE',
|
|
22
|
+
'ONDELETE',
|
|
23
|
+
'OBSERVE_QUERY',
|
|
24
|
+
];
|
|
25
|
+
for (const model of Object.values(modelIntrospection.models)) {
|
|
26
|
+
const { name } = model;
|
|
27
|
+
models[name] = {};
|
|
28
|
+
Object.entries(graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {
|
|
29
|
+
const operation = key;
|
|
30
|
+
// subscriptions are not supported in SSR
|
|
31
|
+
if (SSR_UNSUPORTED_OPS.includes(operation))
|
|
32
|
+
return;
|
|
33
|
+
if (operation === 'LIST') {
|
|
34
|
+
models[name][operationPrefix] = listFactory(client, modelIntrospection, model, useContext);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation, useContext);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return models;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { generateModelsProperty };
|
|
45
|
+
//# sourceMappingURL=generateModelsProperty.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../src/internals/server/generateModelsProperty.ts"],"sourcesContent":["import { graphQLOperationsInfo } from '../APIClient';\nimport { listFactory } from '../operations/list';\nimport { getFactory } from '../operations/get';\nexport function generateModelsProperty(client, params) {\n const models = {};\n const config = params.config;\n const useContext = client === null;\n if (!config) {\n throw new Error('generateModelsProperty cannot retrieve Amplify config');\n }\n if (!config.API?.GraphQL) {\n throw new Error('The API configuration is missing. This is likely due to Amplify.configure() not being called prior to generateClient().');\n }\n const modelIntrospection = config.API.GraphQL.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SSR_UNSUPORTED_OPS = [\n 'ONCREATE',\n 'ONUPDATE',\n 'ONDELETE',\n 'OBSERVE_QUERY',\n ];\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 // subscriptions are not supported in SSR\n if (SSR_UNSUPORTED_OPS.includes(operation))\n return;\n if (operation === 'LIST') {\n models[name][operationPrefix] = listFactory(client, modelIntrospection, model, useContext);\n }\n else {\n models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation, useContext);\n }\n });\n }\n return models;\n}\n"],"names":[],"mappings":";;;;AAGO,SAAS,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE;AACvD,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACjC,IAAI,MAAM,UAAU,GAAG,MAAM,KAAK,IAAI,CAAC;AACvC,IAAI,IAAI,CAAC,MAAM,EAAE;AACjB,QAAQ,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AACjF,KAAK;AACL,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE;AAC9B,QAAQ,MAAM,IAAI,KAAK,CAAC,yHAAyH,CAAC,CAAC;AACnJ,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC;AACrE,IAAI,IAAI,CAAC,kBAAkB,EAAE;AAC7B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,UAAU;AAClB,QAAQ,UAAU;AAClB,QAAQ,UAAU;AAClB,QAAQ,eAAe;AACvB,KAAK,CAAC;AACN,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE;AAClE,QAAQ,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAC/B,QAAQ,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AAC1B,QAAQ,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,eAAe,EAAE,CAAC,KAAK;AACtF,YAAY,MAAM,SAAS,GAAG,GAAG,CAAC;AAClC;AACA,YAAY,IAAI,kBAAkB,CAAC,QAAQ,CAAC,SAAS,CAAC;AACtD,gBAAgB,OAAO;AACvB,YAAY,IAAI,SAAS,KAAK,MAAM,EAAE;AACtC,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AAC3G,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACrH,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateClient } from './generateClient';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
2
|
+
import { GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
*
|
|
6
|
+
* The knobs available for configuring `generateClient` internally.
|
|
7
|
+
*/
|
|
8
|
+
export type ClientGenerationParams = {
|
|
9
|
+
amplify: AmplifyClassV6;
|
|
10
|
+
} & CommonPublicClientOptions;
|
|
11
|
+
/**
|
|
12
|
+
* Common options that can be used on public `generateClient()` interfaces.
|
|
13
|
+
*/
|
|
14
|
+
export type CommonPublicClientOptions = {
|
|
15
|
+
authMode?: GraphQLAuthMode;
|
|
16
|
+
authToken?: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { AmplifyClassV6, ResourcesConfig } from '@aws-amplify/core';
|
|
2
|
+
import { ModelTypes } from '@aws-amplify/data-schema-types';
|
|
2
3
|
import { Source, DocumentNode, GraphQLError } from 'graphql';
|
|
3
4
|
export { OperationTypeNode } from 'graphql';
|
|
4
5
|
import { Observable } from 'rxjs';
|
|
5
6
|
import { GraphQLAuthMode, DocumentType } from '@aws-amplify/core/internals/utils';
|
|
6
7
|
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
|
|
7
8
|
export { CONTROL_MSG, ConnectionState } from './PubSub';
|
|
9
|
+
export { SelectionSet } from '@aws-amplify/data-schema-types';
|
|
10
|
+
export { CommonPublicClientOptions } from '../internals/types';
|
|
8
11
|
/**
|
|
9
12
|
* Loose/Unknown options for raw GraphQLAPICategory `graphql()`.
|
|
10
13
|
*/
|
|
@@ -280,17 +283,35 @@ type ExcludeNeverFields<O> = {
|
|
|
280
283
|
[K in FilteredKeys<O>]: O[K];
|
|
281
284
|
};
|
|
282
285
|
export declare const __amplify: unique symbol;
|
|
286
|
+
export declare const __authMode: unique symbol;
|
|
287
|
+
export declare const __authToken: unique symbol;
|
|
288
|
+
export type ClientWithModels = V6Client<Record<string, any>> | V6ClientSSRRequest<Record<string, any>> | V6ClientSSRCookies<Record<string, any>>;
|
|
283
289
|
export type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
284
290
|
[__amplify]: AmplifyClassV6;
|
|
291
|
+
[__authMode]?: GraphQLAuthMode;
|
|
292
|
+
[__authToken]?: string;
|
|
285
293
|
graphql: GraphQLMethod;
|
|
286
294
|
cancel: (promise: Promise<any>, message?: string) => boolean;
|
|
287
295
|
isCancelError: (error: any) => boolean;
|
|
296
|
+
models: ModelTypes<T>;
|
|
288
297
|
}>;
|
|
289
|
-
export type
|
|
298
|
+
export type V6ClientSSRRequest<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
290
299
|
[__amplify]: AmplifyClassV6;
|
|
300
|
+
[__authMode]?: GraphQLAuthMode;
|
|
301
|
+
[__authToken]?: string;
|
|
291
302
|
graphql: GraphQLMethodSSR;
|
|
292
303
|
cancel: (promise: Promise<any>, message?: string) => boolean;
|
|
293
304
|
isCancelError: (error: any) => boolean;
|
|
305
|
+
models: ModelTypes<T, 'REQUEST'>;
|
|
306
|
+
}>;
|
|
307
|
+
export type V6ClientSSRCookies<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
308
|
+
[__amplify]: AmplifyClassV6;
|
|
309
|
+
[__authMode]?: GraphQLAuthMode;
|
|
310
|
+
[__authToken]?: string;
|
|
311
|
+
graphql: GraphQLMethod;
|
|
312
|
+
cancel: (promise: Promise<any>, message?: string) => boolean;
|
|
313
|
+
isCancelError: (error: any) => boolean;
|
|
314
|
+
models: ModelTypes<T, 'COOKIES'>;
|
|
294
315
|
}>;
|
|
295
316
|
export type GraphQLMethod = <FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string>(options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>, additionalHeaders?: {
|
|
296
317
|
[key: string]: string;
|
|
@@ -304,6 +325,15 @@ export type GraphQLMethodSSR = <FALLBACK_TYPES = unknown, TYPED_GQL_STRING exten
|
|
|
304
325
|
* The knobs available for configuring `server/generateClient` internally.
|
|
305
326
|
*/
|
|
306
327
|
export type ServerClientGenerationParams = {
|
|
307
|
-
amplify: null | ((fn: (amplify:
|
|
328
|
+
amplify: null | ((fn: (amplify: AmplifyClassV6) => Promise<any>) => Promise<any>);
|
|
308
329
|
config: ResourcesConfig;
|
|
309
330
|
};
|
|
331
|
+
export type QueryArgs = Record<string, unknown>;
|
|
332
|
+
export type ListArgs = {
|
|
333
|
+
selectionSet?: string[];
|
|
334
|
+
filter?: {};
|
|
335
|
+
};
|
|
336
|
+
export type AuthModeParams = {
|
|
337
|
+
authMode?: GraphQLAuthMode;
|
|
338
|
+
authToken?: string;
|
|
339
|
+
};
|
package/dist/esm/types/index.mjs
CHANGED
|
@@ -9,6 +9,8 @@ var GraphQLAuthError;
|
|
|
9
9
|
GraphQLAuthError["NO_AUTH_TOKEN"] = "No auth token specified";
|
|
10
10
|
})(GraphQLAuthError || (GraphQLAuthError = {}));
|
|
11
11
|
const __amplify = Symbol('amplify');
|
|
12
|
+
const __authMode = Symbol('authMode');
|
|
13
|
+
const __authToken = Symbol('authToken');
|
|
12
14
|
|
|
13
|
-
export { GraphQLAuthError, __amplify };
|
|
15
|
+
export { GraphQLAuthError, __amplify, __authMode, __authToken };
|
|
14
16
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/types/index.ts"],"sourcesContent":["export { CONTROL_MSG, ConnectionState } from './PubSub';\nexport var GraphQLAuthError;\n(function (GraphQLAuthError) {\n GraphQLAuthError[\"NO_API_KEY\"] = \"No api-key configured\";\n GraphQLAuthError[\"NO_CURRENT_USER\"] = \"No current user\";\n GraphQLAuthError[\"NO_CREDENTIALS\"] = \"No credentials\";\n GraphQLAuthError[\"NO_FEDERATED_JWT\"] = \"No federated jwt\";\n GraphQLAuthError[\"NO_AUTH_TOKEN\"] = \"No auth token specified\";\n})(GraphQLAuthError || (GraphQLAuthError = {}));\nexport const __amplify = Symbol('amplify');\n"],"names":[],"mappings":";;AACU,IAAC,iBAAiB;AAC5B,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,YAAY,CAAC,GAAG,uBAAuB,CAAC;AAC7D,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;AAC5D,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;AAC1D,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AAC9D,IAAI,gBAAgB,CAAC,eAAe,CAAC,GAAG,yBAAyB,CAAC;AAClE,CAAC,EAAE,gBAAgB,KAAK,gBAAgB,GAAG,EAAE,CAAC,CAAC,CAAC;AACpC,MAAC,SAAS,GAAG,MAAM,CAAC,SAAS;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/types/index.ts"],"sourcesContent":["export { CONTROL_MSG, ConnectionState } from './PubSub';\nexport var GraphQLAuthError;\n(function (GraphQLAuthError) {\n GraphQLAuthError[\"NO_API_KEY\"] = \"No api-key configured\";\n GraphQLAuthError[\"NO_CURRENT_USER\"] = \"No current user\";\n GraphQLAuthError[\"NO_CREDENTIALS\"] = \"No credentials\";\n GraphQLAuthError[\"NO_FEDERATED_JWT\"] = \"No federated jwt\";\n GraphQLAuthError[\"NO_AUTH_TOKEN\"] = \"No auth token specified\";\n})(GraphQLAuthError || (GraphQLAuthError = {}));\nexport const __amplify = Symbol('amplify');\nexport const __authMode = Symbol('authMode');\nexport const __authToken = Symbol('authToken');\n"],"names":[],"mappings":";;AACU,IAAC,iBAAiB;AAC5B,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,YAAY,CAAC,GAAG,uBAAuB,CAAC;AAC7D,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;AAC5D,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;AAC1D,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AAC9D,IAAI,gBAAgB,CAAC,eAAe,CAAC,GAAG,yBAAyB,CAAC;AAClE,CAAC,EAAE,gBAAgB,KAAK,gBAAgB,GAAG,EAAE,CAAC,CAAC,CAAC;AACpC,MAAC,SAAS,GAAG,MAAM,CAAC,SAAS,EAAE;AAC/B,MAAC,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE;AACjC,MAAC,WAAW,GAAG,MAAM,CAAC,WAAW;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Iterates through a collection to find a matching item and returns the index.
|
|
3
|
+
*
|
|
4
|
+
* @param needle The item to search for
|
|
5
|
+
* @param haystack The collection to search
|
|
6
|
+
* @param keyFields The fields used to indicate a match
|
|
7
|
+
* @returns Index of `needle` in `haystack`, otherwise -1 if not found.
|
|
8
|
+
*/
|
|
9
|
+
export declare function findIndexByFields<T>(needle: T, haystack: T[], keyFields: Array<keyof T>): number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* Iterates through a collection to find a matching item and returns the index.
|
|
5
|
+
*
|
|
6
|
+
* @param needle The item to search for
|
|
7
|
+
* @param haystack The collection to search
|
|
8
|
+
* @param keyFields The fields used to indicate a match
|
|
9
|
+
* @returns Index of `needle` in `haystack`, otherwise -1 if not found.
|
|
10
|
+
*/
|
|
11
|
+
function findIndexByFields(needle, haystack, keyFields) {
|
|
12
|
+
const searchObject = Object.fromEntries(keyFields.map(fieldName => [fieldName, needle[fieldName]]));
|
|
13
|
+
for (let i = 0; i < haystack.length; i++) {
|
|
14
|
+
if (Object.keys(searchObject).every(k => searchObject[k] === haystack[i][k])) {
|
|
15
|
+
return i;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return -1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { findIndexByFields };
|
|
22
|
+
//# sourceMappingURL=findIndexByFields.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findIndexByFields.mjs","sources":["../../../src/utils/findIndexByFields.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Iterates through a collection to find a matching item and returns the index.\n *\n * @param needle The item to search for\n * @param haystack The collection to search\n * @param keyFields The fields used to indicate a match\n * @returns Index of `needle` in `haystack`, otherwise -1 if not found.\n */\nexport function findIndexByFields(needle, haystack, keyFields) {\n const searchObject = Object.fromEntries(keyFields.map(fieldName => [fieldName, needle[fieldName]]));\n for (let i = 0; i < haystack.length; i++) {\n if (Object.keys(searchObject).every(k => searchObject[k] === haystack[i][k])) {\n return i;\n }\n }\n return -1;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE;AAC/D,IAAI,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACxG,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC9C,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;AACtF,YAAY,OAAO,CAAC,CAAC;AACrB,SAAS;AACT,KAAK;AACL,IAAI,OAAO,CAAC,CAAC,CAAC;AACd;;;;"}
|
package/dist/esm/utils/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { resolveConfig } from './resolveConfig.mjs';
|
|
2
2
|
export { resolveLibraryOptions } from './resolveLibraryOptions.mjs';
|
|
3
|
+
export { resolvePKFields } from './resolvePKFields.mjs';
|
|
4
|
+
export { findIndexByFields } from './findIndexByFields.mjs';
|
|
3
5
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ResourcesConfig } from '@aws-amplify/core';
|
|
2
|
+
type GraphQLConfig = Exclude<ResourcesConfig['API'], undefined>['GraphQL'];
|
|
3
|
+
type ModelIntrospectionSchema = Exclude<Exclude<GraphQLConfig, undefined>['modelIntrospection'], undefined>;
|
|
4
|
+
type Model = ModelIntrospectionSchema['models'][string];
|
|
5
|
+
/**
|
|
6
|
+
* Given an introspection schema model, returns all owner fields.
|
|
7
|
+
*
|
|
8
|
+
* @param model Model from an introspection schema
|
|
9
|
+
* @returns List of owner field names
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveOwnerFields(model: Model): string[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given an introspection schema model, returns all owner fields.
|
|
3
|
+
*
|
|
4
|
+
* @param model Model from an introspection schema
|
|
5
|
+
* @returns List of owner field names
|
|
6
|
+
*/
|
|
7
|
+
function resolveOwnerFields(model) {
|
|
8
|
+
const ownerFields = new Set();
|
|
9
|
+
for (const attr of model.attributes || []) {
|
|
10
|
+
if (isAuthAttribute(attr)) {
|
|
11
|
+
for (const rule of attr.properties.rules) {
|
|
12
|
+
if (rule.allow === 'owner') {
|
|
13
|
+
ownerFields.add(rule.ownerField || 'owner');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return Array.from(ownerFields);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Type guard that identifies an auth attribute with an attached rules list that
|
|
22
|
+
* specifies an `allow` attribute at a minimum.
|
|
23
|
+
*
|
|
24
|
+
* @param attribute Any object. Ideally a model introspection schema model attribute
|
|
25
|
+
* @returns True if given object is an auth attribute
|
|
26
|
+
*/
|
|
27
|
+
function isAuthAttribute(attribute) {
|
|
28
|
+
if (attribute?.type === 'auth') {
|
|
29
|
+
if (typeof attribute?.properties === 'object') {
|
|
30
|
+
if (Array.isArray(attribute?.properties?.rules)) {
|
|
31
|
+
return (attribute?.properties?.rules).every(rule => !!rule.allow);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { resolveOwnerFields };
|
|
39
|
+
//# sourceMappingURL=resolveOwnerFields.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveOwnerFields.mjs","sources":["../../../src/utils/resolveOwnerFields.ts"],"sourcesContent":["/**\n * Given an introspection schema model, returns all owner fields.\n *\n * @param model Model from an introspection schema\n * @returns List of owner field names\n */\nexport function resolveOwnerFields(model) {\n const ownerFields = new Set();\n for (const attr of model.attributes || []) {\n if (isAuthAttribute(attr)) {\n for (const rule of attr.properties.rules) {\n if (rule.allow === 'owner') {\n ownerFields.add(rule.ownerField || 'owner');\n }\n }\n }\n }\n return Array.from(ownerFields);\n}\n/**\n * Type guard that identifies an auth attribute with an attached rules list that\n * specifies an `allow` attribute at a minimum.\n *\n * @param attribute Any object. Ideally a model introspection schema model attribute\n * @returns True if given object is an auth attribute\n */\nfunction isAuthAttribute(attribute) {\n if (attribute?.type === 'auth') {\n if (typeof attribute?.properties === 'object') {\n if (Array.isArray(attribute?.properties?.rules)) {\n return (attribute?.properties?.rules).every(rule => !!rule.allow);\n }\n }\n }\n return false;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,KAAK,EAAE;AAC1C,IAAI,MAAM,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;AAClC,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE;AAC/C,QAAQ,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE;AACnC,YAAY,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;AACtD,gBAAgB,IAAI,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE;AAC5C,oBAAoB,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC,CAAC;AAChE,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACnC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,SAAS,EAAE;AACpC,IAAI,IAAI,SAAS,EAAE,IAAI,KAAK,MAAM,EAAE;AACpC,QAAQ,IAAI,OAAO,SAAS,EAAE,UAAU,KAAK,QAAQ,EAAE;AACvD,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE;AAC7D,gBAAgB,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClF,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ResourcesConfig } from '@aws-amplify/core';
|
|
2
|
+
type GraphQLConfig = Exclude<ResourcesConfig['API'], undefined>['GraphQL'];
|
|
3
|
+
type ModelIntrospectionSchema = Exclude<Exclude<GraphQLConfig, undefined>['modelIntrospection'], undefined>;
|
|
4
|
+
type SchemaModel = ModelIntrospectionSchema['models'][string];
|
|
5
|
+
/**
|
|
6
|
+
* Given a SchemaModel from a ModelIntrospectionSchema, returns the primary key
|
|
7
|
+
* as an array of field names.
|
|
8
|
+
*
|
|
9
|
+
* @param model The model object
|
|
10
|
+
* @returns Array of field names
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolvePKFields(model: SchemaModel): string[];
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a SchemaModel from a ModelIntrospectionSchema, returns the primary key
|
|
3
|
+
* as an array of field names.
|
|
4
|
+
*
|
|
5
|
+
* @param model The model object
|
|
6
|
+
* @returns Array of field names
|
|
7
|
+
*/
|
|
8
|
+
function resolvePKFields(model) {
|
|
9
|
+
const { primaryKeyFieldName, sortKeyFieldNames } = model.primaryKeyInfo;
|
|
10
|
+
return [primaryKeyFieldName, ...sortKeyFieldNames];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { resolvePKFields };
|
|
14
|
+
//# sourceMappingURL=resolvePKFields.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvePKFields.mjs","sources":["../../../src/utils/resolvePKFields.ts"],"sourcesContent":["/**\n * Given a SchemaModel from a ModelIntrospectionSchema, returns the primary key\n * as an array of field names.\n *\n * @param model The model object\n * @returns Array of field names\n */\nexport function resolvePKFields(model) {\n const { primaryKeyFieldName, sortKeyFieldNames } = model.primaryKeyInfo;\n return [primaryKeyFieldName, ...sortKeyFieldNames];\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,KAAK,EAAE;AACvC,IAAI,MAAM,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAC,cAAc,CAAC;AAC5E,IAAI,OAAO,CAAC,mBAAmB,EAAE,GAAG,iBAAiB,CAAC,CAAC;AACvD;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aws-amplify/api-graphql/internals/server",
|
|
3
|
+
"types": "../../dist/esm/internals/server/index.d.ts",
|
|
4
|
+
"main": "../../dist/cjs/internals/server/index.js",
|
|
5
|
+
"module": "../../dist/esm/internals/server/index.mjs",
|
|
6
|
+
"react-native": "../../src/internals/server/index.ts",
|
|
7
|
+
"sideEffects": false
|
|
8
|
+
}
|