@adaptic/backend-legacy 0.0.56 → 0.0.58
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/esm/utils/index.d.ts +15 -1
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/index.mjs +67 -1
- package/package.json +1 -1
package/esm/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utils module index
|
|
3
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'
|
|
4
7
|
*/
|
|
5
|
-
|
|
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
|
+
* We use Record<string, unknown> for the parameter to accept all generated Prisma
|
|
17
|
+
* input shapes without needing to enumerate every possible field type.
|
|
18
|
+
*/
|
|
19
|
+
export declare function removeUndefinedProps(obj: Record<string, unknown> | Record<string, unknown>[] | unknown): Record<string, unknown> | undefined;
|
|
6
20
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|
package/esm/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;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,CAAC;gBAC1C,IAAI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ility 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'
|
|
4
7
|
*/
|
|
5
|
-
|
|
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
|
+
* We use Record<string, unknown> for the parameter to accept all generated Prisma
|
|
17
|
+
* input shapes without needing to enumerate every possible field type.
|
|
18
|
+
*/
|
|
19
|
+
export function removeUndefinedProps(obj) {
|
|
20
|
+
if (Array.isArray(obj)) {
|
|
21
|
+
return obj
|
|
22
|
+
.map((item) => removeUndefinedProps(item))
|
|
23
|
+
.filter((item) => item !== undefined &&
|
|
24
|
+
item !== null &&
|
|
25
|
+
(typeof item !== 'object' ||
|
|
26
|
+
Object.keys(item).length > 0));
|
|
27
|
+
}
|
|
28
|
+
else if (typeof obj === 'object' &&
|
|
29
|
+
obj !== null &&
|
|
30
|
+
!(obj instanceof Date)) {
|
|
31
|
+
const record = obj;
|
|
32
|
+
return Object.keys(record).reduce((acc, key) => {
|
|
33
|
+
const value = record[key];
|
|
34
|
+
if (value !== undefined && value !== null) {
|
|
35
|
+
let cleanedValue;
|
|
36
|
+
if (key === 'where' &&
|
|
37
|
+
typeof value === 'object' &&
|
|
38
|
+
value !== null &&
|
|
39
|
+
!(value instanceof Date)) {
|
|
40
|
+
const whereObj = value;
|
|
41
|
+
if (Object.prototype.hasOwnProperty.call(whereObj, 'id') &&
|
|
42
|
+
whereObj.id !== undefined) {
|
|
43
|
+
// Retain only the 'id' field within 'where'
|
|
44
|
+
cleanedValue = {
|
|
45
|
+
id: removeUndefinedProps(whereObj.id),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Process 'where' object normally if 'id' is undefined or doesn't exist
|
|
50
|
+
cleanedValue = removeUndefinedProps(value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Process other keys normally
|
|
55
|
+
cleanedValue = removeUndefinedProps(value);
|
|
56
|
+
}
|
|
57
|
+
if (cleanedValue !== undefined &&
|
|
58
|
+
cleanedValue !== null &&
|
|
59
|
+
(typeof cleanedValue !== 'object' ||
|
|
60
|
+
cleanedValue instanceof Date ||
|
|
61
|
+
Object.keys(cleanedValue).length > 0)) {
|
|
62
|
+
acc[key] = cleanedValue;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return acc;
|
|
66
|
+
}, {});
|
|
67
|
+
}
|
|
68
|
+
return obj !== undefined && obj !== null
|
|
69
|
+
? obj
|
|
70
|
+
: undefined;
|
|
71
|
+
}
|
|
6
72
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptic/backend-legacy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.58",
|
|
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",
|