av6-core 1.2.8 → 1.2.9
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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +9 -9
- package/dist/index.mjs +9 -9
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -45,7 +45,7 @@ interface FieldRules {
|
|
|
45
45
|
}
|
|
46
46
|
interface FieldConfig {
|
|
47
47
|
name: string;
|
|
48
|
-
db
|
|
48
|
+
db: string;
|
|
49
49
|
type: FieldType;
|
|
50
50
|
src?: SourcePath;
|
|
51
51
|
presence: Record<Op, Presence>;
|
|
@@ -61,6 +61,7 @@ interface RelationWriteConfig {
|
|
|
61
61
|
}
|
|
62
62
|
interface RelationConfig {
|
|
63
63
|
name: string;
|
|
64
|
+
db: string;
|
|
64
65
|
kind: "many" | "one";
|
|
65
66
|
presence: Record<Op, Presence>;
|
|
66
67
|
write: {
|
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ interface FieldRules {
|
|
|
45
45
|
}
|
|
46
46
|
interface FieldConfig {
|
|
47
47
|
name: string;
|
|
48
|
-
db
|
|
48
|
+
db: string;
|
|
49
49
|
type: FieldType;
|
|
50
50
|
src?: SourcePath;
|
|
51
51
|
presence: Record<Op, Presence>;
|
|
@@ -61,6 +61,7 @@ interface RelationWriteConfig {
|
|
|
61
61
|
}
|
|
62
62
|
interface RelationConfig {
|
|
63
63
|
name: string;
|
|
64
|
+
db: string;
|
|
64
65
|
kind: "many" | "one";
|
|
65
66
|
presence: Record<Op, Presence>;
|
|
66
67
|
write: {
|
package/dist/index.js
CHANGED
|
@@ -807,7 +807,7 @@ var omitUndefined = (obj) => {
|
|
|
807
807
|
|
|
808
808
|
// src/utils/dynamicPrismaBuilder.utils.ts
|
|
809
809
|
var resolveSrc = (f, env) => {
|
|
810
|
-
const src = f.src ?? `body.${f.
|
|
810
|
+
const src = f.src ?? `body.${f.db}`;
|
|
811
811
|
if (src.startsWith("body.")) return getByPath(env.body, src.slice(5));
|
|
812
812
|
if (src.startsWith("vars.")) return getByPath(env.ctx.vars ?? {}, src.slice(5));
|
|
813
813
|
if (src.startsWith("ctx.")) return getByPath(env.ctx, src.slice(4));
|
|
@@ -822,7 +822,7 @@ var setAudit = (cfg, op, out, ctx) => {
|
|
|
822
822
|
var buildScalarData = (cfg, op, env) => {
|
|
823
823
|
const out = {};
|
|
824
824
|
for (const f of cfg.fields) {
|
|
825
|
-
const dbKey = f.db
|
|
825
|
+
const dbKey = f.db;
|
|
826
826
|
const presence = f.presence[op];
|
|
827
827
|
if (presence === "forbidden") continue;
|
|
828
828
|
if (dbKey === cfg.primaryKey) continue;
|
|
@@ -835,7 +835,7 @@ var buildScalarData = (cfg, op, env) => {
|
|
|
835
835
|
return out;
|
|
836
836
|
};
|
|
837
837
|
var buildRelationWrite = (rel, op, env) => {
|
|
838
|
-
const raw = env.body[rel.
|
|
838
|
+
const raw = env.body[rel.db];
|
|
839
839
|
if (raw === void 0) return void 0;
|
|
840
840
|
const writeCfg = op === "create" ? rel.write.create : rel.write.update;
|
|
841
841
|
const itemPrimaryKey = writeCfg.itemPrimaryKey ?? "id";
|
|
@@ -843,11 +843,11 @@ var buildRelationWrite = (rel, op, env) => {
|
|
|
843
843
|
const itemBody = isRecord(item) ? item : {};
|
|
844
844
|
const itemOut = {};
|
|
845
845
|
for (const f of rel.items.fields) {
|
|
846
|
-
const dbKey = f.db
|
|
846
|
+
const dbKey = f.db;
|
|
847
847
|
const presence = f.presence[itemOp];
|
|
848
848
|
if (presence === "forbidden") continue;
|
|
849
849
|
if (dbKey === itemPrimaryKey) continue;
|
|
850
|
-
const v = itemBody[f.
|
|
850
|
+
const v = itemBody[f.db];
|
|
851
851
|
if (v === void 0) continue;
|
|
852
852
|
if (v === null && !f.allowNull) continue;
|
|
853
853
|
itemOut[dbKey] = v;
|
|
@@ -927,7 +927,7 @@ var buildPrismaData = (cfg, op, validatedBody, ctx) => {
|
|
|
927
927
|
const out = buildScalarData(cfg, op, env);
|
|
928
928
|
for (const rel of cfg.relations ?? []) {
|
|
929
929
|
const write = buildRelationWrite(rel, op, env);
|
|
930
|
-
if (write) out[rel.
|
|
930
|
+
if (write) out[rel.db] = write;
|
|
931
931
|
}
|
|
932
932
|
return out;
|
|
933
933
|
};
|
|
@@ -1138,7 +1138,7 @@ var buildRelationSchema = (rel, op) => {
|
|
|
1138
1138
|
const itemShape = {};
|
|
1139
1139
|
for (const f of rel.items.fields) {
|
|
1140
1140
|
const scalar = buildScalar(f);
|
|
1141
|
-
itemShape[f.
|
|
1141
|
+
itemShape[f.db] = applyPresence(scalar, f.presence[op]);
|
|
1142
1142
|
}
|
|
1143
1143
|
const itemSchema = import_joi.default.object(itemShape);
|
|
1144
1144
|
const base = rel.kind === "many" ? import_joi.default.array().items(itemSchema) : itemSchema;
|
|
@@ -1148,10 +1148,10 @@ var buildJoiSchemaForOp = (cfg, op) => {
|
|
|
1148
1148
|
const shape = {};
|
|
1149
1149
|
for (const f of cfg.fields) {
|
|
1150
1150
|
const scalar = buildScalar(f);
|
|
1151
|
-
shape[f.
|
|
1151
|
+
shape[f.db] = applyPresence(scalar, f.presence[op]);
|
|
1152
1152
|
}
|
|
1153
1153
|
for (const rel of cfg.relations ?? []) {
|
|
1154
|
-
shape[rel.
|
|
1154
|
+
shape[rel.db] = buildRelationSchema(rel, op);
|
|
1155
1155
|
}
|
|
1156
1156
|
return import_joi.default.object(shape).prefs({
|
|
1157
1157
|
abortEarly: cfg.validation.abortEarly,
|
package/dist/index.mjs
CHANGED
|
@@ -757,7 +757,7 @@ var omitUndefined = (obj) => {
|
|
|
757
757
|
|
|
758
758
|
// src/utils/dynamicPrismaBuilder.utils.ts
|
|
759
759
|
var resolveSrc = (f, env) => {
|
|
760
|
-
const src = f.src ?? `body.${f.
|
|
760
|
+
const src = f.src ?? `body.${f.db}`;
|
|
761
761
|
if (src.startsWith("body.")) return getByPath(env.body, src.slice(5));
|
|
762
762
|
if (src.startsWith("vars.")) return getByPath(env.ctx.vars ?? {}, src.slice(5));
|
|
763
763
|
if (src.startsWith("ctx.")) return getByPath(env.ctx, src.slice(4));
|
|
@@ -772,7 +772,7 @@ var setAudit = (cfg, op, out, ctx) => {
|
|
|
772
772
|
var buildScalarData = (cfg, op, env) => {
|
|
773
773
|
const out = {};
|
|
774
774
|
for (const f of cfg.fields) {
|
|
775
|
-
const dbKey = f.db
|
|
775
|
+
const dbKey = f.db;
|
|
776
776
|
const presence = f.presence[op];
|
|
777
777
|
if (presence === "forbidden") continue;
|
|
778
778
|
if (dbKey === cfg.primaryKey) continue;
|
|
@@ -785,7 +785,7 @@ var buildScalarData = (cfg, op, env) => {
|
|
|
785
785
|
return out;
|
|
786
786
|
};
|
|
787
787
|
var buildRelationWrite = (rel, op, env) => {
|
|
788
|
-
const raw = env.body[rel.
|
|
788
|
+
const raw = env.body[rel.db];
|
|
789
789
|
if (raw === void 0) return void 0;
|
|
790
790
|
const writeCfg = op === "create" ? rel.write.create : rel.write.update;
|
|
791
791
|
const itemPrimaryKey = writeCfg.itemPrimaryKey ?? "id";
|
|
@@ -793,11 +793,11 @@ var buildRelationWrite = (rel, op, env) => {
|
|
|
793
793
|
const itemBody = isRecord(item) ? item : {};
|
|
794
794
|
const itemOut = {};
|
|
795
795
|
for (const f of rel.items.fields) {
|
|
796
|
-
const dbKey = f.db
|
|
796
|
+
const dbKey = f.db;
|
|
797
797
|
const presence = f.presence[itemOp];
|
|
798
798
|
if (presence === "forbidden") continue;
|
|
799
799
|
if (dbKey === itemPrimaryKey) continue;
|
|
800
|
-
const v = itemBody[f.
|
|
800
|
+
const v = itemBody[f.db];
|
|
801
801
|
if (v === void 0) continue;
|
|
802
802
|
if (v === null && !f.allowNull) continue;
|
|
803
803
|
itemOut[dbKey] = v;
|
|
@@ -877,7 +877,7 @@ var buildPrismaData = (cfg, op, validatedBody, ctx) => {
|
|
|
877
877
|
const out = buildScalarData(cfg, op, env);
|
|
878
878
|
for (const rel of cfg.relations ?? []) {
|
|
879
879
|
const write = buildRelationWrite(rel, op, env);
|
|
880
|
-
if (write) out[rel.
|
|
880
|
+
if (write) out[rel.db] = write;
|
|
881
881
|
}
|
|
882
882
|
return out;
|
|
883
883
|
};
|
|
@@ -1088,7 +1088,7 @@ var buildRelationSchema = (rel, op) => {
|
|
|
1088
1088
|
const itemShape = {};
|
|
1089
1089
|
for (const f of rel.items.fields) {
|
|
1090
1090
|
const scalar = buildScalar(f);
|
|
1091
|
-
itemShape[f.
|
|
1091
|
+
itemShape[f.db] = applyPresence(scalar, f.presence[op]);
|
|
1092
1092
|
}
|
|
1093
1093
|
const itemSchema = Joi.object(itemShape);
|
|
1094
1094
|
const base = rel.kind === "many" ? Joi.array().items(itemSchema) : itemSchema;
|
|
@@ -1098,10 +1098,10 @@ var buildJoiSchemaForOp = (cfg, op) => {
|
|
|
1098
1098
|
const shape = {};
|
|
1099
1099
|
for (const f of cfg.fields) {
|
|
1100
1100
|
const scalar = buildScalar(f);
|
|
1101
|
-
shape[f.
|
|
1101
|
+
shape[f.db] = applyPresence(scalar, f.presence[op]);
|
|
1102
1102
|
}
|
|
1103
1103
|
for (const rel of cfg.relations ?? []) {
|
|
1104
|
-
shape[rel.
|
|
1104
|
+
shape[rel.db] = buildRelationSchema(rel, op);
|
|
1105
1105
|
}
|
|
1106
1106
|
return Joi.object(shape).prefs({
|
|
1107
1107
|
abortEarly: cfg.validation.abortEarly,
|