{"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../../../src/runtime/internals/utils/clientProperties/generateModelsProperty.ts"],"sourcesContent":["import { listFactory } from '../../operations/list';\nimport { indexQueryFactory } from '../../operations/indexQuery';\nimport { getFactory } from '../../operations/get';\nimport { subscriptionFactory } from '../../operations/subscription';\nimport { observeQueryFactory } from '../../operations/observeQuery';\nimport { getSecondaryIndexesFromSchemaModel, excludeDisabledOps, } from '../../clientUtils';\nexport function generateModelsProperty(client, apiGraphQLConfig, getInternals) {\n    const models = {};\n    const modelIntrospection = apiGraphQLConfig.modelIntrospection;\n    if (!modelIntrospection) {\n        return {};\n    }\n    const SUBSCRIPTION_OPS = ['ONCREATE', 'ONUPDATE', 'ONDELETE'];\n    for (const model of Object.values(modelIntrospection.models)) {\n        const { name } = model;\n        models[name] = {};\n        const enabledModelOps = excludeDisabledOps(modelIntrospection, name);\n        Object.entries(enabledModelOps).forEach(([key, { operationPrefix }]) => {\n            const operation = key;\n            if (operation === 'LIST') {\n                models[name][operationPrefix] = listFactory(client, modelIntrospection, model, getInternals);\n            }\n            else if (SUBSCRIPTION_OPS.includes(operation)) {\n                models[name][operationPrefix] = subscriptionFactory(client, modelIntrospection, model, operation, getInternals);\n            }\n            else if (operation === 'OBSERVEQUERY') {\n                models[name][operationPrefix] = observeQueryFactory(models, model);\n            }\n            else {\n                models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation, getInternals);\n            }\n        });\n        const secondaryIdxs = getSecondaryIndexesFromSchemaModel(model);\n        for (const idx of secondaryIdxs) {\n            models[name][idx.queryField] = indexQueryFactory(client, modelIntrospection, model, idx, getInternals);\n        }\n    }\n    return models;\n}\n"],"names":[],"mappings":";;;;;;;AAMO,SAAS,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE;AAC/E,IAAI,MAAM,MAAM,GAAG,EAAE;AACrB,IAAI,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,kBAAkB;AAClE,IAAI,IAAI,CAA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