Module: cpb-api/common

Members

(static, constant) accumulator

summary reducer calculator

Source:

Methods

(static) getProductIdFromFileName(name) → {number|undefined}

Parameters:
Name Type Description
name
Source:
Returns:
Type
number | undefined

(static) getProductIdsFromFiles(files) → {Array(number[], number[])}

gets array of shopify product id's from the files on cloud storage bucket where the dir is request.params('id')
with trailing forward slash appended ( the prefix )

Parameters:
Name Type Description
files Array.<Object>

array of files returned by gcs api

Source:
Returns:

ids, deletedId - shopify product ids

Type
Array(number[], number[])

(static) groupFiles(files, versionsopt, nullable) → {GroupedFiles}

groups files by name, adds versions array to each file, & calculates the stats (counters)

Parameters:
Name Type Attributes Default Description
files Array.<Object>

array of files returned by gcs api

versions boolean <optional>
<nullable>
true
Source:
Returns:
Type
GroupedFiles
Example
[
  [ 1864679522368 ], // products
  [ 1545018852513735 ], //deletedProducts
  {  // productConfigs
     "1864679522368": {
      "name": "1864679522368.json",
       "path": "10039296064/1864679522368.json",
       "versions": [
                     {
                "id": "custom-product-builder/10039296064/1864679522368.json/1545026853482573",
                "generation": 1545026853482573,
                "metadata": {
                    "name": "10039296064/1864679522368.json",
                    "md5Hash": "hJ4zFV1TRwWqBz6h4NjHhw==",
                    "crc32c": "F6w/kw==",
                    "timeCreated": "2018-12-17T06:07:33.482Z",
                    "updated": "2018-12-17T06:07:33.482Z",
                    "timeDeleted": "2018-12-17T06:08:26.690Z"
                },
                "isDeleted": true,
                "isCurrent": false,
                "size": 13743,
                "url":
  "https://storage.googleapis.com/download/storage/v1/b/custom-product-builder/o/10039296064%2F1864679522368.json?generation=1545026853482573&alt=media"
                },
                {
                  "id": "custom-product-builder/10039296064/1864679522368.json/1545026906691128",
                  "generation": 1545026906691128,
                  "metadata": {
                    "name": "10039296064/1864679522368.json",
                    "md5Hash": "VUowmTd+trJuzWnIXk3T9Q==",
                    "crc32c": "Aov/rA==",
                    "timeCreated": "2018-12-17T06:08:26.690Z",
                    "updated": "2018-12-17T06:08:26.690Z"
                  },
                "isDeleted": false,
                "isCurrent": true,
                "size": 13879,
                "url":
  "https://storage.googleapis.com/download/storage/v1/b/custom-product-builder/o/10039296064%2F1864679522368.json?generation=1545026906691128&alt=media"
                }