@statezero/core 0.2.20 → 0.2.21
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.
|
@@ -12,7 +12,7 @@ export namespace fileFieldSerializer {
|
|
|
12
12
|
function toLive(value: any, context?: {}): any;
|
|
13
13
|
}
|
|
14
14
|
export namespace dateFieldSerializer {
|
|
15
|
-
export function toInternal_1(value: any, context?: {}):
|
|
15
|
+
export function toInternal_1(value: any, context?: {}): string | null | undefined;
|
|
16
16
|
export { toInternal_1 as toInternal };
|
|
17
17
|
export function toLive_1(value: any, context?: {}): any;
|
|
18
18
|
export { toLive_1 as toLive };
|
|
@@ -24,7 +24,7 @@ export namespace relationshipFieldSerializer {
|
|
|
24
24
|
export { toLive_2 as toLive };
|
|
25
25
|
}
|
|
26
26
|
export namespace m2mFieldSerializer {
|
|
27
|
-
export function toInternal_3(value: any, context?: {}):
|
|
27
|
+
export function toInternal_3(value: any, context?: {}): (string | number)[] | null | undefined;
|
|
28
28
|
export { toInternal_3 as toInternal };
|
|
29
29
|
export function toLive_3(value: any, context?: {}): any;
|
|
30
30
|
export { toLive_3 as toLive };
|
|
@@ -27,6 +27,9 @@ export const fileFieldSerializer = {
|
|
|
27
27
|
if (isNil(value)) {
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
31
|
+
throw new Error(`expected file object, got ${Array.isArray(value) ? "array" : typeof value}`);
|
|
32
|
+
}
|
|
30
33
|
value = {
|
|
31
34
|
file_path: value.filePath || value.file_path,
|
|
32
35
|
file_name: value.fileName || value.file_name,
|
|
@@ -79,7 +82,7 @@ export const dateFieldSerializer = {
|
|
|
79
82
|
// Fallback if no schema context
|
|
80
83
|
return value.toISOString();
|
|
81
84
|
}
|
|
82
|
-
|
|
85
|
+
throw new Error(`expected string or Date, got ${typeof value}`);
|
|
83
86
|
},
|
|
84
87
|
toLive: (value, context = {}) => {
|
|
85
88
|
if (isNil(value) || typeof value !== "string")
|
|
@@ -135,8 +138,10 @@ export const relationshipFieldSerializer = {
|
|
|
135
138
|
*/
|
|
136
139
|
export const m2mFieldSerializer = {
|
|
137
140
|
toInternal: (value, context = {}) => {
|
|
138
|
-
if (isNil(value)
|
|
141
|
+
if (isNil(value))
|
|
139
142
|
return value;
|
|
143
|
+
if (!Array.isArray(value))
|
|
144
|
+
throw new Error(`expected array, got ${typeof value}`);
|
|
140
145
|
return value.map((item) => {
|
|
141
146
|
// Extract PK or use item directly
|
|
142
147
|
const pk = item.pk || item;
|
package/package.json
CHANGED