@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
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;AAAA;;;;CAIC","sources":["business/index.js"],"sourcesContent":["/**\n * A collection of Business logic and database functions. Shared between ReactJS\n * frontEnd and NodeJS BackEnd\n * @module InventoryLogic\n */\nexport * from \"./boilerplate/index.js\";\nexport * from \"./Addresses/index.js\";\nexport * from \"./BusinessData/index.js\";\nexport * from \"./Commodities/index.js\";\nexport * from \"./Fundamentals/index.js\";\nexport * from \"./LineItem/index.js\";\nexport * from \"./Markups/index.js\";\nexport * from \"./Messages/index.js\";\nexport * from \"./Payment/index.js\";\nexport * from \"./PrivateData/index.js\";\nexport * from \"./Product/index.js\";\nexport * from \"./User/index.js\";\nexport * from \"./Utilities/index.js\";\n"],"names":[],"version":3,"file":"InventoryLogic.0ac93278.js.map"}
@@ -1,152 +0,0 @@
1
- import {ADDRESSES as $fefa9c41cb73ae0b$export$6890d3564b1f252d} from "./InventoryLogic.d27e84a7.js";
2
- import {saveHost as $9baf0c6b8de436d9$export$cc9d030424d53c6d, simpleObjectCompare as $9baf0c6b8de436d9$export$f5d1cbac23428e02, formatItem as $9baf0c6b8de436d9$export$62f58f44692b37a8, compare as $9baf0c6b8de436d9$export$398604a469f7de9a, anyInAny as $9baf0c6b8de436d9$export$3145210430358e7, lesserOf as $9baf0c6b8de436d9$export$15b0b9b385c1f78e, largerOf as $9baf0c6b8de436d9$export$e375dfe918aae343, archiveRecord as $9baf0c6b8de436d9$export$f7bac52274eacccb, refPathToBaseRecord as $9baf0c6b8de436d9$export$b6b6e72408f809e2, bound as $9baf0c6b8de436d9$export$adf7c0fe6059d774, blindPush as $9baf0c6b8de436d9$export$884089555def93f8, addToArrayObject as $9baf0c6b8de436d9$export$7fecbbe7deb1a058, makeHexAsNeeded as $9baf0c6b8de436d9$export$36538c15a30486a1} from "./InventoryLogic.35827495.js";
3
- import $3gfAb$InventoryLogic59be76a4js from "./InventoryLogic.59be76a4.js";
4
- import {fetchRecord as $3gfAb$fetchRecord, collectRecords as $3gfAb$collectRecords, collectRecordsByFilter as $3gfAb$collectRecordsByFilter, typedIdFromChild as $3gfAb$typedIdFromChild, typedRefPathFromChild as $3gfAb$typedRefPathFromChild, writeBack as $3gfAb$writeBack, writeRecord as $3gfAb$writeRecord} from "@leaddreamer/firebase-wrapper";
5
- import {Forms as $3gfAb$Forms} from "@leaddreamer/staticforms";
6
-
7
- /**
8
- * Typedefs, constants, support functions and database operations related to usage Units
9
- * and conversions
10
- * @module Utilities
11
- */
12
-
13
-
14
-
15
-
16
- //////////////////////////////////////////////////////////////////////
17
- /**
18
- * pulls the document Id from a passed refPath string (firebase dependent)
19
- * @param {!string} refPath
20
- * @returns {string} Id
21
- */ function $9ab66828811feaa2$var$stripDocIdFromRefPath(refPath) {
22
- return refPath.split("/").pop();
23
- }
24
- async function $9ab66828811feaa2$export$c89b632375228111(type, link, refPath = null) {
25
- return (0, $3gfAb$fetchRecord)(type, link, refPath);
26
- //the "link" in this case is the document Id
27
- }
28
- async function $9ab66828811feaa2$export$5a3279b4c9648f0f(type, refPath) {
29
- let result;
30
- const commonId = $9ab66828811feaa2$var$stripDocIdFromRefPath(refPath);
31
- try {
32
- result = await (0, $3gfAb$fetchRecord)(type, commonId, refPath);
33
- } catch (err) {
34
- //if there is no record, create a skeleton record
35
- result = Promise.resolve({
36
- Id: commonId,
37
- refPath: `${refPath}/${type}/${commonId}`
38
- });
39
- }
40
- return result;
41
- //returns a PROMISE
42
- //subrecord items are in the named sub-collection with the parent's Id
43
- //these collections have ONLY one document
44
- }
45
- async function $9ab66828811feaa2$export$d39fdbaf795265a7(type, refPath = null) {
46
- const tablePath = type;
47
- if (type === (0, $fefa9c41cb73ae0b$export$6890d3564b1f252d) && !refPath) return null;
48
- return (0, $3gfAb$collectRecords)(tablePath, refPath);
49
- //returns a PROMISE
50
- //subrecord items are in the named sub-collection
51
- }
52
- async function $9ab66828811feaa2$export$abd398b6018f8436(type, parent = null, prompt = null, limit = null) {
53
- const field = (0, $3gfAb$Forms).SearchBy[type];
54
- let filterArray = prompt && prompt.length ? [
55
- {
56
- fieldRef: field,
57
- opStr: ">=",
58
- value: prompt
59
- }
60
- ] : null;
61
- const sortArray = [
62
- {
63
- fieldRef: field,
64
- dirStr: "asc"
65
- }
66
- ];
67
- return (0, $3gfAb$collectRecordsByFilter)(type, parent?.refPath, filterArray, sortArray, limit);
68
- }
69
- const $9ab66828811feaa2$export$921842c360078a33 = (Id, Type)=>{
70
- return {
71
- Id: Id,
72
- refPath: `/${Type}/${Id}`
73
- };
74
- };
75
- function $9ab66828811feaa2$export$9536a88c96a1be48(child, type) {
76
- return {
77
- Id: (0, $3gfAb$typedIdFromChild)(child, type),
78
- refPath: (0, $3gfAb$typedRefPathFromChild)(child, type)
79
- };
80
- }
81
- function $9ab66828811feaa2$export$c093435923294c4e(type) {
82
- switch(type){
83
- case 0, $fefa9c41cb73ae0b$export$6890d3564b1f252d:
84
- return [
85
- {
86
- fieldRef: "address_line_1",
87
- dirStr: "asc"
88
- }
89
- ];
90
- default:
91
- return [
92
- {
93
- fieldRef: "name",
94
- dirStr: "asc"
95
- }
96
- ];
97
- }
98
- }
99
- async function $9ab66828811feaa2$export$19e2e60a6b9b3b01(item, type, refPath = null, batch = null) {
100
- switch(type){
101
- case 0, $fefa9c41cb73ae0b$export$6890d3564b1f252d:
102
- return item?.Id ? (0, $3gfAb$writeBack)(item, batch) : (0, $3gfAb$writeRecord)(type, item, refPath, batch);
103
- default:
104
- return Promise.resolve(null);
105
- }
106
- }
107
- async function $9ab66828811feaa2$export$d2db84ed358b7054(link, type, refPath) {
108
- const tablePath = type;
109
- const Id = link; //can also be a partial path ending with Id
110
- const item = await (0, $3gfAb$fetchRecord)(tablePath, Id, refPath);
111
- return $9ab66828811feaa2$export$da804150202b2b8d(item, type);
112
- }
113
- function $9ab66828811feaa2$export$da804150202b2b8d(item, type) {
114
- //checks for presence in the Forms object
115
- return (0, $3gfAb$Forms).Summarize[type] ? (0, $3gfAb$Forms).Summarize[type](item) : item.name || item.Id;
116
- }
117
- function $9ab66828811feaa2$export$31dbe01f37b7732f(type) {
118
- return (0, $3gfAb$Forms).Base[type];
119
- }
120
- function $9ab66828811feaa2$export$3ee853080fb51bea(type) {
121
- return (0, $3gfAb$Forms).BaseForm[type];
122
- }
123
- function $9ab66828811feaa2$export$5af4610fbe1137fd(type) {
124
- return (0, $3gfAb$Forms)?.Data[type] ? (0, $3gfAb$Forms).Data[type] : null;
125
- }
126
- function $9ab66828811feaa2$export$f681a8129d2e9d28(type) {
127
- return (0, $3gfAb$Forms)?.CreateForm[type] ? (0, $3gfAb$Forms).CreateForm[type] : null;
128
- }
129
- function $9ab66828811feaa2$export$c050911d30958522(type) {
130
- return (0, $3gfAb$Forms)?.AccountForm[type] ? (0, $3gfAb$Forms).AccountForm[type] : null;
131
- }
132
- function $9ab66828811feaa2$export$55369601a4bc1cda(type) {
133
- return (0, $3gfAb$Forms)?.Save[type] ? (0, $3gfAb$Forms).Save[type] : ()=>{};
134
- }
135
- function $9ab66828811feaa2$export$24178ee8231de835(type) {
136
- //if there *is* a special change function, return it, else
137
- //return a simple function to return the new value directly
138
- return (0, $3gfAb$Forms)?.UpdateChange[type] ? (0, $3gfAb$Forms).UpdateChange[type] //returns a FUNCTION
139
- : (prev, value, itemFor)=>{
140
- return {
141
- ...prev,
142
- [itemFor]: value
143
- };
144
- };
145
- }
146
- function $9ab66828811feaa2$export$b9a757ca31a5f892(fieldname) {
147
- return (0, $3gfAb$Forms).Choices[fieldname] ? (0, $3gfAb$Forms).Choices[fieldname] : {};
148
- }
149
-
150
-
151
- export {$9ab66828811feaa2$export$c89b632375228111 as fetchLinkedItem, $9ab66828811feaa2$export$5a3279b4c9648f0f as fetchSubItem, $9ab66828811feaa2$export$d39fdbaf795265a7 as fetchType, $9ab66828811feaa2$export$abd398b6018f8436 as searchType, $9ab66828811feaa2$export$921842c360078a33 as recordByIdAndType, $9ab66828811feaa2$export$9536a88c96a1be48 as typedRecordFromChild, $9ab66828811feaa2$export$c093435923294c4e as typedSortArray, $9ab66828811feaa2$export$19e2e60a6b9b3b01 as processItemType, $9ab66828811feaa2$export$d2db84ed358b7054 as formatLinkedItem, $9ab66828811feaa2$export$da804150202b2b8d as summarizeItem, $9ab66828811feaa2$export$31dbe01f37b7732f as baseItem, $9ab66828811feaa2$export$3ee853080fb51bea as baseForm, $9ab66828811feaa2$export$5af4610fbe1137fd as dataForm, $9ab66828811feaa2$export$f681a8129d2e9d28 as createForm, $9ab66828811feaa2$export$c050911d30958522 as accountForm, $9ab66828811feaa2$export$55369601a4bc1cda as saveForm, $9ab66828811feaa2$export$24178ee8231de835 as updateChangeForm, $9ab66828811feaa2$export$b9a757ca31a5f892 as choicesForm, $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, $d403d40112d3687c$exports as default};
152
- //# sourceMappingURL=InventoryLogic.31f6d549.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;AAAA;;;;CAIC;;;;;AAaD,sEAAsE;AAEtE;;;;CAIC,GACD,SAAS,4CAAsB,OAAO;IACpC,OAAO,QAAQ,KAAK,CAAC,KAAK,GAAG;AAC/B;AAUO,eAAe,0CAAgB,IAAI,EAAE,IAAI,EAAE,UAAU,IAAI;IAC9D,OAAO,CAAA,GAAA,kBAAU,EAAE,MAAM,MAAM;AAC/B,4CAA4C;AAC9C;AAUO,eAAe,0CAAa,IAAI,EAAE,OAAO;IAC9C,IAAI;IACJ,MAAM,WAAW,4CAAsB;IACvC,IAAI;QACF,SAAS,MAAM,CAAA,GAAA,kBAAU,EAAE,MAAM,UAAU;IAC7C,EAAE,OAAO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W,CAAC,KAAK,GAAG;AAC9D;AAUO,SAAS,0CAAS,IAAI;IAC3B,OAAO,CAAA,GAAA,YAAI,GAAG,IAAI,CAAC,KAAK,GAAG,CAAA,GAAA,YAAI,EAAE,IAAI,CAAC,KAAK,GAAG,KAAQ;AACxD;AAmBO,SAAS,0CAAiB,IAAI;IACnC,0DAA0D;IAC1D,2DAA2D;IAC3D,OAAO,CAAA,GAAA,YAAI,GAAG,YAAY,CAAC,KAAK,GAC5B,CAAA,GAAA,YAAI,EAAE,YAAY,CAAC,KAAK,CAAC,oBAAoB;OAC7C,CAAC,MAAM,OAAO;QACd,OAAO;YACL,GAAG,IAAI;YACP,CAAC,QAAQ,EAAE;QACb;IACF;AACJ;AAUO,SAAS,0CAAY,SAAS;IACnC,OAAO,CAAA,GAAA,YAAI,EAAE,OAAO,CAAC,UAAU,GAC3B,CAAA,GAAA,YAAI,EAAE,OAAO,CAAC,UAAU,GACxB,CAAC;AACP","sources":["business/Utilities/index.js"],"sourcesContent":["/**\n * Typedefs, constants, support functions and database operations related to usage Units\n * and conversions\n * @module Utilities\n */\nimport {\n collectRecordsByFilter,\n typedIdFromChild,\n typedRefPathFromChild,\n fetchRecord,\n collectRecords,\n writeBack,\n writeRecord,\n} from \"@leaddreamer/firebase-wrapper\";\nimport { Forms } from \"@leaddreamer/staticforms\";\nimport { ADDRESSES } from \"../boilerplate/index.js\";\n\n//////////////////////////////////////////////////////////////////////\n\n/**\n * pulls the document Id from a passed refPath string (firebase dependent)\n * @param {!string} refPath\n * @returns {string} Id\n */\nfunction stripDocIdFromRefPath(refPath) {\n return refPath.split(\"/\").pop();\n}\n\n/**\n * used generic for constructing forms for input and display\n * @param {!string} type refers to the sub-collection name\n * @param {!string} link refers to the linking \"value\" - a documentID\n * @param {?string} refPath optionally refers to the \"/\" separate path to\n * the parent document in firebase\n * @returns {Promise.RecordDocument}\n */\nexport async function fetchLinkedItem(type, link, refPath = null) {\n return fetchRecord(type, link, refPath);\n //the \"link\" in this case is the document Id\n}\n\n/**\n * some items are stored in the database as a single-record collection, using\n * the same Id as the parent\n * @param {!string} type refers to the sub-collection name\n * @param {!string} refPath refers to the \"/\" separate path to the required\n * parent document in firebase\n * @returns {Promise.RecordDocument}\n */\nexport async function fetchSubItem(type, refPath) {\n let result;\n const commonId = stripDocIdFromRefPath(refPath);\n try {\n result = await fetchRecord(type, commonId, refPath);\n } catch (err) {\n //if there is no record, create a skeleton record\n result = Promise.resolve({\n Id: commonId,\n refPath: `${refPath}/${type}/${commonId}`,\n });\n }\n return result;\n //returns a PROMISE\n //subrecord items are in the named sub-collection with the parent's Id\n //these collections have ONLY one document\n}\n\n/**\n * returns an entire sub-collection by \"type\" (sub-collection name).\n * If refpath is omitted, assumes \"type\" is a top-level collection\n * @param {!string} type refers to the sub-collection name\n * @param {?string} refPath optionally refers to the \"/\" separate path to\n * the parent document in firebase\n * @returns {Promise.Array.RecordDocument}\n */\nexport async function fetchType(type, refPath = null) {\n const tablePath = type;\n\n if (type === ADDRESSES && !refPath) return null;\n\n return collectRecords(tablePath, refPath);\n //returns a PROMISE\n //subrecord items are in the named sub-collection\n}\n\n/**\n * returns a Promise which resolves to an array of all Type's whose\n * name begins with the provided prompt, optionally limited to a provided number\n * CASE SENSITIVE FOR NOW\n * @param {string} type type of record to search\n * @param {Record} parent parent object of records, if any\n * @param {?string} prompt Used to query for matching records\n * @param {?string|number} limit Used to limit the number of results\n * @returns {Promise.Array.OrganizationType}\n */\nexport async function searchType(\n type,\n parent = null,\n prompt = null,\n limit = null,\n) {\n const field = Forms.SearchBy[type];\n let filterArray =\n prompt && prompt.length\n ? [{ fieldRef: field, opStr: \">=\", value: prompt }]\n : null;\n const sortArray = [\n {\n fieldRef: field,\n dirStr: \"asc\",\n },\n ];\n return collectRecordsByFilter(\n type,\n parent?.refPath,\n filterArray,\n sortArray,\n limit,\n );\n}\n\n/**\n * creates and returns a minimal record from an Id and `type`\n * @param {!string} Id\n * @param {!string} Type\n * @returns {AccountType}\n */\nexport const recordByIdAndType = (Id, Type) => {\n return {\n Id: Id,\n refPath: `/${Type}/${Id}`,\n };\n};\n\n/**\n * builds a representation of a parent from a child, by type\n * @param {string} type \n * @param {Record} child \n * @returns {Record}\n */\n\nexport function typedRecordFromChild(child, type) {\n return {\n Id: typedIdFromChild(child, type),\n refPath: typedRefPathFromChild(child, type),\n }\n}\n\n/**\n * Firebase query support - builds default sort options\n * @param {!string} type\n * @returns {Array.SortObject}\n */\nexport function typedSortArray(type) {\n switch (type) {\n case ADDRESSES:\n return [{ fieldRef: \"address_line_1\", dirStr: \"asc\" }];\n default:\n return [{ fieldRef: \"name\", dirStr: \"asc\" }];\n }\n}\n\n/**\n * generic form data processing for database by \"type\" (collection name)\n * @param {RecordDocument} item\n * @param {!string} type refers to the sub-collection name\n * @param {?string} refPath optionally refers to the \"/\" separate path to\n * the parent document in firebase\n * @returns {Promise.RecordDocument}\n */\nexport async function processItemType(\n item,\n type,\n refPath = null,\n batch = null,\n) {\n switch (type) {\n case ADDRESSES:\n return item?.Id\n ? writeBack(item, batch)\n : writeRecord(type, item, refPath, batch);\n default:\n return Promise.resolve(null);\n }\n}\n\n/**\n * fetches a sub-record from the database and returns the result as a summary string\n * @param {!string} link refers to the linking \"value\" - a documentID\n * @param {!string} type refers to the sub-collection name\n * @param {!string} refPath refers to the \"/\" separate path to the required\n * parent document in firebase\n * @returns {Promise.string}\n */\nexport async function formatLinkedItem(link, type, refPath) {\n const tablePath = type;\n const Id = link; //can also be a partial path ending with Id\n const item = await fetchRecord(tablePath, Id, refPath);\n return summarizeItem(item, type);\n}\n\n/**\n * parameterized function to return string summary of an object\n * By default, returns the \"name\" property of the item.\n * @param {object} item - data object to summarize\n * @param {String|\"User\"|\"Product\"|\"LineItem\"|\"Commodities\"|\"Units\"} type\n * - type of the object to summarize\n * @returns {string}\n */\nexport function summarizeItem(item, type) {\n //checks for presence in the Forms object\n return Forms.Summarize[type] ? Forms.Summarize[type](item) : (item.name || item.Id);\n}\n\n/**\n * Convenience function to mask actual Forms array from the front-end\n * This version returns the \"base\" item sample for a business-object type,\n * where the keys are the field/property names, and the values are the\n * default values as defined in the business logic\n * @param {string} type \n * @returns {object} keys and default values\n */\nexport function baseItem(type) {\n return Forms.Base[type];\n}\n\n/**\n * Convenience function to mask actual Forms array from the front-end\n * This version returns the \"baseForm\" withe keys/properties, and\n * values are strings with \":\" separated definitions for EditForm and\n * similar functionality - see \"EditForm\" for more details\n * @param {string} type \n * @returns {object} keys and default values\n */\nexport function baseForm(type) {\n return Forms.BaseForm[type];\n}\n\n/**\n * Convenience function to mask actual Forms array from the front-end\n * This version returns the \"Data\" object with keys/properties, and\n * values are strings with \":\" separated definitions for Faker and\n * similar functionality - to generate \"fake\" simulated data for testing\n * @param {string} type \n * @returns {object} keys and default values\n */\nexport function dataForm(type) {\n return Forms?.Data[type] ? Forms.Data[type] : null;\n}\n\n/**\n * Convenience function to mask actual Forms array from the front-end\n * This version returns the \"createForm\" withe keys/properties, and\n * values are strings with \":\" separated definitions for EditForm and\n * similar functionality - see \"EditForm\" for more details\n * Specifically for limited \"front-end\" use to CREATE new\n * business-objects with the minimum entries necessary\n * @param {string} type \n * @returns {object} keys and default values\n */\nexport function createForm(type) {\n return Forms?.CreateForm[type]\n ? Forms.CreateForm[type]\n : null;\n\n}\n\n/**\n * Convenience function to mask actual Forms array from the front-end\n * This version returns the \"createForm\" withe keys/properties, and\n * values are strings with \":\" separated definitions for EditForm and\n * similar functionality - see \"EditForm\" for more details\n * Specifically for limited \"front-end\" use on ACCOUNT business-objects\n * with the minimum entries necessary\n * @param {string} type \n * @returns {object} keys and default values\n */\nexport function accountForm(type) {\n return Forms?.AccountForm[type] ? Forms.AccountForm[type] : null;\n}\n\n/**\n * Convenience function to mask actual Forms array from the front-end\n * This version returns a FUNCTION to use for saving a business-object\n * to the database - abstracting type-specific features and functionality\n * from the front end\n * @param {string} type \n * @returns {callback}\n */\nexport function saveForm(type) {\n return Forms?.Save[type] ? Forms.Save[type] : () => { };\n}\n\n/**\n * @function UpdateChange\n * Function Signature for UpdateChange functions\n * @param {object} prev\n * @param {object} value\n * @param {string} itemFor\n * @param {object} fullChoiceObject\n * @returns {object}\n */\n\n/**\n * Convenience function to mask actual Forms array from the front-end\n * This version returns a FUNCTION to respond to cross-field dependent\n * chnages during editing with EditForm, reactdatagrid, etc\n * @param {string} type \n * @returns {callback}\n */\nexport function updateChangeForm(type) {\n //if there *is* a special change function, return it, else\n //return a simple function to return the new value directly\n return Forms?.UpdateChange[type]\n ? Forms.UpdateChange[type] //returns a FUNCTION\n : (prev, value, itemFor) => {\n return {\n ...prev,\n [itemFor]: value\n };\n };\n}\n\n/**\n * Returns an object whose keys are the available choices for a\n * business-object field, and whose values represent the sort order\n * Most fieldname have no such choices. Both the definitions and \n * usage are defined in business logic elsewhere\n * @param {string} fieldname which business type is being processes\n * @returns {object}\n */\nexport function choicesForm(fieldname) {\n return Forms.Choices[fieldname]\n ? Forms.Choices[fieldname]\n : {};\n}\n\nexport * from \"./other.js\";\nexport * from \"./promise-queue/index.js\";\n"],"names":[],"version":3,"file":"InventoryLogic.31f6d549.js.map"}
@@ -1,285 +0,0 @@
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
@@ -1 +0,0 @@
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,SAAS;QAC7B,GAAG;QACH,OAAO,MAAM,oCAAc,KAAK,cAAc;IAChD;IAEF,OAAO;AACT;AAEA;;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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"}
@@ -1,72 +0,0 @@
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
@@ -1 +0,0 @@
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"}