@open-xamu-co/firebase-nuxt 1.0.0 → 1.1.0

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.
Files changed (133) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +0 -14
  3. package/dist/module.d.mts +50 -0
  4. package/dist/module.json +12 -0
  5. package/dist/module.mjs +137 -0
  6. package/dist/runtime/client/types/entities/base.d.ts +29 -0
  7. package/dist/runtime/client/types/entities/base.js +0 -0
  8. package/dist/runtime/client/types/entities/instance.d.ts +42 -0
  9. package/dist/runtime/client/types/entities/instance.js +0 -0
  10. package/dist/runtime/client/types/entities/logs.d.ts +9 -0
  11. package/dist/runtime/client/types/entities/logs.js +0 -0
  12. package/dist/runtime/client/types/entities/user.d.ts +27 -0
  13. package/dist/runtime/client/types/entities/user.js +0 -0
  14. package/dist/runtime/client/types/firestore.d.ts +55 -0
  15. package/dist/runtime/client/types/firestore.js +0 -0
  16. package/dist/runtime/client/types/index.d.ts +5 -0
  17. package/dist/runtime/client/types/index.js +5 -0
  18. package/dist/runtime/client/utils/locale.d.ts +185 -0
  19. package/dist/runtime/client/utils/locale.js +63 -0
  20. package/dist/runtime/client/utils/logger.d.ts +14 -0
  21. package/dist/runtime/client/utils/logger.js +65 -0
  22. package/dist/runtime/client/utils/resolver.d.ts +14 -0
  23. package/dist/runtime/client/utils/resolver.js +88 -0
  24. package/dist/runtime/components/ValueCellphone.d.vue.ts +24 -0
  25. package/dist/runtime/components/ValueCellphone.vue +21 -0
  26. package/dist/runtime/components/ValueCellphone.vue.d.ts +24 -0
  27. package/dist/runtime/components/ValueID.d.vue.ts +18 -0
  28. package/dist/runtime/components/ValueID.vue +14 -0
  29. package/dist/runtime/components/ValueID.vue.d.ts +18 -0
  30. package/dist/runtime/components/ValueIP.d.vue.ts +18 -0
  31. package/dist/runtime/components/ValueIP.vue +28 -0
  32. package/dist/runtime/components/ValueIP.vue.d.ts +18 -0
  33. package/dist/runtime/components/ValueLocation.d.vue.ts +21 -0
  34. package/dist/runtime/components/ValueLocation.vue +20 -0
  35. package/dist/runtime/components/ValueLocation.vue.d.ts +21 -0
  36. package/dist/runtime/components/ValuePrice.d.vue.ts +11 -0
  37. package/dist/runtime/components/ValuePrice.vue +12 -0
  38. package/dist/runtime/components/ValuePrice.vue.d.ts +11 -0
  39. package/dist/runtime/composables/firestore/auth.d.ts +4 -0
  40. package/dist/runtime/composables/firestore/auth.js +46 -0
  41. package/dist/runtime/composables/firestore/index.d.ts +2 -0
  42. package/dist/runtime/composables/firestore/index.js +2 -0
  43. package/dist/runtime/composables/firestore/write.d.ts +21 -0
  44. package/dist/runtime/composables/firestore/write.js +279 -0
  45. package/dist/runtime/composables/index.d.ts +4 -0
  46. package/dist/runtime/composables/index.js +4 -0
  47. package/dist/runtime/composables/store/app.d.ts +82 -0
  48. package/dist/runtime/composables/store/app.js +90 -0
  49. package/dist/runtime/composables/store/instance.d.ts +57 -0
  50. package/dist/runtime/composables/store/instance.js +94 -0
  51. package/dist/runtime/composables/store/session.d.ts +41 -0
  52. package/dist/runtime/composables/store/session.js +89 -0
  53. package/dist/runtime/composables/useAppLogger.d.ts +2 -0
  54. package/dist/runtime/composables/useAppLogger.js +8 -0
  55. package/dist/runtime/composables/useFilesUpload.d.ts +19 -0
  56. package/dist/runtime/composables/useFilesUpload.js +110 -0
  57. package/dist/runtime/composables/usePrice.d.ts +9 -0
  58. package/dist/runtime/composables/usePrice.js +6 -0
  59. package/dist/runtime/composables/useQuery.d.ts +12 -0
  60. package/dist/runtime/composables/useQuery.js +33 -0
  61. package/dist/runtime/composables/utils.d.ts +14 -0
  62. package/dist/runtime/composables/utils.js +65 -0
  63. package/dist/runtime/functions/types/entities/base.d.ts +56 -0
  64. package/dist/runtime/functions/types/entities/base.js +0 -0
  65. package/dist/runtime/functions/types/entities/instance.d.ts +73 -0
  66. package/dist/runtime/functions/types/entities/instance.js +0 -0
  67. package/dist/runtime/functions/types/entities/logs.d.ts +15 -0
  68. package/dist/runtime/functions/types/entities/logs.js +0 -0
  69. package/dist/runtime/functions/types/entities/user.d.ts +13 -0
  70. package/dist/runtime/functions/types/entities/user.js +0 -0
  71. package/dist/runtime/functions/types/index.d.ts +4 -0
  72. package/dist/runtime/functions/types/index.js +4 -0
  73. package/dist/runtime/functions/utils/encrypt.d.ts +24 -0
  74. package/dist/runtime/functions/utils/encrypt.js +17 -0
  75. package/dist/runtime/functions/utils/enums.d.ts +40 -0
  76. package/dist/runtime/functions/utils/enums.js +24 -0
  77. package/dist/runtime/functions/utils/event.d.ts +71 -0
  78. package/dist/runtime/functions/utils/event.js +91 -0
  79. package/dist/runtime/functions/utils/firebase.d.ts +7 -0
  80. package/dist/runtime/functions/utils/firebase.js +21 -0
  81. package/dist/runtime/functions/utils/logger.d.ts +3 -0
  82. package/dist/runtime/functions/utils/logger.js +17 -0
  83. package/dist/runtime/functions/utils/logs.d.ts +10 -0
  84. package/dist/runtime/functions/utils/logs.js +47 -0
  85. package/dist/runtime/functions/utils/price.d.ts +12 -0
  86. package/dist/runtime/functions/utils/price.js +26 -0
  87. package/dist/runtime/functions/utils/queue.d.ts +4 -0
  88. package/dist/runtime/functions/utils/queue.js +11 -0
  89. package/dist/runtime/functions/utils/search.d.ts +15 -0
  90. package/dist/runtime/functions/utils/search.js +38 -0
  91. package/dist/runtime/functions/utils/slugs.d.ts +2 -0
  92. package/dist/runtime/functions/utils/slugs.js +16 -0
  93. package/dist/runtime/plugins/firebase-setup.d.ts +26 -0
  94. package/dist/runtime/plugins/firebase-setup.js +35 -0
  95. package/dist/runtime/plugins/loaded.client.d.ts +2 -0
  96. package/dist/runtime/plugins/loaded.client.js +44 -0
  97. package/dist/runtime/plugins/scrollBehavior.client.d.ts +2 -0
  98. package/dist/runtime/plugins/scrollBehavior.client.js +20 -0
  99. package/dist/runtime/providers/firebase.d.ts +2 -0
  100. package/dist/runtime/providers/firebase.js +7 -0
  101. package/dist/runtime/public/js/file-upload.d.ts +1 -0
  102. package/dist/runtime/public/js/file-upload.js +67 -0
  103. package/dist/runtime/public/sample-loading.png +0 -0
  104. package/dist/runtime/public/sample-missing.png +0 -0
  105. package/dist/runtime/public/sample.png +0 -0
  106. package/dist/runtime/server/api/all-collection-document.get.d.ts +7 -0
  107. package/dist/runtime/server/api/all-collection-document.get.js +56 -0
  108. package/dist/runtime/server/api/all-collection.get.d.ts +8 -0
  109. package/dist/runtime/server/api/all-collection.get.js +67 -0
  110. package/dist/runtime/server/api/media.get.d.ts +8 -0
  111. package/dist/runtime/server/api/media.get.js +114 -0
  112. package/dist/runtime/server/middleware/0.hotlinking.d.ts +5 -0
  113. package/dist/runtime/server/middleware/0.hotlinking.js +28 -0
  114. package/dist/runtime/server/middleware/1.context.d.ts +5 -0
  115. package/dist/runtime/server/middleware/1.context.js +108 -0
  116. package/dist/runtime/server/types/index.d.ts +34 -0
  117. package/dist/runtime/server/types/index.js +0 -0
  118. package/dist/runtime/server/utils/auth.d.ts +10 -0
  119. package/dist/runtime/server/utils/auth.js +31 -0
  120. package/dist/runtime/server/utils/cache.d.ts +21 -0
  121. package/dist/runtime/server/utils/cache.js +20 -0
  122. package/dist/runtime/server/utils/environment.d.ts +45 -0
  123. package/dist/runtime/server/utils/environment.js +50 -0
  124. package/dist/runtime/server/utils/firebase.d.ts +9 -0
  125. package/dist/runtime/server/utils/firebase.js +13 -0
  126. package/dist/runtime/server/utils/firestore.d.ts +27 -0
  127. package/dist/runtime/server/utils/firestore.js +137 -0
  128. package/dist/runtime/server/utils/guards.d.ts +15 -0
  129. package/dist/runtime/server/utils/guards.js +23 -0
  130. package/dist/runtime/server/utils/instance.d.ts +21 -0
  131. package/dist/runtime/server/utils/instance.js +68 -0
  132. package/dist/types.d.mts +7 -0
  133. package/package.json +17 -17
@@ -0,0 +1,63 @@
1
+ import es from "@open-xamu-co/ui-common-helpers/es";
2
+ export const locale = {
3
+ // values
4
+ address: "Direcci\xF3n",
5
+ at: "Lugar",
6
+ body: "Cuerpo",
7
+ categories: "Categor\xEDas",
8
+ category: "Categor\xEDa",
9
+ cellphone: "Celular",
10
+ description: "Descripci\xF3n",
11
+ document: "Documento",
12
+ due_at: "Vencimiento",
13
+ highlight: "Principal",
14
+ image: "Imagen",
15
+ images: "Im\xE1genes",
16
+ is_anonymous: "An\xF3nimo",
17
+ keywords: "Palabras clave",
18
+ location_city: "Ciudad",
19
+ location_country: "Pa\xEDs",
20
+ location_state: "Departamento",
21
+ location: "Ubicaci\xF3n",
22
+ lock: "Bloqueado",
23
+ main_variant: "Variante principal",
24
+ main: "Principal",
25
+ message: "Mensaje",
26
+ metadata: "Metadatos",
27
+ month: "Mes",
28
+ name: "Nombre",
29
+ observations: "Observaciones",
30
+ old_observations: "Historial",
31
+ paid_at: "Pagado",
32
+ pending_quantity: "Pendiente",
33
+ // Cantidad pendiente
34
+ photo_url: "Foto",
35
+ possible_variants: "Variantes posibles",
36
+ price: "Precio",
37
+ product: "Producto",
38
+ quantity: "Cantidad",
39
+ reference: "Referencia",
40
+ role: "rol",
41
+ sales: "Ventas",
42
+ slug: "Etiqueta",
43
+ sold_quantity: "Vendido",
44
+ // Cantidad vendida
45
+ tracking_code: "C\xF3digo de rastreo",
46
+ type: "Tipo",
47
+ uid: "Referencia",
48
+ value: "Valor",
49
+ values: "Valores",
50
+ variants: "Variantes",
51
+ visible_products: "Productos visibles",
52
+ with_debug_key: "Modo de pruebas",
53
+ // Across all tables
54
+ created_at: "Creado",
55
+ created_by: "Creado por",
56
+ updated_at: "Actualizado",
57
+ updated_by: "Actualizado por",
58
+ // Prefer locale definitions
59
+ ...es,
60
+ // Explicit override
61
+ refresh: "Actualizar",
62
+ table_update: "Editar"
63
+ };
@@ -0,0 +1,14 @@
1
+ import { Firestore } from "firebase/firestore";
2
+ import type { tLogger } from "@open-xamu-co/ui-common-types";
3
+ interface iMakeLogger {
4
+ instanceId?: string;
5
+ authId?: string;
6
+ loggerFirestore?: Firestore;
7
+ }
8
+ /**
9
+ * Logger
10
+ * No circular dependencies or nuxt context
11
+ * Conditionally log user data
12
+ */
13
+ export declare function makeLogger({ instanceId, authId, loggerFirestore }?: iMakeLogger): tLogger;
14
+ export {};
@@ -0,0 +1,65 @@
1
+ import { getApp } from "firebase/app";
2
+ import { getFirestore, collection, addDoc, doc } from "firebase/firestore";
3
+ import { getLog } from "../../functions/utils/logs.js";
4
+ import { getDocumentId } from "./resolver.js";
5
+ export function makeLogger({ instanceId, authId, loggerFirestore } = {}) {
6
+ return async function(...args) {
7
+ try {
8
+ instanceId = getDocumentId(instanceId);
9
+ authId = getDocumentId(authId);
10
+ const instancePath = `instances/${instanceId}`;
11
+ const memberPath = `${instancePath}/members/${authId}`;
12
+ let logData;
13
+ if (import.meta.server) {
14
+ try {
15
+ const { useEvent } = await import("nitropack/runtime");
16
+ const { getRequestHeaders } = await import("h3");
17
+ const event = useEvent();
18
+ const { url, statusCode, statusMessage, method } = event.node.req;
19
+ const {
20
+ host,
21
+ "x-forwarded-host": forwardedHost = host,
22
+ "xamu-context-hits": contextHits = "0",
23
+ "xamu-context-source": contextSource = "unknown",
24
+ // Server or client
25
+ ...headers
26
+ } = getRequestHeaders(event);
27
+ logData = getLog(...args, {
28
+ headers,
29
+ url,
30
+ statusCode,
31
+ statusMessage,
32
+ method,
33
+ forwardedHost,
34
+ contextHits: Number(contextHits),
35
+ contextSource
36
+ });
37
+ } catch (error) {
38
+ logData = getLog(...args, { errorMessage: "Could not get server metadata" });
39
+ }
40
+ const { getServerFirebase } = await import("../../server/utils/firebase.js");
41
+ const { firebaseFirestore } = getServerFirebase("makeLogger");
42
+ const at = instanceId ? firebaseFirestore.doc(instancePath) : firebaseFirestore;
43
+ if (instanceId && authId) {
44
+ const createdByRef = firebaseFirestore.doc(memberPath);
45
+ logData.createdByRef = logData.updatedByRef = createdByRef;
46
+ }
47
+ await at.collection("logs").add(logData);
48
+ } else {
49
+ logData = getLog(...args, { userAgent: navigator.userAgent });
50
+ loggerFirestore ||= getFirestore(getApp());
51
+ const logsRef = collection(
52
+ loggerFirestore,
53
+ instanceId ? `${instancePath}/logs` : "logs"
54
+ );
55
+ if (instanceId && authId) {
56
+ const createdByRef = doc(loggerFirestore, memberPath);
57
+ logData.createdByRef = logData.updatedByRef = createdByRef;
58
+ }
59
+ await addDoc(logsRef, logData);
60
+ }
61
+ } catch (err) {
62
+ console.error("Error logging to db", err);
63
+ }
64
+ };
65
+ }
@@ -0,0 +1,14 @@
1
+ import type { FirebaseDocument, FromData } from "../types/entities/base.js";
2
+ import type { iSnapshotConfig, PseudoDocumentReference, PseudoDocumentSnapshot, PseudoNode } from "../types/firestore.js";
3
+ export declare function getDocumentId(path?: string): string;
4
+ /** Timestamp breaks nuxt */
5
+ export declare function resolveSnapshotDefaults<T extends PseudoNode, R extends FirebaseDocument = FromData<T>>(id: string, node?: T): R;
6
+ /**
7
+ * Get a document snapshot from a reference
8
+ */
9
+ type Resolver = <Tr extends PseudoNode, Rr extends FirebaseDocument = FromData<Tr>>(ref: PseudoDocumentReference<Tr, Rr>) => Promise<PseudoDocumentSnapshot<Tr, Rr>>;
10
+ /**
11
+ * Get object from firebase snapshot
12
+ */
13
+ export declare function makeResolveRefs(resolver: Resolver): <T extends PseudoNode, R extends FirebaseDocument = FromData<T>>(snapshot: PseudoDocumentSnapshot<T, R>, { level, omit }?: iSnapshotConfig, withAuth?: boolean) => Promise<R | undefined>;
14
+ export {};
@@ -0,0 +1,88 @@
1
+ export function getDocumentId(path = "") {
2
+ return path.split("/").pop() || "";
3
+ }
4
+ export function resolveSnapshotDefaults(id, node) {
5
+ if (!node) return {};
6
+ const dateFields = {};
7
+ for (const key in node) {
8
+ if (key.endsWith("At") && node[key] && "toDate" in node[key]) {
9
+ dateFields[key] = node[key]?.toDate();
10
+ }
11
+ }
12
+ return Object.assign({}, node, { id, ...dateFields });
13
+ }
14
+ export function makeResolveRefs(resolver) {
15
+ return async function resolveRefs(snapshot, { level = 0, omit = [] } = {}, withAuth = false) {
16
+ const exists = typeof snapshot.exists === "function" ? snapshot.exists() : snapshot.exists;
17
+ if (!exists) return;
18
+ const node = snapshot.data() || {};
19
+ const path = snapshot.ref.path;
20
+ const keys = Object.keys(node || {});
21
+ await Promise.all(
22
+ keys.map(async (key) => {
23
+ if (!Object.hasOwn(node, key)) return;
24
+ const newKey = key.replace(/(Ref|Refs)$/, "");
25
+ const innerOmit = omit.filter((k) => k && k.startsWith(newKey)).map((k) => k.replace(`${newKey.toString()}.`, ""));
26
+ if (key.endsWith("Ref")) {
27
+ const ref = node[key];
28
+ if (!omit.includes(newKey) && typeof ref === "object" && ref !== null) {
29
+ let innerLevel = level;
30
+ if (innerLevel > 0) {
31
+ if (newKey.endsWith("By")) {
32
+ innerLevel = Math.max(innerLevel, 2);
33
+ if (!withAuth) {
34
+ delete node[key];
35
+ return;
36
+ }
37
+ }
38
+ const innerSnapshot = await resolver(ref);
39
+ if (innerSnapshot) {
40
+ const resolved = await resolveRefs(
41
+ innerSnapshot,
42
+ { level: Math.max(0, innerLevel - 1), omit: innerOmit },
43
+ withAuth
44
+ );
45
+ node[newKey] = resolved;
46
+ }
47
+ }
48
+ }
49
+ delete node[key];
50
+ } else if (key.endsWith("Refs")) {
51
+ const nodes = node[key];
52
+ if (level > 0 && !omit.includes(newKey) && Array.isArray(nodes)) {
53
+ const refs = [];
54
+ await Promise.all(
55
+ nodes.map(async (ref) => {
56
+ if (typeof ref !== "object" || ref === null) return;
57
+ const innerSnapshot = await resolver(ref);
58
+ const data = innerSnapshot?.data();
59
+ if (!innerSnapshot || !data) return;
60
+ const resolved = await resolveRefs(
61
+ innerSnapshot,
62
+ { level: Math.max(0, level - 1), omit: innerOmit },
63
+ withAuth
64
+ );
65
+ if (resolved) refs.push(resolved);
66
+ })
67
+ );
68
+ node[newKey] = refs;
69
+ }
70
+ delete node[key];
71
+ } else if (!key.endsWith("At") && node[key] && typeof node[key] === "object") {
72
+ if (0 in node[key]) {
73
+ const dataArr = Object.values(node[key]).map((data) => {
74
+ if (typeof data !== "object" || data === null) return data;
75
+ const { id, ...newData } = resolveSnapshotDefaults("", data);
76
+ return newData;
77
+ });
78
+ node[key] = dataArr;
79
+ } else {
80
+ const { id, ...newData } = resolveSnapshotDefaults("", node[key]);
81
+ node[key] = newData;
82
+ }
83
+ }
84
+ })
85
+ );
86
+ return resolveSnapshotDefaults(path, node);
87
+ };
88
+ }
@@ -0,0 +1,24 @@
1
+ import type { tProp, tThemeModifier, tThemeTuple } from "@open-xamu-co/ui-common-types";
2
+ /**
3
+ * Value cellphone
4
+ *
5
+ * @component
6
+ */
7
+ type __VLS_Props = {
8
+ value: any;
9
+ node?: {
10
+ whatsappNumber?: string;
11
+ whatsappIndicative?: `${string}+${number}`;
12
+ user?: {
13
+ address?: string;
14
+ cellphoneNumber?: string;
15
+ cellphoneIndicative?: `${string}+${number}`;
16
+ };
17
+ };
18
+ mappedNode?: {
19
+ theme?: tThemeTuple | tProp<tThemeModifier>;
20
+ };
21
+ };
22
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
+ declare const _default: typeof __VLS_export;
24
+ export default _default;
@@ -0,0 +1,21 @@
1
+ <template>
2
+ <XamuActionLink v-if="tel" v-bind="{ tel, indicative, theme: mappedNode?.theme }" />
3
+ <span v-else>-</span>
4
+ </template>
5
+
6
+ <script setup>
7
+ import { computed } from "vue";
8
+ const props = defineProps({
9
+ value: { type: null, required: true },
10
+ node: { type: Object, required: false },
11
+ mappedNode: { type: Object, required: false }
12
+ });
13
+ const tel = computed(() => {
14
+ const { whatsappNumber, user } = props.node || {};
15
+ return whatsappNumber || user?.cellphoneNumber;
16
+ });
17
+ const indicative = computed(() => {
18
+ const { whatsappIndicative, user } = props.node || {};
19
+ return whatsappIndicative || user?.cellphoneIndicative;
20
+ });
21
+ </script>
@@ -0,0 +1,24 @@
1
+ import type { tProp, tThemeModifier, tThemeTuple } from "@open-xamu-co/ui-common-types";
2
+ /**
3
+ * Value cellphone
4
+ *
5
+ * @component
6
+ */
7
+ type __VLS_Props = {
8
+ value: any;
9
+ node?: {
10
+ whatsappNumber?: string;
11
+ whatsappIndicative?: `${string}+${number}`;
12
+ user?: {
13
+ address?: string;
14
+ cellphoneNumber?: string;
15
+ cellphoneIndicative?: `${string}+${number}`;
16
+ };
17
+ };
18
+ mappedNode?: {
19
+ theme?: tThemeTuple | tProp<tThemeModifier>;
20
+ };
21
+ };
22
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
+ declare const _default: typeof __VLS_export;
24
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import { eIdDocumentType } from "../functions/utils/enums.js";
2
+ /**
3
+ * Value user document
4
+ *
5
+ * @component
6
+ */
7
+ type __VLS_Props = {
8
+ value: number;
9
+ node?: {
10
+ user?: {
11
+ documentType?: eIdDocumentType;
12
+ documentNumber?: string;
13
+ };
14
+ };
15
+ };
16
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;
@@ -0,0 +1,14 @@
1
+ <template>
2
+ <span v-if="node?.user?.documentNumber">
3
+ {{ node?.user?.documentType || "CC" }}. {{ node?.user?.documentNumber }}
4
+ </span>
5
+ <span v-else>-</span>
6
+ </template>
7
+
8
+ <script setup>
9
+ import { eIdDocumentType } from "../functions/utils/enums";
10
+ defineProps({
11
+ value: { type: Number, required: true },
12
+ node: { type: Object, required: false }
13
+ });
14
+ </script>
@@ -0,0 +1,18 @@
1
+ import { eIdDocumentType } from "../functions/utils/enums.js";
2
+ /**
3
+ * Value user document
4
+ *
5
+ * @component
6
+ */
7
+ type __VLS_Props = {
8
+ value: number;
9
+ node?: {
10
+ user?: {
11
+ documentType?: eIdDocumentType;
12
+ documentNumber?: string;
13
+ };
14
+ };
15
+ };
16
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import type { tProp, tThemeModifier, tThemeTuple } from "@open-xamu-co/ui-common-types";
2
+ /**
3
+ * Value location
4
+ *
5
+ * @component
6
+ */
7
+ type __VLS_Props = {
8
+ value: number;
9
+ node?: {
10
+ ip?: string;
11
+ };
12
+ mappedNode?: {
13
+ theme?: tThemeTuple | tProp<tThemeModifier>;
14
+ };
15
+ };
16
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;
@@ -0,0 +1,28 @@
1
+ <template>
2
+ <XamuActionLink
3
+ v-if="ip"
4
+ v-bind="{
5
+ href: `https://checkip.me/check.php?ip=${ip}`,
6
+ target: '_blank',
7
+ tooltip: 'Ver detalles de la IP',
8
+ tooltipAsText: true,
9
+ theme: mappedNode?.theme
10
+ }"
11
+ >
12
+ {{ ip }}
13
+ </XamuActionLink>
14
+ <span v-else>-</span>
15
+ </template>
16
+
17
+ <script setup>
18
+ import { computed } from "vue";
19
+ const props = defineProps({
20
+ value: { type: Number, required: true },
21
+ node: { type: Object, required: false },
22
+ mappedNode: { type: Object, required: false }
23
+ });
24
+ const ip = computed(() => {
25
+ const { ip: ip2 } = props.node || {};
26
+ return ip2;
27
+ });
28
+ </script>
@@ -0,0 +1,18 @@
1
+ import type { tProp, tThemeModifier, tThemeTuple } from "@open-xamu-co/ui-common-types";
2
+ /**
3
+ * Value location
4
+ *
5
+ * @component
6
+ */
7
+ type __VLS_Props = {
8
+ value: number;
9
+ node?: {
10
+ ip?: string;
11
+ };
12
+ mappedNode?: {
13
+ theme?: tThemeTuple | tProp<tThemeModifier>;
14
+ };
15
+ };
16
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Value location
3
+ *
4
+ * @component
5
+ */
6
+ type __VLS_Props = {
7
+ value: number;
8
+ node?: {
9
+ locationCity?: string;
10
+ locationState?: string;
11
+ locationCountry?: string;
12
+ user?: {
13
+ locationCity?: string;
14
+ locationState?: string;
15
+ locationCountry?: string;
16
+ };
17
+ };
18
+ };
19
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
+ declare const _default: typeof __VLS_export;
21
+ export default _default;
@@ -0,0 +1,20 @@
1
+ <template>
2
+ <span v-if="city">{{ city }}, {{ state }}</span>
3
+ <span v-else>-</span>
4
+ </template>
5
+
6
+ <script setup>
7
+ import { computed } from "vue";
8
+ const props = defineProps({
9
+ value: { type: Number, required: true },
10
+ node: { type: Object, required: false }
11
+ });
12
+ const city = computed(() => {
13
+ const { locationCity, user } = props.node || {};
14
+ return locationCity || user?.locationCity;
15
+ });
16
+ const state = computed(() => {
17
+ const { locationState, user } = props.node || {};
18
+ return locationState || user?.locationState;
19
+ });
20
+ </script>
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Value location
3
+ *
4
+ * @component
5
+ */
6
+ type __VLS_Props = {
7
+ value: number;
8
+ node?: {
9
+ locationCity?: string;
10
+ locationState?: string;
11
+ locationCountry?: string;
12
+ user?: {
13
+ locationCity?: string;
14
+ locationState?: string;
15
+ locationCountry?: string;
16
+ };
17
+ };
18
+ };
19
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
+ declare const _default: typeof __VLS_export;
21
+ export default _default;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Value price
3
+ *
4
+ * @component
5
+ */
6
+ type __VLS_Props = {
7
+ value: number;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,12 @@
1
+ <template>
2
+ <span>{{ price.formattedPrice }}</span>
3
+ </template>
4
+
5
+ <script setup>
6
+ import { computed } from "vue";
7
+ import { usePrice } from "#imports";
8
+ const props = defineProps({
9
+ value: { type: Number, required: true }
10
+ });
11
+ const price = computed(() => usePrice({ price: props.value }));
12
+ </script>
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Value price
3
+ *
4
+ * @component
5
+ */
6
+ type __VLS_Props = {
7
+ value: number;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,4 @@
1
+ export declare function useGoogleAuth(defaultRdrPath?: string): {
2
+ loading: import("vue").Ref<boolean, boolean>;
3
+ loginWithGoogle: import("lodash").DebouncedFunc<() => Promise<void>>;
4
+ };
@@ -0,0 +1,46 @@
1
+ import { debounce } from "lodash-es";
2
+ import {
3
+ browserLocalPersistence,
4
+ setPersistence,
5
+ GoogleAuthProvider,
6
+ signInWithPopup,
7
+ signInWithRedirect
8
+ } from "firebase/auth";
9
+ import { FirebaseError } from "firebase/app";
10
+ import { ref } from "vue";
11
+ import { useRouter, useRoute } from "vue-router";
12
+ import { useSwal } from "@open-xamu-co/ui-common-helpers";
13
+ import { useAppLogger, useNuxtApp } from "#imports";
14
+ export function useGoogleAuth(defaultRdrPath = "/") {
15
+ const { $clientAuth } = useNuxtApp();
16
+ const Swal = useSwal();
17
+ const loading = ref(false);
18
+ const loginWithGoogle = debounce(async () => {
19
+ const router = useRouter();
20
+ const route = useRoute();
21
+ const { restricted } = route.query;
22
+ loading.value = true;
23
+ try {
24
+ if (!$clientAuth) throw new Error("Missing auth");
25
+ const googleProvider = new GoogleAuthProvider();
26
+ googleProvider.setCustomParameters({ prompt: "select_account" });
27
+ await setPersistence($clientAuth, browserLocalPersistence);
28
+ try {
29
+ await signInWithPopup($clientAuth, googleProvider);
30
+ } catch (err) {
31
+ if (!(err instanceof FirebaseError) || err.code !== "auth/popup-blocked") throw err;
32
+ await signInWithRedirect($clientAuth, googleProvider);
33
+ }
34
+ if (!restricted) router.push({ path: defaultRdrPath });
35
+ } catch (err) {
36
+ Swal.fire({
37
+ title: "\xA1Algo sucedi\xF3!",
38
+ text: "Ocurri\xF3 un error mientras iniciabas sesi\xF3n",
39
+ icon: "error"
40
+ });
41
+ useAppLogger("composables:useGoogleAuth", err);
42
+ }
43
+ loading.value = false;
44
+ });
45
+ return { loading, loginWithGoogle };
46
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./auth.js";
2
+ export * from "./write.js";
@@ -0,0 +1,2 @@
1
+ export * from "./auth.js";
2
+ export * from "./write.js";
@@ -0,0 +1,21 @@
1
+ import { DocumentReference } from "firebase/firestore";
2
+ import type { iNodeFnResponseStream } from "@open-xamu-co/ui-common-types";
3
+ import type { GetRef, SharedDocument, FirebaseDocument, iSnapshotConfig } from "../../client/types/index.js";
4
+ interface iUseDocumentOptions extends iSnapshotConfig {
5
+ omitLoggings?: boolean;
6
+ }
7
+ /** Creates document with the given values */
8
+ export declare function useDocumentCreate<Vgr extends GetRef<V>, V extends FirebaseDocument = FirebaseDocument>(collectionPath: string, partialRef: Vgr, createdCallback?: (ref: DocumentReference<Vgr, V>) => Promise<void> | void, { omitLoggings, ...config }?: iUseDocumentOptions): Promise<iNodeFnResponseStream<V>>;
9
+ /**
10
+ * Updates a given document in Firestore.
11
+ *
12
+ * @param node - The existing document to update.
13
+ * @param partialRef - The partial data to update the document with.
14
+ * @returns A boolean promise.
15
+ */
16
+ export declare function useDocumentUpdate<Vgr extends GetRef<V>, V extends FirebaseDocument = FirebaseDocument>(node: SharedDocument, middleRef?: Partial<Vgr>, { omitLoggings, ...config }?: iUseDocumentOptions): Promise<iNodeFnResponseStream<V>>;
17
+ /** Clones given document */
18
+ export declare function useDocumentClone<Vgr extends GetRef<V>, V extends FirebaseDocument = FirebaseDocument>(node: SharedDocument, middleRef?: Partial<Vgr>, { omitLoggings, ...config }?: iUseDocumentOptions): Promise<iNodeFnResponseStream<V>>;
19
+ /** Deletes given document */
20
+ export declare function useDocumentDelete<T extends FirebaseDocument = FirebaseDocument>(node: SharedDocument, { omitLoggings }?: iUseDocumentOptions): Promise<iNodeFnResponseStream<T>>;
21
+ export {};