@leaddreamer/inventorylogic 0.0.3-beta.78 → 0.0.3-beta.80

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 (80) hide show
  1. package/README.md +16 -20
  2. package/business/Utilities/index.js +1 -0
  3. package/business/Utilities/other.js +1 -3
  4. package/business/Utilities/promise-queue/index.js +183 -150
  5. package/business/Utilities/promise-queue/new.js +231 -0
  6. package/dist/InventoryLogic.0ac93278.js +35 -0
  7. package/dist/InventoryLogic.0ac93278.js.map +1 -0
  8. package/dist/InventoryLogic.31f6d549.js +152 -0
  9. package/dist/InventoryLogic.31f6d549.js.map +1 -0
  10. package/dist/InventoryLogic.35827495.js +285 -0
  11. package/dist/InventoryLogic.35827495.js.map +1 -0
  12. package/dist/InventoryLogic.37dfff3e.js +72 -0
  13. package/dist/InventoryLogic.37dfff3e.js.map +1 -0
  14. package/dist/InventoryLogic.4206cb15.js +213 -0
  15. package/dist/InventoryLogic.4206cb15.js.map +1 -0
  16. package/dist/InventoryLogic.44193a77.js +35 -0
  17. package/dist/InventoryLogic.44193a77.js.map +1 -0
  18. package/dist/InventoryLogic.46ca6768.js +131 -0
  19. package/dist/InventoryLogic.46ca6768.js.map +1 -0
  20. package/dist/InventoryLogic.4d012935.js +151 -0
  21. package/dist/InventoryLogic.4d012935.js.map +1 -0
  22. package/dist/InventoryLogic.57f24f5f.js +155 -0
  23. package/dist/InventoryLogic.57f24f5f.js.map +1 -0
  24. package/dist/InventoryLogic.59be76a4.js +184 -0
  25. package/dist/InventoryLogic.59be76a4.js.map +1 -0
  26. package/dist/InventoryLogic.70925a32.js +375 -0
  27. package/dist/InventoryLogic.70925a32.js.map +1 -0
  28. package/dist/InventoryLogic.72fcf301.js +6 -0
  29. package/dist/InventoryLogic.72fcf301.js.map +1 -0
  30. package/dist/InventoryLogic.7741caec.js +375 -0
  31. package/dist/InventoryLogic.7741caec.js.map +1 -0
  32. package/dist/InventoryLogic.78480e5e.js +152 -0
  33. package/dist/InventoryLogic.78480e5e.js.map +1 -0
  34. package/dist/InventoryLogic.80d0e568.js +135 -0
  35. package/dist/InventoryLogic.80d0e568.js.map +1 -0
  36. package/dist/InventoryLogic.8a273d2e.js +110 -0
  37. package/dist/InventoryLogic.8a273d2e.js.map +1 -0
  38. package/dist/InventoryLogic.8addb055.js +202 -0
  39. package/dist/InventoryLogic.8addb055.js.map +1 -0
  40. package/dist/InventoryLogic.9dee46ea.js +6 -0
  41. package/dist/InventoryLogic.9dee46ea.js.map +1 -0
  42. package/dist/InventoryLogic.b90f66ea.js +124 -0
  43. package/dist/InventoryLogic.b90f66ea.js.map +1 -0
  44. package/dist/InventoryLogic.bb447b4c.js +39 -0
  45. package/dist/InventoryLogic.bb447b4c.js.map +1 -0
  46. package/dist/InventoryLogic.d27e84a7.js +75 -0
  47. package/dist/InventoryLogic.d27e84a7.js.map +1 -0
  48. package/dist/InventoryLogic.d69ad127.js +217 -0
  49. package/dist/InventoryLogic.d69ad127.js.map +1 -0
  50. package/dist/InventoryLogic.e03e6b07.js +245 -0
  51. package/dist/InventoryLogic.e03e6b07.js.map +1 -0
  52. package/dist/InventoryLogic.f276f76c.js +213 -0
  53. package/dist/InventoryLogic.f276f76c.js.map +1 -0
  54. package/dist/InventoryLogic.f4627c8a.js +160 -0
  55. package/dist/InventoryLogic.f4627c8a.js.map +1 -0
  56. package/dist/index.js +22 -1
  57. package/dist/index.js.map +1 -0
  58. package/index.js +1 -2
  59. package/package.json +9 -20
  60. package/dist/InventoryLogic.0b64d0ad.js +0 -2
  61. package/dist/InventoryLogic.0fde24a4.js +0 -2
  62. package/dist/InventoryLogic.1e519cb0.js +0 -2
  63. package/dist/InventoryLogic.20d9efd7.js +0 -2
  64. package/dist/InventoryLogic.2468e70a.js +0 -2
  65. package/dist/InventoryLogic.30338491.js +0 -2
  66. package/dist/InventoryLogic.30e7c3e7.js +0 -2
  67. package/dist/InventoryLogic.4a3c62d7.js +0 -2
  68. package/dist/InventoryLogic.4e7ced22.js +0 -9
  69. package/dist/InventoryLogic.62b5247c.js +0 -2
  70. package/dist/InventoryLogic.6479c130.js +0 -2
  71. package/dist/InventoryLogic.74baf986.js +0 -2
  72. package/dist/InventoryLogic.7852e007.js +0 -2
  73. package/dist/InventoryLogic.87addb57.js +0 -2
  74. package/dist/InventoryLogic.9658c8e7.js +0 -2
  75. package/dist/InventoryLogic.9a89425d.js +0 -2
  76. package/dist/InventoryLogic.b49f09b1.js +0 -2
  77. package/dist/InventoryLogic.e0dc6c34.js +0 -2
  78. package/dist/InventoryLogic.e295e814.js +0 -2
  79. package/dist/InventoryLogic.f716bebc.js +0 -2
  80. package/dist/InventoryLogic.f8d080e8.js +0 -2
@@ -0,0 +1,285 @@
1
+ import $lLeNo$dayjs from "dayjs";
2
+ import $lLeNo$dayjspluginisSameOrAfterjs from "dayjs/plugin/isSameOrAfter.js";
3
+ import $lLeNo$dayjspluginisSameOrBeforejs from "dayjs/plugin/isSameOrBefore.js";
4
+ import {writeBack as $lLeNo$writeBack, runTransaction as $lLeNo$runTransaction, fetchRecordByRefPath as $lLeNo$fetchRecordByRefPath, deleteRecordByRefPath as $lLeNo$deleteRecordByRefPath} from "@leaddreamer/firebase-wrapper";
5
+
6
+ /**
7
+ * Typedefs, constants, support functions and database operations for
8
+ * general Utilities
9
+ * @module Utilities
10
+ */
11
+
12
+
13
+
14
+ //the following inits the dayjs plugins
15
+ (0, $lLeNo$dayjs).extend((0, $lLeNo$dayjspluginisSameOrAfterjs));
16
+ (0, $lLeNo$dayjs).extend((0, $lLeNo$dayjspluginisSameOrBeforejs));
17
+ async function $9baf0c6b8de436d9$export$cc9d030424d53c6d(host, batch = null) {
18
+ return (0, $lLeNo$writeBack)(host, batch);
19
+ }
20
+ function $9baf0c6b8de436d9$export$f5d1cbac23428e02(object1, object2) {
21
+ let result = Object.keys(object1).reduce((accumulate, key)=>{
22
+ // eslint-disable-next-line
23
+ return object1[key] == object2[key] ? accumulate : false;
24
+ }, true); // note simple (not object) compare
25
+ return result;
26
+ }
27
+ function $9baf0c6b8de436d9$export$62f58f44692b37a8(thisObject, thisFormat) {
28
+ let final = thisFormat.replace(/{.+?}/g, function(field) {
29
+ let fieldRaw = field.slice(1, -1);
30
+ //below allows for DOT notation access within the item object
31
+ let fieldparts = fieldRaw.split(":");
32
+ let [fieldname, fieldStyle] = fieldparts;
33
+ let fieldArray = fieldname.split(".");
34
+ //below walks into an object - note: ASSUMES an object
35
+ const bob = fieldArray.reduce((lastObject, nextName)=>{
36
+ return lastObject[nextName];
37
+ }, thisObject);
38
+ return bob ? $9baf0c6b8de436d9$var$specialFormat(bob, fieldStyle) : "----";
39
+ });
40
+ return final;
41
+ }
42
+ /**
43
+ * @private
44
+ * @param {any} value
45
+ * @param {!string} style
46
+ * @returns {any|string}
47
+ */ function $9baf0c6b8de436d9$var$specialFormat(value, style) {
48
+ switch(style){
49
+ case "timestamp":
50
+ return (0, $lLeNo$dayjs)(value.toDate()).format("MMM DD, YYYY");
51
+ default:
52
+ return value;
53
+ }
54
+ }
55
+ function $9baf0c6b8de436d9$export$398604a469f7de9a(thisItem, anotherItem, sort = "Id:number") {
56
+ let [field, type] = sort.split(":");
57
+ type = type ? type : "number";
58
+ switch(type){
59
+ case "string":
60
+ let nameArray = thisItem[field].split("The ");
61
+ let anotherArray = anotherItem[field].split("The ");
62
+ return (nameArray[0] ? nameArray[0] : nameArray[1]).localeCompare(anotherArray[0] ? anotherArray[0] : anotherArray[1]);
63
+ case "date":
64
+ //if (!thisItem[field] || !anotherItem[field]) return 0;
65
+ return !thisItem[field] || (0, $lLeNo$dayjs)(thisItem[field]).isBefore(anotherItem[field], "day") ? -1 : anotherItem[field] && (0, $lLeNo$dayjs)(thisItem[field]).isSame(anotherItem[field], "day") ? 0 : 1;
66
+ default:
67
+ return Number(thisItem[field]) - Number(anotherItem[field]);
68
+ }
69
+ }
70
+ function $9baf0c6b8de436d9$export$3145210430358e7(findFrom, findIn) {
71
+ let mapFindIn = new Map();
72
+ findIn.forEach((entry, index)=>{
73
+ mapFindIn.set(entry, true);
74
+ }); //speed up by avoiding second loop
75
+ const findFromLength = findFrom.length;
76
+ let found = false;
77
+ for(let findFromIndex = 0; findFromIndex < findFromLength && !found; findFromIndex++)if (mapFindIn.get(findFrom[findFromIndex].valueOf())) found = true; //note this breaks both loops
78
+ return found;
79
+ }
80
+ function $9baf0c6b8de436d9$export$15b0b9b385c1f78e(...args) {
81
+ return Math.min(...args);
82
+ }
83
+ function $9baf0c6b8de436d9$export$e375dfe918aae343(...args) {
84
+ return Math.max(...args);
85
+ }
86
+ async function $9baf0c6b8de436d9$export$f7bac52274eacccb(record) {
87
+ //split the reference path into it's constituent parts
88
+ const parts = record.refPath.split("/");
89
+ const partsCount = parts.length;
90
+ if (Math.floor(partsCount / 2) * 2 !== partsCount) //throw "safe" error
91
+ return; //returns a null promise resolved
92
+ let archivePath = "";
93
+ let index = 0;
94
+ //adde a "_" to the start of every collection named in the path
95
+ //this avoids collectionGroup issues, but follows a parallel path
96
+ do {
97
+ archivePath = `${archivePath}/_${parts[index]}/${parts[index + 1]}`;
98
+ index += 2;
99
+ }while (index < partsCount);
100
+ await (0, $lLeNo$runTransaction)(async (batch)=>{
101
+ //////////////////////////////
102
+ //Read a current full copy of the record
103
+ const realRecord = await (0, $lLeNo$fetchRecordByRefPath)(record.refPath, batch);
104
+ //Write it to the "archivePath"
105
+ await (0, $lLeNo$writeBack)({
106
+ ...realRecord,
107
+ refPath: archivePath
108
+ }, batch);
109
+ //delete the original copy
110
+ await (0, $lLeNo$deleteRecordByRefPath)(realRecord.refPath, batch);
111
+ });
112
+ }
113
+ function $9baf0c6b8de436d9$export$b6b6e72408f809e2(refPath) {
114
+ return {
115
+ Id: refPath.split("/").pop(),
116
+ refPath: refPath
117
+ };
118
+ }
119
+ function $9baf0c6b8de436d9$export$adf7c0fe6059d774(value, lowerBound, upperBound) {
120
+ return $9baf0c6b8de436d9$export$e375dfe918aae343($9baf0c6b8de436d9$export$15b0b9b385c1f78e(value, upperBound), lowerBound);
121
+ }
122
+ function $9baf0c6b8de436d9$export$884089555def93f8(targetArray, newObject) {
123
+ targetArray ? targetArray.push(newObject) : targetArray = [
124
+ newObject
125
+ ];
126
+ return targetArray;
127
+ }
128
+ function $9baf0c6b8de436d9$export$7fecbbe7deb1a058(arrayObject, key, object) {
129
+ if (arrayObject[key] && arrayObject[key].length) //if the key is already present, *and* there are already objects in the keyed array
130
+ arrayObject[key].push(object); //push the object onto the indexed array
131
+ else arrayObject[key] = [
132
+ object
133
+ ];
134
+ }
135
+ function $9baf0c6b8de436d9$export$36538c15a30486a1(color) {
136
+ var colours = {
137
+ aliceblue: "#f0f8ff",
138
+ antiquewhite: "#faebd7",
139
+ aqua: "#00ffff",
140
+ aquamarine: "#7fffd4",
141
+ azure: "#f0ffff",
142
+ beige: "#f5f5dc",
143
+ bisque: "#ffe4c4",
144
+ black: "#000000",
145
+ blanchedalmond: "#ffebcd",
146
+ blue: "#0000ff",
147
+ blueviolet: "#8a2be2",
148
+ brown: "#a52a2a",
149
+ burlywood: "#deb887",
150
+ cadetblue: "#5f9ea0",
151
+ chartreuse: "#7fff00",
152
+ chocolate: "#d2691e",
153
+ coral: "#ff7f50",
154
+ cornflowerblue: "#6495ed",
155
+ cornsilk: "#fff8dc",
156
+ crimson: "#dc143c",
157
+ cyan: "#00ffff",
158
+ darkblue: "#00008b",
159
+ darkcyan: "#008b8b",
160
+ darkgoldenrod: "#b8860b",
161
+ darkgray: "#a9a9a9",
162
+ darkgreen: "#006400",
163
+ darkkhaki: "#bdb76b",
164
+ darkmagenta: "#8b008b",
165
+ darkolivegreen: "#556b2f",
166
+ darkorange: "#ff8c00",
167
+ darkorchid: "#9932cc",
168
+ darkred: "#8b0000",
169
+ darksalmon: "#e9967a",
170
+ darkseagreen: "#8fbc8f",
171
+ darkslateblue: "#483d8b",
172
+ darkslategray: "#2f4f4f",
173
+ darkturquoise: "#00ced1",
174
+ darkviolet: "#9400d3",
175
+ deeppink: "#ff1493",
176
+ deepskyblue: "#00bfff",
177
+ dimgray: "#696969",
178
+ dodgerblue: "#1e90ff",
179
+ firebrick: "#b22222",
180
+ floralwhite: "#fffaf0",
181
+ forestgreen: "#228b22",
182
+ fuchsia: "#ff00ff",
183
+ gainsboro: "#dcdcdc",
184
+ ghostwhite: "#f8f8ff",
185
+ gold: "#ffd700",
186
+ goldenrod: "#daa520",
187
+ gray: "#808080",
188
+ green: "#008000",
189
+ greenyellow: "#adff2f",
190
+ honeydew: "#f0fff0",
191
+ hotpink: "#ff69b4",
192
+ "indianred ": "#cd5c5c",
193
+ indigo: "#4b0082",
194
+ ivory: "#fffff0",
195
+ khaki: "#f0e68c",
196
+ lavender: "#e6e6fa",
197
+ lavenderblush: "#fff0f5",
198
+ lawngreen: "#7cfc00",
199
+ lemonchiffon: "#fffacd",
200
+ lightblue: "#add8e6",
201
+ lightcoral: "#f08080",
202
+ lightcyan: "#e0ffff",
203
+ lightgoldenrodyellow: "#fafad2",
204
+ lightgrey: "#d3d3d3",
205
+ lightgreen: "#90ee90",
206
+ lightpink: "#ffb6c1",
207
+ lightsalmon: "#ffa07a",
208
+ lightseagreen: "#20b2aa",
209
+ lightskyblue: "#87cefa",
210
+ lightslategray: "#778899",
211
+ lightsteelblue: "#b0c4de",
212
+ lightyellow: "#ffffe0",
213
+ lime: "#00ff00",
214
+ limegreen: "#32cd32",
215
+ linen: "#faf0e6",
216
+ magenta: "#ff00ff",
217
+ maroon: "#800000",
218
+ mediumaquamarine: "#66cdaa",
219
+ mediumblue: "#0000cd",
220
+ mediumorchid: "#ba55d3",
221
+ mediumpurple: "#9370d8",
222
+ mediumseagreen: "#3cb371",
223
+ mediumslateblue: "#7b68ee",
224
+ mediumspringgreen: "#00fa9a",
225
+ mediumturquoise: "#48d1cc",
226
+ mediumvioletred: "#c71585",
227
+ midnightblue: "#191970",
228
+ mintcream: "#f5fffa",
229
+ mistyrose: "#ffe4e1",
230
+ moccasin: "#ffe4b5",
231
+ navajowhite: "#ffdead",
232
+ navy: "#000080",
233
+ oldlace: "#fdf5e6",
234
+ olive: "#808000",
235
+ olivedrab: "#6b8e23",
236
+ orange: "#ffa500",
237
+ orangered: "#ff4500",
238
+ orchid: "#da70d6",
239
+ palegoldenrod: "#eee8aa",
240
+ palegreen: "#98fb98",
241
+ paleturquoise: "#afeeee",
242
+ palevioletred: "#d87093",
243
+ papayawhip: "#ffefd5",
244
+ peachpuff: "#ffdab9",
245
+ peru: "#cd853f",
246
+ pink: "#ffc0cb",
247
+ plum: "#dda0dd",
248
+ powderblue: "#b0e0e6",
249
+ purple: "#800080",
250
+ rebeccapurple: "#663399",
251
+ red: "#ff0000",
252
+ rosybrown: "#bc8f8f",
253
+ royalblue: "#4169e1",
254
+ saddlebrown: "#8b4513",
255
+ salmon: "#fa8072",
256
+ sandybrown: "#f4a460",
257
+ seagreen: "#2e8b57",
258
+ seashell: "#fff5ee",
259
+ sienna: "#a0522d",
260
+ silver: "#c0c0c0",
261
+ skyblue: "#87ceeb",
262
+ slateblue: "#6a5acd",
263
+ slategray: "#708090",
264
+ snow: "#fffafa",
265
+ springgreen: "#00ff7f",
266
+ steelblue: "#4682b4",
267
+ tan: "#d2b48c",
268
+ teal: "#008080",
269
+ thistle: "#d8bfd8",
270
+ tomato: "#ff6347",
271
+ turquoise: "#40e0d0",
272
+ violet: "#ee82ee",
273
+ wheat: "#f5deb3",
274
+ white: "#ffffff",
275
+ whitesmoke: "#f5f5f5",
276
+ yellow: "#ffff00",
277
+ yellowgreen: "#9acd32"
278
+ };
279
+ if (colours[color.toLowerCase()]) return colours[color.toLowerCase()];
280
+ return color;
281
+ }
282
+
283
+
284
+ export {$9baf0c6b8de436d9$export$cc9d030424d53c6d as saveHost, $9baf0c6b8de436d9$export$f5d1cbac23428e02 as simpleObjectCompare, $9baf0c6b8de436d9$export$62f58f44692b37a8 as formatItem, $9baf0c6b8de436d9$export$398604a469f7de9a as compare, $9baf0c6b8de436d9$export$3145210430358e7 as anyInAny, $9baf0c6b8de436d9$export$15b0b9b385c1f78e as lesserOf, $9baf0c6b8de436d9$export$e375dfe918aae343 as largerOf, $9baf0c6b8de436d9$export$f7bac52274eacccb as archiveRecord, $9baf0c6b8de436d9$export$b6b6e72408f809e2 as refPathToBaseRecord, $9baf0c6b8de436d9$export$adf7c0fe6059d774 as bound, $9baf0c6b8de436d9$export$884089555def93f8 as blindPush, $9baf0c6b8de436d9$export$7fecbbe7deb1a058 as addToArrayObject, $9baf0c6b8de436d9$export$36538c15a30486a1 as makeHexAsNeeded};
285
+ //# sourceMappingURL=InventoryLogic.35827495.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;AAAA;;;;CAIC;;;;AAWD,uCAAuC;AAEvC,CAAA,GAAA,YAAI,EAAE,MAAM,CAAC,CAAA,GAAA,iCAAY;AACzB,CAAA,GAAA,YAAI,EAAE,MAAM,CAAC,CAAA,GAAA,kCAAa;AAOnB,eAAe,0CAAS,IAAI,EAAE,QAAQ,IAAI;IAC/C,OAAO,CAAA,GAAA,gBAAQ,EAAE,MAAM;AACzB;AASO,SAAS,0CAAoB,OAAO,EAAE,OAAO;IAClD,IAAI,SAAS,OAAO,IAAI,CAAC,SAAS,MAAM,CAAC,CAAC,YAAY;QACpD,2BAA2B;QAC3B,OAAO,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,GAAG,aAAa;IACrD,GAAG,OAAO,mCAAmC;IAC7C,OAAO;AACT;AAUO,SAAS,0CAAW,UAAU,EAAE,UAAU;IAC/C,IAAI,QAAQ,WAAW,OAAO,CAC5B,UACA,SAAU,KAAK;QACb,IAAI,WAAW,MAAM,KAAK,CAAC,GAAG;QAC9B,6DAA6D;QAC7D,IAAI,aAAa,SAAS,KAAK,CAAC;QAChC,IAAI,CAAC,WAAW,WAAW,GAAG;QAC9B,IAAI,aAAa,UAAU,KAAK,CAAC;QACjC,sDAAsD;QACtD,MAAM,MAAM,WAAW,MAAM,CAAC,CAAC,YAAY;YACzC,OAAO,UAAU,CAAC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Y;QACZ,WAAW;QACX,aAAa;QACb,eAAe;QACf,cAAc;QACd,gBAAgB;QAChB,gBAAgB;QAChB,aAAa;QACb,MAAM;QACN,WAAW;QACX,OAAO;QACP,SAAS;QACT,QAAQ;QACR,kBAAkB;QAClB,YAAY;QACZ,cAAc;QACd,cAAc;QACd,gBAAgB;QAChB,iBAAiB;QACjB,mBAAmB;QACnB,iBAAiB;QACjB,iBAAiB;QACjB,cAAc;QACd,WAAW;QACX,WAAW;QACX,UAAU;QACV,aAAa;QACb,MAAM;QACN,SAAS;QACT,OAAO;QACP,WAAW;QACX,QAAQ;QACR,WAAW;QACX,QAAQ;QACR,eAAe;QACf,WAAW;QACX,eAAe;QACf,eAAe;QACf,YAAY;QACZ,WAAW;QACX,MAAM;QACN,MAAM;QACN,MAAM;QACN,YAAY;QACZ,QAAQ;QACR,eAAe;QACf,KAAK;QACL,WAAW;QACX,WAAW;QACX,aAAa;QACb,QAAQ;QACR,YAAY;QACZ,UAAU;QACV,UAAU;QACV,QAAQ;QACR,QAAQ;QACR,SAAS;QACT,WAAW;QACX,WAAW;QACX,MAAM;QACN,aAAa;QACb,WAAW;QACX,KAAK;QACL,MAAM;QACN,SAAS;QACT,QAAQ;QACR,WAAW;QACX,QAAQ;QACR,OAAO;QACP,OAAO;QACP,YAAY;QACZ,QAAQ;QACR,aAAa;IACf;IAEA,IAAI,OAAO,CAAC,MAAM,WAAW,GAAG,EAAE,OAAO,OAAO,CAAC,MAAM,WAAW,GAAG;IACrE,OAAO;AACT","sources":["business/Utilities/other.js"],"sourcesContent":["/**\n * Typedefs, constants, support functions and database operations for\n * general Utilities\n * @module Utilities\n */\nimport dayjs from \"dayjs\";\n//import promisePool from \"es6-promise-pool\";\nimport isSameOrAfter from \"dayjs/plugin/isSameOrAfter.js\";\nimport isSameOrBefore from \"dayjs/plugin/isSameOrBefore.js\";\nimport {\n fetchRecordByRefPath,\n runTransaction,\n writeBack,\n deleteRecordByRefPath,\n} from \"@leaddreamer/firebase-wrapper\";\n//the following inits the dayjs plugins\n\ndayjs.extend(isSameOrAfter);\ndayjs.extend(isSameOrBefore);\n\n/**\n * A convenience function for some shared artist/host front-end pages\n * @param {OrganizationType} host\n * @returns {Promise.OrganizationType}\n */\nexport async function saveHost(host, batch = null) {\n return writeBack(host, batch);\n}\n\n/**\n * Simple top-level object compare - assumes objects have similar structure - or\n * AT LEAST all the fields of object1 are present in object2\n * @param {object} object1\n * @param {object} object2\n * @returns {boolean}\n */\nexport function simpleObjectCompare(object1, object2) {\n let result = Object.keys(object1).reduce((accumulate, key) => {\n // eslint-disable-next-line\n return object1[key] == object2[key] ? accumulate : false;\n }, true); // note simple (not object) compare\n return result;\n}\n\n/**\n * Allows string substitution from an object\n * field names support Dot notation\n * field names allow \":\" extension for alternate formatting\n * @param {object} thisItem - object to create formated string from\n * @param {string} thisFormat - string describing formatted output - fieldname wrapped in {} will be substituted. DOT notation allowed for fields.\n * @returns {string}\n */\nexport function formatItem(thisObject, thisFormat) {\n let final = thisFormat.replace(\n /{.+?}/g, //global, non-greedy - i.e. multiple {} bracketed elements\n function (field) {\n let fieldRaw = field.slice(1, -1);\n //below allows for DOT notation access within the item object\n let fieldparts = fieldRaw.split(\":\");\n let [fieldname, fieldStyle] = fieldparts;\n let fieldArray = fieldname.split(\".\");\n //below walks into an object - note: ASSUMES an object\n const bob = fieldArray.reduce((lastObject, nextName) => {\n return lastObject[nextName];\n }, thisObject);\n return bob ? specialFormat(bob, fieldStyle) : \"----\";\n }\n );\n return final;\n}\n\n/**\n * @private\n * @param {any} value\n * @param {!string} style\n * @returns {any|string}\n */\nfunction specialFormat(value, style) {\n switch (style) {\n case \"timestamp\":\n return dayjs(value.toDate()).format(\"MMM DD, YYYY\");\n default:\n return value;\n }\n}\n\n/**\n * @param {object} thisItem - one of two objects being compared\n * @param {object} anotherItem - the other of two objects being compared\n * @param {!string} sort - string describing sort - format \"fieldName:sortType\" - sort Type is \"string, \"date\" or \"number\" (default)\n * @return {string}\n */\nexport function compare(thisItem, anotherItem, sort = \"Id:number\") {\n let [field, type] = sort.split(\":\");\n type = type ? type : \"number\";\n switch (type) {\n case \"string\":\n let nameArray = thisItem[field].split(\"The \");\n let anotherArray = anotherItem[field].split(\"The \");\n return (nameArray[0] ? nameArray[0] : nameArray[1]).localeCompare(\n anotherArray[0] ? anotherArray[0] : anotherArray[1]\n );\n\n case \"date\":\n //if (!thisItem[field] || !anotherItem[field]) return 0;\n return !thisItem[field] ||\n dayjs(thisItem[field]).isBefore(anotherItem[field], \"day\")\n ? -1\n : anotherItem[field] &&\n dayjs(thisItem[field]).isSame(anotherItem[field], \"day\")\n ? 0\n : 1;\n\n default:\n return Number(thisItem[field]) - Number(anotherItem[field]);\n }\n}\n\n/**\n * An array based compare function - is any entry of findFrom present in findIn\n * @param {Array.any} findFrom\n * @param {Array.any} findIn\n * @returns {boolean}\n */\nexport function anyInAny(findFrom, findIn) {\n let mapFindIn = new Map();\n\n findIn.forEach((entry, index) => {\n mapFindIn.set(entry, true);\n }); //speed up by avoiding second loop\n\n const findFromLength = findFrom.length;\n let found = false;\n for (\n let findFromIndex = 0;\n findFromIndex < findFromLength && !found;\n findFromIndex++\n )\n if (\n mapFindIn.get(findFrom[findFromIndex].valueOf())\n //findFrom[findFromIndex].valueOf() === findIn[arrayTwoIndex].valueOf()\n )\n found = true; //note this breaks both loops\n\n return found;\n}\n\n/**\n * A convenience function for legibility\n * @param {any} args unbounded list of arguments\n * @returns {number} the least of any of the arguments\nb */\nexport function lesserOf(...args) {\n return Math.min(...args);\n}\n\n/**\n * @param {any} args unbounded list of arguments\n * @returns {number} the largest of any of the arguments\n */\nexport function largerOf(...args) {\n return Math.max(...args);\n}\n\n/**\n * \"Moves\" a record from our standard tree structureto a parallel archival\n * structure, by prepending a \"_\" to the collection names in the path\n * This prevents the archived record from appearing in collectionGroup queries\n * @param {RecordDocument} record\n * @param {!string} record.refPath\n * @returns {Promise}\n */\nexport async function archiveRecord(record) {\n //split the reference path into it's constituent parts\n const parts = record.refPath.split(\"/\");\n const partsCount = parts.length;\n if (Math.floor(partsCount / 2) * 2 !== partsCount) {\n //throw \"safe\" error\n return; //returns a null promise resolved\n }\n\n let archivePath = \"\";\n let index = 0;\n //adde a \"_\" to the start of every collection named in the path\n //this avoids collectionGroup issues, but follows a parallel path\n do {\n archivePath = `${archivePath}/_${parts[index]}/${parts[index + 1]}`;\n index += 2;\n } while (index < partsCount);\n await runTransaction(async (batch) => {\n //////////////////////////////\n //Read a current full copy of the record\n const realRecord = await fetchRecordByRefPath(record.refPath, batch);\n //Write it to the \"archivePath\"\n await writeBack({ ...realRecord, refPath: archivePath }, batch);\n //delete the original copy\n await deleteRecordByRefPath(realRecord.refPath, batch);\n });\n}\n\n/**\n * uses a passed refPath to create the most basic document record form\n * @param {!string} refPath - \"/\" separated document path reference\n * @returns {RecordDocument}\n */\nexport function refPathToBaseRecord(refPath) {\n return {\n Id: refPath.split(\"/\").pop(),\n refPath: refPath,\n };\n}\n\n/**\n * clips value to given bounds\n * @param {number} value\n * @param {number} lowerBound\n * @param {number} upperBound\n * @returns {number}\n */\nexport function bound(value, lowerBound, upperBound) {\n return largerOf(lesserOf(value, upperBound), lowerBound);\n}\n\n/**\n * function to push an element to an array which may not be initialized\n * @param {Array.object} targetArray\n * @param {object} newObject\n * \n */\nexport function blindPush(targetArray, newObject) {\n targetArray\n ? targetArray.push(newObject)\n : (targetArray = [newObject]);\n return targetArray;\n}\n\n/**\n * @param {Array.Array.object} arrayObject\n * @param {string} key key or index to choose which Array.object to add *this* object to\n * @param {object} object\n */\nexport function addToArrayObject(arrayObject, key, object) {\n if (arrayObject[key] && arrayObject[key].length) {\n //if the key is already present, *and* there are already objects in the keyed array\n arrayObject[key].push(object); //push the object onto the indexed array\n } else {\n arrayObject[key] = [object];\n }\n}\n\n\n\n/**\n * @param {string} color name of color\n * @returns {string} hex value of named color\n */\nexport function makeHexAsNeeded(color) {\n var colours = {\n aliceblue: \"#f0f8ff\",\n antiquewhite: \"#faebd7\",\n aqua: \"#00ffff\",\n aquamarine: \"#7fffd4\",\n azure: \"#f0ffff\",\n beige: \"#f5f5dc\",\n bisque: \"#ffe4c4\",\n black: \"#000000\",\n blanchedalmond: \"#ffebcd\",\n blue: \"#0000ff\",\n blueviolet: \"#8a2be2\",\n brown: \"#a52a2a\",\n burlywood: \"#deb887\",\n cadetblue: \"#5f9ea0\",\n chartreuse: \"#7fff00\",\n chocolate: \"#d2691e\",\n coral: \"#ff7f50\",\n cornflowerblue: \"#6495ed\",\n cornsilk: \"#fff8dc\",\n crimson: \"#dc143c\",\n cyan: \"#00ffff\",\n darkblue: \"#00008b\",\n darkcyan: \"#008b8b\",\n darkgoldenrod: \"#b8860b\",\n darkgray: \"#a9a9a9\",\n darkgreen: \"#006400\",\n darkkhaki: \"#bdb76b\",\n darkmagenta: \"#8b008b\",\n darkolivegreen: \"#556b2f\",\n darkorange: \"#ff8c00\",\n darkorchid: \"#9932cc\",\n darkred: \"#8b0000\",\n darksalmon: \"#e9967a\",\n darkseagreen: \"#8fbc8f\",\n darkslateblue: \"#483d8b\",\n darkslategray: \"#2f4f4f\",\n darkturquoise: \"#00ced1\",\n darkviolet: \"#9400d3\",\n deeppink: \"#ff1493\",\n deepskyblue: \"#00bfff\",\n dimgray: \"#696969\",\n dodgerblue: \"#1e90ff\",\n firebrick: \"#b22222\",\n floralwhite: \"#fffaf0\",\n forestgreen: \"#228b22\",\n fuchsia: \"#ff00ff\",\n gainsboro: \"#dcdcdc\",\n ghostwhite: \"#f8f8ff\",\n gold: \"#ffd700\",\n goldenrod: \"#daa520\",\n gray: \"#808080\",\n green: \"#008000\",\n greenyellow: \"#adff2f\",\n honeydew: \"#f0fff0\",\n hotpink: \"#ff69b4\",\n \"indianred \": \"#cd5c5c\",\n indigo: \"#4b0082\",\n ivory: \"#fffff0\",\n khaki: \"#f0e68c\",\n lavender: \"#e6e6fa\",\n lavenderblush: \"#fff0f5\",\n lawngreen: \"#7cfc00\",\n lemonchiffon: \"#fffacd\",\n lightblue: \"#add8e6\",\n lightcoral: \"#f08080\",\n lightcyan: \"#e0ffff\",\n lightgoldenrodyellow: \"#fafad2\",\n lightgrey: \"#d3d3d3\",\n lightgreen: \"#90ee90\",\n lightpink: \"#ffb6c1\",\n lightsalmon: \"#ffa07a\",\n lightseagreen: \"#20b2aa\",\n lightskyblue: \"#87cefa\",\n lightslategray: \"#778899\",\n lightsteelblue: \"#b0c4de\",\n lightyellow: \"#ffffe0\",\n lime: \"#00ff00\",\n limegreen: \"#32cd32\",\n linen: \"#faf0e6\",\n magenta: \"#ff00ff\",\n maroon: \"#800000\",\n mediumaquamarine: \"#66cdaa\",\n mediumblue: \"#0000cd\",\n mediumorchid: \"#ba55d3\",\n mediumpurple: \"#9370d8\",\n mediumseagreen: \"#3cb371\",\n mediumslateblue: \"#7b68ee\",\n mediumspringgreen: \"#00fa9a\",\n mediumturquoise: \"#48d1cc\",\n mediumvioletred: \"#c71585\",\n midnightblue: \"#191970\",\n mintcream: \"#f5fffa\",\n mistyrose: \"#ffe4e1\",\n moccasin: \"#ffe4b5\",\n navajowhite: \"#ffdead\",\n navy: \"#000080\",\n oldlace: \"#fdf5e6\",\n olive: \"#808000\",\n olivedrab: \"#6b8e23\",\n orange: \"#ffa500\",\n orangered: \"#ff4500\",\n orchid: \"#da70d6\",\n palegoldenrod: \"#eee8aa\",\n palegreen: \"#98fb98\",\n paleturquoise: \"#afeeee\",\n palevioletred: \"#d87093\",\n papayawhip: \"#ffefd5\",\n peachpuff: \"#ffdab9\",\n peru: \"#cd853f\",\n pink: \"#ffc0cb\",\n plum: \"#dda0dd\",\n powderblue: \"#b0e0e6\",\n purple: \"#800080\",\n rebeccapurple: \"#663399\",\n red: \"#ff0000\",\n rosybrown: \"#bc8f8f\",\n royalblue: \"#4169e1\",\n saddlebrown: \"#8b4513\",\n salmon: \"#fa8072\",\n sandybrown: \"#f4a460\",\n seagreen: \"#2e8b57\",\n seashell: \"#fff5ee\",\n sienna: \"#a0522d\",\n silver: \"#c0c0c0\",\n skyblue: \"#87ceeb\",\n slateblue: \"#6a5acd\",\n slategray: \"#708090\",\n snow: \"#fffafa\",\n springgreen: \"#00ff7f\",\n steelblue: \"#4682b4\",\n tan: \"#d2b48c\",\n teal: \"#008080\",\n thistle: \"#d8bfd8\",\n tomato: \"#ff6347\",\n turquoise: \"#40e0d0\",\n violet: \"#ee82ee\",\n wheat: \"#f5deb3\",\n white: \"#ffffff\",\n whitesmoke: \"#f5f5f5\",\n yellow: \"#ffff00\",\n yellowgreen: \"#9acd32\",\n };\n\n if (colours[color.toLowerCase()]) return colours[color.toLowerCase()];\n return color;\n}\n"],"names":[],"version":3,"file":"InventoryLogic.35827495.js.map"}
@@ -0,0 +1,72 @@
1
+ import {ADDRESSES as $fefa9c41cb73ae0b$export$6890d3564b1f252d} from "./InventoryLogic.d27e84a7.js";
2
+ import {businessDataPath as $852adca6ae24886c$export$8c755753b01b12f} from "./InventoryLogic.57f24f5f.js";
3
+ import {deleteRecordByRefPath as $2ZLEA$deleteRecordByRefPath, deleteRecord as $2ZLEA$deleteRecord, writeBack as $2ZLEA$writeBack, writeRecord as $2ZLEA$writeRecord, collectRecords as $2ZLEA$collectRecords} from "@leaddreamer/firebase-wrapper";
4
+ import {Forms as $2ZLEA$Forms} from "@leaddreamer/staticforms";
5
+
6
+ /**
7
+ * Types and functins for handling addresses
8
+ * @module Addresses
9
+ *
10
+ */
11
+
12
+
13
+
14
+ const $5e875028eacae923$export$5b4eaa31e9936f4c = {
15
+ name: null,
16
+ tel: null,
17
+ address_line_1: null,
18
+ address_line_2: null,
19
+ city: null,
20
+ region: null,
21
+ state: null,
22
+ zip: null,
23
+ maplink: null
24
+ };
25
+ const $5e875028eacae923$export$20ca2f03d61fd4de = {
26
+ name: "text::6",
27
+ tel: "tel::6",
28
+ address_line_1: "text::6",
29
+ address_line_2: "text::6",
30
+ city: "text::6",
31
+ // region: "lookup:Regions:4",
32
+ state: "text::3",
33
+ zip: "number::3"
34
+ };
35
+ const $5e875028eacae923$export$688a09815a2d76e = {
36
+ address: `lookupLink:${(0, $fefa9c41cb73ae0b$export$6890d3564b1f252d)}`
37
+ };
38
+ const $5e875028eacae923$export$5003d738bf1e0422 = {
39
+ placeID: null,
40
+ latlng: {
41
+ lat: null,
42
+ lng: null
43
+ },
44
+ url: null,
45
+ formatted_address: null
46
+ };
47
+ (0, $2ZLEA$Forms).Base[0, $fefa9c41cb73ae0b$export$6890d3564b1f252d] = $5e875028eacae923$export$5b4eaa31e9936f4c;
48
+ (0, $2ZLEA$Forms).BaseForm[0, $fefa9c41cb73ae0b$export$6890d3564b1f252d] = $5e875028eacae923$export$20ca2f03d61fd4de;
49
+ (0, $2ZLEA$Forms).AccountForm[0, $fefa9c41cb73ae0b$export$6890d3564b1f252d] = $5e875028eacae923$export$20ca2f03d61fd4de;
50
+ async function $5e875028eacae923$export$6f33ffc8bc2e0c30(address) {
51
+ //check for real reacord (i.e. refPath)
52
+ if (!address?.refPath) return null;
53
+ return (0, $2ZLEA$deleteRecordByRefPath)(address.refPath);
54
+ }
55
+ async function $5e875028eacae923$export$2873378411ec704(addressId, parent, batch = null) {
56
+ //check for real reacord (i.e. refPath)
57
+ return (0, $2ZLEA$deleteRecord)((0, $fefa9c41cb73ae0b$export$6890d3564b1f252d), addressId, parent?.refPath, batch);
58
+ }
59
+ function $5e875028eacae923$export$9ab766ce7f4c1f3c(address) {
60
+ let formattedString = address ? (address.address_line_1 ? address.address_line_1 + ", " : "") + (address.address_line_2 ? address.address_line_2 + ", " : "") + (address.city ? address.city + ", " : "") + (address.state ? address.state + " " : "") + (address.zip ? address.zip : "") + (address.region ? " ( " + address.region + " )" : "") : null;
61
+ return formattedString;
62
+ }
63
+ async function $5e875028eacae923$export$f4e55b204eefc919(address, parentRefPath) {
64
+ return address?.refPath ? (0, $2ZLEA$writeBack)(address) : (0, $2ZLEA$writeRecord)((0, $fefa9c41cb73ae0b$export$6890d3564b1f252d), address, parentRefPath);
65
+ }
66
+ async function $5e875028eacae923$export$c9b8cb1768a98d34(account) {
67
+ return (0, $2ZLEA$collectRecords)((0, $fefa9c41cb73ae0b$export$6890d3564b1f252d), (0, $852adca6ae24886c$export$8c755753b01b12f)(account));
68
+ }
69
+
70
+
71
+ export {$5e875028eacae923$export$5b4eaa31e9936f4c as AddressDefault, $5e875028eacae923$export$20ca2f03d61fd4de as AddressForm, $5e875028eacae923$export$688a09815a2d76e as AddressSelectForm, $5e875028eacae923$export$5003d738bf1e0422 as maplink, $5e875028eacae923$export$6f33ffc8bc2e0c30 as deleteAddress, $5e875028eacae923$export$2873378411ec704 as deleteAddressByIdAndParent, $5e875028eacae923$export$9ab766ce7f4c1f3c as formatAddress, $5e875028eacae923$export$f4e55b204eefc919 as saveAddress, $5e875028eacae923$export$c9b8cb1768a98d34 as fetchAddresses};
72
+ //# sourceMappingURL=InventoryLogic.37dfff3e.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;AAAA;;;;CAIC;;;;AAkCM,MAAM,4CAAiB;IAC5B,MAAM;IACN,KAAK;IACL,gBAAgB;IAChB,gBAAgB;IAChB,MAAM;IACN,QAAQ;IACR,OAAO;IACP,KAAK;IACL,SAAS;AACX;AAOO,MAAM,4CAAc;IACzB,MAAM;IACN,KAAK;IACL,gBAAgB;IAChB,gBAAgB;IAChB,MAAM;IACN,+BAA+B;IAC/B,OAAO;IACP,KAAK;AACP;AAEO,MAAM,2CAAoB;IAC/B,SAAS,CAAC,WAAW,EAAE,CAAA,GAAA,yCAAQ,GAAG;AACpC;AAiBO,MAAM,4CAAU;IACrB,SAAS;IACT,QAAQ;QACN,KAAK;QACL,KAAK;IACP;IACA,KAAK;IACL,mBAAmB;AACrB;AAEA,CAAA,GAAA,YAAI,EAAE,IAAI,CAAC,GAAA,0CAAU,GAAG;AACxB,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,GAAA,0CAAU,GAAG;AAC5B,CAAA,GAAA,YAAI,EAAE,WAAW,CAAC,GAAA,0CAAU,GAAG;AAiBxB,eAAe,0CAAc,OAAO;IACzC,uCAAuC;IACvC,IAAI,CAAC,SAAS,SAAS,OAAO;IAC9B,OAAO,CAAA,GAAA,4BAAoB,EAAE,QAAQ,OAAO;AAC9C;AAWO,eAAe,yCACpB,SAAS,EACT,MAAM,EACN,QAAQ,IAAI;IAEZ,uCAAuC;IACvC,OAAO,CAAA,GAAA,mBAAW,EAAE,CAAA,GAAA,yCAAQ,GAAG,WAAW,QAAQ,SAAS;AAC7D;AAUO,SAAS,0CAAc,OAAO;IACnC,IAAI,kBAAkB,UAClB,AAAC,CAAA,QAAQ,cAAc,GAAG,QAAQ,cAAc,GAAG,OAAO,EAAC,IAC1D,CAAA,QAAQ,cAAc,GAAG,QAAQ,cAAc,GAAG,OAAO,EAAC,IAC1D,CAAA,QAAQ,IAAI,GAAG,QAAQ,IAAI,GAAG,OAAO,EAAC,IACtC,CAAA,QAAQ,KAAK,GAAG,QAAQ,KAAK,GAAG,OAAO,EAAC,IACxC,CAAA,QAAQ,GAAG,GAAG,QAAQ,GAAG,GAAG,EAAC,IAC7B,CAAA,QAAQ,MAAM,GAAG,QAAQ,QAAQ,MAAM,GAAG,OAAO,EAAC,IACnD;IACJ,OAAO;AACT;AAUO,eAAe,0CAAY,OAAO,EAAE,aAAa;IACtD,OAAO,SAAS,UACZ,CAAA,GAAA,gBAAQ,EAAE,WACV,CAAA,GAAA,kBAAU,EAAE,CAAA,GAAA,yCAAQ,GAAG,SAAS;AACtC;AAQO,eAAe,0CAAe,OAAO;IAC1C,OAAO,CAAA,GAAA,qBAAa,EAAE,CAAA,GAAA,yCAAQ,GAAG,CAAA,GAAA,wCAAe,EAAE;AACpD","sources":["business/Addresses/index.js"],"sourcesContent":["/**\n * Types and functins for handling addresses\n * @module Addresses\n *\n */\n\nimport {\n writeRecord,\n writeBack,\n deleteRecord,\n deleteRecordByRefPath,\n collectRecords,\n} from \"@leaddreamer/firebase-wrapper\";\nimport { Forms } from \"@leaddreamer/staticforms\";\nimport { ADDRESSES } from \"../boilerplate/index.js\";\nimport { businessDataPath } from \"../BusinessData/index.js\";\n\n//////////////////////////////////////////////////////////////////////\n//Constants\n/**\n * @typedef {object} AddressType\n * @property {?string} Id - will be populated for existing record; null or\n * missing for new/minimal object\n * @property {?string} refPath - will be populated for existing record; null or\n * missing for new/minimal object\n * @property {string} address_line_1\n * @property {?string} address_line_2\n * @property {string} city\n * @property {string} region - selected from a list of supported Cities/Regions\n * @property {string} state\n * @property {zip} zip\n * @property {?maplink} mapLink - link to Google map location\n */\n/**\n * @constant\n * @type {AddressType}\n * @default\n */\nexport const AddressDefault = {\n name: null,\n tel: null,\n address_line_1: null,\n address_line_2: null,\n city: null,\n region: null,\n state: null,\n zip: null,\n maplink: null,\n};\n\n/**\n * @constant\n * @type {AddressType}\n * @default\n */\nexport const AddressForm = {\n name: \"text::6\",\n tel: \"tel::6\",\n address_line_1: \"text::6\",\n address_line_2: \"text::6\",\n city: \"text::6\",\n // region: \"lookup:Regions:4\",\n state: \"text::3\",\n zip: \"number::3\",\n};\n\nexport const AddressSelectForm = {\n address: `lookupLink:${ADDRESSES}`,\n};\n\n/**\n * @typedef {object} MapLink\n * @property {?string} placeId - as defined by Google\n * @property {?object} latlng - coordinates tuple\n * @property {string} latlng.lat - lattitude\n * @property {string} latlng.lng - longitude\n * @property {?string} url - link to place/map entry\n * @property {?string} formatted_address - printable string of address\n */\n/**\n * @readonly\n * @constant\n * @type {MapLink}\n * @default\n */\nexport const maplink = {\n placeID: null,\n latlng: {\n lat: null,\n lng: null,\n },\n url: null,\n formatted_address: null,\n};\n\nForms.Base[ADDRESSES] = AddressDefault;\nForms.BaseForm[ADDRESSES] = AddressForm;\nForms.AccountForm[ADDRESSES] = AddressForm;\n\n/**\n * @external WriteBatch\n * @external Transaction\n * @typedef {WriteBatch|Transaction|void} ChainType\n */\n\n//////////////////////////////////////////////////////////////////////\n//Business Logic\n\n/**\n * Deletes an existing address record from the database, based on it's own refPath\n * @param {AddressType} address\n * @param {!string} address.refPath\n * @returns {Promise<void>}\n */\nexport async function deleteAddress(address) {\n //check for real reacord (i.e. refPath)\n if (!address?.refPath) return null;\n return deleteRecordByRefPath(address.refPath);\n}\n\n/**\n * Deletes an existing address record from the database, based on it's parent\n * record and Id\n * @param {!string} addressId\n * @param {OrganizationType} parent\n * @param {!string} parent.refPath\n * @param {ChainType} batch\n * @returns {Promise.ChainType}\n */\nexport async function deleteAddressByIdAndParent(\n addressId,\n parent,\n batch = null\n) {\n //check for real reacord (i.e. refPath)\n return deleteRecord(ADDRESSES, addressId, parent?.refPath, batch);\n}\n\n//////////////////////////////////////////////////////////////////////\n//helpers\n\n/**\n * Builds a formatted string from a provided address record\n * @param {AddressType} address\n * @returns {string}\n */\nexport function formatAddress(address) {\n let formattedString = address\n ? (address.address_line_1 ? address.address_line_1 + \", \" : \"\") +\n (address.address_line_2 ? address.address_line_2 + \", \" : \"\") +\n (address.city ? address.city + \", \" : \"\") +\n (address.state ? address.state + \" \" : \"\") +\n (address.zip ? address.zip : \"\") +\n (address.region ? \" ( \" + address.region + \" )\" : \"\")\n : null;\n return formattedString;\n}\n\n/**\n * Saves an address record to the database below the provided parentRefPath,\n * whether exsiting or not\n * @param {AddressType} address\n * @param {?string} address.refPath - if present, writes back\n * @param {string} paraentRefPath - required if new record\n * @returns {Promise<AddressType>}\n */\nexport async function saveAddress(address, parentRefPath) {\n return address?.refPath\n ? writeBack(address)\n : writeRecord(ADDRESSES, address, parentRefPath);\n}\n\n/**\n * Fetches all address records for an account\n * @param {Record} account\n * @param {!string} account.refPath\n * @returns {Promise<Array.AddressType>}\n */\nexport async function fetchAddresses(account) {\n return collectRecords(ADDRESSES, businessDataPath(account));\n}\n"],"names":[],"version":3,"file":"InventoryLogic.37dfff3e.js.map"}
@@ -0,0 +1,213 @@
1
+ import {USER as $fefa9c41cb73ae0b$export$ff09b90989b21a8, USERS as $fefa9c41cb73ae0b$export$5a898dd3a28f57e9} from "./InventoryLogic.d27e84a7.js";
2
+ import {typedRecordFromChild as $9ab66828811feaa2$export$9536a88c96a1be48} from "./InventoryLogic.78480e5e.js";
3
+ import $5Osbf$lodashclonedeep from "lodash.clonedeep";
4
+ import {deleteRecord as $5Osbf$deleteRecord, writeRecord as $5Osbf$writeRecord, writeBack as $5Osbf$writeBack, collectRecords as $5Osbf$collectRecords, PaginateFetch as $5Osbf$PaginateFetch, documentId as $5Osbf$documentId, fetchRecord as $5Osbf$fetchRecord, collectRecordsByFilter as $5Osbf$collectRecordsByFilter, typedFetchFromChild as $5Osbf$typedFetchFromChild} from "@leaddreamer/firebase-wrapper";
5
+ import {Forms as $5Osbf$Forms} from "@leaddreamer/staticforms";
6
+
7
+ /**
8
+ * Typedefs, constants, support functions and database operations related to individual
9
+ * users
10
+ * @module User
11
+ */
12
+
13
+
14
+
15
+
16
+ //////////////////////////////////////////////////////////////////////
17
+ // Constants
18
+ /**
19
+ * @typedef {object} UserObject
20
+ * @property {?string} Id Id of document from storage
21
+ * @property {?string} refPath if from database, full path to document
22
+ * @property {!string} first_name could be "Anonymous"
23
+ * @property {?string} last_name
24
+ * @property {boolean} isAnonymous flag indicating auto-generated Anonymous user account
25
+ * @property {url} image URL (possibly in app storage) of User image
26
+ * @property {string} region User home region, from fixed list
27
+ * @property {?url} [social_links] array of user social account links
28
+ * @property {?string} bio user-maintained biography
29
+ * @property {?url} website URL to user user website
30
+ * @property {?string} payment_method summary string of user payment
31
+ * method. Not secure, not source-of-truth
32
+ * @property {?PaymentData} payment when "full account"
33
+ */ /**
34
+ * @readonly
35
+ * @constant
36
+ * @type {UserObject}
37
+ * @default
38
+ */ const $aeb56590b68e5483$var$UserDefault = {
39
+ Id: null,
40
+ refPath: null,
41
+ name: null,
42
+ email: null,
43
+ tel: null,
44
+ isAnonymous: true,
45
+ payment_method: null,
46
+ admin_status: null
47
+ };
48
+ /**
49
+ * @readonly
50
+ * @constant
51
+ * @type {UserObject}
52
+ * @default
53
+ */ const $aeb56590b68e5483$var$UserData = {
54
+ Id: `string.uuid`,
55
+ refPath: null,
56
+ name: `person.fullName`,
57
+ email: `internet.email`,
58
+ tel: `phone.number`,
59
+ isAnonymous: `datatype.boolean`,
60
+ payment_method: null,
61
+ admin_status: null
62
+ };
63
+ /**
64
+ * @readonly
65
+ * @constant
66
+ * @type {UserObject}
67
+ * @default
68
+ */ const $aeb56590b68e5483$var$UserDefaultForm = {
69
+ name: "text",
70
+ email: "email",
71
+ tel: "tel"
72
+ };
73
+ (0, $5Osbf$Forms).Base[0, $fefa9c41cb73ae0b$export$ff09b90989b21a8] = $aeb56590b68e5483$var$UserDefault;
74
+ (0, $5Osbf$Forms).BaseForm[0, $fefa9c41cb73ae0b$export$ff09b90989b21a8] = $aeb56590b68e5483$var$UserDefaultForm;
75
+ (0, $5Osbf$Forms).AccountForm[0, $fefa9c41cb73ae0b$export$ff09b90989b21a8] = $aeb56590b68e5483$var$UserDefaultForm;
76
+ (0, $5Osbf$Forms).Data[0, $fefa9c41cb73ae0b$export$ff09b90989b21a8] = $aeb56590b68e5483$var$UserData;
77
+ (0, $5Osbf$Forms).Summarize[0, $fefa9c41cb73ae0b$export$ff09b90989b21a8] = $aeb56590b68e5483$export$7822bd6f88cc1494;
78
+ (0, $5Osbf$Forms).SearchBy[0, $fefa9c41cb73ae0b$export$ff09b90989b21a8] = "name";
79
+ async function $aeb56590b68e5483$export$7d0f10f273c0438a(user) {
80
+ return (0, $5Osbf$deleteRecord)(user, (0, $fefa9c41cb73ae0b$export$ff09b90989b21a8));
81
+ }
82
+ async function $aeb56590b68e5483$export$1eb857e02349d4c8(user) {
83
+ if (!user?.Id) return Promise.reject;
84
+ return (0, $5Osbf$deleteRecord)(user, (0, $fefa9c41cb73ae0b$export$ff09b90989b21a8));
85
+ }
86
+ const $aeb56590b68e5483$export$3493b8991d49f558 = (user)=>{
87
+ //need a "no duplicate" function - whatever that means in this context
88
+ return (0, $5Osbf$writeRecord)((0, $fefa9c41cb73ae0b$export$ff09b90989b21a8), user);
89
+ };
90
+ async function $aeb56590b68e5483$export$2cccdc7105e5f652(user) {
91
+ let newUser = (0, $5Osbf$lodashclonedeep)((0, $5Osbf$Forms).Base[0, $fefa9c41cb73ae0b$export$5a898dd3a28f57e9]);
92
+ if (user.isAnonymous) //signin anonymous worked
93
+ newUser = {
94
+ ...newUser,
95
+ Id: user.uid,
96
+ isAnonymous: true,
97
+ name: "Anonymous"
98
+ };
99
+ else newUser = {
100
+ ...newUser,
101
+ Id: user.uid,
102
+ isAnonymous: false,
103
+ name: user?.displayName,
104
+ email: user?.email,
105
+ tel: user?.phoneNumber
106
+ };
107
+ return $aeb56590b68e5483$export$3493b8991d49f558(newUser);
108
+ }
109
+ async function $aeb56590b68e5483$export$3c10411f5368919b(user) {
110
+ // will update just the fields provided
111
+ return (0, $5Osbf$writeBack)({
112
+ ...user,
113
+ refPath: `/${(0, $fefa9c41cb73ae0b$export$ff09b90989b21a8)}/${user.Id}`
114
+ });
115
+ }
116
+ async function $aeb56590b68e5483$export$e3ac7a5d19605772(user) {
117
+ return (0, $5Osbf$writeBack)({
118
+ ...user,
119
+ refPath: user?.refPath || `/${0, $fefa9c41cb73ae0b$export$ff09b90989b21a8}/${user.Id}`
120
+ });
121
+ }
122
+ async function $aeb56590b68e5483$export$e1980ceaf83ba89(Id) {
123
+ let exists = true;
124
+ try {
125
+ await $aeb56590b68e5483$export$6cf10d295bf9320e(Id);
126
+ } catch (err) {
127
+ exists = false;
128
+ }
129
+ return exists;
130
+ }
131
+ async function $aeb56590b68e5483$export$2bb8333a9210be15() {
132
+ return (0, $5Osbf$collectRecords)((0, $fefa9c41cb73ae0b$export$ff09b90989b21a8));
133
+ }
134
+ async function $aeb56590b68e5483$export$db873fddb7c8685b(pageSize) {
135
+ return new (0, $5Osbf$PaginateFetch)((0, $fefa9c41cb73ae0b$export$ff09b90989b21a8), null, [
136
+ {
137
+ fieldRef: "first_name",
138
+ dirStr: "asc"
139
+ }
140
+ ], null, pageSize);
141
+ }
142
+ async function $aeb56590b68e5483$export$8cc74b74b196db4a(pageSize) {
143
+ return new (0, $5Osbf$PaginateFetch)((0, $fefa9c41cb73ae0b$export$ff09b90989b21a8), [
144
+ {
145
+ fieldRef: "first_name",
146
+ opStr: "==",
147
+ value: "Anonymous"
148
+ }
149
+ ], [
150
+ {
151
+ fieldRef: (0, $5Osbf$documentId),
152
+ dirStr: "asc"
153
+ }
154
+ ], null, pageSize);
155
+ }
156
+ async function $aeb56590b68e5483$export$6cf10d295bf9320e(userId) {
157
+ return (0, $5Osbf$fetchRecord)((0, $fefa9c41cb73ae0b$export$ff09b90989b21a8), userId);
158
+ }
159
+ async function $aeb56590b68e5483$export$32d6fa31f0d8a28(userId) {
160
+ const user = await $aeb56590b68e5483$export$6cf10d295bf9320e(userId);
161
+ return $aeb56590b68e5483$export$7822bd6f88cc1494(user);
162
+ }
163
+ async function $aeb56590b68e5483$export$53755dbf7eaa9f86(userId) {
164
+ const user = await $aeb56590b68e5483$export$6cf10d295bf9320e($aeb56590b68e5483$export$e1ca85ff667d230a(userId));
165
+ return user.email;
166
+ }
167
+ async function $aeb56590b68e5483$export$85df9b940b8f75fd(userID) {
168
+ const account = $aeb56590b68e5483$export$e1ca85ff667d230a(userID);
169
+ return fetchPayment(account);
170
+ }
171
+ async function $aeb56590b68e5483$export$747404941cf39e5f(email) {
172
+ let them = await (0, $5Osbf$collectRecordsByFilter)((0, $fefa9c41cb73ae0b$export$ff09b90989b21a8), [
173
+ {
174
+ fieldRef: "email",
175
+ opStr: "==",
176
+ value: email
177
+ }
178
+ ], null, null);
179
+ //Not at all efficient, but rarely called. If this ends up used for any bulk searches
180
+ //de-normalize the database instead.
181
+ return them;
182
+ }
183
+ async function $aeb56590b68e5483$export$3f848cf621800fba(userIdentifier) {
184
+ let user, payment;
185
+ const userId = userIdentifier.Id ? userIdentifier.Id : userIdentifier;
186
+ user = await $aeb56590b68e5483$export$6cf10d295bf9320e(userId);
187
+ try {
188
+ payment = await fetchPayment(user);
189
+ } catch (err) {
190
+ payment = null; //Just a flag - not really a failure as such
191
+ }
192
+ user.payment = payment;
193
+ return user;
194
+ }
195
+ function $aeb56590b68e5483$export$7822bd6f88cc1494(user) {
196
+ return `${user?.name}`;
197
+ }
198
+ async function $aeb56590b68e5483$export$127de379ac0a4e64(child) {
199
+ return (0, $5Osbf$typedFetchFromChild)(child, (0, $fefa9c41cb73ae0b$export$ff09b90989b21a8));
200
+ }
201
+ function $aeb56590b68e5483$export$e1ca85ff667d230a(userId) {
202
+ return {
203
+ Id: userId,
204
+ refPath: `/${0, $fefa9c41cb73ae0b$export$ff09b90989b21a8}/${userId}`
205
+ };
206
+ }
207
+ function $aeb56590b68e5483$export$a081e2667846200b(child) {
208
+ return (0, $9ab66828811feaa2$export$9536a88c96a1be48)(child, (0, $fefa9c41cb73ae0b$export$ff09b90989b21a8));
209
+ }
210
+
211
+
212
+ export {$aeb56590b68e5483$export$7822bd6f88cc1494 as summarizeUser, $aeb56590b68e5483$export$7d0f10f273c0438a as deleteUser, $aeb56590b68e5483$export$1eb857e02349d4c8 as deleteUserById, $aeb56590b68e5483$export$3493b8991d49f558 as createUser, $aeb56590b68e5483$export$2cccdc7105e5f652 as buildUserRecords, $aeb56590b68e5483$export$3c10411f5368919b as updateUserByID, $aeb56590b68e5483$export$e3ac7a5d19605772 as updateUser, $aeb56590b68e5483$export$e1980ceaf83ba89 as knownUser, $aeb56590b68e5483$export$6cf10d295bf9320e as fetchUser, $aeb56590b68e5483$export$2bb8333a9210be15 as fetchUsers, $aeb56590b68e5483$export$db873fddb7c8685b as fetchUsersPaginated, $aeb56590b68e5483$export$8cc74b74b196db4a as fetchAnonymousPaginated, $aeb56590b68e5483$export$32d6fa31f0d8a28 as fetchUserName, $aeb56590b68e5483$export$53755dbf7eaa9f86 as fetchUserEmail, $aeb56590b68e5483$export$e1ca85ff667d230a as userFromId, $aeb56590b68e5483$export$85df9b940b8f75fd as fetchUserPaymentById, $aeb56590b68e5483$export$747404941cf39e5f as fetchUserByEmail, $aeb56590b68e5483$export$3f848cf621800fba as fetchFullUser, $aeb56590b68e5483$export$127de379ac0a4e64 as fetchUserFromChild, $aeb56590b68e5483$export$a081e2667846200b as makeUserFromChild};
213
+ //# sourceMappingURL=InventoryLogic.4206cb15.js.map