rads-db 3.2.22 → 3.2.23

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.
@@ -34,10 +34,28 @@ function primitiveToOas(type) {
34
34
  return {};
35
35
  }
36
36
  }
37
+ function relationToOas(field, schema) {
38
+ const properties = {
39
+ id: {
40
+ type: "string"
41
+ }
42
+ };
43
+ for (const fname of field.relationDenormFields ?? []) {
44
+ const relField = schema[field.type]?.fields?.[fname];
45
+ properties[fname] = relField ? primitiveToOas(relField.type) : {};
46
+ }
47
+ return {
48
+ type: "object",
49
+ required: ["id"],
50
+ properties
51
+ };
52
+ }
37
53
  function fieldToOas(field, schema) {
38
54
  const entry = schema[field.type];
39
55
  let itemSchema;
40
- if (entry) {
56
+ if (field.isRelation) {
57
+ itemSchema = relationToOas(field, schema);
58
+ } else if (entry) {
41
59
  itemSchema = entry.enumValues ? {
42
60
  type: "string",
43
61
  enum: Object.keys(entry.enumValues)
@@ -14,10 +14,20 @@ function primitiveToOas(type) {
14
14
  return {};
15
15
  }
16
16
  }
17
+ function relationToOas(field, schema) {
18
+ const properties = { id: { type: "string" } };
19
+ for (const fname of field.relationDenormFields ?? []) {
20
+ const relField = schema[field.type]?.fields?.[fname];
21
+ properties[fname] = relField ? primitiveToOas(relField.type) : {};
22
+ }
23
+ return { type: "object", required: ["id"], properties };
24
+ }
17
25
  function fieldToOas(field, schema) {
18
26
  const entry = schema[field.type];
19
27
  let itemSchema;
20
- if (entry) {
28
+ if (field.isRelation) {
29
+ itemSchema = relationToOas(field, schema);
30
+ } else if (entry) {
21
31
  itemSchema = entry.enumValues ? { type: "string", enum: Object.keys(entry.enumValues) } : { $ref: `#/components/schemas/${field.type}` };
22
32
  } else {
23
33
  itemSchema = primitiveToOas(field.type);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rads-db",
3
- "version": "3.2.22",
3
+ "version": "3.2.23",
4
4
  "description": "Say goodbye to boilerplate code and hello to efficient and elegant syntax.",
5
5
  "author": "",
6
6
  "license": "ISC",