@olinfo/quizms-firebase 4.1.1 → 4.1.2
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/dist/package.json.js
CHANGED
|
@@ -1,58 +1,57 @@
|
|
|
1
|
-
import { contestSchema as
|
|
2
|
-
import { validate as
|
|
3
|
-
import { serverTimestamp as
|
|
4
|
-
import { cloneDeepWith as
|
|
5
|
-
import { websiteSchema as
|
|
6
|
-
function
|
|
7
|
-
return
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
10
|
-
if (
|
|
11
|
-
return
|
|
12
|
-
if (
|
|
1
|
+
import { contestSchema as f, participationSchema as d, studentRestoreSchema as p, variantSchema as u, announcementSchema as F, studentSchema as S } from "@olinfo/quizms/models";
|
|
2
|
+
import { validate as h } from "@olinfo/quizms/utils";
|
|
3
|
+
import { serverTimestamp as c, Timestamp as m } from "firebase/firestore";
|
|
4
|
+
import { cloneDeepWith as v, omit as C, isDate as D, isString as b, transform as T, isObject as w } from "lodash-es";
|
|
5
|
+
import { websiteSchema as A } from "../../models/website.js";
|
|
6
|
+
function i(r) {
|
|
7
|
+
return v(C(r, "id"), (t) => {
|
|
8
|
+
if (D(t))
|
|
9
|
+
return m.fromDate(t);
|
|
10
|
+
if (b(t))
|
|
11
|
+
return t.trim();
|
|
12
|
+
if (t === void 0)
|
|
13
13
|
return null;
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
return r.toDate();
|
|
16
|
+
function a(r) {
|
|
17
|
+
return T(r, (t, e, n) => {
|
|
18
|
+
e === null ? t[n] = void 0 : e instanceof m ? t[n] = e.toDate() : w(e) ? t[n] = a(e) : t[n] = e;
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
return
|
|
21
|
+
function s(r, t) {
|
|
22
|
+
const e = a({ ...t.data(), id: t.id });
|
|
23
|
+
return h(r, e);
|
|
25
24
|
}
|
|
26
|
-
function
|
|
25
|
+
function o(r) {
|
|
27
26
|
return {
|
|
28
|
-
toFirestore: (
|
|
29
|
-
fromFirestore: (
|
|
27
|
+
toFirestore: (t) => i(t),
|
|
28
|
+
fromFirestore: (t) => s(r, t)
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
|
-
const
|
|
33
|
-
toFirestore(
|
|
31
|
+
const W = o(f), q = o(d), z = o(p), B = o(u), E = o(A), G = {
|
|
32
|
+
toFirestore(r) {
|
|
34
33
|
return {
|
|
35
|
-
...
|
|
36
|
-
createdAt:
|
|
34
|
+
...i(r),
|
|
35
|
+
createdAt: c()
|
|
37
36
|
};
|
|
38
37
|
},
|
|
39
|
-
fromFirestore: (
|
|
40
|
-
},
|
|
41
|
-
toFirestore(
|
|
38
|
+
fromFirestore: (r) => s(F, r)
|
|
39
|
+
}, H = {
|
|
40
|
+
toFirestore(r) {
|
|
42
41
|
return {
|
|
43
|
-
...
|
|
44
|
-
updatedAt:
|
|
42
|
+
...i(r),
|
|
43
|
+
updatedAt: c()
|
|
45
44
|
};
|
|
46
45
|
},
|
|
47
|
-
fromFirestore: (
|
|
46
|
+
fromFirestore: (r) => s(S, r)
|
|
48
47
|
};
|
|
49
48
|
export {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
G as announcementConverter,
|
|
50
|
+
W as contestConverter,
|
|
51
|
+
q as participationConverter,
|
|
52
|
+
H as studentConverter,
|
|
53
|
+
z as studentRestoreConvert,
|
|
54
|
+
B as variantConverter,
|
|
55
|
+
E as websiteConverter
|
|
57
56
|
};
|
|
58
57
|
//# sourceMappingURL=converters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converters.js","sources":["../../../../src/web/common/converters.ts"],"sourcesContent":["import {\n type Announcement,\n announcementSchema,\n contestSchema,\n participationSchema,\n type Student,\n studentRestoreSchema,\n studentSchema,\n variantSchema,\n} from \"@olinfo/quizms/models\";\nimport { validate } from \"@olinfo/quizms/utils\";\nimport {\n type DocumentSnapshot,\n type FirestoreDataConverter,\n serverTimestamp,\n Timestamp,\n} from \"firebase/firestore\";\nimport { cloneDeepWith, isDate, isString, omit } from \"lodash-es\";\nimport type z from \"zod\";\n\nimport { websiteSchema } from \"~/models/website\";\n\nfunction convertToFirestore(data: object) {\n return cloneDeepWith(omit(data, \"id\"), (value) => {\n if (isDate(value)) {\n return Timestamp.fromDate(value);\n }\n if (isString(value)) {\n return value.trim();\n }\n if (value === undefined) {\n return null;\n }\n });\n}\n\nfunction convertFromFirestore(data: object) {\n return
|
|
1
|
+
{"version":3,"file":"converters.js","sources":["../../../../src/web/common/converters.ts"],"sourcesContent":["import {\n type Announcement,\n announcementSchema,\n contestSchema,\n participationSchema,\n type Student,\n studentRestoreSchema,\n studentSchema,\n variantSchema,\n} from \"@olinfo/quizms/models\";\nimport { validate } from \"@olinfo/quizms/utils\";\nimport {\n type DocumentSnapshot,\n type FirestoreDataConverter,\n serverTimestamp,\n Timestamp,\n} from \"firebase/firestore\";\nimport { cloneDeepWith, isDate, isObject, isString, omit, transform } from \"lodash-es\";\nimport type z from \"zod\";\n\nimport { websiteSchema } from \"~/models/website\";\n\nfunction convertToFirestore(data: object) {\n return cloneDeepWith(omit(data, \"id\"), (value) => {\n if (isDate(value)) {\n return Timestamp.fromDate(value);\n }\n if (isString(value)) {\n return value.trim();\n }\n if (value === undefined) {\n return null;\n }\n });\n}\n\nfunction convertFromFirestore(data: object) {\n return transform(data, (result: any, value: any, key: string | number) => {\n if (value === null) {\n result[key] = undefined;\n } else if (value instanceof Timestamp) {\n result[key] = value.toDate();\n } else if (isObject(value)) {\n result[key] = convertFromFirestore(value);\n } else {\n result[key] = value;\n }\n });\n}\n\nfunction parse<T>(schema: z.core.$ZodType<T>, snapshot: DocumentSnapshot): T {\n const data = convertFromFirestore({ ...snapshot.data(), id: snapshot.id });\n return validate(schema, data);\n}\n\nfunction converter<T extends object>(schema: z.core.$ZodType<T>): FirestoreDataConverter<T> {\n return {\n toFirestore: (data) => convertToFirestore(data),\n fromFirestore: (snapshot) => parse(schema, snapshot),\n };\n}\n\nexport const contestConverter = converter(contestSchema);\nexport const participationConverter = converter(participationSchema);\nexport const studentRestoreConvert = converter(studentRestoreSchema);\nexport const variantConverter = converter(variantSchema);\nexport const websiteConverter = converter(websiteSchema);\n\nexport const announcementConverter: FirestoreDataConverter<Announcement> = {\n toFirestore(data) {\n return {\n ...convertToFirestore(data),\n createdAt: serverTimestamp(),\n };\n },\n fromFirestore: (snapshot) => parse(announcementSchema, snapshot),\n};\n\nexport const studentConverter: FirestoreDataConverter<Student> = {\n toFirestore(data) {\n return {\n ...convertToFirestore(data),\n updatedAt: serverTimestamp(),\n };\n },\n fromFirestore: (snapshot) => parse(studentSchema, snapshot),\n};\n"],"names":["convertToFirestore","data","cloneDeepWith","omit","value","isDate","Timestamp","isString","convertFromFirestore","transform","result","key","isObject","parse","schema","snapshot","validate","converter","contestConverter","contestSchema","participationConverter","participationSchema","studentRestoreConvert","studentRestoreSchema","variantConverter","variantSchema","websiteConverter","websiteSchema","announcementConverter","serverTimestamp","announcementSchema","studentConverter","studentSchema"],"mappings":";;;;;AAsBA,SAASA,EAAmBC,GAAc;AACxC,SAAOC,EAAcC,EAAKF,GAAM,IAAI,GAAG,CAACG,MAAU;AAChD,QAAIC,EAAOD,CAAK;AACd,aAAOE,EAAU,SAASF,CAAK;AAEjC,QAAIG,EAASH,CAAK;AAChB,aAAOA,EAAM,KAAA;AAEf,QAAIA,MAAU;AACZ,aAAO;AAAA,EAEX,CAAC;AACH;AAEA,SAASI,EAAqBP,GAAc;AAC1C,SAAOQ,EAAUR,GAAM,CAACS,GAAaN,GAAYO,MAAyB;AACxE,IAAIP,MAAU,OACZM,EAAOC,CAAG,IAAI,SACLP,aAAiBE,IAC1BI,EAAOC,CAAG,IAAIP,EAAM,OAAA,IACXQ,EAASR,CAAK,IACvBM,EAAOC,CAAG,IAAIH,EAAqBJ,CAAK,IAExCM,EAAOC,CAAG,IAAIP;AAAA,EAElB,CAAC;AACH;AAEA,SAASS,EAASC,GAA4BC,GAA+B;AAC3E,QAAMd,IAAOO,EAAqB,EAAE,GAAGO,EAAS,QAAQ,IAAIA,EAAS,IAAI;AACzE,SAAOC,EAASF,GAAQb,CAAI;AAC9B;AAEA,SAASgB,EAA4BH,GAAuD;AAC1F,SAAO;AAAA,IACL,aAAa,CAACb,MAASD,EAAmBC,CAAI;AAAA,IAC9C,eAAe,CAACc,MAAaF,EAAMC,GAAQC,CAAQ;AAAA,EAAA;AAEvD;AAEO,MAAMG,IAAmBD,EAAUE,CAAa,GAC1CC,IAAyBH,EAAUI,CAAmB,GACtDC,IAAwBL,EAAUM,CAAoB,GACtDC,IAAmBP,EAAUQ,CAAa,GAC1CC,IAAmBT,EAAUU,CAAa,GAE1CC,IAA8D;AAAA,EACzE,YAAY3B,GAAM;AAChB,WAAO;AAAA,MACL,GAAGD,EAAmBC,CAAI;AAAA,MAC1B,WAAW4B,EAAA;AAAA,IAAgB;AAAA,EAE/B;AAAA,EACA,eAAe,CAACd,MAAaF,EAAMiB,GAAoBf,CAAQ;AACjE,GAEagB,IAAoD;AAAA,EAC/D,YAAY9B,GAAM;AAChB,WAAO;AAAA,MACL,GAAGD,EAAmBC,CAAI;AAAA,MAC1B,WAAW4B,EAAA;AAAA,IAAgB;AAAA,EAE/B;AAAA,EACA,eAAe,CAACd,MAAaF,EAAMmB,GAAejB,CAAQ;AAC5D;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olinfo/quizms-firebase",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Alessandro Bortolin <bortolin.alessandro@outlook.it>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"vite-plugin-dts": "^4.5.4",
|
|
60
60
|
"wouter": "^3.9.0",
|
|
61
61
|
"zod": "^4.3.6",
|
|
62
|
-
"@olinfo/quizms": "^4.1.
|
|
62
|
+
"@olinfo/quizms": "^4.1.2"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"react": "~19.1.4"
|