@aws-amplify/api-graphql 4.0.29-unstable.f37faeb.0 → 4.0.29
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/internals/generateClient.js +4 -14
- package/dist/cjs/internals/generateClient.js.map +1 -1
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +3 -8
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -1
- package/dist/cjs/internals/v6.js +6 -3
- package/dist/cjs/internals/v6.js.map +1 -1
- package/dist/cjs/types/index.js +11 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/index.js +1 -5
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/esm/GraphQLAPI.d.ts +1 -1
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.d.ts +1 -1
- package/dist/esm/internals/generateClient.mjs +5 -15
- package/dist/esm/internals/generateClient.mjs.map +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +4 -9
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
- package/dist/esm/internals/types.d.ts +1 -1
- package/dist/esm/internals/v6.d.ts +1 -1
- package/dist/esm/internals/v6.mjs +7 -4
- package/dist/esm/internals/v6.mjs.map +1 -1
- package/dist/esm/types/index.d.ts +10 -40
- package/dist/esm/types/index.mjs +10 -1
- package/dist/esm/types/index.mjs.map +1 -1
- package/dist/esm/utils/index.d.ts +0 -2
- package/dist/esm/utils/index.mjs +0 -2
- package/dist/esm/utils/index.mjs.map +1 -1
- package/package.json +5 -6
- package/src/GraphQLAPI.ts +1 -1
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +4 -1
- package/src/internals/InternalGraphQLAPI.ts +4 -1
- package/src/internals/generateClient.ts +8 -36
- package/src/internals/server/generateClientWithAmplifyInstance.ts +6 -16
- package/src/internals/types.ts +1 -1
- package/src/internals/v6.ts +7 -7
- package/src/server/generateClient.ts +1 -1
- package/src/types/index.ts +36 -60
- package/src/utils/index.ts +0 -2
- package/dist/cjs/internals/APIClient.js +0 -733
- package/dist/cjs/internals/APIClient.js.map +0 -1
- package/dist/cjs/internals/clientUtils.js +0 -29
- package/dist/cjs/internals/clientUtils.js.map +0 -1
- package/dist/cjs/internals/generateCustomOperationsProperty.js +0 -50
- package/dist/cjs/internals/generateCustomOperationsProperty.js.map +0 -1
- package/dist/cjs/internals/operations/custom.js +0 -356
- package/dist/cjs/internals/operations/custom.js.map +0 -1
- package/dist/cjs/internals/operations/get.js +0 -62
- package/dist/cjs/internals/operations/get.js.map +0 -1
- package/dist/cjs/internals/operations/indexQuery.js +0 -75
- package/dist/cjs/internals/operations/indexQuery.js.map +0 -1
- package/dist/cjs/internals/operations/list.js +0 -74
- package/dist/cjs/internals/operations/list.js.map +0 -1
- package/dist/cjs/internals/operations/observeQuery.js +0 -121
- package/dist/cjs/internals/operations/observeQuery.js.map +0 -1
- package/dist/cjs/internals/operations/subscription.js +0 -31
- package/dist/cjs/internals/operations/subscription.js.map +0 -1
- package/dist/cjs/internals/server/generateModelsProperty.js +0 -53
- package/dist/cjs/internals/server/generateModelsProperty.js.map +0 -1
- package/dist/cjs/internals/utils/clientProperties/generateEnumsProperty.js +0 -21
- package/dist/cjs/internals/utils/clientProperties/generateEnumsProperty.js.map +0 -1
- package/dist/cjs/internals/utils/clientProperties/generateModelsProperty.js +0 -45
- package/dist/cjs/internals/utils/clientProperties/generateModelsProperty.js.map +0 -1
- package/dist/cjs/utils/findIndexByFields.js +0 -25
- package/dist/cjs/utils/findIndexByFields.js.map +0 -1
- package/dist/cjs/utils/resolveOwnerFields.js +0 -48
- package/dist/cjs/utils/resolveOwnerFields.js.map +0 -1
- package/dist/cjs/utils/resolvePKFields.js +0 -17
- package/dist/cjs/utils/resolvePKFields.js.map +0 -1
- package/dist/esm/internals/APIClient.d.ts +0 -126
- package/dist/esm/internals/APIClient.mjs +0 -721
- package/dist/esm/internals/APIClient.mjs.map +0 -1
- package/dist/esm/internals/clientUtils.d.ts +0 -6
- package/dist/esm/internals/clientUtils.mjs +0 -26
- package/dist/esm/internals/clientUtils.mjs.map +0 -1
- package/dist/esm/internals/generateCustomOperationsProperty.d.ts +0 -9
- package/dist/esm/internals/generateCustomOperationsProperty.mjs +0 -45
- package/dist/esm/internals/generateCustomOperationsProperty.mjs.map +0 -1
- package/dist/esm/internals/operations/custom.d.ts +0 -63
- package/dist/esm/internals/operations/custom.mjs +0 -354
- package/dist/esm/internals/operations/custom.mjs.map +0 -1
- package/dist/esm/internals/operations/get.d.ts +0 -5
- package/dist/esm/internals/operations/get.mjs +0 -60
- package/dist/esm/internals/operations/get.mjs.map +0 -1
- package/dist/esm/internals/operations/indexQuery.d.ts +0 -9
- package/dist/esm/internals/operations/indexQuery.mjs +0 -73
- package/dist/esm/internals/operations/indexQuery.mjs.map +0 -1
- package/dist/esm/internals/operations/list.d.ts +0 -4
- package/dist/esm/internals/operations/list.mjs +0 -72
- package/dist/esm/internals/operations/list.mjs.map +0 -1
- package/dist/esm/internals/operations/observeQuery.d.ts +0 -3
- package/dist/esm/internals/operations/observeQuery.mjs +0 -121
- package/dist/esm/internals/operations/observeQuery.mjs.map +0 -1
- package/dist/esm/internals/operations/subscription.d.ts +0 -3
- package/dist/esm/internals/operations/subscription.mjs +0 -29
- package/dist/esm/internals/operations/subscription.mjs.map +0 -1
- package/dist/esm/internals/server/generateModelsProperty.d.ts +0 -3
- package/dist/esm/internals/server/generateModelsProperty.mjs +0 -51
- package/dist/esm/internals/server/generateModelsProperty.mjs.map +0 -1
- package/dist/esm/internals/utils/clientProperties/generateEnumsProperty.d.ts +0 -3
- package/dist/esm/internals/utils/clientProperties/generateEnumsProperty.mjs +0 -18
- package/dist/esm/internals/utils/clientProperties/generateEnumsProperty.mjs.map +0 -1
- package/dist/esm/internals/utils/clientProperties/generateModelsProperty.d.ts +0 -4
- package/dist/esm/internals/utils/clientProperties/generateModelsProperty.mjs +0 -43
- package/dist/esm/internals/utils/clientProperties/generateModelsProperty.mjs.map +0 -1
- package/dist/esm/utils/findIndexByFields.d.ts +0 -9
- package/dist/esm/utils/findIndexByFields.mjs +0 -22
- package/dist/esm/utils/findIndexByFields.mjs.map +0 -1
- package/dist/esm/utils/resolveOwnerFields.d.ts +0 -12
- package/dist/esm/utils/resolveOwnerFields.mjs +0 -45
- package/dist/esm/utils/resolveOwnerFields.mjs.map +0 -1
- package/dist/esm/utils/resolvePKFields.d.ts +0 -13
- package/dist/esm/utils/resolvePKFields.mjs +0 -14
- package/dist/esm/utils/resolvePKFields.mjs.map +0 -1
- package/src/internals/APIClient.ts +0 -1076
- package/src/internals/clientUtils.ts +0 -37
- package/src/internals/generateCustomOperationsProperty.ts +0 -112
- package/src/internals/operations/custom.ts +0 -492
- package/src/internals/operations/get.ts +0 -140
- package/src/internals/operations/indexQuery.ts +0 -170
- package/src/internals/operations/list.ts +0 -135
- package/src/internals/operations/observeQuery.ts +0 -146
- package/src/internals/operations/subscription.ts +0 -75
- package/src/internals/server/generateModelsProperty.ts +0 -97
- package/src/internals/utils/clientProperties/generateEnumsProperty.ts +0 -34
- package/src/internals/utils/clientProperties/generateModelsProperty.ts +0 -81
- package/src/utils/findIndexByFields.ts +0 -31
- package/src/utils/resolveOwnerFields.ts +0 -77
- package/src/utils/resolvePKFields.ts +0 -23
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { graphQLOperationsInfo } from '../../APIClient.mjs';
|
|
2
|
-
import { listFactory } from '../../operations/list.mjs';
|
|
3
|
-
import { indexQueryFactory } from '../../operations/indexQuery.mjs';
|
|
4
|
-
import { getFactory } from '../../operations/get.mjs';
|
|
5
|
-
import { subscriptionFactory } from '../../operations/subscription.mjs';
|
|
6
|
-
import { observeQueryFactory } from '../../operations/observeQuery.mjs';
|
|
7
|
-
import { getSecondaryIndexesFromSchemaModel } from '../../clientUtils.mjs';
|
|
8
|
-
|
|
9
|
-
function generateModelsProperty(client, apiGraphQLConfig) {
|
|
10
|
-
const models = {};
|
|
11
|
-
const modelIntrospection = apiGraphQLConfig.modelIntrospection;
|
|
12
|
-
if (!modelIntrospection) {
|
|
13
|
-
return {};
|
|
14
|
-
}
|
|
15
|
-
const SUBSCRIPTION_OPS = ['ONCREATE', 'ONUPDATE', 'ONDELETE'];
|
|
16
|
-
for (const model of Object.values(modelIntrospection.models)) {
|
|
17
|
-
const { name } = model;
|
|
18
|
-
models[name] = {};
|
|
19
|
-
Object.entries(graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {
|
|
20
|
-
const operation = key;
|
|
21
|
-
if (operation === 'LIST') {
|
|
22
|
-
models[name][operationPrefix] = listFactory(client, modelIntrospection, model);
|
|
23
|
-
}
|
|
24
|
-
else if (SUBSCRIPTION_OPS.includes(operation)) {
|
|
25
|
-
models[name][operationPrefix] = subscriptionFactory(client, modelIntrospection, model, operation);
|
|
26
|
-
}
|
|
27
|
-
else if (operation === 'OBSERVE_QUERY') {
|
|
28
|
-
models[name][operationPrefix] = observeQueryFactory(models, model);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
const secondaryIdxs = getSecondaryIndexesFromSchemaModel(model);
|
|
35
|
-
for (const idx of secondaryIdxs) {
|
|
36
|
-
models[name][idx.queryField] = indexQueryFactory(client, modelIntrospection, model, idx);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return models;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export { generateModelsProperty };
|
|
43
|
-
//# sourceMappingURL=generateModelsProperty.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../../src/internals/utils/clientProperties/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,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,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,YAAY,IAAI,SAAS,KAAK,MAAM,EAAE;AACtC,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAC/F,aAAa;AACb,iBAAiB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AAC3D,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAClH,aAAa;AACb,iBAAiB,IAAI,SAAS,KAAK,eAAe,EAAE;AACpD,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACnF,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AACzG,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,aAAa,GAAG,kCAAkC,CAAC,KAAK,CAAC,CAAC;AACxE,QAAQ,KAAK,MAAM,GAAG,IAAI,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,9 +0,0 @@
|
|
|
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: (keyof T)[]): number;
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;"}
|
|
@@ -1,12 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
else if (rule.allow === 'groups' && rule.groupsField !== undefined) {
|
|
16
|
-
// only valid for dynamic group(s)
|
|
17
|
-
// static group auth will have an array of predefined groups in the attribute, groups: string[]
|
|
18
|
-
// but `groupsField` will be undefined
|
|
19
|
-
ownerFields.add(rule.groupsField);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return Array.from(ownerFields);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Type guard that identifies an auth attribute with an attached rules list that
|
|
28
|
-
* specifies an `allow` attribute at a minimum.
|
|
29
|
-
*
|
|
30
|
-
* @param attribute Any object. Ideally a model introspection schema model attribute
|
|
31
|
-
* @returns True if given object is an auth attribute
|
|
32
|
-
*/
|
|
33
|
-
function isAuthAttribute(attribute) {
|
|
34
|
-
if (attribute?.type === 'auth') {
|
|
35
|
-
if (typeof attribute?.properties === 'object') {
|
|
36
|
-
if (Array.isArray(attribute?.properties?.rules)) {
|
|
37
|
-
return (attribute?.properties?.rules).every(rule => !!rule.allow);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { resolveOwnerFields };
|
|
45
|
-
//# sourceMappingURL=resolveOwnerFields.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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 else if (rule.allow === 'groups' && rule.groupsField !== undefined) {\n // only valid for dynamic group(s)\n // static group auth will have an array of predefined groups in the attribute, groups: string[]\n // but `groupsField` will be undefined\n ownerFields.add(rule.groupsField);\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,qBAAqB,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;AACpF;AACA;AACA;AACA,oBAAoB,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACtD,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;;;;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;"}
|