@_henriquewilson/gabirubi-domain 1.3.92 → 1.3.94
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/model/store/raw.d.mts +3 -0
- package/dist/model/store/raw.d.ts +3 -0
- package/dist/model/store/raw.js +1 -0
- package/dist/model/store/raw.js.map +1 -1
- package/dist/model/store/raw.mjs +1 -0
- package/dist/model/store/raw.mjs.map +1 -1
- package/dist/util/firestore.util.d.mts +9 -4
- package/dist/util/firestore.util.d.ts +9 -4
- package/dist/util/firestore.util.js +16 -4
- package/dist/util/firestore.util.js.map +1 -1
- package/dist/util/firestore.util.mjs +16 -4
- package/dist/util/firestore.util.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ declare const RawStoreSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
10
10
|
category: z.ZodOptional<z.ZodString>;
|
|
11
11
|
type: z.ZodOptional<z.ZodString>;
|
|
12
12
|
amount: z.ZodNumber;
|
|
13
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
13
14
|
history: z.ZodOptional<z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
|
|
14
15
|
createdAt: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodType<FirebaseFirestore.Timestamp, z.ZodTypeDef, FirebaseFirestore.Timestamp>, FirebaseFirestore.Timestamp, unknown>>>>;
|
|
15
16
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -33,6 +34,7 @@ declare const RawStoreSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
33
34
|
updatedAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
34
35
|
order?: number | null | undefined;
|
|
35
36
|
category?: string | undefined;
|
|
37
|
+
unit?: string | undefined;
|
|
36
38
|
history?: {
|
|
37
39
|
subtract: number;
|
|
38
40
|
createdAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
@@ -47,6 +49,7 @@ declare const RawStoreSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
47
49
|
updatedAt?: unknown;
|
|
48
50
|
order?: number | null | undefined;
|
|
49
51
|
category?: string | undefined;
|
|
52
|
+
unit?: string | undefined;
|
|
50
53
|
history?: {
|
|
51
54
|
subtract: number;
|
|
52
55
|
createdAt?: unknown;
|
|
@@ -10,6 +10,7 @@ declare const RawStoreSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
10
10
|
category: z.ZodOptional<z.ZodString>;
|
|
11
11
|
type: z.ZodOptional<z.ZodString>;
|
|
12
12
|
amount: z.ZodNumber;
|
|
13
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
13
14
|
history: z.ZodOptional<z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
|
|
14
15
|
createdAt: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodType<FirebaseFirestore.Timestamp, z.ZodTypeDef, FirebaseFirestore.Timestamp>, FirebaseFirestore.Timestamp, unknown>>>>;
|
|
15
16
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -33,6 +34,7 @@ declare const RawStoreSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
33
34
|
updatedAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
34
35
|
order?: number | null | undefined;
|
|
35
36
|
category?: string | undefined;
|
|
37
|
+
unit?: string | undefined;
|
|
36
38
|
history?: {
|
|
37
39
|
subtract: number;
|
|
38
40
|
createdAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
@@ -47,6 +49,7 @@ declare const RawStoreSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
47
49
|
updatedAt?: unknown;
|
|
48
50
|
order?: number | null | undefined;
|
|
49
51
|
category?: string | undefined;
|
|
52
|
+
unit?: string | undefined;
|
|
50
53
|
history?: {
|
|
51
54
|
subtract: number;
|
|
52
55
|
createdAt?: unknown;
|
package/dist/model/store/raw.js
CHANGED
|
@@ -113,6 +113,7 @@ var RawStoreSchema = ModelSchema.extend({
|
|
|
113
113
|
category: import_zod3.z.string().optional(),
|
|
114
114
|
type: import_zod3.z.string().optional(),
|
|
115
115
|
amount: import_zod3.z.number(),
|
|
116
|
+
unit: import_zod3.z.string().optional(),
|
|
116
117
|
history: DocumentHistorySchema.extend({
|
|
117
118
|
subtract: import_zod3.z.number()
|
|
118
119
|
}).array().optional()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/store/raw.js","../../../src/model/store/raw.ts","../../../src/model.ts","../../../src/model/shared.ts"],"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","raw_exports","RawStoreSchema","module","exports","import_zod","require","import_firestore","TimestampOrNow","z","preprocess","arg","Timestamp","now","custom","nullish","optional","import_cuid","generateFirestoreId","cuid","IdModelSchema","import_zod2","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","import_zod3","category","type","amount","history","subtract"],"mappings":"AAAA;AACA,IAAIA,WAAWC,OAAOC,MAAM;AAC5B,IAAIC,YAAYF,OAAOG,cAAc;AACrC,IAAIC,mBAAmBJ,OAAOK,wBAAwB;AACtD,IAAIC,oBAAoBN,OAAOO,mBAAmB;AAClD,IAAIC,eAAeR,OAAOS,cAAc;AACxC,IAAIC,eAAeV,OAAOW,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,SAACC,QAAQC;IACtB,IAAK,IAAIC,QAAQD,IACfb,UAAUY,QAAQE,MAAM;QAAEC,KAAKF,GAAG,CAACC,KAAK;QAAEE,YAAY;IAAK;AAC/D;AACA,IAAIC,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AAA,CAAEc,MAAA,GAASP,QAAA;IACrB8B,MAAMF,YAAAnC,CAAA,CAAEc,MAAA,GAASP,QAAA;IACjB+B,QAAQH,YAAAnC,CAAA,CAAEe,MAAA;IACVwB,
|
|
1
|
+
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/store/raw.js","../../../src/model/store/raw.ts","../../../src/model.ts","../../../src/model/shared.ts"],"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","raw_exports","RawStoreSchema","module","exports","import_zod","require","import_firestore","TimestampOrNow","z","preprocess","arg","Timestamp","now","custom","nullish","optional","import_cuid","generateFirestoreId","cuid","IdModelSchema","import_zod2","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","import_zod3","category","type","amount","unit","history","subtract"],"mappings":"AAAA;AACA,IAAIA,WAAWC,OAAOC,MAAM;AAC5B,IAAIC,YAAYF,OAAOG,cAAc;AACrC,IAAIC,mBAAmBJ,OAAOK,wBAAwB;AACtD,IAAIC,oBAAoBN,OAAOO,mBAAmB;AAClD,IAAIC,eAAeR,OAAOS,cAAc;AACxC,IAAIC,eAAeV,OAAOW,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,SAACC,QAAQC;IACtB,IAAK,IAAIC,QAAQD,IACfb,UAAUY,QAAQE,MAAM;QAAEC,KAAKF,GAAG,CAACC,KAAK;QAAEE,YAAY;IAAK;AAC/D;AACA,IAAIC,cAAc,SAACC,IAAIC,MAAMC,QAAQC;IACnC,IAAIF,QAAQ,OAAOA,SAAS,YAAY,OAAOA,SAAS,YAAY;YAC7D,kCAAA,2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,CAAA,CAAEe,MAAA;IACVwB,MAAMJ,YAAAnC,CAAA,CAAEc,MAAA,GAASP,QAAA;IACjBiC,SAASP,sBAAsBP,MAAA,CAAO;QACpCe,UAAUN,YAAAnC,CAAA,CAAEe,MAAA;IACd,GAAGc,KAAA,GAAQtB,QAAA;AACb;AD2EA,6DAA6D;AAC7D,KAAMb,CAAAA,OAAOC,OAAO,GAAG;IACrBF,gBAAAA;AACF,CAAA","sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/model/store/raw.ts\nvar raw_exports = {};\n__export(raw_exports, {\n RawStoreSchema: () => RawStoreSchema\n});\nmodule.exports = __toCommonJS(raw_exports);\n\n// src/model.ts\nvar import_zod2 = require(\"zod\");\n\n// src/model/shared.ts\nvar import_firestore = require(\"@google-cloud/firestore\");\nvar import_zod = require(\"zod\");\nvar TimestampOrNow = import_zod.z.preprocess(\n (arg) => arg === void 0 ? import_firestore.Timestamp.now() : arg,\n import_zod.z.custom()\n).nullish().optional();\n\n// src/model.ts\nvar import_cuid = __toESM(require(\"cuid\"));\nvar generateFirestoreId = () => {\n return (0, import_cuid.default)();\n};\nvar IdModelSchema = import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]);\nvar IdModelProcess = import_zod2.z.preprocess((val) => {\n if (val === void 0 || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\nvar ModelSchema = import_zod2.z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: import_zod2.z.coerce.number().nullish().optional()\n});\nvar PreviousSchema = ModelSchema.extend({\n previous: import_zod2.z.lazy(() => ModelSchema.array().optional())\n});\nvar EnabledSchema = import_zod2.z.object({\n enabled: import_zod2.z.boolean().optional()\n});\nvar DocumentHistorySchema = import_zod2.z.object({\n createdAt: TimestampOrNow,\n description: import_zod2.z.string().optional()\n});\n\n// src/model/store/raw.ts\nvar import_zod3 = require(\"zod\");\nvar RawStoreSchema = ModelSchema.extend({\n name: import_zod3.z.string(),\n category: import_zod3.z.string().optional(),\n type: import_zod3.z.string().optional(),\n amount: import_zod3.z.number(),\n unit: import_zod3.z.string().optional(),\n history: DocumentHistorySchema.extend({\n subtract: import_zod3.z.number()\n }).array().optional()\n});\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n RawStoreSchema\n});\n","import {DocumentHistorySchema, ModelSchema} from \"../../model\";\nimport {z} from \"zod\";\n\n\nexport const RawStoreSchema = ModelSchema.extend({\n name: z.string(),\n category: z.string().optional(),\n type: z.string().optional(),\n amount: z.number(),\n unit: z.string().optional(),\n history: DocumentHistorySchema.extend({\n subtract: z.number()\n }).array().optional()\n})\n\n\n\nexport type RawStore = z.infer<typeof RawStoreSchema>\n\n\n","import {z} from \"zod\";\nimport {TimestampOrNow} from \"./model/shared\";\nimport cuid from 'cuid';\n\nexport const generateFirestoreId = () => {\n return cuid();\n}\n\nexport const IdModelSchema = z.union([z.string(), z.number()])\n\nconst IdModelProcess = z.preprocess((val) => {\n if (val === undefined || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\n\nexport const ModelSchema = z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z.coerce.number().nullish().optional()\n});\n\nexport const PreviousSchema = ModelSchema.extend({\n previous: z.lazy(() => ModelSchema.array().optional())\n})\n\nexport const EnabledSchema = z.object({\n enabled: z.boolean().optional()\n})\n\nexport const DocumentHistorySchema = z.object({\n createdAt: TimestampOrNow,\n description: z.string().optional(),\n})\n\nexport type IdModel = z.infer<typeof IdModelSchema>;\nexport type Model = z.infer<typeof ModelSchema>;\nexport type Previous = z.infer<typeof PreviousSchema>;\nexport type Enabled = z.infer<typeof EnabledSchema>;\nexport type PartialWithId<T extends Model> = Partial<T> & {\n id: NonNullable<T['id']>\n}\n\n\n","import { Timestamp } from '@google-cloud/firestore';\nimport {z} from \"zod\";\n\nexport const TimestampOrNow = z\n .preprocess(\n (arg) => (arg === undefined ? Timestamp.now() : arg),\n z.custom<Timestamp>(),\n )\n .nullish().optional();\n"]}
|
package/dist/model/store/raw.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/store/raw.mjs","../../../src/model.ts","../../../src/model/shared.ts","../../../src/model/store/raw.ts"],"names":["z","Timestamp","TimestampOrNow","preprocess","arg","now","custom","nullish","optional","cuid","generateFirestoreId","IdModelSchema","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","RawStoreSchema","name","category","type","amount","history","subtract"],"mappings":"AAAA,eAAe;ACAf,SAAQA,KAAAA,EAAAA,QAAQ,M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L,QAAA;IACjB8B,QAAQtC,GAAEc,MAAA;IACVyB,
|
|
1
|
+
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/store/raw.mjs","../../../src/model.ts","../../../src/model/shared.ts","../../../src/model/store/raw.ts"],"names":["z","Timestamp","TimestampOrNow","preprocess","arg","now","custom","nullish","optional","cuid","generateFirestoreId","IdModelSchema","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","RawStoreSchema","name","category","type","amount","unit","history","subtract"],"mappings":"AAAA,eAAe;ACAf,SAAQA,KAAAA,EAAAA,QAAQ,MAAA;ADGhB,sBAAsB;AEHtB,SAASC,SAAA,QAAiB,0BAAA;AAC1B,SAAQD,CAAA,QAAQ,MAAA;AAET,IAAME,iBAAiBF,EAC3BG,UAAA,CACC,SAACC;WAASA,QAAQ,KAAA,IAAYH,UAAUI,GAAA,KAAQD;GAChDJ,EAAEM,MAAA,IAEHC,OAAA,GAAUC,QAAA;AFGb,eAAe;ACTf,OAAOC,UAAU,OAAA;AAEV,IAAMC,sBAAsB;IACjC,OAAOD;AACT;AAEO,IAAME,gBAAgBX,GAAEY,KAAA,CAAM;IAACZ,GAAEa,MAAA;IAAUb,GAAEc,MAAA;CAAS;AAE7D,IAAMC,iBAAiBf,GAAEG,UAAA,CAAW,SAACa;IACnC,IAAIA,QAAQ,KAAA,KAAaA,QAAQ,MAAM;QACrC,OAAON;IACT;IACA,OAAOM;AACT,GAAGL;AAEI,IAAMM,cAAcjB,GAAEkB,MAAA,CAAO;IAClCC,IAAIJ;IACJK,WAAWlB;IACXmB,WAAWnB;IACXoB,OAAOtB,GAAEuB,MAAA,CAAOT,MAAA,GAASP,OAAA,GAAUC,QAAA;AACrC;AAEO,IAAMgB,iBAAiBP,YAAYQ,MAAA,CAAO;IAC/CC,UAAU1B,GAAE2B,IAAA,CAAK;eAAMV,YAAYW,KAAA,GAAQpB,QAAA;;AAC7C;AAEO,IAAMqB,gBAAgB7B,GAAEkB,MAAA,CAAO;IACpCY,SAAS9B,GAAE+B,OAAA,GAAUvB,QAAA;AACvB;AAEO,IAAMwB,wBAAwBhC,GAAEkB,MAAA,CAAO;IAC5CE,WAAWlB;IACX+B,aAAajC,GAAEa,MAAA,GAASL,QAAA;AAC1B;ADKA,yBAAyB;AGvCzB,SAAQR,KAAAA,EAAAA,QAAQ,MAAA;AAGT,IAAMkC,iBAAiBjB,YAAYQ,MAAA,CAAO;IAC/CU,MAAMnC,GAAEa,MAAA;IACRuB,UAAUpC,GAAEa,MAAA,GAASL,QAAA;IACrB6B,MAAMrC,GAAEa,MAAA,GAASL,QAAA;IACjB8B,QAAQtC,GAAEc,MAAA;IACVyB,MAAMvC,GAAEa,MAAA,GAASL,QAAA;IACjBgC,SAASR,sBAAsBP,MAAA,CAAO;QACpCgB,UAAUzC,GAAEc,MAAA;IACd,GAAGc,KAAA,GAAQpB,QAAA;AACb;AHuCA,SACE0B,cAAc,GACd","sourcesContent":["// src/model.ts\nimport { z as z2 } from \"zod\";\n\n// src/model/shared.ts\nimport { Timestamp } from \"@google-cloud/firestore\";\nimport { z } from \"zod\";\nvar TimestampOrNow = z.preprocess(\n (arg) => arg === void 0 ? Timestamp.now() : arg,\n z.custom()\n).nullish().optional();\n\n// src/model.ts\nimport cuid from \"cuid\";\nvar generateFirestoreId = () => {\n return cuid();\n};\nvar IdModelSchema = z2.union([z2.string(), z2.number()]);\nvar IdModelProcess = z2.preprocess((val) => {\n if (val === void 0 || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\nvar ModelSchema = z2.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z2.coerce.number().nullish().optional()\n});\nvar PreviousSchema = ModelSchema.extend({\n previous: z2.lazy(() => ModelSchema.array().optional())\n});\nvar EnabledSchema = z2.object({\n enabled: z2.boolean().optional()\n});\nvar DocumentHistorySchema = z2.object({\n createdAt: TimestampOrNow,\n description: z2.string().optional()\n});\n\n// src/model/store/raw.ts\nimport { z as z3 } from \"zod\";\nvar RawStoreSchema = ModelSchema.extend({\n name: z3.string(),\n category: z3.string().optional(),\n type: z3.string().optional(),\n amount: z3.number(),\n unit: z3.string().optional(),\n history: DocumentHistorySchema.extend({\n subtract: z3.number()\n }).array().optional()\n});\nexport {\n RawStoreSchema\n};\n","import {z} from \"zod\";\nimport {TimestampOrNow} from \"./model/shared\";\nimport cuid from 'cuid';\n\nexport const generateFirestoreId = () => {\n return cuid();\n}\n\nexport const IdModelSchema = z.union([z.string(), z.number()])\n\nconst IdModelProcess = z.preprocess((val) => {\n if (val === undefined || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\n\nexport const ModelSchema = z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z.coerce.number().nullish().optional()\n});\n\nexport const PreviousSchema = ModelSchema.extend({\n previous: z.lazy(() => ModelSchema.array().optional())\n})\n\nexport const EnabledSchema = z.object({\n enabled: z.boolean().optional()\n})\n\nexport const DocumentHistorySchema = z.object({\n createdAt: TimestampOrNow,\n description: z.string().optional(),\n})\n\nexport type IdModel = z.infer<typeof IdModelSchema>;\nexport type Model = z.infer<typeof ModelSchema>;\nexport type Previous = z.infer<typeof PreviousSchema>;\nexport type Enabled = z.infer<typeof EnabledSchema>;\nexport type PartialWithId<T extends Model> = Partial<T> & {\n id: NonNullable<T['id']>\n}\n\n\n","import { Timestamp } from '@google-cloud/firestore';\nimport {z} from \"zod\";\n\nexport const TimestampOrNow = z\n .preprocess(\n (arg) => (arg === undefined ? Timestamp.now() : arg),\n z.custom<Timestamp>(),\n )\n .nullish().optional();\n","import {DocumentHistorySchema, ModelSchema} from \"../../model\";\nimport {z} from \"zod\";\n\n\nexport const RawStoreSchema = ModelSchema.extend({\n name: z.string(),\n category: z.string().optional(),\n type: z.string().optional(),\n amount: z.number(),\n unit: z.string().optional(),\n history: DocumentHistorySchema.extend({\n subtract: z.number()\n }).array().optional()\n})\n\n\n\nexport type RawStore = z.infer<typeof RawStoreSchema>\n\n\n"]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface TimestampLike {
|
|
2
|
+
seconds: number;
|
|
3
|
+
nanoseconds: number;
|
|
4
|
+
toDate?: () => Date;
|
|
5
|
+
}
|
|
3
6
|
declare class FirestoreRawService {
|
|
4
|
-
static
|
|
7
|
+
private static TimestampClass;
|
|
8
|
+
static configure(TimestampClass: any): void;
|
|
9
|
+
static forceTimestamp(data?: TimestampLike | null): any;
|
|
5
10
|
}
|
|
6
|
-
declare const forceTimestamp: (data:
|
|
11
|
+
declare const forceTimestamp: (data: any) => any;
|
|
7
12
|
|
|
8
13
|
export { FirestoreRawService, forceTimestamp };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface TimestampLike {
|
|
2
|
+
seconds: number;
|
|
3
|
+
nanoseconds: number;
|
|
4
|
+
toDate?: () => Date;
|
|
5
|
+
}
|
|
3
6
|
declare class FirestoreRawService {
|
|
4
|
-
static
|
|
7
|
+
private static TimestampClass;
|
|
8
|
+
static configure(TimestampClass: any): void;
|
|
9
|
+
static forceTimestamp(data?: TimestampLike | null): any;
|
|
5
10
|
}
|
|
6
|
-
declare const forceTimestamp: (data:
|
|
11
|
+
declare const forceTimestamp: (data: any) => any;
|
|
7
12
|
|
|
8
13
|
export { FirestoreRawService, forceTimestamp };
|
|
@@ -75,22 +75,33 @@ __export(firestore_util_exports, {
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
module.exports = __toCommonJS(firestore_util_exports);
|
|
78
|
-
var import_firestore = require("@google-cloud/firestore");
|
|
79
78
|
var FirestoreRawService = /*#__PURE__*/ function() {
|
|
80
79
|
function FirestoreRawService() {
|
|
81
80
|
_class_call_check(this, FirestoreRawService);
|
|
82
81
|
}
|
|
83
82
|
_create_class(FirestoreRawService, null, [
|
|
83
|
+
{
|
|
84
|
+
key: "configure",
|
|
85
|
+
value: function configure(TimestampClass) {
|
|
86
|
+
this.TimestampClass = TimestampClass;
|
|
87
|
+
}
|
|
88
|
+
},
|
|
84
89
|
{
|
|
85
90
|
key: "forceTimestamp",
|
|
86
91
|
value: function forceTimestamp(data) {
|
|
87
92
|
if (!data) return null;
|
|
93
|
+
if (!this.TimestampClass) {
|
|
94
|
+
throw new Error("FirestoreRawService has not been configured. Call configure() first");
|
|
95
|
+
}
|
|
88
96
|
try {
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
if (data.toDate && typeof data.toDate === "function") {
|
|
98
|
+
var d = data.toDate();
|
|
99
|
+
return this.TimestampClass.fromDate ? this.TimestampClass.fromDate(d) : new this.TimestampClass(Math.floor(d.getTime() / 1e3), d.getTime() % 1e3 * 1e6);
|
|
100
|
+
}
|
|
101
|
+
return new this.TimestampClass(data.seconds, data.nanoseconds);
|
|
91
102
|
} catch (e) {
|
|
92
103
|
try {
|
|
93
|
-
return new
|
|
104
|
+
return new this.TimestampClass(data.seconds, data.nanoseconds);
|
|
94
105
|
} catch (e2) {
|
|
95
106
|
return null;
|
|
96
107
|
}
|
|
@@ -100,6 +111,7 @@ var FirestoreRawService = /*#__PURE__*/ function() {
|
|
|
100
111
|
]);
|
|
101
112
|
return FirestoreRawService;
|
|
102
113
|
}();
|
|
114
|
+
FirestoreRawService.TimestampClass = null;
|
|
103
115
|
var forceTimestamp = function(data) {
|
|
104
116
|
return FirestoreRawService.forceTimestamp(data);
|
|
105
117
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/util/firestore.util.js","../../src/util/firestore.util.ts"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","firestore_util_exports","FirestoreRawService","forceTimestamp","module","exports","
|
|
1
|
+
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/util/firestore.util.js","../../src/util/firestore.util.ts"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","firestore_util_exports","FirestoreRawService","forceTimestamp","module","exports","configure","TimestampClass","data","Error","toDate","d","fromDate","Math","floor","getTime","seconds","nanoseconds","e"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,YAAYC,OAAOC,cAAc;AACrC,IAAIC,mBAAmBF,OAAOG,wBAAwB;AACtD,IAAIC,oBAAoBJ,OAAOK,mBAAmB;AAClD,IAAIC,eAAeN,OAAOO,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,SAACC,QAAQC;IACtB,IAAK,IAAIC,QAAQD,IACfZ,UAAUW,QAAQE,MAAM;QAAEC,KAAKF,GAAG,CAACC,KAAK;QAAEE,YAAY;IAAK;AAC/D;AACA,IAAIC,cAAc,SAACC,IAAIC,MAAMC,QAAQC;IACnC,IAAIF,QAAQ,OAAOA,SAAS,YAAY,OAAOA,SAAS,YAAY;YAC7D,kCAAA,2BAAA;;;gBAAA,IAAIG,MAAJ;gBACH,IAAI,CAACd,aAAae,IAAI,CAACL,IAAII,QAAQA,QAAQF,QACzCnB,UAAUiB,IAAII,KAAK;oBAAEP,KAAK;+BAAMI,IAAI,CAACG,IAAI;;oBAAEN,YAAY,CAAEK,CAAAA,OAAOjB,iBAAiBe,MAAMG,IAAG,KAAMD,KAAKL,UAAU;gBAAC;;YAFpH,QAAK,YAAWV,kBAAkBa,0BAA7B,SAAA,6BAAA,QAAA,yBAAA;;YAAA;YAAA;;;qBAAA,6BAAA;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A,CAAeK;;ADYrC,6DAA6D;AAC7D,KAAMJ,CAAAA,OAAOC,OAAO,GAAG;IACrBH,qBAAAA;IACAC,gBAAAA;AACF,CAAA","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/util/firestore.util.ts\nvar firestore_util_exports = {};\n__export(firestore_util_exports, {\n FirestoreRawService: () => FirestoreRawService,\n forceTimestamp: () => forceTimestamp\n});\nmodule.exports = __toCommonJS(firestore_util_exports);\nvar FirestoreRawService = class {\n static configure(TimestampClass) {\n this.TimestampClass = TimestampClass;\n }\n static forceTimestamp(data) {\n if (!data) return null;\n if (!this.TimestampClass) {\n throw new Error(\"FirestoreRawService has not been configured. Call configure() first\");\n }\n try {\n if (data.toDate && typeof data.toDate === \"function\") {\n const d = data.toDate();\n return this.TimestampClass.fromDate ? this.TimestampClass.fromDate(d) : new this.TimestampClass(\n Math.floor(d.getTime() / 1e3),\n d.getTime() % 1e3 * 1e6\n );\n }\n return new this.TimestampClass(data.seconds, data.nanoseconds);\n } catch (e) {\n try {\n return new this.TimestampClass(data.seconds, data.nanoseconds);\n } catch (e2) {\n return null;\n }\n }\n }\n};\nFirestoreRawService.TimestampClass = null;\nvar forceTimestamp = (data) => FirestoreRawService.forceTimestamp(data);\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n FirestoreRawService,\n forceTimestamp\n});\n","interface TimestampLike {\n seconds: number;\n nanoseconds: number;\n toDate?: () => Date;\n}\n\nexport class FirestoreRawService {\n private static TimestampClass: any = null;\n\n public static configure(TimestampClass: any) {\n this.TimestampClass = TimestampClass;\n }\n\n public static forceTimestamp(data?: TimestampLike | null) {\n if (!data) return null;\n\n if (!this.TimestampClass) {\n throw new Error('FirestoreRawService has not been configured. Call configure() first');\n }\n\n try {\n if (data.toDate && typeof data.toDate === 'function') {\n const d = data.toDate();\n return this.TimestampClass.fromDate\n ? this.TimestampClass.fromDate(d)\n : new this.TimestampClass(\n Math.floor(d.getTime() / 1000),\n (d.getTime() % 1000) * 1000000\n );\n }\n\n return new this.TimestampClass(data.seconds, data.nanoseconds);\n } catch (e) {\n try {\n return new this.TimestampClass(data.seconds, data.nanoseconds);\n } catch (e) {\n return null;\n }\n }\n }\n}\n\nexport const forceTimestamp = (data: any) =>\n FirestoreRawService.forceTimestamp(data);\n"]}
|
|
@@ -18,23 +18,34 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
18
18
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
19
19
|
return Constructor;
|
|
20
20
|
}
|
|
21
|
-
import { Timestamp } from "@google-cloud/firestore";
|
|
22
21
|
var FirestoreRawService = /*#__PURE__*/ function() {
|
|
23
22
|
"use strict";
|
|
24
23
|
function FirestoreRawService() {
|
|
25
24
|
_class_call_check(this, FirestoreRawService);
|
|
26
25
|
}
|
|
27
26
|
_create_class(FirestoreRawService, null, [
|
|
27
|
+
{
|
|
28
|
+
key: "configure",
|
|
29
|
+
value: function configure(TimestampClass) {
|
|
30
|
+
this.TimestampClass = TimestampClass;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
28
33
|
{
|
|
29
34
|
key: "forceTimestamp",
|
|
30
35
|
value: function forceTimestamp(data) {
|
|
31
36
|
if (!data) return null;
|
|
37
|
+
if (!this.TimestampClass) {
|
|
38
|
+
throw new Error("FirestoreRawService has not been configured. Call configure() first");
|
|
39
|
+
}
|
|
32
40
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
if (data.toDate && typeof data.toDate === "function") {
|
|
42
|
+
var d = data.toDate();
|
|
43
|
+
return this.TimestampClass.fromDate ? this.TimestampClass.fromDate(d) : new this.TimestampClass(Math.floor(d.getTime() / 1e3), d.getTime() % 1e3 * 1e6);
|
|
44
|
+
}
|
|
45
|
+
return new this.TimestampClass(data.seconds, data.nanoseconds);
|
|
35
46
|
} catch (e) {
|
|
36
47
|
try {
|
|
37
|
-
return new
|
|
48
|
+
return new this.TimestampClass(data.seconds, data.nanoseconds);
|
|
38
49
|
} catch (e2) {
|
|
39
50
|
return null;
|
|
40
51
|
}
|
|
@@ -44,6 +55,7 @@ var FirestoreRawService = /*#__PURE__*/ function() {
|
|
|
44
55
|
]);
|
|
45
56
|
return FirestoreRawService;
|
|
46
57
|
}();
|
|
58
|
+
FirestoreRawService.TimestampClass = null;
|
|
47
59
|
var forceTimestamp = function(data) {
|
|
48
60
|
return FirestoreRawService.forceTimestamp(data);
|
|
49
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/util/firestore.util.mjs","../../src/util/firestore.util.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/util/firestore.util.mjs","../../src/util/firestore.util.ts"],"names":["FirestoreRawService","configure","TimestampClass","forceTimestamp","data","Error","toDate","d","fromDate","Math","floor","getTime","seconds","nanoseconds","e"],"mappings":"AAAA,6BAA6B;;;;;;;;;;;;;;;;;;;;ACMtB,IAAMA,oCAAN;;aAAMA;;;;;YAGGC,KAAAA;mBAAd,SAAcA,UAAUC,cAAA;gBACtB,IAAA,CAAKA,cAAA,GAAiBA;YACxB;;;YAEcC,KAAAA;mBAAd,SAAcA,eAAeC,IAAA;gBAC3B,IAAI,CAACA,MAAM,OAAO;gBAElB,IAAI,CAAC,IAAA,CAAKF,cAAA,EAAgB;oBACxB,MAAM,IAAIG,MAAM;gBAClB;gBAEA,IAAI;oBACF,IAAID,KAAKE,MAAA,IAAU,OAAOF,KAAKE,MAAA,KAAW,YAAY;wBACpD,IAAMC,IAAIH,KAAKE,MAAA;wBACf,OAAO,IAAA,CAAKJ,cAAA,CAAeM,QAAA,GACvB,IAAA,CAAKN,cAAA,CAAeM,QAAA,CAASD,KAC7B,IAAI,IAAA,CAAKL,cAAA,CACTO,KAAKC,KAAA,CAAMH,EAAEI,OAAA,KAAY,MACxBJ,EAAEI,OAAA,KAAY,MAAQ;oBAE7B;oBAEA,OAAO,IAAI,IAAA,CAAKT,cAAA,CAAeE,KAAKQ,OAAA,EAASR,KAAKS,WAAW;gBAC/D,EAAA,OAASC,GAAG;oBACV,IAAI;wBACF,OAAO,IAAI,IAAA,CAAKZ,cAAA,CAAeE,KAAKQ,OAAA,EAASR,KAAKS,WAAW;oBAC/D,EAAA,OAASC,IAAG;wBACV,OAAO;oBACT;gBACF;YACF;;;;;AAjCWd,oBACIE,cAAA,GAAsB;AAmChC,IAAMC,iBAAiB,SAACC;WAC7BJ,oBAAoBG,cAAA,CAAeC;;ADbrC,SACEJ,mBAAmB,EACnBG,cAAc,GACd","sourcesContent":["// src/util/firestore.util.ts\nvar FirestoreRawService = class {\n static configure(TimestampClass) {\n this.TimestampClass = TimestampClass;\n }\n static forceTimestamp(data) {\n if (!data) return null;\n if (!this.TimestampClass) {\n throw new Error(\"FirestoreRawService has not been configured. Call configure() first\");\n }\n try {\n if (data.toDate && typeof data.toDate === \"function\") {\n const d = data.toDate();\n return this.TimestampClass.fromDate ? this.TimestampClass.fromDate(d) : new this.TimestampClass(\n Math.floor(d.getTime() / 1e3),\n d.getTime() % 1e3 * 1e6\n );\n }\n return new this.TimestampClass(data.seconds, data.nanoseconds);\n } catch (e) {\n try {\n return new this.TimestampClass(data.seconds, data.nanoseconds);\n } catch (e2) {\n return null;\n }\n }\n }\n};\nFirestoreRawService.TimestampClass = null;\nvar forceTimestamp = (data) => FirestoreRawService.forceTimestamp(data);\nexport {\n FirestoreRawService,\n forceTimestamp\n};\n","interface TimestampLike {\n seconds: number;\n nanoseconds: number;\n toDate?: () => Date;\n}\n\nexport class FirestoreRawService {\n private static TimestampClass: any = null;\n\n public static configure(TimestampClass: any) {\n this.TimestampClass = TimestampClass;\n }\n\n public static forceTimestamp(data?: TimestampLike | null) {\n if (!data) return null;\n\n if (!this.TimestampClass) {\n throw new Error('FirestoreRawService has not been configured. Call configure() first');\n }\n\n try {\n if (data.toDate && typeof data.toDate === 'function') {\n const d = data.toDate();\n return this.TimestampClass.fromDate\n ? this.TimestampClass.fromDate(d)\n : new this.TimestampClass(\n Math.floor(d.getTime() / 1000),\n (d.getTime() % 1000) * 1000000\n );\n }\n\n return new this.TimestampClass(data.seconds, data.nanoseconds);\n } catch (e) {\n try {\n return new this.TimestampClass(data.seconds, data.nanoseconds);\n } catch (e) {\n return null;\n }\n }\n }\n}\n\nexport const forceTimestamp = (data: any) =>\n FirestoreRawService.forceTimestamp(data);\n"]}
|