@adaptic/backend-legacy 0.0.920 → 0.0.921

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.
@@ -13,6 +13,10 @@
13
13
  * fields (Date, Decimal, bigint, JsonValue, nested relations, etc.) which cannot
14
14
  * be enumerated exhaustively. The return value is used as Apollo OperationVariables.
15
15
  *
16
+ * Class instances (Date, Decimal, etc.) are preserved as leaf values — only plain
17
+ * objects and arrays are recursed into. This prevents Decimal objects (which have
18
+ * no own enumerable keys) from being incorrectly stripped as "empty objects".
19
+ *
16
20
  * We use Record<string, unknown> for the parameter to accept all generated Prisma
17
21
  * input shapes without needing to enumerate every possible field type.
18
22
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,OAAO,GACjE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAmErC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,OAAO,GACjE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CA4DrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CACl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CAAC,aAAa,CAAC,YAAY,CAAC;wBAC3B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EACvC,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;QACtC,CAAC,CAAE,GAA+B;QAClC,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
@@ -5,6 +5,16 @@
5
5
  * This file provides a utils/index.mjs export path for ESM imports
6
6
  * from generated CRUD files that import from './utils/index.mjs'
7
7
  */
8
+ /**
9
+ * Check if a value is a plain object (created via {} or new Object()), as opposed
10
+ * to a class instance (Date, Decimal, Buffer, etc.) that should be treated as a leaf.
11
+ */
12
+ function isPlainObject(value) {
13
+ if (typeof value !== 'object' || value === null)
14
+ return false;
15
+ const proto = Object.getPrototypeOf(value);
16
+ return proto === Object.prototype || proto === null;
17
+ }
8
18
  /**
9
19
  * Recursively removes undefined and null properties from an object or array.
10
20
  *
@@ -13,6 +23,10 @@
13
23
  * fields (Date, Decimal, bigint, JsonValue, nested relations, etc.) which cannot
14
24
  * be enumerated exhaustively. The return value is used as Apollo OperationVariables.
15
25
  *
26
+ * Class instances (Date, Decimal, etc.) are preserved as leaf values — only plain
27
+ * objects and arrays are recursed into. This prevents Decimal objects (which have
28
+ * no own enumerable keys) from being incorrectly stripped as "empty objects".
29
+ *
16
30
  * We use Record<string, unknown> for the parameter to accept all generated Prisma
17
31
  * input shapes without needing to enumerate every possible field type.
18
32
  */
@@ -22,21 +36,17 @@ export function removeUndefinedProps(obj) {
22
36
  .map((item) => removeUndefinedProps(item))
23
37
  .filter((item) => item !== undefined &&
24
38
  item !== null &&
25
- (typeof item !== 'object' ||
39
+ (!isPlainObject(item) ||
26
40
  Object.keys(item).length > 0));
27
41
  }
28
- else if (typeof obj === 'object' &&
29
- obj !== null &&
30
- !(obj instanceof Date)) {
42
+ else if (isPlainObject(obj)) {
31
43
  const record = obj;
32
44
  return Object.keys(record).reduce((acc, key) => {
33
45
  const value = record[key];
34
46
  if (value !== undefined && value !== null) {
35
47
  let cleanedValue;
36
48
  if (key === 'where' &&
37
- typeof value === 'object' &&
38
- value !== null &&
39
- !(value instanceof Date)) {
49
+ isPlainObject(value)) {
40
50
  const whereObj = value;
41
51
  if (Object.prototype.hasOwnProperty.call(whereObj, 'id') &&
42
52
  whereObj.id !== undefined) {
@@ -56,8 +66,7 @@ export function removeUndefinedProps(obj) {
56
66
  }
57
67
  if (cleanedValue !== undefined &&
58
68
  cleanedValue !== null &&
59
- (typeof cleanedValue !== 'object' ||
60
- cleanedValue instanceof Date ||
69
+ (!isPlainObject(cleanedValue) ||
61
70
  Object.keys(cleanedValue).length > 0)) {
62
71
  acc[key] = cleanedValue;
63
72
  }
package/esm/utils.d.ts CHANGED
@@ -6,6 +6,10 @@
6
6
  * fields (Date, Decimal, bigint, JsonValue, nested relations, etc.) which cannot
7
7
  * be enumerated exhaustively. The return value is used as Apollo OperationVariables.
8
8
  *
9
+ * Class instances (Date, Decimal, etc.) are preserved as leaf values — only plain
10
+ * objects and arrays are recursed into. This prevents Decimal objects (which have
11
+ * no own enumerable keys) from being incorrectly stripped as "empty objects".
12
+ *
9
13
  * We use Record<string, unknown> for the parameter to accept all generated Prisma
10
14
  * input shapes without needing to enumerate every possible field type.
11
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,OAAO,GACjE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAmErC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,OAAO,GACjE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CA4DrC"}
package/esm/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAkE;IAElE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG;aACP,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;aACzC,MAAM,CACL,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,KAAK,SAAS;YAClB,IAAI,KAAK,IAAI;YACb,CAAC,OAAO,IAAI,KAAK,QAAQ;gBACvB,MAAM,CAAC,IAAI,CAAC,IAA+B,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CACvB,CAAC;IAC5C,CAAC;SAAM,IACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,CAAC,CAAC,GAAG,YAAY,IAAI,CAAC,EACtB,CAAC;QACD,MAAM,MAAM,GAAG,GAA8B,CAAC;QAC9C,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAA4B,EAAE,GAAG,EAAE,EAAE;YACtE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAE1B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,C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I,CAAC;wBACpD,QAAQ,CAAC,EAAE,KAAK,SAAS,EACzB,CAAC;wBACD,4CAA4C;wBAC5C,YAAY,GAAG;4BACb,EAAE,EAAE,oBAAoB,CAAC,QAAQ,CAAC,EAA6B,CAAC;yBACjE,CAAC;oBACJ,CAAC;yBAAM,CAAC;wBACN,wEAAwE;wBACxE,YAAY,GAAG,oBAAoB,CACjC,KAAgC,CACjC,CAAC;oBACJ,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,8BAA8B;oBAC9B,YAAY,GAAG,oBAAoB,CAAC,KAAgC,CAAC,CAAC;gBACxE,CAAC;gBAED,IACE,YAAY,KAAK,SAAS;oBAC1B,YAAY,KAAK,IAAI;oBACrB,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC;wBAC3B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EACvC,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;QACtC,CAAC,CAAE,GAA+B;QAClC,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
package/esm/utils.mjs CHANGED
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Check if a value is a plain object (created via {} or new Object()), as opposed
3
+ * to a class instance (Date, Decimal, Buffer, etc.) that should be treated as a leaf.
4
+ */
5
+ function isPlainObject(value) {
6
+ if (typeof value !== 'object' || value === null)
7
+ return false;
8
+ const proto = Object.getPrototypeOf(value);
9
+ return proto === Object.prototype || proto === null;
10
+ }
1
11
  /**
2
12
  * Recursively removes undefined and null properties from an object or array.
3
13
  *
@@ -6,6 +16,10 @@
6
16
  * fields (Date, Decimal, bigint, JsonValue, nested relations, etc.) which cannot
7
17
  * be enumerated exhaustively. The return value is used as Apollo OperationVariables.
8
18
  *
19
+ * Class instances (Date, Decimal, etc.) are preserved as leaf values — only plain
20
+ * objects and arrays are recursed into. This prevents Decimal objects (which have
21
+ * no own enumerable keys) from being incorrectly stripped as "empty objects".
22
+ *
9
23
  * We use Record<string, unknown> for the parameter to accept all generated Prisma
10
24
  * input shapes without needing to enumerate every possible field type.
11
25
  */
@@ -15,21 +29,17 @@ export function removeUndefinedProps(obj) {
15
29
  .map((item) => removeUndefinedProps(item))
16
30
  .filter((item) => item !== undefined &&
17
31
  item !== null &&
18
- (typeof item !== 'object' ||
32
+ (!isPlainObject(item) ||
19
33
  Object.keys(item).length > 0));
20
34
  }
21
- else if (typeof obj === 'object' &&
22
- obj !== null &&
23
- !(obj instanceof Date)) {
35
+ else if (isPlainObject(obj)) {
24
36
  const record = obj;
25
37
  return Object.keys(record).reduce((acc, key) => {
26
38
  const value = record[key];
27
39
  if (value !== undefined && value !== null) {
28
40
  let cleanedValue;
29
41
  if (key === 'where' &&
30
- typeof value === 'object' &&
31
- value !== null &&
32
- !(value instanceof Date)) {
42
+ isPlainObject(value)) {
33
43
  const whereObj = value;
34
44
  if (Object.prototype.hasOwnProperty.call(whereObj, 'id') &&
35
45
  whereObj.id !== undefined) {
@@ -49,8 +59,7 @@ export function removeUndefinedProps(obj) {
49
59
  }
50
60
  if (cleanedValue !== undefined &&
51
61
  cleanedValue !== null &&
52
- (typeof cleanedValue !== 'object' ||
53
- cleanedValue instanceof Date ||
62
+ (!isPlainObject(cleanedValue) ||
54
63
  Object.keys(cleanedValue).length > 0)) {
55
64
  acc[key] = cleanedValue;
56
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptic/backend-legacy",
3
- "version": "0.0.920",
3
+ "version": "0.0.921",
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",
package/utils.cjs CHANGED
@@ -1,6 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeUndefinedProps = removeUndefinedProps;
4
+ /**
5
+ * Check if a value is a plain object (created via {} or new Object()), as opposed
6
+ * to a class instance (Date, Decimal, Buffer, etc.) that should be treated as a leaf.
7
+ */
8
+ function isPlainObject(value) {
9
+ if (typeof value !== 'object' || value === null)
10
+ return false;
11
+ const proto = Object.getPrototypeOf(value);
12
+ return proto === Object.prototype || proto === null;
13
+ }
4
14
  /**
5
15
  * Recursively removes undefined and null properties from an object or array.
6
16
  *
@@ -9,6 +19,10 @@ exports.removeUndefinedProps = removeUndefinedProps;
9
19
  * fields (Date, Decimal, bigint, JsonValue, nested relations, etc.) which cannot
10
20
  * be enumerated exhaustively. The return value is used as Apollo OperationVariables.
11
21
  *
22
+ * Class instances (Date, Decimal, etc.) are preserved as leaf values — only plain
23
+ * objects and arrays are recursed into. This prevents Decimal objects (which have
24
+ * no own enumerable keys) from being incorrectly stripped as "empty objects".
25
+ *
12
26
  * We use Record<string, unknown> for the parameter to accept all generated Prisma
13
27
  * input shapes without needing to enumerate every possible field type.
14
28
  */
@@ -18,21 +32,17 @@ function removeUndefinedProps(obj) {
18
32
  .map((item) => removeUndefinedProps(item))
19
33
  .filter((item) => item !== undefined &&
20
34
  item !== null &&
21
- (typeof item !== 'object' ||
35
+ (!isPlainObject(item) ||
22
36
  Object.keys(item).length > 0));
23
37
  }
24
- else if (typeof obj === 'object' &&
25
- obj !== null &&
26
- !(obj instanceof Date)) {
38
+ else if (isPlainObject(obj)) {
27
39
  const record = obj;
28
40
  return Object.keys(record).reduce((acc, key) => {
29
41
  const value = record[key];
30
42
  if (value !== undefined && value !== null) {
31
43
  let cleanedValue;
32
44
  if (key === 'where' &&
33
- typeof value === 'object' &&
34
- value !== null &&
35
- !(value instanceof Date)) {
45
+ isPlainObject(value)) {
36
46
  const whereObj = value;
37
47
  if (Object.prototype.hasOwnProperty.call(whereObj, 'id') &&
38
48
  whereObj.id !== undefined) {
@@ -52,8 +62,7 @@ function removeUndefinedProps(obj) {
52
62
  }
53
63
  if (cleanedValue !== undefined &&
54
64
  cleanedValue !== null &&
55
- (typeof cleanedValue !== 'object' ||
56
- cleanedValue instanceof Date ||
65
+ (!isPlainObject(cleanedValue) ||
57
66
  Object.keys(cleanedValue).length > 0)) {
58
67
  acc[key] = cleanedValue;
59
68
  }
package/utils.d.ts CHANGED
@@ -6,6 +6,10 @@
6
6
  * fields (Date, Decimal, bigint, JsonValue, nested relations, etc.) which cannot
7
7
  * be enumerated exhaustively. The return value is used as Apollo OperationVariables.
8
8
  *
9
+ * Class instances (Date, Decimal, etc.) are preserved as leaf values — only plain
10
+ * objects and arrays are recursed into. This prevents Decimal objects (which have
11
+ * no own enumerable keys) from being incorrectly stripped as "empty objects".
12
+ *
9
13
  * We use Record<string, unknown> for the parameter to accept all generated Prisma
10
14
  * input shapes without needing to enumerate every possible field type.
11
15
  */