@aws-amplify/data-schema 0.14.14 → 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 +20 -48
- 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 +17 -194
- package/dist/cjs/SchemaProcessor.js.map +1 -0
- package/{lib-esm/src/index.js → dist/cjs/a.js} +4 -5
- 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 +8 -15
- 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 +1 -2
- 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 +7 -14
- 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 +10 -32
- 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} +2 -4
- 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/ForeignKeys.d.ts +0 -84
- package/lib-esm/src/MappedTypes/ForeignKeys.d.ts.map +0 -1
- package/lib-esm/src/MappedTypes/ForeignKeys.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,33 @@
|
|
|
1
|
+
import { brand } from './util/Brand.mjs';
|
|
2
|
+
|
|
3
|
+
const brandName = 'modelIndexType';
|
|
4
|
+
function _modelIndex(partitionKeyFieldName) {
|
|
5
|
+
const data = {
|
|
6
|
+
partitionKey: partitionKeyFieldName,
|
|
7
|
+
sortKeys: [],
|
|
8
|
+
indexName: '',
|
|
9
|
+
queryField: '',
|
|
10
|
+
};
|
|
11
|
+
const builder = {
|
|
12
|
+
sortKeys(sortKeys) {
|
|
13
|
+
data.sortKeys = sortKeys;
|
|
14
|
+
return this;
|
|
15
|
+
},
|
|
16
|
+
name(name) {
|
|
17
|
+
data.indexName = name;
|
|
18
|
+
return this;
|
|
19
|
+
},
|
|
20
|
+
queryField(field) {
|
|
21
|
+
data.queryField = field;
|
|
22
|
+
return this;
|
|
23
|
+
},
|
|
24
|
+
...brand(brandName),
|
|
25
|
+
};
|
|
26
|
+
return { ...builder, data };
|
|
27
|
+
}
|
|
28
|
+
function modelIndex(partitionKeyFieldName) {
|
|
29
|
+
return _modelIndex(partitionKeyFieldName);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { modelIndex };
|
|
33
|
+
//# sourceMappingURL=ModelIndex.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelIndex.mjs","sources":["../../src/ModelIndex.ts"],"sourcesContent":["import { brand } from './util';\nconst brandName = 'modelIndexType';\nfunction _modelIndex(partitionKeyFieldName) {\n const data = {\n partitionKey: partitionKeyFieldName,\n sortKeys: [],\n indexName: '',\n queryField: '',\n };\n const builder = {\n sortKeys(sortKeys) {\n data.sortKeys = sortKeys;\n return this;\n },\n name(name) {\n data.indexName = name;\n return this;\n },\n queryField(field) {\n data.queryField = field;\n return this;\n },\n ...brand(brandName),\n };\n return { ...builder, data };\n}\nexport function modelIndex(partitionKeyFieldName) {\n return _modelIndex(partitionKeyFieldName);\n}\n"],"names":[],"mappings":";;AACA,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACnC,SAAS,WAAW,CAAC,qBAAqB,EAAE;AAC5C,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,YAAY,EAAE,qBAAqB;AAC3C,QAAQ,QAAQ,EAAE,EAAE;AACpB,QAAQ,SAAS,EAAE,EAAE;AACrB,QAAQ,UAAU,EAAE,EAAE;AACtB,KAAK,CAAC;AACN,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,QAAQ,CAAC,QAAQ,EAAE;AAC3B,YAAY,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACrC,YAAY,OAAO,IAAI,CAAC;AACxB,SAAS;AACT,QAAQ,IAAI,CAAC,IAAI,EAAE;AACnB,YAAY,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;AAClC,YAAY,OAAO,IAAI,CAAC;AACxB,SAAS;AACT,QAAQ,UAAU,CAAC,KAAK,EAAE;AAC1B,YAAY,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;AACpC,YAAY,OAAO,IAAI,CAAC;AACxB,SAAS;AACT,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC;AAC3B,KAAK,CAAC;AACN,IAAI,OAAO,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC;AAChC,CAAC;AACM,SAAS,UAAU,CAAC,qBAAqB,EAAE;AAClD,IAAI,OAAO,WAAW,CAAC,qBAAqB,CAAC,CAAC;AAC9C;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SetTypeSubArg } from '@aws-amplify/data-schema-types';
|
|
2
2
|
import { Brand } from './util';
|
|
3
|
-
import { Authorization } from './Authorization';
|
|
3
|
+
import { AllowModifier, Authorization } from './Authorization';
|
|
4
4
|
/**
|
|
5
5
|
* Used to "attach" auth types to ModelField without exposing them on the builder.
|
|
6
6
|
*/
|
|
@@ -9,8 +9,7 @@ declare const brandName = "modelRelationalField";
|
|
|
9
9
|
export declare enum ModelRelationshipTypes {
|
|
10
10
|
hasOne = "hasOne",
|
|
11
11
|
hasMany = "hasMany",
|
|
12
|
-
belongsTo = "belongsTo"
|
|
13
|
-
manyToMany = "manyToMany"
|
|
12
|
+
belongsTo = "belongsTo"
|
|
14
13
|
}
|
|
15
14
|
type RelationshipTypes = `${ModelRelationshipTypes}`;
|
|
16
15
|
type ModelRelationalFieldData = {
|
|
@@ -20,8 +19,7 @@ type ModelRelationalFieldData = {
|
|
|
20
19
|
array: boolean;
|
|
21
20
|
valueRequired: boolean;
|
|
22
21
|
arrayRequired: boolean;
|
|
23
|
-
|
|
24
|
-
references?: string[];
|
|
22
|
+
references: string[];
|
|
25
23
|
authorization: Authorization<any, any, any>[];
|
|
26
24
|
};
|
|
27
25
|
export type ModelRelationalFieldParamShape = {
|
|
@@ -30,19 +28,14 @@ export type ModelRelationalFieldParamShape = {
|
|
|
30
28
|
relatedModel: string;
|
|
31
29
|
array: boolean;
|
|
32
30
|
valueRequired: boolean;
|
|
33
|
-
references
|
|
31
|
+
references: string[];
|
|
34
32
|
arrayRequired: boolean;
|
|
35
|
-
relationName?: string;
|
|
36
33
|
};
|
|
37
34
|
type ModelRelationalFieldFunctions<T extends ModelRelationalFieldParamShape, RM extends string | symbol, K extends keyof ModelRelationalField<T, RM> = never> = {
|
|
38
35
|
/**
|
|
39
36
|
* When set, it requires the value of the relationship type to be required.
|
|
40
37
|
*/
|
|
41
38
|
valueRequired(): ModelRelationalField<SetTypeSubArg<T, 'valueRequired', true>, K | 'valueRequired'>;
|
|
42
|
-
/**
|
|
43
|
-
* Reference sets the foreign key on which to establish the relationship
|
|
44
|
-
*/
|
|
45
|
-
references(references: string[]): ModelRelationalField<SetTypeSubArg<T, 'references', string[]>, K | 'references'>;
|
|
46
39
|
/**
|
|
47
40
|
* When set, it requires the relationship to always return a value
|
|
48
41
|
*/
|
|
@@ -57,7 +50,7 @@ type ModelRelationalFieldFunctions<T extends ModelRelationalFieldParamShape, RM
|
|
|
57
50
|
* Configures field-level authorization rules. Pass in an array of authorizations `(a.allow.____)` to mix and match
|
|
58
51
|
* multiple authorization rules for this field.
|
|
59
52
|
*/
|
|
60
|
-
authorization<AuthRuleType extends Authorization<any, any, any>>(
|
|
53
|
+
authorization<AuthRuleType extends Authorization<any, any, any>>(callback: (allow: AllowModifier) => AuthRuleType | AuthRuleType[]): ModelRelationalField<T, K | 'authorization', K, AuthRuleType>;
|
|
61
54
|
};
|
|
62
55
|
export type ModelRelationalField<T extends ModelRelationalFieldParamShape, RM extends string | symbol, K extends keyof ModelRelationalField<T, RM> = never, Auth = undefined> = Omit<ModelRelationalFieldFunctions<T, RM, K>, K> & {
|
|
63
56
|
[__auth]?: Auth;
|
|
@@ -69,15 +62,14 @@ export type ModelRelationalField<T extends ModelRelationalFieldParamShape, RM ex
|
|
|
69
62
|
export type InternalRelationalField = ModelRelationalField<ModelRelationalFieldParamShape, string, never> & {
|
|
70
63
|
data: ModelRelationalFieldData;
|
|
71
64
|
};
|
|
72
|
-
export type RelationTypeFunctionOmitMapping<Type extends ModelRelationshipTypes> = Type extends ModelRelationshipTypes.belongsTo ? 'required' | 'arrayRequired' | 'valueRequired' : Type extends ModelRelationshipTypes.hasMany ? 'required' : Type extends ModelRelationshipTypes.hasOne ? 'arrayRequired' | 'valueRequired' :
|
|
73
|
-
export type ModelRelationalTypeArgFactory<RM extends string, RT extends RelationshipTypes, IsArray extends boolean
|
|
65
|
+
export type RelationTypeFunctionOmitMapping<Type extends ModelRelationshipTypes> = Type extends ModelRelationshipTypes.belongsTo ? 'required' | 'arrayRequired' | 'valueRequired' : Type extends ModelRelationshipTypes.hasMany ? 'required' : Type extends ModelRelationshipTypes.hasOne ? 'arrayRequired' | 'valueRequired' : never;
|
|
66
|
+
export type ModelRelationalTypeArgFactory<RM extends string, RT extends RelationshipTypes, IsArray extends boolean> = {
|
|
74
67
|
type: 'model';
|
|
75
68
|
relatedModel: RM;
|
|
76
69
|
relationshipType: RT;
|
|
77
70
|
array: IsArray;
|
|
78
71
|
valueRequired: false;
|
|
79
72
|
arrayRequired: false;
|
|
80
|
-
relationName: RelationName;
|
|
81
73
|
references: string[];
|
|
82
74
|
};
|
|
83
75
|
/**
|
|
@@ -87,13 +79,13 @@ export type ModelRelationalTypeArgFactory<RM extends string, RT extends Relation
|
|
|
87
79
|
* @param relatedModel the name of the related model
|
|
88
80
|
* @returns a one-to-one relationship definition
|
|
89
81
|
*/
|
|
90
|
-
export declare function hasOne<RM extends string>(relatedModel: RM): ModelRelationalField<ModelRelationalTypeArgFactory<RM, ModelRelationshipTypes.hasOne, false
|
|
82
|
+
export declare function hasOne<RM extends string>(relatedModel: RM, references: string | string[]): ModelRelationalField<ModelRelationalTypeArgFactory<RM, ModelRelationshipTypes.hasOne, false>, RM, "valueRequired" | "arrayRequired", undefined>;
|
|
91
83
|
/**
|
|
92
84
|
* Create a one-directional one-to-many relationship between two models using the `hasMany()` method.
|
|
93
85
|
* @param relatedModel the name of the related model
|
|
94
86
|
* @returns a one-to-many relationship definition
|
|
95
87
|
*/
|
|
96
|
-
export declare function hasMany<RM extends string>(relatedModel: RM): ModelRelationalField<ModelRelationalTypeArgFactory<RM, ModelRelationshipTypes.hasMany, true
|
|
88
|
+
export declare function hasMany<RM extends string>(relatedModel: RM, references: string | string[]): ModelRelationalField<ModelRelationalTypeArgFactory<RM, ModelRelationshipTypes.hasMany, true>, RM, "required", undefined>;
|
|
97
89
|
/**
|
|
98
90
|
* Make a `hasOne()` or `hasMany()` relationship bi-directional using the `belongsTo()` method.
|
|
99
91
|
* The belongsTo() method requires that a hasOne() or hasMany() relationship already exists from
|
|
@@ -101,19 +93,5 @@ export declare function hasMany<RM extends string>(relatedModel: RM): ModelRelat
|
|
|
101
93
|
* @param relatedModel name of the related `.hasOne()` or `.hasMany()` model
|
|
102
94
|
* @returns a belong-to relationship definition
|
|
103
95
|
*/
|
|
104
|
-
export declare function belongsTo<RM extends string>(relatedModel: RM): ModelRelationalField<ModelRelationalTypeArgFactory<RM, ModelRelationshipTypes.belongsTo, false
|
|
105
|
-
/**
|
|
106
|
-
* Create a many-to-many relationship between two models with the manyToMany() method.
|
|
107
|
-
* Provide a common relationName on both models to join them into a many-to-many relationship.
|
|
108
|
-
* Under the hood a many-to-many relationship is modeled with a "join table" with corresponding
|
|
109
|
-
* `hasMany()` relationships between the two related models. You must set the same `manyToMany()`
|
|
110
|
-
* field on both models of the relationship.
|
|
111
|
-
* @param relatedModel name of the related model
|
|
112
|
-
* @param opts pass in the `relationName` that will serve as the join table name for this many-to-many relationship
|
|
113
|
-
* @returns a many-to-many relationship definition
|
|
114
|
-
*/
|
|
115
|
-
export declare function manyToMany<RM extends string, RN extends string>(relatedModel: RM, opts: {
|
|
116
|
-
relationName: RN;
|
|
117
|
-
}): ModelRelationalField<ModelRelationalTypeArgFactory<RM, ModelRelationshipTypes.manyToMany, true, RN>, RM, "required" | "references", undefined>;
|
|
96
|
+
export declare function belongsTo<RM extends string>(relatedModel: RM, references: string | string[]): ModelRelationalField<ModelRelationalTypeArgFactory<RM, ModelRelationshipTypes.belongsTo, false>, RM, "valueRequired" | "arrayRequired" | "required", undefined>;
|
|
118
97
|
export {};
|
|
119
|
-
//# sourceMappingURL=ModelRelationalField.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { allow } from './Authorization.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Used to "attach" auth types to ModelField without exposing them on the builder.
|
|
5
|
+
*/
|
|
6
|
+
const __auth = Symbol('__auth');
|
|
7
|
+
var ModelRelationshipTypes;
|
|
8
|
+
(function (ModelRelationshipTypes) {
|
|
9
|
+
ModelRelationshipTypes["hasOne"] = "hasOne";
|
|
10
|
+
ModelRelationshipTypes["hasMany"] = "hasMany";
|
|
11
|
+
ModelRelationshipTypes["belongsTo"] = "belongsTo";
|
|
12
|
+
})(ModelRelationshipTypes || (ModelRelationshipTypes = {}));
|
|
13
|
+
const relationModifierMap = {
|
|
14
|
+
belongsTo: ['authorization'],
|
|
15
|
+
hasMany: ['arrayRequired', 'valueRequired', 'authorization'],
|
|
16
|
+
hasOne: ['required', 'authorization'],
|
|
17
|
+
};
|
|
18
|
+
function _modelRelationalField(type, relatedModel, references) {
|
|
19
|
+
const data = {
|
|
20
|
+
relatedModel,
|
|
21
|
+
type,
|
|
22
|
+
fieldType: 'model',
|
|
23
|
+
array: false,
|
|
24
|
+
valueRequired: false,
|
|
25
|
+
arrayRequired: false,
|
|
26
|
+
references,
|
|
27
|
+
authorization: [],
|
|
28
|
+
};
|
|
29
|
+
data.array = type === 'hasMany';
|
|
30
|
+
const relationshipBuilderFunctions = {
|
|
31
|
+
required() {
|
|
32
|
+
data.arrayRequired = true;
|
|
33
|
+
return this;
|
|
34
|
+
},
|
|
35
|
+
arrayRequired() {
|
|
36
|
+
data.arrayRequired = true;
|
|
37
|
+
return this;
|
|
38
|
+
},
|
|
39
|
+
valueRequired() {
|
|
40
|
+
data.valueRequired = true;
|
|
41
|
+
return this;
|
|
42
|
+
},
|
|
43
|
+
authorization(callback) {
|
|
44
|
+
const rules = callback(allow);
|
|
45
|
+
data.authorization = Array.isArray(rules) ? rules : [rules];
|
|
46
|
+
return this;
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
const builder = Object.fromEntries(relationModifierMap[type].map((key) => [
|
|
50
|
+
key,
|
|
51
|
+
relationshipBuilderFunctions[key],
|
|
52
|
+
]));
|
|
53
|
+
return {
|
|
54
|
+
...builder,
|
|
55
|
+
data,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a one-directional one-to-one relationship between two models using the `hasOne("MODEL_NAME")` method.
|
|
60
|
+
* A hasOne relationship always uses a reference to the related model's identifier. Typically this is the `id` field
|
|
61
|
+
* unless overwritten with the `identifier()` method.
|
|
62
|
+
* @param relatedModel the name of the related model
|
|
63
|
+
* @returns a one-to-one relationship definition
|
|
64
|
+
*/
|
|
65
|
+
function hasOne(relatedModel, references) {
|
|
66
|
+
return _modelRelationalField(ModelRelationshipTypes.hasOne, relatedModel, Array.isArray(references) ? references : [references]);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a one-directional one-to-many relationship between two models using the `hasMany()` method.
|
|
70
|
+
* @param relatedModel the name of the related model
|
|
71
|
+
* @returns a one-to-many relationship definition
|
|
72
|
+
*/
|
|
73
|
+
function hasMany(relatedModel, references) {
|
|
74
|
+
return _modelRelationalField(ModelRelationshipTypes.hasMany, relatedModel, Array.isArray(references) ? references : [references]);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Make a `hasOne()` or `hasMany()` relationship bi-directional using the `belongsTo()` method.
|
|
78
|
+
* The belongsTo() method requires that a hasOne() or hasMany() relationship already exists from
|
|
79
|
+
* parent to the related model.
|
|
80
|
+
* @param relatedModel name of the related `.hasOne()` or `.hasMany()` model
|
|
81
|
+
* @returns a belong-to relationship definition
|
|
82
|
+
*/
|
|
83
|
+
function belongsTo(relatedModel, references) {
|
|
84
|
+
return _modelRelationalField(ModelRelationshipTypes.belongsTo, relatedModel, Array.isArray(references) ? references : [references]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { ModelRelationshipTypes, __auth, belongsTo, hasMany, hasOne };
|
|
88
|
+
//# sourceMappingURL=ModelRelationalField.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelRelationalField.mjs","sources":["../../src/ModelRelationalField.ts"],"sourcesContent":["import { allow } from './Authorization';\n/**\n * Used to \"attach\" auth types to ModelField without exposing them on the builder.\n */\nexport const __auth = Symbol('__auth');\nconst brandName = 'modelRelationalField';\nexport var ModelRelationshipTypes;\n(function (ModelRelationshipTypes) {\n ModelRelationshipTypes[\"hasOne\"] = \"hasOne\";\n ModelRelationshipTypes[\"hasMany\"] = \"hasMany\";\n ModelRelationshipTypes[\"belongsTo\"] = \"belongsTo\";\n})(ModelRelationshipTypes || (ModelRelationshipTypes = {}));\nconst relationalModifiers = [\n 'required',\n 'arrayRequired',\n 'valueRequired',\n 'authorization',\n];\nconst relationModifierMap = {\n belongsTo: ['authorization'],\n hasMany: ['arrayRequired', 'valueRequired', 'authorization'],\n hasOne: ['required', 'authorization'],\n};\nfunction _modelRelationalField(type, relatedModel, references) {\n const data = {\n relatedModel,\n type,\n fieldType: 'model',\n array: false,\n valueRequired: false,\n arrayRequired: false,\n references,\n authorization: [],\n };\n data.array = type === 'hasMany';\n const relationshipBuilderFunctions = {\n required() {\n data.arrayRequired = true;\n return this;\n },\n arrayRequired() {\n data.arrayRequired = true;\n return this;\n },\n valueRequired() {\n data.valueRequired = true;\n return this;\n },\n authorization(callback) {\n const rules = callback(allow);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n };\n const builder = Object.fromEntries(relationModifierMap[type].map((key) => [\n key,\n relationshipBuilderFunctions[key],\n ]));\n return {\n ...builder,\n data,\n };\n}\n/**\n * Create a one-directional one-to-one relationship between two models using the `hasOne(\"MODEL_NAME\")` method.\n * A hasOne relationship always uses a reference to the related model's identifier. Typically this is the `id` field\n * unless overwritten with the `identifier()` method.\n * @param relatedModel the name of the related model\n * @returns a one-to-one relationship definition\n */\nexport function hasOne(relatedModel, references) {\n return _modelRelationalField(ModelRelationshipTypes.hasOne, relatedModel, Array.isArray(references) ? references : [references]);\n}\n/**\n * Create a one-directional one-to-many relationship between two models using the `hasMany()` method.\n * @param relatedModel the name of the related model\n * @returns a one-to-many relationship definition\n */\nexport function hasMany(relatedModel, references) {\n return _modelRelationalField(ModelRelationshipTypes.hasMany, relatedModel, Array.isArray(references) ? references : [references]);\n}\n/**\n * Make a `hasOne()` or `hasMany()` relationship bi-directional using the `belongsTo()` method.\n * The belongsTo() method requires that a hasOne() or hasMany() relationship already exists from\n * parent to the related model.\n * @param relatedModel name of the related `.hasOne()` or `.hasMany()` model\n * @returns a belong-to relationship definition\n */\nexport function belongsTo(relatedModel, references) {\n return _modelRelationalField(ModelRelationshipTypes.belongsTo, relatedModel, Array.isArray(references) ? references : [references]);\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE;AAE7B,IAAC,uBAAuB;AAClC,CAAC,UAAU,sBAAsB,EAAE;AACnC,IAAI,sBAAsB,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AAChD,IAAI,sBAAsB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAClD,IAAI,sBAAsB,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;AACtD,CAAC,EAAE,sBAAsB,KAAK,sBAAsB,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AAO,IAAI,CAAC;AACxB,SAAS;AACT,KAAK,CAAC;AACN,IAAI,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK;AAC9E,QAAQ,GAAG;AACX,QAAQ,4BAA4B,CAAC,GAAG,CAAC;AACzC,KAAK,CAAC,CAAC,CAAC;AACR,IAAI,OAAO;AACX,QAAQ,GAAG,OAAO;AAClB,QAAQ,IAAI;AACZ,KAAK,CAAC;AACN,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,MAAM,CAAC,YAAY,EAAE,UAAU,EAAE;AACjD,IAAI,OAAO,qBAAqB,CAAC,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AACrI,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,SAAS,OAAO,CAAC,YAAY,EAAE,UAAU,EAAE;AAClD,IAAI,OAAO,qBAAqB,CAAC,sBAAsB,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AACtI,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAC,YAAY,EAAE,UAAU,EAAE;AACpD,IAAI,OAAO,qBAAqB,CAAC,sBAAsB,CAAC,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AACxI;;;;"}
|
|
@@ -3,7 +3,7 @@ import { type ModelType, type ModelTypeParamShape, type InternalModel, SchemaMod
|
|
|
3
3
|
import type { EnumType, EnumTypeParamShape } from './EnumType';
|
|
4
4
|
import type { CustomType, CustomTypeParamShape } from './CustomType';
|
|
5
5
|
import type { CustomOperation, CustomOperationParamShape, InternalCustom, MutationCustomOperation, QueryCustomOperation, SubscriptionCustomOperation } from './CustomOperation';
|
|
6
|
-
import { SchemaAuthorization } from './Authorization';
|
|
6
|
+
import { AllowModifier, SchemaAuthorization } from './Authorization';
|
|
7
7
|
import { Brand } from './util';
|
|
8
8
|
import { ModelRelationalField, ModelRelationalFieldParamShape } from './ModelRelationalField';
|
|
9
9
|
export declare const rdsSchemaBrandName = "RDSSchema";
|
|
@@ -36,14 +36,14 @@ export type BaseSchema<T extends ModelSchemaParamShape, IsRDS extends boolean =
|
|
|
36
36
|
};
|
|
37
37
|
export type GenericModelSchema<T extends ModelSchemaParamShape> = BaseSchema<T> & Brand<typeof rdsSchemaBrandName | typeof ddbSchemaBrandName>;
|
|
38
38
|
export type ModelSchema<T extends ModelSchemaParamShape, UsedMethods extends 'authorization' | 'addRelationships' = never> = Omit<{
|
|
39
|
-
authorization: <AuthRules extends SchemaAuthorization<any, any, any>>(
|
|
39
|
+
authorization: <AuthRules extends SchemaAuthorization<any, any, any>>(callback: (allow: AllowModifier) => AuthRules | AuthRules[]) => ModelSchema<SetTypeSubArg<T, 'authorization', AuthRules[]>, UsedMethods | 'authorization'>;
|
|
40
40
|
}, UsedMethods> & BaseSchema<T> & DDBSchemaBrand;
|
|
41
41
|
type RDSModelSchemaFunctions = 'addQueries' | 'addMutations' | 'addSubscriptions' | 'authorization' | 'relationships' | 'setAuthorization' | 'renameModelFields' | 'renameModels';
|
|
42
42
|
export type RDSModelSchema<T extends RDSModelSchemaParamShape, UsedMethods extends RDSModelSchemaFunctions = never, RelationshipTemplate extends Record<string, ModelRelationalField<ModelRelationalFieldParamShape, string, any, any>> = Record<string, ModelRelationalField<ModelRelationalFieldParamShape, string, any, any>>> = Omit<{
|
|
43
43
|
addQueries: <Queries extends Record<string, QueryCustomOperation>>(types: Queries) => RDSModelSchema<SetTypeSubArg<T, 'types', T['types'] & Queries>, UsedMethods | 'addQueries'>;
|
|
44
44
|
addMutations: <Mutations extends Record<string, MutationCustomOperation>>(types: Mutations) => RDSModelSchema<SetTypeSubArg<T, 'types', T['types'] & Mutations>, UsedMethods | 'addMutations'>;
|
|
45
45
|
addSubscriptions: <Subscriptions extends Record<string, SubscriptionCustomOperation>>(types: Subscriptions) => RDSModelSchema<SetTypeSubArg<T, 'types', T['types'] & Subscriptions>, UsedMethods | 'addSubscriptions'>;
|
|
46
|
-
authorization: <AuthRules extends SchemaAuthorization<any, any, any>>(
|
|
46
|
+
authorization: <AuthRules extends SchemaAuthorization<any, any, any>>(callback: (allow: AllowModifier) => AuthRules | AuthRules[]) => RDSModelSchema<SetTypeSubArg<T, 'authorization', AuthRules[]>, UsedMethods | 'authorization'>;
|
|
47
47
|
setAuthorization: (callback: (models: BaseSchema<T, true>['models'], schema: RDSModelSchema<T, UsedMethods | 'setAuthorization'>) => void) => RDSModelSchema<T>;
|
|
48
48
|
relationships: <Relationships extends ReadonlyArray<Partial<Record<keyof T['types'], RelationshipTemplate>>>>(callback: (models: BaseSchema<T, true>['models']) => Relationships) => RDSModelSchema<UnionToIntersection<Relationships[number]> extends infer RelationshipsDefs ? RelationshipsDefs extends Record<string, RelationshipTemplate> ? SetTypeSubArg<T, 'types', {
|
|
49
49
|
[ModelName in keyof T['types']]: ModelName extends keyof RelationshipsDefs ? AddRelationshipFieldsToModelTypeFields<T['types'][ModelName], RelationshipsDefs[ModelName]> : T['types'][ModelName];
|
|
@@ -104,4 +104,3 @@ export type CustomPathData = {
|
|
|
104
104
|
entry: string;
|
|
105
105
|
};
|
|
106
106
|
export {};
|
|
107
|
-
//# sourceMappingURL=ModelSchema.d.ts.map
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { isSchemaModelType } from './ModelType.mjs';
|
|
2
|
+
import { processSchema } from './SchemaProcessor.mjs';
|
|
3
|
+
import { allow } from './Authorization.mjs';
|
|
4
|
+
import { brand } from './util/Brand.mjs';
|
|
5
|
+
|
|
6
|
+
const rdsSchemaBrandName = 'RDSSchema';
|
|
7
|
+
const rdsSchemaBrand = brand(rdsSchemaBrandName);
|
|
8
|
+
const ddbSchemaBrandName = 'DDBSchema';
|
|
9
|
+
const ddbSchemaBrand = brand(ddbSchemaBrandName);
|
|
10
|
+
/**
|
|
11
|
+
* Filter the schema types down to only include the ModelTypes as SchemaModelType
|
|
12
|
+
*
|
|
13
|
+
* @param schemaContents The object containing all SchemaContent for this schema
|
|
14
|
+
* @returns Only the schemaContents that are ModelTypes, coerced to the SchemaModelType surface
|
|
15
|
+
*/
|
|
16
|
+
const filterSchemaModelTypes = (schemaContents) => {
|
|
17
|
+
const modelTypes = {};
|
|
18
|
+
if (schemaContents) {
|
|
19
|
+
Object.entries(schemaContents).forEach(([key, content]) => {
|
|
20
|
+
if (isSchemaModelType(content)) {
|
|
21
|
+
modelTypes[key] = content;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return modelTypes;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Model Schema type guard
|
|
29
|
+
* @param schema - api-next ModelSchema or string
|
|
30
|
+
* @returns true if the given value is a ModelSchema
|
|
31
|
+
*/
|
|
32
|
+
const isModelSchema = (schema) => {
|
|
33
|
+
return typeof schema === 'object' && schema.data !== undefined;
|
|
34
|
+
};
|
|
35
|
+
function _rdsSchema(types, config) {
|
|
36
|
+
const data = {
|
|
37
|
+
types,
|
|
38
|
+
authorization: [],
|
|
39
|
+
configuration: config,
|
|
40
|
+
};
|
|
41
|
+
const models = filterSchemaModelTypes(data.types);
|
|
42
|
+
return {
|
|
43
|
+
data,
|
|
44
|
+
models,
|
|
45
|
+
transform() {
|
|
46
|
+
const internalSchema = { data };
|
|
47
|
+
return processSchema({ schema: internalSchema });
|
|
48
|
+
},
|
|
49
|
+
authorization(callback) {
|
|
50
|
+
const rules = callback(allow);
|
|
51
|
+
this.data.authorization = Array.isArray(rules) ? rules : [rules];
|
|
52
|
+
const { authorization: _, ...rest } = this;
|
|
53
|
+
return rest;
|
|
54
|
+
},
|
|
55
|
+
addQueries(types) {
|
|
56
|
+
this.data.types = { ...this.data.types, ...types };
|
|
57
|
+
const { addQueries: _, ...rest } = this;
|
|
58
|
+
return rest;
|
|
59
|
+
},
|
|
60
|
+
addMutations(types) {
|
|
61
|
+
this.data.types = { ...this.data.types, ...types };
|
|
62
|
+
const { addMutations: _, ...rest } = this;
|
|
63
|
+
return rest;
|
|
64
|
+
},
|
|
65
|
+
addSubscriptions(types) {
|
|
66
|
+
this.data.types = { ...this.data.types, ...types };
|
|
67
|
+
const { addSubscriptions: _, ...rest } = this;
|
|
68
|
+
return rest;
|
|
69
|
+
},
|
|
70
|
+
setAuthorization(callback) {
|
|
71
|
+
callback(models, this);
|
|
72
|
+
const { setAuthorization: _, ...rest } = this;
|
|
73
|
+
return rest;
|
|
74
|
+
},
|
|
75
|
+
relationships(callback) {
|
|
76
|
+
const { relationships: _, ...rest } = this;
|
|
77
|
+
// The relationships are added via `models.<Model>.addRelationships`
|
|
78
|
+
// modifiers that's being called within the callback. They are modifying
|
|
79
|
+
// by references on each model, so there is not anything else to be done
|
|
80
|
+
// here.
|
|
81
|
+
callback(models);
|
|
82
|
+
return rest;
|
|
83
|
+
},
|
|
84
|
+
renameModels(callback) {
|
|
85
|
+
const { renameModels: _, ...rest } = this;
|
|
86
|
+
// returns an array of tuples [curName, newName]
|
|
87
|
+
const changeLog = callback();
|
|
88
|
+
changeLog.forEach(([curName, newName]) => {
|
|
89
|
+
const currentType = data.types[curName];
|
|
90
|
+
if (currentType === undefined) {
|
|
91
|
+
throw new Error(`Invalid renameModels call. ${curName} is not defined in the schema`);
|
|
92
|
+
}
|
|
93
|
+
if (typeof newName !== 'string' || newName.length < 1) {
|
|
94
|
+
throw new Error(`Invalid renameModels call. New name must be a non-empty string. Received: "${newName}"`);
|
|
95
|
+
}
|
|
96
|
+
models[newName] = currentType;
|
|
97
|
+
data.types[newName] = currentType;
|
|
98
|
+
delete models[curName];
|
|
99
|
+
delete data.types[curName];
|
|
100
|
+
});
|
|
101
|
+
return rest;
|
|
102
|
+
},
|
|
103
|
+
...rdsSchemaBrand,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function _ddbSchema(types, config) {
|
|
107
|
+
const data = {
|
|
108
|
+
types,
|
|
109
|
+
authorization: [],
|
|
110
|
+
configuration: config,
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
data,
|
|
114
|
+
transform() {
|
|
115
|
+
const internalSchema = { data };
|
|
116
|
+
return processSchema({ schema: internalSchema });
|
|
117
|
+
},
|
|
118
|
+
authorization(callback) {
|
|
119
|
+
const rules = callback(allow);
|
|
120
|
+
this.data.authorization = Array.isArray(rules) ? rules : [rules];
|
|
121
|
+
const { authorization: _, ...rest } = this;
|
|
122
|
+
return rest;
|
|
123
|
+
},
|
|
124
|
+
models: filterSchemaModelTypes(data.types),
|
|
125
|
+
...ddbSchemaBrand,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function bindConfigToSchema(config) {
|
|
129
|
+
return (types) => {
|
|
130
|
+
return (config.database.engine === 'dynamodb'
|
|
131
|
+
? _ddbSchema(types, config)
|
|
132
|
+
: _rdsSchema(types, config));
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The API and data model definition for Amplify Data. Pass in `{ <NAME>: a.model(...) }` to create a database table
|
|
137
|
+
* and exposes CRUDL operations via an API.
|
|
138
|
+
* @param types The API and data model definition
|
|
139
|
+
* @returns An API and data model definition to be deployed with Amplify (Gen 2) experience (`processSchema(...)`)
|
|
140
|
+
* or with the Amplify Data CDK construct (`@aws-amplify/data-construct`)
|
|
141
|
+
*/
|
|
142
|
+
const schema = bindConfigToSchema({ database: { engine: 'dynamodb' } });
|
|
143
|
+
/**
|
|
144
|
+
* Configure wraps schema definition with non-default config to allow usecases other than
|
|
145
|
+
* the default DynamoDB use-case.
|
|
146
|
+
*
|
|
147
|
+
* @param config The SchemaConfig augments the schema with content like the database type
|
|
148
|
+
* @returns
|
|
149
|
+
*/
|
|
150
|
+
function configure(config) {
|
|
151
|
+
return {
|
|
152
|
+
schema: bindConfigToSchema(config),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function isCustomPathData(obj) {
|
|
156
|
+
return ('stack' in obj &&
|
|
157
|
+
(typeof obj.stack === 'undefined' || typeof obj.stack === 'string') &&
|
|
158
|
+
'entry' in obj &&
|
|
159
|
+
typeof obj.entry === 'string');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export { configure, ddbSchemaBrandName, isCustomPathData, isModelSchema, rdsSchemaBrand, rdsSchemaBrandName, schema };
|
|
163
|
+
//# sourceMappingURL=ModelSchema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelSchema.mjs","sources":["../../src/ModelSchema.ts"],"sourcesContent":["import { isSchemaModelType, } from './ModelType';\nimport { processSchema } from './SchemaProcessor';\nimport { allow } from './Authorization';\nimport { brand } from './util';\nexport const rdsSchemaBrandName = 'RDSSchema';\nexport const rdsSchemaBrand = brand(rdsSchemaBrandName);\nexport const ddbSchemaBrandName = 'DDBSchema';\nconst ddbSchemaBrand = brand(ddbSchemaBrandName);\n/**\n * Filter the schema types down to only include the ModelTypes as SchemaModelType\n *\n * @param schemaContents The object containing all SchemaContent for this schema\n * @returns Only the schemaContents that are ModelTypes, coerced to the SchemaModelType surface\n */\nconst filterSchemaModelTypes = (schemaContents) => {\n const modelTypes = {};\n if (schemaContents) {\n Object.entries(schemaContents).forEach(([key, content]) => {\n if (isSchemaModelType(content)) {\n modelTypes[key] = content;\n }\n });\n }\n return modelTypes;\n};\n/**\n * Model Schema type guard\n * @param schema - api-next ModelSchema or string\n * @returns true if the given value is a ModelSchema\n */\nexport const isModelSchema = (schema) => {\n return typeof schema === 'object' && schema.data !== undefined;\n};\nfunction _rdsSchema(types, config) {\n const data = {\n types,\n authorization: [],\n configuration: config,\n };\n const models = filterSchemaModelTypes(data.types);\n return {\n data,\n models,\n transform() {\n const internalSchema = { data };\n return processSchema({ schema: internalSchema });\n },\n authorization(callback) {\n const rules = callback(allow);\n this.data.authorization = Array.isArray(rules) ? rules : [rules];\n const { authorization: _, ...rest } = this;\n return rest;\n },\n addQueries(types) {\n this.data.types = { ...this.data.types, ...types };\n const { addQueries: _, ...rest } = this;\n return rest;\n },\n addMutations(types) {\n this.data.types = { ...this.data.types, ...types };\n const { addMutations: _, ...rest } = this;\n return rest;\n },\n addSubscriptions(types) {\n this.data.types = { ...this.data.types, ...types };\n const { addSubscriptions: _, ...rest } = this;\n return rest;\n },\n setAuthorization(callback) {\n callback(models, this);\n const { setAuthorization: _, ...rest } = this;\n return rest;\n },\n relationships(callback) {\n const { relationships: _, ...rest } = this;\n // The relationships are added via `models.<Model>.addRelationships`\n // modifiers that's being called within the callback. They are modifying\n // by references on each model, so there is not anything else to be done\n // here.\n callback(models);\n return rest;\n },\n renameModels(callback) {\n const { renameModels: _, ...rest } = this;\n // returns an array of tuples [curName, newName]\n const changeLog = callback();\n changeLog.forEach(([curName, newName]) => {\n const currentType = data.types[curName];\n if (currentType === undefined) {\n throw new Error(`Invalid renameModels call. ${curName} is not defined in the schema`);\n }\n if (typeof newName !== 'string' || newName.length < 1) {\n throw new Error(`Invalid renameModels call. New name must be a non-empty string. Received: \"${newName}\"`);\n }\n models[newName] = currentType;\n data.types[newName] = currentType;\n delete models[curName];\n delete data.types[curName];\n });\n return rest;\n },\n ...rdsSchemaBrand,\n };\n}\nfunction _ddbSchema(types, config) {\n const data = {\n types,\n authorization: [],\n configuration: config,\n };\n return {\n data,\n transform() {\n const internalSchema = { data };\n return processSchema({ schema: internalSchema });\n },\n authorization(callback) {\n const rules = callback(allow);\n this.data.authorization = Array.isArray(rules) ? rules : [rules];\n const { authorization: _, ...rest } = this;\n return rest;\n },\n models: filterSchemaModelTypes(data.types),\n ...ddbSchemaBrand,\n };\n}\nfunction bindConfigToSchema(config) {\n return (types) => {\n return (config.database.engine === 'dynamodb'\n ? _ddbSchema(types, config)\n : _rdsSchema(types, config));\n };\n}\n/**\n * The API and data model definition for Amplify Data. Pass in `{ <NAME>: a.model(...) }` to create a database table\n * and exposes CRUDL operations via an API.\n * @param types The API and data model definition\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 const schema = bindConfigToSchema({ database: { engine: 'dynamodb' } });\n/**\n * Configure wraps schema definition with non-default config to allow usecases other than\n * the default DynamoDB use-case.\n *\n * @param config The SchemaConfig augments the schema with content like the database type\n * @returns\n */\nexport function configure(config) {\n return {\n schema: bindConfigToSchema(config),\n };\n}\nexport function isCustomPathData(obj) {\n return ('stack' in obj &&\n (typeof obj.stack === 'undefined' || typeof obj.stack === 'string') &&\n 'entry' in obj &&\n typeof obj.entry === 'string');\n}\n"],"names":[],"mappings":";;;;;AAIY,MAAC,kBAAkB,GAAG,YAAY;AAClC,MAAC,cAAc,GAAG,KAAK,CAAC,kBAAkB,EAAE;AAC5C,MAAC,kBAAkB,GAAG,YAAY;AAC9C,MAAM,cAAc,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC;AACjD;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,sBAAsB,GAAG,CAAC,cAAc,KAAK;AACnD,IAAI,MAAM,UAAU,GAAG,EAAE,CAAC;AAC1B,IAAI,IAAI,cAAc,EAAE;AACxB,QAAQ,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK;AACnE,YAAY,IAAI,iBAAiB,CAAC,OAAO,CAAC,EAAE;AAC5C,gBAAgB,UAAU,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;AAC1C,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACY,MAAC,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GAAG;AACtB,QAAQ,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,EAAE;AACvC;;;;"}
|
|
@@ -2,7 +2,7 @@ import type { SetTypeSubArg, SecondaryIndexIrShape } from '@aws-amplify/data-sch
|
|
|
2
2
|
import { Brand } from './util';
|
|
3
3
|
import { ModelField, InternalField } from './ModelField';
|
|
4
4
|
import type { ModelRelationalField, InternalRelationalField, ModelRelationalFieldParamShape } from './ModelRelationalField';
|
|
5
|
-
import { Authorization } from './Authorization';
|
|
5
|
+
import { AllowModifier, Authorization } from './Authorization';
|
|
6
6
|
import { RefType } from './RefType';
|
|
7
7
|
import { EnumType, EnumTypeParamShape } from './EnumType';
|
|
8
8
|
import { CustomType, CustomTypeParamShape } from './CustomType';
|
|
@@ -45,7 +45,7 @@ export type AddRelationshipFieldsToModelTypeFields<Model, RelationshipFields ext
|
|
|
45
45
|
export type ModelType<T extends ModelTypeParamShape, K extends keyof ModelType<T> = never> = Omit<{
|
|
46
46
|
identifier<ID extends IdentifierType<T> = []>(identifier: ID): ModelType<SetTypeSubArg<T, 'identifier', ID>, K | 'identifier'>;
|
|
47
47
|
secondaryIndexes<const SecondaryIndexPKPool extends string = SecondaryIndexFields<ExtractType<T>>, const Indexes extends readonly ModelIndexType<string, string, unknown, readonly [], any>[] = readonly [], const IndexesIR extends readonly any[] = SecondaryIndexToIR<Indexes, ExtractType<T>>>(callback: (index: <PK extends SecondaryIndexPKPool>(pk: PK) => ModelIndexType<SecondaryIndexPKPool, PK, ReadonlyArray<Exclude<SecondaryIndexPKPool, PK>>>) => Indexes): ModelType<SetTypeSubArg<T, 'secondaryIndexes', IndexesIR>, K | 'secondaryIndexes'>;
|
|
48
|
-
authorization<AuthRuleType extends Authorization<any, any, any>>(
|
|
48
|
+
authorization<AuthRuleType extends Authorization<any, any, any>>(callback: (allow: Omit<AllowModifier, 'resource'>) => AuthRuleType | AuthRuleType[]): ModelType<SetTypeSubArg<T, 'authorization', AuthRuleType[]>, K | 'authorization'>;
|
|
49
49
|
}, K> & Brand<typeof brandName>;
|
|
50
50
|
/**
|
|
51
51
|
* External representation of Model Type that exposes the `addRelationships` modifier.
|
|
@@ -82,4 +82,3 @@ export declare function model<T extends ModelFields>(fields: T): ModelType<{
|
|
|
82
82
|
authorization: [];
|
|
83
83
|
}>;
|
|
84
84
|
export {};
|
|
85
|
-
//# sourceMappingURL=ModelType.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { brand } from './util/Brand.mjs';
|
|
2
|
+
import { allow } from './Authorization.mjs';
|
|
3
|
+
import { modelIndex } from './ModelIndex.mjs';
|
|
4
|
+
|
|
5
|
+
const brandName = 'modelType';
|
|
6
|
+
function _model(fields) {
|
|
7
|
+
const data = {
|
|
8
|
+
fields,
|
|
9
|
+
identifier: ['id'],
|
|
10
|
+
secondaryIndexes: [],
|
|
11
|
+
authorization: [],
|
|
12
|
+
};
|
|
13
|
+
const builder = {
|
|
14
|
+
identifier(identifier) {
|
|
15
|
+
data.identifier = identifier;
|
|
16
|
+
return this;
|
|
17
|
+
},
|
|
18
|
+
secondaryIndexes(callback) {
|
|
19
|
+
data.secondaryIndexes = callback(modelIndex);
|
|
20
|
+
return this;
|
|
21
|
+
},
|
|
22
|
+
authorization(callback) {
|
|
23
|
+
const { resource: _, ...rest } = allow;
|
|
24
|
+
const rules = callback(rest);
|
|
25
|
+
data.authorization = Array.isArray(rules) ? rules : [rules];
|
|
26
|
+
return this;
|
|
27
|
+
},
|
|
28
|
+
...brand(brandName),
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
...builder,
|
|
32
|
+
data,
|
|
33
|
+
addRelationships(relationships) {
|
|
34
|
+
data.fields = { ...data.fields, ...relationships };
|
|
35
|
+
},
|
|
36
|
+
fields: data.fields,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Model Type type guard
|
|
41
|
+
* @param modelType - api-next ModelType
|
|
42
|
+
* @returns true if the given value is a ModelSchema
|
|
43
|
+
*/
|
|
44
|
+
const isSchemaModelType = (modelType) => {
|
|
45
|
+
const internalType = modelType;
|
|
46
|
+
return (typeof internalType === 'object' &&
|
|
47
|
+
internalType.data !== undefined &&
|
|
48
|
+
internalType.data.fields !== undefined &&
|
|
49
|
+
internalType.data.authorization !== undefined &&
|
|
50
|
+
internalType.data.identifier !== undefined &&
|
|
51
|
+
internalType.data.secondaryIndexes !== undefined &&
|
|
52
|
+
typeof internalType.addRelationships === 'function');
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* A data model that creates a matching Amazon DynamoDB table and provides create, read (list and get), update,
|
|
56
|
+
* delete, and subscription APIs.
|
|
57
|
+
*
|
|
58
|
+
* @param fields database table fields. Supports scalar types and relationship types.
|
|
59
|
+
* @returns a data model definition
|
|
60
|
+
*/
|
|
61
|
+
function model(fields) {
|
|
62
|
+
return _model(fields);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { isSchemaModelType, model };
|
|
66
|
+
//# sourceMappingURL=ModelType.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelType.mjs","sources":["../../src/ModelType.ts"],"sourcesContent":["import { brand } from './util';\nimport { allow } from './Authorization';\nimport { modelIndex, } from './ModelIndex';\nconst brandName = 'modelType';\nfunction _model(fields) {\n const data = {\n fields,\n identifier: ['id'],\n secondaryIndexes: [],\n authorization: [],\n };\n const builder = {\n identifier(identifier) {\n data.identifier = identifier;\n return this;\n },\n secondaryIndexes(callback) {\n data.secondaryIndexes = callback(modelIndex);\n return this;\n },\n authorization(callback) {\n const { resource: _, ...rest } = allow;\n const rules = callback(rest);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n ...brand(brandName),\n };\n return {\n ...builder,\n data,\n addRelationships(relationships) {\n data.fields = { ...data.fields, ...relationships };\n },\n fields: data.fields,\n };\n}\n/**\n * Model Type type guard\n * @param modelType - api-next ModelType\n * @returns true if the given value is a ModelSchema\n */\nexport const isSchemaModelType = (modelType) => {\n const internalType = modelType;\n return (typeof internalType === 'object' &&\n internalType.data !== undefined &&\n internalType.data.fields !== undefined &&\n internalType.data.authorization !== undefined &&\n internalType.data.identifier !== undefined &&\n internalType.data.secondaryIndexes !== undefined &&\n typeof internalType.addRelationships === 'function');\n};\n/**\n * A data model that creates a matching Amazon DynamoDB table and provides create, read (list and get), update,\n * delete, and subscription APIs.\n *\n * @param fields database table fields. Supports scalar types and relationship types.\n * @returns a data model definition\n */\nexport function model(fields) {\n return _model(fields);\n}\n"],"names":[],"mappings":";;;;AAGA,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,SAAS,MAAM,CAAC,MAAM,EAAE;AACxB,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,MAAM;AACd,QAAQ,UAAU,EAAE,CAAC,IAAI,CAAC;AAC1B,QAAQ,gBAAgB,EAAE,EAAE;AAC5B,QAAQ,aAAa,EAAE,EAAE;AACzB,KAAK,CAAC;AACN,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,UAAU,CAAC,UAAU,EAAE;AAC/B,YAAY,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;AACzC,YAAY,OAAO,IAAI,CAAC;AACxB,SAAS;AACT,QAAQ,gBAAgB,CAAC,QAAQ,EAAE;AACnC,YAAY,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AACzD,YAAY,OAAO,IAAI,CAAC;AACxB,SAAS;AACT,QAAQ,aAAa,CAAC,QAAQ,EAAE;AAChC,YAAY,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;AACnD,YAAY,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;AACzC,YAAY,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC;AACxE,YAAY,OAAO,IAAI,CAAC;AACxB,SAAS;AACT,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC;AAC3B,KAAK,CAAC;AACN,IAAI,OAAO;AACX,QAAQ,GAAG,OAAO;AAClB,QAAQ,IAAI;AACZ,QAAQ,gBAAgB,CAAC,aAAa,EAAE;AACxC,YAAY,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,aAAa,EAAE,CAAC;AAC/D,SAAS;AACT,QAAQ,MAAM,EAAE,IAAI,CAAC,MAAM;AAC3B,KAAK,CAAC;AACN,CAAC;AACD;AACA;AACA;AACA;AACA;AACY,MAAC,iBAAiB,GAAG,CAAC,SAAS,KAAK;AAChD,IAAI,MAAM,YAAY,GAAG,SAAS,CAAC;AACnC,IAAI,QAAQ,OAAO,YAAY,KAAK,QAAQ;AAC5C,QAAQ,YAAY,CAAC,IAAI,KAAK,SAAS;AACvC,QAAQ,YAAY,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS;AAC9C,QAAQ,YAAY,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS;AACrD,QAAQ,YAAY,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS;AAClD,QAAQ,YAAY,CAAC,IAAI,CAAC,gBAAgB,KAAK,SAAS;AACxD,QAAQ,OAAO,YAAY,CAAC,gBAAgB,KAAK,UAAU,EAAE;AAC7D,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,KAAK,CAAC,MAAM,EAAE;AAC9B,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AAC1B;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SetTypeSubArg } from '@aws-amplify/data-schema-types';
|
|
2
2
|
import { Brand } from './util';
|
|
3
|
-
import { Authorization } from './Authorization';
|
|
3
|
+
import { AllowModifier, Authorization } from './Authorization';
|
|
4
4
|
import { __auth } from './ModelField';
|
|
5
5
|
declare const brandName = "ref";
|
|
6
6
|
type RefTypeData = {
|
|
@@ -34,7 +34,7 @@ export type RefType<T extends RefTypeParamShape, K extends keyof RefType<T> = ne
|
|
|
34
34
|
* Configures field-level authorization rules. Pass in an array of authorizations `(a.allow.____)` to mix and match
|
|
35
35
|
* multiple authorization rules for this field.
|
|
36
36
|
*/
|
|
37
|
-
authorization<AuthRuleType extends Authorization<any, any, any>>(
|
|
37
|
+
authorization<AuthRuleType extends Authorization<any, any, any>>(callback: (allow: AllowModifier) => AuthRuleType | AuthRuleType[]): RefType<T, K | 'authorization', AuthRuleType>;
|
|
38
38
|
mutations(operations: MutationOperations[]): RefType<T, K | 'mutations'>;
|
|
39
39
|
}, K> & {
|
|
40
40
|
[__auth]?: Auth;
|
|
@@ -56,4 +56,3 @@ type RefTypeArgFactory<Link extends string> = {
|
|
|
56
56
|
};
|
|
57
57
|
export declare function ref<Value extends string, T extends Value>(link: T): RefType<RefTypeArgFactory<T>, never, undefined>;
|
|
58
58
|
export {};
|
|
59
|
-
//# sourceMappingURL=RefType.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { allow } from './Authorization.mjs';
|
|
2
|
+
import './ModelField.mjs';
|
|
3
|
+
|
|
4
|
+
function brandedBuilder(builder) {
|
|
5
|
+
return builder;
|
|
6
|
+
}
|
|
7
|
+
function _ref(link) {
|
|
8
|
+
const data = {
|
|
9
|
+
type: 'ref',
|
|
10
|
+
link,
|
|
11
|
+
valueRequired: false,
|
|
12
|
+
array: false,
|
|
13
|
+
arrayRequired: false,
|
|
14
|
+
mutationOperations: [],
|
|
15
|
+
authorization: [],
|
|
16
|
+
};
|
|
17
|
+
const builder = brandedBuilder({
|
|
18
|
+
required() {
|
|
19
|
+
if (data.array) {
|
|
20
|
+
data.arrayRequired = true;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
data.valueRequired = true;
|
|
24
|
+
}
|
|
25
|
+
return this;
|
|
26
|
+
},
|
|
27
|
+
array() {
|
|
28
|
+
data.array = true;
|
|
29
|
+
return this;
|
|
30
|
+
},
|
|
31
|
+
authorization(callback) {
|
|
32
|
+
const rules = callback(allow);
|
|
33
|
+
data.authorization = Array.isArray(rules) ? rules : [rules];
|
|
34
|
+
return this;
|
|
35
|
+
},
|
|
36
|
+
mutations(operations) {
|
|
37
|
+
data.mutationOperations = operations;
|
|
38
|
+
return this;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
return { ...builder, data };
|
|
42
|
+
}
|
|
43
|
+
function ref(link) {
|
|
44
|
+
return _ref(link);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { ref };
|
|
48
|
+
//# sourceMappingURL=RefType.mjs.map
|