adaptic-backend 1.0.31 → 1.0.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adaptic-backend",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "Backend executable CRUD functions with dynamic variables construction, and type definitions for the Adaptic AI platform.",
5
5
  "type": "module",
6
6
  "types": "index.d.ts",
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAsBlD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CA4ClD"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB,CAAC,GAAQ;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG;aACP,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;aACvC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;SAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACnD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,GAAG,EAAE,EAAE;YAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,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KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC1C,IAAI,YAAY,CAAC;gBAEjB,IAAI,GAAG,KAAK,OAAO,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;oBACnE,IAAI,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;wBACzD,4CAA4C;wBAC5C,YAAY,GAAG,EAAE,EAAE,EAAE,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;oBACxD,CAAC;yBAAM,CAAC;wBACN,wEAAwE;wBACxE,YAAY,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;oBAC7C,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,8BAA8B;oBAC9B,YAAY,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;gBAC7C,CAAC;gBAED,IACE,YAAY,KAAK,SAAS;oBAC1B,YAAY,KAAK,IAAI;oBACrB,CAAC,OAAO,YAAY,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAC1E,CAAC;oBACD,GAAG,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC;gBAC1B,CAAC;YACH,CAAC;YAED,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;IAED,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7D,CAAC"}
package/server/utils.mjs CHANGED
@@ -2,20 +2,38 @@ export function removeUndefinedProps(obj) {
2
2
  if (Array.isArray(obj)) {
3
3
  return obj
4
4
  .map(item => removeUndefinedProps(item))
5
- .filter(item => item !== undefined && Object.keys(item).length > 0);
5
+ .filter(item => item !== undefined &&
6
+ item !== null &&
7
+ (typeof item !== 'object' || Object.keys(item).length > 0));
6
8
  }
7
9
  else if (typeof obj === 'object' && obj !== null) {
8
10
  return Object.keys(obj).reduce((acc, key) => {
9
- const value = obj[key];
10
- if (value !== undefined) {
11
- const cleanedValue = removeUndefinedProps(value);
12
- if (cleanedValue !== undefined && (typeof cleanedValue !== 'object' || Object.keys(cleanedValue).length > 0)) {
11
+ let value = obj[key];
12
+ if (value !== undefined && value !== null) {
13
+ let cleanedValue;
14
+ if (key === 'where' && typeof value === 'object' && value !== null) {
15
+ if (value.hasOwnProperty('id') && value.id !== undefined) {
16
+ // Retain only the 'id' field within 'where'
17
+ cleanedValue = { id: removeUndefinedProps(value.id) };
18
+ }
19
+ else {
20
+ // Process 'where' object normally if 'id' is undefined or doesn't exist
21
+ cleanedValue = removeUndefinedProps(value);
22
+ }
23
+ }
24
+ else {
25
+ // Process other keys normally
26
+ cleanedValue = removeUndefinedProps(value);
27
+ }
28
+ if (cleanedValue !== undefined &&
29
+ cleanedValue !== null &&
30
+ (typeof cleanedValue !== 'object' || Object.keys(cleanedValue).length > 0)) {
13
31
  acc[key] = cleanedValue;
14
32
  }
15
33
  }
16
34
  return acc;
17
35
  }, {});
18
36
  }
19
- return obj !== undefined ? obj : undefined;
37
+ return obj !== undefined && obj !== null ? obj : undefined;
20
38
  }
21
39
  //# sourceMappingURL=utils.js.map
package/utils.js CHANGED
@@ -5,20 +5,38 @@ function removeUndefinedProps(obj) {
5
5
  if (Array.isArray(obj)) {
6
6
  return obj
7
7
  .map(item => removeUndefinedProps(item))
8
- .filter(item => item !== undefined && Object.keys(item).length > 0);
8
+ .filter(item => item !== undefined &&
9
+ item !== null &&
10
+ (typeof item !== 'object' || Object.keys(item).length > 0));
9
11
  }
10
12
  else if (typeof obj === 'object' && obj !== null) {
11
13
  return Object.keys(obj).reduce((acc, key) => {
12
- const value = obj[key];
13
- if (value !== undefined) {
14
- const cleanedValue = removeUndefinedProps(value);
15
- if (cleanedValue !== undefined && (typeof cleanedValue !== 'object' || Object.keys(cleanedValue).length > 0)) {
14
+ let value = obj[key];
15
+ if (value !== undefined && value !== null) {
16
+ let cleanedValue;
17
+ if (key === 'where' && typeof value === 'object' && value !== null) {
18
+ if (value.hasOwnProperty('id') && value.id !== undefined) {
19
+ // Retain only the 'id' field within 'where'
20
+ cleanedValue = { id: removeUndefinedProps(value.id) };
21
+ }
22
+ else {
23
+ // Process 'where' object normally if 'id' is undefined or doesn't exist
24
+ cleanedValue = removeUndefinedProps(value);
25
+ }
26
+ }
27
+ else {
28
+ // Process other keys normally
29
+ cleanedValue = removeUndefinedProps(value);
30
+ }
31
+ if (cleanedValue !== undefined &&
32
+ cleanedValue !== null &&
33
+ (typeof cleanedValue !== 'object' || Object.keys(cleanedValue).length > 0)) {
16
34
  acc[key] = cleanedValue;
17
35
  }
18
36
  }
19
37
  return acc;
20
38
  }, {});
21
39
  }
22
- return obj !== undefined ? obj : undefined;
40
+ return obj !== undefined && obj !== null ? obj : undefined;
23
41
  }
24
42
  //# sourceMappingURL=utils.js.map