rads-db 3.2.24 → 3.2.26
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.
|
@@ -94,35 +94,7 @@ function buildObjectSchema(entity, schema, allOptional = false) {
|
|
|
94
94
|
} : {})
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
const
|
|
98
|
-
const s = {
|
|
99
|
-
type: "string"
|
|
100
|
-
};
|
|
101
|
-
return {
|
|
102
|
-
[`${name}_ieq`]: s,
|
|
103
|
-
[`${name}_istartsWith`]: s,
|
|
104
|
-
[`${name}_startsWith`]: s,
|
|
105
|
-
[`${name}_icontains`]: s,
|
|
106
|
-
[`${name}_contains`]: s,
|
|
107
|
-
[`${name}_iendsWith`]: s,
|
|
108
|
-
[`${name}_endsWith`]: s,
|
|
109
|
-
[`${name}_gt`]: s,
|
|
110
|
-
[`${name}_gte`]: s,
|
|
111
|
-
[`${name}_lt`]: s,
|
|
112
|
-
[`${name}_lte`]: s
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
const numberOps = name => {
|
|
116
|
-
const n = {
|
|
117
|
-
type: "number"
|
|
118
|
-
};
|
|
119
|
-
return {
|
|
120
|
-
[`${name}_gt`]: n,
|
|
121
|
-
[`${name}_gte`]: n,
|
|
122
|
-
[`${name}_lt`]: n,
|
|
123
|
-
[`${name}_lte`]: n
|
|
124
|
-
};
|
|
125
|
-
};
|
|
97
|
+
const WHERE_OPERATORS_DESCRIPTION = "Suffix operators: strings \u2014 _in, _ieq, _istartsWith, _startsWith, _icontains, _contains, _iendsWith, _endsWith, _gt, _gte, _lt, _lte; numbers \u2014 _in, _gt, _gte, _lt, _lte; optional fields \u2014 _isNull; arrays \u2014 _isEmpty; JSON \u2014 _jsonContains";
|
|
126
98
|
const relationWhereOas = () => ({
|
|
127
99
|
type: "object",
|
|
128
100
|
properties: {
|
|
@@ -137,16 +109,6 @@ const relationWhereOas = () => ({
|
|
|
137
109
|
}
|
|
138
110
|
}
|
|
139
111
|
});
|
|
140
|
-
function addPrimitiveWhereProps(props, name, type) {
|
|
141
|
-
props[name] = primitiveToOas(type);
|
|
142
|
-
if (type !== "boolean") props[`${name}_in`] = {
|
|
143
|
-
type: "array",
|
|
144
|
-
items: primitiveToOas(type)
|
|
145
|
-
};
|
|
146
|
-
if (type === "string") Object.assign(props, stringOps(name));else if (type === "number") Object.assign(props, numberOps(name));else if (type === "Record<string, any>") props[`${name}_jsonContains`] = {
|
|
147
|
-
$ref: "#/components/schemas/WhereJsonContains"
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
112
|
function buildWhereProps(typeDef, schema) {
|
|
151
113
|
const props = {};
|
|
152
114
|
for (const [, field] of Object.entries(typeDef.fields ?? {})) {
|
|
@@ -159,7 +121,6 @@ function buildWhereProps(typeDef, schema) {
|
|
|
159
121
|
isArray
|
|
160
122
|
} = field;
|
|
161
123
|
const entry = schema[type];
|
|
162
|
-
const isPrimitive = !entry;
|
|
163
124
|
const isEnum = !!entry?.enumValues;
|
|
164
125
|
const isObject = !!entry?.fields;
|
|
165
126
|
const optional = !isRequired;
|
|
@@ -168,7 +129,7 @@ function buildWhereProps(typeDef, schema) {
|
|
|
168
129
|
enum: Object.keys(entry.enumValues)
|
|
169
130
|
} : {};
|
|
170
131
|
if (isArray) {
|
|
171
|
-
if (
|
|
132
|
+
if (isEnum) props[`${name}_arrayContains`] = enumSchema;else if (!entry) props[`${name}_arrayContains`] = primitiveToOas(type);else if (isRelation) props[`${name}_some`] = relationWhereOas();else if (isObject) props[`${name}_some`] = {
|
|
172
133
|
$ref: `#/components/schemas/${type}Where`
|
|
173
134
|
};
|
|
174
135
|
props[`${name}_isEmpty`] = {
|
|
@@ -187,13 +148,12 @@ function buildWhereProps(typeDef, schema) {
|
|
|
187
148
|
};
|
|
188
149
|
} else if (isEnum) {
|
|
189
150
|
props[name] = enumSchema;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
151
|
+
} else if (type === "Record<string, any>") {
|
|
152
|
+
props[`${name}_jsonContains`] = {
|
|
153
|
+
$ref: "#/components/schemas/WhereJsonContains"
|
|
193
154
|
};
|
|
194
|
-
Object.assign(props, stringOps(name));
|
|
195
155
|
} else {
|
|
196
|
-
|
|
156
|
+
props[name] = primitiveToOas(type);
|
|
197
157
|
}
|
|
198
158
|
if (optional) props[`${name}_isNull`] = {
|
|
199
159
|
type: "boolean"
|
|
@@ -205,6 +165,8 @@ function buildWhereSchema(typeName, typeDef, schema) {
|
|
|
205
165
|
const selfRef = `#/components/schemas/${typeName}Where`;
|
|
206
166
|
return {
|
|
207
167
|
type: "object",
|
|
168
|
+
description: WHERE_OPERATORS_DESCRIPTION,
|
|
169
|
+
additionalProperties: true,
|
|
208
170
|
properties: {
|
|
209
171
|
_not: {
|
|
210
172
|
$ref: selfRef
|
|
@@ -234,7 +196,8 @@ function buildIncludeSchema(typeDef, schema) {
|
|
|
234
196
|
const canSubInclude = field.isRelation || entry?.fields && !entry.enumValues;
|
|
235
197
|
if (canSubInclude) {
|
|
236
198
|
includeProps[field.name] = {
|
|
237
|
-
|
|
199
|
+
type: "object",
|
|
200
|
+
additionalProperties: true
|
|
238
201
|
};
|
|
239
202
|
} else {
|
|
240
203
|
primitiveFields.push(field.name);
|
|
@@ -52,51 +52,24 @@ function buildObjectSchema(entity, schema, allOptional = false) {
|
|
|
52
52
|
...required.length > 0 ? { required } : {}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
const s = { type: "string" };
|
|
57
|
-
return {
|
|
58
|
-
[`${name}_ieq`]: s,
|
|
59
|
-
[`${name}_istartsWith`]: s,
|
|
60
|
-
[`${name}_startsWith`]: s,
|
|
61
|
-
[`${name}_icontains`]: s,
|
|
62
|
-
[`${name}_contains`]: s,
|
|
63
|
-
[`${name}_iendsWith`]: s,
|
|
64
|
-
[`${name}_endsWith`]: s,
|
|
65
|
-
[`${name}_gt`]: s,
|
|
66
|
-
[`${name}_gte`]: s,
|
|
67
|
-
[`${name}_lt`]: s,
|
|
68
|
-
[`${name}_lte`]: s
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
const numberOps = (name) => {
|
|
72
|
-
const n = { type: "number" };
|
|
73
|
-
return { [`${name}_gt`]: n, [`${name}_gte`]: n, [`${name}_lt`]: n, [`${name}_lte`]: n };
|
|
74
|
-
};
|
|
55
|
+
const WHERE_OPERATORS_DESCRIPTION = "Suffix operators: strings \u2014 _in, _ieq, _istartsWith, _startsWith, _icontains, _contains, _iendsWith, _endsWith, _gt, _gte, _lt, _lte; numbers \u2014 _in, _gt, _gte, _lt, _lte; optional fields \u2014 _isNull; arrays \u2014 _isEmpty; JSON \u2014 _jsonContains";
|
|
75
56
|
const relationWhereOas = () => ({
|
|
76
57
|
type: "object",
|
|
77
58
|
properties: { id: { type: "string" }, id_in: { type: "array", items: { type: "string" } } }
|
|
78
59
|
});
|
|
79
|
-
function addPrimitiveWhereProps(props, name, type) {
|
|
80
|
-
props[name] = primitiveToOas(type);
|
|
81
|
-
if (type !== "boolean") props[`${name}_in`] = { type: "array", items: primitiveToOas(type) };
|
|
82
|
-
if (type === "string") Object.assign(props, stringOps(name));
|
|
83
|
-
else if (type === "number") Object.assign(props, numberOps(name));
|
|
84
|
-
else if (type === "Record<string, any>")
|
|
85
|
-
props[`${name}_jsonContains`] = { $ref: "#/components/schemas/WhereJsonContains" };
|
|
86
|
-
}
|
|
87
60
|
function buildWhereProps(typeDef, schema) {
|
|
88
61
|
const props = {};
|
|
89
62
|
for (const [, field] of Object.entries(typeDef.fields ?? {})) {
|
|
90
63
|
if (field.isInverseRelation) continue;
|
|
91
64
|
const { name, type, isRelation, isRequired, isArray } = field;
|
|
92
65
|
const entry = schema[type];
|
|
93
|
-
const isPrimitive = !entry;
|
|
94
66
|
const isEnum = !!entry?.enumValues;
|
|
95
67
|
const isObject = !!entry?.fields;
|
|
96
68
|
const optional = !isRequired;
|
|
97
69
|
const enumSchema = isEnum ? { type: "string", enum: Object.keys(entry.enumValues) } : {};
|
|
98
70
|
if (isArray) {
|
|
99
|
-
if (
|
|
71
|
+
if (isEnum) props[`${name}_arrayContains`] = enumSchema;
|
|
72
|
+
else if (!entry) props[`${name}_arrayContains`] = primitiveToOas(type);
|
|
100
73
|
else if (isRelation) props[`${name}_some`] = relationWhereOas();
|
|
101
74
|
else if (isObject) props[`${name}_some`] = { $ref: `#/components/schemas/${type}Where` };
|
|
102
75
|
props[`${name}_isEmpty`] = { type: "boolean" };
|
|
@@ -109,10 +82,10 @@ function buildWhereProps(typeDef, schema) {
|
|
|
109
82
|
props[name] = { $ref: `#/components/schemas/${type}Where` };
|
|
110
83
|
} else if (isEnum) {
|
|
111
84
|
props[name] = enumSchema;
|
|
112
|
-
|
|
113
|
-
|
|
85
|
+
} else if (type === "Record<string, any>") {
|
|
86
|
+
props[`${name}_jsonContains`] = { $ref: "#/components/schemas/WhereJsonContains" };
|
|
114
87
|
} else {
|
|
115
|
-
|
|
88
|
+
props[name] = primitiveToOas(type);
|
|
116
89
|
}
|
|
117
90
|
if (optional) props[`${name}_isNull`] = { type: "boolean" };
|
|
118
91
|
}
|
|
@@ -122,6 +95,8 @@ function buildWhereSchema(typeName, typeDef, schema) {
|
|
|
122
95
|
const selfRef = `#/components/schemas/${typeName}Where`;
|
|
123
96
|
return {
|
|
124
97
|
type: "object",
|
|
98
|
+
description: WHERE_OPERATORS_DESCRIPTION,
|
|
99
|
+
additionalProperties: true,
|
|
125
100
|
properties: {
|
|
126
101
|
_not: { $ref: selfRef },
|
|
127
102
|
_and: { type: "array", items: { $ref: selfRef } },
|
|
@@ -138,7 +113,7 @@ function buildIncludeSchema(typeDef, schema) {
|
|
|
138
113
|
const entry = schema[field.type];
|
|
139
114
|
const canSubInclude = field.isRelation || entry?.fields && !entry.enumValues;
|
|
140
115
|
if (canSubInclude) {
|
|
141
|
-
includeProps[field.name] = {
|
|
116
|
+
includeProps[field.name] = { type: "object", additionalProperties: true };
|
|
142
117
|
} else {
|
|
143
118
|
primitiveFields.push(field.name);
|
|
144
119
|
}
|