UNPKG

@geek-fun/serverlessinsight

Version:

Full life cycle cross providers serverless application management for your fast-growing business.

42 lines (41 loc) 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseTable = parseTable; const lodash_1 = require("lodash"); function parseTable(tablesRaw) { if ((0, lodash_1.isEmpty)(tablesRaw)) { return undefined; } return Object.entries(tablesRaw)?.map(([key, table]) => { const throughput = (0, lodash_1.omitBy)({ reserved: (0, lodash_1.omitBy)({ read: table.throughput?.reserved?.read, write: table.throughput?.reserved?.write, }, lodash_1.isNil), onDemand: (0, lodash_1.omitBy)({ read: table.throughput?.on_demand?.read, write: table.throughput?.on_demand?.write, }, lodash_1.isNil), }, lodash_1.isEmpty); return { key, collection: table.collection, name: table.name, type: table.type, desc: table.desc, network: { type: table.network?.type ?? 'PRIVATE', ingressRules: table.network?.ingress_rules ?? [], }, throughput: !(0, lodash_1.isEmpty)(throughput) ? throughput : undefined, keySchema: table.key_schema?.map((keySchema) => ({ name: keySchema.name, type: keySchema.type, })) ?? [], attributes: table.attributes?.map((attribute) => ({ name: attribute.name, type: attribute.type, })) ?? [], }; }); }