@aws-amplify/data-schema 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{lib-esm/src → dist/cjs}/Authorization.js +149 -31
- package/dist/cjs/Authorization.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/ClientSchema.js +3 -1
- package/dist/cjs/ClientSchema.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/CombineSchema.js +3 -2
- package/dist/cjs/CombineSchema.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/CustomOperation.js +7 -3
- package/dist/cjs/CustomOperation.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/CustomType.js +3 -1
- package/dist/cjs/CustomType.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/EnumType.js +3 -1
- package/dist/cjs/EnumType.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/Handler.js +3 -1
- package/dist/cjs/Handler.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/MappedTypes/CustomOperations.js +3 -1
- package/dist/cjs/MappedTypes/CustomOperations.js.map +1 -0
- package/dist/cjs/MappedTypes/ExtractNonModelTypes.js +4 -0
- package/dist/cjs/MappedTypes/ExtractNonModelTypes.js.map +1 -0
- package/dist/cjs/MappedTypes/ImplicitFieldInjector.js +4 -0
- package/dist/cjs/MappedTypes/ImplicitFieldInjector.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/MappedTypes/MapSecondaryIndexes.js +3 -1
- package/dist/cjs/MappedTypes/MapSecondaryIndexes.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/MappedTypes/ModelMetadata.js +3 -1
- package/dist/cjs/MappedTypes/ModelMetadata.js.map +1 -0
- package/dist/cjs/MappedTypes/ResolveFieldProperties.js +4 -0
- package/dist/cjs/MappedTypes/ResolveFieldProperties.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/MappedTypes/ResolveSchema.js +3 -1
- package/dist/cjs/MappedTypes/ResolveSchema.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/ModelField.js +8 -3
- package/dist/cjs/ModelField.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/ModelIndex.js +3 -1
- package/dist/cjs/ModelIndex.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/ModelRelationalField.js +7 -10
- package/dist/cjs/ModelRelationalField.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/ModelSchema.js +10 -5
- package/dist/cjs/ModelSchema.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/ModelType.js +8 -3
- package/dist/cjs/ModelType.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/RefType.js +8 -5
- package/dist/cjs/RefType.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/SchemaProcessor.js +15 -61
- package/dist/cjs/SchemaProcessor.js.map +1 -0
- package/{lib-esm/src/index.js → dist/cjs/a.js} +4 -4
- package/dist/cjs/a.js.map +1 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/index.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/internals/index.js +3 -1
- package/dist/cjs/internals/index.js.map +1 -0
- package/dist/cjs/runtime/addSchemaToClient.js +17 -0
- package/dist/cjs/runtime/addSchemaToClient.js.map +1 -0
- package/dist/cjs/runtime/addSchemaToClientWithInstance.js +22 -0
- package/dist/cjs/runtime/addSchemaToClientWithInstance.js.map +1 -0
- package/dist/cjs/runtime/bridge-types.js +15 -0
- package/dist/cjs/runtime/bridge-types.js.map +1 -0
- package/dist/cjs/runtime/client/index.js +17 -0
- package/dist/cjs/runtime/client/index.js.map +1 -0
- package/dist/cjs/runtime/client/index.v3.js +7 -0
- package/dist/cjs/runtime/client/index.v3.js.map +1 -0
- package/dist/cjs/runtime/index.js +13 -0
- package/dist/cjs/runtime/index.js.map +1 -0
- package/dist/cjs/runtime/index.v3.js +13 -0
- package/dist/cjs/runtime/index.v3.js.map +1 -0
- package/dist/cjs/runtime/internals/APIClient.js +740 -0
- package/dist/cjs/runtime/internals/APIClient.js.map +1 -0
- package/dist/cjs/runtime/internals/clientUtils.js +29 -0
- package/dist/cjs/runtime/internals/clientUtils.js.map +1 -0
- package/dist/cjs/runtime/internals/generateCustomOperationsProperty.js +49 -0
- package/dist/cjs/runtime/internals/generateCustomOperationsProperty.js.map +1 -0
- package/dist/cjs/runtime/internals/index.js +21 -0
- package/dist/cjs/runtime/internals/index.js.map +1 -0
- package/dist/cjs/runtime/internals/operations/custom.js +356 -0
- package/dist/cjs/runtime/internals/operations/custom.js.map +1 -0
- package/dist/cjs/runtime/internals/operations/get.js +62 -0
- package/dist/cjs/runtime/internals/operations/get.js.map +1 -0
- package/dist/cjs/runtime/internals/operations/indexQuery.js +75 -0
- package/dist/cjs/runtime/internals/operations/indexQuery.js.map +1 -0
- package/dist/cjs/runtime/internals/operations/list.js +74 -0
- package/dist/cjs/runtime/internals/operations/list.js.map +1 -0
- package/dist/cjs/runtime/internals/operations/observeQuery.js +121 -0
- package/dist/cjs/runtime/internals/operations/observeQuery.js.map +1 -0
- package/dist/cjs/runtime/internals/operations/subscription.js +31 -0
- package/dist/cjs/runtime/internals/operations/subscription.js.map +1 -0
- package/dist/cjs/runtime/internals/server/generateModelsProperty.js +53 -0
- package/dist/cjs/runtime/internals/server/generateModelsProperty.js.map +1 -0
- package/dist/cjs/runtime/internals/server/index.js +8 -0
- package/dist/cjs/runtime/internals/server/index.js.map +1 -0
- package/dist/cjs/runtime/internals/utils/clientProperties/generateEnumsProperty.js +21 -0
- package/dist/cjs/runtime/internals/utils/clientProperties/generateEnumsProperty.js.map +1 -0
- package/dist/cjs/runtime/internals/utils/clientProperties/generateModelsProperty.js +45 -0
- package/dist/cjs/runtime/internals/utils/clientProperties/generateModelsProperty.js.map +1 -0
- package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.js +11 -0
- package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.js.map +1 -0
- package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.js +11 -0
- package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.js.map +1 -0
- package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.js +15 -0
- package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.js.map +1 -0
- package/dist/cjs/runtime/utils/findIndexByFields.js +25 -0
- package/dist/cjs/runtime/utils/findIndexByFields.js.map +1 -0
- package/dist/cjs/runtime/utils/index.js +11 -0
- package/dist/cjs/runtime/utils/index.js.map +1 -0
- package/dist/cjs/runtime/utils/resolveOwnerFields.js +48 -0
- package/dist/cjs/runtime/utils/resolveOwnerFields.js.map +1 -0
- package/dist/cjs/runtime/utils/resolvePKFields.js +17 -0
- package/dist/cjs/runtime/utils/resolvePKFields.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/util/Brand.js +3 -1
- package/dist/cjs/util/Brand.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/util/IndexLimit.js +3 -1
- package/dist/cjs/util/IndexLimit.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/util/SpreadTuple.js +3 -1
- package/dist/cjs/util/SpreadTuple.js.map +1 -0
- package/{lib-esm/src → dist/cjs}/util/index.js +3 -1
- package/dist/cjs/util/index.js.map +1 -0
- package/{lib-esm/src → dist/esm}/Authorization.d.ts +105 -31
- package/dist/esm/Authorization.mjs +446 -0
- package/dist/esm/Authorization.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/ClientSchema.d.ts +1 -2
- package/dist/esm/ClientSchema.mjs +2 -0
- package/dist/esm/ClientSchema.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/CombineSchema.d.ts +0 -1
- package/dist/esm/CombineSchema.mjs +39 -0
- package/dist/esm/CombineSchema.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/CustomOperation.d.ts +2 -3
- package/dist/esm/CustomOperation.mjs +67 -0
- package/dist/esm/CustomOperation.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/CustomType.d.ts +0 -1
- package/dist/esm/CustomType.mjs +13 -0
- package/dist/esm/CustomType.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/EnumType.d.ts +0 -1
- package/dist/esm/EnumType.mjs +16 -0
- package/dist/esm/EnumType.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/Handler.d.ts +0 -1
- package/dist/esm/Handler.mjs +48 -0
- package/dist/esm/Handler.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/MappedTypes/CustomOperations.d.ts +0 -1
- package/dist/esm/MappedTypes/CustomOperations.mjs +2 -0
- package/dist/esm/MappedTypes/CustomOperations.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/MappedTypes/ExtractNonModelTypes.d.ts +0 -1
- package/dist/esm/MappedTypes/ExtractNonModelTypes.mjs +2 -0
- package/dist/esm/MappedTypes/ExtractNonModelTypes.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/MappedTypes/ImplicitFieldInjector.d.ts +0 -1
- package/dist/esm/MappedTypes/ImplicitFieldInjector.mjs +2 -0
- package/dist/esm/MappedTypes/ImplicitFieldInjector.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/MappedTypes/MapSecondaryIndexes.d.ts +0 -1
- package/dist/esm/MappedTypes/MapSecondaryIndexes.mjs +2 -0
- package/dist/esm/MappedTypes/MapSecondaryIndexes.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/MappedTypes/ModelMetadata.d.ts +0 -1
- package/dist/esm/MappedTypes/ModelMetadata.mjs +2 -0
- package/dist/esm/MappedTypes/ModelMetadata.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/MappedTypes/ResolveFieldProperties.d.ts +0 -1
- package/dist/esm/MappedTypes/ResolveFieldProperties.mjs +2 -0
- package/dist/esm/MappedTypes/ResolveFieldProperties.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/MappedTypes/ResolveSchema.d.ts +0 -1
- package/dist/esm/MappedTypes/ResolveSchema.mjs +2 -0
- package/dist/esm/MappedTypes/ResolveSchema.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/ModelField.d.ts +2 -3
- package/dist/esm/ModelField.mjs +199 -0
- package/dist/esm/ModelField.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/ModelIndex.d.ts +0 -1
- package/dist/esm/ModelIndex.mjs +33 -0
- package/dist/esm/ModelIndex.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/ModelRelationalField.d.ts +3 -4
- package/dist/esm/ModelRelationalField.mjs +88 -0
- package/dist/esm/ModelRelationalField.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/ModelSchema.d.ts +3 -4
- package/dist/esm/ModelSchema.mjs +163 -0
- package/dist/esm/ModelSchema.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/ModelType.d.ts +2 -3
- package/dist/esm/ModelType.mjs +66 -0
- package/dist/esm/ModelType.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/RefType.d.ts +2 -3
- package/dist/esm/RefType.mjs +48 -0
- package/dist/esm/RefType.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/SchemaProcessor.d.ts +0 -1
- package/dist/esm/SchemaProcessor.mjs +926 -0
- package/dist/esm/SchemaProcessor.mjs.map +1 -0
- package/{lib-esm/src/index.d.ts → dist/esm/a.d.ts} +1 -3
- package/dist/esm/a.mjs +11 -0
- package/dist/esm/a.mjs.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/internals/index.d.ts +2 -0
- package/dist/esm/internals/index.mjs +2 -0
- package/dist/esm/internals/index.mjs.map +1 -0
- package/dist/esm/runtime/addSchemaToClient.d.ts +3 -0
- package/dist/esm/runtime/addSchemaToClient.mjs +17 -0
- package/dist/esm/runtime/addSchemaToClient.mjs.map +1 -0
- package/dist/esm/runtime/addSchemaToClientWithInstance.d.ts +3 -0
- package/dist/esm/runtime/addSchemaToClientWithInstance.mjs +22 -0
- package/dist/esm/runtime/addSchemaToClientWithInstance.mjs.map +1 -0
- package/dist/esm/runtime/bridge-types.d.ts +281 -0
- package/dist/esm/runtime/bridge-types.mjs +13 -0
- package/dist/esm/runtime/bridge-types.mjs.map +1 -0
- package/dist/esm/runtime/client/index.d.ts +571 -0
- package/dist/esm/runtime/client/index.mjs +2 -0
- package/dist/esm/runtime/client/index.mjs.map +1 -0
- package/dist/esm/runtime/client/index.v3.d.ts +15 -0
- package/dist/esm/runtime/client/index.v3.mjs +2 -0
- package/dist/esm/runtime/client/index.v3.mjs.map +1 -0
- package/dist/esm/runtime/index.d.ts +4 -0
- package/dist/esm/runtime/index.mjs +4 -0
- package/dist/esm/runtime/index.mjs.map +1 -0
- package/dist/esm/runtime/index.v3.d.ts +4 -0
- package/dist/esm/runtime/index.v3.mjs +4 -0
- package/dist/esm/runtime/index.v3.mjs.map +1 -0
- package/dist/esm/runtime/internals/APIClient.d.ts +125 -0
- package/dist/esm/runtime/internals/APIClient.mjs +728 -0
- package/dist/esm/runtime/internals/APIClient.mjs.map +1 -0
- package/dist/esm/runtime/internals/clientUtils.d.ts +6 -0
- package/dist/esm/runtime/internals/clientUtils.mjs +26 -0
- package/dist/esm/runtime/internals/clientUtils.mjs.map +1 -0
- package/dist/esm/runtime/internals/generateCustomOperationsProperty.d.ts +8 -0
- package/dist/esm/runtime/internals/generateCustomOperationsProperty.mjs +44 -0
- package/dist/esm/runtime/internals/generateCustomOperationsProperty.mjs.map +1 -0
- package/dist/esm/runtime/internals/index.d.ts +6 -0
- package/dist/esm/runtime/internals/index.mjs +7 -0
- package/dist/esm/runtime/internals/index.mjs.map +1 -0
- package/dist/esm/runtime/internals/operations/custom.d.ts +61 -0
- package/dist/esm/runtime/internals/operations/custom.mjs +354 -0
- package/dist/esm/runtime/internals/operations/custom.mjs.map +1 -0
- package/dist/esm/runtime/internals/operations/get.d.ts +3 -0
- package/dist/esm/runtime/internals/operations/get.mjs +60 -0
- package/dist/esm/runtime/internals/operations/get.mjs.map +1 -0
- package/dist/esm/runtime/internals/operations/indexQuery.d.ts +7 -0
- package/dist/esm/runtime/internals/operations/indexQuery.mjs +73 -0
- package/dist/esm/runtime/internals/operations/indexQuery.mjs.map +1 -0
- package/dist/esm/runtime/internals/operations/list.d.ts +2 -0
- package/dist/esm/runtime/internals/operations/list.mjs +72 -0
- package/dist/esm/runtime/internals/operations/list.mjs.map +1 -0
- package/dist/esm/runtime/internals/operations/observeQuery.d.ts +3 -0
- package/dist/esm/runtime/internals/operations/observeQuery.mjs +120 -0
- package/dist/esm/runtime/internals/operations/observeQuery.mjs.map +1 -0
- package/dist/esm/runtime/internals/operations/subscription.d.ts +3 -0
- package/dist/esm/runtime/internals/operations/subscription.mjs +29 -0
- package/dist/esm/runtime/internals/operations/subscription.mjs.map +1 -0
- package/dist/esm/runtime/internals/server/generateModelsProperty.d.ts +3 -0
- package/dist/esm/runtime/internals/server/generateModelsProperty.mjs +51 -0
- package/dist/esm/runtime/internals/server/generateModelsProperty.mjs.map +1 -0
- package/dist/esm/runtime/internals/server/index.d.ts +1 -0
- package/dist/esm/runtime/internals/server/index.mjs +2 -0
- package/dist/esm/runtime/internals/server/index.mjs.map +1 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateEnumsProperty.d.ts +3 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateEnumsProperty.mjs +18 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateEnumsProperty.mjs.map +1 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateModelsProperty.d.ts +3 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateModelsProperty.mjs +43 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateModelsProperty.mjs.map +1 -0
- package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.d.ts +2 -0
- package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs +8 -0
- package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs.map +1 -0
- package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.d.ts +8 -0
- package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs +8 -0
- package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs.map +1 -0
- package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.d.ts +2 -0
- package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs +12 -0
- package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs.map +1 -0
- package/dist/esm/runtime/utils/findIndexByFields.d.ts +9 -0
- package/dist/esm/runtime/utils/findIndexByFields.mjs +22 -0
- package/dist/esm/runtime/utils/findIndexByFields.mjs.map +1 -0
- package/dist/esm/runtime/utils/index.d.ts +2 -0
- package/dist/esm/runtime/utils/index.mjs +3 -0
- package/dist/esm/runtime/utils/index.mjs.map +1 -0
- package/dist/esm/runtime/utils/resolveOwnerFields.d.ts +12 -0
- package/dist/esm/runtime/utils/resolveOwnerFields.mjs +45 -0
- package/dist/esm/runtime/utils/resolveOwnerFields.mjs.map +1 -0
- package/dist/esm/runtime/utils/resolvePKFields.d.ts +13 -0
- package/dist/esm/runtime/utils/resolvePKFields.mjs +14 -0
- package/dist/esm/runtime/utils/resolvePKFields.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/util/Brand.d.ts +0 -1
- package/dist/esm/util/Brand.mjs +30 -0
- package/dist/esm/util/Brand.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/util/IndexLimit.d.ts +0 -1
- package/dist/esm/util/IndexLimit.mjs +2 -0
- package/dist/esm/util/IndexLimit.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/util/SpreadTuple.d.ts +0 -1
- package/dist/esm/util/SpreadTuple.mjs +2 -0
- package/dist/esm/util/SpreadTuple.mjs.map +1 -0
- package/{lib-esm/src → dist/esm}/util/index.d.ts +0 -1
- package/dist/esm/util/index.mjs +2 -0
- package/dist/esm/util/index.mjs.map +1 -0
- package/dist/meta/cjs.tsbuildinfo +1 -0
- package/internals/package.json +7 -5
- package/package.json +31 -14
- package/runtime/package.json +8 -0
- package/src/Authorization.ts +684 -0
- package/src/ClientSchema.ts +118 -0
- package/src/CombineSchema.ts +58 -0
- package/src/CustomOperation.ts +286 -0
- package/src/CustomType.ts +67 -0
- package/src/EnumType.ts +36 -0
- package/src/Handler.ts +127 -0
- package/src/MappedTypes/CustomOperations.ts +256 -0
- package/src/MappedTypes/ExtractNonModelTypes.ts +154 -0
- package/src/MappedTypes/ImplicitFieldInjector.ts +69 -0
- package/src/MappedTypes/MapSecondaryIndexes.ts +100 -0
- package/src/MappedTypes/ModelMetadata.ts +87 -0
- package/src/MappedTypes/ResolveFieldProperties.ts +254 -0
- package/src/MappedTypes/ResolveSchema.ts +148 -0
- package/src/ModelField.ts +304 -0
- package/src/ModelIndex.ts +91 -0
- package/src/ModelRelationalField.ts +263 -0
- package/src/ModelSchema.ts +437 -0
- package/src/ModelType.ts +345 -0
- package/src/RefType.ts +139 -0
- package/src/SchemaProcessor.ts +1516 -0
- package/src/a.ts +58 -0
- package/src/index.ts +6 -0
- package/src/internals/index.ts +2 -0
- package/src/runtime/addSchemaToClient.ts +45 -0
- package/src/runtime/addSchemaToClientWithInstance.ts +46 -0
- package/src/runtime/bridge-types.ts +382 -0
- package/src/runtime/client/index.ts +923 -0
- package/src/runtime/client/index.v3.ts +52 -0
- package/src/runtime/index.ts +7 -0
- package/src/runtime/index.v3.ts +7 -0
- package/src/runtime/internals/APIClient.ts +1082 -0
- package/src/runtime/internals/clientUtils.ts +37 -0
- package/src/runtime/internals/generateCustomOperationsProperty.ts +116 -0
- package/src/runtime/internals/index.ts +12 -0
- package/src/runtime/internals/operations/custom.ts +497 -0
- package/src/runtime/internals/operations/get.ts +150 -0
- package/src/runtime/internals/operations/indexQuery.ts +178 -0
- package/src/runtime/internals/operations/list.ts +143 -0
- package/src/runtime/internals/operations/observeQuery.ts +146 -0
- package/src/runtime/internals/operations/subscription.ts +78 -0
- package/src/runtime/internals/server/generateModelsProperty.ts +94 -0
- package/src/runtime/internals/server/index.ts +4 -0
- package/src/runtime/internals/utils/clientProperties/generateEnumsProperty.ts +34 -0
- package/src/runtime/internals/utils/clientProperties/generateModelsProperty.ts +88 -0
- package/src/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.ts +10 -0
- package/src/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.ts +13 -0
- package/src/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.ts +15 -0
- package/src/runtime/utils/findIndexByFields.ts +31 -0
- package/src/runtime/utils/index.ts +5 -0
- package/src/runtime/utils/resolveOwnerFields.ts +77 -0
- package/src/runtime/utils/resolvePKFields.ts +23 -0
- package/src/util/Brand.ts +45 -0
- package/src/util/IndexLimit.ts +12 -0
- package/src/util/SpreadTuple.ts +10 -0
- package/src/util/index.ts +3 -0
- package/lib-esm/index.d.ts +0 -5
- package/lib-esm/index.d.ts.map +0 -1
- package/lib-esm/index.js +0 -28
- package/lib-esm/src/Authorization.d.ts.map +0 -1
- package/lib-esm/src/ClientSchema.d.ts.map +0 -1
- package/lib-esm/src/CombineSchema.d.ts.map +0 -1
- package/lib-esm/src/CustomOperation.d.ts.map +0 -1
- package/lib-esm/src/CustomType.d.ts.map +0 -1
- package/lib-esm/src/EnumType.d.ts.map +0 -1
- package/lib-esm/src/Handler.d.ts.map +0 -1
- package/lib-esm/src/MappedTypes/CustomOperations.d.ts.map +0 -1
- package/lib-esm/src/MappedTypes/ExtractNonModelTypes.d.ts.map +0 -1
- package/lib-esm/src/MappedTypes/ExtractNonModelTypes.js +0 -2
- package/lib-esm/src/MappedTypes/ImplicitFieldInjector.d.ts.map +0 -1
- package/lib-esm/src/MappedTypes/ImplicitFieldInjector.js +0 -2
- package/lib-esm/src/MappedTypes/MapSecondaryIndexes.d.ts.map +0 -1
- package/lib-esm/src/MappedTypes/ModelMetadata.d.ts.map +0 -1
- package/lib-esm/src/MappedTypes/ResolveFieldProperties.d.ts.map +0 -1
- package/lib-esm/src/MappedTypes/ResolveFieldProperties.js +0 -2
- package/lib-esm/src/MappedTypes/ResolveSchema.d.ts.map +0 -1
- package/lib-esm/src/ModelField.d.ts.map +0 -1
- package/lib-esm/src/ModelIndex.d.ts.map +0 -1
- package/lib-esm/src/ModelRelationalField.d.ts.map +0 -1
- package/lib-esm/src/ModelSchema.d.ts.map +0 -1
- package/lib-esm/src/ModelType.d.ts.map +0 -1
- package/lib-esm/src/RefType.d.ts.map +0 -1
- package/lib-esm/src/SchemaProcessor.d.ts.map +0 -1
- package/lib-esm/src/index.d.ts.map +0 -1
- package/lib-esm/src/internals/index.d.ts +0 -2
- package/lib-esm/src/internals/index.d.ts.map +0 -1
- package/lib-esm/src/util/Brand.d.ts.map +0 -1
- package/lib-esm/src/util/IndexLimit.d.ts.map +0 -1
- package/lib-esm/src/util/SpreadTuple.d.ts.map +0 -1
- package/lib-esm/src/util/index.d.ts.map +0 -1
- package/lib-esm/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
const __data = Symbol('data');
|
|
2
|
+
/**
|
|
3
|
+
* All possible providers.
|
|
4
|
+
*
|
|
5
|
+
* This list should not be used if you need to restrict available providers
|
|
6
|
+
* according to an auth strategcy. E.g., `public` auth can only be facilitated
|
|
7
|
+
* by `apiKey` and `iam` providers.
|
|
8
|
+
*/
|
|
9
|
+
const Providers = [
|
|
10
|
+
'apiKey',
|
|
11
|
+
'iam',
|
|
12
|
+
'userPools',
|
|
13
|
+
'oidc',
|
|
14
|
+
'function',
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* The subset of auth providers that can facilitate `public` auth.
|
|
18
|
+
*/
|
|
19
|
+
const PublicProviders = ['apiKey', 'iam'];
|
|
20
|
+
/**
|
|
21
|
+
* The subset of auth providers that can facilitate `private` auth.
|
|
22
|
+
*/
|
|
23
|
+
const PrivateProviders = ['userPools', 'oidc', 'iam'];
|
|
24
|
+
/**
|
|
25
|
+
* The subset of auth providers that can facilitate `owner` auth.
|
|
26
|
+
*/
|
|
27
|
+
const OwnerProviders = ['userPools', 'oidc'];
|
|
28
|
+
/**
|
|
29
|
+
* The subset of auth providers that can facilitate `group` auth.
|
|
30
|
+
*/
|
|
31
|
+
const GroupProviders = ['userPools', 'oidc'];
|
|
32
|
+
/**
|
|
33
|
+
* The subset of auth providers that can facilitate `custom` auth.
|
|
34
|
+
*/
|
|
35
|
+
const CustomProviders = ['function'];
|
|
36
|
+
const Strategies = [
|
|
37
|
+
'public',
|
|
38
|
+
'private',
|
|
39
|
+
'owner',
|
|
40
|
+
'groups',
|
|
41
|
+
'custom',
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* The operations that can be performed against an API.
|
|
45
|
+
*/
|
|
46
|
+
const Operations = [
|
|
47
|
+
'create',
|
|
48
|
+
'update',
|
|
49
|
+
'delete',
|
|
50
|
+
'read',
|
|
51
|
+
'get',
|
|
52
|
+
'list',
|
|
53
|
+
'sync',
|
|
54
|
+
'listen',
|
|
55
|
+
'search',
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* The operations that can be performed against an API by a Lambda function.
|
|
59
|
+
*/
|
|
60
|
+
const ResourceOperations = ['query', 'mutate', 'listen'];
|
|
61
|
+
/**
|
|
62
|
+
* Creates a shallow copy of an object with an individual field pruned away.
|
|
63
|
+
*
|
|
64
|
+
* @param original The original object to prune.
|
|
65
|
+
* @param without The field to prune.
|
|
66
|
+
* @returns The pruned object.
|
|
67
|
+
*/
|
|
68
|
+
function omit(original, without) {
|
|
69
|
+
const pruned = { ...original };
|
|
70
|
+
delete pruned[without];
|
|
71
|
+
return pruned;
|
|
72
|
+
}
|
|
73
|
+
function to(operations) {
|
|
74
|
+
this[__data].operations = operations;
|
|
75
|
+
return omit(this, 'to');
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Specifies a property of the identity JWT to use in place of `sub::username`
|
|
79
|
+
* as the value to match against the owner field for authorization.
|
|
80
|
+
*
|
|
81
|
+
* @param this Authorization object to operate against.
|
|
82
|
+
* @param property A property of identity JWT.
|
|
83
|
+
* @returns A copy of the Authorization object with the claim attached.
|
|
84
|
+
*/
|
|
85
|
+
function identityClaim(property) {
|
|
86
|
+
this[__data].identityClaim = property;
|
|
87
|
+
return omit(this, 'identityClaim');
|
|
88
|
+
}
|
|
89
|
+
function withClaimIn(property) {
|
|
90
|
+
this[__data].groupClaim = property;
|
|
91
|
+
return omit(this, 'withClaimIn');
|
|
92
|
+
}
|
|
93
|
+
function validateProvider(needle, haystack) {
|
|
94
|
+
if (needle && !haystack.includes(needle)) {
|
|
95
|
+
throw new Error(`Invalid provider (${needle}) given!`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function authData(defaults, builderMethods) {
|
|
99
|
+
return {
|
|
100
|
+
[__data]: {
|
|
101
|
+
strategy: 'public',
|
|
102
|
+
provider: undefined,
|
|
103
|
+
operations: undefined,
|
|
104
|
+
groupOrOwnerField: undefined,
|
|
105
|
+
multiOwner: false,
|
|
106
|
+
identityClaim: undefined,
|
|
107
|
+
groups: undefined,
|
|
108
|
+
...defaults,
|
|
109
|
+
},
|
|
110
|
+
...builderMethods,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Defines an authorization rule for your data models and fields. First choose an authorization strategy (`public`,
|
|
115
|
+
* `private`, `owner`, `group`, or `custom`), then choose an auth provider (`apiKey`, `iam`, `userPools`, `oidc`, or `function`)
|
|
116
|
+
* and optionally use `.to(...)` to specify the operations that can be performed against your data models and fields.
|
|
117
|
+
*/
|
|
118
|
+
const allow = {
|
|
119
|
+
/**
|
|
120
|
+
* Authorize unauthenticated users by using API key based authorization.
|
|
121
|
+
* @returns an authorization rule for unauthenticated users
|
|
122
|
+
*/
|
|
123
|
+
publicApiKey() {
|
|
124
|
+
return authData({
|
|
125
|
+
strategy: 'public',
|
|
126
|
+
provider: 'apiKey',
|
|
127
|
+
}, {
|
|
128
|
+
to,
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* Authorize unauthenticated users by using IAM based authorization.
|
|
133
|
+
* @returns an authorization rule for unauthenticated users
|
|
134
|
+
*/
|
|
135
|
+
guest() {
|
|
136
|
+
return authData({
|
|
137
|
+
strategy: 'public',
|
|
138
|
+
provider: 'iam',
|
|
139
|
+
}, {
|
|
140
|
+
to,
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
* Authorize authenticated users. By default, `.private()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
145
|
+
* use `.authenticated("iam")` or `.authenticated("oidc")` to use IAM or OIDC based authorization for authenticated users.
|
|
146
|
+
* @param provider the authentication provider - supports "userPools", "iam", or "oidc"
|
|
147
|
+
* @returns an authorization rule for authenticated users
|
|
148
|
+
*/
|
|
149
|
+
authenticated(provider) {
|
|
150
|
+
validateProvider(provider, PrivateProviders);
|
|
151
|
+
return authData({
|
|
152
|
+
strategy: 'private',
|
|
153
|
+
provider,
|
|
154
|
+
}, {
|
|
155
|
+
to,
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
/**
|
|
159
|
+
* Authorize access on a per-user (owner) basis. By setting owner-based authorization, a new `owner: a.string()`
|
|
160
|
+
* field will be added to the model to store which user "owns" the item. Upon item creation, the "owner field" is
|
|
161
|
+
* auto-populated with the authenticated user's information. If you want to specify which field should be used as
|
|
162
|
+
* the owner field, you can use the `ownerDefinedIn` builder function instead.
|
|
163
|
+
*
|
|
164
|
+
* By default, `.owner()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
165
|
+
* use `.owner("oidc")` to use OIDC based authentication to designate the owner.
|
|
166
|
+
*
|
|
167
|
+
* To change the specific claim that should be used as the user identifier within the owner field, chain the
|
|
168
|
+
* `.identityClaim(...)` method.
|
|
169
|
+
*
|
|
170
|
+
* @param provider the authentication provider - supports "userPools", "iam", or "oidc"
|
|
171
|
+
* @returns an authorization rule for authenticated users
|
|
172
|
+
*/
|
|
173
|
+
owner(provider) {
|
|
174
|
+
validateProvider(provider, OwnerProviders);
|
|
175
|
+
return authData({
|
|
176
|
+
strategy: 'owner',
|
|
177
|
+
provider,
|
|
178
|
+
groupOrOwnerField: 'owner',
|
|
179
|
+
}, {
|
|
180
|
+
to,
|
|
181
|
+
identityClaim,
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
/**
|
|
185
|
+
* Authorize access on a per-user (owner) basis with specifying which field should be used as the owner field.
|
|
186
|
+
*
|
|
187
|
+
* By default, `.owner()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
188
|
+
* use `.ownerDefinedIn("owner", "oidc")` to use OIDC based authentication to designate the owner.
|
|
189
|
+
*
|
|
190
|
+
* To change the specific claim that should be used as the user identifier within the owner field, chain the
|
|
191
|
+
* `.identityClaim(...)` method.
|
|
192
|
+
*
|
|
193
|
+
* @param ownerField the field that contains the owner information
|
|
194
|
+
* @param provider the authentication provider - supports "userPools", "iam", or "oidc"
|
|
195
|
+
* @returns an authorization rule for authenticated users
|
|
196
|
+
*/
|
|
197
|
+
ownerDefinedIn(ownerField, provider) {
|
|
198
|
+
validateProvider(provider, OwnerProviders);
|
|
199
|
+
return authData({
|
|
200
|
+
strategy: 'owner',
|
|
201
|
+
provider,
|
|
202
|
+
groupOrOwnerField: ownerField,
|
|
203
|
+
}, {
|
|
204
|
+
to,
|
|
205
|
+
identityClaim,
|
|
206
|
+
});
|
|
207
|
+
},
|
|
208
|
+
/**
|
|
209
|
+
* Authorize access for multi-user / multi-owner access. By setting multi-owner-based authorization, a new `owners: a.string().array()`
|
|
210
|
+
* field will be added to the model to store which users "own" the item. Upon item creation, the "owners field" is
|
|
211
|
+
* auto-populated with the authenticated user's information. To grant other users access to the item, append their user identifier into the `owners` array.
|
|
212
|
+
*
|
|
213
|
+
* You can specify which field should be used as the owners field by passing the `ownersField` parameter.
|
|
214
|
+
*
|
|
215
|
+
* By default, `.ownersDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
216
|
+
* use `.ownersDefinedIn("owners", "oidc")` to use OIDC based authentication to designate the owner.
|
|
217
|
+
*
|
|
218
|
+
* To change the specific claim that should be used as the user identifier within the owners field, chain the
|
|
219
|
+
* `.identityClaim(...)` method.
|
|
220
|
+
*
|
|
221
|
+
* @param ownersField the field that contains the owners information
|
|
222
|
+
* @param provider the authentication provider - supports "userPools", "iam", or "oidc"
|
|
223
|
+
* @returns an authorization rule for authenticated users
|
|
224
|
+
*/
|
|
225
|
+
ownersDefinedIn(ownersField, provider) {
|
|
226
|
+
validateProvider(provider, OwnerProviders);
|
|
227
|
+
return authData({
|
|
228
|
+
strategy: 'owner',
|
|
229
|
+
provider,
|
|
230
|
+
groupOrOwnerField: ownersField,
|
|
231
|
+
multiOwner: true,
|
|
232
|
+
}, {
|
|
233
|
+
to,
|
|
234
|
+
identityClaim,
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
/**
|
|
238
|
+
* Authorize a specific user group. Provide the name of the specific user group to have access.
|
|
239
|
+
*
|
|
240
|
+
* By default, `.group()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
241
|
+
* use `.group("group-name", "oidc")` to use OIDC based authentication to designate the user group.
|
|
242
|
+
*
|
|
243
|
+
* To change the specific claim that should be used as the user group identifier, chain the
|
|
244
|
+
* `.withClaimIn(...)` method.
|
|
245
|
+
* @param group the name of the group to authorize
|
|
246
|
+
* @param provider the authentication provider - supports "userPools" or "oidc"
|
|
247
|
+
* @returns an authorization rule to grant access by a specific group
|
|
248
|
+
*/
|
|
249
|
+
group(group, provider) {
|
|
250
|
+
return authData({
|
|
251
|
+
strategy: 'groups',
|
|
252
|
+
provider,
|
|
253
|
+
groups: [group],
|
|
254
|
+
}, {
|
|
255
|
+
to,
|
|
256
|
+
withClaimIn,
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
/**
|
|
260
|
+
* Authorize multiple specific user groups. Provide the names of the specific user groups to have access.
|
|
261
|
+
*
|
|
262
|
+
* By default, `.groups()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
263
|
+
* use `.groups(["group-a", "group-b"], "oidc")` to use OIDC based authentication to designate the user group.
|
|
264
|
+
*
|
|
265
|
+
* To change the specific claim that should be used as the user group identifier, chain the
|
|
266
|
+
* `.withClaimIn(...)` method.
|
|
267
|
+
* @param groups the names of the group to authorize defined as an array
|
|
268
|
+
* @param provider the authentication provider - supports "userPools" or "oidc"
|
|
269
|
+
* @returns an authorization rule to grant access by a specific group
|
|
270
|
+
*/
|
|
271
|
+
groups(groups, provider) {
|
|
272
|
+
return authData({
|
|
273
|
+
strategy: 'groups',
|
|
274
|
+
provider,
|
|
275
|
+
groups,
|
|
276
|
+
}, {
|
|
277
|
+
to,
|
|
278
|
+
withClaimIn,
|
|
279
|
+
});
|
|
280
|
+
},
|
|
281
|
+
/**
|
|
282
|
+
* Authorize if a user is part of a group defined in a data model field.
|
|
283
|
+
*
|
|
284
|
+
* By default, `.groupDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
285
|
+
* use `.groupDefinedIn("field-name", "oidc")` to use OIDC based authentication to designate the user group.
|
|
286
|
+
*
|
|
287
|
+
* To change the specific claim that should be used as the user group identifier within the groups field, chain the
|
|
288
|
+
* `.withClaimIn(...)` method.
|
|
289
|
+
* @param groupsField the field that should store the authorized user group information
|
|
290
|
+
* @param provider the authentication provider - supports "userPools" or "oidc"
|
|
291
|
+
* @returns an authorization rule to grant access by a specific group
|
|
292
|
+
*/
|
|
293
|
+
groupDefinedIn(groupsField, provider) {
|
|
294
|
+
return authData({
|
|
295
|
+
strategy: 'groups',
|
|
296
|
+
provider,
|
|
297
|
+
groupOrOwnerField: groupsField,
|
|
298
|
+
}, {
|
|
299
|
+
to,
|
|
300
|
+
withClaimIn,
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
/**
|
|
304
|
+
* Authorize if a user is part of a one of the groups defined in a data model field.
|
|
305
|
+
*
|
|
306
|
+
* By default, `.groupsDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
307
|
+
* use `.groupsDefinedIn("field-name", "oidc")` to use OIDC based authentication to designate the user group.
|
|
308
|
+
*
|
|
309
|
+
* To change the specific claim that should be used as the user group identifier within the groups field, chain the
|
|
310
|
+
* `.withClaimIn(...)` method.
|
|
311
|
+
* @param groupsField the field that should store the list of authorized user groups
|
|
312
|
+
* @param provider the authentication provider - supports "userPools" or "oidc"
|
|
313
|
+
* @returns an authorization rule to grant access by a specific group
|
|
314
|
+
*/
|
|
315
|
+
groupsDefinedIn(groupsField, provider) {
|
|
316
|
+
return authData({
|
|
317
|
+
strategy: 'groups',
|
|
318
|
+
provider,
|
|
319
|
+
groupOrOwnerField: groupsField,
|
|
320
|
+
multiOwner: true,
|
|
321
|
+
}, {
|
|
322
|
+
to,
|
|
323
|
+
withClaimIn,
|
|
324
|
+
});
|
|
325
|
+
},
|
|
326
|
+
custom(provider) {
|
|
327
|
+
return authData({
|
|
328
|
+
strategy: 'custom',
|
|
329
|
+
provider,
|
|
330
|
+
}, {
|
|
331
|
+
to,
|
|
332
|
+
});
|
|
333
|
+
},
|
|
334
|
+
resource(fn) {
|
|
335
|
+
return resourceAuthData(fn, {
|
|
336
|
+
to: resourceTo,
|
|
337
|
+
});
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* This is a copy of the {@link allow} defined above, with modifications for custom operations.
|
|
342
|
+
*
|
|
343
|
+
* Removed builder methods:
|
|
344
|
+
*
|
|
345
|
+
* * `owner`
|
|
346
|
+
* * `ownerDefinedIn`
|
|
347
|
+
* * `ownersDefinedIn`
|
|
348
|
+
* * `groupDefinedIn`
|
|
349
|
+
* * `groupsDefinedIn`
|
|
350
|
+
* * `resource`
|
|
351
|
+
* * `.to()` builder method from each available rule builder
|
|
352
|
+
*/
|
|
353
|
+
const allowForCustomOperations = {
|
|
354
|
+
/**
|
|
355
|
+
* Authorize unauthenticated users by using API key based authorization.
|
|
356
|
+
* @returns an authorization rule for unauthenticated users
|
|
357
|
+
*/
|
|
358
|
+
publicApiKey() {
|
|
359
|
+
return authData({
|
|
360
|
+
strategy: 'public',
|
|
361
|
+
provider: 'apiKey',
|
|
362
|
+
}, {});
|
|
363
|
+
},
|
|
364
|
+
/**
|
|
365
|
+
* Authorize unauthenticated users by using IAM based authorization.
|
|
366
|
+
* @returns an authorization rule for unauthenticated users
|
|
367
|
+
*/
|
|
368
|
+
guest() {
|
|
369
|
+
return authData({
|
|
370
|
+
strategy: 'public',
|
|
371
|
+
provider: 'iam',
|
|
372
|
+
}, {});
|
|
373
|
+
},
|
|
374
|
+
/**
|
|
375
|
+
* Authorize authenticated users. By default, `.private()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
376
|
+
* use `.authenticated("iam")` or `.authenticated("oidc")` to use IAM or OIDC based authorization for authenticated users.
|
|
377
|
+
* @param provider the authentication provider - supports "userPools", "iam", or "oidc"
|
|
378
|
+
* @returns an authorization rule for authenticated users
|
|
379
|
+
*/
|
|
380
|
+
authenticated(provider) {
|
|
381
|
+
validateProvider(provider, PrivateProviders);
|
|
382
|
+
return authData({
|
|
383
|
+
strategy: 'private',
|
|
384
|
+
provider,
|
|
385
|
+
}, {});
|
|
386
|
+
},
|
|
387
|
+
/**
|
|
388
|
+
* Authorize a specific user group. Provide the name of the specific user group to have access.
|
|
389
|
+
*
|
|
390
|
+
* By default, `.group()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
391
|
+
* use `.group("group-name", "oidc")` to use OIDC based authentication to designate the user group.
|
|
392
|
+
*
|
|
393
|
+
* @param group the name of the group to authorize
|
|
394
|
+
* @param provider the authentication provider - supports "userPools" or "oidc"
|
|
395
|
+
* @returns an authorization rule to grant access by a specific group
|
|
396
|
+
*/
|
|
397
|
+
group(group, provider) {
|
|
398
|
+
return authData({
|
|
399
|
+
strategy: 'groups',
|
|
400
|
+
provider,
|
|
401
|
+
groups: [group],
|
|
402
|
+
}, {});
|
|
403
|
+
},
|
|
404
|
+
/**
|
|
405
|
+
* Authorize multiple specific user groups. Provide the names of the specific user groups to have access.
|
|
406
|
+
*
|
|
407
|
+
* By default, `.groups()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
408
|
+
* use `.groups(["group-a", "group-b"], "oidc")` to use OIDC based authentication to designate the user group.
|
|
409
|
+
*
|
|
410
|
+
* @param groups the names of the group to authorize defined as an array
|
|
411
|
+
* @param provider the authentication provider - supports "userPools" or "oidc"
|
|
412
|
+
* @returns an authorization rule to grant access by a specific group
|
|
413
|
+
*/
|
|
414
|
+
groups(groups, provider) {
|
|
415
|
+
return authData({
|
|
416
|
+
strategy: 'groups',
|
|
417
|
+
provider,
|
|
418
|
+
groups,
|
|
419
|
+
}, {});
|
|
420
|
+
},
|
|
421
|
+
custom(provider) {
|
|
422
|
+
return authData({
|
|
423
|
+
strategy: 'custom',
|
|
424
|
+
provider,
|
|
425
|
+
}, {});
|
|
426
|
+
},
|
|
427
|
+
};
|
|
428
|
+
function resourceTo(operations) {
|
|
429
|
+
this[__data].operations = operations;
|
|
430
|
+
return omit(this, 'to');
|
|
431
|
+
}
|
|
432
|
+
function resourceAuthData(resource, builderMethods) {
|
|
433
|
+
return {
|
|
434
|
+
[__data]: {
|
|
435
|
+
strategy: 'resource',
|
|
436
|
+
resource,
|
|
437
|
+
},
|
|
438
|
+
...builderMethods,
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
const accessData = (authorization) => authorization[__data];
|
|
442
|
+
// TODO: delete when we make resource auth available at each level in the schema (model, field)
|
|
443
|
+
const accessSchemaData = (authorization) => authorization[__data];
|
|
444
|
+
|
|
445
|
+
export { CustomProviders, GroupProviders, Operations, OwnerProviders, PrivateProviders, Providers, PublicProviders, ResourceOperations, Strategies, accessData, accessSchemaData, allow, allowForCustomOperations };
|
|
446
|
+
//# sourceMappingURL=Authorization.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Authorization.mjs","sources":["../../src/Authorization.ts"],"sourcesContent":["const __data = Symbol('data');\n/**\n * All possible providers.\n *\n * This list should not be used if you need to restrict available providers\n * according to an auth strategcy. E.g., `public` auth can only be facilitated\n * by `apiKey` and `iam` providers.\n */\nexport const Providers = [\n 'apiKey',\n 'iam',\n 'userPools',\n 'oidc',\n 'function',\n];\n/**\n * The subset of auth providers that can facilitate `public` auth.\n */\nexport const PublicProviders = ['apiKey', 'iam'];\n/**\n * The subset of auth providers that can facilitate `private` auth.\n */\nexport const PrivateProviders = ['userPools', 'oidc', 'iam'];\n/**\n * The subset of auth providers that can facilitate `owner` auth.\n */\nexport const OwnerProviders = ['userPools', 'oidc'];\n/**\n * The subset of auth providers that can facilitate `group` auth.\n */\nexport const GroupProviders = ['userPools', 'oidc'];\n/**\n * The subset of auth providers that can facilitate `custom` auth.\n */\nexport const CustomProviders = ['function'];\nexport const Strategies = [\n 'public',\n 'private',\n 'owner',\n 'groups',\n 'custom',\n];\n/**\n * The operations that can be performed against an API.\n */\nexport const Operations = [\n 'create',\n 'update',\n 'delete',\n 'read',\n 'get',\n 'list',\n 'sync',\n 'listen',\n 'search',\n];\n/**\n * The operations that can be performed against an API by a Lambda function.\n */\nexport const ResourceOperations = ['query', 'mutate', 'listen'];\n/**\n * Creates a shallow copy of an object with an individual field pruned away.\n *\n * @param original The original object to prune.\n * @param without The field to prune.\n * @returns The pruned object.\n */\nfunction omit(original, without) {\n const pruned = { ...original };\n delete pruned[without];\n return pruned;\n}\nfunction to(operations) {\n this[__data].operations = operations;\n return omit(this, 'to');\n}\n/**\n * Specifies a property of the identity JWT to use in place of `sub::username`\n * as the value to match against the owner field for authorization.\n *\n * @param this Authorization object to operate against.\n * @param property A property of identity JWT.\n * @returns A copy of the Authorization object with the claim attached.\n */\nfunction identityClaim(property) {\n this[__data].identityClaim = property;\n return omit(this, 'identityClaim');\n}\nfunction withClaimIn(property) {\n this[__data].groupClaim = property;\n return omit(this, 'withClaimIn');\n}\nfunction validateProvider(needle, haystack) {\n if (needle && !haystack.includes(needle)) {\n throw new Error(`Invalid provider (${needle}) given!`);\n }\n}\nfunction authData(defaults, builderMethods) {\n return {\n [__data]: {\n strategy: 'public',\n provider: undefined,\n operations: undefined,\n groupOrOwnerField: undefined,\n multiOwner: false,\n identityClaim: undefined,\n groups: undefined,\n ...defaults,\n },\n ...builderMethods,\n };\n}\n/**\n * Defines an authorization rule for your data models and fields. First choose an authorization strategy (`public`,\n * `private`, `owner`, `group`, or `custom`), then choose an auth provider (`apiKey`, `iam`, `userPools`, `oidc`, or `function`)\n * and optionally use `.to(...)` to specify the operations that can be performed against your data models and fields.\n */\nexport const allow = {\n /**\n * Authorize unauthenticated users by using API key based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n publicApiKey() {\n return authData({\n strategy: 'public',\n provider: 'apiKey',\n }, {\n to,\n });\n },\n /**\n * Authorize unauthenticated users by using IAM based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n guest() {\n return authData({\n strategy: 'public',\n provider: 'iam',\n }, {\n to,\n });\n },\n /**\n * Authorize authenticated users. By default, `.private()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.authenticated(\"iam\")` or `.authenticated(\"oidc\")` to use IAM or OIDC based authorization for authenticated users.\n * @param provider the authentication provider - supports \"userPools\", \"iam\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n authenticated(provider) {\n validateProvider(provider, PrivateProviders);\n return authData({\n strategy: 'private',\n provider,\n }, {\n to,\n });\n },\n /**\n * Authorize access on a per-user (owner) basis. By setting owner-based authorization, a new `owner: a.string()`\n * field will be added to the model to store which user \"owns\" the item. Upon item creation, the \"owner field\" is\n * auto-populated with the authenticated user's information. If you want to specify which field should be used as\n * the owner field, you can use the `ownerDefinedIn` builder function instead.\n *\n * By default, `.owner()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.owner(\"oidc\")` to use OIDC based authentication to designate the owner.\n *\n * To change the specific claim that should be used as the user identifier within the owner field, chain the\n * `.identityClaim(...)` method.\n *\n * @param provider the authentication provider - supports \"userPools\", \"iam\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n owner(provider) {\n validateProvider(provider, OwnerProviders);\n return authData({\n strategy: 'owner',\n provider,\n groupOrOwnerField: 'owner',\n }, {\n to,\n identityClaim,\n });\n },\n /**\n * Authorize access on a per-user (owner) basis with specifying which field should be used as the owner field.\n *\n * By default, `.owner()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.ownerDefinedIn(\"owner\", \"oidc\")` to use OIDC based authentication to designate the owner.\n *\n * To change the specific claim that should be used as the user identifier within the owner field, chain the\n * `.identityClaim(...)` method.\n *\n * @param ownerField the field that contains the owner information\n * @param provider the authentication provider - supports \"userPools\", \"iam\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n ownerDefinedIn(ownerField, provider) {\n validateProvider(provider, OwnerProviders);\n return authData({\n strategy: 'owner',\n provider,\n groupOrOwnerField: ownerField,\n }, {\n to,\n identityClaim,\n });\n },\n /**\n * Authorize access for multi-user / multi-owner access. By setting multi-owner-based authorization, a new `owners: a.string().array()`\n * field will be added to the model to store which users \"own\" the item. Upon item creation, the \"owners field\" is\n * auto-populated with the authenticated user's information. To grant other users access to the item, append their user identifier into the `owners` array.\n *\n * You can specify which field should be used as the owners field by passing the `ownersField` parameter.\n *\n * By default, `.ownersDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.ownersDefinedIn(\"owners\", \"oidc\")` to use OIDC based authentication to designate the owner.\n *\n * To change the specific claim that should be used as the user identifier within the owners field, chain the\n * `.identityClaim(...)` method.\n *\n * @param ownersField the field that contains the owners information\n * @param provider the authentication provider - supports \"userPools\", \"iam\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n ownersDefinedIn(ownersField, provider) {\n validateProvider(provider, OwnerProviders);\n return authData({\n strategy: 'owner',\n provider,\n groupOrOwnerField: ownersField,\n multiOwner: true,\n }, {\n to,\n identityClaim,\n });\n },\n /**\n * Authorize a specific user group. Provide the name of the specific user group to have access.\n *\n * By default, `.group()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.group(\"group-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier, chain the\n * `.withClaimIn(...)` method.\n * @param group the name of the group to authorize\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n group(group, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups: [group],\n }, {\n to,\n withClaimIn,\n });\n },\n /**\n * Authorize multiple specific user groups. Provide the names of the specific user groups to have access.\n *\n * By default, `.groups()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groups([\"group-a\", \"group-b\"], \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier, chain the\n * `.withClaimIn(...)` method.\n * @param groups the names of the group to authorize defined as an array\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groups(groups, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups,\n }, {\n to,\n withClaimIn,\n });\n },\n /**\n * Authorize if a user is part of a group defined in a data model field.\n *\n * By default, `.groupDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groupDefinedIn(\"field-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier within the groups field, chain the\n * `.withClaimIn(...)` method.\n * @param groupsField the field that should store the authorized user group information\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groupDefinedIn(groupsField, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groupOrOwnerField: groupsField,\n }, {\n to,\n withClaimIn,\n });\n },\n /**\n * Authorize if a user is part of a one of the groups defined in a data model field.\n *\n * By default, `.groupsDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groupsDefinedIn(\"field-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier within the groups field, chain the\n * `.withClaimIn(...)` method.\n * @param groupsField the field that should store the list of authorized user groups\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groupsDefinedIn(groupsField, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groupOrOwnerField: groupsField,\n multiOwner: true,\n }, {\n to,\n withClaimIn,\n });\n },\n custom(provider) {\n return authData({\n strategy: 'custom',\n provider,\n }, {\n to,\n });\n },\n resource(fn) {\n return resourceAuthData(fn, {\n to: resourceTo,\n });\n },\n};\n/**\n * This is a copy of the {@link allow} defined above, with modifications for custom operations.\n *\n * Removed builder methods:\n *\n * * `owner`\n * * `ownerDefinedIn`\n * * `ownersDefinedIn`\n * * `groupDefinedIn`\n * * `groupsDefinedIn`\n * * `resource`\n * * `.to()` builder method from each available rule builder\n */\nexport const allowForCustomOperations = {\n /**\n * Authorize unauthenticated users by using API key based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n publicApiKey() {\n return authData({\n strategy: 'public',\n provider: 'apiKey',\n }, {});\n },\n /**\n * Authorize unauthenticated users by using IAM based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n guest() {\n return authData({\n strategy: 'public',\n provider: 'iam',\n }, {});\n },\n /**\n * Authorize authenticated users. By default, `.private()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.authenticated(\"iam\")` or `.authenticated(\"oidc\")` to use IAM or OIDC based authorization for authenticated users.\n * @param provider the authentication provider - supports \"userPools\", \"iam\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n authenticated(provider) {\n validateProvider(provider, PrivateProviders);\n return authData({\n strategy: 'private',\n provider,\n }, {});\n },\n /**\n * Authorize a specific user group. Provide the name of the specific user group to have access.\n *\n * By default, `.group()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.group(\"group-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * @param group the name of the group to authorize\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n group(group, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups: [group],\n }, {});\n },\n /**\n * Authorize multiple specific user groups. Provide the names of the specific user groups to have access.\n *\n * By default, `.groups()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groups([\"group-a\", \"group-b\"], \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * @param groups the names of the group to authorize defined as an array\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groups(groups, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups,\n }, {});\n },\n custom(provider) {\n return authData({\n strategy: 'custom',\n provider,\n }, {});\n },\n};\nfunction resourceTo(operations) {\n this[__data].operations = operations;\n return omit(this, 'to');\n}\nfunction resourceAuthData(resource, builderMethods) {\n return {\n [__data]: {\n strategy: 'resource',\n resource,\n },\n ...builderMethods,\n };\n}\nexport const accessData = (authorization) => authorization[__data];\n// TODO: delete when we make resource auth available at each level in the schema (model, field)\nexport const accessSchemaData = (authorization) => authorization[__data];\n"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,SAAS,GAAG;AACzB,IAAI,QAAQ;AACZ,IAAI,KAAK;AACT,IAAI,WAAW;AACf,IAAI,MAAM;AACV,IAAI,UAAU;AACd,EAAE;AACF;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE;AACjD;AACA;AACA;AACY,MAAC,gBAAgB,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE;AAC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QAAQ,GAAG,cAAc;AACzB,KAAK,CAAC;AACN,CAAC;AACW,MAAC,UAAU,GAAG,CAAC,aAAa,KAAK,aAAa,CAAC,MAAM,EAAE;AACnE;AACY,MAAC,gBAAgB,GAAG,CAAC,aAAa,KAAK,aAAa,CAAC,MAAM;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { __modelMeta__ } from '
|
|
1
|
+
import type { __modelMeta__ } from './runtime/client';
|
|
2
2
|
import type { GenericModelSchema, RDSModelSchema } from './ModelSchema';
|
|
3
3
|
import type { ResolveSchema, SchemaTypes } from './MappedTypes/ResolveSchema';
|
|
4
4
|
import type { ResolveFieldProperties, ResolveStaticFieldProperties } from './MappedTypes/ResolveFieldProperties';
|
|
@@ -45,4 +45,3 @@ type InternalCombinedSchema<Combined extends CombinedModelSchema<any>, ClientSch
|
|
|
45
45
|
}>;
|
|
46
46
|
};
|
|
47
47
|
export {};
|
|
48
|
-
//# sourceMappingURL=ClientSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientSchema.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -16,4 +16,3 @@ export type CombinedModelSchema<Schemas extends GenericModelSchema<any>[]> = Com
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function combine<Schema extends GenericModelSchema<any>[]>(schemas: [...Schema]): CombinedModelSchema<Schema>;
|
|
18
18
|
export {};
|
|
19
|
-
//# sourceMappingURL=CombineSchema.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { brand } from './util/Brand.mjs';
|
|
2
|
+
|
|
3
|
+
const CombinedSchemaBrandName = 'CombinedSchema';
|
|
4
|
+
const combinedSchemaBrand = brand(CombinedSchemaBrandName);
|
|
5
|
+
/**
|
|
6
|
+
* The interface for merging up to 50 schemas into a single API.
|
|
7
|
+
* @param schemas The schemas to combine into a single API
|
|
8
|
+
* @returns An API and data model definition to be deployed with Amplify (Gen 2) experience (`processSchema(...)`)
|
|
9
|
+
* or with the Amplify Data CDK construct (`@aws-amplify/data-construct`)
|
|
10
|
+
*/
|
|
11
|
+
function combine(schemas) {
|
|
12
|
+
return internalCombine(schemas);
|
|
13
|
+
}
|
|
14
|
+
function internalCombine(schemas) {
|
|
15
|
+
validateDuplicateTypeNames(schemas);
|
|
16
|
+
return {
|
|
17
|
+
...combinedSchemaBrand,
|
|
18
|
+
schemas: schemas,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function validateDuplicateTypeNames(schemas) {
|
|
22
|
+
const allSchemaKeys = schemas.flatMap((s) => Object.keys(s.data.types));
|
|
23
|
+
const keySet = new Set();
|
|
24
|
+
const duplicateKeySet = new Set();
|
|
25
|
+
allSchemaKeys.forEach((key) => {
|
|
26
|
+
if (keySet.has(key)) {
|
|
27
|
+
duplicateKeySet.add(key);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
keySet.add(key);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (duplicateKeySet.size > 0) {
|
|
34
|
+
throw new Error(`The schemas you are attempting to combine have a name collision. Please remove or rename ${Array.from(duplicateKeySet).join(', ')}.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { combine, combinedSchemaBrand };
|
|
39
|
+
//# sourceMappingURL=CombineSchema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CombineSchema.mjs","sources":["../../src/CombineSchema.ts"],"sourcesContent":["import { brand } from './util';\nconst COMBINED_SCHEMA_LIMIT = 50;\nconst CombinedSchemaBrandName = 'CombinedSchema';\nexport const combinedSchemaBrand = brand(CombinedSchemaBrandName);\n/**\n * The interface for merging up to 50 schemas into a single API.\n * @param schemas The schemas to combine into a single API\n * @returns An API and data model definition to be deployed with Amplify (Gen 2) experience (`processSchema(...)`)\n * or with the Amplify Data CDK construct (`@aws-amplify/data-construct`)\n */\nexport function combine(schemas) {\n return internalCombine(schemas);\n}\nfunction internalCombine(schemas) {\n validateDuplicateTypeNames(schemas);\n return {\n ...combinedSchemaBrand,\n schemas: schemas,\n };\n}\nfunction validateDuplicateTypeNames(schemas) {\n const allSchemaKeys = schemas.flatMap((s) => Object.keys(s.data.types));\n const keySet = new Set();\n const duplicateKeySet = new Set();\n allSchemaKeys.forEach((key) => {\n if (keySet.has(key)) {\n duplicateKeySet.add(key);\n }\n else {\n keySet.add(key);\n }\n });\n if (duplicateKeySet.size > 0) {\n throw new Error(`The schemas you are attempting to combine have a name collision. Please remove or rename ${Array.from(duplicateKeySet).join(', ')}.`);\n }\n}\n"],"names":[],"mappings":";;AAEA,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AACrC,MAAC,mBAAmB,GAAG,KAAK,CAAC,uBAAuB,EAAE;AAClE;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,OAAO,CAAC,OAAO,EAAE;AACjC,IAAI,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AACD,SAAS,eAAe,CAAC,OAAO,EAAE;AAClC,IAAI,0BAA0B,CAAC,OAAO,CAAC,CAAC;AACxC,IAAI,OAAO;AACX,QAAQ,GAAG,mBAAmB;AAC9B,QAAQ,OAAO,EAAE,OAAO;AACxB,KAAK,CAAC;AACN,CAAC;AACD,SAAS,0BAA0B,CAAC,OAAO,EAAE;AAC7C,IAAI,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5E,IAAI,MAAM,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;AAC7B,IAAI,MAAM,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;AACtC,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK;AACnC,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AAC7B,YAAY,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrC,SAAS;AACT,aAAa;AACb,YAAY,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC5B,SAAS;AACT,KAAK,CAAC,CAAC;AACP,IAAI,IAAI,eAAe,CAAC,IAAI,GAAG,CAAC,EAAE;AAClC,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,yFAAyF,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/J,KAAK;AACL;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SetTypeSubArg } from '@aws-amplify/data-schema-types';
|
|
2
2
|
import { Brand } from './util';
|
|
3
3
|
import { ModelField, InternalField } from './ModelField';
|
|
4
|
-
import { Authorization } from './Authorization';
|
|
4
|
+
import { AllowModifierForCustomOperation, Authorization } from './Authorization';
|
|
5
5
|
import { RefType, InternalRef } from './RefType';
|
|
6
6
|
import { EnumType, EnumTypeParamShape } from './EnumType';
|
|
7
7
|
import { CustomType } from './CustomType';
|
|
@@ -56,7 +56,7 @@ export type CustomOperation<T extends CustomOperationParamShape, K extends keyof
|
|
|
56
56
|
* Use `.handler(a.handler.function())` instead
|
|
57
57
|
*/
|
|
58
58
|
function<FunctionRef extends CustomFunctionRefType>(functionRefOrName: FunctionRef): CustomOperation<SetTypeSubArg<T, 'functionRef', FunctionRef>, K | 'function', B>;
|
|
59
|
-
authorization<AuthRuleType extends Authorization<any, any, any>>(
|
|
59
|
+
authorization<AuthRuleType extends Authorization<any, any, any>>(callback: (allow: AllowModifierForCustomOperation) => AuthRuleType | AuthRuleType[]): CustomOperation<SetTypeSubArg<T, 'authorization', AuthRuleType[]>, K | 'authorization', B>;
|
|
60
60
|
handler<H extends HandlerInputType>(handlers: H): CustomOperation<T, K | 'handler', B>;
|
|
61
61
|
for<Source extends SubscriptionSource>(source: Source | Source[]): CustomOperation<T['typeName'] extends 'Subscription' ? SetTypeSubArg<T, 'returnType', Source extends SubscriptionSource[] ? Source[number] : Source> : T, K | 'for', B>;
|
|
62
62
|
}, K> & Brand<B>;
|
|
@@ -95,4 +95,3 @@ export declare function subscription(): CustomOperation<{
|
|
|
95
95
|
handlers: null;
|
|
96
96
|
}, 'returns', typeof subscriptionBrand>;
|
|
97
97
|
export {};
|
|
98
|
-
//# sourceMappingURL=CustomOperation.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { brand } from './util/Brand.mjs';
|
|
2
|
+
import { allowForCustomOperations } from './Authorization.mjs';
|
|
3
|
+
|
|
4
|
+
const queryBrand = 'queryCustomOperation';
|
|
5
|
+
const mutationBrand = 'mutationCustomOperation';
|
|
6
|
+
const subscriptionBrand = 'subscriptionCustomOperation';
|
|
7
|
+
const CustomOperationNames = [
|
|
8
|
+
'Query',
|
|
9
|
+
'Mutation',
|
|
10
|
+
'Subscription',
|
|
11
|
+
];
|
|
12
|
+
function brandedBuilder(builder, brandValue) {
|
|
13
|
+
return { ...builder, ...brand(brandValue) };
|
|
14
|
+
}
|
|
15
|
+
function _custom(typeName, brand) {
|
|
16
|
+
const data = {
|
|
17
|
+
arguments: {},
|
|
18
|
+
returnType: null,
|
|
19
|
+
functionRef: null,
|
|
20
|
+
authorization: [],
|
|
21
|
+
typeName: typeName,
|
|
22
|
+
handlers: null,
|
|
23
|
+
subscriptionSource: [],
|
|
24
|
+
};
|
|
25
|
+
const builder = brandedBuilder({
|
|
26
|
+
arguments(args) {
|
|
27
|
+
data.arguments = args;
|
|
28
|
+
return this;
|
|
29
|
+
},
|
|
30
|
+
returns(returnType) {
|
|
31
|
+
data.returnType = returnType;
|
|
32
|
+
return this;
|
|
33
|
+
},
|
|
34
|
+
function(functionRefOrName) {
|
|
35
|
+
data.functionRef = functionRefOrName;
|
|
36
|
+
return this;
|
|
37
|
+
},
|
|
38
|
+
authorization(callback) {
|
|
39
|
+
const rules = callback(allowForCustomOperations);
|
|
40
|
+
data.authorization = Array.isArray(rules) ? rules : [rules];
|
|
41
|
+
return this;
|
|
42
|
+
},
|
|
43
|
+
handler(handlers) {
|
|
44
|
+
data.handlers = Array.isArray(handlers)
|
|
45
|
+
? handlers
|
|
46
|
+
: [handlers];
|
|
47
|
+
return this;
|
|
48
|
+
},
|
|
49
|
+
for(source) {
|
|
50
|
+
data.subscriptionSource = Array.isArray(source) ? source : [source];
|
|
51
|
+
return this;
|
|
52
|
+
},
|
|
53
|
+
}, brand);
|
|
54
|
+
return { ...builder, data };
|
|
55
|
+
}
|
|
56
|
+
function query() {
|
|
57
|
+
return _custom('Query', queryBrand);
|
|
58
|
+
}
|
|
59
|
+
function mutation() {
|
|
60
|
+
return _custom('Mutation', mutationBrand);
|
|
61
|
+
}
|
|
62
|
+
function subscription() {
|
|
63
|
+
return _custom('Subscription', subscriptionBrand);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { CustomOperationNames, mutation, query, subscription };
|
|
67
|
+
//# sourceMappingURL=CustomOperation.mjs.map
|