Comparing version 0.0.14 to 0.0.15
@@ -36,7 +36,7 @@ import { schema, sc } from "compact-json-schema"; | ||
const idField2 = systemTable?.fields.find((item) => item.name === form.idField); | ||
if (!idField2) throw Error(`Unable to find ID field ${form.idField} in table ${systemTable}`); | ||
if (!idField2) throw Error(`Unable to find ID field ${form.idField} in table ${systemTable?.name}`); | ||
return idField2; | ||
} | ||
const idField = systemTable?.fields.find((item) => item.isId); | ||
if (!idField) throw Error(`Unable to find ID field in table ${systemTable}`); | ||
if (!idField) throw Error(`Unable to find ID field in table ${form.systemTable}`); | ||
return idField; | ||
@@ -220,3 +220,4 @@ }; | ||
} | ||
} | ||
}, | ||
take: 100 | ||
}; | ||
@@ -339,2 +340,5 @@ postCallbacks.push((item) => { | ||
} | ||
if (!path.startsWith("/")) { | ||
return reply.code(400).send({ error: { path: { message: 'Path must started with "/"' } } }); | ||
} | ||
const id = getUniqueName(systemTable, (name) => !fastify.marceline.endpoints.hasItem(name)); | ||
@@ -349,2 +353,5 @@ const newItem = fastify.marceline.endpoints.createItem({ id, path, systemTable, data: data2 }); | ||
if (!item) return reply.code(400).send(`Endpoint ${itemId} not found`); | ||
if (!path.startsWith("/")) { | ||
return reply.code(400).send({ error: { path: { message: 'Path must started with "/"' } } }); | ||
} | ||
const data2 = item.data; | ||
@@ -702,2 +709,4 @@ for (let newItem of newData) { | ||
if (!form) return reply.code(500).send("Contact with administrator. Error: Form not found"); | ||
const idField = getIdField(item); | ||
req.where = { [idField.name]: parseIdField(idField, req.params.itemId) }; | ||
const resp = await parseBody(fastify, req, reply, form, req.body); | ||
@@ -709,7 +718,6 @@ if (typeof resp === "object" && resp === reply) return resp; | ||
} | ||
const idField = getIdField(item); | ||
const newObject = await fastify.prisma[item.systemTable].update({ | ||
select: { [idField.name]: true }, | ||
data: req.modifiedBody, | ||
where: { id: parseIdField(idField, req.params.itemId) } | ||
where: req.where | ||
}); | ||
@@ -730,4 +738,9 @@ Object.assign(req.modifiedBody, newObject); | ||
const idField = getIdField(item); | ||
req.where = { [idField.name]: parseIdField(idField, req.params.itemId) }; | ||
if (entry.hooks.bodyModifier && entry.hooks.bodyModifier.length > 0) { | ||
const resp = await fastify.marceline.applyHooks("bodyModifier", entry.hooks.bodyModifier, req, reply); | ||
if (typeof resp === "object" && resp === reply) return resp; | ||
} | ||
await fastify.prisma[item.systemTable].delete({ | ||
where: { id: parseIdField(idField, req.params.itemId) } | ||
where: req.where | ||
}); | ||
@@ -734,0 +747,0 @@ if (entry.hooks.postEffect && entry.hooks.postEffect.length > 0) { |
{ | ||
"name": "marceline", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"main": "dist/plugin/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
475758
2811