@adaptic/backend-legacy 0.0.988 → 0.0.989

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.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Utils module index
3
+ * Re-exports utility functions for CRUD operations
4
+ *
5
+ * This file provides a utils/index.mjs export path for ESM imports
6
+ * from generated CRUD files that import from './utils/index.mjs'
7
+ */
8
+ /**
9
+ * Recursively removes undefined and null properties from an object or array.
10
+ *
11
+ * This utility is called by generated CRUD functions to clean GraphQL variables
12
+ * before passing them to Apollo Client. The input objects contain Prisma-typed
13
+ * fields (Date, Decimal, bigint, JsonValue, nested relations, etc.) which cannot
14
+ * be enumerated exhaustively. The return value is used as Apollo OperationVariables.
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
+ *
20
+ * We use Record<string, unknown> for the parameter to accept all generated Prisma
21
+ * input shapes without needing to enumerate every possible field type.
22
+ */
23
+ export declare function removeUndefinedProps(obj: Record<string, unknown> | Record<string, unknown>[] | unknown): Record<string, unknown> | undefined;
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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,CAuDrC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG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AQ,EAAE,IAAI,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,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EACtE,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"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Utils module index
3
+ * Re-exports utility functions for CRUD operations
4
+ *
5
+ * This file provides a utils/index.mjs export path for ESM imports
6
+ * from generated CRUD files that import from './utils/index.mjs'
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
+ }
18
+ /**
19
+ * Recursively removes undefined and null properties from an object or array.
20
+ *
21
+ * This utility is called by generated CRUD functions to clean GraphQL variables
22
+ * before passing them to Apollo Client. The input objects contain Prisma-typed
23
+ * fields (Date, Decimal, bigint, JsonValue, nested relations, etc.) which cannot
24
+ * be enumerated exhaustively. The return value is used as Apollo OperationVariables.
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
+ *
30
+ * We use Record<string, unknown> for the parameter to accept all generated Prisma
31
+ * input shapes without needing to enumerate every possible field type.
32
+ */
33
+ export function removeUndefinedProps(obj) {
34
+ if (Array.isArray(obj)) {
35
+ return obj
36
+ .map((item) => removeUndefinedProps(item))
37
+ .filter((item) => item !== undefined &&
38
+ item !== null &&
39
+ (!isPlainObject(item) || Object.keys(item).length > 0));
40
+ }
41
+ else if (isPlainObject(obj)) {
42
+ const record = obj;
43
+ return Object.keys(record).reduce((acc, key) => {
44
+ const value = record[key];
45
+ if (value !== undefined && value !== null) {
46
+ let cleanedValue;
47
+ if (key === 'where' && isPlainObject(value)) {
48
+ const whereObj = value;
49
+ if (Object.prototype.hasOwnProperty.call(whereObj, 'id') &&
50
+ whereObj.id !== undefined) {
51
+ // Retain only the 'id' field within 'where'
52
+ cleanedValue = {
53
+ id: removeUndefinedProps(whereObj.id),
54
+ };
55
+ }
56
+ else {
57
+ // Process 'where' object normally if 'id' is undefined or doesn't exist
58
+ cleanedValue = removeUndefinedProps(value);
59
+ }
60
+ }
61
+ else {
62
+ // Process other keys normally
63
+ cleanedValue = removeUndefinedProps(value);
64
+ }
65
+ if (cleanedValue !== undefined &&
66
+ cleanedValue !== null &&
67
+ (!isPlainObject(cleanedValue) || Object.keys(cleanedValue).length > 0)) {
68
+ acc[key] = cleanedValue;
69
+ }
70
+ }
71
+ return acc;
72
+ }, {});
73
+ }
74
+ return obj !== undefined && obj !== null
75
+ ? obj
76
+ : undefined;
77
+ }
78
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptic/backend-legacy",
3
- "version": "0.0.988",
3
+ "version": "0.0.989",
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",