@brickkit/effect 0.16.0-beta.15 → 0.16.0-beta.16
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/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2093,7 +2093,10 @@ function crud(service, options) {
|
|
|
2093
2093
|
offset: optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
2094
2094
|
includeTotal: optional(Schema.Boolean)
|
|
2095
2095
|
};
|
|
2096
|
-
const
|
|
2096
|
+
const rowOf = (loose) => struct(Object.fromEntries([...readable, ...includable].map((key) => {
|
|
2097
|
+
const schema = fields[key].schema ?? (fields[key].scrub ? Schema.Unknown : schemas[key]);
|
|
2098
|
+
return [key, loose || fields[key].resolve ? optional(schema) : schema];
|
|
2099
|
+
})));
|
|
2097
2100
|
const writeSchema = (kind) => struct(Object.fromEntries(Object.entries(fields).filter(([, policy]) => policy[kind]).map(([key]) => [key, kind === "update" || columns[key].hasDefault || !columns[key].notNull ? optional(schemas[key]) : schemas[key]])));
|
|
2098
2101
|
const createSchema = writeSchema("create");
|
|
2099
2102
|
const updateSchema = writeSchema("update");
|
|
@@ -2125,7 +2128,7 @@ function crud(service, options) {
|
|
|
2125
2128
|
})) }),
|
|
2126
2129
|
bulkDelete: struct({ ids: batch(bodyId, true) })
|
|
2127
2130
|
};
|
|
2128
|
-
const
|
|
2131
|
+
const outputsFor = (rowSchema) => ({
|
|
2129
2132
|
list: struct({
|
|
2130
2133
|
items: Schema.Array(rowSchema),
|
|
2131
2134
|
total: optional(Schema.Int),
|
|
@@ -2143,7 +2146,9 @@ function crud(service, options) {
|
|
|
2143
2146
|
bulkCreate: struct({ items: Schema.Array(rowSchema) }),
|
|
2144
2147
|
bulkUpdate: struct({ items: Schema.Array(rowSchema) }),
|
|
2145
2148
|
bulkDelete: struct({ count: Schema.Int })
|
|
2146
|
-
};
|
|
2149
|
+
});
|
|
2150
|
+
const outputs = outputsFor(rowOf(false));
|
|
2151
|
+
const runtimeOutputs = outputsFor(rowOf(true));
|
|
2147
2152
|
const resource = service.getResource(name) ?? service.resource({
|
|
2148
2153
|
name,
|
|
2149
2154
|
table,
|
|
@@ -2209,6 +2214,7 @@ function crud(service, options) {
|
|
|
2209
2214
|
method,
|
|
2210
2215
|
input: inputs[operation],
|
|
2211
2216
|
output: outputs[operation],
|
|
2217
|
+
runtimeOutput: runtimeOutputs[operation],
|
|
2212
2218
|
strict: "deep",
|
|
2213
2219
|
audit: writes.has(operation) ? inlineAuditOptions({ resource: name }) : false,
|
|
2214
2220
|
checkInput: (input) => whereDepthExceeded(input) ? [{
|