## Classes

<dl>
<dt><a href="#BatchedQueueClient">BatchedQueueClient</a></dt>
<dd><p>Creates a new BatchedQueueClient. It allows to read and write from a SQS queue in batches,
supporting larger batch sizes than the default of 10. If a message gets too big for SQS it is
automatically swapped out to S3.</p>
</dd>
</dl>

## Constants

<dl>
<dt><a href="#INDEX_CONFIGURATION_NAME">INDEX_CONFIGURATION_NAME</a></dt>
<dd><p>Name of the indexing configuration, subject to be renamed.</p>
</dd>
</dl>

## Functions

<dl>
<dt><a href="#calculateContentBusId">calculateContentBusId(ctx, info)</a> ⇒ <code>Promise.&lt;(string|null)&gt;</code></dt>
<dd><p>Retrieves the content bus id by calculating the hash from the fstab.</p>
</dd>
<dt><a href="#getContentBusId">getContentBusId(ctx, info, optional)</a> ⇒ <code>Promise.&lt;string&gt;</code></dt>
<dd><p>Retrieves the content bus id either from the context or by reading fstab entry of
helix-config.json. If the helix-config.json does contain the information (yet) it will fall back
to <a href="#calculateContentBusId">#calculateContentBusId</a>.</p>
</dd>
<dt><a href="#handleResponse">handleResponse(log, response, key, type)</a> ⇒ <code>Promise.&lt;ConfigAll&gt;</code></dt>
<dd><p>Checks if the response is valid and returns the project config.</p>
</dd>
<dt><a href="#fetchConfigAll">fetchConfigAll(ctx, opts)</a> ⇒ <code>Promise.&lt;ConfigAll&gt;</code></dt>
<dd><p>Retrieves the project config from the underlying storage
and stores it in the context as projectConfig.</p>
</dd>
<dt><a href="#handleResponse">handleResponse(log, response, key, type)</a> ⇒ <code>Promise.&lt;ProjectConfig&gt;</code></dt>
<dd><p>Checks if the response is valid and returns the project config.</p>
</dd>
<dt><a href="#fetchProjectConfig">fetchProjectConfig(ctx, opts)</a> ⇒ <code>Promise.&lt;ProjectConfig&gt;</code></dt>
<dd><p>Retrieves the project config from the underlying storage
and stores it in the context as projectConfig.</p>
</dd>
<dt><a href="#handleResponse">handleResponse(log, response, key, type)</a> ⇒ <code>Promise.&lt;ProjectConfig&gt;</code></dt>
<dd><p>Checks if the response is valid and returns the project config.</p>
</dd>
<dt><a href="#fetchCrontab">fetchCrontab(ctx, opts)</a> ⇒ <code>Promise.&lt;ProjectConfig&gt;</code></dt>
<dd><p>Retrieves the project config from the underlying storage
and stores it in the context as projectConfig.</p>
</dd>
<dt><a href="#handleResponse">handleResponse(log, response, key, type)</a> ⇒ <code>Promise.&lt;MountConfig&gt;</code></dt>
<dd><p>Checks if the response is valid and returns a mount config.</p>
</dd>
<dt><a href="#fetchFstab">fetchFstab(ctx, opts, optional)</a> ⇒ <code>Promise.&lt;MountConfig&gt;</code></dt>
<dd><p>Retrieves the fstab from the underlying storage and stores it in the context as mountConfig.</p>
</dd>
<dt><a href="#handleResponse">handleResponse(log, response, key, type)</a> ⇒ <code>Promise.&lt;HelixConfig&gt;</code></dt>
<dd><p>Checks if the response is valid and returns the helix config.</p>
</dd>
<dt><a href="#fetchHelixConfig">fetchHelixConfig(ctx, info, optional)</a> ⇒ <code>Promise.&lt;HelixConfig&gt;</code></dt>
<dd><p>Retrieves the helix-config.json which is an aggregate from fstab.yaml and head.html.
Note: it always uses the branch <code>main</code>.</p>
</dd>
<dt><a href="#handleResponse">handleResponse(log, response, key)</a> ⇒ <code>Promise.&lt;MountConfig&gt;</code></dt>
<dd><p>Checks if the response is valid and returns a IgnoreConfig.</p>
</dd>
<dt><a href="#fetchIgnore">fetchIgnore(ctx, opts)</a> ⇒ <code>Promise.&lt;IgnoreConfig&gt;</code></dt>
<dd><p>Retrieves the hlxignore from github and stores it in the context as IgnoreConfig.
If 404 is encountered, returns an empty IgnoreConfig that considers nothing ignored.</p>
</dd>
<dt><a href="#handleResponse">handleResponse(log, response, key, type)</a> ⇒ <code>Promise.&lt;IndexConfig&gt;</code></dt>
<dd><p>Checks if the response is valid and returns an index config.</p>
</dd>
<dt><a href="#fetchIndex">fetchIndex(ctx, opts, optional)</a> ⇒ <code>Promise.&lt;IndexConfig&gt;</code></dt>
<dd><p>Retrieves the indexing configuration from the underlying storage and stores it in the context as
indexConfig.</p>
</dd>
<dt><a href="#fetchS3">fetchS3(bucketId, key, head)</a> ⇒ <code>Promise.&lt;Response&gt;</code></dt>
<dd><p>Fetches content from s3</p>
</dd>
<dt><a href="#handleResponse">handleResponse(log, response, key, type)</a> ⇒ <code>Promise.&lt;SitemapConfig&gt;</code></dt>
<dd><p>Checks if the response is valid and returns a sitemap config.</p>
</dd>
<dt><a href="#fetchSitemap">fetchSitemap(ctx, opts, optional)</a> ⇒ <code>Promise.&lt;SitemapConfig&gt;</code></dt>
<dd><p>Retrieves the sitemap from the underlying storage and stores it in the context as sitemapConfig.</p>
</dd>
<dt><a href="#flatJson2object">flatJson2object(rows, [keyName], [valueName])</a></dt>
<dd><p>Converts a config row-based name/value pair array with dotted key notation to an object.</p>
<p>example:</p>
<pre><code>host: www.adobe.com
document.level: 42,
document.title: hello
document.body.status: 200
acl.allow: /foo
acl.allow: /bar
cnd.0.type: fastly
cnd.0.host: www.adobe.com
cnd.1.type: cloudflare
</code></pre>
<p>becomes:</p>
<pre><code>{
  host: &#39;www.adobe.com&#39;,
  document: {
    level: 42,
    title: &#39;hello&#39;,
    body: {
      status: 200,
    }
  },
  acl: {
    allow: [&#39;/foo&#39;, &#39;/bar],
  }
  cnd: [
    { type: &#39;fastly&#39;, host: &#39;www.adobe.com&#39; },
    { type: &#39;cloudflare&#39; },
  ]
}
</code></pre>
</dd>
<dt><a href="#error">error(message, status)</a> ⇒ <code>Response</code></dt>
<dd><p>Generates an error response</p>
</dd>
</dl>

## Typedefs

<dl>
<dt><a href="#BatchedQueueClientOpts">BatchedQueueClientOpts</a></dt>
<dd></dd>
</dl>

<a name="INDEX_CONFIGURATION_NAME"></a>

## INDEX\_CONFIGURATION\_NAME
Name of the indexing configuration, subject to be renamed.

**Kind**: global constant  
<a name="calculateContentBusId"></a>

## calculateContentBusId(ctx, info) ⇒ <code>Promise.&lt;(string\|null)&gt;</code>
Retrieves the content bus id by calculating the hash from the fstab.

**Kind**: global function  
**Returns**: <code>Promise.&lt;(string\|null)&gt;</code> - the content bus id or {@code null}
                                if no fstab or no mountpoint not found in fstab  

| Param | Type | Description |
| --- | --- | --- |
| ctx | <code>AdminContext</code> | the context |
| info | <code>PathInfo</code> | lookup options |

<a name="getContentBusId"></a>

## getContentBusId(ctx, info, optional) ⇒ <code>Promise.&lt;string&gt;</code>
Retrieves the content bus id either from the context or by reading fstab entry of
helix-config.json. If the helix-config.json does contain the information (yet) it will fall back
to [#calculateContentBusId](#calculateContentBusId).

**Kind**: global function  
**Returns**: <code>Promise.&lt;string&gt;</code> - the content bus id  

| Param | Type | Description |
| --- | --- | --- |
| ctx | <code>AdminContext</code> | the context |
| info | <code>PathInfo</code> | lookup options |
| optional | <code>boolean</code> | if {@code true} it will return {@code null} if none of the sources                           exists. |

<a name="handleResponse"></a>

## handleResponse(log, response, key, type) ⇒ <code>Promise.&lt;ConfigAll&gt;</code>
Checks if the response is valid and returns the project config.

**Kind**: global function  
**Returns**: <code>Promise.&lt;ConfigAll&gt;</code> - the helix project config or null  

| Param | Type | Description |
| --- | --- | --- |
| log | <code>Console</code> | logger |
| response | <code>Response</code> | content response from the storage |
| key | <code>string</code> | storage key (logging information) |
| type | <code>string</code> | type of storage (logging information) |

<a name="fetchConfigAll"></a>

## fetchConfigAll(ctx, opts) ⇒ <code>Promise.&lt;ConfigAll&gt;</code>
Retrieves the project config from the underlying storage
and stores it in the context as projectConfig.

**Kind**: global function  
**Returns**: <code>Promise.&lt;ConfigAll&gt;</code> - the project configuration  

| Param | Type | Description |
| --- | --- | --- |
| ctx | <code>AdminContext</code> | the context |
| opts | <code>PathInfo</code> | lookup options |

<a name="handleResponse"></a>

## handleResponse(log, response, key, type) ⇒ <code>Promise.&lt;ProjectConfig&gt;</code>
Checks if the response is valid and returns the project config.

**Kind**: global function  
**Returns**: <code>Promise.&lt;ProjectConfig&gt;</code> - the helix project config or null  

| Param | Type | Description |
| --- | --- | --- |
| log | <code>Console</code> | logger |
| response | <code>Response</code> | content response from the storage |
| key | <code>string</code> | storage key (logging information) |
| type | <code>string</code> | type of storage (logging information) |

<a name="fetchProjectConfig"></a>

## fetchProjectConfig(ctx, opts) ⇒ <code>Promise.&lt;ProjectConfig&gt;</code>
Retrieves the project config from the underlying storage
and stores it in the context as projectConfig.

**Kind**: global function  
**Returns**: <code>Promise.&lt;ProjectConfig&gt;</code> - the project configuration  

| Param | Type | Description |
| --- | --- | --- |
| ctx | <code>AdminContext</code> | the context |
| opts | <code>PathInfo</code> | lookup options |

<a name="handleResponse"></a>

## handleResponse(log, response, key, type) ⇒ <code>Promise.&lt;ProjectConfig&gt;</code>
Checks if the response is valid and returns the project config.

**Kind**: global function  
**Returns**: <code>Promise.&lt;ProjectConfig&gt;</code> - the helix project config or null  

| Param | Type | Description |
| --- | --- | --- |
| log | <code>Logger</code> | logger |
| response | <code>Response</code> | content response from the storage |
| key | <code>string</code> | storage key (logging information) |
| type | <code>string</code> | type of storage (logging information) |

<a name="fetchCrontab"></a>

## fetchCrontab(ctx, opts) ⇒ <code>Promise.&lt;ProjectConfig&gt;</code>
Retrieves the project config from the underlying storage
and stores it in the context as projectConfig.

**Kind**: global function  
**Returns**: <code>Promise.&lt;ProjectConfig&gt;</code> - the project configuration  

| Param | Type | Description |
| --- | --- | --- |
| ctx | <code>AdminContext</code> | the context |
| opts | <code>LookupOptions</code> | lookup options |

<a name="handleResponse"></a>

## handleResponse(log, response, key, type) ⇒ <code>Promise.&lt;MountConfig&gt;</code>
Checks if the response is valid and returns a mount config.

**Kind**: global function  
**Returns**: <code>Promise.&lt;MountConfig&gt;</code> - the mount config or null  

| Param | Type | Description |
| --- | --- | --- |
| log | <code>Logger</code> | logger |
| response | <code>Response</code> | content response from the storage |
| key | <code>string</code> | storage key (logging information) |
| type | <code>string</code> | type of storage (logging information |

<a name="fetchFstab"></a>

## fetchFstab(ctx, opts, optional) ⇒ <code>Promise.&lt;MountConfig&gt;</code>
Retrieves the fstab from the underlying storage and stores it in the context as mountConfig.

**Kind**: global function  
**Returns**: <code>Promise.&lt;MountConfig&gt;</code> - the fstab  

| Param | Type | Description |
| --- | --- | --- |
| ctx | <code>AdminContext</code> | the context |
| opts | <code>LookupOptions</code> | lookup options |
| optional | <code>boolean</code> | if {@code true}, no error is thrown if the fstab can't be retrieved |

<a name="handleResponse"></a>

## handleResponse(log, response, key, type) ⇒ <code>Promise.&lt;HelixConfig&gt;</code>
Checks if the response is valid and returns the helix config.

**Kind**: global function  
**Returns**: <code>Promise.&lt;HelixConfig&gt;</code> - the index config or null  

| Param | Type | Description |
| --- | --- | --- |
| log | <code>Logger</code> | logger |
| response | <code>Response</code> | content response from the storage |
| key | <code>string</code> | storage key (logging information) |
| type | <code>string</code> | type of storage (logging information |

<a name="fetchHelixConfig"></a>

## fetchHelixConfig(ctx, info, optional) ⇒ <code>Promise.&lt;HelixConfig&gt;</code>
Retrieves the helix-config.json which is an aggregate from fstab.yaml and head.html.
Note: it always uses the branch `main`.

**Kind**: global function  
**Returns**: <code>Promise.&lt;HelixConfig&gt;</code> - the helix-config or {@code null} if optional and not found.  

| Param | Type | Description |
| --- | --- | --- |
| ctx | <code>AdminContext</code> | the context |
| info | <code>PathInfo</code> | path info |
| optional | <code>boolean</code> | if {@code true} returns null if not found |

<a name="handleResponse"></a>

## handleResponse(log, response, key) ⇒ <code>Promise.&lt;MountConfig&gt;</code>
Checks if the response is valid and returns a IgnoreConfig.

**Kind**: global function  
**Returns**: <code>Promise.&lt;MountConfig&gt;</code> - the IgnoreConfig  
**Throws**:

- <code>Error(&#x27;Unable to fetch hlxignore&#x27;)</code> 


| Param | Type | Description |
| --- | --- | --- |
| log | <code>Logger</code> | logger |
| response | <code>Response</code> | content response from the storage |
| key | <code>string</code> | storage key (logging information) |

<a name="fetchIgnore"></a>

## fetchIgnore(ctx, opts) ⇒ <code>Promise.&lt;IgnoreConfig&gt;</code>
Retrieves the hlxignore from github and stores it in the context as IgnoreConfig.
If 404 is encountered, returns an empty IgnoreConfig that considers nothing ignored.

**Kind**: global function  
**Returns**: <code>Promise.&lt;IgnoreConfig&gt;</code> - the IgnoreConfig  

| Param | Type | Description |
| --- | --- | --- |
| ctx | <code>AdminContext</code> | the context |
| opts | <code>LookupOptions</code> | lookup options |

<a name="handleResponse"></a>

## handleResponse(log, response, key, type) ⇒ <code>Promise.&lt;IndexConfig&gt;</code>
Checks if the response is valid and returns an index config.

**Kind**: global function  
**Returns**: <code>Promise.&lt;IndexConfig&gt;</code> - the index config or null  

| Param | Type | Description |
| --- | --- | --- |
| log | <code>Logger</code> | logger |
| response | <code>Response</code> | content response from the storage |
| key | <code>string</code> | storage key (logging information) |
| type | <code>string</code> | type of storage (logging information |

<a name="fetchIndex"></a>

## fetchIndex(ctx, opts, optional) ⇒ <code>Promise.&lt;IndexConfig&gt;</code>
Retrieves the indexing configuration from the underlying storage and stores it in the context as
indexConfig.

**Kind**: global function  
**Returns**: <code>Promise.&lt;IndexConfig&gt;</code> - the index config  

| Param | Type | Description |
| --- | --- | --- |
| ctx | <code>AdminContext</code> | the context |
| opts | <code>LookupOptions</code> | lookup options |
| optional | <code>boolean</code> | if {@code true}, no error is thrown if the config can't be retrieved |

<a name="fetchS3"></a>

## fetchS3(bucketId, key, head) ⇒ <code>Promise.&lt;Response&gt;</code>
Fetches content from s3

**Kind**: global function  
**Returns**: <code>Promise.&lt;Response&gt;</code> - fetch api response  
**Oaram**: <code>AdminContext</code> context the admin context  

| Param | Type | Description |
| --- | --- | --- |
| bucketId | <code>string</code> | bucket id |
| key | <code>string</code> | the resource key |
| head | <code>boolean</code> | flag indicating to create a head request |

<a name="handleResponse"></a>

## handleResponse(log, response, key, type) ⇒ <code>Promise.&lt;SitemapConfig&gt;</code>
Checks if the response is valid and returns a sitemap config.

**Kind**: global function  
**Returns**: <code>Promise.&lt;SitemapConfig&gt;</code> - the sitemap config or null  

| Param | Type | Description |
| --- | --- | --- |
| log | <code>Logger</code> | logger |
| response | <code>Response</code> | content response from the storage |
| key | <code>string</code> | storage key (logging information) |
| type | <code>string</code> | type of storage (logging information |

<a name="fetchSitemap"></a>

## fetchSitemap(ctx, opts, optional) ⇒ <code>Promise.&lt;SitemapConfig&gt;</code>
Retrieves the sitemap from the underlying storage and stores it in the context as sitemapConfig.

**Kind**: global function  
**Returns**: <code>Promise.&lt;SitemapConfig&gt;</code> - the sitemap configuration  

| Param | Type | Description |
| --- | --- | --- |
| ctx | <code>AdminContext</code> | the context |
| opts | <code>LookupOptions</code> | lookup options |
| optional | <code>boolean</code> | if {@code true}, no error is thrown if the config can't be retrieved |

<a name="flatJson2object"></a>

## flatJson2object(rows, [keyName], [valueName])
Converts a config row-based name/value pair array with dotted key notation to an object.

example:

```
host: www.adobe.com
document.level: 42,
document.title: hello
document.body.status: 200
acl.allow: /foo
acl.allow: /bar
cnd.0.type: fastly
cnd.0.host: www.adobe.com
cnd.1.type: cloudflare
```

becomes:

```
{
  host: 'www.adobe.com',
  document: {
    level: 42,
    title: 'hello',
    body: {
      status: 200,
    }
  },
  acl: {
    allow: ['/foo', '/bar],
  }
  cnd: [
    { type: 'fastly', host: 'www.adobe.com' },
    { type: 'cloudflare' },
  ]
}
```

**Kind**: global function  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| rows | <code>Array.&lt;object&gt;</code> |  | array of columns |
| [keyName] | <code>string</code> | <code>&quot;&#x27;key&#x27;&quot;</code> | name of the key column. |
| [valueName] | <code>string</code> | <code>&quot;&#x27;value&#x27;&quot;</code> | name of the value column. |

<a name="error"></a>

## error(message, status) ⇒ <code>Response</code>
Generates an error response

**Kind**: global function  
**Returns**: <code>Response</code> - A response object.  

| Param | Type | Description |
| --- | --- | --- |
| message | <code>string</code> | error message |
| status | <code>number</code> | error code. |

<a name="BatchedQueueClientOpts"></a>

## BatchedQueueClientOpts
**Kind**: global typedef  
**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [log] | <code>Console</code> | <code>Console</code> | Console like logger |
| [maxSqsPollTime] | <code>number</code> | <code>20</code> | Time to poll for messages |
| inQueue | <code>string</code> |  | Name of the receiving queue |
| outQueue | <code>string</code> |  | Name of the output queue |
| s3ClientOpts | <code>object</code> |  | S3 client options |
| sqsClientOpts | <code>object</code> |  | SQS client options |
| headerKeys | <code>Array.&lt;string&gt;</code> |  | Name of the properties that common to all message properties |
| swapBucket | <code>string</code> |  | Name of the bucket used for swap space |
| swapPrefix | <code>string</code> |  | Prefix for the swap objects |

