@leaddreamer/inventorylogic 0.0.3-beta.79 → 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 (59) 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 +23 -0
  57. package/dist/index.js.map +1 -0
  58. package/index.js +1 -2
  59. package/package.json +7 -3
@@ -0,0 +1,231 @@
1
+ /**
2
+ * Typedefs, constants, support functions and database operations related to Promise getQueueSize
3
+ * Thes are useful for scheduling large serial asynchronous operations
4
+ * @module PromiseQueue
5
+ */
6
+ (function () {
7
+ /**
8
+ * Creates a new rate limited queue. The queue is created with stopped state, i.e. you have to call start() to run jobs.
9
+ * @param {number} maxCallsPerSecond=1 - The rate limit of this queue in maximum calls per seconds which may be executed at any time. Pass values less than 1 to have less than one call per second, e.g. 1/3 for 3 one call in three seconds at maximum.
10
+ * @param logger
11
+ * @constructor
12
+ */
13
+ function PromiseQueue(maxCallsPerSecond, logger) {
14
+ this.maxCallsPerSecond =
15
+ typeof maxCallsPerSecond === "undefined" ? 1 : maxCallsPerSecond;
16
+ this.logger = logger;
17
+
18
+ this.tasks = [];
19
+ this.isActive = false;
20
+ this.jobIntervalMillis = 1000 / maxCallsPerSecond;
21
+
22
+ this.lastTaskTimestamp = null;
23
+ this.currentTaskTimeoutId = null;
24
+ }
25
+
26
+ /**
27
+ * Processes the next task and returns the id of the time used to wait for the next invocation of this method.
28
+ * @private
29
+ */
30
+ PromiseQueue.prototype.updateTaskSchedule = function () {
31
+ if (this.logger && this.logger.debug) {
32
+ this.logger.debug("PromiseQueue.updateTaskSchedule");
33
+ }
34
+
35
+ if (this.isEmpty() || this.isStopped()) {
36
+ return;
37
+ }
38
+
39
+ const queue = this;
40
+
41
+ function processNextTask() {
42
+ if (queue.logger && queue.logger.debug) {
43
+ queue.logger.debug("PromiseQueue.processNextTask", queue.tasks.length);
44
+ }
45
+
46
+ var nextTaskItem = queue.tasks.shift();
47
+ if (nextTaskItem) {
48
+ try {
49
+ const result = nextTaskItem.task.call();
50
+
51
+ if (queue.logger && queue.logger.debug) {
52
+ queue.logger.debug(
53
+ "Resolving queued promise",
54
+ result,
55
+ result instanceof Promise
56
+ );
57
+ }
58
+
59
+ nextTaskItem.resolve(result);
60
+ } catch (e) {
61
+ queue.logger.info("rejecting queued promise result", e);
62
+ nextTaskItem.reject(e);
63
+ }
64
+ }
65
+ }
66
+
67
+ function scheduleNext(timeoutMillisOverride) {
68
+ if (queue.logger && queue.logger.debug) {
69
+ queue.logger.debug("PromiseQueue.scheduleNext", timeoutMillisOverride);
70
+ }
71
+
72
+ if (queue.isEmpty()) {
73
+ queue.currentTaskTimeoutId = null;
74
+ return;
75
+ }
76
+
77
+ queue.currentTaskTimeoutId = setTimeout(function () {
78
+ queue.lastTaskTimestamp = Date.now();
79
+ processNextTask();
80
+
81
+ scheduleNext(queue.jobIntervalMillis);
82
+ }, timeoutMillisOverride);
83
+ }
84
+
85
+ if (this.currentTaskTimeoutId == null) {
86
+ if (this.lastTaskTimestamp) {
87
+ let passedTime = Date.now() - this.lastTaskTimestamp;
88
+ if (passedTime > this.jobIntervalMillis) {
89
+ scheduleNext(this.jobIntervalMillis);
90
+ } else {
91
+ scheduleNext(Math.max(0, this.jobIntervalMillis - passedTime));
92
+ }
93
+ } else {
94
+ scheduleNext(0);
95
+ }
96
+ }
97
+ };
98
+
99
+ /**
100
+ * Starts the task processing of this queue.
101
+ *
102
+ * If it is already started, then false will be returned.
103
+ * If it is not yet started then the first task will be processed in the background and true will be returned.
104
+ *
105
+ * @return {boolean} true if this queue wasn't started before and now started to process tasks.
106
+ */
107
+ PromiseQueue.prototype.start = function () {
108
+ if (this.isActive) {
109
+ return false;
110
+ }
111
+
112
+ this.isActive = true;
113
+
114
+ this.updateTaskSchedule();
115
+
116
+ return true;
117
+ };
118
+
119
+ /**
120
+ * Stops the processing of this queue.
121
+ * @return true if the queue was started and is now stopped. false if it was already stopped.
122
+ */
123
+ PromiseQueue.prototype.stop = function () {
124
+ if (this.isActive) {
125
+ this.isActive = false;
126
+
127
+ if (this.currentTaskTimeoutId) {
128
+ clearInterval(this.currentTaskTimeoutId);
129
+ this.currentTaskTimeoutId = null;
130
+ this.lastTaskTimestamp = null;
131
+ }
132
+ }
133
+ };
134
+
135
+ PromiseQueue.prototype.getMaxCallsPerSecond = function () {
136
+ return this.maxCallsPerSecond;
137
+ };
138
+
139
+ PromiseQueue.prototype.isStarted = function () {
140
+ return this.isActive;
141
+ };
142
+
143
+ PromiseQueue.prototype.isStopped = function () {
144
+ return !this.isStarted();
145
+ };
146
+
147
+ /**
148
+ * @returns {boolean} true if this queue is currently empty, i.e. if it has no tasks in the queue.
149
+ */
150
+ PromiseQueue.prototype.isEmpty = function () {
151
+ return this.tasks.length === 0;
152
+ };
153
+
154
+ /**
155
+ * @returns {boolean} true if this queue has one or more entries.
156
+ */
157
+ PromiseQueue.prototype.isNotEmpty = function () {
158
+ return !this.isEmpty();
159
+ };
160
+
161
+ /**
162
+ * @param {function} task - The task to add.
163
+ * @param {boolean} append - if the task should be appended or prepended to the list of queued tasks
164
+ * @return {Promise} A promise which is resolved/rejected when the task was executed by the queue.
165
+ */
166
+ PromiseQueue.prototype.add = function (task, append) {
167
+ var self = this;
168
+
169
+ var promise = new Promise(function (resolve, reject) {
170
+ var newTaskItem = { task: task, resolve: resolve, reject: reject };
171
+
172
+ if (self.isEmpty() || append) {
173
+ self.tasks.push(newTaskItem);
174
+ } else {
175
+ self.tasks.unshift(newTaskItem);
176
+ }
177
+ });
178
+
179
+ self.updateTaskSchedule();
180
+
181
+ return promise;
182
+ };
183
+
184
+ /**
185
+ * Appends a new task at the end of the queue.
186
+ * @param {function} task - The task to perform. This function will be called with no arguments.
187
+ * @return {Promise} A promise which is resolved/rejected When the task was executed by the queue
188
+ */
189
+ PromiseQueue.prototype.append = function (task) {
190
+ return this.add(task, true);
191
+ };
192
+
193
+ /**
194
+ * Adds a new task as first item in the queue.
195
+ * @param task
196
+ * @return {Promise} A promise which is resolved/rejected When the task was executed by the queue
197
+ */
198
+ PromiseQueue.prototype.prepend = function (task) {
199
+ return this.add(task, false);
200
+ };
201
+
202
+ /**
203
+ * Removes the task from the qeueue. If the task is contained more than one time then all occurrences will be removed.
204
+ * @param {function} task - The task to remove.
205
+ * @return {number} - The number of items which were removed.
206
+ */
207
+ PromiseQueue.prototype.remove = function (task) {
208
+ if (this.isEmpty()) {
209
+ return 0;
210
+ }
211
+
212
+ var removedItems = 0;
213
+ for (var i = this.tasks.length - 1; i >= 0; i--) {
214
+ if (this.tasks[i].task === task) {
215
+ this.tasks.splice(i, 1);
216
+ removedItems++;
217
+ }
218
+ }
219
+
220
+ return removedItems;
221
+ };
222
+
223
+ /**
224
+ * @returns {Number} - The number of queued/waiting tasks in the queue.
225
+ */
226
+ PromiseQueue.prototype.getQueueSize = function () {
227
+ return this.tasks.length;
228
+ };
229
+
230
+ module.exports = PromiseQueue;
231
+ })();
@@ -0,0 +1,35 @@
1
+ import {UNSUBSCRIBEKEYS as $fefa9c41cb73ae0b$export$7d0a9b0c57bf84fd, ADDRESSES as $fefa9c41cb73ae0b$export$6890d3564b1f252d, BUSINESS as $fefa9c41cb73ae0b$export$6f454e69bce3a691, BRANDS as $fefa9c41cb73ae0b$export$9547bc19be285f8c, MANAGEDBRANDS as $fefa9c41cb73ae0b$export$73f9b6e7973e6848, ORGANIZATIONS as $fefa9c41cb73ae0b$export$a338fcb90fb9aa37, MANAGEDORGANIZATIONS as $fefa9c41cb73ae0b$export$e72e4cc6cbc6ed26, PRIVATEDATA as $fefa9c41cb73ae0b$export$398ebe85ebcaa41f, BUSINESSDATA as $fefa9c41cb73ae0b$export$e651cf32bc3f78a4, LOGISTICS as $fefa9c41cb73ae0b$export$466d3e044dd15afb, COMMODITY as $fefa9c41cb73ae0b$export$eb747620ce9c5e16, COMMODITIES as $fefa9c41cb73ae0b$export$695940e05bf65de8, LINEITEM as $fefa9c41cb73ae0b$export$4843f9d856059ffd, LINEITEMS as $fefa9c41cb73ae0b$export$f079c6e3d7477fb7, LABORRATES as $fefa9c41cb73ae0b$export$32912c8ca0a712d8, MESSAGES as $fefa9c41cb73ae0b$export$af7faffe10421f14, PRODUCT as $fefa9c41cb73ae0b$export$e36553b0ff5db35a, PRODUCTS as $fefa9c41cb73ae0b$export$4f02bea739260915, PAYMENT as $fefa9c41cb73ae0b$export$eaa266db8852871e, PAYMENTS as $fefa9c41cb73ae0b$export$fadbf22af86be55a, CARDS as $fefa9c41cb73ae0b$export$5f768699f44cc740, TRANSFERS as $fefa9c41cb73ae0b$export$88e60f3c1cd6ae1f, FUNDAMENTALS as $fefa9c41cb73ae0b$export$1a96cd5ee36c0372, PAYOUTRATES as $fefa9c41cb73ae0b$export$e313271f328bdd7d, RATES as $fefa9c41cb73ae0b$export$6b29f6d6b64b8c84, MCC as $fefa9c41cb73ae0b$export$af5764009005aa8e, BUSINESS_TYPE as $fefa9c41cb73ae0b$export$1bd589465335bb9d, ACCESS as $fefa9c41cb73ae0b$export$5eb0c58c8af5c758, ACCESSTO as $fefa9c41cb73ae0b$export$d66f9cc3fc90ff67, STAGE as $fefa9c41cb73ae0b$export$f9865a0a7f208c15, STAGES as $fefa9c41cb73ae0b$export$47007d96f3617630, MATERIAL as $fefa9c41cb73ae0b$export$ca8f11448d1a1116, MATERIALS as $fefa9c41cb73ae0b$export$b7815f33793b967, RECEIPTS as $fefa9c41cb73ae0b$export$cfa5730cd5118215, UNITS as $fefa9c41cb73ae0b$export$a037d132965e1c9f, UNIT as $fefa9c41cb73ae0b$export$97361b7a0c542045, USER as $fefa9c41cb73ae0b$export$ff09b90989b21a8, USERS as $fefa9c41cb73ae0b$export$5a898dd3a28f57e9, MARKUPS as $fefa9c41cb73ae0b$export$1bfdae073fb20e6c, BASE as $fefa9c41cb73ae0b$export$9e15ff8aa6bc996f, HIGHVALUE as $fefa9c41cb73ae0b$export$d93f73eb990136ee, SERVICE as $fefa9c41cb73ae0b$export$3ccfc9db9b7bf43f, FABRICATION as $fefa9c41cb73ae0b$export$5d39addb0306dfd4, WHOLESALE as $fefa9c41cb73ae0b$export$75be49b93be74cb5, RETAIL as $fefa9c41cb73ae0b$export$4466b7859aa06ffd, PAYMENT_SUCCEEDED as $fefa9c41cb73ae0b$export$22e7de231b4ec209, CUSTOMER as $fefa9c41cb73ae0b$export$1d0cc9f143bfe9fc, CUSTOMERADDRESS as $fefa9c41cb73ae0b$export$f437a67b3be18bd2, fakerJSON as $fefa9c41cb73ae0b$export$fe909d0e7ec8aa88, COMPONENT_RANGE as $fefa9c41cb73ae0b$export$72581e25313abf48, COMPONENT_COUNT_RANGE as $fefa9c41cb73ae0b$export$d141374f02dd06d9, ISBN_LENGTH as $fefa9c41cb73ae0b$export$dbb3cd0a4caa6254} from "./InventoryLogic.d27e84a7.js";
2
+ import {AddressDefault as $5e875028eacae923$export$5b4eaa31e9936f4c, AddressForm as $5e875028eacae923$export$20ca2f03d61fd4de, AddressSelectForm as $5e875028eacae923$export$688a09815a2d76e, maplink as $5e875028eacae923$export$5003d738bf1e0422, deleteAddress as $5e875028eacae923$export$6f33ffc8bc2e0c30, deleteAddressByIdAndParent as $5e875028eacae923$export$2873378411ec704, formatAddress as $5e875028eacae923$export$9ab766ce7f4c1f3c, saveAddress as $5e875028eacae923$export$f4e55b204eefc919, fetchAddresses as $5e875028eacae923$export$c9b8cb1768a98d34} from "./InventoryLogic.37dfff3e.js";
3
+ import {fetchFullAccount as $852adca6ae24886c$export$aeea048b1874c987, fetchBusinessData as $852adca6ae24886c$export$a273004aea0035e0, accountPage as $852adca6ae24886c$export$f81f3e9fae10e6db, createBusinessData as $852adca6ae24886c$export$ca4306a1b5762f0e, saveBusinessData as $852adca6ae24886c$export$4bb3a8bbe6017432, deleteBusinessData as $852adca6ae24886c$export$b8447d25d283e6cc, businessDataPath as $852adca6ae24886c$export$8c755753b01b12f, profileComplete as $852adca6ae24886c$export$1e2f140c95101692, profileIncomplete as $852adca6ae24886c$export$f9e1390aa5941c3f, setOpenIssues as $852adca6ae24886c$export$89c9bbe01d357e36, clearOpenIssues as $852adca6ae24886c$export$45379be9a22c2a97} from "./InventoryLogic.57f24f5f.js";
4
+ import {updateCommodity as $21e76cc83a2e54db$export$1ec126d59f4db979, deleteCommodity as $21e76cc83a2e54db$export$9b6c8c0861c73078, deleteCommodityById as $21e76cc83a2e54db$export$51973e05c49d13bf, createCommodity as $21e76cc83a2e54db$export$8566c10d5b97fabb, updateCommodityByID as $21e76cc83a2e54db$export$8396fff7636b69e4, knownCommodity as $21e76cc83a2e54db$export$3171ba3c6caae841, fetchCommodity as $21e76cc83a2e54db$export$dad83ce325511ae2, fetchCommodities as $21e76cc83a2e54db$export$965ec48652f232c7, fetchCommoditiesPaginated as $21e76cc83a2e54db$export$7ad949526eb4312b, fetchCommodityName as $21e76cc83a2e54db$export$a621d0454ced7cc7} from "./InventoryLogic.46ca6768.js";
5
+ import {fetchFundamentals as $367d3ba5e1953c5d$export$f235c8eeea8b793b, fetchRates as $367d3ba5e1953c5d$export$1135a00cfd97f348, fetchPayoutRates as $367d3ba5e1953c5d$export$e545b306de1ff740, fetchMCCs as $367d3ba5e1953c5d$export$e12c451a9ec5cd7c, fetchBusinessTypes as $367d3ba5e1953c5d$export$b0ed4f3c6bb2aee1} from "./InventoryLogic.80d0e568.js";
6
+ import {deleteLineItem as $618035149cc2f269$export$42fb5c11b332038a, deleteLineItemById as $618035149cc2f269$export$9311bf4c650d8c56, createLineItem as $618035149cc2f269$export$9160586647000ce, knownLineItem as $618035149cc2f269$export$682c51c4d54f1588, fetchLineItem as $618035149cc2f269$export$7c918f386d58a9a2, fetchLineItems as $618035149cc2f269$export$93ad1b66295660db, fetchProductLineItems as $618035149cc2f269$export$d2c186a25126fe28, paginateProductLineItems as $618035149cc2f269$export$e6123a92ff8533fc, fetchLineItemName as $618035149cc2f269$export$218cbdd54a707ec7} from "./InventoryLogic.8addb055.js";
7
+ import {MaterialChoices as $082cf3de7799191e$export$ede25c0a3a34c1c7, StageChoices as $082cf3de7799191e$export$eeb76fa3f6b878ea} from "./InventoryLogic.4d012935.js";
8
+ import {logMessageEvent as $b08abff958f5c1f9$export$1d949c62ce6e9407, messageStatus as $b08abff958f5c1f9$export$fb609933e410a9ca, messageEvents as $b08abff958f5c1f9$export$404463f191aa95a1} from "./InventoryLogic.bb447b4c.js";
9
+ import {ERROR_TYPES as $f9cb07fd17b476cd$export$63d334e60537ba01, PaymentDefault as $f9cb07fd17b476cd$export$25824cbb4751202b, paymentDescriptor as $f9cb07fd17b476cd$export$1dc3fa0a524d39c3, receiptDefault as $f9cb07fd17b476cd$export$a5734ae35e42ad51, createPaymentRecord as $f9cb07fd17b476cd$export$e7759a8c3eb8b251, savePaymentData as $f9cb07fd17b476cd$export$f034950df5cadf57, fetchPayment as $f9cb07fd17b476cd$export$81ed014c52470b45, fetchPaymentByUser as $f9cb07fd17b476cd$export$bf9a06d1f6c31bf4, addPaymentDescriptor as $f9cb07fd17b476cd$export$e5cc111dc11d988, savePaymentDescriptor as $f9cb07fd17b476cd$export$218f64344bb0d5b1, removePaymentDescriptor as $f9cb07fd17b476cd$export$2edf51a087d55c34, fetchPDByFingerprint as $f9cb07fd17b476cd$export$719d384deb9d4a1d, fetchPaymentDescriptors as $f9cb07fd17b476cd$export$e67def8f84ea0ce8, listPDSummaries as $f9cb07fd17b476cd$export$afe4f672b985ac26, fetchLatestPDSummary as $f9cb07fd17b476cd$export$46296a85983d5325, fetchPDByOwnerType as $f9cb07fd17b476cd$export$c10d531939e9952c, replaceDefaultPDSummary as $f9cb07fd17b476cd$export$6495802cd4961871, saveReceiptRecord as $f9cb07fd17b476cd$export$4c730f12f97432c2, updateReceipt as $f9cb07fd17b476cd$export$9d597d6207d02073, saveReceiptRecordByOwnerType as $f9cb07fd17b476cd$export$16e7bde1d3e4806e, anyReceiptsByMonthStamp as $f9cb07fd17b476cd$export$be8e05196fbdd05c, fetchReceiptsFiltered as $f9cb07fd17b476cd$export$4eb0e1031e4cb663, saveReceiptRecordByChild as $f9cb07fd17b476cd$export$9612333da9eb2b55, fetchProblemReceipts as $f9cb07fd17b476cd$export$f9dd3c42a9fe0ec7, fetchPledgeTicketReceipt as $f9cb07fd17b476cd$export$912a34b09f6646f6, markReceiptFromPledgeTicket as $f9cb07fd17b476cd$export$cc5e46e81267707d, markReceipt as $f9cb07fd17b476cd$export$b31aae8a995874b9} from "./InventoryLogic.d69ad127.js";
10
+ import {fetchPrivateData as $61cd1791d5265689$export$c3bebe1b4bbebe25, createPrivateData as $61cd1791d5265689$export$9cc830020e353c38, savePrivateData as $61cd1791d5265689$export$fd09f53e2b56e2af, deletePrivateData as $61cd1791d5265689$export$4d99519ebd12d7e2, privateDataPath as $61cd1791d5265689$export$9319c406c799955a} from "./InventoryLogic.8a273d2e.js";
11
+ import {createProduct as $e615241e8e7f6b5a$export$9c734a715e6666d0, makeProductFromChild as $e615241e8e7f6b5a$export$d4a471daa895146b, GoogleAPIProductMap as $e409a6a48e9bf1c0$export$4059922dac929494, JSONProductFeedToItemMapping as $63eb266a363bf697$export$8f68ab01093b41d6, squarespaceFeedTest as $63eb266a363bf697$export$c736243f342fb27b} from "./InventoryLogic.70925a32.js";
12
+ import {summarizeUser as $aeb56590b68e5483$export$7822bd6f88cc1494, deleteUser as $aeb56590b68e5483$export$7d0f10f273c0438a, deleteUserById as $aeb56590b68e5483$export$1eb857e02349d4c8, createUser as $aeb56590b68e5483$export$3493b8991d49f558, buildUserRecords as $aeb56590b68e5483$export$2cccdc7105e5f652, updateUserByID as $aeb56590b68e5483$export$3c10411f5368919b, updateUser as $aeb56590b68e5483$export$e3ac7a5d19605772, knownUser as $aeb56590b68e5483$export$e1980ceaf83ba89, fetchUser as $aeb56590b68e5483$export$6cf10d295bf9320e, fetchUsers as $aeb56590b68e5483$export$2bb8333a9210be15, fetchUsersPaginated as $aeb56590b68e5483$export$db873fddb7c8685b, fetchAnonymousPaginated as $aeb56590b68e5483$export$8cc74b74b196db4a, fetchUserName as $aeb56590b68e5483$export$32d6fa31f0d8a28, fetchUserEmail as $aeb56590b68e5483$export$53755dbf7eaa9f86, userFromId as $aeb56590b68e5483$export$e1ca85ff667d230a, fetchUserPaymentById as $aeb56590b68e5483$export$85df9b940b8f75fd, fetchUserByEmail as $aeb56590b68e5483$export$747404941cf39e5f, fetchFullUser as $aeb56590b68e5483$export$3f848cf621800fba, fetchUserFromChild as $aeb56590b68e5483$export$127de379ac0a4e64, makeUserFromChild as $aeb56590b68e5483$export$a081e2667846200b} from "./InventoryLogic.f276f76c.js";
13
+ import * as $d403d40112d3687c$exports from "./InventoryLogic.31f6d549.js";
14
+
15
+ /**
16
+ * A collection of Business logic and database functions. Shared between ReactJS
17
+ * frontEnd and NodeJS BackEnd
18
+ * @module InventoryLogic
19
+ */
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+ export {$fefa9c41cb73ae0b$export$7d0a9b0c57bf84fd as UNSUBSCRIBEKEYS, $fefa9c41cb73ae0b$export$6890d3564b1f252d as ADDRESSES, $fefa9c41cb73ae0b$export$6f454e69bce3a691 as BUSINESS, $fefa9c41cb73ae0b$export$9547bc19be285f8c as BRANDS, $fefa9c41cb73ae0b$export$73f9b6e7973e6848 as MANAGEDBRANDS, $fefa9c41cb73ae0b$export$a338fcb90fb9aa37 as ORGANIZATIONS, $fefa9c41cb73ae0b$export$e72e4cc6cbc6ed26 as MANAGEDORGANIZATIONS, $fefa9c41cb73ae0b$export$398ebe85ebcaa41f as PRIVATEDATA, $fefa9c41cb73ae0b$export$e651cf32bc3f78a4 as BUSINESSDATA, $fefa9c41cb73ae0b$export$466d3e044dd15afb as LOGISTICS, $fefa9c41cb73ae0b$export$eb747620ce9c5e16 as COMMODITY, $fefa9c41cb73ae0b$export$695940e05bf65de8 as COMMODITIES, $fefa9c41cb73ae0b$export$4843f9d856059ffd as LINEITEM, $fefa9c41cb73ae0b$export$f079c6e3d7477fb7 as LINEITEMS, $fefa9c41cb73ae0b$export$32912c8ca0a712d8 as LABORRATES, $fefa9c41cb73ae0b$export$af7faffe10421f14 as MESSAGES, $fefa9c41cb73ae0b$export$e36553b0ff5db35a as PRODUCT, $fefa9c41cb73ae0b$export$4f02bea739260915 as PRODUCTS, $fefa9c41cb73ae0b$export$eaa266db8852871e as PAYMENT, $fefa9c41cb73ae0b$export$fadbf22af86be55a as PAYMENTS, $fefa9c41cb73ae0b$export$5f768699f44cc740 as CARDS, $fefa9c41cb73ae0b$export$88e60f3c1cd6ae1f as TRANSFERS, $fefa9c41cb73ae0b$export$1a96cd5ee36c0372 as FUNDAMENTALS, $fefa9c41cb73ae0b$export$e313271f328bdd7d as PAYOUTRATES, $fefa9c41cb73ae0b$export$6b29f6d6b64b8c84 as RATES, $fefa9c41cb73ae0b$export$af5764009005aa8e as MCC, $fefa9c41cb73ae0b$export$1bd589465335bb9d as BUSINESS_TYPE, $fefa9c41cb73ae0b$export$5eb0c58c8af5c758 as ACCESS, $fefa9c41cb73ae0b$export$d66f9cc3fc90ff67 as ACCESSTO, $fefa9c41cb73ae0b$export$f9865a0a7f208c15 as STAGE, $fefa9c41cb73ae0b$export$47007d96f3617630 as STAGES, $fefa9c41cb73ae0b$export$ca8f11448d1a1116 as MATERIAL, $fefa9c41cb73ae0b$export$b7815f33793b967 as MATERIALS, $fefa9c41cb73ae0b$export$cfa5730cd5118215 as RECEIPTS, $fefa9c41cb73ae0b$export$a037d132965e1c9f as UNITS, $fefa9c41cb73ae0b$export$97361b7a0c542045 as UNIT, $fefa9c41cb73ae0b$export$ff09b90989b21a8 as USER, $fefa9c41cb73ae0b$export$5a898dd3a28f57e9 as USERS, $fefa9c41cb73ae0b$export$1bfdae073fb20e6c as MARKUPS, $fefa9c41cb73ae0b$export$9e15ff8aa6bc996f as BASE, $fefa9c41cb73ae0b$export$d93f73eb990136ee as HIGHVALUE, $fefa9c41cb73ae0b$export$3ccfc9db9b7bf43f as SERVICE, $fefa9c41cb73ae0b$export$5d39addb0306dfd4 as FABRICATION, $fefa9c41cb73ae0b$export$75be49b93be74cb5 as WHOLESALE, $fefa9c41cb73ae0b$export$4466b7859aa06ffd as RETAIL, $fefa9c41cb73ae0b$export$22e7de231b4ec209 as PAYMENT_SUCCEEDED, $fefa9c41cb73ae0b$export$1d0cc9f143bfe9fc as CUSTOMER, $fefa9c41cb73ae0b$export$f437a67b3be18bd2 as CUSTOMERADDRESS, $fefa9c41cb73ae0b$export$fe909d0e7ec8aa88 as fakerJSON, $fefa9c41cb73ae0b$export$72581e25313abf48 as COMPONENT_RANGE, $fefa9c41cb73ae0b$export$d141374f02dd06d9 as COMPONENT_COUNT_RANGE, $fefa9c41cb73ae0b$export$dbb3cd0a4caa6254 as ISBN_LENGTH, $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, $852adca6ae24886c$export$aeea048b1874c987 as fetchFullAccount, $852adca6ae24886c$export$a273004aea0035e0 as fetchBusinessData, $852adca6ae24886c$export$f81f3e9fae10e6db as accountPage, $852adca6ae24886c$export$ca4306a1b5762f0e as createBusinessData, $852adca6ae24886c$export$4bb3a8bbe6017432 as saveBusinessData, $852adca6ae24886c$export$b8447d25d283e6cc as deleteBusinessData, $852adca6ae24886c$export$8c755753b01b12f as businessDataPath, $852adca6ae24886c$export$1e2f140c95101692 as profileComplete, $852adca6ae24886c$export$f9e1390aa5941c3f as profileIncomplete, $852adca6ae24886c$export$89c9bbe01d357e36 as setOpenIssues, $852adca6ae24886c$export$45379be9a22c2a97 as clearOpenIssues, $21e76cc83a2e54db$export$1ec126d59f4db979 as updateCommodity, $21e76cc83a2e54db$export$9b6c8c0861c73078 as deleteCommodity, $21e76cc83a2e54db$export$51973e05c49d13bf as deleteCommodityById, $21e76cc83a2e54db$export$8566c10d5b97fabb as createCommodity, $21e76cc83a2e54db$export$8396fff7636b69e4 as updateCommodityByID, $21e76cc83a2e54db$export$3171ba3c6caae841 as knownCommodity, $21e76cc83a2e54db$export$dad83ce325511ae2 as fetchCommodity, $21e76cc83a2e54db$export$965ec48652f232c7 as fetchCommodities, $21e76cc83a2e54db$export$7ad949526eb4312b as fetchCommoditiesPaginated, $21e76cc83a2e54db$export$a621d0454ced7cc7 as fetchCommodityName, $367d3ba5e1953c5d$export$f235c8eeea8b793b as fetchFundamentals, $367d3ba5e1953c5d$export$1135a00cfd97f348 as fetchRates, $367d3ba5e1953c5d$export$e545b306de1ff740 as fetchPayoutRates, $367d3ba5e1953c5d$export$e12c451a9ec5cd7c as fetchMCCs, $367d3ba5e1953c5d$export$b0ed4f3c6bb2aee1 as fetchBusinessTypes, $618035149cc2f269$export$42fb5c11b332038a as deleteLineItem, $618035149cc2f269$export$9311bf4c650d8c56 as deleteLineItemById, $618035149cc2f269$export$9160586647000ce as createLineItem, $618035149cc2f269$export$682c51c4d54f1588 as knownLineItem, $618035149cc2f269$export$7c918f386d58a9a2 as fetchLineItem, $618035149cc2f269$export$93ad1b66295660db as fetchLineItems, $618035149cc2f269$export$d2c186a25126fe28 as fetchProductLineItems, $618035149cc2f269$export$e6123a92ff8533fc as paginateProductLineItems, $618035149cc2f269$export$218cbdd54a707ec7 as fetchLineItemName, $082cf3de7799191e$export$ede25c0a3a34c1c7 as MaterialChoices, $082cf3de7799191e$export$eeb76fa3f6b878ea as StageChoices, $b08abff958f5c1f9$export$1d949c62ce6e9407 as logMessageEvent, $b08abff958f5c1f9$export$fb609933e410a9ca as messageStatus, $b08abff958f5c1f9$export$404463f191aa95a1 as messageEvents, $f9cb07fd17b476cd$export$63d334e60537ba01 as ERROR_TYPES, $f9cb07fd17b476cd$export$25824cbb4751202b as PaymentDefault, $f9cb07fd17b476cd$export$1dc3fa0a524d39c3 as paymentDescriptor, $f9cb07fd17b476cd$export$a5734ae35e42ad51 as receiptDefault, $f9cb07fd17b476cd$export$e7759a8c3eb8b251 as createPaymentRecord, $f9cb07fd17b476cd$export$f034950df5cadf57 as savePaymentData, $f9cb07fd17b476cd$export$81ed014c52470b45 as fetchPayment, $f9cb07fd17b476cd$export$bf9a06d1f6c31bf4 as fetchPaymentByUser, $f9cb07fd17b476cd$export$e5cc111dc11d988 as addPaymentDescriptor, $f9cb07fd17b476cd$export$218f64344bb0d5b1 as savePaymentDescriptor, $f9cb07fd17b476cd$export$2edf51a087d55c34 as removePaymentDescriptor, $f9cb07fd17b476cd$export$719d384deb9d4a1d as fetchPDByFingerprint, $f9cb07fd17b476cd$export$e67def8f84ea0ce8 as fetchPaymentDescriptors, $f9cb07fd17b476cd$export$afe4f672b985ac26 as listPDSummaries, $f9cb07fd17b476cd$export$46296a85983d5325 as fetchLatestPDSummary, $f9cb07fd17b476cd$export$c10d531939e9952c as fetchPDByOwnerType, $f9cb07fd17b476cd$export$6495802cd4961871 as replaceDefaultPDSummary, $f9cb07fd17b476cd$export$4c730f12f97432c2 as saveReceiptRecord, $f9cb07fd17b476cd$export$9d597d6207d02073 as updateReceipt, $f9cb07fd17b476cd$export$16e7bde1d3e4806e as saveReceiptRecordByOwnerType, $f9cb07fd17b476cd$export$be8e05196fbdd05c as anyReceiptsByMonthStamp, $f9cb07fd17b476cd$export$4eb0e1031e4cb663 as fetchReceiptsFiltered, $f9cb07fd17b476cd$export$9612333da9eb2b55 as saveReceiptRecordByChild, $f9cb07fd17b476cd$export$f9dd3c42a9fe0ec7 as fetchProblemReceipts, $f9cb07fd17b476cd$export$912a34b09f6646f6 as fetchPledgeTicketReceipt, $f9cb07fd17b476cd$export$cc5e46e81267707d as markReceiptFromPledgeTicket, $f9cb07fd17b476cd$export$b31aae8a995874b9 as markReceipt, $61cd1791d5265689$export$c3bebe1b4bbebe25 as fetchPrivateData, $61cd1791d5265689$export$9cc830020e353c38 as createPrivateData, $61cd1791d5265689$export$fd09f53e2b56e2af as savePrivateData, $61cd1791d5265689$export$4d99519ebd12d7e2 as deletePrivateData, $61cd1791d5265689$export$9319c406c799955a as privateDataPath, $e615241e8e7f6b5a$export$9c734a715e6666d0 as createProduct, $e615241e8e7f6b5a$export$d4a471daa895146b as makeProductFromChild, $e409a6a48e9bf1c0$export$4059922dac929494 as GoogleAPIProductMap, $63eb266a363bf697$export$8f68ab01093b41d6 as JSONProductFeedToItemMapping, $63eb266a363bf697$export$c736243f342fb27b as squarespaceFeedTest, $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, $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};
35
+ //# sourceMappingURL=InventoryLogic.0ac93278.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,152 @@
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
@@ -0,0 +1 @@
1
+ {"mappings":"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","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"}