@leaddreamer/inventorylogic 0.0.3-beta.81 → 0.0.3-beta.83

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 (60) hide show
  1. package/README.md +0 -648
  2. package/business/Product/GoogleMerchantAPI.js +0 -2
  3. package/business/Utilities/index.js +0 -3
  4. package/package.json +5 -16
  5. package/business/Utilities/other.js +0 -404
  6. package/business/Utilities/promise-queue/index.js +0 -264
  7. package/business/Utilities/promise-queue/new.js +0 -231
  8. package/business/Utilities/rate-limited-queue/index.js +0 -127
  9. package/dist/InventoryLogic.0ac93278.js +0 -35
  10. package/dist/InventoryLogic.0ac93278.js.map +0 -1
  11. package/dist/InventoryLogic.31f6d549.js +0 -152
  12. package/dist/InventoryLogic.31f6d549.js.map +0 -1
  13. package/dist/InventoryLogic.35827495.js +0 -285
  14. package/dist/InventoryLogic.35827495.js.map +0 -1
  15. package/dist/InventoryLogic.37dfff3e.js +0 -72
  16. package/dist/InventoryLogic.37dfff3e.js.map +0 -1
  17. package/dist/InventoryLogic.4206cb15.js +0 -213
  18. package/dist/InventoryLogic.4206cb15.js.map +0 -1
  19. package/dist/InventoryLogic.44193a77.js +0 -35
  20. package/dist/InventoryLogic.44193a77.js.map +0 -1
  21. package/dist/InventoryLogic.46ca6768.js +0 -131
  22. package/dist/InventoryLogic.46ca6768.js.map +0 -1
  23. package/dist/InventoryLogic.4d012935.js +0 -151
  24. package/dist/InventoryLogic.4d012935.js.map +0 -1
  25. package/dist/InventoryLogic.57f24f5f.js +0 -155
  26. package/dist/InventoryLogic.57f24f5f.js.map +0 -1
  27. package/dist/InventoryLogic.59be76a4.js +0 -184
  28. package/dist/InventoryLogic.59be76a4.js.map +0 -1
  29. package/dist/InventoryLogic.70925a32.js +0 -375
  30. package/dist/InventoryLogic.70925a32.js.map +0 -1
  31. package/dist/InventoryLogic.72fcf301.js +0 -6
  32. package/dist/InventoryLogic.72fcf301.js.map +0 -1
  33. package/dist/InventoryLogic.7741caec.js +0 -375
  34. package/dist/InventoryLogic.7741caec.js.map +0 -1
  35. package/dist/InventoryLogic.78480e5e.js +0 -152
  36. package/dist/InventoryLogic.78480e5e.js.map +0 -1
  37. package/dist/InventoryLogic.80d0e568.js +0 -135
  38. package/dist/InventoryLogic.80d0e568.js.map +0 -1
  39. package/dist/InventoryLogic.8a273d2e.js +0 -110
  40. package/dist/InventoryLogic.8a273d2e.js.map +0 -1
  41. package/dist/InventoryLogic.8addb055.js +0 -202
  42. package/dist/InventoryLogic.8addb055.js.map +0 -1
  43. package/dist/InventoryLogic.9dee46ea.js +0 -6
  44. package/dist/InventoryLogic.9dee46ea.js.map +0 -1
  45. package/dist/InventoryLogic.b90f66ea.js +0 -124
  46. package/dist/InventoryLogic.b90f66ea.js.map +0 -1
  47. package/dist/InventoryLogic.bb447b4c.js +0 -39
  48. package/dist/InventoryLogic.bb447b4c.js.map +0 -1
  49. package/dist/InventoryLogic.d27e84a7.js +0 -75
  50. package/dist/InventoryLogic.d27e84a7.js.map +0 -1
  51. package/dist/InventoryLogic.d69ad127.js +0 -217
  52. package/dist/InventoryLogic.d69ad127.js.map +0 -1
  53. package/dist/InventoryLogic.e03e6b07.js +0 -245
  54. package/dist/InventoryLogic.e03e6b07.js.map +0 -1
  55. package/dist/InventoryLogic.f276f76c.js +0 -213
  56. package/dist/InventoryLogic.f276f76c.js.map +0 -1
  57. package/dist/InventoryLogic.f4627c8a.js +0 -160
  58. package/dist/InventoryLogic.f4627c8a.js.map +0 -1
  59. package/dist/index.js +0 -23
  60. package/dist/index.js.map +0 -1
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": ">=22"
5
5
  },
6
- "version": "0.0.3-beta.81",
6
+ "version": "0.0.3-beta.83",
7
7
  "description": "Business & Database Logic for Inventory Services",
8
8
  "repository": {
9
9
  "type": "git",
@@ -26,19 +26,14 @@
26
26
  "*.md",
27
27
  "**/*.md",
28
28
  "*.json",
29
- "**/*.json",
30
- "./dist/*.*",
31
- "./dist/**/*.*"
29
+ "**/*.json"
32
30
  ],
33
31
  "source": "index.js",
34
- "browser": "dist/index.js",
35
32
  "main": "index.js",
36
33
  "type": "module",
37
34
  "scripts": {
38
35
  "reinstall": "rm -rf node_modules && rm -rf dist && npm install",
39
- "mybuild": "parcel build --dist-dir './dist'",
40
36
  "release:rebuild": "$npm_execpath version minor --git-tag-version && $npm_execpath run docs",
41
- "myprepublishOnly": "$npm_execpath run build",
42
37
  "make_docs": "jsdoc2md -c jsdoc.conf.json --template README.hbs --files *.js ./business/*.js ./business/*/*.js > README.md",
43
38
  "docs": "$npm_execpath run make_docs",
44
39
  "beta:rebuild": "$npm_execpath version prerelease --git-tag-version --preid=beta && $npm_execpath run docs",
@@ -52,12 +47,9 @@
52
47
  },
53
48
  "dependencies": {
54
49
  "@leaddreamer/firebase-wrapper": "^2.1.2-beta.0",
55
- "@leaddreamer/genericutilities": "^0.2.7",
50
+ "@leaddreamer/genericutilities": "^0.2.8",
56
51
  "@leaddreamer/staticforms": "^1.1.0",
57
- "lodash.clonedeep": "4.5.0",
58
- "dayjs": "1.11.23",
59
- "mathjs": "15.2.0",
60
- "uuid": "14.0.1"
52
+ "lodash.clonedeep": "4.5.0"
61
53
  },
62
54
  "peerDependencies": {
63
55
  "firebase": "12.16.0",
@@ -72,10 +64,7 @@
72
64
  }
73
65
  },
74
66
  "devDependencies": {
75
- "accounting-js": "2.0.3",
76
- "jsdoc-to-markdown": "9.1.3",
77
- "@parcel/bundler-library": "^2.16.4",
78
- "parcel": "latest"
67
+ "jsdoc-to-markdown": "9.1.3"
79
68
  },
80
69
  "keywords": []
81
70
  }
@@ -1,404 +0,0 @@
1
- /**
2
- * Typedefs, constants, support functions and database operations for
3
- * general Utilities
4
- * @module Utilities
5
- */
6
- import dayjs from "dayjs";
7
- //import promisePool from "es6-promise-pool";
8
- import isSameOrAfter from "dayjs/plugin/isSameOrAfter.js";
9
- import isSameOrBefore from "dayjs/plugin/isSameOrBefore.js";
10
- import {
11
- fetchRecordByRefPath,
12
- runTransaction,
13
- writeBack,
14
- deleteRecordByRefPath,
15
- } from "@leaddreamer/firebase-wrapper";
16
- //the following inits the dayjs plugins
17
-
18
- dayjs.extend(isSameOrAfter);
19
- dayjs.extend(isSameOrBefore);
20
-
21
- /**
22
- * A convenience function for some shared artist/host front-end pages
23
- * @param {OrganizationType} host
24
- * @returns {Promise.OrganizationType}
25
- */
26
- export async function saveHost(host, batch = null) {
27
- return writeBack(host, batch);
28
- }
29
-
30
- /**
31
- * Simple top-level object compare - assumes objects have similar structure - or
32
- * AT LEAST all the fields of object1 are present in object2
33
- * @param {object} object1
34
- * @param {object} object2
35
- * @returns {boolean}
36
- */
37
- export function simpleObjectCompare(object1, object2) {
38
- let result = Object.keys(object1).reduce((accumulate, key) => {
39
- // eslint-disable-next-line
40
- return object1[key] == object2[key] ? accumulate : false;
41
- }, true); // note simple (not object) compare
42
- return result;
43
- }
44
-
45
- /**
46
- * Allows string substitution from an object
47
- * field names support Dot notation
48
- * field names allow ":" extension for alternate formatting
49
- * @param {object} thisItem - object to create formated string from
50
- * @param {string} thisFormat - string describing formatted output - fieldname wrapped in {} will be substituted. DOT notation allowed for fields.
51
- * @returns {string}
52
- */
53
- export function formatItem(thisObject, thisFormat) {
54
- let final = thisFormat.replace(
55
- /{.+?}/g, //global, non-greedy - i.e. multiple {} bracketed elements
56
- function (field) {
57
- let fieldRaw = field.slice(1, -1);
58
- //below allows for DOT notation access within the item object
59
- let fieldparts = fieldRaw.split(":");
60
- let [fieldname, fieldStyle] = fieldparts;
61
- let fieldArray = fieldname.split(".");
62
- //below walks into an object - note: ASSUMES an object
63
- const bob = fieldArray.reduce((lastObject, nextName) => {
64
- return lastObject[nextName];
65
- }, thisObject);
66
- return bob ? specialFormat(bob, fieldStyle) : "----";
67
- }
68
- );
69
- return final;
70
- }
71
-
72
- /**
73
- * @private
74
- * @param {any} value
75
- * @param {!string} style
76
- * @returns {any|string}
77
- */
78
- function specialFormat(value, style) {
79
- switch (style) {
80
- case "timestamp":
81
- return dayjs(value.toDate()).format("MMM DD, YYYY");
82
- default:
83
- return value;
84
- }
85
- }
86
-
87
- /**
88
- * @param {object} thisItem - one of two objects being compared
89
- * @param {object} anotherItem - the other of two objects being compared
90
- * @param {!string} sort - string describing sort - format "fieldName:sortType" - sort Type is "string, "date" or "number" (default)
91
- * @return {string}
92
- */
93
- export function compare(thisItem, anotherItem, sort = "Id:number") {
94
- let [field, type] = sort.split(":");
95
- type = type ? type : "number";
96
- switch (type) {
97
- case "string":
98
- let nameArray = thisItem[field].split("The ");
99
- let anotherArray = anotherItem[field].split("The ");
100
- return (nameArray[0] ? nameArray[0] : nameArray[1]).localeCompare(
101
- anotherArray[0] ? anotherArray[0] : anotherArray[1]
102
- );
103
-
104
- case "date":
105
- //if (!thisItem[field] || !anotherItem[field]) return 0;
106
- return !thisItem[field] ||
107
- dayjs(thisItem[field]).isBefore(anotherItem[field], "day")
108
- ? -1
109
- : anotherItem[field] &&
110
- dayjs(thisItem[field]).isSame(anotherItem[field], "day")
111
- ? 0
112
- : 1;
113
-
114
- default:
115
- return Number(thisItem[field]) - Number(anotherItem[field]);
116
- }
117
- }
118
-
119
- /**
120
- * An array based compare function - is any entry of findFrom present in findIn
121
- * @param {Array.any} findFrom
122
- * @param {Array.any} findIn
123
- * @returns {boolean}
124
- */
125
- export function anyInAny(findFrom, findIn) {
126
- let mapFindIn = new Map();
127
-
128
- findIn.forEach((entry, index) => {
129
- mapFindIn.set(entry, true);
130
- }); //speed up by avoiding second loop
131
-
132
- const findFromLength = findFrom.length;
133
- let found = false;
134
- for (
135
- let findFromIndex = 0;
136
- findFromIndex < findFromLength && !found;
137
- findFromIndex++
138
- )
139
- if (
140
- mapFindIn.get(findFrom[findFromIndex].valueOf())
141
- //findFrom[findFromIndex].valueOf() === findIn[arrayTwoIndex].valueOf()
142
- )
143
- found = true; //note this breaks both loops
144
-
145
- return found;
146
- }
147
-
148
- /**
149
- * A convenience function for legibility
150
- * @param {any} args unbounded list of arguments
151
- * @returns {number} the least of any of the arguments
152
- b */
153
- export function lesserOf(...args) {
154
- return Math.min(...args);
155
- }
156
-
157
- /**
158
- * @param {any} args unbounded list of arguments
159
- * @returns {number} the largest of any of the arguments
160
- */
161
- export function largerOf(...args) {
162
- return Math.max(...args);
163
- }
164
-
165
- /**
166
- * "Moves" a record from our standard tree structureto a parallel archival
167
- * structure, by prepending a "_" to the collection names in the path
168
- * This prevents the archived record from appearing in collectionGroup queries
169
- * @param {RecordDocument} record
170
- * @param {!string} record.refPath
171
- * @returns {Promise}
172
- */
173
- export async function archiveRecord(record) {
174
- //split the reference path into it's constituent parts
175
- const parts = record.refPath.split("/");
176
- const partsCount = parts.length;
177
- if (Math.floor(partsCount / 2) * 2 !== partsCount) {
178
- //throw "safe" error
179
- return; //returns a null promise resolved
180
- }
181
-
182
- let archivePath = "";
183
- let index = 0;
184
- //adde a "_" to the start of every collection named in the path
185
- //this avoids collectionGroup issues, but follows a parallel path
186
- do {
187
- archivePath = `${archivePath}/_${parts[index]}/${parts[index + 1]}`;
188
- index += 2;
189
- } while (index < partsCount);
190
- await runTransaction(async (batch) => {
191
- //////////////////////////////
192
- //Read a current full copy of the record
193
- const realRecord = await fetchRecordByRefPath(record.refPath, batch);
194
- //Write it to the "archivePath"
195
- await writeBack({ ...realRecord, refPath: archivePath }, batch);
196
- //delete the original copy
197
- await deleteRecordByRefPath(realRecord.refPath, batch);
198
- });
199
- }
200
-
201
- /**
202
- * uses a passed refPath to create the most basic document record form
203
- * @param {!string} refPath - "/" separated document path reference
204
- * @returns {RecordDocument}
205
- */
206
- export function refPathToBaseRecord(refPath) {
207
- return {
208
- Id: refPath.split("/").pop(),
209
- refPath: refPath,
210
- };
211
- }
212
-
213
- /**
214
- * clips value to given bounds
215
- * @param {number} value
216
- * @param {number} lowerBound
217
- * @param {number} upperBound
218
- * @returns {number}
219
- */
220
- export function bound(value, lowerBound, upperBound) {
221
- return largerOf(lesserOf(value, upperBound), lowerBound);
222
- }
223
-
224
- /**
225
- * function to push an element to an array which may not be initialized
226
- * @param {Array.object} targetArray
227
- * @param {object} newObject
228
- *
229
- */
230
- export function blindPush(targetArray, newObject) {
231
- targetArray
232
- ? targetArray.push(newObject)
233
- : (targetArray = [newObject]);
234
- return targetArray;
235
- }
236
-
237
- /**
238
- * @param {Array.Array.object} arrayObject
239
- * @param {string} key key or index to choose which Array.object to add *this* object to
240
- * @param {object} object
241
- */
242
- export function addToArrayObject(arrayObject, key, object) {
243
- if (arrayObject[key] && arrayObject[key].length) {
244
- //if the key is already present, *and* there are already objects in the keyed array
245
- arrayObject[key].push(object); //push the object onto the indexed array
246
- } else {
247
- arrayObject[key] = [object];
248
- }
249
- }
250
-
251
-
252
-
253
- /**
254
- * @param {string} color name of color
255
- * @returns {string} hex value of named color
256
- */
257
- export function makeHexAsNeeded(color) {
258
- var colours = {
259
- aliceblue: "#f0f8ff",
260
- antiquewhite: "#faebd7",
261
- aqua: "#00ffff",
262
- aquamarine: "#7fffd4",
263
- azure: "#f0ffff",
264
- beige: "#f5f5dc",
265
- bisque: "#ffe4c4",
266
- black: "#000000",
267
- blanchedalmond: "#ffebcd",
268
- blue: "#0000ff",
269
- blueviolet: "#8a2be2",
270
- brown: "#a52a2a",
271
- burlywood: "#deb887",
272
- cadetblue: "#5f9ea0",
273
- chartreuse: "#7fff00",
274
- chocolate: "#d2691e",
275
- coral: "#ff7f50",
276
- cornflowerblue: "#6495ed",
277
- cornsilk: "#fff8dc",
278
- crimson: "#dc143c",
279
- cyan: "#00ffff",
280
- darkblue: "#00008b",
281
- darkcyan: "#008b8b",
282
- darkgoldenrod: "#b8860b",
283
- darkgray: "#a9a9a9",
284
- darkgreen: "#006400",
285
- darkkhaki: "#bdb76b",
286
- darkmagenta: "#8b008b",
287
- darkolivegreen: "#556b2f",
288
- darkorange: "#ff8c00",
289
- darkorchid: "#9932cc",
290
- darkred: "#8b0000",
291
- darksalmon: "#e9967a",
292
- darkseagreen: "#8fbc8f",
293
- darkslateblue: "#483d8b",
294
- darkslategray: "#2f4f4f",
295
- darkturquoise: "#00ced1",
296
- darkviolet: "#9400d3",
297
- deeppink: "#ff1493",
298
- deepskyblue: "#00bfff",
299
- dimgray: "#696969",
300
- dodgerblue: "#1e90ff",
301
- firebrick: "#b22222",
302
- floralwhite: "#fffaf0",
303
- forestgreen: "#228b22",
304
- fuchsia: "#ff00ff",
305
- gainsboro: "#dcdcdc",
306
- ghostwhite: "#f8f8ff",
307
- gold: "#ffd700",
308
- goldenrod: "#daa520",
309
- gray: "#808080",
310
- green: "#008000",
311
- greenyellow: "#adff2f",
312
- honeydew: "#f0fff0",
313
- hotpink: "#ff69b4",
314
- "indianred ": "#cd5c5c",
315
- indigo: "#4b0082",
316
- ivory: "#fffff0",
317
- khaki: "#f0e68c",
318
- lavender: "#e6e6fa",
319
- lavenderblush: "#fff0f5",
320
- lawngreen: "#7cfc00",
321
- lemonchiffon: "#fffacd",
322
- lightblue: "#add8e6",
323
- lightcoral: "#f08080",
324
- lightcyan: "#e0ffff",
325
- lightgoldenrodyellow: "#fafad2",
326
- lightgrey: "#d3d3d3",
327
- lightgreen: "#90ee90",
328
- lightpink: "#ffb6c1",
329
- lightsalmon: "#ffa07a",
330
- lightseagreen: "#20b2aa",
331
- lightskyblue: "#87cefa",
332
- lightslategray: "#778899",
333
- lightsteelblue: "#b0c4de",
334
- lightyellow: "#ffffe0",
335
- lime: "#00ff00",
336
- limegreen: "#32cd32",
337
- linen: "#faf0e6",
338
- magenta: "#ff00ff",
339
- maroon: "#800000",
340
- mediumaquamarine: "#66cdaa",
341
- mediumblue: "#0000cd",
342
- mediumorchid: "#ba55d3",
343
- mediumpurple: "#9370d8",
344
- mediumseagreen: "#3cb371",
345
- mediumslateblue: "#7b68ee",
346
- mediumspringgreen: "#00fa9a",
347
- mediumturquoise: "#48d1cc",
348
- mediumvioletred: "#c71585",
349
- midnightblue: "#191970",
350
- mintcream: "#f5fffa",
351
- mistyrose: "#ffe4e1",
352
- moccasin: "#ffe4b5",
353
- navajowhite: "#ffdead",
354
- navy: "#000080",
355
- oldlace: "#fdf5e6",
356
- olive: "#808000",
357
- olivedrab: "#6b8e23",
358
- orange: "#ffa500",
359
- orangered: "#ff4500",
360
- orchid: "#da70d6",
361
- palegoldenrod: "#eee8aa",
362
- palegreen: "#98fb98",
363
- paleturquoise: "#afeeee",
364
- palevioletred: "#d87093",
365
- papayawhip: "#ffefd5",
366
- peachpuff: "#ffdab9",
367
- peru: "#cd853f",
368
- pink: "#ffc0cb",
369
- plum: "#dda0dd",
370
- powderblue: "#b0e0e6",
371
- purple: "#800080",
372
- rebeccapurple: "#663399",
373
- red: "#ff0000",
374
- rosybrown: "#bc8f8f",
375
- royalblue: "#4169e1",
376
- saddlebrown: "#8b4513",
377
- salmon: "#fa8072",
378
- sandybrown: "#f4a460",
379
- seagreen: "#2e8b57",
380
- seashell: "#fff5ee",
381
- sienna: "#a0522d",
382
- silver: "#c0c0c0",
383
- skyblue: "#87ceeb",
384
- slateblue: "#6a5acd",
385
- slategray: "#708090",
386
- snow: "#fffafa",
387
- springgreen: "#00ff7f",
388
- steelblue: "#4682b4",
389
- tan: "#d2b48c",
390
- teal: "#008080",
391
- thistle: "#d8bfd8",
392
- tomato: "#ff6347",
393
- turquoise: "#40e0d0",
394
- violet: "#ee82ee",
395
- wheat: "#f5deb3",
396
- white: "#ffffff",
397
- whitesmoke: "#f5f5f5",
398
- yellow: "#ffff00",
399
- yellowgreen: "#9acd32",
400
- };
401
-
402
- if (colours[color.toLowerCase()]) return colours[color.toLowerCase()];
403
- return color;
404
- }