@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.
- package/README.md +16 -20
- package/business/Utilities/index.js +1 -0
- package/business/Utilities/other.js +1 -3
- package/business/Utilities/promise-queue/index.js +183 -150
- package/business/Utilities/promise-queue/new.js +231 -0
- package/dist/InventoryLogic.0ac93278.js +35 -0
- package/dist/InventoryLogic.0ac93278.js.map +1 -0
- package/dist/InventoryLogic.31f6d549.js +152 -0
- package/dist/InventoryLogic.31f6d549.js.map +1 -0
- package/dist/InventoryLogic.35827495.js +285 -0
- package/dist/InventoryLogic.35827495.js.map +1 -0
- package/dist/InventoryLogic.37dfff3e.js +72 -0
- package/dist/InventoryLogic.37dfff3e.js.map +1 -0
- package/dist/InventoryLogic.4206cb15.js +213 -0
- package/dist/InventoryLogic.4206cb15.js.map +1 -0
- package/dist/InventoryLogic.44193a77.js +35 -0
- package/dist/InventoryLogic.44193a77.js.map +1 -0
- package/dist/InventoryLogic.46ca6768.js +131 -0
- package/dist/InventoryLogic.46ca6768.js.map +1 -0
- package/dist/InventoryLogic.4d012935.js +151 -0
- package/dist/InventoryLogic.4d012935.js.map +1 -0
- package/dist/InventoryLogic.57f24f5f.js +155 -0
- package/dist/InventoryLogic.57f24f5f.js.map +1 -0
- package/dist/InventoryLogic.59be76a4.js +184 -0
- package/dist/InventoryLogic.59be76a4.js.map +1 -0
- package/dist/InventoryLogic.70925a32.js +375 -0
- package/dist/InventoryLogic.70925a32.js.map +1 -0
- package/dist/InventoryLogic.72fcf301.js +6 -0
- package/dist/InventoryLogic.72fcf301.js.map +1 -0
- package/dist/InventoryLogic.7741caec.js +375 -0
- package/dist/InventoryLogic.7741caec.js.map +1 -0
- package/dist/InventoryLogic.78480e5e.js +152 -0
- package/dist/InventoryLogic.78480e5e.js.map +1 -0
- package/dist/InventoryLogic.80d0e568.js +135 -0
- package/dist/InventoryLogic.80d0e568.js.map +1 -0
- package/dist/InventoryLogic.8a273d2e.js +110 -0
- package/dist/InventoryLogic.8a273d2e.js.map +1 -0
- package/dist/InventoryLogic.8addb055.js +202 -0
- package/dist/InventoryLogic.8addb055.js.map +1 -0
- package/dist/InventoryLogic.9dee46ea.js +6 -0
- package/dist/InventoryLogic.9dee46ea.js.map +1 -0
- package/dist/InventoryLogic.b90f66ea.js +124 -0
- package/dist/InventoryLogic.b90f66ea.js.map +1 -0
- package/dist/InventoryLogic.bb447b4c.js +39 -0
- package/dist/InventoryLogic.bb447b4c.js.map +1 -0
- package/dist/InventoryLogic.d27e84a7.js +75 -0
- package/dist/InventoryLogic.d27e84a7.js.map +1 -0
- package/dist/InventoryLogic.d69ad127.js +217 -0
- package/dist/InventoryLogic.d69ad127.js.map +1 -0
- package/dist/InventoryLogic.e03e6b07.js +245 -0
- package/dist/InventoryLogic.e03e6b07.js.map +1 -0
- package/dist/InventoryLogic.f276f76c.js +213 -0
- package/dist/InventoryLogic.f276f76c.js.map +1 -0
- package/dist/InventoryLogic.f4627c8a.js +160 -0
- package/dist/InventoryLogic.f4627c8a.js.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/index.js +1 -2
- package/package.json +7 -3
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import {ISBN_LENGTH as $fefa9c41cb73ae0b$export$dbb3cd0a4caa6254, MARKUPS as $fefa9c41cb73ae0b$export$1bfdae073fb20e6c, PRODUCT as $fefa9c41cb73ae0b$export$e36553b0ff5db35a} from "./InventoryLogic.d27e84a7.js";
|
|
2
|
+
import {typedRecordFromChild as $9ab66828811feaa2$export$9536a88c96a1be48} from "./InventoryLogic.78480e5e.js";
|
|
3
|
+
import {GoogleAPIProductMap as $e409a6a48e9bf1c0$export$4059922dac929494} from "./InventoryLogic.b90f66ea.js";
|
|
4
|
+
import {JSONProductFeedToItemMapping as $63eb266a363bf697$export$8f68ab01093b41d6, squarespaceFeedTest as $63eb266a363bf697$export$c736243f342fb27b} from "./InventoryLogic.e03e6b07.js";
|
|
5
|
+
import {updateRecord as $lRpTb$updateRecord} from "@leaddreamer/firebase-wrapper";
|
|
6
|
+
import {Forms as $lRpTb$Forms, fillForm as $lRpTb$fillForm} from "@leaddreamer/staticforms";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Typedefs, constants, support functions and database operations related to Products
|
|
10
|
+
* @module Product
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
//////////////////////////////////////////////////////////////////////
|
|
18
|
+
// Constants
|
|
19
|
+
/**
|
|
20
|
+
* "recipe" related values - build-stage markups, product/project Flag, created/modified dates
|
|
21
|
+
* @typedef {object} Recipe_Data
|
|
22
|
+
* @property {module:Markups~Stage} markups
|
|
23
|
+
* @property {boolean} projectQ flag for product/project
|
|
24
|
+
* @property {dateTime} created
|
|
25
|
+
* @property {dateTime} modified
|
|
26
|
+
*/ /**
|
|
27
|
+
* A list of attributes for a product
|
|
28
|
+
* @typedef {Array.String} AttributeList
|
|
29
|
+
*/ /**
|
|
30
|
+
* Array of attribute name/value pairs
|
|
31
|
+
* @typedef {object} AttributeValue
|
|
32
|
+
* @property {string} attibuteName attribute name from attribute list
|
|
33
|
+
* @property {string} value value for the particular attribute
|
|
34
|
+
*/ /**
|
|
35
|
+
* @typedef
|
|
36
|
+
*/ /**
|
|
37
|
+
* Image Descriptor
|
|
38
|
+
* @typedef {object} ProductImage
|
|
39
|
+
* @property {string} altText alt text for the image - SEO etc
|
|
40
|
+
* @property {Array.string} availableFormats Available image sizes.
|
|
41
|
+
* @property {string} id unique id for this productImage
|
|
42
|
+
* @property {integer} orderIndex Position of the image in the product's image list.
|
|
43
|
+
* @property {object} originalSize Image size when first uploaded.
|
|
44
|
+
* @property {MetaData} seoOptions
|
|
45
|
+
* @property {string} URL Absolute URL of the hosted image.
|
|
46
|
+
*/ /**
|
|
47
|
+
* a Brand Object
|
|
48
|
+
* @typedef {object} BrandObject
|
|
49
|
+
* @property {?string} Id Database Id of document (redundant for convenience)
|
|
50
|
+
* @property {?string} refPath if from database, full path to document
|
|
51
|
+
* @property {?AggregateRatingsValue} aggregateRating
|
|
52
|
+
* @property {?URL|ImageObject} logo
|
|
53
|
+
* @property {ReviewObject} review A review of the item. Supersedes reviews
|
|
54
|
+
* @property {text} slogan A slogan or motto associated with the item.
|
|
55
|
+
* @property {Name} name The name of the brand.
|
|
56
|
+
*/ /**
|
|
57
|
+
* Currency Description ISO 4217 currency code
|
|
58
|
+
* @typedef {object} CurrencyDescription
|
|
59
|
+
* @property {string} currencyCode
|
|
60
|
+
* @property {integer} defaultFractionDigits
|
|
61
|
+
* @property {string} displayName
|
|
62
|
+
* @property {string} numericCodeAsString
|
|
63
|
+
* @property {string} symbol
|
|
64
|
+
*/ /**
|
|
65
|
+
* Monetary Value Specification
|
|
66
|
+
* @typedef {object} MonetaryValue
|
|
67
|
+
* @property {CurrencyDescription} currencyDescription
|
|
68
|
+
* @property {decimal} value Decimal monetary value
|
|
69
|
+
* @property {Date} effectiveDate
|
|
70
|
+
*/ /**
|
|
71
|
+
* Pricing Object
|
|
72
|
+
* @typedef {object} FullProductPricing
|
|
73
|
+
* @property {MonetaryValue} basePrice
|
|
74
|
+
* @property {boolean} onSale
|
|
75
|
+
* @property {MonetaryValue} salePrice
|
|
76
|
+
*/ /**
|
|
77
|
+
* Dimensions Object
|
|
78
|
+
* @typedef {object} ProductDimensions
|
|
79
|
+
* @property {float} height
|
|
80
|
+
* @property {float} width
|
|
81
|
+
* @property {float} length
|
|
82
|
+
* @property {text} unit //ProductDimensionsUnit
|
|
83
|
+
*/ /**
|
|
84
|
+
* Price Object
|
|
85
|
+
* @typedef {object} PriceObject
|
|
86
|
+
*
|
|
87
|
+
*/ /**
|
|
88
|
+
* Weight Object
|
|
89
|
+
* @typedef {object} ProductWeight
|
|
90
|
+
* @property {text} unit //ProductWeightUnitEnum
|
|
91
|
+
* @property {float} value
|
|
92
|
+
*/ /**
|
|
93
|
+
* Measurements of the variant when it's shipped. Present for PHYSICAL products only.
|
|
94
|
+
* @typedef {object} ProductMeasurements
|
|
95
|
+
* @property {ProductDimensions} dimensions
|
|
96
|
+
* @property {ProductWeight} weight
|
|
97
|
+
*/ /**
|
|
98
|
+
* @typedef {object} QuantitativeValue
|
|
99
|
+
* @property {Boolean | Number | text | StructuredValue} value
|
|
100
|
+
* The value of a QuantitativeValue (including Observation) or property value node.
|
|
101
|
+
* * For QuantitativeValue and MonetaryAmount, the recommended type for values is 'Number'.
|
|
102
|
+
* * For PropertyValue, it can be 'Text', 'Number', 'Boolean', or 'StructuredValue'.
|
|
103
|
+
* * Use values from 0123456789 (Unicode 'DIGIT ZERO' (U+0030) to 'DIGIT NINE' (U+0039)) rather than superficially similar Unicode symbols.
|
|
104
|
+
* * Use '.' (Unicode 'FULL STOP' (U+002E)) rather than ',' to indicate a decimal point. Avoid using these symbols as a readability separator.
|
|
105
|
+
* @property {number} maxValue The upper value of some characteristic or property.
|
|
106
|
+
* @property {number} minValue The lower value of some characteristic or property.
|
|
107
|
+
* @property {?Text} unitText A string or text indicating the unit of measurement. Useful if you cannot provide a standard unit code for unitCode
|
|
108
|
+
* @property {?Text | URL} unitCode
|
|
109
|
+
* The unit of measurement given using the UN/CEFACT Common Code (3 characters) or a URL. Other codes than the UN/CEFACT Common Code may be used with a prefix followed by a colon
|
|
110
|
+
*
|
|
111
|
+
*/ /**
|
|
112
|
+
* @typedef {object} SizeSpecification
|
|
113
|
+
* @property {Text} type "SizeSpecification"
|
|
114
|
+
* @property {QuantitativeValue} hasMeasurement
|
|
115
|
+
* @property {Array.SizeGroupEnumeration|SizeGroupEnumeration|Text} sizeGroup
|
|
116
|
+
* The size group (also known as "size type") for a product's size. Size groups are common in the fashion industry to define size
|
|
117
|
+
* segments and suggested audiences for wearable products. Multiple values can be combined, for example "men's big and tall", "petite maternity" or "regular".
|
|
118
|
+
* @property {Array.SizeSystemEnumeration|SizeSystemEnumeration|Text} sizeSystem
|
|
119
|
+
* The size system used to identify a product's size. Typically either a standard (for example, "GS1" or "ISO-EN13402"), country
|
|
120
|
+
* code (for example "US" or "JP"), or a measuring system (for example "Metric" or "Imperial").
|
|
121
|
+
* @property {QuantitativeValue} suggestedAge The age or age range for the intended audience or user, for example 3-12 months for infants, 1-5 years for toddlers.
|
|
122
|
+
* @property {GenderType|Text} suggestedGender The suggested gender of the intended user or audience, for example "male", "female", or "unisex".
|
|
123
|
+
* @property {QuantitativeValue} suggestedMeasurement A suggested range of body measurements for the intended audience or user, for example inseam between 32 and 34 inches or
|
|
124
|
+
* height between 170 and 190 cm. Typically found on a size chart for wearable products.
|
|
125
|
+
*/ /**
|
|
126
|
+
* Available stock for the variant. Present for PHYSICAL products only.
|
|
127
|
+
* @typedef {object} ProductStock
|
|
128
|
+
* @property {integer} quantity
|
|
129
|
+
* @property {boolean} unlimited
|
|
130
|
+
*/ /**
|
|
131
|
+
* Meta Information for SEO
|
|
132
|
+
* @typedef {object} MetaData
|
|
133
|
+
* @property {string} title
|
|
134
|
+
* @property {string} description
|
|
135
|
+
*/ /**
|
|
136
|
+
* @typedef {"newborn" | "infant" | "toddler" | "kids" | "adult"} AgeGroupEnum
|
|
137
|
+
* @typedef {"male" | "female" | "unisex"} GenderEnum
|
|
138
|
+
*/ /**
|
|
139
|
+
* Demographics characteristics
|
|
140
|
+
* @typedef {object} Demographics
|
|
141
|
+
* @property {boolean} adultOriented
|
|
142
|
+
* @property {AgeGroupEnum} age_group
|
|
143
|
+
* @property {GenderEnum} gender
|
|
144
|
+
*/ /**
|
|
145
|
+
* List of product ID's for various platforms
|
|
146
|
+
* @typedef {object} PlatformIDs
|
|
147
|
+
* @property {Text} squarespaceId
|
|
148
|
+
* @property {Text} googleMerchantId
|
|
149
|
+
* @property {Text} shopifyId
|
|
150
|
+
*/ /**
|
|
151
|
+
* Squarespace Specific Data
|
|
152
|
+
* @typedef {object} SquarespaceDataObject
|
|
153
|
+
* @property {Text} storePageId
|
|
154
|
+
*/ /**
|
|
155
|
+
* List of Platform Specific Data
|
|
156
|
+
* @typedef {object} PlatformData
|
|
157
|
+
* @property {SquarespaceDataObject} squarespaceData
|
|
158
|
+
*/ /**
|
|
159
|
+
* @typedef {object} AttributeValueObject
|
|
160
|
+
* @property {Text} condition
|
|
161
|
+
* @property {Array.Text} tags
|
|
162
|
+
* @property {Array.Text} colors
|
|
163
|
+
* @property {Array.Text} materials
|
|
164
|
+
* @property {Array.Text} patterns
|
|
165
|
+
* @property {string} custom_label_0
|
|
166
|
+
* @property {string} custom_label_1
|
|
167
|
+
* @property {string} custom_label_2
|
|
168
|
+
* @property {string} custom_label_3
|
|
169
|
+
* @property {string} custom_label_4
|
|
170
|
+
*/ /**
|
|
171
|
+
* @typedef {object} VideoImage
|
|
172
|
+
* @property {URL} video_link
|
|
173
|
+
*/ /**
|
|
174
|
+
* @typedef {object} VirtualModel
|
|
175
|
+
* @property {URL} virtual_model_link
|
|
176
|
+
*/ /**
|
|
177
|
+
* Media Related Data
|
|
178
|
+
* @typedef {object} MediaObject
|
|
179
|
+
* @property {Array.ProductImage} images
|
|
180
|
+
* @property {VideoImage} video_image
|
|
181
|
+
* @property {VirtualModel} virtual_model
|
|
182
|
+
*/ /**
|
|
183
|
+
* variant record (including inventory and pricing)
|
|
184
|
+
* @typedef {object} PhysicalProductVariant
|
|
185
|
+
* @property {PlatformIDs} platformIds
|
|
186
|
+
* @property {string} sku
|
|
187
|
+
* @property {ProductImage} image Image associated with this variant
|
|
188
|
+
* @property {FullProductPricing} pricing
|
|
189
|
+
* @property {ProductStock} stock
|
|
190
|
+
* @property {Array.AttributeValue} attributes array of attribute/value pairs for a variant
|
|
191
|
+
* @property {ProductMeasurements} shippingMeasurements
|
|
192
|
+
* @property {string} gtin Global Trade Item Number
|
|
193
|
+
* @property {string} mpn manufacturer part number
|
|
194
|
+
* @property {ProductMeasurements} productMeasurements
|
|
195
|
+
* @property {SizeSpecification} sizeSpecification
|
|
196
|
+
* @property {"in_stock"|"out_of_stock"|"preorder"|"backorder"} availability
|
|
197
|
+
* Accurately submit the product's availability and match the availability
|
|
198
|
+
* from your landing page, checkout pages, and structured data (for
|
|
199
|
+
* example, “in_stock” or “out_of_stock” in your Schema.org markup).
|
|
200
|
+
* If an item is out of stock, the price must still be clearly visible
|
|
201
|
+
* on the landing page.
|
|
202
|
+
* Provide the availability date [availability_date] attribute if you
|
|
203
|
+
* submit preorder [preorder] or backorder [backorder] as the availability value.
|
|
204
|
+
* @property {string|ISO8601} availability_date
|
|
205
|
+
* Use this attribute if your product's availability is set to preorder.
|
|
206
|
+
* Provide a value up to one year in the future.
|
|
207
|
+
* The availability date should also be added to the product’s landing
|
|
208
|
+
* page and be clear to your customers (for example, “May 6, 2023”).
|
|
209
|
+
* If an exact date can’t be provided, you can use an estimated date
|
|
210
|
+
* (for example, “May 2023”).
|
|
211
|
+
*/ /**
|
|
212
|
+
* a product record
|
|
213
|
+
* @typedef {object} Product
|
|
214
|
+
* @property {?string} Id Database Id of document (redundant for convenience)
|
|
215
|
+
* @property {?string} refPath if from database, full path to document
|
|
216
|
+
* @property {PlatformIDs} platformIds
|
|
217
|
+
* @property {PlatformData} platformData
|
|
218
|
+
* @property {string} name name for the Product
|
|
219
|
+
* @property {string} short_name name for the Product
|
|
220
|
+
* @property {string} description Basic description of the product
|
|
221
|
+
* @property {string} short_description
|
|
222
|
+
* @property {string} google_product_category
|
|
223
|
+
* @property {?string} product_type "casual google_product_category"
|
|
224
|
+
* @property {Text|BrandObject} brand
|
|
225
|
+
* The brand(s) associated with a product or service, or the brand(s) maintained by an organization or business user.
|
|
226
|
+
* @property {Demographics} demographics
|
|
227
|
+
* @property {AttributeValueObject} attributes array of attribute/value pairs for a product
|
|
228
|
+
* @property {Recipe_Data} recipe pricing and fabrication data
|
|
229
|
+
* @property {MediaObject} mediaObject
|
|
230
|
+
* @property {MobileInfo} mobileInfo
|
|
231
|
+
* @property {boolean} isVisible
|
|
232
|
+
* @property {MetaData} seoOptions
|
|
233
|
+
* @property {string} URL
|
|
234
|
+
* @property {string} urlSlug
|
|
235
|
+
* @property {Array.string} variantAttributes
|
|
236
|
+
* @property {Array.PhysicalProductVariant} variants
|
|
237
|
+
*/ /**
|
|
238
|
+
* @readonly
|
|
239
|
+
* @constant
|
|
240
|
+
* @type {Product}
|
|
241
|
+
* @default
|
|
242
|
+
*/ const $e615241e8e7f6b5a$var$ProductDefault = {
|
|
243
|
+
platformIds: {
|
|
244
|
+
squarespaceId: null,
|
|
245
|
+
googleMerchantId: null,
|
|
246
|
+
shopifyId: null
|
|
247
|
+
},
|
|
248
|
+
platformData: {
|
|
249
|
+
squarespaceData: {
|
|
250
|
+
storePageId: null
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
name: null,
|
|
254
|
+
short_name: null,
|
|
255
|
+
description: null,
|
|
256
|
+
short_description: null,
|
|
257
|
+
google_product_category: null,
|
|
258
|
+
product_type: null,
|
|
259
|
+
brand: {
|
|
260
|
+
aggregate_rating: null,
|
|
261
|
+
logo: null,
|
|
262
|
+
review: {},
|
|
263
|
+
slogan: null,
|
|
264
|
+
name: null
|
|
265
|
+
},
|
|
266
|
+
demographics: {
|
|
267
|
+
adultOriented: false,
|
|
268
|
+
age_group: null,
|
|
269
|
+
gender: null
|
|
270
|
+
},
|
|
271
|
+
attributes: [],
|
|
272
|
+
recipe: {
|
|
273
|
+
markups: null,
|
|
274
|
+
projectQ: false,
|
|
275
|
+
created: null,
|
|
276
|
+
modified: null
|
|
277
|
+
},
|
|
278
|
+
mediaObject: {
|
|
279
|
+
images: [],
|
|
280
|
+
video_image: null,
|
|
281
|
+
virtual_model: null
|
|
282
|
+
},
|
|
283
|
+
mobileInfo: null,
|
|
284
|
+
isVisible: true,
|
|
285
|
+
type: "PHYSICAL",
|
|
286
|
+
seoOptions: {
|
|
287
|
+
title: null,
|
|
288
|
+
description: null
|
|
289
|
+
},
|
|
290
|
+
tags: [
|
|
291
|
+
""
|
|
292
|
+
],
|
|
293
|
+
materials: [
|
|
294
|
+
""
|
|
295
|
+
],
|
|
296
|
+
patterns: [
|
|
297
|
+
""
|
|
298
|
+
],
|
|
299
|
+
URL: null,
|
|
300
|
+
urlSlug: null,
|
|
301
|
+
variantAttributes: [],
|
|
302
|
+
variants: []
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Form to create test data
|
|
306
|
+
* @readonly
|
|
307
|
+
* @constant
|
|
308
|
+
* @type {Product}
|
|
309
|
+
* @default
|
|
310
|
+
*/ const $e615241e8e7f6b5a$var$ProductDataForm = {
|
|
311
|
+
Id: `string.uuid`,
|
|
312
|
+
refPath: null,
|
|
313
|
+
name: `commerce.product`,
|
|
314
|
+
description: `commerce.productDescription`,
|
|
315
|
+
sku: `commerce.isbn:${(0, $fefa9c41cb73ae0b$export$dbb3cd0a4caa6254)}`,
|
|
316
|
+
markups: `subrecord:${(0, $fefa9c41cb73ae0b$export$1bfdae073fb20e6c)}`,
|
|
317
|
+
projectQ: `checkbox`
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Form to enter MINIMAL product data to start creation
|
|
321
|
+
* @readonly
|
|
322
|
+
* @constant
|
|
323
|
+
* @type {Product}
|
|
324
|
+
* @default
|
|
325
|
+
*/ const $e615241e8e7f6b5a$var$ProductDefaultForm = {
|
|
326
|
+
Id: `hidden`,
|
|
327
|
+
refPath: `hidden`,
|
|
328
|
+
name: "text",
|
|
329
|
+
description: "textarea",
|
|
330
|
+
sku: "text"
|
|
331
|
+
};
|
|
332
|
+
(0, $lRpTb$Forms).Base[0, $fefa9c41cb73ae0b$export$e36553b0ff5db35a] = $e615241e8e7f6b5a$var$ProductDefault;
|
|
333
|
+
(0, $lRpTb$Forms).BaseForm[0, $fefa9c41cb73ae0b$export$e36553b0ff5db35a] = $e615241e8e7f6b5a$var$ProductDefaultForm;
|
|
334
|
+
(0, $lRpTb$Forms).CreateForm[0, $fefa9c41cb73ae0b$export$e36553b0ff5db35a] = $e615241e8e7f6b5a$var$ProductDefaultForm;
|
|
335
|
+
(0, $lRpTb$Forms).Data[0, $fefa9c41cb73ae0b$export$e36553b0ff5db35a] = $e615241e8e7f6b5a$var$ProductDataForm;
|
|
336
|
+
(0, $lRpTb$Forms).Summarize[0, $fefa9c41cb73ae0b$export$e36553b0ff5db35a] = $e615241e8e7f6b5a$var$summarizeProduct;
|
|
337
|
+
(0, $lRpTb$Forms).Save[0, $fefa9c41cb73ae0b$export$e36553b0ff5db35a] = $e615241e8e7f6b5a$var$updateProduct;
|
|
338
|
+
(0, $lRpTb$Forms).SearchBy[0, $fefa9c41cb73ae0b$export$e36553b0ff5db35a] = "name";
|
|
339
|
+
async function $e615241e8e7f6b5a$export$9c734a715e6666d0() {
|
|
340
|
+
//get a blank Product Record
|
|
341
|
+
//write it to database, saving reference
|
|
342
|
+
//copy user stages to product stages
|
|
343
|
+
//We return the product information - but most applications will use database listeners
|
|
344
|
+
}
|
|
345
|
+
//////////////////////////////////////////////////////////////////////
|
|
346
|
+
// record operations
|
|
347
|
+
/**
|
|
348
|
+
* writes record back to database. Assumes only Id is valid
|
|
349
|
+
* @param {Product} product a partially-populated product record for updates
|
|
350
|
+
* @param {User} user minimal record of user this product belongs to
|
|
351
|
+
* @returns {promise.LineItem} a copy of the data written
|
|
352
|
+
*/ async function $e615241e8e7f6b5a$var$updateProduct(product, user = null) {
|
|
353
|
+
if (!(product?.refPath || user?.refPath)) {
|
|
354
|
+
console.log("no product specified to save LineItem");
|
|
355
|
+
//no root products
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
return (0, $lRpTb$updateRecord)((0, $lRpTb$fillForm)(product, (0, $fefa9c41cb73ae0b$export$e36553b0ff5db35a)), user, (0, $fefa9c41cb73ae0b$export$e36553b0ff5db35a));
|
|
359
|
+
}
|
|
360
|
+
//////////////////////////////////////////////////////////////////////
|
|
361
|
+
// utilities
|
|
362
|
+
/**
|
|
363
|
+
* Returns a standardized formatted name string
|
|
364
|
+
* @param {Unit}
|
|
365
|
+
* @returns {string} formatted name string
|
|
366
|
+
*/ function $e615241e8e7f6b5a$var$summarizeProduct(product) {
|
|
367
|
+
return `${product.name} ${product.description}`;
|
|
368
|
+
}
|
|
369
|
+
function $e615241e8e7f6b5a$export$d4a471daa895146b(child) {
|
|
370
|
+
return (0, $9ab66828811feaa2$export$9536a88c96a1be48)(child, (0, $fefa9c41cb73ae0b$export$e36553b0ff5db35a));
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
export {$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};
|
|
375
|
+
//# sourceMappingURL=InventoryLogic.7741caec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"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","sources":["business/Product/index.js"],"sourcesContent":["/**\n * Typedefs, constants, support functions and database operations related to Products\n * @module Product\n */\nimport { updateRecord } from \"@leaddreamer/firebase-wrapper\";\nimport { Forms, fillForm } from \"@leaddreamer/staticforms\";\n\nimport { PRODUCT, MARKUPS, ISBN_LENGTH } from \"../boilerplate/index.js\";\nimport { typedRecordFromChild } from \"../Utilities/index.js\"\n\n//////////////////////////////////////////////////////////////////////\n// Constants\n\n/**\n * \"recipe\" related values - build-stage markups, product/project Flag, created/modified dates\n * @typedef {object} Recipe_Data\n * @property {module:Markups~Stage} markups\n * @property {boolean} projectQ flag for product/project\n * @property {dateTime} created\n * @property {dateTime} modified\n */\n\n/**\n * A list of attributes for a product\n * @typedef {Array.String} AttributeList\n */\n\n/**\n * Array of attribute name/value pairs\n * @typedef {object} AttributeValue\n * @property {string} attibuteName attribute name from attribute list\n * @property {string} value value for the particular attribute\n */\n\n/**\n * @typedef\n */\n\n/**\n * Image Descriptor\n * @typedef {object} ProductImage\n * @property {string} altText alt text for the image - SEO etc\n * @property {Array.string} availableFormats Available image sizes.\n * @property {string} id unique id for this productImage\n * @property {integer} orderIndex Position of the image in the product's image list.\n * @property {object} originalSize Image size when first uploaded.\n * @property {MetaData} seoOptions\n * @property {string} URL Absolute URL of the hosted image.\n */\n\n/**\n * a Brand Object\n * @typedef {object} BrandObject\n * @property {?string} Id Database Id of document (redundant for convenience)\n * @property {?string} refPath if from database, full path to document\n * @property {?AggregateRatingsValue} aggregateRating\n * @property {?URL|ImageObject} logo\n * @property {ReviewObject} review A review of the item. Supersedes reviews\n * @property {text} slogan A slogan or motto associated with the item.\n * @property {Name} name The name of the brand.\n */\n\n/**\n * Currency Description ISO 4217 currency code\n * @typedef {object} CurrencyDescription\n * @property {string} currencyCode\n * @property {integer} defaultFractionDigits\n * @property {string} displayName\n * @property {string} numericCodeAsString\n * @property {string} symbol\n */\n\n/**\n * Monetary Value Specification\n * @typedef {object} MonetaryValue\n * @property {CurrencyDescription} currencyDescription\n * @property {decimal} value Decimal monetary value\n * @property {Date} effectiveDate\n */\n\n/**\n * Pricing Object\n * @typedef {object} FullProductPricing\n * @property {MonetaryValue} basePrice\n * @property {boolean} onSale\n * @property {MonetaryValue} salePrice\n */\n\n/**\n * Dimensions Object\n * @typedef {object} ProductDimensions\n * @property {float} height \n * @property {float} width \n * @property {float} length \n * @property {text} unit //ProductDimensionsUnit\n */\n\n/**\n * Price Object\n * @typedef {object} PriceObject\n * \n */\n\n/**\n * Weight Object\n * @typedef {object} ProductWeight\n * @property {text} unit //ProductWeightUnitEnum\n * @property {float} value\n */\n\n/**\n * Measurements of the variant when it's shipped. Present for PHYSICAL products only.\n * @typedef {object} ProductMeasurements\n * @property {ProductDimensions} dimensions\n * @property {ProductWeight} weight\n */\n\n/**\n * @typedef {object} QuantitativeValue\n * @property {Boolean | Number | text | StructuredValue} value\n * The value of a QuantitativeValue (including Observation) or property value node.\n * * For QuantitativeValue and MonetaryAmount, the recommended type for values is 'Number'.\n * * For PropertyValue, it can be 'Text', 'Number', 'Boolean', or 'StructuredValue'.\n * * Use values from 0123456789 (Unicode 'DIGIT ZERO' (U+0030) to 'DIGIT NINE' (U+0039)) rather than superficially similar Unicode symbols.\n * * Use '.' (Unicode 'FULL STOP' (U+002E)) rather than ',' to indicate a decimal point. Avoid using these symbols as a readability separator.\n * @property {number} maxValue The upper value of some characteristic or property.\n * @property {number} minValue The lower value of some characteristic or property.\n * @property {?Text} unitText A string or text indicating the unit of measurement. Useful if you cannot provide a standard unit code for unitCode\n * @property {?Text | URL} unitCode \n * The unit of measurement given using the UN/CEFACT Common Code (3 characters) or a URL. Other codes than the UN/CEFACT Common Code may be used with a prefix followed by a colon\n * \n */\n\n/**\n * @typedef {object} SizeSpecification\n * @property {Text} type \"SizeSpecification\"\n * @property {QuantitativeValue} hasMeasurement\n * @property {Array.SizeGroupEnumeration|SizeGroupEnumeration|Text} sizeGroup\n * The size group (also known as \"size type\") for a product's size. Size groups are common in the fashion industry to define size\n * segments and suggested audiences for wearable products. Multiple values can be combined, for example \"men's big and tall\", \"petite maternity\" or \"regular\".\n * @property {Array.SizeSystemEnumeration|SizeSystemEnumeration|Text} sizeSystem\n * The size system used to identify a product's size. Typically either a standard (for example, \"GS1\" or \"ISO-EN13402\"), country\n * code (for example \"US\" or \"JP\"), or a measuring system (for example \"Metric\" or \"Imperial\").\n * @property {QuantitativeValue} suggestedAge The age or age range for the intended audience or user, for example 3-12 months for infants, 1-5 years for toddlers.\n * @property {GenderType|Text} suggestedGender The suggested gender of the intended user or audience, for example \"male\", \"female\", or \"unisex\".\n * @property {QuantitativeValue} suggestedMeasurement A suggested range of body measurements for the intended audience or user, for example inseam between 32 and 34 inches or\n * height between 170 and 190 cm. Typically found on a size chart for wearable products.\n */\n\n/**\n * Available stock for the variant. Present for PHYSICAL products only.\n * @typedef {object} ProductStock\n * @property {integer} quantity\n * @property {boolean} unlimited\n */\n\n/**\n * Meta Information for SEO\n * @typedef {object} MetaData\n * @property {string} title\n * @property {string} description\n */\n\n/**\n * @typedef {\"newborn\" | \"infant\" | \"toddler\" | \"kids\" | \"adult\"} AgeGroupEnum\n * @typedef {\"male\" | \"female\" | \"unisex\"} GenderEnum\n */\n\n/**\n * Demographics characteristics\n * @typedef {object} Demographics\n * @property {boolean} adultOriented\n * @property {AgeGroupEnum} age_group\n * @property {GenderEnum} gender\n */\n\n/**\n * List of product ID's for various platforms\n * @typedef {object} PlatformIDs\n * @property {Text} squarespaceId\n * @property {Text} googleMerchantId\n * @property {Text} shopifyId\n */\n\n/**\n * Squarespace Specific Data\n * @typedef {object} SquarespaceDataObject\n * @property {Text} storePageId\n */\n\n/**\n * List of Platform Specific Data\n * @typedef {object} PlatformData\n * @property {SquarespaceDataObject} squarespaceData\n */\n\n/**\n * @typedef {object} AttributeValueObject\n * @property {Text} condition\n * @property {Array.Text} tags\n * @property {Array.Text} colors\n * @property {Array.Text} materials\n * @property {Array.Text} patterns\n * @property {string} custom_label_0\n * @property {string} custom_label_1\n * @property {string} custom_label_2\n * @property {string} custom_label_3\n * @property {string} custom_label_4\n */\n\n/**\n * @typedef {object} VideoImage\n * @property {URL} video_link\n */\n\n/**\n * @typedef {object} VirtualModel\n * @property {URL} virtual_model_link\n */\n\n/**\n * Media Related Data\n * @typedef {object} MediaObject\n * @property {Array.ProductImage} images\n * @property {VideoImage} video_image\n * @property {VirtualModel} virtual_model \n */\n\n/**\n * variant record (including inventory and pricing)\n * @typedef {object} PhysicalProductVariant\n * @property {PlatformIDs} platformIds\n * @property {string} sku\n * @property {ProductImage} image Image associated with this variant\n * @property {FullProductPricing} pricing\n * @property {ProductStock} stock\n * @property {Array.AttributeValue} attributes array of attribute/value pairs for a variant\n * @property {ProductMeasurements} shippingMeasurements\n * @property {string} gtin Global Trade Item Number\n * @property {string} mpn manufacturer part number\n * @property {ProductMeasurements} productMeasurements\n * @property {SizeSpecification} sizeSpecification\n * @property {\"in_stock\"|\"out_of_stock\"|\"preorder\"|\"backorder\"} availability\n * Accurately submit the product's availability and match the availability\n * from your landing page, checkout pages, and structured data (for\n * example, “in_stock” or “out_of_stock” in your Schema.org markup).\n * If an item is out of stock, the price must still be clearly visible\n * on the landing page.\n * Provide the availability date [availability_date] attribute if you\n * submit preorder [preorder] or backorder [backorder] as the availability value.\n * @property {string|ISO8601} availability_date\n * Use this attribute if your product's availability is set to preorder.\n * Provide a value up to one year in the future.\n * The availability date should also be added to the product’s landing\n * page and be clear to your customers (for example, “May 6, 2023”).\n * If an exact date can’t be provided, you can use an estimated date\n * (for example, “May 2023”).\n */\n\n/**\n * a product record\n * @typedef {object} Product\n * @property {?string} Id Database Id of document (redundant for convenience)\n * @property {?string} refPath if from database, full path to document\n * @property {PlatformIDs} platformIds\n * @property {PlatformData} platformData\n * @property {string} name name for the Product\n * @property {string} short_name name for the Product\n * @property {string} description Basic description of the product\n * @property {string} short_description\n * @property {string} google_product_category\n * @property {?string} product_type \"casual google_product_category\"\n * @property {Text|BrandObject} brand\n * The brand(s) associated with a product or service, or the brand(s) maintained by an organization or business user.\n * @property {Demographics} demographics\n * @property {AttributeValueObject} attributes array of attribute/value pairs for a product\n * @property {Recipe_Data} recipe pricing and fabrication data\n * @property {MediaObject} mediaObject\n * @property {MobileInfo} mobileInfo\n * @property {boolean} isVisible\n * @property {MetaData} seoOptions\n * @property {string} URL\n * @property {string} urlSlug\n * @property {Array.string} variantAttributes\n * @property {Array.PhysicalProductVariant} variants\n */\n\n/**\n * @readonly\n * @constant\n * @type {Product}\n * @default\n */\nconst ProductDefault = {\n platformIds: {\n squarespaceId: null,\n googleMerchantId: null,\n shopifyId: null\n },\n platformData: {\n squarespaceData: {\n storePageId: null\n }\n },\n name: null,\n short_name: null,\n description: null,\n short_description: null,\n google_product_category: null,\n product_type: null,\n brand: {\n aggregate_rating: null,\n logo: null,\n review: {},\n slogan: null,\n name: null\n },\n demographics: {\n adultOriented: false,\n age_group: null,\n gender: null\n },\n attributes: [],\n recipe: {\n markups: null,\n projectQ: false,\n created: null,\n modified: null,\n },\n mediaObject: {\n images: [],\n video_image: null,\n virtual_model: null\n },\n mobileInfo: null,\n isVisible: true,\n type: \"PHYSICAL\",\n seoOptions: {\n title: null,\n description: null,\n },\n tags: [\"\"],\n materials: [\"\"],\n patterns: [\"\"],\n URL: null,\n urlSlug: null,\n variantAttributes: [],\n variants: []\n};\n\n/**\n * Form to create test data\n * @readonly\n * @constant\n * @type {Product}\n * @default\n */\nconst ProductDataForm = {\n Id: `string.uuid`,\n refPath: null,\n name: `commerce.product`,\n description: `commerce.productDescription`,\n sku: `commerce.isbn:${ISBN_LENGTH}`,\n markups: `subrecord:${MARKUPS}`,\n projectQ: `checkbox`\n};\n\n/**\n * Form to enter MINIMAL product data to start creation\n * @readonly\n * @constant\n * @type {Product}\n * @default\n */\nconst ProductDefaultForm = {\n Id: `hidden`,\n refPath: `hidden`,\n name: \"text\",\n description: \"textarea\",\n sku: \"text\",\n};\n\nForms.Base[PRODUCT] = ProductDefault;\nForms.BaseForm[PRODUCT] = ProductDefaultForm;\nForms.CreateForm[PRODUCT] = ProductDefaultForm;\nForms.Data[PRODUCT] = ProductDataForm;\nForms.Summarize[PRODUCT] = summarizeProduct;\nForms.Save[PRODUCT] = updateProduct;\nForms.SearchBy[PRODUCT] = \"name\";\n\n//////////////////////////////////////////////////////////////////////\n// business operations\n\n/**\n * Creates a new Blank Product\n * @param {UserObject} user minimal record of user this commodity belongs to (if any)\n * @returns {Promise<void>}\n */\n\nexport async function createProduct() {\n //get a blank Product Record\n //write it to database, saving reference\n //copy user stages to product stages\n //We return the product information - but most applications will use database listeners\n};\n\n\n//////////////////////////////////////////////////////////////////////\n// record operations\n\n/**\n * writes record back to database. Assumes only Id is valid\n * @param {Product} product a partially-populated product record for updates\n * @param {User} user minimal record of user this product belongs to\n * @returns {promise.LineItem} a copy of the data written\n */\nasync function updateProduct(product, user = null) {\n if (!(product?.refPath || user?.refPath)) {\n console.log(\"no product specified to save LineItem\");\n //no root products\n return null;\n };\n\n return updateRecord(\n fillForm(product, PRODUCT), //saves only APPROPRIATE fields -does NOT populate missing fields\n user,\n PRODUCT\n );\n}\n\n//////////////////////////////////////////////////////////////////////\n// utilities\n\n/**\n * Returns a standardized formatted name string\n * @param {Unit}\n * @returns {string} formatted name string\n */\nfunction summarizeProduct(product) {\n return `${product.name} ${product.description}`;\n}\n/**\n * @param {Record} child a record assumed to be a leaf/child\n * @returns {Record}\n */\nexport function makeProductFromChild(child) {\n return typedRecordFromChild(child, PRODUCT);\n}\n\nexport * from \"./GoogleMerchantAPI.js\";\nexport * from \"./Squarespace.js\"\n"],"names":[],"version":3,"file":"InventoryLogic.7741caec.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$InventoryLogicf4627c8ajs from "./InventoryLogic.f4627c8a.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.78480e5e.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.78480e5e.js.map"}
|