UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

62 lines (61 loc) 2.06 kB
import { createColumnModels as u } from "../../synapse-client/SynapseClient.js"; import "@sage-bionetworks/synapse-client/generated/models/ErrorResponseCode"; import "@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse"; import "@sage-bionetworks/synapse-client/util/SynapseClientError"; import "@sage-bionetworks/synapse-types"; import "./EntityTypeUtils.js"; import "../SynapseConstants.js"; import "@sage-bionetworks/synapse-client/util/synapseClientFetch"; import { isEqualTreatUndefinedAsMissing as f } from "./IsEqualTreatUndefinedAsMissing.js"; function p(i, d) { const l = /* @__PURE__ */ new Set(); for (const n of i) l.add(n.id); for (const n of d) if (n.id != null && !l.has(n.id)) throw new Error( `Proposed schema contains a new column model with ID ${n.id} that is not in the old schema.` ); } async function q(i, d, l, n) { p(l, n); const c = /* @__PURE__ */ new Map(); for (const e of l) c.set(e.id, e); const a = []; for (const e of n) { const o = { ...e }; if (o.id != null) { const t = c.get(o.id); t != null && !f(t, o) && delete o.id; } a.push(o); } const m = (await u(i, a)).list, s = [], r = /* @__PURE__ */ new Set(); for (let e = 0; e < n.length; e++) { const o = n[e].id ?? null, t = m[e].id; o != null && r.add(o), r.add(t), o != null && o !== t ? s.push({ oldColumnId: o, newColumnId: t }) : o == null && s.push({ oldColumnId: null, newColumnId: t }); } for (const e of l) { const o = e.id; r.has(o) || s.push({ oldColumnId: o, newColumnId: null }); } return { concreteType: "org.sagebionetworks.repo.model.table.TableUpdateTransactionRequest", entityId: d, changes: [ { concreteType: "org.sagebionetworks.repo.model.table.TableSchemaChangeRequest", entityId: d, changes: s, orderedColumnIds: m.map((e) => e.id) } ] }; } export { q as createTableUpdateTransactionRequest }; //# sourceMappingURL=TableColumnSchemaUtils.js.map